aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAleksey Veresov <aleksey@veresov.pro>2021-01-04 15:28:21 +0300
committerAleksey Veresov <aleksey@veresov.pro>2021-01-04 15:28:21 +0300
commitfa6a4104b04aa7834fdafc3aca9b479605445ca7 (patch)
treea8e01c20392759587789acbb3e38e0eb773eda8f /examples
parentae882f68193e00deebce41c32df644b6cb2f2a47 (diff)
downloadcsx-fa6a4104b04aa7834fdafc3aca9b479605445ca7.tar
csx-fa6a4104b04aa7834fdafc3aca9b479605445ca7.tar.xz
csx-fa6a4104b04aa7834fdafc3aca9b479605445ca7.zip
Strings work, everything is fine. =)
Diffstat (limited to 'examples')
-rw-r--r--examples/generated.c6
-rw-r--r--examples/generated.csx8
-rw-r--r--examples/translator.c2
3 files changed, 10 insertions, 6 deletions
diff --git a/examples/generated.c b/examples/generated.c
deleted file mode 100644
index e0c3b3b..0000000
--- a/examples/generated.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <csx.h>
-int main()
-{
-csx_run(csx_list(csx_name("do"),csx_list(csx_name("set"),csx_name("no"),csx_list(csx_name("fn"),csx_list(csx_name("x"),0),csx_list(csx_name("same"),csx_name("x"),csx_list(0),0),0),0),csx_list(csx_name("set"),csx_name("outint"),csx_list(csx_name("fn"),csx_list(csx_name("n"),0),csx_list(csx_name("if"),csx_list(csx_name("<"),csx_name("n"),csx_int(0),0),csx_list(csx_name("do"),csx_list(csx_name("out"),csx_int(45),0),csx_list(csx_name("outint"),csx_list(csx_name("neg"),csx_name("n"),0),0),0),csx_list(csx_name("if"),csx_list(csx_name("<"),csx_name("n"),csx_int(10),0),csx_list(csx_name("out"),csx_list(csx_name("+"),csx_int(48),csx_name("n"),0),0),csx_list(csx_name("do"),csx_list(csx_name("outint"),csx_list(csx_name("div"),csx_name("n"),csx_int(10),0),0),csx_list(csx_name("out"),csx_list(csx_name("+"),csx_int(48),csx_list(csx_name("mod"),csx_name("n"),csx_int(10),0),0),0),0),0),0),0),0),csx_list(csx_name("set"),csx_name("map"),csx_list(csx_name("fn"),csx_list(csx_name("f"),csx_name("l"),0),csx_list(csx_name("if"),csx_list(csx_name("no"),csx_name("l"),0),csx_list(0),csx_list(csx_name("pair"),csx_list(csx_name("f"),csx_list(csx_name("head"),csx_name("l"),0),0),csx_list(csx_name("map"),csx_name("f"),csx_list(csx_name("tail"),csx_name("l"),0),0),0),0),0),0),csx_list(csx_name("map"),csx_list(csx_name("fn"),csx_list(csx_name("n"),0),csx_list(csx_name("outint"),csx_name("n"),0),csx_list(csx_name("out"),csx_int(10),0),0),csx_list(csx_name("quote"),csx_list(csx_int(99),csx_int(37),csx_int(73),csx_int(42),0),0),0),csx_list(csx_name("set"),csx_name("id"),csx_list(csx_name("fn"),csx_name("args"),csx_name("args"),0),0),csx_list(csx_name("outint"),csx_list(csx_list(csx_name("id"),csx_int(42),csx_int(13),csx_int(31),0),csx_int(2),0),0),csx_list(csx_name("out"),csx_int(10),0),0));
-return 0;
-}
diff --git a/examples/generated.csx b/examples/generated.csx
index 4d3d5fb..8710bd6 100644
--- a/examples/generated.csx
+++ b/examples/generated.csx
@@ -18,3 +18,11 @@
[set id [fn args args]]
[outint [[id 42 13 31] 2]]
[out 10]
+[out ["Hello!" 1]]
+[out 10]
+[set outstr [fn [str] [if str
+ [do [out [head str]] [outstr [tail str]]]
+ []
+]]]
+[outstr "Hello, World!"]
+[out 10]
diff --git a/examples/translator.c b/examples/translator.c
index 8358a47..29f4d4e 100644
--- a/examples/translator.c
+++ b/examples/translator.c
@@ -40,6 +40,7 @@ void readlist()
if (first) first = 0;
else putchar(',');
printf("csx_str(\"");
+ c = getchar();
while (c != EOF && c != '"') {
if (c == '\\') c = getchar();
if (c == '"' || c == '\\') putchar('\\');
@@ -47,6 +48,7 @@ void readlist()
c = getchar();
}
printf("\")");
+ c = getchar();
} else if (c == '\'') {
if (first) first = 0;
else putchar(',');