Remove eval dependency from unicode.syntax

db4
Slava Pestov 2008-12-08 19:46:40 -06:00
parent 97a91579bb
commit a0e7663afb
3 changed files with 18 additions and 2 deletions

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license.
USING: unicode.data kernel math sequences parser lexer
bit-arrays namespaces make sequences.private arrays quotations
assocs classes.predicate math.order eval ;
assocs classes.predicate math.order strings.parser ;
IN: unicode.syntax
! Character classes (categories)
@ -26,7 +26,7 @@ IN: unicode.syntax
categories [ swap member? ] with map >bit-array ;
: as-string ( strings -- bit-array )
concat "\"" tuck 3append eval ;
concat unescape-string ;
: [category] ( categories -- quot )
[

View File

@ -0,0 +1,4 @@
IN: strings.parser.tests
USING: strings.parser tools.test ;
[ "Hello\n\rworld" ] [ "Hello\\n\\rworld" unescape-string ] unit-test

View File

@ -58,3 +58,15 @@ name>char-hook global [
lexer get [
[ swap tail-slice (parse-string) ] "" make swap
] change-lexer-column ;
: (unescape-string) ( str -- str' )
dup [ CHAR: \\ = ] find [
cut-slice [ % ] dip rest-slice
next-escape [ , ] dip
(unescape-string)
] [
drop %
] if ;
: unescape-string ( str -- str' )
[ (unescape-string) ] "" make ;