Skip to content

Commit

Permalink
Json dumping functions for debugging (#848)
Browse files Browse the repository at this point in the history
  • Loading branch information
elegios authored Aug 21, 2024
1 parent 0ff1478 commit 178f216
Show file tree
Hide file tree
Showing 8 changed files with 864 additions and 158 deletions.
38 changes: 32 additions & 6 deletions src/boot/lib/mexpr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -467,12 +467,38 @@ let getData = function
(idDeclRecLets, fis, [len], tys, tms, strs, [], [], [], [], [], [])
| PTreeTop (TopCon (Con (fi, str, ty))) ->
(idDeclConDef, [fi], [], [ty], [], [str], [], [], [], [], [], [])
| PTreeTop (TopUtest (Utest (fi, tm1, tm2, tmUsing, _))) -> (
match tmUsing with
| Some tm ->
(idDeclUtest, [fi], [1], [], [tm1; tm2; tm], [], [], [], [], [], [], [])
| _ ->
(idDeclUtest, [fi], [0], [], [tm1; tm2], [], [], [], [], [], [], []) )
| PTreeTop (TopUtest (Utest (fi, tm1, tm2, tmUsing, tmOnFail))) -> (
match (tmUsing, tmOnFail) with
| None, None ->
(idDeclUtest, [fi], [2], [], [tm1; tm2], [], [], [], [], [], [], [])
| Some tmUsing, None ->
( idDeclUtest
, [fi]
, [3]
, []
, [tm1; tm2; tmUsing]
, []
, []
, []
, []
, []
, []
, [] )
| Some tmUsing, Some tmOnFail ->
( idDeclUtest
, [fi]
, [4]
, []
, [tm1; tm2; tmUsing; tmOnFail]
, []
, []
, []
, []
, []
, []
, [] )
| _, _ ->
failwith "bootparser getData undefined" )
| PTreeTop (TopExt (Ext (fi, str, effect, ty))) ->
( idDeclExt
, [fi]
Expand Down
2 changes: 1 addition & 1 deletion stdlib/json.mc
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ recursive let json2string: JsonValue -> String = lam value.
concat acc "\\b"
else if eqi cval 12 then
concat acc "\\f"
else if or (lti cval 20) (eqi cval 127) then
else if or (lti cval 32) (eqi cval 127) then
let tohex: Int -> Char = lam x.
if lti x 10 then
int2char (addi x (char2int '0'))
Expand Down
22 changes: 11 additions & 11 deletions stdlib/mexpr/ast.mc
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ type PatName
con PName : Name -> PatName
con PWildcard : () -> PatName

lang NamedPat = MatchAst
lang NamedPat = Ast
syn Pat =
| PatNamed {ident : PatName,
info : Info,
Expand All @@ -1018,7 +1018,7 @@ lang NamedPat = MatchAst
| PatNamed r -> PatNamed {r with ty = ty}
end

lang SeqTotPat = MatchAst
lang SeqTotPat = Ast
syn Pat =
| PatSeqTot {pats : [Pat],
info : Info,
Expand All @@ -1043,7 +1043,7 @@ lang SeqTotPat = MatchAst
else never
end

lang SeqEdgePat = MatchAst
lang SeqEdgePat = Ast
syn Pat =
| PatSeqEdge {prefix : [Pat],
middle: PatName,
Expand Down Expand Up @@ -1072,7 +1072,7 @@ lang SeqEdgePat = MatchAst
else never
end

lang RecordPat = MatchAst
lang RecordPat = Ast
syn Pat =
| PatRecord {bindings : Map SID Pat,
info: Info,
Expand All @@ -1097,7 +1097,7 @@ lang RecordPat = MatchAst
else never
end

lang DataPat = MatchAst + DataAst
lang DataPat = Ast + DataAst
syn Pat =
| PatCon {ident : Name,
subpat : Pat,
Expand All @@ -1123,7 +1123,7 @@ lang DataPat = MatchAst + DataAst
else never
end

lang IntPat = MatchAst + IntAst
lang IntPat = Ast + IntAst
syn Pat =
| PatInt {val : Int,
info : Info,
Expand All @@ -1142,7 +1142,7 @@ lang IntPat = MatchAst + IntAst
| PatInt r -> PatInt {r with ty = ty}
end

lang CharPat = MatchAst
lang CharPat = Ast
syn Pat =
| PatChar {val : Char,
info : Info,
Expand All @@ -1161,7 +1161,7 @@ lang CharPat = MatchAst
| PatChar r -> PatChar {r with ty = ty}
end

lang BoolPat = MatchAst + BoolAst
lang BoolPat = Ast + BoolAst
syn Pat =
| PatBool {val : Bool,
info : Info,
Expand All @@ -1180,7 +1180,7 @@ lang BoolPat = MatchAst + BoolAst
| PatBool r -> PatBool {r with ty = ty}
end

lang AndPat = MatchAst
lang AndPat = Ast
syn Pat =
| PatAnd {lpat : Pat,
rpat : Pat,
Expand Down Expand Up @@ -1208,7 +1208,7 @@ lang AndPat = MatchAst
else never
end

lang OrPat = MatchAst
lang OrPat = Ast
syn Pat =
| PatOr {lpat : Pat,
rpat : Pat,
Expand Down Expand Up @@ -1236,7 +1236,7 @@ lang OrPat = MatchAst
else never
end

lang NotPat = MatchAst
lang NotPat = Ast
syn Pat =
| PatNot {subpat : Pat,
info : Info,
Expand Down
Loading

0 comments on commit 178f216

Please sign in to comment.