Commit f1a115f5a78a4b5fe8000baeb0880c386338141d
1 parent
cf618079
Exists in
master
a litte progress on name analysis
Showing
1 changed file
with
17 additions
and
2 deletions
Show diff stats
fzn-parser/semantic.pl
... | ... | @@ -8,17 +8,23 @@ sa_names(fzn(preds(IP), vars(IV), constrs(IC), SOLVE), |
8 | 8 | |
9 | 9 | % ----------------------------------------------------------------------------- |
10 | 10 | |
11 | -sa_n_traverse([], [], _ST). | |
11 | +sa_n_traverse([], [], _ST) :- !. | |
12 | 12 | sa_n_traverse([N|Ns], [NN|NNs], ST) :- |
13 | 13 | sa_n(N, NN, ST), !, |
14 | 14 | sa_n_traverse(Ns, NNs, ST). |
15 | -sa_n_traverse([_|Ns], NNs, ST) :- % ignore failing nodes (beware!) | |
15 | +sa_n_traverse([_|Ns], NNs, ST) :- !, % ignore failing nodes (beware!) | |
16 | 16 | sa_n_traverse(Ns, NNs, ST). |
17 | 17 | |
18 | +sa_n_traverse(N, NN, ST) :- sa_n(N, NN, ST). % non-list case | |
18 | 19 | |
19 | 20 | % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
20 | 21 | % |
21 | 22 | % sa_n(AST_N_IN, AST_N_OUT, ST) |
23 | +% | |
24 | +% handle all AST cases: | |
25 | +% var(N,T,I,A) - variable declaration | |
26 | +% lit(V,T) - literal with type | |
27 | +% | |
22 | 28 | |
23 | 29 | sa_n(var(N,T,I,A), V, ST) :- |
24 | 30 | sa_attribs(A, AX, ST), |
... | ... | @@ -26,6 +32,15 @@ sa_n(var(N,T,I,A), V, ST) :- |
26 | 32 | V=var(N,T,NI,AX), % new AST node becomes ST entry value |
27 | 33 | st_insert(ST, N, V). |
28 | 34 | |
35 | +sa_n(lit(E,array(T)), lit(NE, array(T)), ST) :- | |
36 | + sa_n_traverse(E, NE, ST). | |
37 | +sa_n(lit(E,int), lit(E,int), _ST). | |
38 | +sa_n(lit(E,float), lit(E,float), _ST). | |
39 | +sa_n(lit(E,string), lit(E,string), _ST). | |
40 | + | |
41 | +sa_n(id(N), V, ST) :- st_lookup(ST, N, V), !. | |
42 | +sa_n(id(N), V, ST) :- V=id(N,_), % type as yet unknown | |
43 | + st_insert(ST, N, V). | |
29 | 44 | |
30 | 45 | % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
31 | 46 | ... | ... |