Pegged: Syntax Highlighting
Andrej Mitrovic
andrej.mitrovich at gmail.com
Wed Mar 28 08:55:54 PDT 2012
On 3/27/12, Philippe Sigaud <philippe.sigaud at gmail.com> wrote:
> snip
Philippe your example on this wiki page doesn't seem to work:
https://github.com/PhilippeSigaud/Pegged/wiki/
import pegged.grammar;
mixin(grammar(
"Expr <- Factor AddExpr*
AddExpr <- ('+'/'-') Factor
Factor <- Primary MulExpr*
MulExpr <- ('*'/'/') Primary
Primary <- Parens / Number / Variable / '-' Primary
Parens <- '(' Expr ')'
Number <~ [0-9]+
Variable <- Identifier"));
void main()
{
auto parseTree2 = Expr.parse(" 0 + 123 - 456 ");
writeln(parseTree2.capture);
}
["Expr failure at pos [index: 0, line: 0, col: 0]", "Factor failure at
pos [index: 0, line: 0, col: 0]", "Primary failure at pos [index: 0,
line: 0, col: 0]", "Parens failure at pos [index: 0, line: 0, col:
0]", "Lit!(() failure at pos [index: 0, line: 0, col: 0]"]
More information about the Digitalmars-d-announce
mailing list