3 ms·
There are some papers (which postdate this blog post) that add simple extensions to context-free grammars that are capable of expressing the grammars of indenta
by andolanra 7y ago
There are some papers (which postdate this blog post) that add simple extensions to context-free grammars that are capable of expressing the grammars of indentation-based languages in a principled way: Principled Parsing for Indentation-Sensitive Languages (Michael Adams, 2013)[1] and Indentation-Sensitve Parsing for Parsec (Michael Adams, 2014)[2], which add support for indentation-based parsing to bottom-up parsers (specifically GLR and LR(k)) and top-down parsers (parser combinator-like systems and PEGs) respectively.
These techniques do not "make Python context-free", so the blog's content stands. However, they do help address the final point of this blog post: they provide principled and limited tools which can express this kind of non-context-free grammar in a declarative way. Tools like these allow us to use simple lexers (i.e. without state hacks like Python's) while expressing indentation-based grammars using easy-to-understand-and-analyze BNF-like formalisms.
[1]: https://michaeldadams.org/papers/layout_parsing/ https://michaeldadams.org/papers/layout_parsing/
[2]: https://michaeldadams.org/papers/layout_parsing_2/ https://michaeldadams.org/papers/layout_parsing_2/