Example #1
0
def main(argv):
    input = FileStream(argv[1])
    lexer = untyped_expressionLexer(input)
    stream = CommonTokenStream(lexer)
    parser = untyped_expressionParser(stream)
    tree = parser.expr()
    print(tree.toStringTree(recog=parser))
Example #2
0
 def readExpr(self, text):
     inp = antlr4.InputStream(text)
     lexer = untyped_expressionLexer(inp)
     lexer.removeErrorListeners()
     lexer.addErrorListener(self)
     stream = antlr4.CommonTokenStream(lexer)
     parser = untyped_expressionParser(stream)
     parser._listeners = [self]
     return self.visit(parser.start())
Example #3
0
 def readExpr(self, text):
     inp = antlr4.InputStream(text)
     lexer = untyped_expressionLexer(inp)
     lexer.removeErrorListeners()
     lexer.addErrorListener(self)
     stream = antlr4.CommonTokenStream(lexer)
     parser = untyped_expressionParser(stream)
     parser._listeners = [self]
     return self.visit(parser.start())
Example #4
0
def readExpr(expr_string):
    errs = _custom_error_handler()
    inp = antlr4.InputStream(expr_string)
    lexer = untyped_expressionLexer(inp)
    lexer.removeErrorListeners()
    lexer.addErrorListener(errs)
    stream = antlr4.CommonTokenStream(lexer)
    parser = untyped_expressionParser(stream)
    parser._listeners = [errs]
    return _parse_visitor().visit(parser.start())
Example #5
0
def readExpr(expr_string):
    errs = _custom_error_handler()
    inp = antlr4.InputStream(expr_string)
    lexer = untyped_expressionLexer(inp)
    lexer.removeErrorListeners()
    lexer.addErrorListener(errs)
    stream = antlr4.CommonTokenStream(lexer)
    parser = untyped_expressionParser(stream)
    parser._listeners = [errs]
    return _parse_visitor().visit(parser.start())