From 0c170345af229f59f99441d659977c51f8444991 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Mon, 20 Jun 2016 15:27:59 -0700 Subject: [PATCH] factor: more escaping. add execute\ for words that simply have to be called..... --- core/bootstrap/syntax.factor | 1 + core/syntax/syntax.factor | 2 ++ libs/c/lexer/lexer.factor | 2 +- libs/c/preprocessor/preprocessor.factor | 6 +++--- libs/fjsc/fjsc.factor | 4 ++-- libs/flip-text/flip-text.factor | 10 +++++----- libs/gml/core/core.factor | 6 +++--- libs/gml/runtime/runtime.factor | 2 +- libs/simple-flat-file/simple-flat-file.factor | 6 +++--- libs/tnetstrings/tnetstrings.factor | 10 +++++----- 10 files changed, 26 insertions(+), 23 deletions(-) diff --git a/core/bootstrap/syntax.factor b/core/bootstrap/syntax.factor index 2b489aec23..3e3d125044 100644 --- a/core/bootstrap/syntax.factor +++ b/core/bootstrap/syntax.factor @@ -107,6 +107,7 @@ in: bootstrap.syntax "read-only" "call(" "execute(" + "execute\\" "\"" "P\"" "SBUF\"" diff --git a/core/syntax/syntax.factor b/core/syntax/syntax.factor index bd9f87b572..68fd76e22e 100644 --- a/core/syntax/syntax.factor +++ b/core/syntax/syntax.factor @@ -373,6 +373,8 @@ in: bootstrap.syntax "execute(" [ \ execute-effect parse-call-paren ] define-core-syntax + "execute\\" [ scan-word suffix! ] define-core-syntax + "::" [ (::) define-declared ] define-core-syntax "M::" [ (M::) define ] define-core-syntax "MACRO:" [ (:) define-macro ] define-core-syntax diff --git a/libs/c/lexer/lexer.factor b/libs/c/lexer/lexer.factor index d0db68849e..2741652ef1 100644 --- a/libs/c/lexer/lexer.factor +++ b/libs/c/lexer/lexer.factor @@ -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] diff --git a/libs/c/preprocessor/preprocessor.factor b/libs/c/preprocessor/preprocessor.factor index 23652a47d3..6a56eb07cd 100644 --- a/libs/c/preprocessor/preprocessor.factor +++ b/libs/c/preprocessor/preprocessor.factor @@ -73,8 +73,8 @@ 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-standard-include ] } + { char: \" [ char: \" take-until-object read-local-include ] } [ bad-include-line ] } case ; @@ -165,7 +165,7 @@ ERROR: header-file-missing path ; ] if ; : preprocess-line ( preprocessor-state sequence-parser -- ) - skip-whitespace/comments dup current char: # = + skip-whitespace/comments dup current char: \# = [ parse-directive-line ] [ swap processing-disabled?>> [ drop ] [ write-full nl ] if ] if ; diff --git a/libs/fjsc/fjsc.factor b/libs/fjsc/fjsc.factor index 4059b88035..ae00e669c3 100644 --- a/libs/fjsc/fjsc.factor +++ b/libs/fjsc/fjsc.factor @@ -59,8 +59,8 @@ defer: expression-parser [ { [ blank? not ] - [ char: ) = not ] - [ char: - = not ] + [ char: \) = not ] + [ char: \- = not ] } 1&& ] satisfy repeat1 [ >string ] action ; diff --git a/libs/flip-text/flip-text.factor b/libs/flip-text/flip-text.factor index 2fd9b026b6..2fb40b7a6d 100644 --- a/libs/flip-text/flip-text.factor +++ b/libs/flip-text/flip-text.factor @@ -74,13 +74,13 @@ CONSTANT: CHARS H{ { char: \" 0x201E } { char: \. 0x02D9 } { char: \; 0x061B } - { char: \[ char: ] } - { char: \( char: ) } - { char: \{ char: } } + { char: \[ char: \] } + { char: \( char: \) } + { char: \{ char: \} } { char: \? 0x00BF } { char: \! 0x00A1 } - { char: \' char: , } - { char: \< char: > } + { char: \' char: \, } + { char: \< char: \> } { char: \_ 0x203E } { 0x203F 0x2040 } { 0x2045 0x2046 } diff --git a/libs/gml/core/core.factor b/libs/gml/core/core.factor index 7c3b90e9c7..e3471f4bc4 100644 --- a/libs/gml/core/core.factor +++ b/libs/gml/core/core.factor @@ -39,7 +39,7 @@ GML: count ( -- n ) dup operand-stack>> length ; GML: counttomark ( -- n ) dup [ operand-stack>> length ] [ find-marker ] bi - ; ! Arrays -GML: ] ( -- array ) +GML: \ ] ( -- array ) dup [ [ operand-stack>> ] [ find-marker ] bi pop-slice { } like ] [ operand-stack>> pop* ] @@ -146,12 +146,12 @@ GML:: map ( array proc -- ) :> gml marker gml push-operand gml array proc proc>quot1 each - gml-] ; + execute\ gml-] ; GML:: twomap ( array1 array2 proc -- ) :> gml marker gml push-operand gml array1 array2 proc proc>quot2 2each - gml-] ; + execute\ gml-] ; ! Extensions to real GML GML: print ( obj -- ) print-gml ; diff --git a/libs/gml/runtime/runtime.factor b/libs/gml/runtime/runtime.factor index 5bad9dd56f..16f176a160 100644 --- a/libs/gml/runtime/runtime.factor +++ b/libs/gml/runtime/runtime.factor @@ -180,7 +180,7 @@ global-dictionary [ H{ } clone ] initialize primitive-effect define-declared ; : scan-gml-name ( -- word name ) - scan-token [ "gml-" prepend create-word-in ] keep ; + scan-escaped-word-string [ "gml-" prepend create-word-in ] keep ; : (GML:) ( -- word name effect def ) scan-gml-name scan-effect parse-definition ; diff --git a/libs/simple-flat-file/simple-flat-file.factor b/libs/simple-flat-file/simple-flat-file.factor index 7cadd2f954..bed1cd8ed9 100644 --- a/libs/simple-flat-file/simple-flat-file.factor +++ b/libs/simple-flat-file/simple-flat-file.factor @@ -25,11 +25,11 @@ in: simple-flat-file : flat-file>biassoc ( filename -- biassoc ) utf8 file-lines process-codetable-lines >biassoc ; -: split-; ( line -- array ) +: split-semi ( line -- array ) ";" split [ [ blank? ] trim ] map! ; : data ( filename -- data ) - utf8 file-lines drop-comments [ split-; ] map! ; + utf8 file-lines drop-comments [ split-semi ] map! ; symbol: interned @@ -40,7 +40,7 @@ symbol: interned : expand-ranges ( assoc -- interval-map ) [ [ - swap char: . over member? [ + swap char: \. over member? [ ".." split1 [ hex> ] bi@ 2array ] [ hex> ] if range, ] assoc-each diff --git a/libs/tnetstrings/tnetstrings.factor b/libs/tnetstrings/tnetstrings.factor index 9b850249e5..1e8e7132fb 100644 --- a/libs/tnetstrings/tnetstrings.factor +++ b/libs/tnetstrings/tnetstrings.factor @@ -43,13 +43,13 @@ defer: parse-tnetstring : parse-tnetstring ( data -- remain value ) parse-payload { - { char: # [ string>number ] } + { char: \# [ string>number ] } { char: \" [ ] } - { char: } [ parse-dict ] } - { char: ] [ parse-list ] } + { char: \} [ parse-dict ] } + { char: \] [ parse-list ] } { char: \! [ parse-bool ] } - { char: ~ [ parse-null ] } - { char: , [ ] } + { char: \~ [ parse-null ] } + { char: \, [ ] } [ "Invalid payload type: %c" sprintf throw ] } case ;