apt-input.pl
1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*****************************************************************************/
/* */
/* Projecto de Compiladores ---------------------------------- VSPL */
/* Level 0 */
/* */
/* APT construction (from yacc). */
/* */
/* Salvador Pinto Abreu */
/* */
/*****************************************************************************/
:- op(100, xfx, ('==>')).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% APTs are fed as a series of stack operations (Old ==> New), followed
% by an end-of-file.
%
% makeAPT(Term) returns a list of global declarations (hopefully) that
% corresponds to the program just read.
%
makeAPT(T) <-> makeAPT([] ==> [], [], T).
makeAPT(end_of_file, S, S) !.
makeAPT(O ==> C, O, N) <-> makeAPT(X, C, N) <= read(X).
/******************************************************************************/
parser("~/aulas/pc/sspl/0/sspl").
browser("~/X/browser/browser").
type(source, ".s").
type(stack, ".so").
type(as, ".as").
type(object, ".o").
type(apt, ".apt").
type(aptx, ".aptx").
prefix("").
name(N, Type, Name) <->
prefix(P),
name(N, X0),
append(P, X0, X1),
type(Type, T),
append(X1, T, Name).
make(stack,N) <-> name(N, source, S), name(N, stack, SO),
parser(SSPL),
append(SSPL, " <", X0),
append(X0, S, X1),
append(X1, " >", X2),
append(X2, SO, Command),
shell(Command).
load(N) <-> name(N, stack, SO), name(SOFile, SO),
see(SOFile), try makeAPT(X), seen,
( retract(apt(N,_)), fail ; true),
assert(apt(N,X)).
make(apt,N) <-> name(N, apt, A), name(AFile, A),
tell(AFile), apt(N,APT), wr(APT), nl, told.
make(aptx,N) <-> name(N, aptx, A), name(AFile, A),
tell(AFile), aptx(N,APT), wr(APT), nl, told.
restart <-> save('sspl-pl'), write('VSPL Level 0.'), nl.