commit 9f994e1e77ffde6a31afb46ffda1bc7efce8636f
parent 45cbd139772d47b5c7d128cbc0cd6243b9581a1c
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Thu, 16 Jun 2022 14:17:42 -0400
Allow S" to be used in interpret mode
Diffstat:
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/fs/lib/core.fs b/fs/lib/core.fs
@@ -29,7 +29,9 @@ $08 const BS $04 const EOF
: nl> CR emit LF emit ; : spc> SPC emit ;
: stype ( str -- ) c@+ rtype ;
: ," begin in< dup '"' = if drop exit then c, again ;
-: S" compile (s) here 1 allot here ," here -^ ( 'len len ) swap c! ; immediate
+: S" ( comp: -- ) ( not-comp: -- str )
+ compiling if compile (s) else here then
+ here 1 allot here ," here -^ ( 'len len ) swap c! ; immediate
: ." [compile] S" compile stype ; immediate
: abort" [compile] ." compile abort ; immediate
diff --git a/fs/tests/cc/ast.fs b/fs/tests/cc/ast.fs
@@ -6,8 +6,7 @@ testbegin
_parse
curunit firstchild dup astid AST_FUNCTION #eq ( fnode )
-: s S" retconst" ;
-dup data1 s s= #
+dup data1 S" retconst" s= #
firstchild nextsibling dup astid AST_STATEMENTS #eq ( snode )
firstchild dup astid AST_RETURN #eq ( rnode )
firstchild dup astid AST_CONSTANT #eq ( cnode )
diff --git a/fs/tests/str.fs b/fs/tests/str.fs
@@ -9,9 +9,9 @@ create list
3 c, ," bar"
0 c,
-: _ S" foo" list sfind 1 #eq ; _
-: _ S" hello" list sfind 0 #eq ; _
-: _ S" baz" list sfind -1 #eq ; _
+S" foo" list sfind 1 #eq
+S" hello" list sfind 0 #eq
+S" baz" list sfind -1 #eq
'c' 0-9? not #
'9' 0-9? #