
Full Python 3 Grammar Specification - quazar
https://docs.python.org/3/reference/grammar.html
======
xg15
I was wondering how they'd specify a language with semantic indents in an EBNF
grammar. Apparently they don't do that at all - they seem to use "virtual"
INDENT and DEDENT tokens that act like brackets. I suppose there is an
instruction written in prose somewhere how to convert the actual python into
the python-with-invisible-brackets that is defined here.

Very clever!

~~~
kbirkeland
The algorithm for generating those tokens is explained in the Lexical Analysis
reference[0], and a quick look at the cpython source shows the logic is
implemented in Parser/tokenizer.c[1].

[0]:
[https://docs.python.org/3/reference/lexical_analysis.html#in...](https://docs.python.org/3/reference/lexical_analysis.html#indentation)

[1]:
[https://github.com/python/cpython/blob/master/Parser/tokeniz...](https://github.com/python/cpython/blob/master/Parser/tokenizer.c)

~~~
xg15
Very cool! Thanks much for the links.

