Parse with semantics
This commit is contained in:
@@ -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() {
|
||||||
|
|||||||
+9
-9
@@ -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
@@ -1,9 +1,5 @@
|
|||||||
struct Test {
|
function test(): int { }
|
||||||
x: int
|
|
||||||
}
|
|
||||||
|
|
||||||
function add() {
|
function add() {
|
||||||
let output = test();
|
let output = test();
|
||||||
}
|
}
|
||||||
|
|
||||||
function test(): int { }
|
|
||||||
Reference in New Issue
Block a user