(module Spad-Grammar (export spad:the-grammar)) (define spad:the-grammar (let ((ital? #f) (bold? #f) (url? #f) (txturl? #f) (url "") (txturl "") (note? #f) (note "") (section? #f)) (regular-grammar ((carcomp (in "éèàùûçêîâÉÈÀÊÎÂÏïëËÇüôäöœ_!-:\\?,'’()//%&"))) ((when (not section?) (bol "{{{")) (set! section? #t) (display* "== ") (ignore)) ((when section? (: (+ (in alpha carcomp digit space punct)) "}}}")) (set! section? #f) (print (the-substring 0 (- (the-length) 3))) (newline) (ignore)) ((when (not note?) (: (+ (in alpha carcomp digit space punct)) "[[")) (set! note? #t) (display* (the-substring 0 (- (the-length) 2)) "<<") (ignore)) ((when note? (: (+ (in alpha carcomp digit space punct)) "]]")) (set! note? #f) (display* (the-substring 0 (- (the-length) 2)) ">>") (ignore)) ((when (not txturl?) (: (+ (in alpha carcomp digit space punct)) "[")) (set! txturl? #t) (display* (the-substring 0 (- (the-length) 1))) (ignore)) ((when txturl? (: (* (in alpha carcomp digit space punct "{}*")) "->")) ;; (set! txturl (read/rp spad:the-grammar (open-input-string (the-substring 0 (- (the-length) 2))))) (set! txturl (the-substring 0 (- (the-length) 2))) (set! txturl? #f) (set! url? #t) (ignore)) ((when url? (: (+ (in alpha carcomp digit space punct "{}*")) "]")) (set! url (the-substring 0 (- (the-length) 1))) (display* url "[" txturl "]") (ignore)) ((when (not bold?) (: (+ (in alpha carcomp digit space punct)) "{{")) (set! bold? #t) (display* (the-substring 0 (- (the-length) 2)) "*") (ignore)) ((when bold? (: (+ (in alpha carcomp digit space punct)) "}}")) (set! bold? #f) (display* (the-substring 0 (- (the-length) 2)) "*") (ignore)) ((when (not ital?) (: (+ (in alpha carcomp digit space punct)) "{")) (set! ital? #t) (display* (the-substring 0 (- (the-length) 1)) "_") (ignore)) ((when ital? (: (+ (in alpha carcomp digit space punct)) "}")) (set! ital? #f) (display* (the-substring 0 (- (the-length) 1)) "_" ) (ignore)) ((: (+ (in alpha carcomp digit space punct))) (print (the-string)) (ignore)) ((: #\newline) (ignore)) ((eol #\newline) (ignore)) ((bol #\newline) (ignore)) )))