Commit df73af2b authored by Robert Strandh's avatar Robert Strandh

The start-mark and size of parse trees are now automatically updated

in syntax.lisp, so there is no need for individual syntax modules to
be concerned with updating them.

Started restructuring the grammar in html-syntax so that for some
grammatical entity, grammar rules, display function, class definition,
etc are grouped together.  This will probably be the preferable way of
structuring most grammars for other syntax modules as well.
parent 1e160e15
This diff is collapsed.
......@@ -87,19 +87,22 @@ the mark, according to the specified syntax."))
;;; parse tree
(defclass parse-tree ()
((start-mark :initarg :start-mark :reader start-mark)
(size :initarg :size)))
((start-mark :initform nil :initarg :start-mark :reader start-mark)
(size :initform nil :initarg :size)))
(defgeneric start-offset (parse-tree))
(defmethod start-offset ((tree parse-tree))
(offset (start-mark tree)))
(let ((mark (start-mark tree)))
(when mark
(offset mark))))
(defgeneric end-offset (parse-tree))
(defmethod end-offset ((tree parse-tree))
(with-slots (start-mark size) tree
(+ (offset start-mark) size)))
(when start-mark
(+ (offset start-mark) size))))
......@@ -275,9 +278,17 @@ position in the lexemes of LEXER"
:parse-trees (cons parse-tree (parse-trees prev-item))
:suffix remaining))
(make-instance 'complete-item
:parse-tree remaining
:parse-trees (cons parse-tree (parse-trees prev-item)))))))
(let* ((parse-trees (cons parse-tree (parse-trees prev-item)))
(start (find-if-not #'null parse-trees
:from-end t :key #'start-offset))
(end (find-if-not #'null parse-trees :key #'end-offset)))
(with-slots (start-mark size) remaining
(when start
(setf start-mark (start-mark start)
size (- (end-offset end) (start-offset start))))
(make-instance 'complete-item
:parse-tree remaining
:parse-trees parse-trees)))))))
(defgeneric item-equal (item1 item2))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment