From 1a8c768772762ed8f0edb90a78630ee97c02dc0e Mon Sep 17 00:00:00 2001 From: John Doty Date: Sun, 6 Oct 2024 07:44:11 -0700 Subject: [PATCH] [dingus] Reset the grammar globals every time Now I can rewrite the grammar --- dingus/worker.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/dingus/worker.js b/dingus/worker.js index d9dc326..4d508f6 100644 --- a/dingus/worker.js +++ b/dingus/worker.js @@ -80,23 +80,22 @@ import parser.runtime as runtime import pyodide.code import pyodide.ffi as ffi -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...") - pyodide.code.eval_code(code, globals=GRAMMAR_GLOBALS) + grammar_globals={} + pyodide.code.eval_code(code, globals=grammar_globals) grammar = None - for key, value in GRAMMAR_GLOBALS.items(): + for key, value in grammar_globals.items(): if isinstance(value, type) and issubclass(value, parser.Grammar) and value is not parser.Grammar: value = value()