Adding list accessor and for loop

This commit is contained in:
Anthony Debucquoy
2025-03-20 21:11:17 +01:00
parent 948b335cb5
commit 1a181095c6
3 changed files with 32 additions and 5 deletions

View File

@@ -35,6 +35,7 @@ operator: expressionleft SAME_OP expression -> equal
| NEG_OP expression -> neg
// string/list -> string/list
| SIZE_OP expression -> sizeof
| expressionleft "[" expression "]" -> list_get
?type: BOOL_TYPE
| INT_TYPE
@@ -45,8 +46,8 @@ declaration: type VARIABLE (EQUAL_SIGN expression)?
assignation: VARIABLE EQUAL_SIGN expression
loop: "tant" "que" expression "faire" "{" (instruction)* "}" -> while_loop
| "pour" "chaque" type VARIABLE "dans" expression "faire" "{" (instruction)* "}" -> for_loop
loop: "tant" "que" expression "faire" "{" instruction_seq "}" -> while_loop
| "pour" "chaque" type VARIABLE "dans" expression "faire" "{" instruction_seq "}" -> for_loop
?literal: ENTIER -> entier
| booleen
@@ -59,7 +60,8 @@ range: "[" expression? ":" expression? "]"
controls: test
| loop
test: "si" expression "alors" "{" instruction* "}" ("sinon" "{" instruction* "}")?
test: "si" expression "alors" "{" instruction_seq "}" ("sinon" "{" instruction_seq "}")?
instruction_seq: (instruction*)
?booleen: TRUE_KW -> true
| FALSE_KW -> false