diff --git a/css-lexer.lisp b/css-lexer.lisp
index 4a187dd..664da97 100644
--- a/css-lexer.lisp
+++ b/css-lexer.lisp
@@ -106,16 +106,16 @@
(when (or (<= (char-code #\0) c (char-code #\9))
(<= (char-code #\a) c (char-code #\f))
(<= (char-code #\A) c (char-code #\F)))
- (incf (parser-match-start p)))))
+ (incf (parser-char-match-start p)))))
(defmethod match-escape ((p parser))
(match-sequence p
(and (match p #\\)
(or (when (match-times p #'match-hex-digit 1 6)
(match-whitespace p)
- (parser-match-start p))
+ (parser-char-match-start p))
(when (not (match-newline p))
- (parser-match-start p))))))
+ (parser-char-match-start p))))))
(defmethod whitespace-token ((p parser))
(push-token p)
@@ -135,7 +135,7 @@
(= (char-code #\_) c)
(= (char-code #\-) c)
(< #x007F c))
- (incf (parser-match-start p))))))
+ (incf (parser-char-match-start p))))))
(defmethod match-ident-char* ((p parser))
(match-times p #'match-ident-char 0 nil))
@@ -150,7 +150,7 @@
(<= (char-code #\A) c (char-code #\Z))
(= (char-code #\_) c)
(< #x007F c))
- (incf (parser-match-start p)))))
+ (incf (parser-char-match-start p)))))
(match-ident-char* p)
(make-token p 'ident-token))
(t
@@ -216,7 +216,7 @@
(= #x000B c)
(<= #x000E c #x001F)
(= #x007F c))
- (incf (parser-match-start p)))))
+ (incf (parser-char-match-start p)))))
(defmethod match-url-unquoted-char ((p parser))
(or (match-escape p)
@@ -252,7 +252,7 @@
(defmethod match-digit ((p parser))
(let ((c (the fixnum (parser-match-char p))))
(when (<= (char-code #\0) c (char-code #\9))
- (incf (parser-match-start p)))))
+ (incf (parser-char-match-start p)))))
(defmethod match-digit+ ((p parser))
(match-times p #'match-digit 1 nil))
@@ -278,7 +278,7 @@
(match p #\+)
t)
(match-digit+ p)))
- (parser-match-start p))))
+ (parser-char-match-start p))))
(make-token p 'number-token)
(discard-token p)))
@@ -315,9 +315,9 @@
(match p #\-)
(match-times p #'match-hex-digit 1 6)))
(match-sequence p
- (let ((start (parser-match-start p)))
+ (let ((start (parser-char-match-start p)))
(and (match-times p #'match-hex-digit 0 5)
- (let ((digits (- (parser-match-start p) start)))
+ (let ((digits (- (parser-char-match-start p) start)))
(match-times p (lambda (p) (match p #\?))
1 (- 6 digits))))))
(match-times p #'match-hex-digit 1 6))
@@ -435,7 +435,7 @@
(defmethod delim-token ((p parser))
(push-token p)
(input-length p 1)
- (incf (parser-match-start p))
+ (incf (parser-char-match-start p))
(make-token p 'delim-token))
;; CSS lexer
diff --git a/input.lisp b/input.lisp
index b2561df..57180cb 100644
--- a/input.lisp
+++ b/input.lisp
@@ -1,46 +1,46 @@
(in-package :parse-css)
-(defgeneric ib-string (ib start end))
-(defgeneric ib-push-extend (parser character))
+(defgeneric cb-string (cb start end))
+(defgeneric cb-push-extend (parser character))
(defgeneric input-char (parser))
(defgeneric input-length (parser length))
(defgeneric parser-match-char (parser &optional char-index))
-(defun make-input-buffer (&optional string (start 0))
+(defun make-character-buffer (&optional string (start 0))
(let* ((length (when string (- (length string) start)))
- (ib (make-array (if string
+ (cb (make-array (if string
(* 64 (ceiling length 64))
64)
:element-type 'fixnum
:adjustable t
:fill-pointer 0)))
(when string
- (setf (fill-pointer ib) length)
- (replace ib string :start2 start))
- ib))
+ (setf (fill-pointer cb) length)
+ (replace cb string :start2 start))
+ cb))
-(defmethod ib-string ((ib array) (start fixnum) (end fixnum))
+(defmethod cb-string ((cb array) (start fixnum) (end fixnum))
(let* ((length (- end start))
(s (make-string length)))
(labels ((at (i j)
- (let ((ib-char (aref ib i)))
+ (let ((cb-char (aref cb i)))
(unless (or (= length j)
- (= ib-char -1))
- (setf (char s j) (code-char ib-char))
+ (= cb-char -1))
+ (setf (char s j) (code-char cb-char))
(at (1+ i) (1+ j))))))
(at start 0))))
-(defmethod ib-push-extend ((p parser) (c fixnum))
- (let ((ib (parser-ib p)))
- (let* ((fill-pointer (fill-pointer ib))
+(defmethod cb-push-extend ((p parser) (c fixnum))
+ (let ((cb (parser-cb p)))
+ (let* ((fill-pointer (fill-pointer cb))
(new-fill-pointer (1+ fill-pointer)))
- (if (= fill-pointer (array-dimension ib 0))
- (setf (parser-ib p) (adjust-array ib (+ fill-pointer 64)
+ (if (= fill-pointer (array-dimension cb 0))
+ (setf (parser-cb p) (adjust-array cb (+ fill-pointer 64)
:fill-pointer new-fill-pointer))
- (setf (fill-pointer ib) new-fill-pointer))
+ (setf (fill-pointer cb) new-fill-pointer))
(locally (declare (optimize (safety 0)))
- (setf (aref ib fill-pointer) c))
+ (setf (aref cb fill-pointer) c))
fill-pointer)))
(defun read-char-code (stream)
@@ -50,10 +50,10 @@
(defmethod input-char ((p parser))
(let* ((in (parser-input p))
(c (read-char-code in))
- (pos (ib-push-extend p c)))
+ (pos (cb-push-extend p c)))
(cond ((or (and (= #x000A c)
(not (and (< 0 pos)
- (= #x000D (aref (parser-ib p) (1- pos))))))
+ (= #x000D (aref (parser-cb p) (1- pos))))))
(= #x000D c)
(= #x000C c))
(setf (parser-input-character p) 0)
@@ -63,12 +63,12 @@
c))
(defmethod input-length ((p parser) (length fixnum))
- (when (< (- (fill-pointer (parser-ib p))
- (parser-match-start p))
+ (when (< (- (fill-pointer (parser-cb p))
+ (parser-char-match-start p))
length)
(input-char p)
(input-length p length)))
(defmethod parser-match-char ((p parser) &optional (index 0))
(input-length p (1+ index))
- (aref (parser-ib p) (+ (parser-match-start p) index)))
+ (aref (parser-cb p) (+ (parser-char-match-start p) index)))
diff --git a/matcher.lisp b/matcher.lisp
index a4381c8..cbd7d6a 100644
--- a/matcher.lisp
+++ b/matcher.lisp
@@ -1,22 +1,22 @@
(in-package :parse-css)
-(defgeneric ib= (parser item &key start1))
+(defgeneric cb= (parser item &key start1))
(defgeneric match (parser item))
(defgeneric match-until (parser item))
(defgeneric match-option (parser function))
(defgeneric match-times (parser function min max))
-(defmethod ib= ((p parser) (s string) &key (start1 0))
- (let ((ib (parser-ib p))
+(defmethod cb= ((p parser) (s string) &key (start1 0))
+ (let ((cb (parser-cb p))
(end (length s)))
- (when (<= end (- (fill-pointer ib) start1))
+ (when (<= end (- (fill-pointer cb) start1))
(locally (declare (optimize (safety 0)))
(labels ((at (m i)
(declare (type fixnum m i))
(cond ((= end i)
t)
- ((= (aref ib m) (char-code (char s i)))
+ ((= (aref cb m) (char-code (char s i)))
(at (the fixnum (1+ m)) (the fixnum (1+ i))))
(t
nil))))
@@ -24,12 +24,12 @@
(defmethod match ((p parser) (s string))
(input-length p (length s))
- (when (ib= p s :start1 (parser-match-start p))
- (incf (parser-match-start p) (length s))))
+ (when (cb= p s :start1 (parser-char-match-start p))
+ (incf (parser-char-match-start p) (length s))))
(defmethod match ((p parser) (c fixnum))
(when (= (the fixnum (parser-match-char p)) c)
- (incf (parser-match-start p))))
+ (incf (parser-char-match-start p))))
(defmethod match ((p parser) (c character))
(match p (char-code c)))
@@ -41,39 +41,39 @@
(and (not (match p -1))
(progn
(input-char p)
- (incf (parser-match-start p))
+ (incf (parser-char-match-start p))
(maybe-eat))))))
(maybe-eat)))
(defmethod match-option ((p parser) (f function))
(or (funcall f p)
- (parser-match-start p)))
+ (parser-char-match-start p)))
(defmacro match-not (p &body body)
(let ((parser (gensym "PARSER-"))
(match-start (gensym "MATCH-START-"))
(result (gensym "RESULT-")))
`(let* ((,parser ,p)
- (,match-start (parser-match-start ,parser))
+ (,match-start (parser-char-match-start ,parser))
(,result (progn ,@body)))
(cond ((or ,result
(match p -1))
- (setf (parser-match-start ,parser) ,match-start)
+ (setf (parser-char-match-start ,parser) ,match-start)
nil)
(t
- (incf (parser-match-start p)))))))
+ (incf (parser-char-match-start p)))))))
(defmacro match-sequence (p &body body)
(let ((parser (gensym "PARSER-"))
(match-start (gensym "MATCH-START-"))
(result (gensym "RESULT-")))
`(let* ((,parser ,p)
- (,match-start (parser-match-start ,parser))
+ (,match-start (parser-char-match-start ,parser))
(,result (progn ,@body)))
(cond (,result
,result)
(t
- (setf (parser-match-start ,parser) ,match-start)
+ (setf (parser-char-match-start ,parser) ,match-start)
nil)))))
(defmethod match-times ((p parser) (f function) (min fixnum) (max fixnum))
@@ -92,7 +92,7 @@
(decf max)
(match-max))
(t
- (parser-match-start p)))))
+ (parser-char-match-start p)))))
(match-min))))
(defmethod match-times ((p parser) (f function) (min fixnum) (max null))
@@ -109,5 +109,5 @@
(cond ((funcall f p)
(match-max))
(t
- (parser-match-start p)))))
+ (parser-char-match-start p)))))
(match-min))))
diff --git a/parser.lisp b/parser.lisp
index 71822b6..4b9cfd0 100644
--- a/parser.lisp
+++ b/parser.lisp
@@ -33,12 +33,12 @@
:type fixnum)
(eof :initform nil
:accessor parser-eof)
- (ib :initform (make-input-buffer)
- :accessor parser-ib
+ (cb :initform (make-character-buffer)
+ :accessor parser-cb
:type array)
- (match-start :initform 0
- :accessor parser-match-start
- :type fixnum)
+ (char-match-start :initform 0
+ :accessor parser-char-match-start
+ :type fixnum)
(token-stack :initform ()
:accessor parser-token-stack
:type list)
diff --git a/tokenizer.lisp b/tokenizer.lisp
index 56628b5..05462fc 100644
--- a/tokenizer.lisp
+++ b/tokenizer.lisp
@@ -8,24 +8,24 @@
(defmethod push-token ((p parser))
(let ((token (make-instance 'parser-token
- :start (parser-match-start p)
+ :start (parser-char-match-start p)
:line (parser-input-line p)
:character (parser-input-character p))))
(push token (parser-token-stack p))))
(defmethod pop-token ((p parser))
(assert (parser-token-stack p))
- (let* ((ib (parser-ib p))
- (fill-pointer (fill-pointer ib))
+ (let* ((cb (parser-cb p))
+ (fill-pointer (fill-pointer cb))
(token (pop (parser-token-stack p)))
- (match-start (parser-match-start p)))
- (setf (token-string token) (ib-string ib
+ (match-start (parser-char-match-start p)))
+ (setf (token-string token) (cb-string cb
(token-start token)
match-start))
(when (endp (parser-token-stack p))
- (replace ib ib :start2 match-start :end2 fill-pointer)
- (setf (parser-match-start p) 0
- (fill-pointer (parser-ib p)) (- fill-pointer match-start)))
+ (replace cb cb :start2 match-start :end2 fill-pointer)
+ (setf (parser-char-match-start p) 0
+ (fill-pointer (parser-cb p)) (- fill-pointer match-start)))
token))
(defmethod make-token ((p parser) (class symbol) &rest initargs)