EBNF: Lecture vs. Python Documentation There are a few different typographic conventions used in the EBNF lecture, compared to the EBNF used in actual Python Documentation. Here is a short summary of the six differences, and a short and large example. 1. Write <= (separating LHS from RHS) as ::= 2. Italicized names (of rules) are just written as names 3. Boxed characters (which stand for themselves) are written within quotes 4. () do not stand for themselves; they are used for grouping (see rule 5) write "(" and ")" for parentheses in the EBNF used for Python Documentation 5. {item} is written as item*; {item1 ... itemN} is written (item1 ... itemN)* 6. Writing + superscript means repeat 1 or more times Short Example: digit ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" integer ::= ["+"|"-"]digit digit* the last rule can be written as either: integer ::= ["+"|"-"]digit(digit)* or integer ::= ["+"|"-"](digit)+ Online: See https://docs.python.org/3/reference/simple_stmts.html See https://docs.python.org/3/reference/compound_stmts.html Questions: is it legal in Python to write a = b = 0 Also, see the import statement (and all its forms) Large Example: This is from Section 6.1.3.1 Format Specification Mini-Language of the Python Library. Format strings contain “replacement fields” surrounded by curly braces {}. Anything that is not contained in braces is considered literal text, which is copied unchanged to the output. If you need to include a brace character in the literal text, it can be escaped by doubling: {{ and }}. The grammar for a replacement field is as follows: replacement_field ::= "{" [field_name] ["!" conversion] [":" format_spec] "}" field_name ::= arg_name ("." attribute_name | "[" element_index "]")* arg_name ::= [identifier | integer] attribute_name ::= identifier element_index ::= integer | index_string index_string ::= + conversion ::= "r" | "s" | "a" format_spec ::= [[fill]align][sign][#][0][width][,][.precision][type] fill ::= align ::= "<" | ">" | "=" | "^" sign ::= "+" | "-" | " " width ::= integer precision ::= integer type ::= "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"