aboutsummaryrefslogtreecommitdiff
path: root/src/relooper/test6.cpp
blob: c292e79c0e83228aa3267a41aa2c78a2ed0c0c8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "Relooper.h"

int main() {
  char buffer[10000];
  rl_set_output_buffer(buffer, sizeof(buffer));

  void *r = rl_new_relooper();

  void *b0 = rl_new_block("//0", "the_var");
  rl_relooper_add_block(r, b0);
  void *b1 = rl_new_block("//1", "the_var");
  rl_relooper_add_block(r, b1);
  void *b2 = rl_new_block("//2", "the_var");
  rl_relooper_add_block(r, b2);
  void *b3 = rl_new_block("//3", "the_var");
  rl_relooper_add_block(r, b3);

  rl_block_add_branch_to(b0, b1, "check(0)", NULL);
  rl_block_add_branch_to(b0, b3, NULL, NULL);
  rl_block_add_branch_to(b1, b2, "check(1)", NULL);
  rl_block_add_branch_to(b1, b3, NULL, NULL);
  rl_block_add_branch_to(b2, b3, NULL, NULL);

  rl_relooper_calculate(r, b0);
  rl_relooper_render(r);
  rl_delete_relooper(r);

  puts(buffer);
}