Last active
May 11, 2020 01:19
-
-
Save amazzalel-habib/6fe31ff798012fc8c136080bc39c4a78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { TodoLangGrammarParser, TodoExpressionsContext } from "../ANTLR/TodoLangGrammarParser"; | |
import { TodoLangGrammarLexer } from "../ANTLR/TodoLangGrammarLexer"; | |
import { ANTLRInputStream, CommonTokenStream } from "antlr4ts"; | |
export default function parseAndGetASTRoot(code: string): TodoExpressionsContext { | |
const inputStream = new ANTLRInputStream(code); | |
const lexer = new TodoLangGrammarLexer(inputStream); | |
const tokenStream = new CommonTokenStream(lexer); | |
const parser = new TodoLangGrammarParser(tokenStream); | |
// Parse the input, where `compilationUnit` is whatever entry point you defined | |
return parser.todoExpressions(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment