Mon Nov 16 09:02:50 UTC 2009 pix@kepibu.org
* Status commit
hunk ./regexp-template.lisp 32
- (format t "rex: ~s, ~s~%"
- (concatenate 'string "^(.*?)" regexp "$")
- (append '(?&rest) vars))
hunk ./selectors.lisp 76
+#+FIXME ; is this the right name?
+(defclass universal-selector (simple-selector) ())
hunk ./selectors.lisp 87
-;; forwards
-#+(or)
hunk ./selectors.lisp 90
- (#T(regexp+ "^[ ]*[>][ ]*" ()) (list (make-instance 'child-combinator :matcher (parse-selector &rest))))
- (#T(regexp+ "^[ ]+" ()) (list (make-instance 'descendant-combinator :matcher (parse-selector &rest))))
+ (#T(regexp$ "[ ]*[>][ ]*" ()) (list (make-instance 'child-combinator :matcher (parse-selector &rest))))
+ (#T(regexp$ "[ ]+" ()) (list (make-instance 'descendant-combinator :matcher (parse-selector &rest))))
hunk ./selectors.lisp 93
- (#T(regexp+ "^(\\w+)" (?type)) (cons (make-instance 'type-selector :arg type) (parse-selector &rest)))
- (#T(regexp+ "^[#](\\w+)" (?id)) (cons (make-instance 'id-selector :arg id) (parse-selector &rest)))
- (#T(regexp+ "^[\\.](\\w+)" (?class)) (cons (make-instance 'class-selector :arg class) (parse-selector &rest)))))
-
-;; backwards
-;; FIXME: somehow, selector is ending up as "NIL"
-(defun parse-selector (selector)
- (when (string= "NIL" selector) (error "selector is nil"))
- (format t "selector: ~s~%" selector)
- (macrolet ((prest (x) `(format t "rest~s: ~S~%" ,x &rest)))
- (match-case (selector)
- ;; combinators
- (#T(regexp$ "[ ]*[>][ ]*" ()) (prest 'a) (list (make-instance 'child-combinator :matcher (parse-selector &rest))))
- (#T(regexp$ "[ ]+" ()) (prest 'b) (list (make-instance 'descendant-combinator :matcher (parse-selector &rest))))
- ;; simple selector
- (#T(regexp$ "[#](\\w+)" (?id)) (prest 'c) (cons (make-instance 'id-selector :arg id) (parse-selector &rest)))
- (#T(regexp$ "[\\.](\\w+)" (?class)) (prest 'd) (cons (make-instance 'class-selector :arg class) (parse-selector &rest)))
- (#T(regexp$ "(\\w+)" (?type)) (prest 'e) (cons (make-instance 'type-selector :arg type) (parse-selector &rest))))))
-
-
-;; FIXME: the find/matches split seems to be causing me some mental
-;; trouble. I'm not sure how to handle combinators now. (Not that I
-;; was doing very well with them before.)
-;;
-;; Should probably map this out on a whiteboard. I'm not doing very
-;; well with just trying to hack it.
+ (#T(regexp$ "[#](\\w+)" (?id)) (cons (make-instance 'id-selector :arg id) (parse-selector &rest)))
+ (#T(regexp$ "[\\.](\\w+)" (?class)) (cons (make-instance 'class-selector :arg class) (parse-selector &rest)))
+ (#T(regexp$ "(\\w+)" (?type)) (cons (make-instance 'type-selector :arg type) (parse-selector &rest)))
+ #+(or)
+ (#T(regexp$ "\\*" ()) (cons (make-instance 'universal-selector) (parse-selector &rest)))))
hunk ./selectors.lisp 101
-(defmethod find-matching-elements ((selectors list) element)
- (call-next-method)
- #+(or)
- (prog1
- (when (element-matches-p selectors element)
- (when (every (alexandria:rcurry #'find-matching-elements element) selectors)
- element)
- (format t "lv fme~%"))))
-
-(defmethod find-matching-elements ((selector selector) (elements list))
- (call-next-method))
-
hunk ./selectors.lisp 102
- (format t "in fme: ~s~%" elements)
- (prog1
hunk ./selectors.lisp 107
- elements))))
- (format t "lv fme~%")))
+ elements)))))
hunk ./selectors.lisp 112
-;; for lhtml compatibility
-#||
-(defvar *ancestors* nil)
-(defmethod find-matching-elements ((selector selector) (elements cons))
- (if (keywordp (car elements))
- (remove-if #'null
- (nconc
- (when (element-matches-p elements selector) (list elements))
- (let ((*ancestors* (cons elements nil)))
- (mapcar (lambda (el) (find-matching-elements selector el))
- (element-children elements)))))
- (call-next-method)))
-||#
-
hunk ./selectors.lisp 114
-(defmethod element-matches-p ((element t) (selector selector))
- (error "ar?")
- nil)
-(defmethod element-matches-p :around ((element string) (selector selector))
- (call-next-method))
-
-(defmethod element-matches-p :around ((element t) (selector selector))
- (call-next-method)
- #+(or)
- (format t "c: ~s, ~s, ~s~%"
- (class-of element)
- (class-of selector)
- (find-method #'element-matches-p '() (list (find-class t) (class-of selector)) nil))
- #+(or)
- (when (find-method #'element-matches-p '() (mapcar #'class-of (list element selector)) nil)
- (call-next-method)))
-
hunk ./selectors.lisp 118
- ;(cerror "hrm" element)
- (format t "id: ~s~%" (element-id element))
hunk ./selectors.lisp 125
-#+(or)
-(defmethod element-matches-p (element (selector child-combinator))
- (plusp (length (find-matching-elements selector (element-children element)))))
-
-#+TODO
-(defmethod element-matches-p (element (selector descendant-combinator))
- (flet ((all-match (element) (every (lambda (m) (element-matches-p element m)) (matcher selector))))
- #+nil
- (when (all-match element) element)
- (let ((elements (cddr element)))
- (format t "el: ~s~%" elements)
- (case (selector-arg selector)
- (:direct (loop :for element :in elements
- :when (all-match element)
- :collect element))
- (t (css-collect-elements selector elements))))))
-
hunk ./tests.lisp 31
- (match (#T(html ("div" ("> i" . ?i)))
+ (match (#T(html ("div" ("> i" . ?i)
+ ("span>i" . ?span)))
hunk ./tests.lisp 34
- i))
+ (values i span)))
hunk ./traversal/lhtml.lisp 12
+#+FIXME
hunk ./traversal/lhtml.lisp 18
+(defmethod element-parent ((element list))
+ (error "cannot get parent"))
+#+FIXME
hunk ./traversal/lhtml.lisp 23
+(defmethod element-ancestors ((element list))
+ (error "cannot get ancestors"))
hunk ./unification-templates.lisp 2
+;; FIXME: rather than having separate
+;; #t(pt-html ...) [_$_]
+;; #t(lhtml ...)
+;; etc.
+;; syntaxes for every possible parser, have a single
+;; #t(html [(:parser parser-function)] ...)
+;; which uses the value of :parser to handle parsing. Or, if no
+;; parser is specified, requires an already-parsed document be passed
+;; in.
hunk ./unification-templates.lisp 17
- #+(or)
- (parent :reader parent-template :initarg :parent :initform nil)
hunk ./unification-templates.lisp 19
-(defmethod parent-template ((template t)) nil)
-
hunk ./unification-templates.lisp 32
-(defmethod initialize-instance :after ((template lhtml-template) &key css-specifiers &allow-other-keys)
- (let ((specifiers-and-vars (or css-specifiers (rest (template-spec template)))))
- (setf (slot-value template 'specifiers)
- (parse-specifiers specifiers-and-vars 'lhtml-template))))
-
-(defmethod initialize-instance :after ((template pt-template) &key css-specifiers parent &allow-other-keys)
+(defmethod initialize-instance :after ((template css-selector-template) &key css-specifiers parent &allow-other-keys)
hunk ./unification-templates.lisp 38
- (format t "sss: ~s~%" selector)
hunk ./unification-templates.lisp 43
- (format t "ok!~%")
hunk ./unification-templates.lisp 55
- ((consp rest) (make-instance (class-of template) :css-specifiers rest :parent selector))))))
+ ((consp rest)
+ (make-instance (class-of template)
+ :spec (list* (first (template-spec template)) rest)
+ :css-specifiers rest
+ :parent selector))))))
hunk ./unification-templates.lisp 71
- (format t "ts: ~s~%" (template-spec template))
hunk ./unification-templates.lisp 73
- (format t "spec: ~s, tpl: ~s~%" css-specifier template)
hunk ./unification-templates.lisp 74
- (format t "val: ~s~%" val)