4 ms·
Python's grammar is context-sensitive until the lexer processes indentation. There are other programming languages whose grammar is context-free.
by paxcoder 10y ago
Python's grammar is context-sensitive until the lexer processes indentation. There are other programming languages whose grammar is context-free.
- gary_bernhardt 10y agoI went back and forth on that statement for exactly this reason, but kept it because the whitespace is handled in the lexer, as you mentioned. The Python grammar itself is context-free, and the grammar is the only part that I expect the series to examine.
- paxcoder 10y agoYou imply that indentation isn't a part of Python's grammar...
- gary_bernhardt 10y agoIt's not part of the Python grammar as specified in the file called Grammar in the canonical implementation of the language (https://github.com/python/cpython/blob/master/Grammar/Grammar https://github.com/python/cpython/blob/master/Grammar/Gramma...). Of course it's part of the grammar in the larger sense. I don't think that that distinction is important when trying to convince someone with no theoretical background to learn these topics, which is what the video in question is trying to do.