From 3f81d391df7c33c008486c55e6029c5292ea3265 Mon Sep 17 00:00:00 2001 From: Per Lindgren <per.lindgren@ltu.se> Date: Mon, 21 Sep 2020 20:52:43 +0200 Subject: [PATCH] move to new syntax, wip4 --- examples/wip.rs | 1 + src/grammar.lalrpop | 18 ++---------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/examples/wip.rs b/examples/wip.rs index 4e7015b..cc3412e 100644 --- a/examples/wip.rs +++ b/examples/wip.rs @@ -1,3 +1,4 @@ fn main() { + {} a; } diff --git a/src/grammar.lalrpop b/src/grammar.lalrpop index 0ad634c..843bb45 100644 --- a/src/grammar.lalrpop +++ b/src/grammar.lalrpop @@ -155,29 +155,15 @@ pub Block: Stmts = { StmtSeq: Stmt = { <Stmt> ";" => <>, - StmtBlock => panic!(), + StmtBlock => Stmt::Block(<>), } StmtBlock: Stmts = { "while" Expr Block => panic!(), "if" Expr Block ("else" Block)? => panic!(), - Block => panic!(), + Block, } -// Stmt: Stmt = { - // ";" => Stmt::Semi, -// "let" "mut"? Id "=" Expr ";" => (), -// ExprNoBlock "=" Expr => (), -// "while" Expr Block => (), -// "if" Expr Block ("else" Block)? => (), -// ExprNoBlock => (), -// Block => (), -// } - - - - - Stmt: Stmt = { ";" => Stmt::Semi, //"let" <m: "mut"?> <id: Id> <t: (":" <Type>)?> <e: ("=" <Expr>)?> => Stmt::Let(id, m.is_some(), t, e), -- GitLab