2024-10-02 14:29:09 发布
网友
Python文档中到处都有::=:
::=
例如:
atom ::= identifier | literal | enclosure
我搜索并学习了它的BNF语法。你知道吗
从几十个文件中得到一个简短的想法真的不容易。你知道吗
在python中:可以看作是'assignment'符号=的变体
:
=
在Django的模板语法中,|是函数符号。你知道吗
|
BFN中的::=和|是什么?你知道吗
在适用于许多语言语法的Backus-Naur形式中,::=表示语法的某个元素的定义,几乎像宏一样。根据the Wikipedia page:
The "::=" means that the symbol on the left must be replaced with the expression on the right.
假设形式的定义是:
symbol ::= expression
表示出现symbol的地方,替换为expression。你知道吗
symbol
expression
|表示“or”,如在atom中定义为标识符、文字或附件。同样,从维基百科页面:
atom
more sequences are separated by the vertical bar "|", indicating a choice, the whole being a possible substitution for the symbol on the left.
因此,当用“|”分隔时,左边的符号可以是左边表达式中的许多符号之一。总之,文档实际上是这样说的:“只要有atom,就意味着那里可能有一个文本、标识符或附件”。你知道吗
从wikipedia:
|符号表示独占的OR。你知道吗
OR
这意味着你必须用identifier、literal或enclosure来替换atom。你知道吗
identifier
literal
enclosure
在适用于许多语言语法的Backus-Naur形式中,
::=
表示语法的某个元素的定义,几乎像宏一样。根据the Wikipedia page:假设形式的定义是:
表示出现
symbol
的地方,替换为expression
。你知道吗|
表示“or”,如在atom
中定义为标识符、文字或附件。同样,从维基百科页面:因此,当用“|”分隔时,左边的符号可以是左边表达式中的许多符号之一。总之,文档实际上是这样说的:“只要有
atom
,就意味着那里可能有一个文本、标识符或附件”。你知道吗从wikipedia:
|
符号表示独占的OR
。你知道吗这意味着你必须用
identifier
、literal
或enclosure
来替换atom
。你知道吗相关问题 更多 >
编程相关推荐