Skip to content
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions spectec/src/backend-ast/print.ml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ and exp e =
| CatE (e1, e2) -> Node ("cat", [exp e1; exp e2])
| CvtE (e1, nt1, nt2) -> Node ("cvt", [numtyp nt1; numtyp nt2; exp e1])
| SubE (e1, t1, t2) -> Node ("sub", [typ t1; typ t2; exp e1])
| AnnE (e1, t1) -> Node ("ann", [typ t1; exp e1])

and expfield (at, e) =
Node ("field", [mixop (Mixop.Atom at); exp e])
Expand Down
4 changes: 2 additions & 2 deletions spectec/src/frontend/det.ml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ and det_exp e =
(* We consider arithmetic expressions determinate,
* since we sometimes need to use invertible formulas. *)
| CvtE (e1, _, _) | UnE (#Xl.Num.unop, _, e1) | TheE e1 | LiftE e1
| SubE (e1, _, _) -> det_exp e1
| SubE (e1, _, _) | AnnE (e1, _) -> det_exp e1
| BinE (#Xl.Num.binop, _, e1, e2) | CatE (e1, e2) -> det_exp e1 ++ det_exp e2
| OptE eo -> free_opt det_exp eo
| ListE es | TupE es -> det_list det_exp es
Expand Down Expand Up @@ -123,7 +123,7 @@ and det_quant_exp e =
| VarE x -> bound_varid x
| BoolE _ | NumE _ | TextE _ -> empty
| UnE (_, _, e1) | ProjE (e1, _) | TheE e1 | LiftE e1 | LenE e1
| CvtE (e1, _, _) | SubE (e1, _, _) ->
| CvtE (e1, _, _) | SubE (e1, _, _) | AnnE (e1, _) ->
det_quant_exp e1
| BinE (_, _, e1, e2) | CmpE (_, _, e1, e2)
| IdxE (e1, e2) | MemE (e1, e2) | CatE (e1, e2) | CompE (e1, e2) ->
Expand Down
7 changes: 7 additions & 0 deletions spectec/src/frontend/dim.ml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ and check_exp dims ctx e =
check_exp dims ctx e1;
check_typ dims ctx t1;
check_typ dims ctx t2
| AnnE (e1, t1) ->
check_exp dims ctx e1;
check_typ dims ctx t1

and check_expfield dims ctx (_, e) =
check_exp dims ctx e
Expand Down Expand Up @@ -575,6 +578,10 @@ and annot_exp side dims e : exp * occur =
let t1', occur2 = annot_typ dims t1 in
let t2', occur3 = annot_typ dims t2 in
SubE (e1', t1', t2'), union occur1 (union occur2 occur3)
| AnnE (e1, t1) ->
let e1', occur1 = annot_exp side dims e1 in
let t1', occur2 = annot_typ dims t1 in
AnnE (e1', t1'), union occur1 occur2
in {e with it}, occur

and annot_expfield side dims (atom, e) : expfield * occur =
Expand Down
1 change: 1 addition & 0 deletions spectec/src/il/ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ and exp' =
| IterE of exp * iterexp (* exp iter *)
| CvtE of exp * numtyp * numtyp (* exp : typ1 <:> typ2 *)
| SubE of exp * typ * typ (* exp : typ1 <: typ2 *)
| AnnE of exp * typ (* exp : typ *)

and expfield = atom * exp (* atom exp *)

Expand Down
2 changes: 2 additions & 0 deletions spectec/src/il/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
(libraries util zarith xl el)
(modules ast eq free fresh subst iter env eval print debug valid)
)

(env (dev (flags :standard -w -8-26-27-32-33-34)))
1 change: 1 addition & 0 deletions spectec/src/il/eval.ml
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ and reduce_exp env e : exp =
{e1' with note = e.note}
| _ -> SubE (e1', t1', t2') $> e
)
| AnnE (e1, _) -> reduce_exp env e1 (* FIXME(zilinc) *)

and reduce_iter env = function
| ListN (e, ido) -> ListN (reduce_exp env e, ido)
Expand Down
1 change: 1 addition & 0 deletions spectec/src/il/free.ml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ and free_exp e =
| IterE (e1, ite) -> (free_exp e1 -- bound_iterexp ite) ++ free_iterexp ite
| CvtE (e1, _nt1, _nt2) -> free_exp e1
| SubE (e1, t1, t2) -> free_exp e1 ++ free_typ t1 ++ free_typ t2
| AnnE (e1, t1) -> free_exp e1 ++ free_typ t1

and free_expfield (_, e) = free_exp e

Expand Down
1 change: 1 addition & 0 deletions spectec/src/il/iter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ and exp e =
| IterE (e1, it) -> iterexp exp e1 it
| CvtE (e1, nt1, nt2) -> exp e1; numtyp nt1; numtyp nt2
| SubE (e1, t1, t2) -> exp e1; typ t1; typ t2
| AnnE (e1, t1) -> exp e1; typ t1

and expfield (at, e) = atom at; exp e

Expand Down
1 change: 1 addition & 0 deletions spectec/src/il/print.ml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ and string_of_exp e =
"(" ^ string_of_exp e1 ^ " : " ^ string_of_numtyp nt1 ^ " <:> " ^ string_of_numtyp nt2 ^ ")"
| SubE (e1, t1, t2) ->
"(" ^ string_of_exp e1 ^ " : " ^ string_of_typ t1 ^ " <: " ^ string_of_typ t2 ^ ")"
| AnnE (e1, t1) -> "(" ^ string_of_exp e1 ^ " : " ^ string_of_typ t1 ^ ")"
) ^
(if !print_notes then ")@[" ^ string_of_typ e.note ^ "]" else "")

Expand Down
1 change: 1 addition & 0 deletions spectec/src/il/subst.ml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ and subst_exp s e =
CaseE (op, subst_exp s e1)
| CvtE (e1, nt1, nt2) -> CvtE (subst_exp s e1, nt1, nt2)
| SubE (e1, t1, t2) -> SubE (subst_exp s e1, subst_typ s t1, subst_typ s t2)
| AnnE (e1, t1) -> AnnE (subst_exp s e1, subst_typ s t1)
) $$ e.at % subst_typ s e.note

and subst_expfield s (atom, e) = (atom, subst_exp s e)
Expand Down
Loading
Loading