Commits

Anonymous committed 7f1c304

Renamed some methods/slots to reference tokens rather than characters, in preparation for moving to token streams, not character streams

Comments (0)

Files changed (5)

   )
 
 (defun copy-parser ( a-parser )
-  (with-slots ( threads thread-counter results position ready-for-character last-character-read-successfully) a-parser
+  (with-slots ( threads thread-counter results position ready-for-token last-token-read-successfully) a-parser
     (make-instance 'parser 
 		   ;; :code  not serialized at this time, because we may not be able to do that
 		   :position position
 		   :threads (loop for thread in threads
 				 collect (copy-thread thread)
 				 )
-		   :ready ready-for-character
-		   :last last-character-read-successfully
+		   :ready ready-for-token
+		   :last last-token-read-successfully
 		   )
     )
   )
 (defgeneric (setf parse-position ) ( code position )
   )
 
-(defgeneric wants-character-p (node)
+(defgeneric wants-token-p (node)
   )
 
-(defgeneric next-parse-character ( code )
+(defgeneric next-parse-token ( code )
   )
 
-(defgeneric end-parse-characters-p ( code )
+(defgeneric end-parse-token-p ( code )
   )
 
 (defgeneric continue-parse (parser thread node)
   )
 
-(defgeneric next-character ( parser )
+(defgeneric next-token ( parser )
   )
 
 (defgeneric end-p ( parser )
 	  ;; get ready for character
 	  (trace-parser "P: Getting ready for character~%")
 	  (loop while (threads-of parser)
-	     do (setf (ready-for-character parser) t)
+	     do (setf (ready-for-token parser) t)
 	       (loop for thread in (threads-of parser)
 		  do (loop while (and (not (thread-completed-p thread)) (stack-of thread) )
 			;; TODO yeah, still don't have this cleaned up
 			for frame = (first stack)
 			for node = (node-in frame)
 			;; until ready for character
-			until (wants-character-p node)
+			until (wants-token-p node)
 			do (continue-parse parser thread node)
 			  )
 		    )
-	     until (ready-for-character parser)
+	     until (ready-for-token parser)
 	       )
 
 	  ;; handle next character, if any remaining
 	  (loop for thread in (threads-of parser)
 	     ;; theoretically, the nil will cause nodes to start failing
 	     ;; and eventually cause threads to flush, thus exiting the outer loop
-	     with character = (if (end-p parser) nil (next-character parser) )
+	     with character = (if (end-p parser) nil (next-token parser) )
 	     do (trace-parser "P: Reading character ~a~%" character)
 	     do (when character
-		  (setf (last-character-read-successfully parser) nil)
+		  (setf (last-token-read-successfully parser) nil)
 		  ) 
 	     do (when (and (not (thread-completed-p thread)) (stack-of thread) )
 		  (let*(
   )
 
 (defmethod parse-result ( (parser parser) )
-  (if (and (end-p parser) (results-of parser) (last-character-read-successfully parser) )
+  (if (and (end-p parser) (results-of parser) (last-token-read-successfully parser) )
       (let (
 	    (results (results-of parser))
 	    )
 		  )
 	  )
     ;; reset readiness for characters; new thread needs a chance to continue
-    (setf (ready-for-character parser) nil) 
+    (setf (ready-for-token parser) nil) 
     thread
     )
   )
   (typep (status-of thread) 'thread-completion-status)
   )
 
-(defmethod next-character ( (parser parser) )
+(defmethod next-token ( (parser parser) )
   (let (
-	(c (next-parse-character (code parser)) )
+	(c (next-parse-token (code parser)) )
 	)
     (setf (position-of parser) (parse-position (code parser)) )
     c
   )
 
 (defmethod end-p ( (parser parser) )
-  (end-parse-characters-p (code parser) )
+  (end-parse-tokens-p (code parser) )
   )
 
 (defmethod call-node (parser thread node)
 
 (defmethod return-from-node (parser thread value)
   (setf (value-of thread) value)
-  (setf (last-character-read-successfully parser) 
-	(or (last-character-read-successfully parser)
+  (setf (last-token-read-successfully parser) 
+	(or (last-token-read-successfully parser)
 	    value
 	    )
 	)
   (file-position code position)
   )
 
-(defmethod wants-character-p ( (node parse-node) )
+(defmethod wants-token-p ( (node parse-node) )
   nil
   )
 
-(defmethod wants-character-p ( (node literal-node) )
+(defmethod wants-token-p ( (node literal-node) )
   (slot-value node 'called)
   )
 
-(defmethod wants-character-p ( (node character-class-node) )
+(defmethod wants-token-p ( (node character-class-node) )
   (slot-value node 'called)
   )
 
-(defmethod next-parse-character ( (code stream) )
+(defmethod next-parse-token ( (code stream) )
   (read-char code nil nil)
   )
 
-(defmethod end-parse-characters-p ( (code stream) )
+(defmethod end-parse-tokens-p ( (code stream) )
   (equal :eof (peek-char nil code nil :eof) )
   )
 
 			   (write-string " :index " stream)
 			   (write (index-of obj) :stream stream)
 			   )
-		       (when (wants-character obj)
+		       (when (wants-token obj)
 			   (write-string " :wants " stream)
-			   (write (wants-character obj) :stream stream)
+			   (write (wants-token obj) :stream stream)
 			   )
 		       )
   )
    (stop-postion :initform () :initarg :stop :accessor stop-position-of)
    ;; non-serialized state
    (code :initarg :code :accessor code)
-   (ready-for-character :initform t :initarg :ready :accessor ready-for-character)
-   (last-character-read-successfully :initform t :initarg :last :accessor last-character-read-successfully)
+   (ready-for-token :initform t :initarg :ready :accessor ready-for-token)
+   (last-token-read-successfully :initform t :initarg :last :accessor last-token-read-successfully)
    )
   )
 
   (
    (index :initform 0 :initarg :index :accessor index-of)
    (literal :initarg :literal :accessor literal)
-   (wants-character :initform nil :initarg :wants :accessor wants-character)
+   (wants-token :initform nil :initarg :wants :accessor wants-token)
    )
   )