1
0
Fork 0

- prefixed all parsing rule for tour parsing to avoid clash with other rules in the code.

This commit is contained in:
cage 2024-06-19 17:50:37 +02:00
parent a708977646
commit 7d0c41eed9
2 changed files with 10 additions and 10 deletions

View File

@ -276,7 +276,7 @@
(:function first)) (:function first))
(defun parse-menu (data) (defun parse-menu (data)
(let ((menu (parse 'menu data))) (let ((menu (parse 'gopher-menu data)))
(loop for entry in menu (loop for entry in menu
collect collect
(let* ((line-type (getf entry :type)) (let* ((line-type (getf entry :type))
@ -371,7 +371,7 @@
(list host port path type))))) (list host port path type)))))
(defun parse-iri (iri) (defun parse-iri (iri)
(let* ((parsed (parse 'gopher-url iri)) (let* ((parsed (parse 'gopher-gopher-url iri))
(host (first parsed)) (host (first parsed))
(port (second parsed)) (port (second parsed))
(selector (third parsed)) (selector (third parsed))

View File

@ -19,27 +19,27 @@
(define-constant +-separator+ "/" :test #'string=) (define-constant +-separator+ "/" :test #'string=)
(defrule digit (character-ranges (#\0 #\9)) (defrule tour-digit (character-ranges (#\0 #\9))
(:text t)) (:text t))
(defrule range-delimter #\-) (defrule tour-range-delimter #\-)
(defrule list-delimiter (+ (or #\Space #\,))) (defrule tour-list-delimiter (+ (or #\Space #\,)))
(defrule number (and digit (* digit)) (defrule tour-number (and tour-digit (* tour-digit))
(:text t) (:text t)
(:function parse-integer)) (:function parse-integer))
(defstruct range from to) (defstruct range from to)
(defrule range (and number range-delimter number) (defrule tour-range (and tour-number tour-range-delimter tour-number)
(:function (lambda (a) (make-range :from (first a) :to (third a))))) (:function (lambda (a) (make-range :from (first a) :to (third a)))))
(defrule tour-tail (? (and list-delimiter tour)) (defrule tour-tour-tail (? (and tour-list-delimiter tour-tour))
(:function rest)) (:function rest))
(defrule tour (and (or range number) tour-tail) (defrule tour-tour (and (or tour-range tour-number) tour-tour-tail)
(:function flatten)) (:function flatten))
(defun parse-tour-mode (data) (defun parse-tour-mode (data)
(parse 'tour data)) (parse 'tour-tour data))