mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 06:48:48 +00:00
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:
parent
7c3687b65b
commit
16d9f06afb
1 changed files with 4 additions and 2 deletions
|
|
@ -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";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue