I have two questions about how to write a recursive descent parser:
The first is what when you have a nonterminal that can match one of a few different nonterminals? How do you check which way is correct?
Second, how do you build an AST? Using YACC, I can just write a piece of code to execute for every instance of a nonterminal and it has special variables which refer to the "values" of the rules. How do you do a similar thing in a recursive descent parser?
Or a leasson in how to give yourself a stroke in one easy leasson.
You need to look ahead in the stream and make a decision. Its hard to do backtracking on a RDC.
An easier solution is to design your grammar so that it does not need to look ahead (hard).
The return value from the function call is the tree for everything that was parsed by the call. You wrap all the sub calls into another dynamically allocated object and return that.
E.g.,