Thread overview
Pegged: error I am unable to fix
Oct 15, 2012
Lubos Pintes
Oct 15, 2012
Philippe Sigaud
Oct 15, 2012
Lubos Pintes
October 15, 2012
Hi,
I wanted to write very simple Markup lexer, that would recognize HTML/XML tags, not structurally, only lexically.
DMD generates some error which I don't understand, either there is a problem in my grammar, or possibly a bug in Pegged:

import pegged.grammar;
import pegged.peg;
enum mp=`
MarkupParser:
Markup <- Spacing (Tag / Text)* :eoi

Text <~ (! '<' .)*

Tag <- StartTag / EndTag

StartTag <- '<' Name Attr* '>'

EndTag < "</" Name '>'

Attr < Name ('=' Value)?

Name <- (alpha / Alpha) (alpha / Alpha / digit / '-' / '_' / ':' / '.')*

Value <- SQValue / DQValue / CharValue

SQValue <~ :"'" (! "'" .)* :"'"

DQValue <~ :'"' (! '"' .)* :'"'

CharValue <~ (!(Spacing / '>') .)*
`;

mixin(grammar(mp));
void main() {

}
October 15, 2012
On Mon, Oct 15, 2012 at 12:24 PM, Lubos Pintes <lubos.pintes@gmail.com> wrote:

> SQValue <~ :"'" (! "'" .)* :"'"
>
> DQValue <~ :'"' (! '"' .)* :'"'

Hi,

that came from the code generated for the quote and double-quote
literals. I have trouble finding a resilient way to produce code
dealing with ", when some template arguments are strings themselves.
Even r"  " and q{  } do not work perfectly.
Anyway, I chose `  ` this time and your example now works with the
latest Git HEAD (I pushed a few minutes ago)

You can also use the predefined 'quote' and 'doublequote' (also, 'backquote' and 'backslash') rules in your own rules.

To get my attention more efficiently, could you please post any trouble using the git issues system?

https://github.com/PhilippeSigaud/Pegged/issues?direction=desc&sort=created&state=open


Philippe
October 15, 2012
Hi,
Of course I can. But I "evaluated" this as my failure coming from fact that D is new to me. So I was not sure if this is a bug in Pegged. So I wrote here.

Dňa 15. 10. 2012 14:01 Philippe Sigaud  wrote / napísal(a):
> On Mon, Oct 15, 2012 at 12:24 PM, Lubos Pintes <lubos.pintes@gmail.com> wrote:
>
>> SQValue <~ :"'" (! "'" .)* :"'"
>>
>> DQValue <~ :'"' (! '"' .)* :'"'
>
> Hi,
>
> that came from the code generated for the quote and double-quote
> literals. I have trouble finding a resilient way to produce code
> dealing with ", when some template arguments are strings themselves.
> Even r"  " and q{  } do not work perfectly.
> Anyway, I chose `  ` this time and your example now works with the
> latest Git HEAD (I pushed a few minutes ago)
>
> You can also use the predefined 'quote' and 'doublequote' (also,
> 'backquote' and 'backslash') rules in your own rules.
>
> To get my attention more efficiently, could you please post any
> trouble using the git issues system?
>
> https://github.com/PhilippeSigaud/Pegged/issues?direction=desc&sort=created&state=open
>
>
> Philippe
>