BNFs are often used empty as an alternative, effectively making the generic expression optional:
leading_sign ::= + | - | empty
integer ::= leading_sign digit...
This is not necessary in pyparsing, since pyparsing includes an extra class for this:
leading_sign = Optional(oneOf("+ -"))
integer = leading_sign + Word(nums)
Empty can be useful for certain purposes related to pyraming:
- pyparsing , CharsNotIn restOfLine. , , , :
"Key 1" value of Key 1
"Key 2" value of Key 2
:
quotedString + restOfLine
" 1" " 2" . Pyparsing empty , :
quotedString + empty + restOfLine
.
- originalTextFor, . , originalTextFor .
, . empty , ( ). :
OneOrMore(empty)
.
empty | "A" | "B" | "C"
, MatchFirsts .