Various progress, doesnt compile

Added prelude, made lambdas a single-token prefix like NS, made progress on implementations, removed const line type
This commit is contained in:
2025-07-31 00:30:41 +02:00
parent 19f2c6426a
commit 769c6cfc9f
31 changed files with 450 additions and 250 deletions

View File

@@ -0,0 +1,59 @@
use futures::future::LocalBoxFuture;
use itertools::Itertools;
use orchid_base::error::{OrcRes, mk_errv};
use orchid_base::interner::Tok;
use orchid_base::name::Sym;
use orchid_base::parse::{Comment, ParseCtx, Parsed, expect_tok, token_errv, try_pop_no_fluff};
use orchid_extension::gen_expr::GExpr;
use orchid_extension::parser::{
ConstCtx, GenSnippet, ParsCtx, ParsedLine, ParsedLineKind, ParsedMem, ParsedMemKind, Parser,
};
use substack::Substack;
type ExprGenerator =
Box<dyn for<'a> FnOnce(ConstCtx, Substack<'a, Sym>) -> LocalBoxFuture<'a, GExpr>>;
#[derive(Default)]
pub struct LetLine;
impl Parser for LetLine {
const LINE_HEAD: &'static str = "let";
async fn parse<'a>(
ctx: ParsCtx<'a>,
exported: bool,
comments: Vec<Comment>,
line: GenSnippet<'a>,
) -> OrcRes<Vec<ParsedLine>> {
let Parsed { output: name_tok, tail } = try_pop_no_fluff(&ctx, line).await?;
let Some(name) = name_tok.as_name() else {
let err = token_errv(&ctx, name_tok, "Constant must have a name", |t| {
format!("Expected a name but found {t}")
});
return Err(err.await);
};
let Parsed { tail, .. } = expect_tok(&ctx, tail, ctx.i().i("=").await).await?;
fn do_tokv(line: GenSnippet<'_>) -> ExprGenerator {
let first: ExprGenerator = if let Some((idx, arg)) =
line.iter().enumerate().find_map(|(i, x)| Some((i, x.as_lambda()?)))
{
Box::new(move |ctx, stack| Box::pin(async move {
let name = ctx.names([])
}))
} else {
};
todo!()
}
let expr_generator = do_tokv(tail);
Ok(vec![ParsedLine {
comments,
sr: line.sr(),
kind: ParsedLineKind::Mem(ParsedMem {
exported,
name,
kind: ParsedMemKind::cnst(async |ctx| expr_generator(ctx, Substack::Bottom).await),
}),
}])
}
}
fn update_names(tree: MacTree)