Rename _buffer to buffer, expand tabs to spaces in src/ and tests/ and move up BUFFER_SIZE macro definition

This commit is contained in:
Benjamin Loison 2023-01-03 22:58:38 +01:00
parent 5cabb042fc
commit 69e84f0a8e
5 changed files with 15 additions and 16 deletions

View File

@ -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)

View File

@ -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\

View File

@ -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

View File

@ -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)

View File

@ -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);