Hey all,
This is my first time posting on GoExpert, so I'm excited to see what the community here has to offer! Anyway, I am currently working on creating a compiler (using Flex and Bison) in C for a subset of the Pascal programming language in my Compilers course... and to be honest - I'm a bit stuck!
I think I've made a lot of progress but, I'm getting stuck on this transition from Semantic Analysis to Code Generation... and what's worse is I'm not entirely sure I've gotten the semantic Analysis part all down!
I've created a Lex file (.l), a Bison/YACC file for my grammar (parser), a symbol table file that holds my insert() and lookup() methods for the symbol records, as well as a code generation file as well (although, there are some pieces of code in here that I'm unsure about - on how I translated the code ( ie. STORE/JUMP instructions).
Anyway, let me get to the specific question/request: I need some help modifying my .y Bison file to install, generate code, and back patch labels the different parts of the Pascal grammar. For Example:
Here's a small snippet of my grammar (starting symbol):
program: program_header block PERIOD
;
program_header: PROGRAM IDENT SEMICOLON { install( $2 ); }
;
** where install( $2 ) installs the identifier (symbol name) into the symbol table. **
** where lowercase are non-terminals and UPPERCASE are terminals (Keywords in Pascal) **
I really have plenty of questions and would probably bog down this forum post if I went into any more random detail... if you have any clue about Compiler Design using Flex/Lex and Bison/YACC, I would REALLY appreciate your attention and help. I could and probably would need to go into more detail if I get some responses.
Just let me know what I need to elaborate on or to upload any files you need to view like: the mini-Pascal grammar, my lex file, my bison file, my symbol table, code generator, etc.
Thanks in advance,
-Krysis09