At 13:12 5/05/2009, Matthew M. Burke wrote: >1) I could go with something that matches '<' ID expr* '>' and then >in the parser action, I can test ID.text and act as appropriate > >or > >2) I could do something like > >lhs > : '<' 'array' expr '>' -> ^(ARRAY_REF expr) > | '<' 'socket' expr '>' -> ^(SOCKET_REF expr) > | ... > ; > >Is either alternative especially better than the other?
In general, option #2 is more efficient -- but you need to bear in mind that it'll introduce new top-level lexer tokens, and thus "array" will always be treated as a single token (with an obscure generated name), not as an ID or some other token. So if "array" is not always a keyword in your language then you'll need a bit more intelligence in your identifier-matching (eg. id : ID | 'array' | 'socket';) or go with option #1 instead. (If you want to avoid the obscurely-named tokens, then you should avoid using quoted constants in parser rules and just create the corresponding lexer rules yourself.) 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 -~----------~----~----~----~------~----~------~--~---
