[antlr-interest] rewrite smth like "type: (primitive|complex) multiplicity?"
Felix Dorner
felix_do at web.de
Thu Mar 6 05:05:31 PST 2008
Felix Dorner wrote:
> Hey,
>
> I have a grammar rule for specifying the type of a variable.
>
> vardef : Identifier ':' type;
> type : (PrimitiveType | complexType) ('['IntegerLiteral']')?;
>
> PrimitiveType : 'int' | 'boolean';
> complexType : Identifier ('*' Identifier)* -> Identifier+;
>
Ok, I could rewrite the rules like that:
type : basetype ('['IntegerLiteral']')? -> ^(TYPE basetype IntegerLiteral?)
basetype : Primitivetype | complexType
...
Anyway, comments are welcome.
Felix
More information about the antlr-interest
mailing list