/[climacs]/climacs/html-syntax.lisp
ViewVC logotype

Diff of /climacs/html-syntax.lisp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by rstrandh, Fri Mar 4 07:17:44 2005 UTC revision 1.6 by rstrandh, Sat Mar 5 07:03:53 2005 UTC
# Line 20  Line 20 
20    
21  ;;; Syntax for analysing HTML  ;;; Syntax for analysing HTML
22    
23  (in-package :climacs-syntax) ;;; Put this in a separate package once it works  (in-package :climacs-html-syntax)
24    
25  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
26  ;;;  ;;;
# Line 34  Line 34 
34    (and (eq (class-of t1) (class-of t2))    (and (eq (class-of t1) (class-of t2))
35         (< (badness t1) (badness t2))))         (< (badness t1) (badness t2))))
36    
37  (defclass words (html-sym) ())  (defclass html-nonterminal (html-sym)
38      ((start-offset :initarg :start-offset :reader start-offset)
39       (end-offset :initarg :end-offset :reader end-offset)))
40    
41    (defclass words (html-nonterminal) ())
42    
43  (defclass empty-words (words) ())  (defclass empty-words (words) ())
44    
# Line 42  Line 46 
46    ((words :initarg :words)    ((words :initarg :words)
47     (word :initarg :word)))     (word :initarg :word)))
48    
49  (defclass html-balanced (html-sym)  (defclass html-balanced (html-nonterminal)
50    ((start :initarg :start)    ((start :initarg :start)
51     (end :initarg :end)))     (end :initarg :end)))
52    
# Line 195  Line 199 
199                   (tag-end (= (end-offset word) (start-offset tag-end))))                   (tag-end (= (end-offset word) (start-offset tag-end))))
200               :start-mark (start-mark tag-start))               :start-mark (start-mark tag-start))
201      (html -> (<html> head body </html>)      (html -> (<html> head body </html>)
202              :start-offset (start-offset <html>) :end-offset (end-offset </html>)
203            :start <html> :head head :body body :end </html>)            :start <html> :head head :body body :end </html>)
204      (head -> (<head> title </head>)      (head -> (<head> title </head>)
205              :start-offset (start-offset <head>) :end-offset (end-offset </head>)
206            :start <head> :title title :end </head>)            :start <head> :title title :end </head>)
207      (title -> (<title> words </title>)      (title -> (<title> words </title>)
208               :start-offset (start-offset <title>) :end-offset (end-offset </title>)
209             :start <title> :words words :end </title>)             :start <title> :words words :end </title>)
210      (body -> (<body> words </body>)      (body -> (<body> words </body>)
211              :start-offset (start-offset <body>) :end-offset (end-offset </body>)
212            :start <body> :words words :end </body>)            :start <body> :words words :end </body>)
213      (words -> ()      (words -> ()
214             (make-instance 'empty-words))             (make-instance 'empty-words :start-offset nil))
215      (words -> (words word)      (words -> (words word)
216             (make-instance 'nonempty-words :words words :word word))))             (make-instance 'nonempty-words
217                  :start-offset (or (start-offset words) (start-offset word))
218                  :end-offset (end-offset word)
219                  :words words :word word))))
220    
221  (defmethod initialize-instance :after ((syntax html-syntax) &rest args)  (defmethod initialize-instance :after ((syntax html-syntax) &rest args)
222    (declare (ignore args))    (declare (ignore args))
# Line 220  Line 231 
231                            :size 0                            :size 0
232                            :state (initial-state parser)))))                            :state (initial-state parser)))))
233    
234    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
235    ;;;
236    ;;; update syntax
237    
238  (defmethod update-syntax-for-display (buffer (syntax html-syntax) top bot)  (defmethod update-syntax-for-display (buffer (syntax html-syntax) top bot)
239    (with-slots (parser tokens valid-parse) syntax    (with-slots (parser tokens valid-parse) syntax
240       (loop until (= valid-parse (nb-elements tokens))       (loop until (= valid-parse (nb-elements tokens))
# Line 268  Line 283 
283                    (insert* tokens guess-pos (next-token scan))                    (insert* tokens guess-pos (next-token scan))
284                    (incf guess-pos))))))                    (incf guess-pos))))))
285    
286    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
287    ;;;
288    ;;; display
289    
290    
291    

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

  ViewVC Help
Powered by ViewVC 1.1.5