add let and in as keywords; x=y can be used in expressions as sygar for compare(x,y) == 0

This commit is contained in:
danyaberezun 2024-03-03 14:13:31 +02:00 committed by Roman Venediktov
parent 7c3687b65b
commit 16d9f06afb

View file

@ -604,6 +604,7 @@ module Expr =
match s with match s with
| ":" -> Sexp ("cons", [x; y]) | ":" -> Sexp ("cons", [x; y])
| ":=" -> Assign (x, y) | ":=" -> Assign (x, y)
| "=" -> Binop ("==", Call (Var ("compare"), [x; y]), Const (0))
| _ -> Binop (s, x, y) | _ -> Binop (s, x, y)
in in
match x with match x with
@ -921,7 +922,7 @@ module Infix =
in List.rev exports in List.rev exports
let is_predefined op = let is_predefined op =
List.exists (fun x -> op = x) [":"; "!!"; "&&"; "=="; "!="; "<="; "<"; ">="; ">"; "+"; "-"; "*" ; "/"; "%"; ":="] List.exists (fun x -> op = x) [":"; "!!"; "&&"; "="; "=="; "!="; "<="; "<"; ">="; ">"; "+"; "-"; "*" ; "/"; "%"; ":="]
(* (*
List.iter (fun op -> List.iter (fun op ->
@ -947,7 +948,7 @@ module Infix =
`Righta, [":"]; `Righta, [":"];
`Lefta , ["!!"]; `Lefta , ["!!"];
`Lefta , ["&&"]; `Lefta , ["&&"];
`Nona , ["=="; "!="; "<="; "<"; ">="; ">"]; `Nona , ["=";"=="; "!="; "<="; "<"; ">="; ">"];
`Lefta , ["+" ; "-"]; `Lefta , ["+" ; "-"];
`Lefta , ["*" ; "/"; "%"]; `Lefta , ["*" ; "/"; "%"];
|] |]
@ -1272,6 +1273,7 @@ let run_parser cmd =
let kws = [ let kws = [
"skip"; "skip";
"if"; "then"; "else"; "elif"; "fi"; "if"; "then"; "else"; "elif"; "fi";
"let"; "in";
"while"; "do"; "od"; "while"; "do"; "od";
"for"; "for";
"fun"; "var"; "public"; "external"; "import"; "fun"; "var"; "public"; "external"; "import";