*** 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/generate-code.ss")
(require-for-syntax "private-lex/structs.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 (provide lex define-lex-abbrev define-lex-abbrevs
make-lex-buf 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 (define-syntax lex
@ -94,16 +96,42 @@
(define-syntax define-lex-abbrev (define-syntax define-lex-abbrev
(syntax-rules () (lambda (stx)
((_ name val) (define-syntax name (syntax-case stx ()
(make-lex-abbrev (quote-syntax val)))))) ((_ 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 (define-syntax define-lex-abbrevs
(syntax-rules () (lambda (stx)
((_ (name val) ...) (syntax-case stx ()
(define-syntaxes (name ...) ((_ x ...)
(values (make-lex-abbrev (quote-syntax val)) ...))))) (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 ;; Lex buffer is NOT thread safe

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

@ -1,9 +1,9 @@
#cs #cs
(module terminal mzscheme (module token mzscheme
;; Defining tokens ;; 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?) (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 ;; routines for parsing the input to the parser generator and producing a
;; grammar (See grammar.ss) ;; 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) (provide parse-input)

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

Loading…
Cancel
Save