%.inst.h: gen_inst$(EXE) instruction.txt
./gen_inst$(EXE) -$> < instruction.txt > $@
+%.tag.h: gen_inst$(EXE) instruction.txt
+ ./gen_inst$(EXE) -$> < tag.txt > $@
+
%.pat.h: gen_inst$(EXE) instruction.txt
./gen_inst$(EXE) -pat $> < instruction.txt > $@
sprintf "| %s -> %s" pat body
end;
+ begin "-tag", fun {opcode; name; args} ->
+ let pat =
+ make_pat name args in
+ let body =
+ sprintf "(0x%x,[%s])"
+ opcode
+ (call_args "byte" args) in
+ sprintf "| %s -> %s" pat body
+ end;
+
begin "-compile",fun {name;args}->
let pat =
make_pat name args in
sprintf "(%s)" @@ concat_mapi "," (sprintf "arg_%s ctx _%d") args in
sprintf "| %s -> `%s %s" pat name args'
end;
+
begin "-pat",fun {name; args} ->
let pat =
make_pat name args in
sprintf "| %s -> [%s]" pat @@
call_args Sys.argv.(2) args
end;
+
begin "-extra",fun {name; args;extra} ->
let pat =
make_pat name args in
--- /dev/null
+End(0x00)
+ShowFrame(0x01)
+SetBackgroundColor of color(0x09)
+
+++ /dev/null
-open Base
-
-type t = [
- `End
-| `SetBackgroundColor of int * int * int
-| `ShowFrame
-]
-let to_base = function
- `End ->
- (0,[])
- | `ShowFrame ->
- (1,[])
- | `SetBackgroundColor(r,g,b) ->
- (9,[`RGB(r,g,b)])
--- /dev/null
+open Base
+
+type color= {r:int; g:int; b:int}
+let byte_color {r;g;b} = `RGB(r,g,b)
+
+type t = [
+#include "type.tag.h"
+]
+
+let to_base = function
+#include "tag.tag.h"
open TagOut
let ok x y =
- assert_equal x @@ to_base y
+ assert_equal ~printer:Std.dump x @@ to_base y
let _ = begin "tagOut.ml" >::: [
"End" >:: begin fun () ->
ok (0,[]) `End
end;
"SetBackgroundColor" >:: begin fun () ->
- ok (9,[`RGB(0,1,2)]) (`SetBackgroundColor (0,1,2))
+ ok (9,[`RGB(0,1,2)]) @@ `SetBackgroundColor {r=0; g=1; b=2}
end
] end +> run_test_tt_main
-
-