Refactoring of the AST.
This commit is contained in:
parent
aa117ecfc2
commit
abbebbf0f6
126
AST.ml
126
AST.ml
@ -155,9 +155,9 @@ type t = {
|
|||||||
and ast = t
|
and ast = t
|
||||||
|
|
||||||
and declaration =
|
and declaration =
|
||||||
TypeDecl of type_decl reg
|
TypeDecl of type_decl reg
|
||||||
| ConstDecl of const_decl reg
|
| ConstDecl of const_decl reg
|
||||||
| LambdaDecl of lambda_decl
|
| LambdaDecl of lambda_decl
|
||||||
|
|
||||||
and const_decl = {
|
and const_decl = {
|
||||||
kwd_const : kwd_const;
|
kwd_const : kwd_const;
|
||||||
@ -180,11 +180,11 @@ and type_decl = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
and type_expr =
|
and type_expr =
|
||||||
Prod of cartesian
|
TProd of cartesian
|
||||||
| Sum of (variant reg, vbar) nsepseq reg
|
| TSum of (variant reg, vbar) nsepseq reg
|
||||||
| Record of record_type reg
|
| TRecord of record_type reg
|
||||||
| TypeApp of (type_name * type_tuple) reg
|
| TApp of (type_name * type_tuple) reg
|
||||||
| ParType of type_expr par reg
|
| TPar of type_expr par reg
|
||||||
| TAlias of variable
|
| TAlias of variable
|
||||||
|
|
||||||
and cartesian = (type_expr, times) nsepseq reg
|
and cartesian = (type_expr, times) nsepseq reg
|
||||||
@ -443,20 +443,20 @@ and for_collect = {
|
|||||||
(* Expressions *)
|
(* Expressions *)
|
||||||
|
|
||||||
and expr =
|
and expr =
|
||||||
LogicExpr of logic_expr
|
ELogic of logic_expr
|
||||||
| ArithExpr of arith_expr
|
| EArith of arith_expr
|
||||||
| StringExpr of string_expr
|
| EString of string_expr
|
||||||
| ListExpr of list_expr
|
| EList of list_expr
|
||||||
| SetExpr of set_expr
|
| ESet of set_expr
|
||||||
| ConstrExpr of constr_expr
|
| EConstr of constr_expr
|
||||||
| RecordExpr of record_expr
|
| ERecord of record_expr
|
||||||
| MapExpr of map_expr
|
| EMap of map_expr
|
||||||
| Var of Lexer.lexeme reg
|
| EVar of Lexer.lexeme reg
|
||||||
| FunCall of fun_call
|
| ECall of fun_call
|
||||||
| Bytes of (Lexer.lexeme * Hex.t) reg
|
| EBytes of (Lexer.lexeme * Hex.t) reg
|
||||||
| Unit of c_Unit
|
| EUnit of c_Unit
|
||||||
| Tuple of tuple
|
| ETuple of tuple
|
||||||
| ParExpr of expr par reg
|
| EPar of expr par reg
|
||||||
|
|
||||||
and map_expr =
|
and map_expr =
|
||||||
MapLookUp of map_lookup reg
|
MapLookUp of map_lookup reg
|
||||||
@ -609,28 +609,28 @@ and list_pattern =
|
|||||||
open! Region
|
open! Region
|
||||||
|
|
||||||
let type_expr_to_region = function
|
let type_expr_to_region = function
|
||||||
Prod {region; _}
|
TProd {region; _}
|
||||||
| Sum {region; _}
|
| TSum {region; _}
|
||||||
| Record {region; _}
|
| TRecord {region; _}
|
||||||
| TypeApp {region; _}
|
| TApp {region; _}
|
||||||
| ParType {region; _}
|
| TPar {region; _}
|
||||||
| TAlias {region; _} -> region
|
| TAlias {region; _} -> region
|
||||||
|
|
||||||
let rec expr_to_region = function
|
let rec expr_to_region = function
|
||||||
LogicExpr e -> logic_expr_to_region e
|
ELogic e -> logic_expr_to_region e
|
||||||
| ArithExpr e -> arith_expr_to_region e
|
| EArith e -> arith_expr_to_region e
|
||||||
| StringExpr e -> string_expr_to_region e
|
| EString e -> string_expr_to_region e
|
||||||
| ListExpr e -> list_expr_to_region e
|
| EList e -> list_expr_to_region e
|
||||||
| SetExpr e -> set_expr_to_region e
|
| ESet e -> set_expr_to_region e
|
||||||
| ConstrExpr e -> constr_expr_to_region e
|
| EConstr e -> constr_expr_to_region e
|
||||||
| RecordExpr e -> record_expr_to_region e
|
| ERecord e -> record_expr_to_region e
|
||||||
| MapExpr e -> map_expr_to_region e
|
| EMap e -> map_expr_to_region e
|
||||||
| Var {region; _}
|
| EVar {region; _}
|
||||||
| FunCall {region; _}
|
| ECall {region; _}
|
||||||
| Bytes {region; _}
|
| EBytes {region; _}
|
||||||
| Unit region
|
| EUnit region
|
||||||
| Tuple {region; _}
|
| ETuple {region; _}
|
||||||
| ParExpr {region; _} -> region
|
| EPar {region; _} -> region
|
||||||
|
|
||||||
and map_expr_to_region = function
|
and map_expr_to_region = function
|
||||||
MapLookUp {region; _}
|
MapLookUp {region; _}
|
||||||
@ -788,9 +788,9 @@ let rec print_tokens ast =
|
|||||||
print_token eof "EOF"
|
print_token eof "EOF"
|
||||||
|
|
||||||
and print_decl = function
|
and print_decl = function
|
||||||
TypeDecl decl -> print_type_decl decl
|
TypeDecl decl -> print_type_decl decl
|
||||||
| ConstDecl decl -> print_const_decl decl
|
| ConstDecl decl -> print_const_decl decl
|
||||||
| LambdaDecl decl -> print_lambda_decl decl
|
| LambdaDecl decl -> print_lambda_decl decl
|
||||||
|
|
||||||
and print_const_decl {value; _} =
|
and print_const_decl {value; _} =
|
||||||
let {kwd_const; name; colon; const_type;
|
let {kwd_const; name; colon; const_type;
|
||||||
@ -813,11 +813,11 @@ and print_type_decl {value; _} =
|
|||||||
print_terminator terminator
|
print_terminator terminator
|
||||||
|
|
||||||
and print_type_expr = function
|
and print_type_expr = function
|
||||||
Prod cartesian -> print_cartesian cartesian
|
TProd cartesian -> print_cartesian cartesian
|
||||||
| Sum sum_type -> print_sum_type sum_type
|
| TSum sum_type -> print_sum_type sum_type
|
||||||
| Record record_type -> print_record_type record_type
|
| TRecord record_type -> print_record_type record_type
|
||||||
| TypeApp type_app -> print_type_app type_app
|
| TApp type_app -> print_type_app type_app
|
||||||
| ParType par_type -> print_par_type par_type
|
| TPar par_type -> print_par_type par_type
|
||||||
| TAlias type_alias -> print_var type_alias
|
| TAlias type_alias -> print_var type_alias
|
||||||
|
|
||||||
and print_cartesian {value; _} =
|
and print_cartesian {value; _} =
|
||||||
@ -1106,20 +1106,20 @@ and print_bind_to = function
|
|||||||
| None -> ()
|
| None -> ()
|
||||||
|
|
||||||
and print_expr = function
|
and print_expr = function
|
||||||
LogicExpr e -> print_logic_expr e
|
ELogic e -> print_logic_expr e
|
||||||
| ArithExpr e -> print_arith_expr e
|
| EArith e -> print_arith_expr e
|
||||||
| StringExpr e -> print_string_expr e
|
| EString e -> print_string_expr e
|
||||||
| ListExpr e -> print_list_expr e
|
| EList e -> print_list_expr e
|
||||||
| SetExpr e -> print_set_expr e
|
| ESet e -> print_set_expr e
|
||||||
| ConstrExpr e -> print_constr_expr e
|
| EConstr e -> print_constr_expr e
|
||||||
| RecordExpr e -> print_record_expr e
|
| ERecord e -> print_record_expr e
|
||||||
| MapExpr e -> print_map_expr e
|
| EMap e -> print_map_expr e
|
||||||
| Var var -> print_var var
|
| EVar v -> print_var v
|
||||||
| FunCall e -> print_fun_call e
|
| ECall e -> print_fun_call e
|
||||||
| Bytes b -> print_bytes b
|
| EBytes b -> print_bytes b
|
||||||
| Unit region -> print_token region "Unit"
|
| EUnit r -> print_token r "Unit"
|
||||||
| Tuple e -> print_tuple e
|
| ETuple e -> print_tuple e
|
||||||
| ParExpr e -> print_par_expr e
|
| EPar e -> print_par_expr e
|
||||||
|
|
||||||
and print_map_expr = function
|
and print_map_expr = function
|
||||||
MapLookUp {value; _} -> print_map_lookup value
|
MapLookUp {value; _} -> print_map_lookup value
|
||||||
|
44
AST.mli
44
AST.mli
@ -139,9 +139,9 @@ type t = {
|
|||||||
and ast = t
|
and ast = t
|
||||||
|
|
||||||
and declaration =
|
and declaration =
|
||||||
TypeDecl of type_decl reg
|
TypeDecl of type_decl reg
|
||||||
| ConstDecl of const_decl reg
|
| ConstDecl of const_decl reg
|
||||||
| LambdaDecl of lambda_decl
|
| LambdaDecl of lambda_decl
|
||||||
|
|
||||||
and const_decl = {
|
and const_decl = {
|
||||||
kwd_const : kwd_const;
|
kwd_const : kwd_const;
|
||||||
@ -164,11 +164,11 @@ and type_decl = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
and type_expr =
|
and type_expr =
|
||||||
Prod of cartesian
|
TProd of cartesian
|
||||||
| Sum of (variant reg, vbar) nsepseq reg
|
| TSum of (variant reg, vbar) nsepseq reg
|
||||||
| Record of record_type reg
|
| TRecord of record_type reg
|
||||||
| TypeApp of (type_name * type_tuple) reg
|
| TApp of (type_name * type_tuple) reg
|
||||||
| ParType of type_expr par reg
|
| TPar of type_expr par reg
|
||||||
| TAlias of variable
|
| TAlias of variable
|
||||||
|
|
||||||
and cartesian = (type_expr, times) nsepseq reg
|
and cartesian = (type_expr, times) nsepseq reg
|
||||||
@ -427,20 +427,20 @@ and for_collect = {
|
|||||||
(* Expressions *)
|
(* Expressions *)
|
||||||
|
|
||||||
and expr =
|
and expr =
|
||||||
LogicExpr of logic_expr
|
ELogic of logic_expr
|
||||||
| ArithExpr of arith_expr
|
| EArith of arith_expr
|
||||||
| StringExpr of string_expr
|
| EString of string_expr
|
||||||
| ListExpr of list_expr
|
| EList of list_expr
|
||||||
| SetExpr of set_expr
|
| ESet of set_expr
|
||||||
| ConstrExpr of constr_expr
|
| EConstr of constr_expr
|
||||||
| RecordExpr of record_expr
|
| ERecord of record_expr
|
||||||
| MapExpr of map_expr
|
| EMap of map_expr
|
||||||
| Var of Lexer.lexeme reg
|
| EVar of Lexer.lexeme reg
|
||||||
| FunCall of fun_call
|
| ECall of fun_call
|
||||||
| Bytes of (Lexer.lexeme * Hex.t) reg
|
| EBytes of (Lexer.lexeme * Hex.t) reg
|
||||||
| Unit of c_Unit
|
| EUnit of c_Unit
|
||||||
| Tuple of tuple
|
| ETuple of tuple
|
||||||
| ParExpr of expr par reg
|
| EPar of expr par reg
|
||||||
|
|
||||||
and map_expr =
|
and map_expr =
|
||||||
MapLookUp of map_lookup reg
|
MapLookUp of map_lookup reg
|
||||||
|
92
Parser.mly
92
Parser.mly
@ -157,9 +157,9 @@ type_decl:
|
|||||||
in {region; value}}
|
in {region; value}}
|
||||||
|
|
||||||
type_expr:
|
type_expr:
|
||||||
cartesian { Prod $1 }
|
cartesian { TProd $1 }
|
||||||
| sum_type { Sum $1 }
|
| sum_type { TSum $1 }
|
||||||
| record_type { Record $1 }
|
| record_type { TRecord $1 }
|
||||||
|
|
||||||
cartesian:
|
cartesian:
|
||||||
nsepseq(core_type,TIMES) {
|
nsepseq(core_type,TIMES) {
|
||||||
@ -173,15 +173,15 @@ core_type:
|
|||||||
}
|
}
|
||||||
| type_name type_tuple {
|
| type_name type_tuple {
|
||||||
let region = cover $1.region $2.region
|
let region = cover $1.region $2.region
|
||||||
in TypeApp {region; value = $1,$2}
|
in TApp {region; value = $1,$2}
|
||||||
}
|
}
|
||||||
| Map type_tuple {
|
| Map type_tuple {
|
||||||
let region = cover $1 $2.region in
|
let region = cover $1 $2.region in
|
||||||
let value = {value="map"; region=$1}
|
let value = {value="map"; region=$1}
|
||||||
in TypeApp {region; value = value, $2}
|
in TApp {region; value = value, $2}
|
||||||
}
|
}
|
||||||
| par(type_expr) {
|
| par(type_expr) {
|
||||||
ParType $1
|
TPar $1
|
||||||
}
|
}
|
||||||
|
|
||||||
type_tuple:
|
type_tuple:
|
||||||
@ -377,7 +377,7 @@ unqualified_decl(OP):
|
|||||||
lpar = Region.ghost;
|
lpar = Region.ghost;
|
||||||
inside = value;
|
inside = value;
|
||||||
rpar = Region.ghost} in
|
rpar = Region.ghost} in
|
||||||
ListExpr (EmptyList {region; value})
|
EList (EmptyList {region; value})
|
||||||
| `ENone region ->
|
| `ENone region ->
|
||||||
let value = {
|
let value = {
|
||||||
lpar = Region.ghost;
|
lpar = Region.ghost;
|
||||||
@ -386,9 +386,9 @@ unqualified_decl(OP):
|
|||||||
colon = Region.ghost;
|
colon = Region.ghost;
|
||||||
opt_type = $3};
|
opt_type = $3};
|
||||||
rpar = Region.ghost}
|
rpar = Region.ghost}
|
||||||
in ConstrExpr (NoneExpr {region; value})
|
in EConstr (NoneExpr {region; value})
|
||||||
| `EMap inj ->
|
| `EMap inj ->
|
||||||
MapExpr (MapInj inj)
|
EMap (MapInj inj)
|
||||||
in $1, $2, $3, $4, init, $6, stop
|
in $1, $2, $3, $4, init, $6, stop
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -621,7 +621,7 @@ expr:
|
|||||||
and stop = expr_to_region $3 in
|
and stop = expr_to_region $3 in
|
||||||
let region = cover start stop
|
let region = cover start stop
|
||||||
and value = {arg1 = $1; op = $2; arg2 = $3} in
|
and value = {arg1 = $1; op = $2; arg2 = $3} in
|
||||||
LogicExpr (BoolExpr (Or {region; value}))
|
ELogic (BoolExpr (Or {region; value}))
|
||||||
}
|
}
|
||||||
| conj_expr { $1 }
|
| conj_expr { $1 }
|
||||||
|
|
||||||
@ -630,8 +630,8 @@ conj_expr:
|
|||||||
let start = expr_to_region $1
|
let start = expr_to_region $1
|
||||||
and stop = expr_to_region $3 in
|
and stop = expr_to_region $3 in
|
||||||
let region = cover start stop
|
let region = cover start stop
|
||||||
and value = {arg1 = $1; op = $2; arg2 = $3} in
|
and value = {arg1 = $1; op = $2; arg2 = $3}
|
||||||
LogicExpr (BoolExpr (And {region; value}))
|
in ELogic (BoolExpr (And {region; value}))
|
||||||
}
|
}
|
||||||
| comp_expr { $1 }
|
| comp_expr { $1 }
|
||||||
|
|
||||||
@ -640,43 +640,43 @@ comp_expr:
|
|||||||
let start = expr_to_region $1
|
let start = expr_to_region $1
|
||||||
and stop = expr_to_region $3 in
|
and stop = expr_to_region $3 in
|
||||||
let region = cover start stop
|
let region = cover start stop
|
||||||
and value = {arg1 = $1; op = $2; arg2 = $3} in
|
and value = {arg1 = $1; op = $2; arg2 = $3}
|
||||||
LogicExpr (CompExpr (Lt {region; value}))
|
in ELogic (CompExpr (Lt {region; value}))
|
||||||
}
|
}
|
||||||
| comp_expr LEQ cat_expr {
|
| comp_expr LEQ cat_expr {
|
||||||
let start = expr_to_region $1
|
let start = expr_to_region $1
|
||||||
and stop = expr_to_region $3 in
|
and stop = expr_to_region $3 in
|
||||||
let region = cover start stop
|
let region = cover start stop
|
||||||
and value = {arg1 = $1; op = $2; arg2 = $3}
|
and value = {arg1 = $1; op = $2; arg2 = $3}
|
||||||
in LogicExpr (CompExpr (Leq {region; value}))
|
in ELogic (CompExpr (Leq {region; value}))
|
||||||
}
|
}
|
||||||
| comp_expr GT cat_expr {
|
| comp_expr GT cat_expr {
|
||||||
let start = expr_to_region $1
|
let start = expr_to_region $1
|
||||||
and stop = expr_to_region $3 in
|
and stop = expr_to_region $3 in
|
||||||
let region = cover start stop
|
let region = cover start stop
|
||||||
and value = {arg1 = $1; op = $2; arg2 = $3}
|
and value = {arg1 = $1; op = $2; arg2 = $3}
|
||||||
in LogicExpr (CompExpr (Gt {region; value}))
|
in ELogic (CompExpr (Gt {region; value}))
|
||||||
}
|
}
|
||||||
| comp_expr GEQ cat_expr {
|
| comp_expr GEQ cat_expr {
|
||||||
let start = expr_to_region $1
|
let start = expr_to_region $1
|
||||||
and stop = expr_to_region $3 in
|
and stop = expr_to_region $3 in
|
||||||
let region = cover start stop
|
let region = cover start stop
|
||||||
and value = {arg1 = $1; op = $2; arg2 = $3}
|
and value = {arg1 = $1; op = $2; arg2 = $3}
|
||||||
in LogicExpr (CompExpr (Geq {region; value}))
|
in ELogic (CompExpr (Geq {region; value}))
|
||||||
}
|
}
|
||||||
| comp_expr EQUAL cat_expr {
|
| comp_expr EQUAL cat_expr {
|
||||||
let start = expr_to_region $1
|
let start = expr_to_region $1
|
||||||
and stop = expr_to_region $3 in
|
and stop = expr_to_region $3 in
|
||||||
let region = cover start stop
|
let region = cover start stop
|
||||||
and value = {arg1 = $1; op = $2; arg2 = $3}
|
and value = {arg1 = $1; op = $2; arg2 = $3}
|
||||||
in LogicExpr (CompExpr (Equal {region; value}))
|
in ELogic (CompExpr (Equal {region; value}))
|
||||||
}
|
}
|
||||||
| comp_expr NEQ cat_expr {
|
| comp_expr NEQ cat_expr {
|
||||||
let start = expr_to_region $1
|
let start = expr_to_region $1
|
||||||
and stop = expr_to_region $3 in
|
and stop = expr_to_region $3 in
|
||||||
let region = cover start stop
|
let region = cover start stop
|
||||||
and value = {arg1 = $1; op = $2; arg2 = $3}
|
and value = {arg1 = $1; op = $2; arg2 = $3}
|
||||||
in LogicExpr (CompExpr (Neq {region; value}))
|
in ELogic (CompExpr (Neq {region; value}))
|
||||||
}
|
}
|
||||||
| cat_expr { $1 }
|
| cat_expr { $1 }
|
||||||
|
|
||||||
@ -686,7 +686,7 @@ cat_expr:
|
|||||||
and stop = expr_to_region $3 in
|
and stop = expr_to_region $3 in
|
||||||
let region = cover start stop
|
let region = cover start stop
|
||||||
and value = {arg1 = $1; op = $2; arg2 = $3}
|
and value = {arg1 = $1; op = $2; arg2 = $3}
|
||||||
in StringExpr (Cat {region; value})
|
in EString (Cat {region; value})
|
||||||
}
|
}
|
||||||
| cons_expr { $1 }
|
| cons_expr { $1 }
|
||||||
|
|
||||||
@ -696,7 +696,7 @@ cons_expr:
|
|||||||
and stop = expr_to_region $3 in
|
and stop = expr_to_region $3 in
|
||||||
let region = cover start stop
|
let region = cover start stop
|
||||||
and value = {arg1 = $1; op = $2; arg2 = $3}
|
and value = {arg1 = $1; op = $2; arg2 = $3}
|
||||||
in ListExpr (Cons {region; value})
|
in EList (Cons {region; value})
|
||||||
}
|
}
|
||||||
| add_expr { $1 }
|
| add_expr { $1 }
|
||||||
|
|
||||||
@ -706,14 +706,14 @@ add_expr:
|
|||||||
and stop = expr_to_region $3 in
|
and stop = expr_to_region $3 in
|
||||||
let region = cover start stop
|
let region = cover start stop
|
||||||
and value = {arg1 = $1; op = $2; arg2 = $3}
|
and value = {arg1 = $1; op = $2; arg2 = $3}
|
||||||
in ArithExpr (Add {region; value})
|
in EArith (Add {region; value})
|
||||||
}
|
}
|
||||||
| add_expr MINUS mult_expr {
|
| add_expr MINUS mult_expr {
|
||||||
let start = expr_to_region $1
|
let start = expr_to_region $1
|
||||||
and stop = expr_to_region $3 in
|
and stop = expr_to_region $3 in
|
||||||
let region = cover start stop
|
let region = cover start stop
|
||||||
and value = {arg1 = $1; op = $2; arg2 = $3}
|
and value = {arg1 = $1; op = $2; arg2 = $3}
|
||||||
in ArithExpr (Sub {region; value})
|
in EArith (Sub {region; value})
|
||||||
}
|
}
|
||||||
| mult_expr { $1 }
|
| mult_expr { $1 }
|
||||||
|
|
||||||
@ -723,21 +723,21 @@ mult_expr:
|
|||||||
and stop = expr_to_region $3 in
|
and stop = expr_to_region $3 in
|
||||||
let region = cover start stop
|
let region = cover start stop
|
||||||
and value = {arg1 = $1; op = $2; arg2 = $3}
|
and value = {arg1 = $1; op = $2; arg2 = $3}
|
||||||
in ArithExpr (Mult {region; value})
|
in EArith (Mult {region; value})
|
||||||
}
|
}
|
||||||
| mult_expr SLASH unary_expr {
|
| mult_expr SLASH unary_expr {
|
||||||
let start = expr_to_region $1
|
let start = expr_to_region $1
|
||||||
and stop = expr_to_region $3 in
|
and stop = expr_to_region $3 in
|
||||||
let region = cover start stop
|
let region = cover start stop
|
||||||
and value = {arg1 = $1; op = $2; arg2 = $3}
|
and value = {arg1 = $1; op = $2; arg2 = $3}
|
||||||
in ArithExpr (Div {region; value})
|
in EArith (Div {region; value})
|
||||||
}
|
}
|
||||||
| mult_expr Mod unary_expr {
|
| mult_expr Mod unary_expr {
|
||||||
let start = expr_to_region $1
|
let start = expr_to_region $1
|
||||||
and stop = expr_to_region $3 in
|
and stop = expr_to_region $3 in
|
||||||
let region = cover start stop
|
let region = cover start stop
|
||||||
and value = {arg1 = $1; op = $2; arg2 = $3}
|
and value = {arg1 = $1; op = $2; arg2 = $3}
|
||||||
in ArithExpr (Mod {region; value})
|
in EArith (Mod {region; value})
|
||||||
}
|
}
|
||||||
| unary_expr { $1 }
|
| unary_expr { $1 }
|
||||||
|
|
||||||
@ -746,40 +746,40 @@ unary_expr:
|
|||||||
let stop = expr_to_region $2 in
|
let stop = expr_to_region $2 in
|
||||||
let region = cover $1 stop
|
let region = cover $1 stop
|
||||||
and value = {op = $1; arg = $2}
|
and value = {op = $1; arg = $2}
|
||||||
in ArithExpr (Neg {region; value})
|
in EArith (Neg {region; value})
|
||||||
}
|
}
|
||||||
| Not core_expr {
|
| Not core_expr {
|
||||||
let stop = expr_to_region $2 in
|
let stop = expr_to_region $2 in
|
||||||
let region = cover $1 stop
|
let region = cover $1 stop
|
||||||
and value = {op = $1; arg = $2} in
|
and value = {op = $1; arg = $2} in
|
||||||
LogicExpr (BoolExpr (Not {region; value}))
|
ELogic (BoolExpr (Not {region; value}))
|
||||||
}
|
}
|
||||||
| core_expr { $1 }
|
| core_expr { $1 }
|
||||||
|
|
||||||
core_expr:
|
core_expr:
|
||||||
Int { ArithExpr (Int $1) }
|
Int { EArith (Int $1) }
|
||||||
| var { Var $1 }
|
| var { EVar $1 }
|
||||||
| String { StringExpr (String $1) }
|
| String { EString (String $1) }
|
||||||
| Bytes { Bytes $1 }
|
| Bytes { EBytes $1 }
|
||||||
| C_False { LogicExpr (BoolExpr (False $1)) }
|
| C_False { ELogic (BoolExpr (False $1)) }
|
||||||
| C_True { LogicExpr (BoolExpr (True $1)) }
|
| C_True { ELogic (BoolExpr (True $1)) }
|
||||||
| C_Unit { Unit $1 }
|
| C_Unit { EUnit $1 }
|
||||||
| tuple { Tuple $1 }
|
| tuple { ETuple $1 }
|
||||||
| list_expr { ListExpr (List $1) }
|
| list_expr { EList (List $1) }
|
||||||
| empty_list { ListExpr (EmptyList $1) }
|
| empty_list { EList (EmptyList $1) }
|
||||||
| set_expr { SetExpr (Set $1) }
|
| set_expr { ESet (Set $1) }
|
||||||
| empty_set { SetExpr (EmptySet $1) }
|
| empty_set { ESet (EmptySet $1) }
|
||||||
| none_expr { ConstrExpr (NoneExpr $1) }
|
| none_expr { EConstr (NoneExpr $1) }
|
||||||
| fun_call { FunCall $1 }
|
| fun_call { ECall $1 }
|
||||||
| map_expr { MapExpr $1 }
|
| map_expr { EMap $1 }
|
||||||
| record_expr { RecordExpr $1 }
|
| record_expr { ERecord $1 }
|
||||||
| Constr arguments {
|
| Constr arguments {
|
||||||
let region = cover $1.region $2.region in
|
let region = cover $1.region $2.region in
|
||||||
ConstrExpr (ConstrApp {region; value = $1,$2})
|
EConstr (ConstrApp {region; value = $1,$2})
|
||||||
}
|
}
|
||||||
| C_Some arguments {
|
| C_Some arguments {
|
||||||
let region = cover $1 $2.region in
|
let region = cover $1 $2.region in
|
||||||
ConstrExpr (SomeApp {region; value = $1,$2})
|
EConstr (SomeApp {region; value = $1,$2})
|
||||||
}
|
}
|
||||||
|
|
||||||
map_expr:
|
map_expr:
|
||||||
|
Loading…
Reference in New Issue
Block a user