aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Veresov <aleksey@veresov.pro>2021-01-06 03:04:23 +0300
committerAleksey Veresov <aleksey@veresov.pro>2021-01-06 03:04:23 +0300
commit94ebec008ef085ac6973d89cf6722eb348d4e9d9 (patch)
tree9c53e9532c4729561a404978be21567fd04ef2a1
parent672512b0a2b3b4ae88f204293f4379c1fbb79850 (diff)
downloadcsx-94ebec008ef085ac6973d89cf6722eb348d4e9d9.tar
csx-94ebec008ef085ac6973d89cf6722eb348d4e9d9.tar.xz
csx-94ebec008ef085ac6973d89cf6722eb348d4e9d9.zip
fix
-rw-r--r--examples/interpreter.csx16
1 files changed, 9 insertions, 7 deletions
diff --git a/examples/interpreter.csx b/examples/interpreter.csx
index f4e22dc..7df8ffc 100644
--- a/examples/interpreter.csx
+++ b/examples/interpreter.csx
@@ -131,15 +131,15 @@
]]]
[set readint [fn [num]
- [if [head [head linep]] [if [< 47 [head [head linep]] 58] [do
+ [if [head linep] [if [< 47 [head [head linep]] 58] [do
[set newnum [+ [* 10 num] [head [head linep]] -48]]
[sethead linep [tail [head linep]]]
[readint newnum]
] num] num]
]]
-[set readname [fn []
- [if [head [head linep]] [if [no [same [head [head linep]] [" " 0]]]
+[set readname [fn [] [output [str [head linep]] newline]
+ [if [head linep] [if [no [same [head [head linep]] [" " 0]]]
[if [no [same [head [head linep]] ["[" 0]]] [if [no [same [head [head linep]] ["]" 0]]] [do
[if [same [head [head linep]] ["\\" 0]] [sethead linep [tail [head linep]]]]
[set res [head [head linep]]]
@@ -150,7 +150,7 @@
]]
[set readstr [fn []
- [if [head [head linep]] [if [no [same [head [head linep]] ["\"" 0]]][do
+ [if [head linep] [if [no [same [head [head linep]] ["\"" 0]]][do
[if [same [head [head linep]] ["\\" 0]] [sethead linep [tail [head linep]]]]
[set res [head [head linep]]]
[sethead linep [tail [head linep]]]
@@ -158,7 +158,7 @@
] [sethead linep [tail [head linep]]]]]
]]
-[set readobj [fn [] [if
+[set readobj [fn [] [output [str [head linep]] newline] [if
[same [head [head linep]] ["{" 0]] [do
[sethead linep [tail [head linep]]]
[readcomment]
@@ -195,13 +195,15 @@
[str [readstr]]
]
[< 47 [head [head linep]] 58] [readint 0]
- [name [str [readname line]]]
+ [name [str [readname]]]
]]]
[set read [fn [usercontext]
[output "> "]
[sethead linep [instrlist]]
- [set res [run [readobj] usercontext]]
+ [set readed [readobj]]
+ [write readed] [output newline]
+ [set res [run readed usercontext]]
[write [head res]]
[output newline]
[read [tail res]]