Python 使用的是什么元语法符号?
What metasyntax notation is Python using?
Python 3.6.3 的完整语法规范如下:https://docs.python.org/3/reference/grammar.html
看起来 EBNF 附加了一些取自正则表达式的特殊结构,例如:()*
(重复零次或多次?)和 ()+
(重复一次或多次?)。
Python 使用什么元语法,在哪里可以找到它的规范?
更新
Python 的语法在此 file 中定义(感谢@larsks)。但是,问题仍然存在-使用什么符号?
Python 语法由 Parser directory of the source. You can see this in Makefile.pre 中的解析器解析。这会生成 Include/graminit.[ch]
,用于 Python/ast.c
以及 Modules/parsermodule.c
。
文法格式在 bottom of pgen.c:
中描述
Input is a grammar in extended BNF (using * for repetition, + for
at-least-once repetition, [] for optional parts, | for alternatives and
() for grouping).
Python 3.6.3 的完整语法规范如下:https://docs.python.org/3/reference/grammar.html
看起来 EBNF 附加了一些取自正则表达式的特殊结构,例如:()*
(重复零次或多次?)和 ()+
(重复一次或多次?)。
Python 使用什么元语法,在哪里可以找到它的规范?
更新
Python 的语法在此 file 中定义(感谢@larsks)。但是,问题仍然存在-使用什么符号?
Python 语法由 Parser directory of the source. You can see this in Makefile.pre 中的解析器解析。这会生成 Include/graminit.[ch]
,用于 Python/ast.c
以及 Modules/parsermodule.c
。
文法格式在 bottom of pgen.c:
中描述Input is a grammar in extended BNF (using * for repetition, + for at-least-once repetition, [] for optional parts, | for alternatives and () for grouping).