Browse Source

Remove uneeded compount statement

github-actions
Garrit Franke 3 years ago
parent
commit
a593bba4d7
  1. 6
      examples/hello_world.sb
  2. 7
      examples_out/out.js
  3. 1
      src/generator/js.rs
  4. 1
      src/parser/node_type.rs

6
examples/hello_world.sb

@ -1,7 +1,9 @@
// main.sb
fn main() {
foo(2, 1);
return foo(2);
}
fn foo(x) {
return x;
}
}

7
examples_out/out.js

@ -1,7 +1,8 @@
// out.js
function main() {
foo(2,1)
return foo(2);
}
function foo(x) {
return x
return x;
}
console.log(main())
console.log(main());

1
src/generator/js.rs

@ -43,7 +43,6 @@ fn generate_statement(statement: Statement) -> String {
Statement::Return(ret) => generate_return(ret),
Statement::Declare(_, _) => todo!(),
Statement::Exp(val) => generate_expression(val),
Statement::Compound(_) => todo!(),
Statement::If(_, _, _) => todo!(),
Statement::While(_, _) => todo!(),
}

1
src/parser/node_type.rs

@ -23,7 +23,6 @@ pub enum Statement {
If(Expression, Box<Statement>, Option<Box<Statement>>),
While(Expression, Box<Statement>),
Exp(Expression),
Compound(Vec<Statement>),
}
#[derive(Debug, Eq, PartialEq)]

Loading…
Cancel
Save