|
|
@ -22,10 +22,11 @@
|
|
|
|
(end #f)
|
|
|
|
(end #f)
|
|
|
|
(precs #f)
|
|
|
|
(precs #f)
|
|
|
|
(suppress #f)
|
|
|
|
(suppress #f)
|
|
|
|
(grammar #f))
|
|
|
|
(grammar #f)
|
|
|
|
|
|
|
|
(yacc-output #f))
|
|
|
|
(for-each
|
|
|
|
(for-each
|
|
|
|
(lambda (arg)
|
|
|
|
(lambda (arg)
|
|
|
|
(syntax-case* arg (debug error tokens start end precs grammar suppress src-pos)
|
|
|
|
(syntax-case* arg (debug error tokens start end precs grammar suppress src-pos yacc-output)
|
|
|
|
(lambda (a b)
|
|
|
|
(lambda (a b)
|
|
|
|
(eq? (syntax-object->datum a) (syntax-object->datum b)))
|
|
|
|
(eq? (syntax-object->datum a) (syntax-object->datum b)))
|
|
|
|
((debug filename)
|
|
|
|
((debug filename)
|
|
|
@ -95,6 +96,17 @@
|
|
|
|
(if grammar
|
|
|
|
(if grammar
|
|
|
|
(raise-syntax-error #f "Multiple grammar declarations" stx)
|
|
|
|
(raise-syntax-error #f "Multiple grammar declarations" stx)
|
|
|
|
(set! grammar arg)))
|
|
|
|
(set! grammar arg)))
|
|
|
|
|
|
|
|
((yacc-output filename)
|
|
|
|
|
|
|
|
(cond
|
|
|
|
|
|
|
|
((not (string? (syntax-object->datum (syntax filename))))
|
|
|
|
|
|
|
|
(raise-syntax-error
|
|
|
|
|
|
|
|
'parser-yacc-output
|
|
|
|
|
|
|
|
"Yacc-output filename must be a string"
|
|
|
|
|
|
|
|
(syntax filename)))
|
|
|
|
|
|
|
|
(yacc-output
|
|
|
|
|
|
|
|
(raise-syntax-error #f "Multiple yacc-output declarations" stx))
|
|
|
|
|
|
|
|
(else
|
|
|
|
|
|
|
|
(set! yacc-output (syntax-object->datum (syntax filename))))))
|
|
|
|
(_ (raise-syntax-error 'parser-args "argument must match (debug filename), (error expression), (tokens def ...), (start non-term), (end tokens ...), (precs decls ...), or (grammar prods ...)" arg))))
|
|
|
|
(_ (raise-syntax-error 'parser-args "argument must match (debug filename), (error expression), (tokens def ...), (start non-term), (end tokens ...), (precs decls ...), or (grammar prods ...)" arg))))
|
|
|
|
(syntax->list (syntax (args ...))))
|
|
|
|
(syntax->list (syntax (args ...))))
|
|
|
|
(if (not tokens)
|
|
|
|
(if (not tokens)
|
|
|
@ -117,6 +129,23 @@
|
|
|
|
precs
|
|
|
|
precs
|
|
|
|
grammar
|
|
|
|
grammar
|
|
|
|
stx)))
|
|
|
|
stx)))
|
|
|
|
|
|
|
|
(if (and yacc-output (not (string=? yacc-output "")))
|
|
|
|
|
|
|
|
(with-handlers [(exn:i/o:filesystem?
|
|
|
|
|
|
|
|
(lambda (e)
|
|
|
|
|
|
|
|
(fprintf
|
|
|
|
|
|
|
|
(current-error-port)
|
|
|
|
|
|
|
|
"Cannot write yacc-output to file \"~a\". ~a~n"
|
|
|
|
|
|
|
|
(exn:i/o:filesystem-pathname e)
|
|
|
|
|
|
|
|
(exn:i/o:filesystem-detail e))))]
|
|
|
|
|
|
|
|
(call-with-output-file yacc-output
|
|
|
|
|
|
|
|
(lambda (port)
|
|
|
|
|
|
|
|
(display-yacc (syntax-object->datum grammar)
|
|
|
|
|
|
|
|
tokens
|
|
|
|
|
|
|
|
(syntax-object->datum start)
|
|
|
|
|
|
|
|
(if precs
|
|
|
|
|
|
|
|
(syntax-object->datum precs)
|
|
|
|
|
|
|
|
#f)
|
|
|
|
|
|
|
|
port)))))
|
|
|
|
(with-syntax ((check-syntax-fix check-syntax-fix)
|
|
|
|
(with-syntax ((check-syntax-fix check-syntax-fix)
|
|
|
|
(err error)
|
|
|
|
(err error)
|
|
|
|
(ends end)
|
|
|
|
(ends end)
|
|
|
@ -309,4 +338,6 @@
|
|
|
|
"parser: Could not parse input"
|
|
|
|
"parser: Could not parse input"
|
|
|
|
#f #f #f #f #f))))))))))
|
|
|
|
#f #f #f #f #f))))))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|