forked from Orchid/orchid
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:
@@ -25,8 +25,10 @@ use orchid_host::expr::PathSetBuilder;
|
||||
use orchid_host::extension::Extension;
|
||||
use orchid_host::lex::lex;
|
||||
use orchid_host::parse::{HostParseCtxImpl, parse_expr, parse_items};
|
||||
use orchid_host::parsed::{Item, ItemKind, ParsedMember, ParsedMemberKind, ParsedModule};
|
||||
use orchid_host::subprocess::ext_command;
|
||||
use orchid_host::system::init_systems;
|
||||
use orchid_host::tree::Root;
|
||||
use substack::Substack;
|
||||
use tokio::task::{LocalSet, spawn_local};
|
||||
|
||||
@@ -194,6 +196,7 @@ async fn main() -> io::Result<ExitCode> {
|
||||
},
|
||||
Commands::Execute { proj, code } => {
|
||||
let reporter = Reporter::new();
|
||||
let path = sym!(usercode::entrypoint; i).await;
|
||||
let (mut root, systems) = init_systems(&args.system, &extensions).await.unwrap();
|
||||
if let Some(proj_path) = proj {
|
||||
let path = PathBuf::from(proj_path.into_std_path_buf());
|
||||
@@ -206,25 +209,18 @@ async fn main() -> io::Result<ExitCode> {
|
||||
},
|
||||
}
|
||||
}
|
||||
let lexemes =
|
||||
lex(i.i(code.trim()).await, sym!(usercode; i).await, &systems, ctx).await.unwrap();
|
||||
let lexemes = lex(i.i(code.trim()).await, path.clone(), &systems, ctx).await.unwrap();
|
||||
let snippet = Snippet::new(&lexemes[0], &lexemes);
|
||||
if args.logs {
|
||||
println!("lexed: {}", take_first(&ttv_fmt(&lexemes, &FmtCtxImpl { i }).await, true));
|
||||
}
|
||||
let path = sym!(usercode; i).await;
|
||||
let parse_ctx = HostParseCtxImpl {
|
||||
ctx: ctx.clone(),
|
||||
rep: &reporter,
|
||||
src: path.clone(),
|
||||
systems: &systems[..],
|
||||
};
|
||||
let parse_res = parse_expr(
|
||||
&parse_ctx,
|
||||
path.clone(),
|
||||
PathSetBuilder::new(),
|
||||
Snippet::new(&lexemes[0], &lexemes),
|
||||
)
|
||||
.await;
|
||||
let parse_res = parse_expr(&parse_ctx, path.clone(), PathSetBuilder::new(), snippet).await;
|
||||
let expr = match reporter.merge(parse_res) {
|
||||
Ok(expr) => expr,
|
||||
Err(e) => {
|
||||
@@ -233,6 +229,12 @@ async fn main() -> io::Result<ExitCode> {
|
||||
return;
|
||||
},
|
||||
};
|
||||
let parsed_root = ParsedModule::new(true, [Item::new(
|
||||
snippet.sr(),
|
||||
ParsedMember::new(true, i.i("entrypoint").await, expr.clone()),
|
||||
)]);
|
||||
let reporter = Reporter::new();
|
||||
let root = root.add_parsed(&parsed_root, sym!(usercode; i).await, &reporter).await;
|
||||
let mut xctx = ExecCtx::new(ctx.clone(), logger.clone(), root, expr).await;
|
||||
xctx.set_gas(Some(1000));
|
||||
xctx.execute().await;
|
||||
|
||||
@@ -63,7 +63,7 @@ pub async fn parse_folder(
|
||||
Ok(Some(module)) => items.push(module.default_item(name.clone(), sr.clone())),
|
||||
}
|
||||
}
|
||||
Ok(Some(ParsedModule::new(items)))
|
||||
Ok(Some(ParsedModule::new(false, items)))
|
||||
} else if path.extension() == Some(OsStr::new("orc")) {
|
||||
let name_os = path.file_stem().expect("If there is an extension, there must be a stem");
|
||||
let name = ctx.i.i(os_str_to_string(name_os, &ctx.i, [sr]).await?).await;
|
||||
@@ -81,9 +81,9 @@ pub async fn parse_folder(
|
||||
ctx.systems.read().await.iter().filter_map(|(_, sys)| sys.upgrade()).collect_vec();
|
||||
let lexemes = lex(ctx.i.i(&text).await, ns.clone(), &systems, &ctx).await?;
|
||||
let hpctx = HostParseCtxImpl { ctx: ctx.clone(), rep, src: ns.clone(), systems: &systems };
|
||||
let Some(fst) = lexemes.first() else { return Ok(Some(ParsedModule::new([]))) };
|
||||
let Some(fst) = lexemes.first() else { return Ok(Some(ParsedModule::new(false, []))) };
|
||||
let items = parse_items(&hpctx, Substack::Bottom, Snippet::new(fst, &lexemes)).await?;
|
||||
Ok(Some(ParsedModule::new(items)))
|
||||
Ok(Some(ParsedModule::new(false, items)))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user