Changes in api and upwards

- Removed out-of-stack error reporting
- Revised module system to match previous Orchid system
- Errors are now in a Vec everywhere
- Implemented atoms and lexer
- Started implementation of line parser
- Tree is now ephemeral to avoid copying Atoms held inside
- Moved numbers into std and the shared parser into base
- Started implementation of Commands
This commit is contained in:
2024-07-28 23:59:55 +02:00
parent cc3699bbe7
commit 9d35ba8040
46 changed files with 1236 additions and 642 deletions

View File

@@ -1,14 +1,16 @@
use std::sync::Arc;
use orchid_base::interner::Tok;
use orchid_extension::atom::{AtomDynfo, AtomicFeatures};
use orchid_extension::fs::DeclFs;
use orchid_extension::fun::Fun;
use orchid_extension::system::{System, SystemCard};
use orchid_extension::system_ctor::SystemCtor;
use orchid_extension::tree::GenTree;
use orchid_extension::tree::{cnst, module, root_mod, GenMemberKind};
use crate::string::str_atom::StringAtom;
use crate::string::str_leer::StringLexer;
use crate::number::num_atom::{Float, Int};
use crate::string::str_atom::StrAtom;
use crate::string::str_lexer::StringLexer;
use crate::OrcString;
#[derive(Default)]
@@ -22,25 +24,23 @@ impl SystemCtor for StdSystem {
}
impl SystemCard for StdSystem {
type Ctor = Self;
const ATOM_DEFS: &'static [Option<&'static dyn AtomDynfo>] = &[Some(StringAtom::INFO)];
const ATOM_DEFS: &'static [Option<&'static dyn AtomDynfo>] =
&[Some(Int::INFO), Some(Float::INFO), Some(StrAtom::INFO)];
}
impl System for StdSystem {
fn lexers() -> Vec<orchid_extension::lexer::LexerObj> { vec![&StringLexer] }
fn vfs() -> DeclFs { DeclFs::Mod(&[]) }
fn env() -> GenTree {
GenTree::module([(
"std",
GenTree::module([(
"string",
GenTree::module([(
"concat",
GenTree::cnst(Fun::new(|left: OrcString| {
fn env() -> Vec<(Tok<String>, GenMemberKind)> {
vec![
root_mod("std", [], [
module(true, "string", [], [
cnst(true, "concat", Fun::new(|left: OrcString| {
Fun::new(move |right: OrcString| {
StringAtom::new(Arc::new(left.get_string().to_string() + &right.get_string()))
StrAtom::new(Arc::new(left.get_string().to_string() + &right.get_string()))
})
})),
)]),
)]),
)])
}))
]),
])
]
}
}