Blame view

fz/types.pl 912 Bytes
0b83a7f1   Salvador Abreu   First stab at sem...
1
2
% == No, Emacs this is -*-Prolog-*- code, not what you thought... =============

57421ab2   Salvador Abreu   first stab at typ...
3
4
5
% -- type(NODE, TYPE) ---------------------------------------------------------
%
% type/2: Extract type from AST node.
0b83a7f1   Salvador Abreu   First stab at sem...
6

57421ab2   Salvador Abreu   first stab at typ...
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
type(var(_,T,_,_), T) :- type(T).
type(lit(_,T),     T) :- type(T).
type(id(_,T),      T) :- type(T).

type(lit(E,array(T)), array(T)) :- type(E, T).
type(lit(_,T), T) :- type(T).

type([], _).
type([E|Es], T) :- type(E, T), type(Es, T).

% -- type(TYPE) ---------------------------------------------------------------
%
% type/1: generate or test valid types.

type(int).			% integer
type(int(_L,_U)).		% integer interval
type(float).			% floating point
type(float(_L,_U)).		% floating point interval
type(string).			% string
type(array(T,1,_U)) :- type(T).	% array of type
65f52800   Salvador Abreu   paccs output prog...
27
28
29
30
31
32
33
34
35

% bound(lb,T,LB)
% bound(ub,T,UB)

bound(lb,int(LB,_UB),LB).
bound(lb,int,1).

bound(ub,int(_LB,UB),UB).
bound(ub,int,999).		% FIXME