From fef619ac03ace67e4d9d39764e14b328960a9486 Mon Sep 17 00:00:00 2001 From: Marvin Schlegel Date: Tue, 14 May 2024 13:20:46 +0200 Subject: [PATCH] parser add if then --- src/Parser/JavaParser.y | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Parser/JavaParser.y b/src/Parser/JavaParser.y index e51afb4..b64cb27 100644 --- a/src/Parser/JavaParser.y +++ b/src/Parser/JavaParser.y @@ -184,7 +184,7 @@ referencetype : classorinterfacetype { $1 } variabledeclarator : variabledeclaratorid { Declarator $1 Nothing } | variabledeclaratorid ASSIGN variableinitializer { Declarator $1 (Just $3) } -blockstatement : localvariabledeclarationstatement { $1 } +blockstatement : localvariabledeclarationstatement { $1 } -- expected type statement | statement { $1 } formalparameter : type variabledeclaratorid { ParameterDeclaration $1 $2 } @@ -200,8 +200,8 @@ variableinitializer : expression { $1 } localvariabledeclarationstatement : localvariabledeclaration SEMICOLON { $1 } -statement : statementwithouttrailingsubstatement{ $1 } - -- | ifthenstatement { } +statement : statementwithouttrailingsubstatement{ $1 } -- statement returns a list of statements + | ifthenstatement { [$1] } -- | ifthenelsestatement { } -- | whilestatement { } @@ -218,7 +218,7 @@ statementwithouttrailingsubstatement : block { [$1] } -- | expressionstatement { } | returnstatement { [$1] } -ifthenstatement : IF LBRACE expression RBRACE statement { } +ifthenstatement : IF LBRACE expression RBRACE statement { If $3 (Block $5) Nothing } ifthenelsestatement : IF LBRACE expression RBRACE statementnoshortif ELSE statement { }