((eof-object? ch) ch)
; Whitespace
- ((dlang/whitespace? in)
+ ((chobj-whitespace? ch)
(dlang/whitespace in))
; Comment
(dlang/comment in))
; Number
- ((or (and (chobj-char=? ch #\-) (dlang/integer? (buf-lookahead! in 2)))
- (char-numeric? (chobj-char ch)))
+ ((or (and (chobj-char=? ch #\-) (chobj-numeric? (buf-lookahead! in 2)))
+ (chobj-numeric? ch))
(dlang/number in))
; Character
(dlang/tokenize in))
(define (dlang/whitespace? in)
- (and (not (eof-object? (buf-lookahead! in 1)))
- (char-whitespace? (chobj-char (buf-lookahead! in 1)))))
+ (chobj-whitespace? (buf-lookahead! in 1)))
(define (dlang/comment in)
(char-match in #\#)
(define (dlang/exponent in)
(string-append
(string
- (if (and (not (eof-object? (buf-lookahead! in 1)))
- (char=? #\e (chobj-char (buf-lookahead! in 1))))
- (char-match in #\e)
- (char-match in #\E)))
- (if (and (not (eof-object? (buf-lookahead! in 1)))
- (char=? #\- (chobj-char (buf-lookahead! in 1))))
- (string (chobj-char (buf-consume! in))) "")
+ (if (chobj-char=? (buf-lookahead! in 1) #\e)
+ (char-match in #\e)
+ (char-match in #\E)))
+ (if (chobj-char=? (buf-lookahead! in 1) #\-)
+ (string (chobj-char (buf-consume! in))) "")
(dlang/integer in)))
(define (dlang/character in)
(define (dlang/string-char? in)
(define ch (buf-lookahead! in 1))
(and (not (eof-object? ch))
- (not (char=? #\newline (chobj-char ch)))
- (not (char=? #\" (chobj-char ch)))))
+ (not (chobj-char=? ch #\newline))
+ (not (chobj-char=? ch #\"))))
(define (dlang/symbol in)
(define location (buf-posdata in))
(define (dlang/id-char? in)
(define ch (buf-lookahead! in 1))
(and (not (eof-object? ch))
- (not (char-whitespace? (chobj-char ch)))
+ (not (chobj-whitespace? ch))
(case (chobj-char ch)
((#\( #\) #\; #\, #\' #\" #\$ #\#) #f)
(else #t))))
(and (not (eof-object? obj))
(char=? (chobj-char obj) ch)))
+(define (chobj-numeric? ch)
+ (and (not (eof-object? ch))
+ (char-numeric? (chobj-char ch))))
+
+(define (chobj-whitespace? ch)
+ (and (not (eof-object? ch))
+ (char-whitespace? (chobj-char ch))))
+
(define (charport-read chprt)
(define ch (read-char (charport-port chprt)))
(cond
(if (eof-object? actual)
(abort
(string-append "Expected '" (string expect) "', received EOF instead"))
- (if (equal? expect (chobj-char actual))
+ (if (chobj-char=? actual expect)
(buf-consume! buf)
(abort
(string-append