*** empty log message ***

original commit: 01365893460fcdf119a95bbadf1c2110c01f0b4e
tokens
Scott Owens 23 years ago
parent 6d1742abc8
commit ce7db455eb

@ -395,4 +395,6 @@
(cons start (cons end-non-term non-terms)) (cons start (cons end-non-term non-terms))
terms terms
(add1 counter) (add1 counter)
end-terms)))))) (map (lambda (term-name)
(hash-table-get term-table term-name))
end-terms)))))))

@ -207,18 +207,23 @@
;; buile-table: grammar * string -> action2d-array ;; buile-table: grammar * string -> action2d-array
(define (build-table g file) (define (build-table g file)
(let* ((a (build-lr0-automaton g)) (let* ((a (build-lr0-automaton g))
(get-state (lr0-states a))
(terms (grammar-terms g)) (terms (grammar-terms g))
(non-terms (grammar-non-terms g)) (non-terms (grammar-non-terms g))
(get-state (lr0-states a))
(get-term (list->vector terms)) (get-term (list->vector terms))
(get-non-term (list->vector non-terms)) (get-non-term (list->vector non-terms))
(get-prod (list->vector (grammar-prods g))) (get-prod (list->vector (grammar-prods g)))
(num-states (vector-length get-state)) (num-states (vector-length get-state))
(num-terms (vector-length get-term)) (num-terms (vector-length get-term))
(num-non-terms (vector-length get-non-term)) (num-non-terms (vector-length get-non-term))
(end-term-indexes
(map
(lambda (term)
(+ num-non-terms (gram-sym-index term)))
(grammar-end-terms g)))
(num-gram-syms (+ num-terms num-non-terms)) (num-gram-syms (+ num-terms num-non-terms))
(table (make-array2d num-states num-gram-syms #f)) (table (make-array2d num-states num-gram-syms #f))
(array2d-add! (array2d-add!
(lambda (v i1 i2 a) (lambda (v i1 i2 a)
(let ((old (array2d-ref v i1 i2))) (let ((old (array2d-ref v i1 i2)))
(cond (cond
@ -246,10 +251,14 @@
(array2d-set! table (array2d-set! table
state state
i i
(if (< i num-non-terms) (cond
(kernel-index goto) ((< i num-non-terms)
(make-shift (kernel-index goto))
(kernel-index goto)))))) ((member i end-term-indexes)
(make-accept))
(else
(make-shift
(kernel-index goto)))))))
(loop (add1 i))))) (loop (add1 i)))))
(let ((items (let ((items
(filter (lambda (item) (filter (lambda (item)

Loading…
Cancel
Save