Conditional statements grammar

This commit is contained in:
ala89 2023-11-15 16:33:25 +01:00
parent 1a37e67b2c
commit 5e304a70aa
2 changed files with 4 additions and 2 deletions

View File

@ -12,7 +12,9 @@ Prog -> Instruction Prog | Instruction
Instruction -> Statement | ExprStatement; | Expr; | ; Instruction -> Statement | ExprStatement; | Expr; | ;
Statement -> // Rien pour l'instant, mais "for", "if" etc Statement ->
| { Prog }
| If (Expr) Instruction Else Instruction
ExprStatement -> ExprStatement ->
| Type ParIdentifier = Expr // AssignedDeclaration | Type ParIdentifier = Expr // AssignedDeclaration
| Type ParIdentifier // Declaration | Type ParIdentifier // Declaration

View File

@ -7,7 +7,7 @@
#include <stdexcept> #include <stdexcept>
using namespace std; 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 }; enum class Type { Int };
using TokenData = variant<int, string, Type>; using TokenData = variant<int, string, Type>;