branch: externals/parser-generator commit 563cbddc04ae78532e775e72fd77c070d3237301 Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Passed FIRST tests for semi-complex grammar --- parser.el | 3 ++- test/parser-test.el | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/parser.el b/parser.el index 053720b..be01ce3 100644 --- a/parser.el +++ b/parser.el @@ -364,7 +364,8 @@ ((parser--valid-e-p rhs-element) (setq rhs-type 'EMPTY)) ((parser--valid-terminal-p rhs-element) - (setq rhs-type 'TERMINAL))) + (setq rhs-type 'TERMINAL)) + (t (error (format "Invalid symbol %s" rhs-element)))) (parser--debug (message "rhs-type: %s" rhs-type)) (cond diff --git a/test/parser-test.el b/test/parser-test.el index 1c7ef74..2004fa3 100644 --- a/test/parser-test.el +++ b/test/parser-test.el @@ -70,24 +70,24 @@ (parser--first 'S))) (message "Passed first 3 with intermediate grammar") - (parser--set-grammar '((S A B) ("c" "d") ((S A) (A B) (B c d)) S) 1) + (parser--set-grammar '((S A B) ("c" "d") ((S A) (A B) (B "c" "d")) S) 1) (should (equal - '((c) (d)) + '(("d") ("c")) (parser--first 'S))) (message "Passed first 1 with semi-complex grammar") - (parser--set-grammar '((S A B) (a c d f) ((S A a) (A B) (B (c f) d)) S) 2) + (parser--set-grammar '((S A B) (a c d f) ((S (A a)) (A B) (B (c f) d)) S) 2) (should (equal - '((c f) (d a)) + '((d a) (c f)) (parser--first 'S))) (message "Passed first 2 with semi-complex grammar") (parser--set-grammar '((S A B) ("a" "c" "d" "m") ((S A) (A (B "a" "m")) (B "c" "d")) S) 3) (should (equal - '(("c" "a" "m") ("d" "a" "m")) + '(("d" "a" "m") ("c" "a" "m")) (parser--first 'S))) (message "Passed first 3 with semi-complex grammar")