From 5e304a70aa1f62b024958f3c3c89177c864e6fdc Mon Sep 17 00:00:00 2001 From: ala89 Date: Wed, 15 Nov 2023 16:33:25 +0100 Subject: [PATCH] Conditional statements grammar --- src/include/parser.h | 4 +++- src/include/tokenize.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/include/parser.h b/src/include/parser.h index ef2f4ce..479ea6e 100644 --- a/src/include/parser.h +++ b/src/include/parser.h @@ -12,7 +12,9 @@ Prog -> Instruction Prog | Instruction Instruction -> Statement | ExprStatement; | Expr; | ; -Statement -> // Rien pour l'instant, mais "for", "if" etc +Statement -> + | { Prog } + | If (Expr) Instruction Else Instruction ExprStatement -> | Type ParIdentifier = Expr // AssignedDeclaration | Type ParIdentifier // Declaration diff --git a/src/include/tokenize.h b/src/include/tokenize.h index 7339572..82dc7fe 100644 --- a/src/include/tokenize.h +++ b/src/include/tokenize.h @@ -7,7 +7,7 @@ #include using namespace std; -enum class TokenType { Type, Identifier, Int, Plus, Minus, DoublePlus, DoubleMinus, Star, Slash, Percent, Equal, Semicolon, LParenthese, RParenthese }; +enum class TokenType { Type, Identifier, Int, Plus, Minus, DoublePlus, DoubleMinus, Star, Slash, Percent, Equal, Semicolon, LParenthese, RParenthese, LCurlyBracket, RCurlyBracket, If, Else }; enum class Type { Int }; using TokenData = variant;