[antlr-interest] Would somebody help me clarify the difference between AST, Tree Grammars, and Parse Trees?
ANTLR Mailing List
jstpierre-antlr at mecheye.net
Sun Oct 14 15:57:12 PDT 2007
I need a good example/explanation between the difference between tree
grammars, ASTs and Parse Trees.
I see that grammars don't have to be tree grammars to output ASTs.
This is very confusing to me...
For a simple grammar to test:
// Begin Grammar
grammar TestGrammar;
options {
output = AST;
k = 10;
}
tokens {
STAT;
SEMI = ';';
}
program : statement *;
statement
: expression SEMI;
expression
: INT;
INT : ( '0'..'9' ) +;
// End Grammar
When removing "output = AST", I see no difference in the output generated by
ANTLRWorks.
When putting "tree " in front of "grammar TestGrammar", it fails and
generates a NullPointerException.
Anybody have an explanation?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20071014/c9f2e50a/attachment.html
More information about the antlr-interest
mailing list