Troubleshooting Parse Error for Flex and Bison

Click For Summary
SUMMARY

The discussion centers on troubleshooting a parse error encountered while developing an assignment statements parser using Flex and Bison. The user initially faced issues with token recognition, which were resolved by identifying discrepancies in the #define values for token types between the Windows and Unix versions of Bison. The user learned that the header file created from the C file generated on Windows did not match the Unix environment, leading to the parse errors. This highlights the importance of ensuring compatibility between development and production environments when using Flex and Bison.

PREREQUISITES
  • Understanding of Flex and Bison syntax and functionality
  • Familiarity with C programming and header file usage
  • Knowledge of cross-platform development issues
  • Experience with debugging parse errors in parser generators
NEXT STEPS
  • Research how to manage cross-platform compatibility in Flex and Bison projects
  • Learn about debugging techniques for Flex and Bison parsers
  • Explore the differences between Windows and Unix implementations of Bison
  • Study best practices for defining and managing token types in parser generators
USEFUL FOR

Students and developers working on compiler design, specifically those using Flex and Bison for parsing tasks, as well as anyone troubleshooting cross-platform development issues in parser implementations.

Dissident Dan
Messages
244
Reaction score
1
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?
 
Computer science news on Phys.org
Would it be possible to post your lex file?
 
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.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 2 ·
Replies
2
Views
10K
  • · Replies 4 ·
Replies
4
Views
4K
Replies
1
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • Sticky
  • · Replies 0 ·
Replies
0
Views
24K
  • Sticky
  • · Replies 0 ·
Replies
0
Views
18K
  • Sticky
  • · Replies 1 ·
Replies
1
Views
27K