Working top level statement #103
This commit is contained in:
@@ -389,8 +389,8 @@ statement_list = {
|
|||||||
|
|
||||||
statement = _{
|
statement = _{
|
||||||
control_flow
|
control_flow
|
||||||
| (expr ~ semicolon)
|
|
||||||
| top_level
|
| top_level
|
||||||
|
| (expr ~ semicolon)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------
|
// ------------------------------------------------------
|
||||||
|
|||||||
@@ -94,7 +94,8 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for Expression {
|
|||||||
| Rule::basic_stmt
|
| Rule::basic_stmt
|
||||||
| Rule::control_flow
|
| Rule::control_flow
|
||||||
| Rule::block
|
| Rule::block
|
||||||
| Rule::unsafe_block => Ok(Expression::Statement(Box::new(pair.try_into()?))),
|
| Rule::unsafe_block
|
||||||
|
| Rule::top_level => Ok(Expression::Statement(Box::new(pair.try_into()?))),
|
||||||
|
|
||||||
_ => AstError::bug_unimplemented(pair),
|
_ => AstError::bug_unimplemented(pair),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ impl<'a> TryFrom<pest::iterators::Pair<'a, Rule>> for Statement {
|
|||||||
|
|
||||||
Rule::block => Ok(Statement::Block(pair.try_into()?)),
|
Rule::block => Ok(Statement::Block(pair.try_into()?)),
|
||||||
|
|
||||||
|
Rule::top_level => Ok(Statement::TopLevel(Box::new(pair.try_into()?))),
|
||||||
|
|
||||||
Rule::var_decl_statement => Ok(Statement::VarDecl(pair.try_into()?)),
|
Rule::var_decl_statement => Ok(Statement::VarDecl(pair.try_into()?)),
|
||||||
|
|
||||||
Rule::return_stmt => Ok(Statement::Return(
|
Rule::return_stmt => Ok(Statement::Return(
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
use std::fmt;
|
|
||||||
println!("running common tests...");
|
println!("running common tests...");
|
||||||
common::test_package();
|
common::test_package();
|
||||||
common::expr_test::run_tests();
|
common::expr_test::run_tests();
|
||||||
|
|||||||
Reference in New Issue
Block a user