3 ms·
C++ is absolutely not context-free. It is probably in fact the worst and is "undecidable". http://yosefk.com/c++fqa/defective.html#defect-2 http://yosefk.com/c
by dottrap 14y ago
C++ is absolutely not context-free. It is probably in fact the worst and is "undecidable".
http://yosefk.com/c++fqa/defective.html#defect-2 http://yosefk.com/c++fqa/defective.html#defect-2
Compiler writers have to use heuristics to sort out the all the ambiguities and cross their fingers they are correct.
Lua might be context-free. I forgot how to do rigorous proofs. But is one of the cleanest and most elegant languages ever made. See the complete (tiny) syntax of Lua in extended BNF at the very bottom of the manual.
http://www.lua.org/manual/5.2/manual.html http://www.lua.org/manual/5.2/manual.html
- lucian1900 14y agoAfaik both Lua and Python are context-free.
- Twisol 14y agoHow would you implement Lua's long-string syntax in a context-free grammar? str = [==[foo]bar]=]baz]==] Been trying to puzzle this one out.
- CJefferson 14y agoWhile parsing C++ is indeed a pain, there are no heuristics used in the parsing of C++.