|
|
@ -94,18 +94,26 @@
|
|
|
|
pos)))))))))))
|
|
|
|
pos)))))))))))
|
|
|
|
(lambda (stx)
|
|
|
|
(lambda (stx)
|
|
|
|
(syntax-case stx ()
|
|
|
|
(syntax-case stx ()
|
|
|
|
((_ (re1 act1) (re act) ...)
|
|
|
|
((_)
|
|
|
|
(let* ((table (generate-table (syntax ((re1 act1) (re act) ...)) stx))
|
|
|
|
(raise-syntax-error #f "empty lexer is not allowed" stx))
|
|
|
|
(code
|
|
|
|
((_ re-act ...)
|
|
|
|
`(let ((start-state ,(table-start table))
|
|
|
|
(begin
|
|
|
|
(trans-table ,(table-trans table))
|
|
|
|
(for-each
|
|
|
|
(eof-table ,(table-eof table))
|
|
|
|
(lambda (x)
|
|
|
|
(actions (vector ,@(vector->list (table-actions table)))))
|
|
|
|
(syntax-case x ()
|
|
|
|
,code)))
|
|
|
|
((re act) (void))
|
|
|
|
(datum->syntax-object #'here code #f)))
|
|
|
|
(_ (raise-syntax-error 'lexer
|
|
|
|
(_
|
|
|
|
"expects regular expression / action pairs"
|
|
|
|
(raise-syntax-error #f "Form should be (lexer (re act) ...) with at least 1 (re ast) pair" stx))))))
|
|
|
|
x))))
|
|
|
|
|
|
|
|
(syntax->list (syntax (re-act ...))))
|
|
|
|
|
|
|
|
(let* ((table (generate-table (syntax (re-act ...)) stx))
|
|
|
|
|
|
|
|
(code
|
|
|
|
|
|
|
|
`(let ((start-state ,(table-start table))
|
|
|
|
|
|
|
|
(trans-table ,(table-trans table))
|
|
|
|
|
|
|
|
(eof-table ,(table-eof table))
|
|
|
|
|
|
|
|
(actions (vector ,@(vector->list (table-actions table)))))
|
|
|
|
|
|
|
|
,code)))
|
|
|
|
|
|
|
|
(datum->syntax-object #'here code #f))))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(define-syntax (define-lex-abbrev stx)
|
|
|
|
(define-syntax (define-lex-abbrev stx)
|
|
|
|