Parse scalar expressions with source spans
This commit is contained in:
9 files changed
+363
-12
No files matched your search
@@ -0,0 +1,52 @@
|
||||
type binop =
|
||||
| Add
|
||||
| Sub
|
||||
| Mul
|
||||
| Div
|
||||
| Eq
|
||||
| Ne
|
||||
| Lt
|
||||
| Le
|
||||
| Gt
|
||||
| Ge
|
||||
| And
|
||||
| Or
|
||||
|
||||
type expr = {
|
||||
e : expr_desc;
|
||||
espan : Location.span;
|
||||
}
|
||||
|
||||
and expr_desc =
|
||||
| EInt of int
|
||||
| EBool of bool
|
||||
| EString of string
|
||||
| EUnit
|
||||
| EVar of string
|
||||
| ELet of string * expr * expr
|
||||
| ELambda of string * expr
|
||||
| EApp of expr * expr
|
||||
| EIf of expr * expr * expr
|
||||
| EBinop of binop * expr * expr
|
||||
| ENeg of expr
|
||||
| ETuple of expr list
|
||||
| ERecord of (string * expr) list
|
||||
| EField of expr * string
|
||||
|
||||
let make e espan = { e = e; espan = espan }
|
||||
|
||||
let binop_name = function
|
||||
| Add -> "+"
|
||||
| Sub -> "-"
|
||||
| Mul -> "*"
|
||||
| Div -> "/"
|
||||
| Eq -> "="
|
||||
| Ne -> "<>"
|
||||
| Lt -> "<"
|
||||
| Le -> "<="
|
||||
| Gt -> ">"
|
||||
| Ge -> ">="
|
||||
| And -> "&&"
|
||||
| Or -> "||"
|
||||
|
||||
let string_of_binop = binop_name
|
||||
Reference in new issue
Block a user