|
|
|
@ -1,7 +1,9 @@
|
|
|
|
|
#lang br/quicklang
|
|
|
|
|
(require "parser.rkt" "tokenizer.rkt")
|
|
|
|
|
#lang at-exp br/quicklang
|
|
|
|
|
(require "parser.rkt" "tokenizer.rkt" gregor)
|
|
|
|
|
(provide (matching-identifiers-out #rx"pf-" (all-defined-out)))
|
|
|
|
|
|
|
|
|
|
(module+ test (require rackunit))
|
|
|
|
|
|
|
|
|
|
(module+ reader (provide read-syntax))
|
|
|
|
|
|
|
|
|
|
(define (read-syntax src port)
|
|
|
|
@ -21,7 +23,36 @@
|
|
|
|
|
|
|
|
|
|
(define (pf-name str)
|
|
|
|
|
(let* ([str (string-trim str "/" #:right? #f)]
|
|
|
|
|
[str (regexp-replace* #px"#(\\d\\d)" str (λ (m sub) (string (integer->char (string->number sub 16)))))])
|
|
|
|
|
[str (regexp-replace* @pregexp{#(\d\d)} str (λ (m sub) (string (integer->char (string->number sub 16)))))])
|
|
|
|
|
(string->symbol str)))
|
|
|
|
|
|
|
|
|
|
(pf-name "B#45#20L")
|
|
|
|
|
(module+ test
|
|
|
|
|
(check-equal? (pf-name "B#45#20NICE") '|BE NICE|))
|
|
|
|
|
|
|
|
|
|
(define (pf-string arg . tail)
|
|
|
|
|
(cond
|
|
|
|
|
[(andmap byte? (cons arg tail)) (cons arg tail)]
|
|
|
|
|
[(string-prefix? arg "D:")
|
|
|
|
|
#;(parameterize ([current-locale "en"])
|
|
|
|
|
(parse-date "2015-03-15T02:02:02-04:00" "yyyy-MM-dd'T'HH:mm:ssxxx"))
|
|
|
|
|
#f]
|
|
|
|
|
[else
|
|
|
|
|
(let* ([str (regexp-replace @regexp{^\((.*)\)$} arg "\\1")]
|
|
|
|
|
[str (regexp-replace* @pregexp{\\(\\|\))} str "\\1")]
|
|
|
|
|
[str (regexp-replace* @pregexp{\\(\d\d\d)} str (λ (m sub) (string (integer->char (string->number sub)))))])
|
|
|
|
|
str)]))
|
|
|
|
|
|
|
|
|
|
(module+ test
|
|
|
|
|
(check-equal? (pf-string "(Testing)") "Testing")
|
|
|
|
|
(check-equal? (pf-string "(Test\\)ing)") "Test)ing")
|
|
|
|
|
(check-equal? (pf-string "(Test\\\\ing)") "Test\\ing")
|
|
|
|
|
(check-equal? (pf-string "(A\\043B)") "A+B")
|
|
|
|
|
#;(check-equal? (pf-string "(D:19990209153925-08\'00\')") )
|
|
|
|
|
#;(check-true (andmap byte? (pf-string "<1C2D3F>")))
|
|
|
|
|
#;(check-true (andmap byte? (pf-string "<1C 2D 3F>"))))
|
|
|
|
|
|
|
|
|
|
(define (pf-array . xs) xs)
|
|
|
|
|
|
|
|
|
|
(define (pf-dict . args)
|
|
|
|
|
(apply hash args))
|
|
|
|
|
|