[antlr-interest] Summary/Cheat Sheet?

Gerald B. Rosenberg gbr at newtechlaw.com
Tue May 31 15:44:08 PDT 2005


Found this all-to-brief syntax summary in an old non-Antlr mailing 
list.  Anyone have something similar that is more complete?  In particular, 
including summary descriptions of the LT, LA, $, #, ##, n:TOKEN (variable 
reference) constructs.

Have not seen it in the Antlr.org documentation, but think that it would be 
a good addition.

Thanks,
Gerald


===================================================
ANTLR grammars are written in a kind of EBNF, which makes them very
readable:

rule
         :       TOKEN
         |       nonterminal
         |       (optional)?
         |       (zero_or_more)*
         |       (one_or_more)?
         ;

syntactic_predicates                    // finite lookahead, back-tracking
         :       (A A b) => A A b
         |       (A)* b
         ;

semantic_predicates
         :       { conditional_code; } => rule
         |       { conditional_code; } => rule
         |       foo
         ;

automatic Abstract Syntax Tree generation with grammar annotations (^):

mult_expr
         :       add_expr ((STAR^ | SLASH^) add_expr)
         ;

add_expr
         :       atom ((PLUS^ | MINUS^) atom)
         ;

----
Gerald B. Rosenberg, Esq.
NewTechLaw
285 Hamilton Avenue, Suite 520
Palo Alto, CA  94301-2576

650.325.2100  (office)  /  650.703.1724  (cell)
650.325.2107  (facsimile)

www.newtechlaw.com


CONFIDENTIALITY NOTICE:  This email message (including any attachments) is 
being sent by an attorney, is for the sole use of the intended recipient, 
and may contain confidential and privileged information.  Any unauthorized 
review, use, disclosure or distribution is prohibited.  If you are not the 
intended recipient, please contact the sender immediately by reply e-mail 
and delete all copies of this message and any attachments without retaining 
a copy. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050531/51e98501/attachment.html


More information about the antlr-interest mailing list