mirror of https://codeberg.org/cage/tinmop/
- prefixed all parsing rule for gopher parsing to avoid clash with other rules in the code.
This commit is contained in:
parent
1e3854989b
commit
a708977646
|
@ -209,55 +209,56 @@
|
|||
|
||||
(gen-check-line-predicate empty 'line-empty)
|
||||
|
||||
(defrule line-separator (and #\Return #\Newline)
|
||||
(defrule gopher-line-separator (and #\Return #\Newline)
|
||||
(:constant :line-separator))
|
||||
|
||||
(defrule field-separator #\tab
|
||||
(defrule gopher-field-separator #\tab
|
||||
(:constant :field-separator))
|
||||
|
||||
(defrule null-char #\Nul
|
||||
(defrule gopher-null-char #\Nul
|
||||
(:constant :field-separator))
|
||||
|
||||
(defrule unascii (not (or field-separator line-separator null-char))
|
||||
(defrule gopher-unascii (not (or gopher-field-separator gopher-line-separator gopher-null-char))
|
||||
(:text t))
|
||||
|
||||
(defrule last-line (and #\. line-separator)
|
||||
(defrule gopher-last-line (and #\. gopher-line-separator)
|
||||
(:constant :last-line))
|
||||
|
||||
(defrule line-type unascii
|
||||
(defrule gopher-line-type gopher-unascii
|
||||
(:text t))
|
||||
|
||||
(defrule red-type (and #\+ #\.)
|
||||
(defrule gopher-red-type (and #\+ #\.)
|
||||
(:constant :red-type))
|
||||
|
||||
(defrule user-name (* unascii)
|
||||
(defrule gopher-user-name (* gopher-unascii)
|
||||
(:text t))
|
||||
|
||||
(defrule selector (* unascii)
|
||||
(defrule gopher-selector (* gopher-unascii)
|
||||
(:text t))
|
||||
|
||||
(defrule hostname-component (* (not (or field-separator line-separator null-char
|
||||
(defrule gopher-hostname-component (* (not (or gopher-field-separator gopher-line-separator
|
||||
gopher-null-char
|
||||
#\.)))
|
||||
(:text t))
|
||||
|
||||
(defrule host (and (* (and hostname-component #\.))
|
||||
hostname-component)
|
||||
(defrule gopher-host (and (* (and gopher-hostname-component #\.))
|
||||
gopher-hostname-component)
|
||||
(:text t))
|
||||
|
||||
(defrule digit (character-ranges #\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9)
|
||||
(defrule gopher-digit (character-ranges #\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9)
|
||||
(:text t))
|
||||
|
||||
(defrule digit-sequence (and digit (* digit))
|
||||
(defrule gopher-digit-sequence (and gopher-digit (* gopher-digit))
|
||||
(:text t))
|
||||
|
||||
(defrule port digit-sequence
|
||||
(defrule gopher-port gopher-digit-sequence
|
||||
(:function parse-integer))
|
||||
|
||||
(defrule dir-entity (or (and line-type user-name field-separator
|
||||
selector field-separator
|
||||
host field-separator
|
||||
port line-separator)
|
||||
line-separator)
|
||||
(defrule gopher-dir-entity (or (and gopher-line-type gopher-user-name gopher-field-separator
|
||||
gopher-selector gopher-field-separator
|
||||
gopher-host gopher-field-separator
|
||||
gopher-port gopher-line-separator)
|
||||
line-separator)
|
||||
(:function (lambda (line)
|
||||
(if (listp line)
|
||||
(list :type (first line)
|
||||
|
@ -271,7 +272,7 @@
|
|||
:host ""
|
||||
:port "")))))
|
||||
|
||||
(defrule menu (and (* dir-entity) (? last-line))
|
||||
(defrule gopher-menu (and (* gopher-dir-entity) (? gopher-last-line))
|
||||
(:function first))
|
||||
|
||||
(defun parse-menu (data)
|
||||
|
@ -323,16 +324,17 @@
|
|||
(port instance) (getf entry :port))
|
||||
instance))))
|
||||
|
||||
(defrule text-block (+ (not (and #\Newline #\. #\Return #\Newline)))
|
||||
(defrule gopher-text-block (+ (not (and #\Newline #\. #\Return #\Newline)))
|
||||
(:text t))
|
||||
|
||||
(defrule text-file (and (* text-block) (? (and #\Newline #\. #\Return #\Newline)))
|
||||
(defrule gopher-text-file (and (* gopher-text-block)
|
||||
(? (and #\Newline #\. #\Return #\Newline)))
|
||||
(:function caar))
|
||||
|
||||
(defun parse-text-file (data)
|
||||
(parse 'text-file data))
|
||||
|
||||
(defrule gopher-url-authority (or (and (+ (not #\:))
|
||||
(defrule gopher-gopher-url-authority (or (and (+ (not #\:))
|
||||
#\:
|
||||
(+ (not #\/))
|
||||
#\/)
|
||||
|
@ -346,7 +348,7 @@
|
|||
70)))
|
||||
(list host port)))))
|
||||
|
||||
(defrule gopher-url (and (+ (not #\:))
|
||||
(defrule gopher-gopher-url (and (+ (not #\:))
|
||||
"://"
|
||||
gopher-url-authority
|
||||
(? (and (not #\/)
|
||||
|
|
Loading…
Reference in New Issue