-
-
Notifications
You must be signed in to change notification settings - Fork 291
Closed
Description
Hi,
thanks a lot for the great library!
I am puzzled by the semantics of the validate()
method: I tried with a very simple grammar (taken from https://github.com/pyparsing/pyparsing/blob/master/examples/simpleArith.py) and the validate()
method fails:
from pyparsing import *
integer = pyparsing_common.integer
variable = Word(alphas, exact=1)
operand = integer | variable
expop = Literal("^")
signop = oneOf("+ -")
multop = oneOf("* /")
plusop = oneOf("+ -")
factop = Literal("!")
expr = infixNotation(
operand,
[
("!", 1, opAssoc.LEFT),
("^", 2, opAssoc.RIGHT),
(signop, 1, opAssoc.RIGHT),
(multop, 2, opAssoc.LEFT),
(plusop, 2, opAssoc.LEFT),
],
)
expr.validate()
Gives me:
pyparsing.exceptions.RecursiveGrammarException: RecursiveGrammarException: [+ | - term, + | - term, {FollowedBy>:({+ | - + | - term}) Group:({[+ | -] + | - term})}, Group:({[+ | -] + | - term}), {[+ | -] + | - term}, + | - term]
Is this an expected behavior? More in general, is it ok for a grammar to be validate() == False
? The documentation is very unclear on this and I would like to understand if it is OK to create grammars that do not validate...
Metadata
Metadata
Assignees
Labels
No labels