2over stream-read1 swap over =
[ nip ] [
{
- { CHAR: " [ [ CHAR: " , ] when quoted-field, ] }
+ { CHAR: \" [ [ CHAR: \" , ] when quoted-field, ] }
{ CHAR: \n [ ] } ! Error: cr inside string?
{ CHAR: \r [ ] } ! Error: lf inside string?
[ [ , drop f maybe-escaped-quote ] when* ]
swap ?trim [ drop ] 2dip ; inline
: field ( delimiter stream field-seps quote-seps -- sep/f field )
- pick stream-read-until dup CHAR: " = [
+ pick stream-read-until dup CHAR: \" = [
drop [ drop quoted-field ] [ continue-field ] if-empty
] [ [ 3drop ] 2dip swap ?trim ] if ;
'[ dup "\n\"\r" member? [ drop t ] [ _ = ] if ] any? ; inline
: escape-quotes ( cell stream -- )
- CHAR: " over stream-write1 swap [
+ CHAR: \" over stream-write1 swap [
[ over stream-write1 ]
- [ dup CHAR: " = [ over stream-write1 ] [ drop ] if ] bi
- ] each CHAR: " swap stream-write1 ;
+ [ dup CHAR: \" = [ over stream-write1 ] [ drop ] if ] bi
+ ] each CHAR: \" swap stream-write1 ;
: escape-if-required ( cell delimiter stream -- )
[ dupd needs-escaping? ] dip
: escape-char ( ch -- )
dup ascii? [
dup H{
- { CHAR: " "__quo__" }
+ { CHAR: \" "__quo__" }
{ CHAR: * "__star__" }
{ CHAR: : "__colon__" }
{ CHAR: < "__lt__" }
M: template-lexer skip-word
[
{
- { [ 2dup nth CHAR: " = ] [ drop 1 + ] }
+ { [ 2dup nth CHAR: \" = ] [ drop 1 + ] }
{ [ 2dup swap tail-slice "%>" head? ] [ drop 2 + ] }
[ f skip ]
} cond
[ " \t" member? ] satisfy repeat1 ;
: qdtext-parser ( -- parser )
- { [ CHAR: " = ] [ control? ] } except-these ;
+ { [ CHAR: \" = ] [ control? ] } except-these ;
: quoted-char-parser ( -- parser )
"\\" token hide any-char 2seq ;
[
{ [ drop CHAR: \ = ] [ nip "\\\"" member? ] } 2&&
] monotonic-split [
- dup last CHAR: " = [
+ dup last CHAR: \" = [
dup length 1 > [
! String of backslashes + double-quote
- length 1 - 2 * CHAR: \ <repetition> "\\\"" append
+ length 1 - 2 * CHAR: \\ <repetition> "\\\"" append
] [
! Single double-quote
drop "\\\""
: (read-json-escape) ( stream accum -- accum )
{ sbuf } declare
over stream-read1 {
- { CHAR: " [ CHAR: " ] }
+ { CHAR: \" [ CHAR: \" ] }
{ CHAR: \\ [ CHAR: \\ ] }
{ CHAR: / [ CHAR: / ] }
{ CHAR: b [ CHAR: \b ] }
PRIVATE>
M: string stream-json-print
- CHAR: " over stream-write1 swap [
+ CHAR: \" over stream-write1 swap [
{
- { CHAR: " [ "\\\"" over stream-write ] }
+ { CHAR: \" [ "\\\"" over stream-write ] }
{ CHAR: \\ [ "\\\\" over stream-write ] }
{ CHAR: / [
json-escape-slashes? get
] if
]
} case
- ] each CHAR: " swap stream-write1 ;
+ ] each CHAR: \" swap stream-write1 ;
M: integer stream-json-print
[ number>string ] [ stream-write ] bi* ;
[
[ CHAR: \ = ] satisfy
[ "\"\\" member? ] satisfy 2seq ,
- [ CHAR: " = not ] satisfy ,
+ [ CHAR: \" = not ] satisfy ,
] choice* repeat1 "\"" "\"" surrounded-by ,
[ CHAR: ' = not ] satisfy repeat1 "'" "'" surrounded-by ,
] choice* [ "" flatten-as unescape-string ] action ;
: string-parser ( -- parser )
[
- [ CHAR: " = ] satisfy hide ,
- [ CHAR: " = not ] satisfy repeat0 ,
- [ CHAR: " = ] satisfy hide ,
+ [ CHAR: \" = ] satisfy hide ,
+ [ CHAR: \" = not ] satisfy repeat0 ,
+ [ CHAR: \" = ] satisfy hide ,
] seq* [ first >string ] action ;
: (range-pattern) ( pattern -- string )
[
take-word pass-blank get-char {
{ CHAR: ' [ parse-quote ] }
- { CHAR: " [ parse-quote ] }
+ { CHAR: \" [ parse-quote ] }
[ drop take-external-id close ]
} case
] dip '[ swap _ [ ?set-at ] change ] 2keep ;
H{
{ CHAR: & "&" }
{ CHAR: ' "'" }
- { CHAR: " """ }
+ { CHAR: \" """ }
{ CHAR: < "<" }
}
{ "gt" CHAR: > }
{ "amp" CHAR: & }
{ "apos" CHAR: ' }
- { "quot" CHAR: " }
+ { "quot" CHAR: \" }
}
: with-entities ( entities quot -- )
<PRIVATE
: write-quoted ( string -- )
- CHAR: " write1 write CHAR: " write1 ;
+ CHAR: \" write1 write CHAR: \" write1 ;
: print-attrs ( assoc -- )
[
M: lexer skip-word
[
- 2dup nth CHAR: " eq? [ drop 1 + ] [ f skip ] if
+ 2dup nth CHAR: \" eq? [ drop 1 + ] [ f skip ] if
] change-lexer-column ;
: still-parsing? ( lexer -- ? )
{ f }
[
"\"abc\" asdf" <sequence-parser>
- [ CHAR: \ CHAR: " take-quoted-string drop ] [ "asdf" take-sequence ] bi
+ [ CHAR: \ CHAR: \" take-quoted-string drop ] [ "asdf" take-sequence ] bi
] unit-test
{ "abc\\\"def" }
[
"\"abc\\\"def\" asdf" <sequence-parser>
- CHAR: \ CHAR: " take-quoted-string
+ CHAR: \ CHAR: \" take-quoted-string
] unit-test
{ "asdf" }
[
"\"abc\" asdf" <sequence-parser>
- [ CHAR: \ CHAR: " take-quoted-string drop ]
+ [ CHAR: \ CHAR: \" take-quoted-string drop ]
[ skip-whitespace "asdf" take-sequence ] bi
] unit-test
{ f }
[
"\"abc asdf" <sequence-parser>
- CHAR: \ CHAR: " take-quoted-string
+ CHAR: \ CHAR: \" take-quoted-string
] unit-test
{ "\"abc" }
[
"\"abc asdf" <sequence-parser>
- [ CHAR: \ CHAR: " take-quoted-string drop ]
+ [ CHAR: \ CHAR: \" take-quoted-string drop ]
[ "\"abc" take-sequence ] bi
] unit-test
[ "" <sequence-parser> take-token ] unit-test
{ "abcd e \\\"f g" }
-[ "\"abcd e \\\"f g\"" <sequence-parser> CHAR: \ CHAR: " take-token* ] unit-test
+[ "\"abcd e \\\"f g\"" <sequence-parser> CHAR: \ CHAR: \" take-token* ] unit-test
{ "123" }
[ "123jjj" <sequence-parser> take-c-integer ] unit-test
} case ;
: take-token ( sequence-parser -- string/f )
- CHAR: \ CHAR: " take-token* ;
+ CHAR: \ CHAR: \" take-token* ;
: c-identifier-begin? ( ch -- ? )
CHAR: a CHAR: z [a,b]
: handle-include ( preprocessor-state sequence-parser -- )
skip-whitespace/comments advance dup previous {
{ CHAR: < [ CHAR: > take-until-object read-standard-include ] }
- { CHAR: " [ CHAR: " take-until-object read-local-include ] }
+ { CHAR: \" [ CHAR: \" take-until-object read-local-include ] }
[ bad-include-line ]
} case ;
dup [ CHAR: ; = ] find drop [ head ] when* ;
: trim-quotes ( str -- str' )
- [ CHAR: " = ] trim ;
+ [ CHAR: \" = ] trim ;
: last-track ( cuesheet -- cuesheet track )
dup files>> last tracks>> last ;
[
{
[ blank? not ]
- [ CHAR: " = not ]
+ [ CHAR: \" = not ]
[ CHAR: ; = not ]
[ LETTER? not ]
[ letter? not ]
{ CHAR: 9 CHAR: 6 }
{ CHAR: & 0x214B }
{ CHAR: ! 0x00A1 }
- { CHAR: " 0x201E }
+ { CHAR: \" 0x201E }
{ CHAR: . 0x02D9 }
{ CHAR: ; 0x061B }
{ CHAR: [ CHAR: ] }
CHAR: ' (read-quote) ;
: read-double-quote ( sequence-parser -- string )
- CHAR: " (read-quote) ;
+ CHAR: \" (read-quote) ;
: read-quote ( sequence-parser -- string )
dup get+increment CHAR: ' =
{ CHAR: t CHAR: \t }
{ CHAR: v CHAR: \v }
{ CHAR: ' CHAR: ' }
- { CHAR: " CHAR: " }
+ { CHAR: \" CHAR: \" }
{ CHAR: \\ CHAR: \\ }
{ CHAR: ? CHAR: ? }
{ CHAR: ; CHAR: ; }
{ CHAR: \t "\\t" }
{ 0x0b "\\v" }
{ CHAR: ' "\\'" }
- { CHAR: " "\\\"" }
+ { CHAR: \" "\\\"" }
{ CHAR: \\ "\\\\" }
{ CHAR: ? "\\?" }
{ CHAR: ; "\\;" }
{ CHAR: + ".-.-." }
{ CHAR: - "-....-" }
{ CHAR: _ "..--.-" }
- { CHAR: " ".-..-." }
+ { CHAR: \" ".-..-." }
{ CHAR: $ "...-..-" }
{ CHAR: @ ".--.-." }
{ CHAR: \s "/" }
[ digit? ] satisfy <*> [ string>number ] <@ ;
: string-parser ( -- parser )
- [ CHAR: " = ] satisfy
- [ CHAR: " = not ] satisfy <*> &>
- [ CHAR: " = ] satisfy <& [ >string ] <@ ;
+ [ CHAR: \" = ] satisfy
+ [ CHAR: \" = not ] satisfy <*> &>
+ [ CHAR: \" = ] satisfy <& [ >string ] <@ ;
: bold-parser ( -- parser )
"*" token
| "t" => [[ CHAR: \t ]]
| "v" => [[ CHAR: \v ]]
| "'" => [[ CHAR: ' ]]
- | "\"" => [[ CHAR: " ]]
+ | "\"" => [[ CHAR: \" ]]
| "\\" => [[ CHAR: \\ ]]
HexDigit = [0-9a-fA-F]
HexEscape = "x" (HexDigit HexDigit):d => [[ d hex> ]]
: parse-tnetstring ( data -- remain value )
parse-payload {
{ CHAR: # [ string>number ] }
- { CHAR: " [ ] }
+ { CHAR: \" [ ] }
{ CHAR: } [ parse-dict ] }
{ CHAR: ] [ parse-list ] }
{ CHAR: ! [ parse-bool ] }