ref: 53b4d27243b9b20a6628aa200299c3b5ac6f173a
parent: 5597ed0a108af923f112a4ca6336071f71bae6bd
author: McKay Marston <[email protected]>
date: Fri Oct 16 05:43:25 EDT 2020
even more progress
--- a/macro.ml
+++ b/macro.ml
@@ -243,6 +243,24 @@
register_variants patterns
;;
+let match_variant macro args =
+ match macro with
+ | T.Map { T.value = meta } ->
+ (match Types.M9map.find Types.macro_variants meta with
+ | T.Map { T.value = variant_list } ->
+ Types.M9map.iter
+ (fun k v ->
+ print_endline (Printer.print k true ^ ": " ^ Printer.print v true);
+ match v with
+ | T.List { T.value = T.List { T.value = x } :: z } -> print_endline (" !!! [" ^ string_of_int (List.length args) ^ "](" ^ string_of_int (List.length x) ^ ") " ^ Printer.dump x ^ " :: " ^ Printer.dump z);
+ if List.length args = List.length x
+ then print_endline "MATCH!"
+ else print_endline "no match"
+ | _ -> ())
+ variant_list
+ | _ -> ())
+ | _ -> ()
+
(* match meta with
* | T.Map { T.value = m } ->
* (try
--- a/reader.ml
+++ b/reader.ml
@@ -73,7 +73,7 @@
| _ -> T.Nil
with
| T.Macro { T.value = sym; meta } ->
- print_endline("FOUND A MACRO! " ^ Printer.print sym true);
+ print_endline("\nFOUND A MACRO! " ^ Printer.print sym true);
print_endline(" tokens: " ^ String.concat " " list_reader.tokens);
let rec collect_args tokens args =
match tokens with
@@ -82,7 +82,8 @@
| _ -> []
in
let args = collect_args (List.tl list_reader.tokens) [] in
- print_endline(" ### " ^ String.concat " " args)
+ print_endline(" ### " ^ String.concat " " args);
+ Macro.match_variant meta args
| _ -> ());
match list_reader.tokens with
| [] -> raise (Utils.Syntax_error ("unterminated '" ^ eol ^ "'"))