|
|
@ -107,7 +107,7 @@
|
|
|
|
(if (> RR-conflicts 0)
|
|
|
|
(if (> RR-conflicts 0)
|
|
|
|
(fprintf port "~a reduce/reduce conflicts~n" RR-conflicts))))
|
|
|
|
(fprintf port "~a reduce/reduce conflicts~n" RR-conflicts))))
|
|
|
|
|
|
|
|
|
|
|
|
(define (resolve-conflicts a table num-terms num-non-terms)
|
|
|
|
(define (resolve-conflicts a table num-terms num-non-terms suppress)
|
|
|
|
(letrec ((SR-conflicts 0)
|
|
|
|
(letrec ((SR-conflicts 0)
|
|
|
|
(RR-conflicts 0)
|
|
|
|
(RR-conflicts 0)
|
|
|
|
(get-action
|
|
|
|
(get-action
|
|
|
@ -140,7 +140,8 @@
|
|
|
|
(+ num-non-terms term))))
|
|
|
|
(+ num-non-terms term))))
|
|
|
|
(loop (add1 term))))))
|
|
|
|
(loop (add1 term))))))
|
|
|
|
a)
|
|
|
|
a)
|
|
|
|
|
|
|
|
(if (not suppress)
|
|
|
|
|
|
|
|
(begin
|
|
|
|
(if (> SR-conflicts 0)
|
|
|
|
(if (> SR-conflicts 0)
|
|
|
|
(fprintf (current-error-port)
|
|
|
|
(fprintf (current-error-port)
|
|
|
|
"~a shift/reduce conflicts~n"
|
|
|
|
"~a shift/reduce conflicts~n"
|
|
|
@ -148,7 +149,7 @@
|
|
|
|
(if (> RR-conflicts 0)
|
|
|
|
(if (> RR-conflicts 0)
|
|
|
|
(fprintf (current-error-port)
|
|
|
|
(fprintf (current-error-port)
|
|
|
|
"~a reduce/reduce conflicts~n"
|
|
|
|
"~a reduce/reduce conflicts~n"
|
|
|
|
RR-conflicts))))
|
|
|
|
RR-conflicts))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -202,7 +203,7 @@
|
|
|
|
;; In the result table the first index is the state and the second is the
|
|
|
|
;; In the result table the first index is the state and the second is the
|
|
|
|
;; term/non-term index (with the non-terms coming first)
|
|
|
|
;; term/non-term index (with the non-terms coming first)
|
|
|
|
;; buile-table: grammar * string -> action2d-array
|
|
|
|
;; buile-table: grammar * string -> action2d-array
|
|
|
|
(define (build-table g file)
|
|
|
|
(define (build-table g file suppress)
|
|
|
|
(let* ((a (build-lr0-automaton g))
|
|
|
|
(let* ((a (build-lr0-automaton g))
|
|
|
|
(terms (grammar-terms g))
|
|
|
|
(terms (grammar-terms g))
|
|
|
|
(non-terms (grammar-non-terms g))
|
|
|
|
(non-terms (grammar-non-terms g))
|
|
|
@ -287,7 +288,7 @@
|
|
|
|
(lambda (port)
|
|
|
|
(lambda (port)
|
|
|
|
(display-parser a table get-term get-non-term (grammar-prods g)
|
|
|
|
(display-parser a table get-term get-non-term (grammar-prods g)
|
|
|
|
port)))))
|
|
|
|
port)))))
|
|
|
|
(resolve-conflicts a table num-terms num-non-terms)
|
|
|
|
(resolve-conflicts a table num-terms num-non-terms suppress)
|
|
|
|
table))
|
|
|
|
table))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|