At 18:28 3/12/2008, virg g wrote: >ok. Is there anyway i can mention the commands and its paramters >without mentioning them in the quotes?
Yes -- either declare a named token for it instead (as you did for TESTCMD) or define an explicit lexer rule: CMD : 'CMD'; Then you can refer to it as CMD in all the parser rules instead of 'CMD', and it'll have a nicer name in the generated code to boot. Eliminating quoted constants from parser rules like this will also let you group all of your lexer rules together in one place, making it easier to spot surprises and harder to forget that ANTLR is not a scannerless parser. >The literal rule is combination of "OR" of Number, ALPHA and >STRING. So for the command " TESTCMD CNT=2 VAL=TYPE:CNT" where >for VAL paramters CNT will match ALPHA lexer rule right? as it >works if it is "TEST". Otherwise i have to add expilcitely all >the quoted values to "literal" rule like this. sorry if >understanding is wrong. > >literal : (NUMBER|ALPHA|STRING |TESTCMD|'CNT'|'VAL'|'TYPE') Nope, that's exactly right (that you do have to explicitly mention them, I mean). As each of those are unique token types, if you want 'literal' to match all of them then you have to actually mention all of them. Despite the string "CNT" being *compatible* with the rule ALPHA, the simple fact is that when the lexer ran it didn't generate an ALPHA, it generated a CNT (or a T14, or whatever). The parser doesn't know that this is acceptable where an ALPHA is unless you tell it. List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org:8080/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 il-antlr-interest@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---