dcsimg
Simple Grammar parsing incorrectly
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Siddhartha_Azad
Posted On:   Monday, August 1, 2005 05:05 PM

Hi, Following is an excerpt from my Lexer Rules. STAR : '*' ; DOUBLE_FRAC_INT : (DOT)(INT) | (INT '/') => (INT)'/'(INT) | ((INT)(DOT)) => (INT)(DOT)(INT) | (INT) ; protected DOT : '.' ; INT : ('0'..'9')+ ; When I feed it the string: ".2*.223*4 *" I get the following tokens: .2, .223, 4 and *. I don't understand why its not giving me the asterisks (STAR) after the .2 and .223. It looks like its consuming them to check the next character and not putting it back in the stream and hence losing these. Please help.    More>>

Hi,
Following is an excerpt from my Lexer Rules.



			


STAR :
'*'
;

DOUBLE_FRAC_INT :
(DOT)(INT)
| (INT '/') => (INT)'/'(INT)
| ((INT)(DOT)) => (INT)(DOT)(INT)
| (INT)
;

protected

DOT :
'.'
;


INT :
('0'..'9')+
;





When I feed it the string: ".2*.223*4 *" I get the following tokens: .2, .223, 4 and *. I don't understand why its not giving me the asterisks (STAR) after the .2 and .223. It looks like its consuming them to check the next character and not putting it back in the stream and hence losing these.
Please help.
Thanks, Sid.
p.s.: Using C++ on Solaris    <<Less
About | Sitemap | Contact