Skip to content
Snippets Groups Projects
Commit d8dd5ad7 authored by Per Lindgren's avatar Per Lindgren
Browse files

move to new syntax, wip2

parent bb2c8418
No related branches found
No related tags found
No related merge requests found
fn main() {
a;
}
......@@ -149,11 +149,23 @@ Type : Type = {
// }
pub Block: Stmts = {
"{" <Stmt*> "}" => Stmts { stmts: <>, ret: false },
"{" <sts: StmtSeq*> <st: Stmt?> "}"
=> Stmts { stmts: sts, ret: false },
}
// pub Stmt: () = {
// ";" => (),
StmtSeq: Stmt = {
<Stmt> ";" => <>,
StmtBlock => panic!(),
}
StmtBlock: Stmts = {
"while" Expr Block => panic!(),
"if" Expr Block ("else" Block)? => panic!(),
Block => panic!(),
}
// Stmt: Stmt = {
// ";" => Stmt::Semi,
// "let" "mut"? Id "=" Expr ";" => (),
// ExprNoBlock "=" Expr => (),
// "while" Expr Block => (),
......@@ -238,16 +250,16 @@ MulDivOp: Op = {
Term: Box<Expr> = {
Num => Box::new(Expr::Num(<>)),
// "true" => Box::new(Expr::Bool(true)),
// "false" => Box::new(Expr::Bool(false)),
// <Id> <Exprs> => Box::new(Expr::Call(<>)),
// Id => Box::new(Expr::Id(<>)),
// AddSubOp Term => Box::new(Expr::Prefix(<>)),
// "!" <Term> => Box::new(Expr::Prefix(Op::Not, <>)),
// "&" <Term> => Box::new(Expr::Ref(<>)),
// "&" "mut" <Term> => Box::new(Expr::RefMut(<>)),
// "*" <Term> => Box::new(Expr::DeRef(<>)),
// "(" <Expr> ")"
"true" => Box::new(Expr::Bool(true)),
"false" => Box::new(Expr::Bool(false)),
<Id> <Exprs> => Box::new(Expr::Call(<>)),
Id => Box::new(Expr::Id(<>)),
AddSubOp Term => Box::new(Expr::Prefix(<>)),
"!" <Term> => Box::new(Expr::Prefix(Op::Not, <>)),
"&" <Term> => Box::new(Expr::Ref(<>)),
"&" "mut" <Term> => Box::new(Expr::RefMut(<>)),
"*" <Term> => Box::new(Expr::DeRef(<>)),
"(" <Expr> ")" => <>,
};
Num: i32 = {
......
......@@ -174,3 +174,8 @@ fn check_scopes_err() {
fn check_let_if() {
assert!(check(&read_file::parse("examples/let_if.rs")).is_err());
}
#[test]
fn wip() {
assert!(check(&read_file::parse("examples/wip.rs")).is_err());
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment