branch: externals/parser-generator
commit 5150b91cc93ab02da66215c7487463c65cc89e40
Author: Christian Johansson <christ...@cvj.se>
Commit: Christian Johansson <christ...@cvj.se>

    Started working on lr-items for grammar function
---
 parser.el | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/parser.el b/parser.el
index 5fb6277..97e64d0 100644
--- a/parser.el
+++ b/parser.el
@@ -659,23 +659,25 @@
         (marked-sets (make-hash-table :test 'equal))
         (symbols (append (parser--get-grammar-non-terminals) 
(parser--get-grammar-terminals))))
     (let ((e-set (parser--lr-items-for-prefix parser--e-identifier)))
-      ;; TODO (1) Place V(e) in S. The set V(e) is initially unmarked.
-      )
+      ;;(1) Place V(e) in S. The set V(e) is initially unmarked.
+      (push `(,e-set nil) S))
     (let ((found-unmarked t))
+
+      ;; (3) Repeat step (2) until all sets of items in S are marked.
       (while found-unmarked
-        (setq found-unmarked t)
-        ;; TODO (2) If a set of items a in S is unmarked, mark a by computing
-        ;; for each X in N u E, GOTO (a, X). (Algorithm 5.8 can be used here.)
-        ;; If a' = GOTO(a, X) is nonempty and is not already in S,
-        ;; then add a' to S as an unmarked set of items
-
-        ;; TODO (3) Repeat step (2) until all sets of items in S are marked.
-        ))
-
-    ;; Place V(e) in S
-    
-    
-    ;; TODO Implement this
+        (setq found-unmarked nil)
+        (dolist (set S)
+          ;; (2) If a set of items a in S is unmarked
+          (unless (car (cdr set))
+            ;; TODO (2) Mark a by computing for each X in N u E, GOTO (a, X). 
(Algorithm 5.8 can be used here.)
+            ;; If a' = GOTO(a, X) is nonempty and is not already in S,
+            ;; then add a' to S as an unmarked set of items
+            (dolist (symbol symbols)
+              
+              )
+
+            (setq found-unmarked t)))))
+
     S))
 
 ;; Algorithm 5.8, p. 386

Reply via email to