]> gitweb.factorcode.org Git - factor.git/commitdiff
Adding escaping to CHAR: " -> CHAR: \"
authorBjörn Lindqvist <bjourne@gmail.com>
Sun, 4 Sep 2016 04:40:43 +0000 (06:40 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Sun, 4 Sep 2016 04:40:43 +0000 (06:40 +0200)
It is not necessary to escape the " character, but it doesn't hurt and
is necessary for syntax-highlighting (FUEL) to work correctly.

25 files changed:
basis/csv/csv.factor
basis/help/html/html.factor
basis/html/templates/fhtml/fhtml.factor
basis/http/parsers/parsers.factor
basis/io/launcher/windows/windows.factor
basis/json/reader/reader.factor
basis/json/writer/writer.factor
basis/peg/ebnf/ebnf.factor
basis/peg/parsers/parsers.factor
basis/xml/dtd/dtd.factor
basis/xml/entities/entities.factor
basis/xml/writer/writer.factor
core/lexer/lexer.factor
extra/c/lexer/lexer-tests.factor
extra/c/lexer/lexer.factor
extra/c/preprocessor/preprocessor.factor
extra/cuesheet/cuesheet.factor
extra/fjsc/fjsc.factor
extra/flip-text/flip-text.factor
extra/html/parser/parser.factor
extra/ini-file/ini-file.factor
extra/morse/morse.factor
extra/parser-combinators/simple/simple.factor
extra/peg/javascript/tokenizer/tokenizer.factor
extra/tnetstrings/tnetstrings.factor

index 7eba910e1b123b8f65f9fc26cd126799dc8341bb..fb34233c64b6fe74a1631bde6b120365ff789c84 100644 (file)
@@ -20,7 +20,7 @@ DEFER: quoted-field,
     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* ]
@@ -45,7 +45,7 @@ DEFER: quoted-field,
     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 ;
 
@@ -89,10 +89,10 @@ PRIVATE>
     '[ 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
