|
|
@ -97,16 +97,16 @@
|
|
|
|
(for-each
|
|
|
|
(for-each
|
|
|
|
(lambda (prod)
|
|
|
|
(lambda (prod)
|
|
|
|
(fprintf port
|
|
|
|
(fprintf port
|
|
|
|
"~a\t~a\t=\t~a~n"
|
|
|
|
"~a\t~a\t=\t~a\n"
|
|
|
|
(prod-index prod)
|
|
|
|
(prod-index prod)
|
|
|
|
(gram-sym-symbol (prod-lhs prod))
|
|
|
|
(gram-sym-symbol (prod-lhs prod))
|
|
|
|
(map gram-sym-symbol (vector->list (prod-rhs prod)))))
|
|
|
|
(map gram-sym-symbol (vector->list (prod-rhs prod)))))
|
|
|
|
prods)
|
|
|
|
prods)
|
|
|
|
(send a for-each-state
|
|
|
|
(send a for-each-state
|
|
|
|
(lambda (state)
|
|
|
|
(lambda (state)
|
|
|
|
(fprintf port "State ~a~n" (kernel-index state))
|
|
|
|
(fprintf port "State ~a\n" (kernel-index state))
|
|
|
|
(for-each (lambda (item)
|
|
|
|
(for-each (lambda (item)
|
|
|
|
(fprintf port "\t~a~n" (item->string item)))
|
|
|
|
(fprintf port "\t~a\n" (item->string item)))
|
|
|
|
(kernel-items state))
|
|
|
|
(kernel-items state))
|
|
|
|
(newline port)
|
|
|
|
(newline port)
|
|
|
|
(for-each
|
|
|
|
(for-each
|
|
|
@ -118,22 +118,22 @@
|
|
|
|
((null? (cdr act))
|
|
|
|
((null? (cdr act))
|
|
|
|
(print-entry sym (car act) port))
|
|
|
|
(print-entry sym (car act) port))
|
|
|
|
(else
|
|
|
|
(else
|
|
|
|
(fprintf port "begin conflict:~n")
|
|
|
|
(fprintf port "begin conflict:\n")
|
|
|
|
(when (> (count reduce? act) 1)
|
|
|
|
(when (> (count reduce? act) 1)
|
|
|
|
(set! RR-conflicts (add1 RR-conflicts)))
|
|
|
|
(set! RR-conflicts (add1 RR-conflicts)))
|
|
|
|
(when (> (count shift? act) 0)
|
|
|
|
(when (> (count shift? act) 0)
|
|
|
|
(set! SR-conflicts (add1 SR-conflicts)))
|
|
|
|
(set! SR-conflicts (add1 SR-conflicts)))
|
|
|
|
(map (lambda (x) (print-entry sym x port)) act)
|
|
|
|
(map (lambda (x) (print-entry sym x port)) act)
|
|
|
|
(fprintf port "end conflict~n")))))
|
|
|
|
(fprintf port "end conflict\n")))))
|
|
|
|
(vector-ref grouped-table (kernel-index state)))
|
|
|
|
(vector-ref grouped-table (kernel-index state)))
|
|
|
|
(newline port)))
|
|
|
|
(newline port)))
|
|
|
|
|
|
|
|
|
|
|
|
(when (> SR-conflicts 0)
|
|
|
|
(when (> SR-conflicts 0)
|
|
|
|
(fprintf port "~a shift/reduce conflict~a~n"
|
|
|
|
(fprintf port "~a shift/reduce conflict~a\n"
|
|
|
|
SR-conflicts
|
|
|
|
SR-conflicts
|
|
|
|
(if (= SR-conflicts 1) "" "s")))
|
|
|
|
(if (= SR-conflicts 1) "" "s")))
|
|
|
|
(when (> RR-conflicts 0)
|
|
|
|
(when (> RR-conflicts 0)
|
|
|
|
(fprintf port "~a reduce/reduce conflict~a~n"
|
|
|
|
(fprintf port "~a reduce/reduce conflict~a\n"
|
|
|
|
RR-conflicts
|
|
|
|
RR-conflicts
|
|
|
|
(if (= RR-conflicts 1) "" "s")))))
|
|
|
|
(if (= RR-conflicts 1) "" "s")))))
|
|
|
|
|
|
|
|
|
|
|
@ -159,7 +159,7 @@
|
|
|
|
(loop (car rest) (cdr rest)))
|
|
|
|
(loop (car rest) (cdr rest)))
|
|
|
|
((accept? (car rest))
|
|
|
|
((accept? (car rest))
|
|
|
|
(fprintf (current-error-port)
|
|
|
|
(fprintf (current-error-port)
|
|
|
|
"accept/reduce or accept/shift conflicts. Check the grammar for useless cycles of productions~n")
|
|
|
|
"accept/reduce or accept/shift conflicts. Check the grammar for useless cycles of productions\n")
|
|
|
|
(loop current-guess (cdr rest)))
|
|
|
|
(loop current-guess (cdr rest)))
|
|
|
|
(else (loop current-guess (cdr rest)))))))))
|
|
|
|
(else (loop current-guess (cdr rest)))))))))
|
|
|
|
|
|
|
|
|
|
|
@ -180,12 +180,12 @@
|
|
|
|
(unless suppress
|
|
|
|
(unless suppress
|
|
|
|
(when (> SR-conflicts 0)
|
|
|
|
(when (> SR-conflicts 0)
|
|
|
|
(fprintf (current-error-port)
|
|
|
|
(fprintf (current-error-port)
|
|
|
|
"~a shift/reduce conflict~a~n"
|
|
|
|
"~a shift/reduce conflict~a\n"
|
|
|
|
SR-conflicts
|
|
|
|
SR-conflicts
|
|
|
|
(if (= SR-conflicts 1) "" "s")))
|
|
|
|
(if (= SR-conflicts 1) "" "s")))
|
|
|
|
(when (> RR-conflicts 0)
|
|
|
|
(when (> RR-conflicts 0)
|
|
|
|
(fprintf (current-error-port)
|
|
|
|
(fprintf (current-error-port)
|
|
|
|
"~a reduce/reduce conflict~a~n"
|
|
|
|
"~a reduce/reduce conflict~a\n"
|
|
|
|
RR-conflicts
|
|
|
|
RR-conflicts
|
|
|
|
(if (= RR-conflicts 1) "" "s"))))
|
|
|
|
(if (= RR-conflicts 1) "" "s"))))
|
|
|
|
table))
|
|
|
|
table))
|
|
|
|