adding op (unordered)
This commit is contained in:
parent
197df773f7
commit
9c17bd6c81
67
spf.lark
67
spf.lark
@ -1,15 +1,16 @@
|
|||||||
start: (instruction)*
|
start: (instruction)*
|
||||||
|
|
||||||
instruction: keyword expression TERMINAL
|
instruction: type declaration TERMINAL
|
||||||
| type declaration TERMINAL
|
|
||||||
| assignation TERMINAL
|
| assignation TERMINAL
|
||||||
| controls
|
| controls
|
||||||
|
| SHOW_KW expression ("," expression)* TERMINAL
|
||||||
|
| ADD_KW expression "dans" VARIABLE TERMINAL
|
||||||
|
|
||||||
keyword: ADD_KW
|
expression: expressionleft // TODO: priorité des op certainement fausse
|
||||||
| SHOW_KW
|
|
||||||
|
|
||||||
expression: expressionleft
|
|
||||||
| gen_op
|
| gen_op
|
||||||
|
| bool_op
|
||||||
|
| int_op
|
||||||
|
| list_op
|
||||||
|
|
||||||
expressionleft: literal
|
expressionleft: literal
|
||||||
| list
|
| list
|
||||||
@ -19,8 +20,23 @@ expressionleft: literal
|
|||||||
gen_op: expressionleft SAME_OP expression
|
gen_op: expressionleft SAME_OP expression
|
||||||
| expressionleft DIFF_OP expression
|
| expressionleft DIFF_OP expression
|
||||||
|
|
||||||
|
bool_op: expressionleft AND_OP expression
|
||||||
|
| expressionleft OR_OP expression
|
||||||
|
| NOT_OP expression
|
||||||
|
|
||||||
|
int_op: expressionleft LT_OP expression
|
||||||
|
| expressionleft LE_OP expression
|
||||||
|
| expressionleft GT_OP expression
|
||||||
|
| expressionleft GE_OP expression
|
||||||
|
| expressionleft operator expression
|
||||||
|
| NEG_OP expression
|
||||||
|
|
||||||
|
list_op: expressionleft CONC_OP expression
|
||||||
|
| expressionleft ("[" expression "]" | range)
|
||||||
|
| SIZE_OP expression
|
||||||
|
|
||||||
type: BOOL_TYPE
|
type: BOOL_TYPE
|
||||||
| INT_TYPE
|
| INT_TYPE
|
||||||
| STR_TYPE
|
| STR_TYPE
|
||||||
| LIST_TYPE
|
| LIST_TYPE
|
||||||
|
|
||||||
@ -29,6 +45,7 @@ declaration: VARIABLE (EQUAL_SIGN expression)?
|
|||||||
assignation: VARIABLE EQUAL_SIGN expression
|
assignation: VARIABLE EQUAL_SIGN expression
|
||||||
|
|
||||||
loop: "tant" "que" expression "faire" "{" (instruction)* "}"
|
loop: "tant" "que" expression "faire" "{" (instruction)* "}"
|
||||||
|
| "pour" "chaque" type VARIABLE "dans" expression "faire" "{" (instruction)* "}"
|
||||||
|
|
||||||
literal: ENTIER
|
literal: ENTIER
|
||||||
| booleen
|
| booleen
|
||||||
@ -36,7 +53,7 @@ literal: ENTIER
|
|||||||
|
|
||||||
list: "[" expression? ("," expression)* "]"
|
list: "[" expression? ("," expression)* "]"
|
||||||
|
|
||||||
range: "[" ENTIER? ":" ENTIER? "]"
|
range: "[" expression? ":" expression? "]"
|
||||||
|
|
||||||
controls: test
|
controls: test
|
||||||
| loop
|
| loop
|
||||||
@ -45,10 +62,10 @@ test: "si" expression "alors" "{" instruction* "}"
|
|||||||
| "si" expression "alors" "{" instruction* "}" "sinon" "{" instruction* "}"
|
| "si" expression "alors" "{" instruction* "}" "sinon" "{" instruction* "}"
|
||||||
|
|
||||||
|
|
||||||
operator: PLUS_SIGN
|
operator: PLUS_OP
|
||||||
| MINUS_SIGN
|
| MINUS_OP
|
||||||
| TIMES_SIGN
|
| TIMES_OP
|
||||||
| DIVIDE_SIGN // TODO: not complete
|
| DIVIDE_OP // TODO: not complete
|
||||||
|
|
||||||
TERMINAL: ";"
|
TERMINAL: ";"
|
||||||
|
|
||||||
@ -57,16 +74,11 @@ VARIABLE: VAR_CHARS (VAR_CHARS | /[0-9]/)*
|
|||||||
|
|
||||||
EQUAL_SIGN: "="
|
EQUAL_SIGN: "="
|
||||||
|
|
||||||
ENTIER: /[1-9][0-9]*/
|
ENTIER: /0|[1-9][0-9]*/
|
||||||
|
|
||||||
booleen: TRUE_KW
|
booleen: TRUE_KW
|
||||||
| FALSE_KW
|
| FALSE_KW
|
||||||
|
|
||||||
PLUS_SIGN: "+"
|
|
||||||
MINUS_SIGN: "-"
|
|
||||||
TIMES_SIGN: "*"
|
|
||||||
DIVIDE_SIGN: "/"
|
|
||||||
|
|
||||||
BOOL_TYPE: "booléen"
|
BOOL_TYPE: "booléen"
|
||||||
INT_TYPE: "entier"
|
INT_TYPE: "entier"
|
||||||
STR_TYPE: "texte"
|
STR_TYPE: "texte"
|
||||||
@ -75,6 +87,25 @@ LIST_TYPE: "liste"
|
|||||||
SAME_OP: "==" | "vaut"
|
SAME_OP: "==" | "vaut"
|
||||||
DIFF_OP: "!=" | "ne" "vaut" "pas"
|
DIFF_OP: "!=" | "ne" "vaut" "pas"
|
||||||
|
|
||||||
|
AND_OP: "et"
|
||||||
|
OR_OP: "ou"
|
||||||
|
NOT_OP: "not"
|
||||||
|
|
||||||
|
NEG_OP: "-"
|
||||||
|
|
||||||
|
PLUS_OP: "+"
|
||||||
|
MINUS_OP: "-"
|
||||||
|
TIMES_OP: "*"
|
||||||
|
DIVIDE_OP: "/"
|
||||||
|
|
||||||
|
LT_OP: "<"
|
||||||
|
LE_OP: "<="
|
||||||
|
GT_OP: ">"
|
||||||
|
GE_OP: ">="
|
||||||
|
|
||||||
|
CONC_OP: "+"
|
||||||
|
SIZE_OP: "taille"
|
||||||
|
|
||||||
ADD_KW: "ajouter"
|
ADD_KW: "ajouter"
|
||||||
SHOW_KW: "afficher"
|
SHOW_KW: "afficher"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user