*** empty log message ***

original commit: 9d9b93bd8026bff1c523a7257a4d4eafefb15752
tokens
Scott Owens 23 years ago
parent 62a86122aa
commit b7c01baf15

@ -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))

@ -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)

@ -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))

Loading…
Cancel
Save