Make <=, >= and <> work

This commit is contained in:
Benjamin Loison 2022-12-10 19:24:34 +01:00
parent a44c9288f5
commit ac1eea42e9
2 changed files with 4 additions and 7 deletions

View File

@ -125,8 +125,7 @@ let pp_expression =
begin begin
let s = match cop with let s = match cop with
| COp_eq -> " == " | COp_eq -> " == "
| COp_neq -> "" | COp_neq -> " != "
(* TODO: check <= and >= *)
| COp_le -> " <= " | COp_lt -> " < " | COp_le -> " <= " | COp_lt -> " < "
| COp_ge -> " >= " | COp_gt -> " > " in | COp_ge -> " >= " | COp_gt -> " > " in
Format.fprintf fmt "%s%a%s%a" prefix Format.fprintf fmt "%s%a%s%a" prefix

View File

@ -16,15 +16,10 @@
("int", TYP(Ast.TInt)); ("int", TYP(Ast.TInt));
("real", TYP(Ast.TReal)); ("real", TYP(Ast.TReal));
("bool", TYP(Ast.TBool)); ("bool", TYP(Ast.TBool));
("<=", CMP_le);
(">=", CMP_ge);
("not", MO_not); ("not", MO_not);
("mod", BO_mod); ("mod", BO_mod);
("&&", BO_and);
("and", BO_and); ("and", BO_and);
("||", BO_or);
("or", BO_or); ("or", BO_or);
("<>", CMP_neq);
("if", IF); ("if", IF);
("then", THEN); ("then", THEN);
("else", ELSE); ("else", ELSE);
@ -56,7 +51,10 @@ rule token = parse
| ';' { SEMICOL } | ';' { SEMICOL }
| ':' { COLON } | ':' { COLON }
| '<' { CMP_lt } | '<' { CMP_lt }
| "<=" { CMP_le }
| '>' { CMP_gt } | '>' { CMP_gt }
| ">=" { CMP_ge }
| "<>" { CMP_neq }
| '+' { PLUS } | '+' { PLUS }
| '-' { MINUS } | '-' { MINUS }
| '*' { BO_mul } | '*' { BO_mul }