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

33
orchid-host/src/parse.rs Normal file
View File

@@ -0,0 +1,33 @@
use orchid_base::interner::Tok;
use crate::tree::{OwnedItem, OwnedModule, OwnedTok, OwnedTokTree};
pub struct ParseCtx<'a> {
tokens: &'a [OwnedTokTree]
}
pub fn split_br(ctx: ParseCtx) -> impl Iterator<Item = ParseCtx> {
ctx.tokens.split(|t| matches!(t.tok, OwnedTok::BR)).map(|tokens| ParseCtx { tokens })
}
pub fn strip_br(tt: &OwnedTokTree) -> Option<OwnedTokTree> {
let tok = match &tt.tok {
OwnedTok::BR => return None,
OwnedTok::Lambda(arg) => OwnedTok::Lambda(arg.iter().filter_map(strip_br).collect()),
OwnedTok::S(p, b) => OwnedTok::S(p.clone(), b.iter().filter_map(strip_br).collect()),
t => t.clone(),
};
Some(OwnedTokTree { tok, range: tt.range.clone() })
}
pub fn parse_items(ctx: ParseCtx) -> Vec<OwnedItem> {
todo!()
}
pub fn parse_item(ctx: ParseCtx) -> OwnedItem {
todo!()
}
pub fn parse_module(ctx: ParseCtx) -> (Tok<String>, OwnedModule) {
todo!()
}