Commit 2721cfeaea2bdcf41b056351d38063cc760d9966

Authored by Salvador Abreu
1 parent 26ed8fd4
Exists in master

constraints now produce some output

Showing 2 changed files with 9 additions and 53 deletions   Show diff stats
fz/paccs/output.pl
@@ -29,19 +29,21 @@ cg_vars(OP, [V|Vs], ST) --> cg_var(OP, V, ST), cg_vars(OP, Vs, ST). @@ -29,19 +29,21 @@ cg_vars(OP, [V|Vs], ST) --> cg_var(OP, V, ST), cg_vars(OP, Vs, ST).
29 cg_vars(_OP, [], _) --> []. 29 cg_vars(_OP, [], _) --> [].
30 30
31 cg_var(OP, var(N,int,I,A), ST) --> 31 cg_var(OP, var(N,int,I,A), ST) -->
  32 + { ! },
32 cg_var(OP, var(N,int(1,999),I,A), ST). % FIXME 33 cg_var(OP, var(N,int(1,999),I,A), ST). % FIXME
33 34
  35 +
34 cg_var(decl, var(N,int(LB,UB),_I,_A), _ST) --> 36 cg_var(decl, var(N,int(LB,UB),_I,_A), _ST) -->
35 { format_to_codes(S, " fd_int ~w = fd_new(~d, ~d);\n", [N, LB, UB]) }, 37 { format_to_codes(S, " fd_int ~w = fd_new(~d, ~d);\n", [N, LB, UB]) },
36 S. 38 S.
37 39
38 -cg_var(init, var(_,int(_,_),_,_), _) --> []. 40 +cg_var(init, var(_,int(_,_),_,_), _ST) --> [].
39 41
40 cg_var(decl, val(N,int,lit(INIT,_),_), _) --> 42 cg_var(decl, val(N,int,lit(INIT,_),_), _) -->
41 { format_to_codes(S, " const int ~w = ~w;\n", [N, INIT]) }, 43 { format_to_codes(S, " const int ~w = ~w;\n", [N, INIT]) },
42 S. 44 S.
43 45
44 -cg_var(init, val(_,int,_,_), _) --> []. 46 +cg_var(init, val(_,int,_,_), _ST) --> [].
45 47
46 % -- array of variables - - - - - - - - - - - - - - - - - - - - - - - - - - - - 48 % -- array of variables - - - - - - - - - - - - - - - - - - - - - - - - - - - -
47 49
@@ -88,10 +90,13 @@ cg_constrs(CS, ST) --> cg_coverage(CS, CR, ST), cg_constrs(CR, ST). @@ -88,10 +90,13 @@ cg_constrs(CS, ST) --> cg_coverage(CS, CR, ST), cg_constrs(CR, ST).
88 % ++ cg_coverage(CI, CO, ST) [DCG] - - - - - - - - - - - - - - - - - - - - - - 90 % ++ cg_coverage(CI, CO, ST) [DCG] - - - - - - - - - - - - - - - - - - - - - -
89 % 91 %
90 % emit an instruction which partly covers CI, leaving CO untreated 92 % emit an instruction which partly covers CI, leaving CO untreated
  93 +% FIXME: for now this just puts out comments
91 94
92 -cg_coverage([_C|CS], CS, _ST) --> []. % FIXME: temporary 95 +cg_coverage([], [], _ST) --> [].
  96 +cg_coverage([C|CS], [C|CX], ST) -->
  97 + { format_to_codes(S, "// ~w\n", [C]) }, S,
  98 + cg_coverage(CS, CX, ST).
