[antlr-interest] Composite Grammar

Terence Parr parrt at cs.usfca.edu
Tue Mar 4 14:28:06 PST 2008


yes, see

examples-v3.1b1.tar.gz

i have a java grammar broken into multiple pieces :)

/** Exact same grammar as examples-v3/java/Java.g but broken into
  *  multiple pieces to illustrate composing grammars via import  
statement.
  *  Results in multiple classes with Java referring to others via
  *  delegation pattern.  Run ANTLR only once on this root grammar:
  *
  *      java org.antlr.Tool Java.g
  */
grammar Java;
options {k=2; backtrack=true; memoize=true;}

import JavaDecl, JavaAnnotations, JavaExpr, JavaStat, JavaLexerRules;

compilationUnit
     :   annotations?
         packageDeclaration?
         importDeclaration*
         typeDeclaration*
     ;

Ter

On Mar 4, 2008, at 2:19 PM, Fred wrote:

> I know this question is about a new feature but...
> Is there an example of Composite Grammar using the new features of  
> 3.1?
> Even if it were in the class notes that would be fine.
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080304/df3383bf/attachment.html 


More information about the antlr-interest mailing list