[antlr-interest] Help - Populating AST with Type Info
William Koscho
wkoscho at gmail.com
Sat Mar 27 17:32:31 PDT 2010
Hi All,
I'm trying to build an AST with type information, but the grammar I'm
using is ambiguious, and I'm not sure how to fix it. The grammar
below can match the input string "component abc { }" using rule
componentDef or interfaceDef.
How can I fix this and still populate the AST with Type information?
elementDef : componentDef | interfaceDef ;
componentDef : ( type ID '{' interfaceRef* '}' ) -> ^(type ID interfaceRef*);
interfaceDef : ( type ID '{' messageDef* '}' ) -> ^(type ID messageDef*);
type returns [Type t] :
'component' { $t = (Type)m_symbolTable.resolve("component"); }
| 'interface' { $t = (Type)m_symbolTable.resolve("interface"); }
| 'message' { $t = (Type)m_symbolTable.resolve("message"); } ;
More information about the antlr-interest
mailing list