branch: externals/parser-generator commit 1ae36fc70b4f8a6aae9f7a694bc567899178beca Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Added support for calculating first of a sentential form --- parser.el | 3 +-- test/parser-test.el | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/parser.el b/parser.el index b153d84..60eb3ab 100644 --- a/parser.el +++ b/parser.el @@ -498,8 +498,7 @@ ;; Iterate each symbol in β using a PDA algorithm (let ((input-tape β) (input-tape-length (length β)) - (stack '((0 0 nil))) - (first-list nil)) + (stack '((0 0 nil)))) (while stack (let ((stack-topmost (pop stack))) (parser--debug diff --git a/test/parser-test.el b/test/parser-test.el index 1a2b2fc..80d81b4 100644 --- a/test/parser-test.el +++ b/test/parser-test.el @@ -35,11 +35,19 @@ (parser--first 'S))) (message "Passed first 1 with rudimentary grammar") - ;; (should - ;; (equal - ;; '((a a)) - ;; (parser--first '(S a)))) - ;; (message "Passed first 1b with rudimentary grammar") + (parser--set-grammar '((S) (a) ((S a)) S) 1) + (should + (equal + '((a)) + (parser--first '(S a)))) + (message "Passed first 1b with rudimentary grammar") + + (parser--set-grammar '((S) (a) ((S a)) S) 2) + (should + (equal + '((a a)) + (parser--first '(S a)))) + (message "Passed first 1c with rudimentary grammar") (parser--set-grammar '((S) ("a" "b" "c") ((S ("a" "b" "c"))) S) 2) (should