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"); } ;

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to