Skip to content

Commit 18efa29

Browse files
committed
---
yaml --- r: 670 b: refs/heads/master c: 3350b17 h: refs/heads/master v: v3
1 parent 982fa73 commit 18efa29

File tree

2 files changed

+146
-1
lines changed

2 files changed

+146
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 77beffc889effe6f77248568a684d8b942610c85
2+
refs/heads/master: 3350b17c60eec98264c62c3e12893d5ca8e00e7d

trunk/src/boot/fe/ast.ml

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,151 @@ and fmt_expr (ff:Format.formatter) (e:expr) : unit =
906906
end
907907
| EXPR_atom a -> fmt_atom ff a
908908

909+
and fmt_mutability (ff:Format.formatter) (mut:mutability) : unit =
910+
if mut = MUT_mutable then fmt ff "mutable "
911+
912+
and fmt_pexp (ff:Format.formatter) (pexp:pexp) : unit =
913+
match pexp.node with
914+
PEXP_call (fn, args) ->
915+
fmt_pexp ff fn;
916+
fmt_bracketed_arr_sep "(" ")" "," fmt_pexp ff args
917+
918+
| PEXP_spawn (dom, name, call) ->
919+
fmt_domain ff dom;
920+
fmt_str ff ("\"" ^ name ^ "\"");
921+
fmt_pexp ff call
922+
923+
| PEXP_bind (fn, arg_opts) ->
924+
fmt_pexp ff fn;
925+
let fmt_opt ff opt =
926+
match opt with
927+
None -> fmt ff "_"
928+
| Some p -> fmt_pexp ff p
929+
in
930+
fmt_bracketed_arr_sep "(" ")" "," fmt_opt ff arg_opts
931+
932+
| PEXP_rec (elts, base) ->
933+
fmt ff "rec(";
934+
let fmt_elt ff (ident, mut, pexp) =
935+
fmt_mutability ff mut;
936+
fmt_ident ff ident;
937+
fmt ff " = ";
938+
fmt_pexp ff pexp;
939+
in
940+
fmt_arr_sep "," fmt_elt ff elts;
941+
begin
942+
match base with
943+
None -> ()
944+
| Some b ->
945+
fmt ff " with ";
946+
fmt_pexp ff b
947+
end;
948+
fmt ff ")"
949+
950+
| PEXP_tup elts ->
951+
fmt ff "tup";
952+
let fmt_elt ff (mut, pexp) =
953+
fmt_mutability ff mut;
954+
fmt_pexp ff pexp
955+
in
956+
fmt_bracketed_arr_sep "(" ")" "," fmt_elt ff elts
957+
958+
| PEXP_vec (mut, elts) ->
959+
fmt ff "vec";
960+
if mut = MUT_mutable then fmt ff "[mutable]";
961+
fmt_bracketed_arr_sep "(" ")" "," fmt_pexp ff elts
962+
963+
| PEXP_port ->
964+
fmt ff "port()"
965+
966+
| PEXP_chan None ->
967+
fmt ff "chan()"
968+
969+
| PEXP_chan (Some pexp) ->
970+
fmt ff "chan";
971+
fmt_bracketed "(" ")" fmt_pexp ff pexp
972+
973+
| PEXP_binop (binop, a, b) ->
974+
fmt_pexp ff a;
975+
fmt ff " ";
976+
fmt_binop ff binop;
977+
fmt ff " ";
978+
fmt_pexp ff b;
979+
980+
| PEXP_lazy_and (a, b) ->
981+
fmt_pexp ff a;
982+
fmt ff " && ";
983+
fmt_pexp ff b
984+
985+
| PEXP_lazy_or (a, b) ->
986+
fmt_pexp ff a;
987+
fmt ff " || ";
988+
fmt_pexp ff b
989+
990+
| PEXP_unop (unop, pexp) ->
991+
begin
992+
match unop with
993+
UNOP_not ->
994+
fmt ff "!";
995+
fmt_pexp ff pexp
996+
997+
| UNOP_bitnot ->
998+
fmt ff "~";
999+
fmt_pexp ff pexp
1000+
1001+
| UNOP_neg ->
1002+
fmt ff "-";
1003+
fmt_pexp ff pexp
1004+
1005+
| UNOP_cast t ->
1006+
fmt_pexp ff pexp;
1007+
fmt ff " as ";
1008+
fmt_ty ff t.node
1009+
end
1010+
1011+
| PEXP_lval plval ->
1012+
fmt_plval ff plval
1013+
1014+
| PEXP_lit lit ->
1015+
fmt_lit ff lit
1016+
1017+
| PEXP_str str -> fmt_str ff str
1018+
1019+
| PEXP_box (mut, pexp) ->
1020+
fmt_mutability ff mut;
1021+
fmt ff "@";
1022+
fmt_pexp ff pexp
1023+
1024+
| PEXP_custom (name, args, txt) ->
1025+
fmt ff "#";
1026+
fmt_name ff name;
1027+
fmt_bracketed_arr_sep "(" ")" "," fmt_pexp ff args;
1028+
match txt with
1029+
None -> ()
1030+
| Some t -> fmt ff "{%s}" t
1031+
1032+
1033+
and fmt_plval (ff:Format.formatter) (plval:plval) : unit =
1034+
match plval with
1035+
PLVAL_ident id -> fmt_ident ff id
1036+
| PLVAL_app (id, tys) ->
1037+
fmt_ident ff id;
1038+
fmt_bracketed_arr_sep "[" "]" "," fmt_ty ff tys
1039+
1040+
| PLVAL_ext_name (pexp, nc) ->
1041+
fmt_pexp ff pexp;
1042+
fmt ff ".";
1043+
fmt_name_component ff nc
1044+
1045+
| PLVAL_ext_pexp (pexp, ext) ->
1046+
fmt_pexp ff pexp;
1047+
fmt_bracketed ".(" ")" fmt_pexp ff ext
1048+
1049+
| PLVAL_ext_deref pexp ->
1050+
fmt ff "*";
1051+
fmt_pexp ff pexp
1052+
1053+
9091054
and fmt_mach (ff:Format.formatter) (m:ty_mach) : unit =
9101055
match m with
9111056
TY_u8 -> fmt ff "u8"

0 commit comments

Comments
 (0)