Skip to content

Commit

Permalink
Most files suffered major changes
Browse files Browse the repository at this point in the history
- Less ambiguous syntax
- Better parser (Chumsky only does tokenization now)
- Tidy(|ier) error handling
- Facade for simplified embedding
- Dynamic action dispatch
- Many STL additions
  • Loading branch information
lbfalvy committed Aug 17, 2023
1 parent 751a02a commit afc5809
Show file tree
Hide file tree
Showing 126 changed files with 4,284 additions and 1,817 deletions.
93 changes: 88 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ path = "src/lib.rs"

[[bin]]
name = "orcx"
path = "src/bin/main.rs"
path = "src/bin/orcx.rs"
doc = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
thiserror = "1.0"
chumsky = "0.9"
hashbrown = "0.13"
hashbrown = "0.14"
ordered-float = "3.7"
itertools = "0.10"
itertools = "0.11"
dyn-clone = "1.0"
clap = { version = "4.3", features = ["derive"] }
trait-set = "0.3"
Expand All @@ -35,3 +35,5 @@ rust-embed = { version = "6.6", features = ["include-exclude"] }
duplicate = "1.0.0"
take_mut = "0.2.2"
unicode-segmentation = "1.10.1"
polling = "2.8.0"
derive_more = "0.99.17"
52 changes: 48 additions & 4 deletions ROADMAP.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,49 @@
# IO
This document is a wishlist, its items aren't ordered in any way other than inline notes about dependency relations

All IO is event-based via callbacks.
Driven streams such as stdin expose single-fire events for the results of functions such as "read until terminator" or "read N bytes".
Network IO exposes repeated events such as "connect", "message", etc.
# Language

## Operator declarations
A dedicated (exportable) line type for declaring operators. Still just names, only you can write them next to other things without whitespace

- ops may not contain c-ident-safe characters
- clusters of operator characters are broken up with a greedy algorithm

## Typeclasses
Elixir-style protocols probably, only with n-ary dispatch which I saw in SICP-js

# Rules

## Placeholder constraints
Simultaneously match a pattern to a subexpression and give it a name to copy it over

- Copy unique 1->1 names over by default to preserve their location info

# STL

## Command short-circuiting
Functions for each command type which destructure it and pass it to an Orchid callback

## Runtime error handling
result? multipath cps utils? Not sure yet.

## Pattern matching
This was the main trick in Orchid, still want to do it, still need to polish the language first

## Macro error handling
Error tokens with rules to lift them out. Kinda depends on preservation of location info in rules to be really useful

# Systems

## Async
Join allows to run code when a tuple of pending events all resolve on the event poller

## New: FS
Exposes tree operations to Orchid
Uses existing IO to open and read files
Uses the event bus to read directories in batches without blocking other Orchid code

## New: Network
Event-driven I/O with single-fire events and resubscription to relay backpressure to the OS. Initially TCP

## New: Marshall
Serialization of Orchid data, including code, given customizable sets of serializable foreign items. Alternatively, code reflection so that all this can go in the STL
17 changes: 9 additions & 8 deletions examples/calculator/main.orc
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
}
}
8 changes: 5 additions & 3 deletions examples/hello-world/main.orc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import std::io::print

main := print "Hello, world!\n" "goodbye"
const main := (
println "Hello, world!"
"success"
)
-- main := "Hello, World!\n"
8 changes: 4 additions & 4 deletions examples/list-processing/main.orc
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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
|> list::skip 2
|> list::take 3
|> list::reduce (\a.\b. a + b)
|> option::unwrap;
cps print $ to_string sum ++ "\n";
cps println $ to_string sum;
0
}
}
8 changes: 4 additions & 4 deletions examples/maps/main.orc
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
}
}
1 change: 0 additions & 1 deletion orchid.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
},
"extensions": {
"recommendations": [
"bungcip.better-toml",
"maptz.regionfolder",
"serayuzgur.crates",
"tamasfe.even-better-toml",
Expand Down
Loading

0 comments on commit afc5809

Please sign in to comment.