Commits

Phil Hargett  committed fb3b71e

More progress towards tokenizing. Separated HTML tokens out into a separate file, and based the grammar on that.

  • Participants
  • Parent commits 7f1c304

Comments (0)

Files changed (3)

File generics.lisp

 (defgeneric empty-node-p (node)
   )
 
-(defgeneric parse-position ( code )
-  )
-
-(defgeneric (setf parse-position ) ( code position )
+(defgeneric continue-parse (parser thread node)
   )
 
 (defgeneric wants-token-p (node)
   )
 
-(defgeneric next-parse-token ( code )
-  )
-
-(defgeneric end-parse-token-p ( code )
-  )
-
-(defgeneric continue-parse (parser thread node)
-  )
-
 (defgeneric next-token ( parser )
   )
 
 (defgeneric copy-node ( node &optional context-hash)
   )
 
+(defgeneric capture-value ( node value )
+  )
+
+;; Token stream methods
+
+(defgeneric parse-position ( tokens )
+  )
+
+(defgeneric (setf parse-position ) ( tokens position )
+  )
+
+(defgeneric next-parse-token ( tokens )
+  )
+
+(defgeneric end-parse-token-p ( tokens )
+  )
+
 (defgeneric positions-equal ( left right)
   (:documentation "Return true if the left and right positions are equal")
   )
 
-(defgeneric capture-value ( node value )
-  )
   t
   )
 
-;; Implementation for stream-based code
-
-(defmethod parse-position ( (code stream) )
-  (file-position code)
-  )
-
-(defmethod (setf parse-position ) ( position (code stream) )
-  (file-position code position)
-  )
-
 (defmethod wants-token-p ( (node parse-node) )
   nil
   )
   (slot-value node 'called)
   )
 
-(defmethod next-parse-token ( (code stream) )
-  (read-char code nil nil)
-  )
-
-(defmethod end-parse-tokens-p ( (code stream) )
-  (equal :eof (peek-char nil code nil :eof) )
-  )
-
-(defmethod positions-equal ( (left t) (right t) )
-  (equal left right)
-  )
+;; capture semantics
 
 (defmethod capture-value ( (node capture-node) value )
   (handler-case  (with-slots (slot target transform) node
 		  )
 	  )
     )
-  )
+  )
+
+;; Implementation for stream-based token streams
+
+(defmethod parse-position ( (tokens stream) )
+  (file-position tokens)
+  )
+
+(defmethod (setf parse-position ) ( position (tokens stream) )
+  (file-position tokens position)
+  )
+
+(defmethod next-parse-token ( (tokens stream) )
+  (read-char tokens nil nil)
+  )
+
+(defmethod end-parse-tokens-p ( (tokens stream) )
+  (equal :eof (peek-char nil tokens nil :eof) )
+  )
+
+(defmethod positions-equal ( (left t) (right t) )
+  (equal left right)
+  )
+
    )
   )
 
-(defclass parse-stream ()
+(defclass token-stream ()
   (
    )
   (:documentation "A marker type for indicating streams supporting a parsing position interface")