summaryrefslogtreecommitdiff
path: root/test/trans.d/case/cond7_ocaml.rl
diff options
context:
space:
mode:
Diffstat (limited to 'test/trans.d/case/cond7_ocaml.rl')
-rw-r--r--test/trans.d/case/cond7_ocaml.rl64
1 files changed, 64 insertions, 0 deletions
diff --git a/test/trans.d/case/cond7_ocaml.rl b/test/trans.d/case/cond7_ocaml.rl
new file mode 100644
index 00000000..e559fdec
--- /dev/null
+++ b/test/trans.d/case/cond7_ocaml.rl
@@ -0,0 +1,64 @@
+(*
+ * @LANG: ocaml
+ * @GENERATED: true
+ *)
+
+let i = ref 0
+let c = ref 0
+
+%%{
+ machine foo;
+
+ action testi {i .contents > 0}
+ action inc {i := i .contents - 1;
+c := ( fc )
+;
+print_string( "item: " );
+print_int( c.contents );
+print_string( "\n" );
+}
+
+ count = [0-9] @{i := ( fc - 48 )
+;
+print_string( "count: " );
+print_int( i.contents );
+print_string( "\n" );
+};
+
+ sub =
+ count # record the number of digits
+ ( digit when testi @inc )* outwhen !testi;
+
+ main := sub sub '\n';
+}%%
+
+
+
+
+%% write data;
+
+let exec data =
+ let buffer = String.create(1024) in
+ let blen :int ref = ref 0 in
+ let cs = ref 0 in
+ let p = ref 0 in
+ let pe = ref (String.length data) in
+ %% write init;
+ %% write exec;
+ if !cs >= foo_first_final then
+ print_string "ACCEPT\n"
+ else
+ print_string "FAIL\n"
+;;
+
+let () =
+ exec "00\n";
+ exec "019\n";
+ exec "190\n";
+ exec "1719\n";
+ exec "1040000\n";
+ exec "104000a\n";
+ exec "104000\n";
+ ()
+;;
+