I read this documentation:
http://docs.python.org/reference/simple_stmts.html
Now, I want to create statements like it describes. For example, a statement that concat a multiple assert and print statements. The syntax is unclear. How would I use the ::= operator?
I will be grateful for a clear example.
I think you are confusing the Python grammar reference with examples of actual Python code. The sections with
::=are formally describing the structure of Python statements in Backus–Naur Form. The other examples show actual Python code, and how the formal grammar looks in practice.For example, the grammar element
assert_stmthas the form:This describes the structure of an actual Python assert statement, for example:
The quoted elements in the grammar, called terminals, appear literally in the Python syntax. These include, for example, the
assertkeyword and the comma. The unquoted parts refer to other grammar elements, called nonterminals; for example,expressioncorresponds to a Python expression returning a value. Grammar elements in brackets[]denote optionality, soexpression ["," expression]refers to a comma-separated list of one or two expressions.