Pegged: error I am unable to fix

Lubos Pintes lubos.pintes at gmail.com
Mon Oct 15 03:24:27 PDT 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() {

}


More information about the Digitalmars-d-learn mailing list