2023-10-19 17:49:54 +02:00
|
|
|
;; tinmop: a multiprotocol client
|
2023-10-19 17:46:22 +02:00
|
|
|
;; Copyright © cage
|
2021-05-04 11:52:42 +02:00
|
|
|
|
|
|
|
;; This program is free software: you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with this program.
|
|
|
|
;; If not, see [[http://www.gnu.org/licenses/][http://www.gnu.org/licenses/]].
|
|
|
|
|
|
|
|
(in-package :tour-mode-parser)
|
|
|
|
|
|
|
|
(define-constant +-separator+ "/" :test #'string=)
|
|
|
|
|
2024-06-19 17:50:37 +02:00
|
|
|
(defrule tour-digit (character-ranges (#\0 #\9))
|
2021-05-04 11:52:42 +02:00
|
|
|
(:text t))
|
|
|
|
|
2024-06-19 17:50:37 +02:00
|
|
|
(defrule tour-range-delimter #\-)
|
2021-05-04 11:52:42 +02:00
|
|
|
|
2024-06-19 17:50:37 +02:00
|
|
|
(defrule tour-list-delimiter (+ (or #\Space #\,)))
|
2021-05-04 11:52:42 +02:00
|
|
|
|
2024-06-19 17:50:37 +02:00
|
|
|
(defrule tour-number (and tour-digit (* tour-digit))
|
2021-05-04 11:52:42 +02:00
|
|
|
(:text t)
|
|
|
|
(:function parse-integer))
|
|
|
|
|
|
|
|
(defstruct range from to)
|
|
|
|
|
2024-06-19 17:50:37 +02:00
|
|
|
(defrule tour-range (and tour-number tour-range-delimter tour-number)
|
2021-05-04 11:52:42 +02:00
|
|
|
(:function (lambda (a) (make-range :from (first a) :to (third a)))))
|
|
|
|
|
2024-06-19 17:50:37 +02:00
|
|
|
(defrule tour-tour-tail (? (and tour-list-delimiter tour-tour))
|
2021-05-04 11:52:42 +02:00
|
|
|
(:function rest))
|
|
|
|
|
2024-06-19 17:50:37 +02:00
|
|
|
(defrule tour-tour (and (or tour-range tour-number) tour-tour-tail)
|
2021-05-04 11:52:42 +02:00
|
|
|
(:function flatten))
|
|
|
|
|
|
|
|
(defun parse-tour-mode (data)
|
2024-06-19 17:50:37 +02:00
|
|
|
(parse 'tour-tour data))
|