|
|
@ -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
|
|
|
|
|
|
|
|
((list? vi)
|
|
|
|
|
|
|
|
(vector-set! v i
|
|
|
|
|
|
|
|
(cond
|
|
|
|
|
|
|
|
((eq? 's (car vi))
|
|
|
|
|
|
|
|
(make-shift (cadr vi)))
|
|
|
|
|
|
|
|
((eq? 'r (car vi))
|
|
|
|
|
|
|
|
(make-reduce (cadr vi) (caddr vi) (cadddr vi)))
|
|
|
|
|
|
|
|
((eq? 'a (car vi)) (make-accept)))))))
|
|
|
|
|
|
|
|
(loop (add1 i)))
|
|
|
|
|
|
|
|
(else v)))))
|
|
|
|
|
|
|
|
(quote
|
|
|
|
|
|
|
|
,(map (lambda (action)
|
|
|
|
(cond
|
|
|
|
(cond
|
|
|
|
((shift? action)
|
|
|
|
((shift? action)
|
|
|
|
`(make-shift ,(shift-state action)))
|
|
|
|
`(s ,(shift-state action)))
|
|
|
|
((reduce? action)
|
|
|
|
((reduce? action)
|
|
|
|
`(make-reduce ,(reduce-prod-num action)
|
|
|
|
`(r ,(reduce-prod-num action)
|
|
|
|
,(reduce-lhs-num action)
|
|
|
|
,(reduce-lhs-num action)
|
|
|
|
,(reduce-rhs-length action)))
|
|
|
|
,(reduce-rhs-length action)))
|
|
|
|
((accept? action)
|
|
|
|
((accept? action)
|
|
|
|
`(make-accept))
|
|
|
|
`(a))
|
|
|
|
(else action)))
|
|
|
|
(else action)))
|
|
|
|
(vector->list table))))
|
|
|
|
(vector->list table)))))
|
|
|
|
|
|
|
|
|
|
|
|
(num-non-terms (length (grammar-non-terms grammar)))
|
|
|
|
(num-non-terms (length (grammar-non-terms grammar)))
|
|
|
|
|
|
|
|
|
|
|
|