I am trying to build a parser that will eventually output a 3 address code.
My question is, how do I build the parser to go from parsing in a table driven top down parsing to then give me a parse tree?
I am looking for more psudo code than anything. Not anything concrete. For example, I have a table with the first and follow sets of all non-terminal. I take this non terminal and do the standard parsing technique for table driven parsing.
When and how do I take those choices for the parsing to create the parse tree?
Below is the grammar I am trying to parse out, I take the corresponding first and follow sets to the grammar and the parse out the input using the table driven parsing technique.
Grammar
expr ::= term {addop term}
term ::= factor {mulop factor}
factor ::= variable| unsigned-number| ( expr)
variable ::= identifier
addop ::= + | -
mulop ::= * | /