Most files suffered major changes

- Less ambiguous syntax
- Better parser (Chumsky only does tokenization now)
- Tidy(|ier) error handling
- Facade for simplified embedding
- External code grouped in (fairly) self-contained Systems
- Dynamic action dispatch
- Many STL additions
This commit is contained in:
2023-08-17 20:47:08 +01:00
parent 751a02a1ec
commit 3fdabc29da
139 changed files with 4269 additions and 1783 deletions

View File

@@ -1,14 +1,15 @@
import std::(proc::*, to_float, to_string, io::(readline, print))
import std::(proc::*, to_float, to_string, panic, str::char_at)
export main := do{
export const main := do{
cps print "left operand: ";
cps data = readline;
cps data = readln;
let a = to_float data;
cps print "operator: ";
cps op = readline;
cps print ("you selected \"" ++ op ++ "\"\n");
cps op = readln;
let op = char_at op 0;
cps println ("you selected \"" ++ op ++ "\"");
cps print "right operand: ";
cps data = readline;
cps data = readln;
let b = to_float data;
let result = (
if op == "+" then a + b
@@ -17,6 +18,6 @@ export main := do{
else if op == "/" then a / b
else (panic "Unsupported operation")
);
cps print ("Result: " ++ to_string result ++ "\n");
cps println ("Result: " ++ to_string result);
0
}
}

View File

@@ -1,3 +1,5 @@
import std::io::print
main := print "Hello, world!\n" "goodbye"
const main := (
println "Hello, world!"
"success"
)
-- main := "Hello, World!\n"

View File

@@ -1,6 +1,6 @@
import std::(proc::*, io::print, to_string)
import std::(proc::*, to_string)
export main := do{
export const main := do{
let foo = list::new[1, 2, 3, 4, 5, 6];
let bar = list::map foo n => n * 2;
let sum = bar
@@ -8,6 +8,6 @@ export main := do{
|> list::take 3
|> list::reduce (\a.\b. a + b)
|> option::unwrap;
cps print $ to_string sum ++ "\n";
cps println $ to_string sum;
0
}
}

View File

@@ -1,6 +1,6 @@
import std::(proc::*, io::print, to_string)
import std::(proc::*, to_string)
export main := do{
export const main := do{
let foo = map::new[
"foo" = 1,
"bar" = 2,
@@ -9,6 +9,6 @@ export main := do{
];
let num = map::get foo "bar"
|> option::unwrap;
cps print (to_string num ++ "\n");
cps println $ to_string num;
0
}
}