3 ms·
As an informally trained writer of compilers, I believe parsing could be reduced to just these concepts: 1. Greedy matching 2. Minimal matching 3. Tokenizati
by megameter 6y ago
As an informally trained writer of compilers, I believe parsing could be reduced to just these concepts:
1. Greedy matching
2. Minimal matching
3. Tokenization
Regular expressions and implementation of a subset of their operators are a good way to introduce and discuss each, and recursive descent is the elaboration on that, the graduation to a customized mechanism. The last is to generalize it all to a form of constraint logic and introduce other forms of backtracking(e.g. pathfinding algorithms). Discussion of types follows from discussion of constraints and explains "smartness" in compilers, so it might be the last thing if I were teaching the course.
What I really think is at issue with our vast number of grammars is just the reliance on text as the interface. If we discuss parsing as a thing applicable to arbitrary data streams we can start asking "well, what if we don't serialize it to characters, but to some other token format?" That is way more interesting today, since we seem to have dispensed with the premise of natural language being the way to program computers, that really got the whole parsing thing started.