|
|
@ -71,11 +71,9 @@
|
|
|
|
(get-special-action spec/re-act-lst #'eof #''eof))
|
|
|
|
(get-special-action spec/re-act-lst #'eof #''eof))
|
|
|
|
(spec-act
|
|
|
|
(spec-act
|
|
|
|
(get-special-action spec/re-act-lst #'special #'(void)))
|
|
|
|
(get-special-action spec/re-act-lst #'special #'(void)))
|
|
|
|
(spec-error-act
|
|
|
|
|
|
|
|
(get-special-action spec/re-act-lst #'special-error #'(raise lexeme)))
|
|
|
|
|
|
|
|
(spec-comment-act
|
|
|
|
(spec-comment-act
|
|
|
|
(get-special-action spec/re-act-lst #'special-comment #'#f))
|
|
|
|
(get-special-action spec/re-act-lst #'special-comment #'#f))
|
|
|
|
(ids (list #'special #'special-comment #'special-error #'eof))
|
|
|
|
(ids (list #'special #'special-comment #'eof))
|
|
|
|
(re-act-lst
|
|
|
|
(re-act-lst
|
|
|
|
(filter
|
|
|
|
(filter
|
|
|
|
(lambda (spec/re-act)
|
|
|
|
(lambda (spec/re-act)
|
|
|
@ -123,8 +121,6 @@
|
|
|
|
((act-name ...) (vector->list action-names))
|
|
|
|
((act-name ...) (vector->list action-names))
|
|
|
|
(spec-act-stx
|
|
|
|
(spec-act-stx
|
|
|
|
(wrap-action spec-act src-pos?))
|
|
|
|
(wrap-action spec-act src-pos?))
|
|
|
|
(spec-error-act-stx
|
|
|
|
|
|
|
|
(wrap-action spec-error-act src-pos?))
|
|
|
|
|
|
|
|
(has-comment-act?-stx
|
|
|
|
(has-comment-act?-stx
|
|
|
|
(if (syntax-e spec-comment-act) #t #f))
|
|
|
|
(if (syntax-e spec-comment-act) #t #f))
|
|
|
|
(spec-comment-act-stx
|
|
|
|
(spec-comment-act-stx
|
|
|
@ -138,7 +134,6 @@
|
|
|
|
(vector act-name ...)
|
|
|
|
(vector act-name ...)
|
|
|
|
no-lookahead-stx
|
|
|
|
no-lookahead-stx
|
|
|
|
spec-act-stx
|
|
|
|
spec-act-stx
|
|
|
|
spec-error-act-stx
|
|
|
|
|
|
|
|
has-comment-act?-stx
|
|
|
|
has-comment-act?-stx
|
|
|
|
spec-comment-act-stx
|
|
|
|
spec-comment-act-stx
|
|
|
|
eof-act-stx)))
|
|
|
|
eof-act-stx)))
|
|
|
@ -220,8 +215,7 @@
|
|
|
|
(get-next-state-helper char 0 (vector-length table) table)
|
|
|
|
(get-next-state-helper char 0 (vector-length table) table)
|
|
|
|
#f))
|
|
|
|
#f))
|
|
|
|
|
|
|
|
|
|
|
|
(define (lexer-body start-state trans-table actions no-lookahead
|
|
|
|
(define (lexer-body start-state trans-table actions no-lookahead special-action
|
|
|
|
special-action special-error-action
|
|
|
|
|
|
|
|
has-special-comment-action? special-comment-action eof-action)
|
|
|
|
has-special-comment-action? special-comment-action eof-action)
|
|
|
|
(letrec ((lexer
|
|
|
|
(letrec ((lexer
|
|
|
|
(lambda (ip)
|
|
|
|
(lambda (ip)
|
|
|
@ -231,23 +225,15 @@
|
|
|
|
(cond
|
|
|
|
(cond
|
|
|
|
((eof-object? first-char)
|
|
|
|
((eof-object? first-char)
|
|
|
|
(do-match ip first-pos eof-action (read-char-or-special ip)))
|
|
|
|
(do-match ip first-pos eof-action (read-char-or-special ip)))
|
|
|
|
((not (char? first-char))
|
|
|
|
((special-comment? first-char)
|
|
|
|
(let* ((comment? #f)
|
|
|
|
(read-char-or-special ip)
|
|
|
|
(error? #f)
|
|
|
|
|
|
|
|
(spec (with-handlers ((special-comment?
|
|
|
|
|
|
|
|
(lambda (x) (set! comment? #t)))
|
|
|
|
|
|
|
|
(exn:fail?
|
|
|
|
|
|
|
|
(lambda (ex) (set! error? #t) ex)))
|
|
|
|
|
|
|
|
(read-char-or-special ip))))
|
|
|
|
|
|
|
|
(cond
|
|
|
|
(cond
|
|
|
|
((and comment? (not has-special-comment-action?))
|
|
|
|
(has-special-comment-action?
|
|
|
|
(lexer ip))
|
|
|
|
(do-match ip first-pos special-comment-action #f))
|
|
|
|
(else
|
|
|
|
(else (lexer ip))))
|
|
|
|
(do-match ip first-pos (cond
|
|
|
|
((not (char? first-char))
|
|
|
|
(comment? special-comment-action)
|
|
|
|
(let ((spec (read-char-or-special ip)))
|
|
|
|
(error? special-error-action)
|
|
|
|
(do-match ip first-pos special-action (read-char-or-special ip))))
|
|
|
|
(else special-action))
|
|
|
|
|
|
|
|
spec)))))
|
|
|
|
|
|
|
|
(else
|
|
|
|
(else
|
|
|
|
(let lexer-loop (
|
|
|
|
(let lexer-loop (
|
|
|
|
;; current-state
|
|
|
|
;; current-state
|
|
|
@ -267,7 +253,6 @@
|
|
|
|
(longest-match-length 0))
|
|
|
|
(longest-match-length 0))
|
|
|
|
(let ((next-state
|
|
|
|
(let ((next-state
|
|
|
|
(cond
|
|
|
|
(cond
|
|
|
|
((eof-object? char) #f)
|
|
|
|
|
|
|
|
((not (char? char)) #f)
|
|
|
|
((not (char? char)) #f)
|
|
|
|
(else (get-next-state (char->integer char)
|
|
|
|
(else (get-next-state (char->integer char)
|
|
|
|
(vector-ref trans-table state))))))
|
|
|
|
(vector-ref trans-table state))))))
|
|
|
|