start: (instruction)* instruction: declaration ";" | assignation ";" | SHOW_KW expression ("," expression)* ";" -> afficher | ADD_KW expression "dans" VARIABLE ";" -> append | controls // rule finishing by u are "UnambigiousED" expression: logical logical: comparison logicalu? logicalu: AND_OP logical | OR_OP logical comparison: sumterm comparisonu? comparisonu: SAME_OP comparison | DIFF_OP comparison | LT_OP comparison | LE_OP comparison | GT_OP comparison | GE_OP comparison sumterm: multterm sumtermu? sumtermu: PLUS_OP sumterm | MINUS_OP sumterm multterm: priority multtermu? multtermu: TIMES_OP multterm | DIVIDE_OP multterm priority: finalterm | finalterm "[" expression "]" -> list_get | SIZE_OP finalterm | NEG_OP finalterm | NOT_OP finalterm finalterm: "(" expression ")" | literal | list | range | VARIABLE -> variable ?type: BOOL_TYPE | INT_TYPE | STR_TYPE | LIST_TYPE declaration: type VARIABLE (EQUAL_SIGN expression)? assignation: VARIABLE EQUAL_SIGN expression loop: "tant" "que" expression "faire" "{" instruction_seq "}" -> while_loop | "pour" "chaque" type VARIABLE "dans" expression "faire" "{" instruction_seq "}" -> for_loop ?literal: ENTIER -> entier | booleen | ESCAPED_STRING -> string list: "[" expression? ("," expression)* "]" range: "[" expression ":" expression "]" controls: test | loop test: "si" expression "alors" "{" instruction_seq "}" ("sinon" "{" instruction_seq "}")? instruction_seq: (instruction*) ?booleen: TRUE_KW -> true | FALSE_KW -> false TERMINAL: ";" VAR_CHARS: /[a-zA-Zçâêîôûéàèìòùëïü_]/ VARIABLE: VAR_CHARS (VAR_CHARS | /[0-9]/)* EQUAL_SIGN: "=" ENTIER: /0|[1-9][0-9]*/ BOOL_TYPE: "booléen" INT_TYPE: "entier" STR_TYPE: "texte" LIST_TYPE: "liste" SAME_OP: "==" | "vaut" 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" LBRAC: "[" RBRAC: "]" ADD_KW: "ajouter" SHOW_KW: "afficher" TRUE_KW: "vrai" FALSE_KW: "faux" %import common.ESCAPED_STRING COMMENT: /#[^\n]*/ %ignore COMMENT %import common.WS %ignore WS