*** empty log message ***

original commit: 3ea7c7c7074409e1eaf541fe623f0a7229d2e7d0
tokens
Scott Owens 23 years ago
parent d108ca625d
commit 00bae08fd7

@ -5,10 +5,12 @@
(require-for-syntax "private-lex/generate-code.ss")
(require-for-syntax "private-lex/structs.ss")
(require (lib "list.ss"))
(require (lib "list.ss")
"private-lex/token.ss")
(provide lex define-lex-abbrev define-lex-abbrevs
make-lex-buf
get-position position-offset position-line position-col position?)
get-position position-offset position-line position-col position?
define-tokens define-empty-tokens)
(define-syntax lex
@ -91,19 +93,45 @@
,code)))
(datum->syntax-object #'here code #f)))))))
(define-syntax define-lex-abbrev
(syntax-rules ()
((_ name val) (define-syntax name
(make-lex-abbrev (quote-syntax val))))))
(lambda (stx)
(syntax-case stx ()
((_ name val)
(syntax
(define-syntax name
(make-lex-abbrev (quote-syntax val)))))
(_
(raise-syntax-error
#f
"Form should be (define-lex-abbrev name val)"
stx)))))
(define-syntax define-lex-abbrevs
(syntax-rules ()
((_ (name val) ...)
(define-syntaxes (name ...)
(values (make-lex-abbrev (quote-syntax val)) ...)))))
(lambda (stx)
(syntax-case stx ()
((_ x ...)
(let* ((abbrev (syntax->list (syntax (x ...))))
(r (map (lambda (a)
(syntax-case a ()
((name val)
(identifier? (syntax name))
(syntax (define-lex-abbrev name val)))
(_ (raise-syntax-error
#f
"Lexer abbreviation must be (identifier value)"
a))))
abbrev)))
(datum->syntax-object
#'here
(cons 'begin r)
stx)))
(_
(raise-syntax-error
#f
"Form should be (define-lex-abbrevs (name val) ...)"
stx)))))
;; Lex buffer is NOT thread safe

@ -1,5 +1,5 @@
#cs
(module terminal-syntax mzscheme
(module token-syntax mzscheme
;; The things needed at compile time to handle definition of tokens

@ -1,9 +1,9 @@
#cs
(module terminal mzscheme
(module token mzscheme
;; Defining tokens
(require-for-syntax "terminal-syntax.ss")
(require-for-syntax "token-syntax.ss")
(provide define-tokens define-empty-tokens token-name token-value token?)

@ -4,7 +4,7 @@
;; routines for parsing the input to the parser generator and producing a
;; grammar (See grammar.ss)
(require "yacc-helper.ss" "terminal-syntax.ss" "grammar.ss" (lib "list.ss"))
(require "yacc-helper.ss" "../private-lex/token-syntax.ss" "grammar.ss" (lib "list.ss"))
(provide parse-input)

@ -3,11 +3,11 @@
(require-for-syntax "private-yacc/parser-builder.ss"
"private-yacc/yacc-helper.ss")
(require "private-yacc/terminal.ss"
"private-yacc/parser-actions.ss"
"private-yacc/array2d.ss")
(require "private-yacc/parser-actions.ss"
"private-yacc/array2d.ss"
"private-lex/token.ss")
(provide define-tokens define-empty-tokens parser)
(provide parser)
(define-syntax parser
(lambda (stx)

Loading…
Cancel
Save