Parse with semantics
This commit is contained in:
@@ -167,8 +167,6 @@ impl Statement {
|
||||
let kind_pair = inner.next().unwrap(); // let/const/var
|
||||
let name_pair = inner.next().unwrap(); // identifier
|
||||
|
||||
println!("{:#?}", inner);
|
||||
|
||||
let init = inner.next().map(Expression::from_pair);
|
||||
|
||||
let kind = match kind_pair.as_str() {
|
||||
|
||||
+9
-9
@@ -72,15 +72,15 @@ fn cmd_check(path: &str) {
|
||||
fn cmd_parse(path: &str) {
|
||||
let source = read_ms_file(path);
|
||||
match parser::parse(&source) {
|
||||
Ok(output) => {
|
||||
fs::write(
|
||||
"output.json",
|
||||
serde_json::to_string_pretty(&output).unwrap(),
|
||||
)
|
||||
.unwrap_or_else(|e| {
|
||||
eprintln!("error: could not write output.json: {}", e);
|
||||
process::exit(1);
|
||||
});
|
||||
Ok(mut ast) => {
|
||||
walk_ast(semantic::scope::Scope::from_top(&ast), &mut ast);
|
||||
|
||||
fs::write("output.json", serde_json::to_string_pretty(&ast).unwrap()).unwrap_or_else(
|
||||
|e| {
|
||||
eprintln!("error: could not write output.json: {}", e);
|
||||
process::exit(1);
|
||||
},
|
||||
);
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("parse error:\n{}", e);
|
||||
|
||||
+1
-5
@@ -1,9 +1,5 @@
|
||||
struct Test {
|
||||
x: int
|
||||
}
|
||||
function test(): int { }
|
||||
|
||||
function add() {
|
||||
let output = test();
|
||||
}
|
||||
|
||||
function test(): int { }
|
||||
Reference in New Issue
Block a user