PDA

View Full Version : Lex & Yacc


Dissident Dan
Dec6-04, 05:29 PM
I've got an assignment for a class in which I'm supposed to make an assignment statements parser using Lex and Yacc...well, actually variants called Flex and Bison.

I am having major problems getting this to work. It will recognize one token or character and then give a "parse error".

I noticed that if I remove the return statements from my Lex rules, it is able to continue parsing without giving me the dreaded "parse error", but then I lose the functionality that I need for Yacc to be able to parse the tokens.

Does anyone have any idea of what's going on?

kwatz
Dec7-04, 09:54 AM
Would it be possible to post your lex file?

Dissident Dan
Dec7-04, 10:41 AM
I should have done that.

Anyway, I figured it out. As always, it was something really simple and stupid. I am working on a Windows machine, but then I upload my files to Unix machine and run the program there.

As you know, you have to copy the #defines for the token types from the C file generated by Bison (Yacc) to a header file that is included by the Flex (Lex) file. Well, It turns out that the sharp define values are different by 1 between the Windows version of Bison that I am using on my own comp and the Unix version on the remote PC. I made the header file from the C file generated on my computer, so when I tried to run it on Unix, the #defines didn't match, and that gave me the parse errors.