From f2ad77f0826c2956f24f58f7004e9a308a05620e Mon Sep 17 00:00:00 2001 From: Kia <kia@special-circumstanc.es> Date: Sat, 25 Jan 2020 18:15:22 -0700 Subject: [PATCH] reduce ruleset for expression grammar --- combinatorial_LR_parser.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/combinatorial_LR_parser.py b/combinatorial_LR_parser.py index 42aaf05..5e96203 100644 --- a/combinatorial_LR_parser.py +++ b/combinatorial_LR_parser.py @@ -727,6 +727,34 @@ class DummyPlug(Elaboratable): [] ] + + reduce_ruleset = [ + # For state 0: + [], + # For state 1: + [], + # For state 2: + [((STDMASK, ADDOP),1), ((STDMASK, CLOSEPAREN),1), ((STDMASK, ENDOFPARSE),1)], + # For state 3: + [((STDMASK, ADDOP),3), ((STDMASK, MULTOP),3), ((STDMASK, CLOSEPAREN),3), ((STDMASK, ENDOFPARSE),3)], + # For state 4: + [], + # For state 5: + [((STDMASK, ADDOP),5), ((STDMASK, MULTOP),5), ((STDMASK, CLOSEPAREN),5), ((STDMASK, ENDOFPARSE),5)], + # For state 6: + [], + # For state 7: + [], + # For state 8: + [], + # For state 9: + [((STDMASK, ADDOP),0), ((STDMASK, CLOSEPAREN),0), ((STDMASK, ENDOFPARSE),0)], + # For state 10: + [((STDMASK, ADDOP),2), ((STDMASK, MULTOP),2), ((STDMASK, CLOSEPAREN),2), ((STDMASK, ENDOFPARSE),2)], + # For state 11: + [((STDMASK, ADDOP),4), ((STDMASK, MULTOP),4), ((STDMASK, CLOSEPAREN),4), ((STDMASK, ENDOFPARSE),4)], + ] + def extractor(x): return (x & 0x00ff) execute_rules = [ (3, (lambda stackview: EXPRESSION + (extractor(stackview[0]) + extractor(stackview[2])))), -- GitLab