adding control
This commit is contained in:
parent
d7f9dac728
commit
197df773f7
8
examples/simple.spf
Normal file
8
examples/simple.spf
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
entier pi = 314;
|
||||||
|
entier pi2 = 3;
|
||||||
|
|
||||||
|
pi = 3;
|
||||||
|
|
||||||
|
tant que pi vaut pi2 faire {
|
||||||
|
afficher "bonjour";
|
||||||
|
}
|
26
spf.lark
26
spf.lark
@ -8,11 +8,16 @@ instruction: keyword expression TERMINAL
|
|||||||
keyword: ADD_KW
|
keyword: ADD_KW
|
||||||
| SHOW_KW
|
| SHOW_KW
|
||||||
|
|
||||||
expression: literal
|
expression: expressionleft
|
||||||
| list
|
| gen_op
|
||||||
| range
|
|
||||||
//| expression operator expression
|
expressionleft: literal
|
||||||
//| operator expression
|
| list
|
||||||
|
| range
|
||||||
|
| VARIABLE
|
||||||
|
|
||||||
|
gen_op: expressionleft SAME_OP expression
|
||||||
|
| expressionleft DIFF_OP expression
|
||||||
|
|
||||||
type: BOOL_TYPE
|
type: BOOL_TYPE
|
||||||
| INT_TYPE
|
| INT_TYPE
|
||||||
@ -23,10 +28,10 @@ declaration: VARIABLE (EQUAL_SIGN expression)?
|
|||||||
|
|
||||||
assignation: VARIABLE EQUAL_SIGN expression
|
assignation: VARIABLE EQUAL_SIGN expression
|
||||||
|
|
||||||
loop: WHILES_KW expression WHILEE_KW "{" (instruction)* "}"
|
loop: "tant" "que" expression "faire" "{" (instruction)* "}"
|
||||||
|
|
||||||
literal: ENTIER
|
literal: ENTIER
|
||||||
| BOOLEEN
|
| booleen
|
||||||
| ESCAPED_STRING
|
| ESCAPED_STRING
|
||||||
|
|
||||||
list: "[" expression? ("," expression)* "]"
|
list: "[" expression? ("," expression)* "]"
|
||||||
@ -54,7 +59,7 @@ EQUAL_SIGN: "="
|
|||||||
|
|
||||||
ENTIER: /[1-9][0-9]*/
|
ENTIER: /[1-9][0-9]*/
|
||||||
|
|
||||||
BOOLEEN: TRUE_KW
|
booleen: TRUE_KW
|
||||||
| FALSE_KW
|
| FALSE_KW
|
||||||
|
|
||||||
PLUS_SIGN: "+"
|
PLUS_SIGN: "+"
|
||||||
@ -67,10 +72,11 @@ INT_TYPE: "entier"
|
|||||||
STR_TYPE: "texte"
|
STR_TYPE: "texte"
|
||||||
LIST_TYPE: "liste"
|
LIST_TYPE: "liste"
|
||||||
|
|
||||||
|
SAME_OP: "==" | "vaut"
|
||||||
|
DIFF_OP: "!=" | "ne" "vaut" "pas"
|
||||||
|
|
||||||
ADD_KW: "ajouter"
|
ADD_KW: "ajouter"
|
||||||
SHOW_KW: "afficher"
|
SHOW_KW: "afficher"
|
||||||
WHILES_KW: "tant que"
|
|
||||||
WHILEE_KW: "faire"
|
|
||||||
|
|
||||||
TRUE_KW: "vrai"
|
TRUE_KW: "vrai"
|
||||||
FALSE_KW: "faux"
|
FALSE_KW: "faux"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user