[antlr-interest] Heterogeneous trees

Peter Kronenberg PKronenberg at technicacorp.com
Tue May 3 08:04:44 PDT 2005


I'm writing a parser that builds a heterogeneous tree.  The nodes are
based on the token type.  But I'm having a problem when a predicate is
needed to determine the correct token type.  Here's a contrived example.
An IDENT followed by SPECIAL1, I want to create a SPECIAL1 AST.  But an
IDENT by itself should be reflected as a SPECIAL2 type.
Before I added the different AST's, this parser worked, but now, the
IDENT node is just created using the default type.  How can I get it to
honor the AST that's specified in the tokens section?

tokens {
  SPECIAL1<AST=Special1AST>;
  SPECIAL2<AST=Special2AST>;
}

expr: (IDENT SPECIAL1)=> IDENT SPECIAL^ | i:IDENT^ {#i.setType(SPECIAL2)


Peter Kronenberg
Software Engineer
(703) 885-1222
pkronenberg at technicacorp.com


The information contained in this transmission may contain privileged and confidential information. It is intended only for the use of the person(s) named above. If you are not the intended recipient, you are hereby notified that any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. Technica Corporation does not represent this e-mail to be free from any virus, fault or defect and it is therefore the responsibility of the recipient to first scan it for viruses, faults and defects. To reply to our e-mail administrator directly, please send an e-mail to postmaster at technicacorp.com. Thank you.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050503/11b99b37/attachment-0001.html


More information about the antlr-interest mailing list