dcsimg
Parser accepting invalid input.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   iram_seduiv
Posted On:   Sunday, December 3, 2006 08:14 AM

Hi, I'm starting a project consisting in a kind of compiler and I've reached the first problem too much earlier than I thought. The idea is parsing simple assignaments: a=1; test=2; c=5; and so on.. My lexer works fine: IDENT reads characters, NUMBER reads numbers, OPERATOR reads '=' character and SEPARATOR reads ';' But when I enter the text: c=5;======== the parser accepts it as valid. I think the lexer sends the OPERATOR lexemes to the parser and it does not throw any error because it's a known lexeme although it's not in the place where it should be. The rule, as you can guess is: IDENT OPERATOR N   More>>

Hi, I'm starting a project consisting in a kind of compiler and I've reached the first problem too much earlier than I thought.


The idea is parsing simple assignaments:


a=1;

test=2;

c=5;

and so on..


My lexer works fine: IDENT reads characters, NUMBER reads numbers, OPERATOR reads '=' character and SEPARATOR reads ';'


But when I enter the text:


c=5;========


the parser accepts it as valid.


I think the lexer sends the OPERATOR lexemes to the parser
and it does not throw any error because it's a known lexeme although it's not in the place where it should be. The rule, as you can guess is: IDENT OPERATOR NUMBER SEPARATOR. (blanks are ignored and OPERATOR is not used in another place else)



Thanks in advance for any kind of help.

   <<Less
About | Sitemap | Contact