|
|
@ -12,19 +12,36 @@
|
|
|
|
(let* ((grammar (parse-input start end input-terms assocs prods runtime))
|
|
|
|
(let* ((grammar (parse-input start end input-terms assocs prods runtime))
|
|
|
|
(table (build-table grammar filename))
|
|
|
|
(table (build-table grammar filename))
|
|
|
|
(table-code
|
|
|
|
(table-code
|
|
|
|
(cons 'vector
|
|
|
|
`((lambda (table-list)
|
|
|
|
(map (lambda (action)
|
|
|
|
(let ((v (list->vector table-list)))
|
|
|
|
|
|
|
|
(let loop ((i 0))
|
|
|
|
|
|
|
|
(cond
|
|
|
|
|
|
|
|
((< i (vector-length v))
|
|
|
|
|
|
|
|
(let ((vi (vector-ref v i)))
|
|
|
|
(cond
|
|
|
|
(cond
|
|
|
|
((shift? action)
|
|
|
|
((list? vi)
|
|
|
|
`(make-shift ,(shift-state action)))
|
|
|
|
(vector-set! v i
|
|
|
|
((reduce? action)
|
|
|
|
(cond
|
|
|
|
`(make-reduce ,(reduce-prod-num action)
|
|
|
|
((eq? 's (car vi))
|
|
|
|
,(reduce-lhs-num action)
|
|
|
|
(make-shift (cadr vi)))
|
|
|
|
,(reduce-rhs-length action)))
|
|
|
|
((eq? 'r (car vi))
|
|
|
|
((accept? action)
|
|
|
|
(make-reduce (cadr vi) (caddr vi) (cadddr vi)))
|
|
|
|
`(make-accept))
|
|
|
|
((eq? 'a (car vi)) (make-accept)))))))
|
|
|
|
(else action)))
|
|
|
|
(loop (add1 i)))
|
|
|
|
(vector->list table))))
|
|
|
|
(else v)))))
|
|
|
|
|
|
|
|
(quote
|
|
|
|
|
|
|
|
,(map (lambda (action)
|
|
|
|
|
|
|
|
(cond
|
|
|
|
|
|
|
|
((shift? action)
|
|
|
|
|
|
|
|
`(s ,(shift-state action)))
|
|
|
|
|
|
|
|
((reduce? action)
|
|
|
|
|
|
|
|
`(r ,(reduce-prod-num action)
|
|
|
|
|
|
|
|
,(reduce-lhs-num action)
|
|
|
|
|
|
|
|
,(reduce-rhs-length action)))
|
|
|
|
|
|
|
|
((accept? action)
|
|
|
|
|
|
|
|
`(a))
|
|
|
|
|
|
|
|
(else action)))
|
|
|
|
|
|
|
|
(vector->list table)))))
|
|
|
|
|
|
|
|
|
|
|
|
(num-non-terms (length (grammar-non-terms grammar)))
|
|
|
|
(num-non-terms (length (grammar-non-terms grammar)))
|
|
|
|
|
|
|
|
|
|
|
|