mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-15 11:18:43 +00:00
Yep...
This commit is contained in:
parent
1a33860560
commit
f10cdcf2e8
2 changed files with 4 additions and 40 deletions
|
|
@ -77,26 +77,7 @@ module Expr =
|
|||
|
||||
*)
|
||||
ostap (
|
||||
parse:
|
||||
!(Ostap.Util.expr
|
||||
(fun x -> x)
|
||||
(Array.map (fun (a, s) -> a,
|
||||
List.map (fun s -> ostap(- $(s)), (fun x y -> Binop (s, x, y))) s
|
||||
)
|
||||
[|
|
||||
`Lefta, ["!!"];
|
||||
`Lefta, ["&&"];
|
||||
`Nona , ["=="; "!="; "<="; "<"; ">="; ">"];
|
||||
`Lefta, ["+" ; "-"];
|
||||
`Lefta, ["*" ; "/"; "%"];
|
||||
|]
|
||||
)
|
||||
primary);
|
||||
|
||||
primary:
|
||||
n:DECIMAL {Const n}
|
||||
| x:IDENT {Var x}
|
||||
| -"(" parse -")"
|
||||
parse: empty {failwith "Not yet implemented"}
|
||||
)
|
||||
|
||||
end
|
||||
|
|
@ -130,13 +111,7 @@ module Stmt =
|
|||
|
||||
(* Statement parser *)
|
||||
ostap (
|
||||
parse:
|
||||
s:stmt ";" ss:parse {Seq (s, ss)}
|
||||
| stmt;
|
||||
stmt:
|
||||
"read" "(" x:IDENT ")" {Read x}
|
||||
| "write" "(" e:!(Expr.parse) ")" {Write e}
|
||||
| x:IDENT ":=" e:!(Expr.parse) {Assign (x, e)}
|
||||
parse: empty {failwith "Not yet implemented"}
|
||||
)
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue