4 ms·
How are the grammars you see on a regular basis specified if not by BNF?
by alfiedotwtf 1y ago
How are the grammars you see on a regular basis specified if not by BNF?
- mdaniel 1y agoI'm not the person you asked but I believe there are two broad classes of answers: hand rolled parsers and PEG grammars e.g. https://github.com/llvm/llvm-project/blob/llvmorg-20.1.5/clang/lib/Parse/Parser.cpp#L54 https://github.com/llvm/llvm-project/blob/llvmorg-20.1.5/cla... and https://github.com/python/cpython/blob/v3.13.3/Grammar/python.gram https://github.com/python/cpython/blob/v3.13.3/Grammar/pytho...
- alfiedotwtf 1y agoHand rolled and PEG are nice implementation wise, but to think about the grammar itself and needing to debug it not so much. Maybe it's a personal thing, but I'd rather something textual that generated a parser than have to hand roll rec decent etc.