93 99
94 -% cg_coverage(CI, CO, ST) --> [].  
95 100
96 % -- goal --------------------------------------------------------------------- 101 % -- goal ---------------------------------------------------------------------
97 102
fz/typescript
@@ -1,49 +0,0 @@ @@ -1,49 +0,0 @@
1 -Script started on Tue 23 Jun 2015 10:50:19 AM JST  
2 -spa@khawasaki:~/work/src/paccs/fzn-parser$ ./  , ./fznslurp examples/a.fzn > examples/ /a.ast  
3 -| ?-  
4 -spa@khawasaki:~/work/src/paccs/fzn-parser$ ./fznslurp examples/a.fzn > examples/ /a.ast wasaki:~/work/src/paccs/fzn-parser$ ./fznslurp examples/a.fzn > examples/a.ast  
5 - spa@khawasaki:~/work/src/paccs/fzn-parser$ ./  
6 -examples/ fznslurp fzp  
7 -spa@khawasaki:~/work/src/paccs/fzn-parser$ ./ examples/a.fzn > examples/a.ast f examples/a.fzn > examples/a.ast pa@khawasaki:~/work/src/paccs/fzn-parser$ ./fz examples/a.fzn > examples/a.ast pa@khawasaki:~/work/src/paccs/fzn-parser$ ./fzp examples/a.fzn > examples/a.ast a@khawasaki:~/work/src/paccs/fzn-parser$ ./fzp  
8 -  
9 -spa@khawasaki:~/work/src/paccs/fzn-parser$ ./fznslurp  
10 -GNU Prolog 1.3.0  
11 -By Daniel Diaz  
12 -Copyright (C) 1999-2007 Daniel Diaz  
13 -| ?- slurp(e 'examples/a.f ast'< , X)('examples/a.ast', X).  
14 -  
15 -X = [satisfy,[],constrs([constraint(int_lin_ne,(_,array(_),int):(id('X_INTRODUCED_0'),alit((_,_):(id(wa),id(nt))),lit(0)),[])]),vars([var(nt,int(1,3),[],[_:id(output_var)]),var(wa,int(1,3),[],[_:id(output_var)]),var('X_INTRODUCED_0',array(int,1,2),array(_):alit((int,int):(lit(1),lit(-1))),[])]),preds([])]  
16 -  
17 -yes  
18 -| ?- slurp('examples/a.ast', X)._X).X). , member(Y X, _X)(X, _X).  
19 -  
20 -X = satisfy ? ;  
21 -  
22 -X = [] ? ;  
23 -  
24 -X = constrs([constraint(int_lin_ne,(_,array(_),int):(id('X_INTRODUCED_0'),alit((_,_):(id(wa),id(nt))),lit(0)),[])]) ? ;  
25 -  
26 -X = vars([var(nt,int(1,3),[],[_:id(output_var)]),var(wa,int(1,3),[],[_:id(output_var)]),var('X_INTRODUCED_0',array(int,1,2),array(_):alit((int,int):(lit(1),lit(-1))),[])]) ? ;  
27 -  
28 -X = preds([]) ? ;  
29 -  
30 -no  
31 -| ?- slurp('examples/a.ast', _X), member(X, _X).X, _X). _, _X)., _X). v, _X).a, _X).r, _X).s, _X).(, _X)._, _X).Y, _X).), _X).(_Y), _X). , member(_ Y, _Y)(Y, _Y).  
32 -  
33 -Y = var(nt,int(1,3),[],[_:id(output_var)]) ? ;  
34 -  
35 -Y = var(wa,int(1,3),[],[_:id(output_var)]) ? ;  
36 -  
37 -Y = var('X_INTRODUCED_0',array(int,1,2),array(_):alit((int,int):(lit(1),lit(-1))),[]) ? ;  
38 -  
39 -no  
40 -| ?- slurp('examples/a.ast', _X), member(vars(_Y), _X), member(Y, _Y).(_Y), _X), member(Y, _Y). (_Y), _X), member(Y, _Y). (_Y), _X), member(Y, _Y). (_Y), _X), member(Y, _Y). c(_Y), _X), member(Y, _Y).o(_Y), _X), member(Y, _Y).n(_Y), _X), member(Y, _Y).s(_Y), _X), member(Y, _Y).t(_Y), _X), member(Y, _Y).r(_Y), _X), member(Y, _Y).e(_Y), _X), member(Y, _Y).(_Y), _X), member(Y, _Y). s(_Y), _X), member(Y, _Y).(_Y), _X), member(Y, _Y).  
41 -  
42 -Y = constraint(int_lin_ne,(_,array(_),int):(id('X_INTRODUCED_0'),alit((_,_):(id(wa),id(nt))),lit(0)),[]) ? ;  
43 -  
44 -no  
45 -| ?-  
46 -  
47 -spa@khawasaki:~/work/src/paccs/fzn-parser$ exit  
48 -  
49 -Script done on Tue 23 Jun 2015 10:52:37 AM JST