From a4980b8dbf1394c2b302f1de7c72d2264426b86e Mon Sep 17 00:00:00 2001 From: Mel Date: Wed, 20 Oct 2021 22:15:08 +0200 Subject: Statement parsing. --- grammar.ebnf | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'grammar.ebnf') diff --git a/grammar.ebnf b/grammar.ebnf index 425c64a..d99f268 100644 --- a/grammar.ebnf +++ b/grammar.ebnf @@ -25,7 +25,7 @@ UnaryExpression = ( "-" | "!" ) UnaryExpression | UnitExpression ; (* Unaffected Expressions *) -UnitExpression = FLOAT | INT | STR | GroupExpression | BlockExpression | FnExpression | | TypeExpression | FormExpression | IfExpression; +UnitExpression = FLOAT | INT | STR | GroupExpression | BlockExpression | FnExpression | TypeExpression | FormExpression | IfExpression; GroupExpression = "(" Expression ")"; BlockExpression = Block; @@ -37,16 +37,14 @@ IfExpression = "if" Expression Block { "elif" Expression Block } [ "else" Block (* Parts *) -FnHeader = (FnSingleParameter | FnMultipleParameters) ["->" Type]; -FnSingleParameter = "self" | FnParameter; -FnMultipleParameters = "(" FnSingleParameter { "," FnParameter} ")"; -FnParameter = IdentiferType; +FnHeader = (FnParameters) ["->" Type]; +FnParameters = ("self" | FnParameter) { "," FnParameter}; (* Utils *) Block = "{" { Statement } [Expression] "}"; -TypeBlock = "{" [ IdentiferType ] { "," IdentiferType } "}"; +TypeBlock = "{" [ TypedIdentifier ] { "," TypedIdentifier } "}"; -IdentiferType = IDENTIFIER ":" Type; +TypedIdentifier = IDENTIFIER [":" Type]; (* NOTE: Type doesn't include anything other than simple named types for now. *) Type = IDENTIFIER; -- cgit 1.4.1