print n expands
This commit is contained in:
5
sexpr.ml
5
sexpr.ml
@@ -675,6 +675,8 @@ module SExprMacroExp = struct
|
||||
exception Not_Valid_Macro_Arg_Syntax
|
||||
exception FIXME of SExpr.t
|
||||
|
||||
let num_expands = ref 0;;
|
||||
|
||||
let assoc_all k li =
|
||||
li
|
||||
|> List.find_all (fun (x, _) -> x = k)
|
||||
@@ -824,6 +826,7 @@ module SExprMacroExp = struct
|
||||
and expand_macro args macro ctx =
|
||||
let margs, mbody = macro in
|
||||
let defs = match_macro_arg args margs ctx in
|
||||
num_expands := !num_expands + 1;
|
||||
expand_macro_eval mbody defs
|
||||
and eval_while ctx s = begin
|
||||
let s, ch, ctx = eval ctx s in
|
||||
@@ -938,6 +941,8 @@ let () =
|
||||
let v = SExprMacroExp.sparse src in
|
||||
let v = SExprMacroExp.do_eval v in
|
||||
|
||||
Format.printf "; number of macro expansions: %d\n%!" !SExprMacroExp.num_expands;
|
||||
|
||||
Format.set_margin 40;
|
||||
Format.printf "%a@.@?" SExpr.pp_t v;
|
||||
|
||||
|
Reference in New Issue
Block a user