Summary
The generated ModelBuilderSemantics class raises a tatsu.exceptions.SemanticError: Could not call constructor for Sequence: 'closure' object is not callable
Context
Some cases work:
tatsu.compile(grammar).parse("(test)")
BugParser().parse("(test)")
But BugParser().parse("(test)", semantics=BugModelBuilderSemantics()) fails
The grammar
# bug.peg
@@grammar :: Bug
start = sequence $ ;
sequence::Sequence = children:{term [',']}+ ;
term = parens | word ;
parens = '(' ~ @:sequence ')' ;
word::Word = val:/\w+/ ;
Reproduction
Reproduction
-
Generate the parser and model:
python -m tatsu bug.peg -o bug_parser.py -G bug_model.py
-
Run
parser = BugParser()
semantics = BugModelBuilderSemantics()
parser.parse("(test)", semantics=semantics)
GitHub repo with full code
Full reproduction code is available:
https://github.com/EGrunzke/tatsu-sematic-error-closure-not-callable
Summary
The generated ModelBuilderSemantics class raises a
tatsu.exceptions.SemanticError: Could not call constructor for Sequence: 'closure' object is not callableContext
Some cases work:
tatsu.compile(grammar).parse("(test)")BugParser().parse("(test)")But
BugParser().parse("(test)", semantics=BugModelBuilderSemantics())failsThe grammar
Reproduction
Reproduction
Generate the parser and model:
python -m tatsu bug.peg -o bug_parser.py -G bug_model.pyRun
GitHub repo with full code
Full reproduction code is available:
https://github.com/EGrunzke/tatsu-sematic-error-closure-not-callable