Parse with semantics

This commit is contained in:
2026-04-17 03:56:14 +02:00
parent 02447bf510
commit e90e9a1f29
3 changed files with 10 additions and 16 deletions
-2
View File
@@ -167,8 +167,6 @@ impl Statement {
let kind_pair = inner.next().unwrap(); // let/const/var let kind_pair = inner.next().unwrap(); // let/const/var
let name_pair = inner.next().unwrap(); // identifier let name_pair = inner.next().unwrap(); // identifier
println!("{:#?}", inner);
let init = inner.next().map(Expression::from_pair); let init = inner.next().map(Expression::from_pair);
let kind = match kind_pair.as_str() { let kind = match kind_pair.as_str() {
+7 -7
View File
@@ -72,15 +72,15 @@ fn cmd_check(path: &str) {
fn cmd_parse(path: &str) { fn cmd_parse(path: &str) {
let source = read_ms_file(path); let source = read_ms_file(path);
match parser::parse(&source) { match parser::parse(&source) {
Ok(output) => { Ok(mut ast) => {
fs::write( walk_ast(semantic::scope::Scope::from_top(&ast), &mut ast);
"output.json",
serde_json::to_string_pretty(&output).unwrap(), fs::write("output.json", serde_json::to_string_pretty(&ast).unwrap()).unwrap_or_else(
) |e| {
.unwrap_or_else(|e| {
eprintln!("error: could not write output.json: {}", e); eprintln!("error: could not write output.json: {}", e);
process::exit(1); process::exit(1);
}); },
);
} }
Err(e) => { Err(e) => {
eprintln!("parse error:\n{}", e); eprintln!("parse error:\n{}", e);
+1 -5
View File
@@ -1,9 +1,5 @@
struct Test { function test(): int { }
x: int
}
function add() { function add() {
let output = test(); let output = test();
} }
function test(): int { }