From 26ed8fd46e249032d8f5ae2ac522dcc227f5d3fe Mon Sep 17 00:00:00 2001 From: Salvador Abreu Date: Wed, 22 Jul 2015 14:51:02 +0900 Subject: [PATCH] arrays --- fz/semantic.pl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fz/semantic.pl b/fz/semantic.pl index a27e4f1..ad3077e 100644 --- a/fz/semantic.pl +++ b/fz/semantic.pl @@ -35,6 +35,7 @@ sa_n_traverse(N, NN, ST) :- sa_n(N, NN, ST). % non-list case % % handle all AST cases: % var(N,T,I,A) - Name, Type, Initializer, Attrib -- variable declaration +% val(N,T,I,A) - Name, Type, Initializer, Attrib -- (constant) value % lit(V,T) - Value, Type -- literal with type % id(N) - Name -- identifier % constraint(C,A) - Constraint, Attrib -- constraint @@ -47,10 +48,11 @@ sa_n(var(N,T,[],A), V, ST) :- !, V=var(N,T,[],AX), % new AST node becomes ST entry value st_insert(ST, N, V). -sa_n(var(N,_T,I,_A), NI, ST) :- % non-empty initializer +sa_n(var(N,T,I,A), V, ST) :- % non-empty initializer sa_n_traverse(I, NI, ST), % parse initializer (& ignore T and A), - V=NI, % -- just NI, not var(N,T,NI,AX) -- - st_insert(ST, N, V). % which becomes the ST entry value + sa_attribs(A, AX, ST), + V=val(N,T,I,AX), % -- not var(N,T,NI,AX) -- + st_insert(ST, N, V). % and it becomes the ST entry value 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 % -- sa_t(NODE, ST) ----------------------------------------------------------- sa_t(var(_N,T,I,_A), _ST) :- type(I,T). +sa_t(val(_N,T,I,_A), _ST) :- type(I,T). sa_t(lit(E,T), _ST) :- type(lit(E,T), T). sa_t(constraint(CE, _AT), ST) :- CE=..[_|AS], -- libgit2 0.21.2