by nokcha · 9y ago · 0 comments
That's not necessarily true for all languages. For example, in C, "(e1)&e2" is parsed differently depending on how e1 is declared. If e1 is declared as
typedef int* e1;
then the "&" in "(e1)&e2" is parsed as the address-of operator, but if e1 is declared as int e1;
then "(e1)&e2" is parsed as a bitwise AND.I've had some success in the past with using GLR or another algorithm that can handle ambiguity, and then choosing among the possible parse trees in another pass that takes semantic information into account. How applicable that is really depends on the language, though; if things are so ambiguous that you're getting an exponential growth in possible parse trees, you may not want to use this approach.