From 8a6eb35a900081967db16d313ab7ed470de6570f Mon Sep 17 00:00:00 2001 From: Mel Date: Sat, 23 Oct 2021 22:01:52 +0200 Subject: Loop expressions and concrete walker errors. --- grammar.ebnf | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'grammar.ebnf') diff --git a/grammar.ebnf b/grammar.ebnf index c4c6914..7428788 100644 --- a/grammar.ebnf +++ b/grammar.ebnf @@ -4,10 +4,12 @@ Program = {Statement} EOF; (* Statement *) -Statement = ExpressionStatement | ReturnStatement | PrintStatement; +Statement = ExpressionStatement | ReturnStatement | BreakStatement | ContinueExpression | PrintStatement; ExpressionStatement = Expression ";"; ReturnStatement = "return" Expression ";"; +BreakStatement = "break" [Expression] ";"; +ContinueStatement = "continue" ";"; (* NOTE: Hard-coded PrintStatement until Rabbithole has an standard library *) PrintStatement = "print" Expression ";"; @@ -27,7 +29,7 @@ UnaryExpression = ( "-" | "!" ) UnaryExpression | UnitExpression ; (* Unaffected Expressions *) -UnitExpression = FLOAT | INT | STR | TRUE | FALSE |GroupExpression | BlockExpression | FnExpression | TypeExpression | FormExpression | IfExpression; +UnitExpression = FLOAT | INT | STR | TRUE | FALSE | GroupExpression | BlockExpression | FnExpression | TypeExpression | FormExpression | IfExpression; GroupExpression = "(" Expression ")"; BlockExpression = Block; @@ -36,6 +38,7 @@ TypeExpression = "type" TypeBlock; (* NOTE: Will associated functions clash with fields? *) FormExpression = "form" TypeBlock; IfExpression = "if" Expression Block { "elif" Expression Block } [ "else" Block ]; +LoopExpression = "loop" ["if" Expression] Block; (* Parts *) -- cgit 1.4.1