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

View File

@ -19,27 +19,27 @@
(define-constant +-separator+ "/" :test #'string=)
(defrule digit (character-ranges (#\0 #\9))
(defrule tour-digit (character-ranges (#\0 #\9))
(: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)
(:function parse-integer))
(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)))))
(defrule tour-tail (? (and list-delimiter tour))
(defrule tour-tour-tail (? (and tour-list-delimiter tour-tour))
(:function rest))
(defrule tour (and (or range number) tour-tail)
(defrule tour-tour (and (or tour-range tour-number) tour-tour-tail)
(:function flatten))
(defun parse-tour-mode (data)
(parse 'tour data))
(parse 'tour-tour data))