On Mon, Dec 1, 2008 at 1:00 PM, Gavin Lambert <[EMAIL PROTECTED]> wrote:
> At 18:56 1/12/2008, virg g wrote: > >> If the command is >> TESTCMD CNT=2 VAL=TYPE:CNT >> >> It returs error "EarlyExitException" , if i change lexer rules i get >> Mismatchtokenexception. But command is never successful. I have figured out >> that If the literal contains any of these keywords CNT, VAL, TYPE, RTEST >> parsing fails, that means it igonres these tokens while parsing by parser >> eventhough these tokens(eg CNT) is/are created by Lexer. >> How can i resolve this kind of problems. I cannot avoid having these >> tokens in my command as the literal can be any of form. Really i am stuck >> here. >> > > Step 1: realise that using quoted literals in parser rules results in > automatic creation of corresponding lexer rules with a funny name. It's > often clearer if you try to avoid doing this. ok. Is there anyway i can mention the commands and its paramters without mentioning them in the quotes? > > Step 2: realise that in ANTLR, the lexer runs to completion up front and > outside of parser control. So parser context has no influence on how things > get tokenised. > > Step 3: notice how your 'literal' rule doesn't mention any of the other > literal tokens mentioned in step 1, so it's not surprising that it doesn't > match them. 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') > Step 4: realise that you can now fix it. > > ... > > Step N: profit! :) > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address
