3 ms·
I just worked with a mathematician who understood grammars, and could write one, but could not use the theory in any practical way. Parsing is not just recognit
by tlarkworthy 14y ago
I just worked with a mathematician who understood grammars, and could write one, but could not use the theory in any practical way. Parsing is not just recognition. You need to pass info up the parse tree so that after parsing, you have a new data structure with everything nicely structured ready to ACT UPON. People write in specific languages to achieve something, not to simply create syntactically correct bodies of text. So understanding grammars is 50% of being able to use them as tools.
The other understanding you need to be able to put them to use is having a mental model of how a bottom up parser processes the tokens. You need to be able to insert actions for each grammar rule at appropriate places, which allows the information to flow bottom up too, and be processed appropriately at the same time. I have found this second bit to language processing is actually the harder bit, and its worth rewriting your grammar to make it simpler.
- aaronblohowiak 14y ago>You need to pass info up the parse tree so that after parsing, you have a new data structure with everything nicely structured ready to ACT UPON. I (and many others) prefer to keep these passes relatively distinct. Parse tree -> AST -> Internal Representation -> (Generation of Output / Interpretation)