// VRML `deluxe': better, smaller syntax and generic/extensible field types options { USER_TOKEN_MANAGER=false; STATIC=false; ERROR_REPORTING=false; } /* scoping rules: * USE and ROUTE refer to the lexically most recent DEF. * The scene root, and each PROTO and Inline statement has a separate scope. */ PARSER_BEGIN(VrmlParser) public class VrmlParser { VrmlParser() {} //construct(String ) {} print(String s) { System.err.println(s); } } PARSER_END(VrmlParser) <*> SKIP : { "\n" |"\r" |" " |"\t" |"," // |"\f" } <*> SPECIAL_TOKEN : { } void vrmlScene(): {} { ( statement() )* } void statement(): {} { nodeStatement() { } | protoStatement() { } | routeStatement() { } } void nodeStatement(): {} { node() {} | nodeNameId() node() {} | nodeNameId() {} } TOKEN : { | } void rootNodeStatement(): {} { node() {} | nodeNameId() node() {} } void protoStatement(): {} { proto() {} | externproto() {} } void proto(): {} { nodeTypeId() ( interfaceDeclaration() )* protoBody() {} } TOKEN : { | | | | } void protoBody(): {} { ( protoStatement() )* rootNodeStatement() ( statement() )* {} } // this new nonterminal was introduced to reduce redundancy in grammar void commonInterfaceDeclaration(): {} { fieldType() eventInId() {} | fieldType() eventOutId() {} } void restrictedInterfaceDeclaration(): {} { commonInterfaceDeclaration() | fieldType() fieldId() fieldValue() {} } TOKEN : { | | | } void interfaceDeclaration(): {} { restrictedInterfaceDeclaration() | fieldType() fieldId() fieldValue() {} } void externproto(): {} { nodeTypeId() ( externInterfaceDeclaration() )* URLList() {} } TOKEN : { | } void externInterfaceDeclaration(): {} { commonInterfaceDeclaration() | fieldType() fieldId() | fieldType() fieldId() } void routeStatement(): {} { nodeNameId() eventOutId() nodeNameId() eventInId() } TOKEN : { | } // The spec prescribes mfstringValue() rather than fieldValue(). We use the // more generic fieldValue() here, and leave type checking to semantic // analysis. void URLList(): {} { fieldValue() } void node(): {} { nodeTypeId() ( nodeBodyElement() )* |