split two single character will be fail, i am mad now

15 views
Skip to first unread message

Peter Cheung

unread,
Aug 24, 2017, 12:48:24 AM8/24/17
to antlr-discussion
Hi All
    This:
data : 'db' WS 'Aa'
   Can match

db Aa

    But this can't, why?
data : 'db' WS 'A' 'a'


Why fail after split 'Aa' to 'A' 'a' ?

Thanks
from Peter (mche...@hotmail.com)

Jim Idle

unread,
Aug 24, 2017, 2:19:37 AM8/24/17
to antlr-di...@googlegroups.com
As you did not send your lexer rules, it is difficult to say but you probably have another rule that conflicts with this one. 

Remember that you can debug the generated code and find out what the lexer does. 

Jim


From: antlr-di...@googlegroups.com <antlr-di...@googlegroups.com> on behalf of Peter Cheung <mche...@gmail.com>
Sent: Thursday, August 24, 2017 5:48:24 AM
To: antlr-discussion
Subject: [antlr-discussion] split two single character will be fail, i am mad now
 
--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mike Lischke

unread,
Aug 24, 2017, 3:59:17 AM8/24/17
to antlr-di...@googlegroups.com

> This:
> data : 'db' WS 'Aa'
> Can match
>
> db Aa
>
> But this can't, why?
> data : 'db' WS 'A' 'a'
>
>
> Why fail after split 'Aa' to 'A' 'a' ?

In cases like that where you don't get the expected tokens, print your token list to see if it really gives what you would like to see. Use your CommonTokenStream instance to get the token list (if you do that before parsing call fill() first).

Mike
--
www.soft-gems.net

Peter Cheung

unread,
Aug 30, 2017, 12:37:18 PM8/30/17
to antlr-discussion
Super thanks

Jim Idle於 2017年8月24日星期四 UTC+8下午2時19分37秒寫道:
Reply all
Reply to author
Forward
0 new messages