index 2fed7e2ed7060371d174578877ea2485d0402e91..eaba3c55be73d3dbcbc83f9ea4f97f87d9966ace 100644 (file)
@@ -15,7 +15,7 @@ IN: help.html
 : escape-char ( ch -- )
     dup ascii? [
         dup H{
-            { CHAR: " "__quo__" }
+            { CHAR: \" "__quo__" }
             { CHAR: * "__star__" }
             { CHAR: : "__colon__" }
             { CHAR: < "__lt__" }
index b6d960841ede0b892aa4e3b8548e99bf2b86cfe5..1d72c04c43ea55965704c7d2e8947d90b1741a5f 100644 (file)
@@ -16,7 +16,7 @@ TUPLE: template-lexer < lexer ;
 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
index 734e48e3fe7317d488afba7921c87f33f82a4307..df6ccbede9861696e45443f39d34121ad42de206 100644 (file)
@@ -97,7 +97,7 @@ PEG: parse-response-line ( string -- triple )
     [ " \t" member? ] satisfy repeat1 ;
 
 : qdtext-parser ( -- parser )
-    { [ CHAR: " = ] [ control? ] } except-these ;
+    { [ CHAR: \" = ] [ control? ] } except-these ;
 
 : quoted-char-parser ( -- parser )
     "\\" token hide any-char 2seq ;
index 867de0ca83539e787364353377dd514db3ba0c6b..89a9cda59e3f935b72ab09dc64acda4ce37c68ff 100755 (executable)
@@ -64,10 +64,10 @@ TUPLE: CreateProcess-args
     [
         { [ 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 "\\\""
index e08e1ae5b4b94c12ddc6075bdc0257c9891b92a2..39e932c1025f0a5c59ee6ab9343b39c596244102 100644 (file)
@@ -44,7 +44,7 @@ DEFER: (read-json-string)
 : (read-json-escape) ( stream accum -- accum )
     { sbuf } declare
     over stream-read1 {
-        { CHAR: " [ CHAR: " ] }
+        { CHAR: \" [ CHAR: \" ] }
         { CHAR: \\ [ CHAR: \\ ] }
         { CHAR: / [ CHAR: / ] }
         { CHAR: b [ CHAR: \b ] }
index d27027ac96fc05fd72d62d6dbf7bb9b5051e50a6..8e6e1784cf69db9dc44bea6b5064fabf902b9a1e 100644 (file)
@@ -59,9 +59,9 @@ M: json-null stream-json-print
 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
@@ -87,7 +87,7 @@ M: string stream-json-print
                 ] if
             ]
         } case
-    ] each CHAR: " swap stream-write1 ;
+    ] each CHAR: \" swap stream-write1 ;
 
 M: integer stream-json-print
     [ number>string ] [ stream-write ] bi* ;
index 78639595eba3c0ccecf823689cf49d75c355aa7e..5bf5604dd61e1955b592f21e384b72ebca87253a 100644 (file)
@@ -114,7 +114,7 @@ C: <ebnf> ebnf
         [
             [ 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 ;
index 23b262568df5bfbcaeae9c5dc6070490d3fa3149..adcc78a1dac859b41aeceebb2db70840a89b825f 100644 (file)
@@ -74,9 +74,9 @@ PRIVATE>
 
 : 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 )
index 8658a814f8b28be7eb5f582f2813585f767a5ae5..360f30ea6c286aa738f238105aa86eddf0738a00 100644 (file)
@@ -24,7 +24,7 @@ UNION: dtd-acceptable
     [
         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 ;
index 9213a2f9225a13987588bc403bc1802ea2671778..9edca9359cc0f2467d76ba5687132c6dd1e70c5f 100644 (file)
@@ -15,7 +15,7 @@ CONSTANT: quoted-entities-out
     H{
         { CHAR: & "&amp;"  }
         { CHAR: ' "&apos;" }
-        { CHAR: " "&quot;" }
+        { CHAR: \" "&quot;" }
         { CHAR: < "&lt;"   }
     }
 
@@ -35,7 +35,7 @@ CONSTANT: entities
         { "gt"    CHAR: >  }
         { "amp"   CHAR: &  }
         { "apos"  CHAR: '  }
-        { "quot"  CHAR: "  }
+        { "quot"  CHAR: \"  }
     }
 
 : with-entities ( entities quot -- )
index a32d2560ac1504b433d4897ca45a60ffd240316f..1f42bf8a35a6a91f94256355a27156198cd4d16b 100644 (file)
@@ -48,7 +48,7 @@ PRIVATE>
 <PRIVATE
 
 : write-quoted ( string -- )
-    CHAR: " write1 write CHAR: " write1 ;
+    CHAR: \" write1 write CHAR: \" write1 ;
 
 : print-attrs ( assoc -- )
     [
index 2e23e7352beb3247e6aebd711c71dc79e5066752..7dc514b189dbcd48e4cf5816ad504ac20cb22d56 100644 (file)
@@ -85,7 +85,7 @@ GENERIC: skip-word ( lexer -- )
 
 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 -- ? )
index e27e2257771a6714757415f8f7322dc4d35b84f0..1927a72d44620532c0db06850331e5839e3e19e4 100644 (file)
@@ -51,32 +51,32 @@ IN: c.lexer.tests
 { 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
 
@@ -87,7 +87,7 @@ IN: c.lexer.tests
 [ "" <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
index f20ba0f17d468888b8ae97998acfb4450285c7b8..1918d73de8b3a324f316f417b074bccc5f7d4a69 100644 (file)
@@ -69,7 +69,7 @@ IN: c.lexer
     } 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]
index 6abd4c5a443b26790a4c94245fb9f321b0a1c00a..1a128c57b339c6e2e3be8c49a17c0a4e1eac5c2b 100644 (file)
@@ -74,7 +74,7 @@ ERROR: header-file-missing path ;
 : 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 ;
 
index 4b85060a84609b1d9a552d0199fa486777b227b4..8f5b86a599e8eff460a6981c86e706a67e7ca5f1 100644 (file)
@@ -58,7 +58,7 @@ ERROR: unknown-syntax syntax ;
     dup [ CHAR: ; = ] find drop [ head ] when* ;
 
 : trim-quotes ( str -- str' )
-    [ CHAR: " = ] trim ;
+    [ CHAR: \" = ] trim ;
 
 : last-track ( cuesheet -- cuesheet track )
     dup files>> last tracks>> last ;
index 8850c2c77dc07eaf90ef5cef88322cf3f6da9813..035adb97423f414f5bb3528065af9e1e0b15fe4a 100644 (file)
@@ -32,7 +32,7 @@ TUPLE: ast-hashtable elements ;
     [
         {
             [ blank? not ]
-            [ CHAR: " = not ]
+            [ CHAR: \" = not ]
             [ CHAR: ; = not ]
             [ LETTER? not ]
             [ letter? not ]
index a1bb0c7558e857b0aff4bc73b71f092ad12a5030..ee25928d6c5859a120daae39254045de1e2b8f55 100644 (file)
@@ -71,7 +71,7 @@ CONSTANT: CHARS H{
     { CHAR: 9   CHAR: 6   }
     { CHAR: &   0x214B }
     { CHAR: !   0x00A1 }
-    { CHAR: "   0x201E }
+    { CHAR: \"   0x201E }
     { CHAR: .   0x02D9 }
     { CHAR: ;   0x061B }
     { CHAR: [   CHAR: ]   }
index 14534ca8c0857e25db58ef49d3c8d6c3d5dd69c0..f9bb72d4341a75bc394d96db7dd1cf9115322da8 100644 (file)
@@ -43,7 +43,7 @@ SYMBOL: tagstack
     CHAR: ' (read-quote) ;
 
 : read-double-quote ( sequence-parser -- string )
-    CHAR: " (read-quote) ;
+    CHAR: \" (read-quote) ;
 
 : read-quote ( sequence-parser -- string )
     dup get+increment CHAR: ' =
index 97f0490bf41919db46a62f391687b6b54965d83a..a31993cf690bff64876da057d389821e19cc5198 100644 (file)
@@ -19,7 +19,7 @@ IN: ini-file
         { CHAR: t   CHAR: \t }
         { CHAR: v   CHAR: \v }
         { CHAR: '   CHAR: ' }
-        { CHAR: "   CHAR: " }
+        { CHAR: \"   CHAR: \" }
         { CHAR: \\  CHAR: \\ }
         { CHAR: ?   CHAR: ? }
         { CHAR: ;   CHAR: ; }
@@ -50,7 +50,7 @@ USE: xml.entities
         { CHAR: \t   "\\t"  }
         { 0x0b    "\\v"  }
         { CHAR: '    "\\'"  }
-        { CHAR: "    "\\\"" }
+        { CHAR: \"    "\\\"" }
         { CHAR: \\   "\\\\" }
         { CHAR: ?    "\\?"  }
         { CHAR: ;    "\\;"  }
index 86c599137be8de739fdf1745fbabf664c7fc5f3e..23301ed3f8fbb2ab9d2376700be995496db64298 100755 (executable)
@@ -71,7 +71,7 @@ CONSTANT: morse-code-table $[
         { CHAR: + ".-.-."  }
         { CHAR: - "-....-" }
         { CHAR: _ "..--.-" }
-        { CHAR: " ".-..-." }
+        { CHAR: \" ".-..-." }
         { CHAR: $ "...-..-" }
         { CHAR: @ ".--.-." }
         { CHAR: \s "/" }
index e147620b34be2e1765a8f7e30cf1b5da50a275bf..eba74dd8ddd4900c5bfe502a14c62bd64fa00aab 100644 (file)
@@ -11,9 +11,9 @@ IN: parser-combinators.simple
   [ 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
index a4d82a1580318b17771228e9b928efabe1195455..52d6e9807e4bd59633534c451571fea4a4dd15ad 100644 (file)
@@ -55,7 +55,7 @@ SingleEscape      =   "b"  => [[ CHAR: \b ]]
                     | "t"  => [[ CHAR: \t ]]
                     | "v"  => [[ CHAR: \v ]]
                     | "'"  => [[ CHAR: '  ]]
-                    | "\"" => [[ CHAR: "  ]]
+                    | "\"" => [[ CHAR: \"  ]]
                     | "\\" => [[ CHAR: \\ ]]
 HexDigit          = [0-9a-fA-F]
 HexEscape         = "x" (HexDigit HexDigit):d => [[ d hex> ]]
index bf0a4c5ef75bd91ee84e04194fedc249ada76539..f427901e8b77114c3db25b19131c5f2fd1e5f752 100644 (file)
@@ -44,7 +44,7 @@ DEFER: parse-tnetstring
 : parse-tnetstring ( data -- remain value )
     parse-payload {
         { CHAR: # [ string>number ] }
-        { CHAR: " [ ] }
+        { CHAR: \" [ ] }
         { CHAR: } [ parse-dict ] }
         { CHAR: ] [ parse-list ] }
         { CHAR: ! [ parse-bool ] }