当我想测试我的 EBNF 语法时,我遇到了错误:
AttributeError:“元组”对象没有属性“asjson”
代码 :
if not filename or filename == '-':
text = sys.stdin.read()
else:
with open(filename) as f:
text = f.read()
grammarname = 'grammars/CTEST.ebnf'
grammarData = open(grammarname).read()
parser = tatsu.compile(grammarData, asmodel=True)
model = parser.parse(text)
print()
print('# MODEL TYPE IS:', type(model).__name__)
print(json.dumps(model.asjson(), indent=4))
print()
如何验证我的语法文件?