Anonymous avatar Anonymous committed fc6ad8b

Small cleanups in grammar

Comments (0)

Files changed (1)

 (defun initial-lr1-item-for-production (production lookahead)
   (make-instance 'lr1-item :position 0 :production production :lookahead lookahead))
-(defun initial-lr1-items-for-grammar (specification start-rule-name)
+(defun initial-lr1-state-for-grammar (specification start-rule-name)
   (loop for rule in specification
      if (eql (car rule) start-rule-name)
      return (loop for production in (rule-productions rule)
 		       unless (item-finished-p item)
 		       collect (increment-lr1-item-position item))))
-(defun lr1-goto-index-for-symbol ( specification states symbol)
-  (let ((goto (lr1-goto-for-symbol specification states symbol)))
-    (position goto states :test #'equal-items)))
-(defun lr1-items-for-grammar (specification start-rule-name)
-  (let ((states (list (closure-of-lr1-items specification (initial-lr1-items-for-grammar specification start-rule-name))))
+(defun lr1-states-for-grammar (specification start-rule-name)
+  (let ((states (list (closure-of-lr1-items specification (initial-lr1-state-for-grammar specification start-rule-name))))
 	(symbols (symbols-in-grammar specification)))
     (loop for done = t
        do (loop for state in states
-	     ;; do (format *standard-output* "State: ~a~%" state)
 	     do (loop for symbol in symbols
 		   do (let ((goto (lr1-goto-for-symbol specification state symbol)))
 			(when (and goto (not (member goto states :test #'equal-items)))
        finally (return (reverse states)))))
 (defun make-grammar (specification start-rule-name)
-  (let* ((states (lr1-items-for-grammar specification start-rule-name))
+  (let* ((states (lr1-states-for-grammar specification start-rule-name))
 	 (non-terminals (non-terminals-in-grammar specification))
 	 (action-table (make-instance 'lr-parse-table :states (length states)))
 	 (goto-table (make-instance 'lr-parse-table :states (length states))))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.