Commit 26ed8fd46e249032d8f5ae2ac522dcc227f5d3fe

Authored by Salvador Abreu
1 parent 034c6d49
Exists in master

arrays

Showing 1 changed file with 6 additions and 3 deletions   Show diff stats
fz/semantic.pl
@@ -35,6 +35,7 @@ sa_n_traverse(N, NN, ST) :- sa_n(N, NN, ST). % non-list case @@ -35,6 +35,7 @@ sa_n_traverse(N, NN, ST) :- sa_n(N, NN, ST). % non-list case
35 % 35 %
36 % handle all AST cases: 36 % handle all AST cases:
37 % var(N,T,I,A) - Name, Type, Initializer, Attrib -- variable declaration 37 % var(N,T,I,A) - Name, Type, Initializer, Attrib -- variable declaration
  38 +% val(N,T,I,A) - Name, Type, Initializer, Attrib -- (constant) value
38 % lit(V,T) - Value, Type -- literal with type 39 % lit(V,T) - Value, Type -- literal with type
39 % id(N) - Name -- identifier 40 % id(N) - Name -- identifier
40 % constraint(C,A) - Constraint, Attrib -- constraint 41 % constraint(C,A) - Constraint, Attrib -- constraint
@@ -47,10 +48,11 @@ sa_n(var(N,T,[],A), V, ST) :- !, @@ -47,10 +48,11 @@ sa_n(var(N,T,[],A), V, ST) :- !,
47 V=var(N,T,[],AX), % new AST node becomes ST entry value 48 V=var(N,T,[],AX), % new AST node becomes ST entry value
48 st_insert(ST, N, V). 49 st_insert(ST, N, V).
49 50
50 -sa_n(var(N,_T,I,_A), NI, ST) :- % non-empty initializer 51 +sa_n(var(N,T,I,A), V, ST) :- % non-empty initializer
51 sa_n_traverse(I, NI, ST), % parse initializer (& ignore T and A), 52 sa_n_traverse(I, NI, ST), % parse initializer (& ignore T and A),
52 - V=NI, % -- just NI, not var(N,T,NI,AX) --  
53 - st_insert(ST, N, V). % which becomes the ST entry value 53 + sa_attribs(A, AX, ST),
  54 + V=val(N,T,I,AX), % -- not var(N,T,NI,AX) --
  55 + st_insert(ST, N, V). % and it becomes the ST entry value
54 56
55 57
56 sa_n(lit(E,array(T)), lit(NE, array(T)), ST) :- 58 sa_n(lit(E,array(T)), lit(NE, array(T)), ST) :-
@@ -98,6 +100,7 @@ sa_t_traverse(N, ST) :- sa_t(N, ST). % non-list case @@ -98,6 +100,7 @@ sa_t_traverse(N, ST) :- sa_t(N, ST). % non-list case
98 % -- sa_t(NODE, ST) ----------------------------------------------------------- 100 % -- sa_t(NODE, ST) -----------------------------------------------------------
99 101
100 sa_t(var(_N,T,I,_A), _ST) :- type(I,T). 102 sa_t(var(_N,T,I,_A), _ST) :- type(I,T).
  103 +sa_t(val(_N,T,I,_A), _ST) :- type(I,T).
101 sa_t(lit(E,T), _ST) :- type(lit(E,T), T). 104 sa_t(lit(E,T), _ST) :- type(lit(E,T), T).
102 sa_t(constraint(CE, _AT), ST) :- 105 sa_t(constraint(CE, _AT), ST) :-
103 CE=..[_|AS], 106 CE=..[_|AS],