60 lines
933 B
Plaintext
60 lines
933 B
Plaintext
start: (instruction)* TERMINAL
|
|
|
|
instruction: KEYWORD TERMINAL
|
|
| declaration TERMINAL
|
|
|
|
declaration: TYPE VARIABLE
|
|
| TYPE VARIABLE "=" expression
|
|
|
|
expression: literal
|
|
| list
|
|
| range
|
|
| expression operator expression
|
|
| operator expression
|
|
|
|
literal: ENTIER
|
|
| BOOLEEN
|
|
| texte
|
|
|
|
texte: "\"" STRING "\""
|
|
|
|
list: "[" expression? ("," expression)* "]"
|
|
|
|
range: "[" ENTIER? ":" ENTIER? "]"
|
|
|
|
controls: test
|
|
| loop
|
|
|
|
operator: PLUS
|
|
| MINUS
|
|
| TIMES
|
|
| DIVIDE // TODO: not complete
|
|
|
|
PLUS: "+"
|
|
MINUS: "-"
|
|
TIMES: "*"
|
|
DIVIDE: "/"
|
|
|
|
test: "si" expression "alors" "{" instruction* "}"
|
|
|
|
loop: "si" expression "alors" "{" (instruction)* "}"
|
|
|
|
COMMENT: "#" /[^\n]/
|
|
%ignore COMMENT
|
|
|
|
TERMINAL: ";"
|
|
|
|
VARIABLE: /([a-z]|[A-Z]|_)+([a-z]|[A-Z]|[0-9]|_)+/ // TODO: ajouter accents
|
|
|
|
TYPE: "booléen" | "entier" | "texte" | "liste"
|
|
|
|
KEYWORD: "ajouter" | "afficher"
|
|
|
|
ENTIER: /[1-9][0-9]*/
|
|
|
|
BOOLEEN: "vrai" | "faux"
|
|
|
|
STRING: /\w+/
|
|
|
|
|