Ooops  what a mistake ...
Thanks Chris. Now working like a charm!  :)

- Siddharth

On Wed, Nov 26, 2008 at 4:15 PM, Chris Rebert <[EMAIL PROTECTED]> wrote:
> On Wed, Nov 26, 2008 at 2:34 AM, Siddharth Karandikar
> <[EMAIL PROTECTED]> wrote:
>> Hi All!
>>
>> I am a newbie here and trying to test out few things with Antlr-v3.
>> Following is what I have written to parse quoted string and print that
>> parsed string on console.
>> For this I referred to StringLiteral definition in Java.g But somehow,
>> grammar written by me is not working. Am I doing something really
>> stupid?
>>
>> Thanks,
>> Siddharth
>>
>> Grammar -
>>
>> grammar Test;
>>
>> literal : q=quoted
>>  {
>>    System.out.println("q=>"+$q.text);
>>  };
>>
>> quoted : '"' ( EscapeSequence | ~('\\'|'"') )* '"' ;
>
> I believe quoted is supposed to be a lexer rule and thus must start
> with a capital letter (i.e. Quoted), although all-caps is preferred
> (i.e. QUOTED).
> Otherwise, ANTLR thinks it's a parser rule, and it's obviously not
> very sensible as a parser rule, hence the error.
>
> Cheers,
> Chris
> --
> Follow the path of the Iguana...
> http://rebertia.com
>
>>
>> fragment
>> EscapeSequence : '\\' ('\"'|'\''|'\\') ;
>>
>> WS  :  (' '|'\r'|'\t'|'\u000C'|'\n') {$channel=HIDDEN;}
>>    ;
>>
>>
>> Errors that I get -
>>
>> $ java -classpath .:output/:../../antlr-3.1.jar Run
>> "abcd ABCD"
>> line 1:1 no viable alternative at character 'a'
>> line 1:2 no viable alternative at character 'b'
>> line 1:3 no viable alternative at character 'c'
>> line 1:4 no viable alternative at character 'd'
>> line 1:6 no viable alternative at character 'A'
>> line 1:7 no viable alternative at character 'B'
>> line 1:8 no viable alternative at character 'C'
>> line 1:9 no viable alternative at character 'D'
>> q=>" "
>>
>> List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
>> Unsubscribe: 
>> http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address
>>
>>
>

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 [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