BNF for EtchGrammar.jj

TOKENS

/*
 * Tokens to ignore in the BNF follow.
 */
<DEFAULT> SKIP : {
" "
| "\t"
| "\r"
| "\n"
| "\f"
| <SINGLE1: "//" (~["\r","\n"])* ["\r","\n"]>
| <SINGLE2: "#" (~["\r","\n"])* ["\r","\n"]>
}

   
<DEFAULT> SPECIAL : {
<FORMAL: "/**" (~["*"])* "*" ("*" | ~["*","/"] (~["*"])* "*")* "/">
| <BLOCK: "/*" (~["*"])* "*" ("*" | ~["*","/"] (~["*"])* "*")* "/">
}

   
<DEFAULT> TOKEN : {
<BOOLEAN: "boolean">
| <BYTE: "byte">
| <CONST: "const">
| <DOUBLE: "double">
| <ENUM: "enum">
| <EXCEPTION: "exception">
| <EXTENDS: "extends">
| <EXTERN: "extern">
| <FALSE: "false">
| <FLOAT: "float">
| <INCLUDE: "include">
| <INT: "int">
| <LONG: "long">
| <MIXIN: "mixin">
| <MODULE: "module">
| <NULL: "null">
| <OBJECT: "object">
| <SERVICE: "service">
| <SHORT: "short">
| <STRING: "string">
| <STRUCT: "struct">
| <THROWS: "throws">
| <TRUE: "true">
| <VOID: "void">
| <ID: ["a"-"z","A"-"Z"] (["a"-"z","A"-"Z","0"-"9","_"])*>
| <QID: <ID> ("." <ID>)+>
| <#INT_LIT: ["1"-"9"] (["0"-"9"])*>
| <#SGN: (["-"])?>
| <INTEGER: <SGN> ("0" | <INT_LIT>)>
| <OCTAL: "0" (["0"-"7"])+>
| <HEX: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+>
| <BINARY: "0" ["b","B"] (["0"-"1"])+>
| <#EXP: ["e","E"] <INTEGER>>
| <#FRACTION: <SGN> "." (["0"-"9"])+>
| <DECIMAL: <INTEGER> ("." (["0"-"9"])*)? <EXP> | <INTEGER> "." (["0"-"9"])* (<EXP>)? | <FRACTION> (<EXP>)?>
| <STR: "\"" (~["\"","\\","\r","\n"] | "\\" ["\"","\\","r","n","t"] | "\\u" (["0"-"9","a"-"f","A"-"F"]){4,-1})* "\"">
| <AT: "@">
| <COMMA: ",">
| <EQ: "=">
| <SEMI: ";">
| <LPAREN: "(">
| <RPAREN: ")">
| <LBRACE: "{">
| <RBRACE: "}">
| <LBRACKET: "[">
| <RBRACKET: "]">
}

   

NON-TERMINALS

module ::= module_stmt service
module_stmt ::= <MODULE> xid ( <SEMI> )?
service ::= opts <SERVICE> def <LBRACE> stmts <RBRACE>
opts ::= ( opt )*
opt ::= <AT> id ( <LPAREN> args <RPAREN> )?
args ::= arg ( <COMMA> arg )*
arg ::= ( cvalue | xid | <NULL> )
cvalue ::= ( <TRUE> | <FALSE> | <INTEGER> | <OCTAL> | <HEX> | <BINARY> | <DECIMAL> | <STR> )
stmts ::= ( opts ( mixin_stmt | include_stmt | const_stmt | enum_stmt | struct_stmt | extern_stmt | exception_stmt | message_stmt ) )*
mixin_stmt ::= <MIXIN> ref ( <SEMI> )?
include_stmt ::= <INCLUDE> <STR> ( <SEMI> )?
const_stmt ::= <CONST> ctype def <EQ> cvalue ( <SEMI> )?
enum_stmt ::= <ENUM> def <LPAREN> item_list <RPAREN> ( <SEMI> )?
item_list ::= def ( <COMMA> def )*
struct_stmt ::= <STRUCT> def params ( <EXTENDS> ref )? ( <SEMI> )?
extern_stmt ::= <EXTERN> def ( <SEMI> )?
exception_stmt ::= <EXCEPTION> def params ( <EXTENDS> ref )? ( <SEMI> )?
message_stmt ::= rtype def params ( <THROWS> throws_list )? ( <SEMI> )?
throws_list ::= ref ( <COMMA> ref )*
id ::= <ID>
qid ::= <QID>
xid ::= ( qid | id )
def ::= id
ref ::= xid
ctype ::= ( <BOOLEAN> | <BYTE> | <SHORT> | <INT> | <LONG> | <FLOAT> | <DOUBLE> | <STRING> )
ptype ::= ( ctype | <OBJECT> | ref )
rtype ::= ( ( ptype dim ) | <VOID> )
dim ::= ( <LBRACKET> <RBRACKET> )*
params ::= <LPAREN> ( param ( <COMMA> param )* )? <RPAREN>
param ::= ptype dim def