what is the trick? why that 3 lines simple grammar does not recognize my character?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   deniz_toprak
Posted On:   Monday, November 26, 2007 02:39 AM

I wrote a sample grammar shown below;

grammar sample;

mainRule : TWOCHARS
;

NCHAR : 'N'
;

TWOCHARS : 'A' | 'N'
;


That is all and i am trying to recognize 'N' (without quote)character but it gives MismatchTokenException. What do i miss? What is the error? Why it does not recognize over mainRule->TWOCHARS->'N' simply?

Re[2]: what is the trick? why that 3 lines simple grammar does not recognize my character?

Posted By:   deniz_toprak  
Posted On:   Friday, November 30, 2007 02:11 AM

you mean two rule can not refer to same lexer??

Re: what is the trick? why that 3 lines simple grammar does not recognize my character?

Posted By:   Anonymous  
Posted On:   Thursday, November 29, 2007 03:02 AM


Hi,



You should remove your NCHAR rule because it conflicts with the TWOCHARS rule.



Writing:




grammar test;



mainRule : TWOCHARS ;




TWOCHARS : 'A' | 'N' ;




should suffice.


Regards,
Fouad
About | Sitemap | Contact