#| -*-Scheme-*-
-$Id: parser-buffer.scm,v 1.19 2007/01/17 02:48:51 cph Exp $
+$Id: parser-buffer.scm,v 1.20 2007/01/17 03:39:35 cph Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
(declare (usual-integrations))
\f
-;;;; Parser buffer abstraction
-
(define-structure parser-buffer
;; The string buffer, as a substring:
string
(make-parser-buffer (make-wide-string min-length) 0 0 0 0 port #f 0))
(define-integrable min-length 256)
+
+(define (complete-*match matcher buffer)
+ (and (matcher buffer)
+ (not (peek-parser-buffer-char buffer))))
+
+(define (*match-string matcher string #!optional start end)
+ (complete-*match matcher (string->parser-buffer string start end)))
+
+(define (*match-utf8-string matcher string #!optional start end)
+ (complete-*match matcher (utf8-string->parser-buffer string start end)))
+
+(define (*match-symbol matcher symbol)
+ (*match-utf8-string matcher (symbol-name symbol)))
+
+(define (complete-*parse parser buffer)
+ (let ((v (parser buffer)))
+ (and v
+ (not (peek-parser-buffer-char buffer))
+ v)))
+
+(define (*parse-string parser string #!optional start end)
+ (complete-*parse parser (string->parser-buffer string start end)))
+
+(define (*parse-utf8-string parser string #!optional start end)
+ (complete-*parse parser (utf8-string->parser-buffer string start end)))
+
+(define (*parse-symbol parser symbol)
+ (*parse-utf8-string parser (symbol-name symbol)))
\f
(define-structure parser-buffer-pointer
(index #f read-only #t)
#| -*-Scheme-*-
-$Id: runtime.pkg,v 14.611 2007/01/17 02:48:57 cph Exp $
+$Id: runtime.pkg,v 14.612 2007/01/17 03:39:42 cph Exp $
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
(parent (runtime))
(export ()
(match-utf8-char-in-alphabet match-parser-buffer-char-in-alphabet)
+ *match-string
+ *match-symbol
+ *match-utf8-string
+ *parse-string
+ *parse-symbol
+ *parse-utf8-string
call-with-parser-buffer-tail
+ complete-*match
+ complete-*parse
discard-parser-buffer-head!
get-parser-buffer-pointer
get-parser-buffer-tail