diff --git a/collects/parser-tools/private-yacc/input-file-parser.ss b/collects/parser-tools/private-yacc/input-file-parser.ss index 80063be..e20f638 100644 --- a/collects/parser-tools/private-yacc/input-file-parser.ss +++ b/collects/parser-tools/private-yacc/input-file-parser.ss @@ -105,7 +105,7 @@ (set! counter (add1 counter)))) term-list))) - ;; Retrieves the terminal symbols from a terminals-def (See terminal-syntax.xx) + ;; Retrieves the terminal symbols from a terminals-def (See terminal-syntax.ss) ;; get-terms-from-def: syntax-object -> symbol list (define (get-terms-from-def term-syn) (let ((t (syntax-local-value term-syn (lambda () #f)))) @@ -360,7 +360,14 @@ 'parser-productions "A production for a non-terminal must be (non-term right-hand-side ...) with at least 1 right hand side" prods-so)))))) - + + (if (not (memq start-sym list-of-non-terms)) + (raise-syntax-error + 'parser-start + (format "Start symbol ~a not defined as a non-terminal" + start-sym) + start)) + (set! counter 1) (let* ((start (make-non-term (gensym) 0)) (end-non-term (make-non-term (gensym) 1)) @@ -384,14 +391,7 @@ (nulls (nullable (apply append prods) (+ 2 (length non-terms))))) - - (if (not (memq start-sym list-of-non-terms)) - (raise-syntax-error - 'parser-start - (format "Start symbol ~a not defined as a non-terminal" - start-sym) - start)) - + ;; (printf "nullable: {~a}~n~n" ;; (apply string-append ;; (let loop ((i 0)) diff --git a/collects/parser-tools/private-yacc/lr0.ss b/collects/parser-tools/private-yacc/lr0.ss index 2ca949b..5bbf200 100644 --- a/collects/parser-tools/private-yacc/lr0.ss +++ b/collects/parser-tools/private-yacc/lr0.ss @@ -76,7 +76,7 @@ ;; given a non-terminal symbol C, return those non-terminal ;; symbols A s.t. C -> An for some string of terminals and ;; non-terminals n where -> means a rightmost derivation in many - ;; steps. Assumes that each non-term can be reduces to a string + ;; steps. Assumes that each non-term can be reduced to a string ;; of terms. (first-non-term (digraph (grammar-non-terms grammar) diff --git a/collects/parser-tools/private-yacc/parser-builder.ss b/collects/parser-tools/private-yacc/parser-builder.ss index 8dbb607..545ecb6 100644 --- a/collects/parser-tools/private-yacc/parser-builder.ss +++ b/collects/parser-tools/private-yacc/parser-builder.ss @@ -137,13 +137,13 @@ ,(if (token? ip) (token-value ip) #f) ,@stack))) (else - (printf "discard input:~a~n" tok) + ;; (printf "discard input:~a~n" tok) (set! ip (get-token)) (set! tok (input->token ip)) (remove-input)))))) (remove-states (lambda () - (let ((a (find-action stack 'error #f))) + (let ((a (find-action stack (make-token 'error #f) #f))) (cond ((shift? a) ;; (printf "shift:~a~n" (shift-state a))