[antlr-interest] "Best practice" for contructing AST
Paul J. Lucas
pauljlucas at mac.com
Fri Sep 17 16:33:22 PDT 2004
If I have, say, an XML parser in ANTLR and I want to, say,
construct an AST for an XML element attribute list, what's
considered "best practice" for it?
Specifically, given:
<foo bar="1" baz="2">Hello</foo>
Method 1 generated AST:
ELEMENT
QNAME "foo"
ATTRIBUTE_LIST
ATTRIBUTE
QNAME "bar"
VALUE 1
ATTRIBUTE
QNAME "baz"
VALUE 2
CONTENT "Hello"
Method 2 generated AST:
ELEMENT
QNAME "foo"
ATTRIBUTE
QNAME "bar"
VALUE 1
ATTRIBUTE
QNAME "baz"
VALUE 2
CONTENT "Hello"
Method 2 differs from Method 1 in that there's no
ATTRIBUTE_LIST. It's not strictly needed since one "knows"
that attibutes always come before element content.
But does eliding ATTRIBUTE_LIST generally make things easier or
harder?
- Paul
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list