Commits

Anonymous committed 061a544

Bugfix: offset-by-one error in calculation of nonterminal-id.
Keywords: bugfix, nterminal-id

* generator/fg-decl.lisp (nterminal-id):
Do not substract 1.

* generator/fg-grammar.lisp (init-env):
Returns next free ID, not last used one.

Comments (0)

Files changed (2)

generator/fg-decl.lisp

 
 (declaim (inline nterminal-id))
 (defun nterminal-id (terminal grammar)
-  (- (nterm-id terminal) 1 (first-nterminal-id grammar)))
+  (- (nterm-id terminal) (first-nterminal-id grammar)))
 
 (defmethod nterm-name ((name null))
   nil)

generator/fg-grammar.lisp

 first ID of non-terminals."
   (let ((terms (mapcar #'(lambda (term) (get-nterm term :is-terminal t))
                        terminals)))
-    (values terms *grammar-next-id*)))
+    (values terms (1+ *grammar-next-id*))))
 
 (defun get-nterm (name &key is-terminal)
   "If NAME is NIL, return NIL.  Otherwise look for NAME in