Ejemplo n.º 1
0
    def _parse_input(text, cwd=None):
        """The parser fixture accepts a blackbird string to parse"""
        lexer = blackbirdLexer(antlr4.InputStream(text))
        stream = antlr4.CommonTokenStream(lexer)
        parser = blackbirdParser(stream)

        tree = parser.start()

        bb = BlackbirdListener(cwd=cwd)
        walker = antlr4.ParseTreeWalker()
        walker.walk(bb, tree)
        return bb.program
Ejemplo n.º 2
0
    def _parse_input(text):
        """The parser fixture accepts a blackbird string to parse"""
        text = "name mockname\nversion 1.0\n" + text
        lexer = blackbirdLexer(antlr4.InputStream(text))
        stream = antlr4.CommonTokenStream(lexer)
        parser = blackbirdParser(stream)

        tree = parser.start()

        bb = BlackbirdListener()
        walker = antlr4.ParseTreeWalker()
        walker.walk(bb, tree)

        return bb.program