diff --git a/src/ast_to_c.ml b/src/ast_to_c.ml index de1a54a..e00bbd1 100644 --- a/src/ast_to_c.ml +++ b/src/ast_to_c.ml @@ -315,7 +315,7 @@ let ast_to_c fmt verbose debug prog = let prog_st_types = make_state_types prog in debug (Format.asprintf "%a" dump_var_locations prog_st_types); let iprog: i_nodelist = ast_to_intermediate_ast prog prog_st_types in - Format.fprintf fmt "%a\n\n%a\n\n%a\n\n/* Nodes: */\n%a%a\n" + Format.fprintf fmt "%a\n\n#define BUFFER_SIZE 1024\n\n%a\n\n%a\n\n/* Nodes: */\n%a%a\n" cp_includes (Config.c_includes) cp_state_types prog_st_types cp_state_frees (iprog, prog_st_types) diff --git a/src/cprint.ml b/src/cprint.ml index 8527b58..96d1a97 100644 --- a/src/cprint.ml +++ b/src/cprint.ml @@ -424,21 +424,20 @@ let cp_main_fn fmt (prog, sts) = | Some node -> Format.fprintf fmt "int main (int argc, char **argv)\n\ {\n%a\n\ - \t#define BUFFER_SIZE 1024\n\ - \tchar _buffer[BUFFER_SIZE];\n\ + \tchar buffer[BUFFER_SIZE];\n\ \tt_state_main state;\n\ \tstate.is_init = true;\n\ \tstate.is_reset = false;\n\ \twhile(true) {\n\ \t\tprintf(\"input: \");\n\ \t\tfor(unsigned short idx = 0; idx < BUFFER_SIZE; idx++) {\n\ - \t\t\tif(idx == (BUFFER_SIZE - 1) || (_buffer[idx] = getchar()) == '\\n') {\n\ - \t\t\t\t_buffer[idx] = '\\0';\n\ + \t\t\tif(idx == (BUFFER_SIZE - 1) || (buffer[idx] = getchar()) == '\\n') {\n\ + \t\t\t\tbuffer[idx] = '\\0';\n\ \t\t\t\tbreak;\n\ \t\t\t}\n\ \t\t}\n\ - \t\tif(!strcmp(_buffer, \"exit\")) { break; }\n\ - \t\tsscanf(_buffer, %a);\n%a\ + \t\tif(!strcmp(buffer, \"exit\")) { break; }\n\ + \t\tsscanf(buffer, %a);\n%a\ \t\tfn_main(&state, %a);\n\ \t\tprintf(\"output: \");\n\ \t\tprintf(%a);\n\ diff --git a/tests/automaton.node b/tests/automaton.node index 03d9db8..e35065b 100644 --- a/tests/automaton.node +++ b/tests/automaton.node @@ -1,21 +1,21 @@ node diagonal_int (i: int) returns (o1, o2 : int); let - (o1, o2) = (i, i); + (o1, o2) = (i, i); tel node undiag_test (i: int) returns (o : bool); var l1, l2: int; l3: int; let - l3 = (pre (1)) -> 0; - (l1, l2) = diagonal_int(i); - o = (not (not (l1 = l2))) and (l1 = l2) and true; + l3 = (pre (1)) -> 0; + (l1, l2) = diagonal_int(i); + o = (not (not (l1 = l2))) and (l1 = l2) and true; tel node auto (i: int) returns (o : int); var x, y:int; let - automaton - | Incr -> do (o,x) = (0 fby o + 1, 2); done - | Decr -> do (o,x) = diagonal_int(0 fby o); done + automaton + | Incr -> do (o,x) = (0 fby o + 1, 2); done + | Decr -> do (o,x) = diagonal_int(0 fby o); done tel diff --git a/tests/counting.node b/tests/counting.node index b226c53..1888787 100644 --- a/tests/counting.node +++ b/tests/counting.node @@ -3,7 +3,7 @@ node counting (tick:bool; top:bool) returns (o: int); var v, o1: int; let o = if tick then v else 0 -> (pre o) + v; - v = if top then 1 else 0 + v = if top then 1 else 0 tel; node main (i: int) diff --git a/tests/tuple.node b/tests/tuple.node index 2a4f0b3..e809c3d 100644 --- a/tests/tuple.node +++ b/tests/tuple.node @@ -1,6 +1,6 @@ node diagonal_int (i: int) returns (o1, o2 : int); let - (o1, o2) = (i, i); + (o1, o2) = (i, i); tel node main (i: int) returns (o1, o2, o3, o4: int);