From efc6eac842fccf41e0b2e131fffa67cc5ff1f9dc Mon Sep 17 00:00:00 2001 From: John Doty Date: Mon, 30 Sep 2024 22:32:04 -0700 Subject: [PATCH] [dingus] Build lexer and parser --- dingus/worker.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/dingus/worker.js b/dingus/worker.js index 29d2cc7..7b46a33 100644 --- a/dingus/worker.js +++ b/dingus/worker.js @@ -43,9 +43,15 @@ import parser import pyodide.code GRAMMAR_GLOBALS = {} +GRAMMAR = None +PARSE_TABLE = None +LEXER = None def eval_grammar(code): global GRAMMAR_GLOBALS + global GRAMMAR + global PARSE_TABLE + global LEXER try: dingus.post_grammar_status("Evaluating grammar...") @@ -65,7 +71,13 @@ def eval_grammar(code): if grammar is None: raise Exception("No grammar definition, define or instantiate a class that inherits from parser.Grammar") - # TODO: Build the table. + GRAMMAR = grammar + + dingus.post_grammar_status("Building parse table...") + PARSE_TABLE = grammar.build_table() + + dingus.post_grammar_status("Building lexer...") + LEXER = grammar.compile_lexer() dingus.post_grammar_loaded(grammar.name) except Exception as e: