Created
March 13, 2013 04:57
-
-
Save yamasushi/5149485 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (make-string q) | |
(let* ([%quote ($char q)] | |
[%escape ($char #\\)] | |
[%hex4 ($fmap (^s (string->number (list->string s) 16)) | |
($many hexdigit 4 4))] | |
[%special-char | |
($do %escape | |
($or ($char q) | |
($char #\\) | |
($char #\/) | |
($do [($char #\b)] ($return #\x08)) | |
($do [($char #\f)] ($return #\page)) | |
($do [($char #\n)] ($return #\newline)) | |
($do [($char #\r)] ($return #\return)) | |
($do [($char #\t)] ($return #\tab)) | |
($do [($char #\u)] (c %hex4) ($return (ucs->char c)))))] | |
[%unescaped ($none-of (char-set q) )] | |
[%body-char ($or %special-char %unescaped)] | |
[%string-body ($->rope ($many %body-char))]) | |
($between %quote %string-body %quote))) | |
; 文字列はシングルクオートとダブルクオート | |
(define %string ($or (make-string #\') (make-string #\") ) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment