我试图在python中使用lexer.py和parser.py,但它在此代码中有错误:
import antlr3
import antlr3.tree
import traceback
from test22Lexer import test22Lexer
from test22Parser import test22Parser
char_stream = antlr3.ANTLRStringStream("input.txt")
lexer = test22Lexer(char_stream)
tokens = antlr3.CommonTokenStream(lexer)
parser = test22Parser(tokens)
parser.block()
Run Code Online (Sandbox Code Playgroud)
而错误是:
class block_return(ParserRuleReturnScope):
NameError: name 'ParserRuleReturnScope' is not defined
Run Code Online (Sandbox Code Playgroud)
我需要帮助:D
解析器:
class block_return(ParserRuleReturnScope):
def __init__(self):
super(test22Parser.block_return, self).__init__()
self.tree = None
Run Code Online (Sandbox Code Playgroud)