Commit 567a1567b812d6e6e5ec90bd97cb08cffcae3dce
1 parent
e88c58ae
Exists in
master
now doing output
Showing
1 changed file
with
14 additions
and
10 deletions
Show diff stats
fz/paccs/output.pl
... | ... | @@ -3,16 +3,18 @@ |
3 | 3 | % == Code generation for PaCCS ================================================ |
4 | 4 | |
5 | 5 | cg_emit(fzn(preds(PS), vars(VS), constrs(CS), G), ST) :- |
6 | - cg_prefix(TEXT, PTXT), | |
7 | - cg_preds(PS, ST, PTXT, VTXT1), | |
8 | - cg_vars(decl, VS, ST, VTXT1, VTXT2), | |
9 | - cg_vars(init, VS, ST, VTXT2, CTXT), | |
10 | - %% cg_constrs(CTXT, GTXT, CS, ST), | |
11 | - %% cg_goal(GTXT, STXT, G, VS, ST), | |
12 | - %% cg_suffix(STXT, []), | |
13 | - cg_suffix(CTXT, []), | |
6 | + cg_emit(PS, VS, CS, G, ST, TEXT, []), | |
14 | 7 | format("~s\n", [TEXT]). |
15 | 8 | |
9 | +cg_emit(PS, VS, CS, G, ST) --> | |
10 | + cg_prefix, | |
11 | + cg_preds(PS, ST), | |
12 | + cg_vars(decl, VS, ST), | |
13 | + cg_vars(init, VS, ST), | |
14 | + %% cg_constrs(CS, ST), | |
15 | + cg_goal(G, VS, ST), | |
16 | + cg_suffix. | |
17 | + | |
16 | 18 | % == DCGs for code generation ================================================= |
17 | 19 | |
18 | 20 | % -- predicates --------------------------------------------------------------- |
... | ... | @@ -78,7 +80,7 @@ cg_constr(_C, _ST) --> []. % FIXME: temporary |
78 | 80 | |
79 | 81 | % -- goal --------------------------------------------------------------------- |
80 | 82 | |
81 | -cg_goal(satisfy, VS, ST) --> | |
83 | +cg_goal(solve(satisfy,_), VS, ST) --> | |
82 | 84 | "\n", |
83 | 85 | " if (fd_solve()) {\n", |
84 | 86 | cg_var_print(VS, ST, " "), |
... | ... | @@ -87,7 +89,7 @@ cg_goal(satisfy, VS, ST) --> |
87 | 89 | cg_var_print([], _, _) --> []. |
88 | 90 | cg_var_print([var(N,_,_,A)|Vs], ST, PFX) --> |
89 | 91 | { member(output, A), ! }, |
90 | - { format_to_codes(S, "~sfd_println(~s);\n", [PFX, N]) }, S, | |
92 | + { format_to_codes(S, "~sfd_println(~w);\n", [PFX, N]) }, S, | |
91 | 93 | cg_var_print(Vs, ST, PFX). |
92 | 94 | cg_var_print([_|Vs], ST, PFX) --> cg_var_print(Vs, ST, PFX). |
93 | 95 | |
... | ... | @@ -95,6 +97,8 @@ cg_var_print([_|Vs], ST, PFX) --> cg_var_print(Vs, ST, PFX). |
95 | 97 | % -- prefix and suffix -------------------------------------------------------- |
96 | 98 | |
97 | 99 | cg_prefix --> |
100 | + "#include \"paccs.h\"\n\n", | |
101 | + "main()\n", | |
98 | 102 | "{\n", |
99 | 103 | " int i, j;\n". |
100 | 104 | ... | ... |