adding control

This commit is contained in:
tonitch 2025-03-17 23:19:02 +01:00
parent d7f9dac728
commit 197df773f7
Signed by: tonitch
GPG Key ID: A78D6421F083D42E
2 changed files with 24 additions and 10 deletions

8
examples/simple.spf Normal file
View File

@ -0,0 +1,8 @@
entier pi = 314;
entier pi2 = 3;
pi = 3;
tant que pi vaut pi2 faire {
afficher "bonjour";
}

View File

@ -8,11 +8,16 @@ instruction: keyword expression TERMINAL
keyword: ADD_KW
| SHOW_KW
expression: literal
| list
| range
//| expression operator expression
//| operator expression
expression: expressionleft
| gen_op
expressionleft: literal
| list
| range
| VARIABLE
gen_op: expressionleft SAME_OP expression
| expressionleft DIFF_OP expression
type: BOOL_TYPE
| INT_TYPE
@ -23,10 +28,10 @@ declaration: VARIABLE (EQUAL_SIGN expression)?
assignation: VARIABLE EQUAL_SIGN expression
loop: WHILES_KW expression WHILEE_KW "{" (instruction)* "}"
loop: "tant" "que" expression "faire" "{" (instruction)* "}"
literal: ENTIER
| BOOLEEN
| booleen
| ESCAPED_STRING
list: "[" expression? ("," expression)* "]"
@ -54,7 +59,7 @@ EQUAL_SIGN: "="
ENTIER: /[1-9][0-9]*/
BOOLEEN: TRUE_KW
booleen: TRUE_KW
| FALSE_KW
PLUS_SIGN: "+"
@ -67,10 +72,11 @@ INT_TYPE: "entier"
STR_TYPE: "texte"
LIST_TYPE: "liste"
SAME_OP: "==" | "vaut"
DIFF_OP: "!=" | "ne" "vaut" "pas"
ADD_KW: "ajouter"
SHOW_KW: "afficher"
WHILES_KW: "tant que"
WHILEE_KW: "faire"
TRUE_KW: "vrai"
FALSE_KW: "faux"