-
Notifications
You must be signed in to change notification settings - Fork 3
/
prmain.c
88 lines (77 loc) · 2.63 KB
/
prmain.c
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
HEADER: ;
TITLE: Small Prolog;
VERSION: 2.O;
DESCRIPTION: "Interactive Prolog interpreter with lisp-like syntax.
Will run on IBM-PC, Atari ST and Sun-3, and should be very
easy to port to other machines.
Requires sprolog.ini and sprolog.inf on the same directory."
KEYWORDS: Programming language, Prolog.
SYSTEM: MS-DOS v2+, TOS, SUN-OS;
FILENAME: prmain.c;
WARNINGS: Better to compile this with compact or large model on the PC.
SEE-ALSO: pr*.*
AUTHORS: Henri de Feraudy
COMPILERS: Turbo C V1.5, Mark Williams Let's C V4, Quick C
on PC compatibles.
DJ Delorie's GCC386 on 386 based PC compatibles.
Mark Williams C V3.0 for the Atari ST ,
Megamax Laser C on the Atari
cc on the Sun-OS v3.5
gcc on a Sun
*/
/* prmain.c */
/* SPROLOG - a public domain prolog interpreter.
* Design goals: portability, small size, embedability and hopefully
* educational.
* You must add the builtins you need (and remove the ones you don't).
* Input-output has been left to the trivial minimum.
* You are encouraged to modify prsun.c to adapt it to your machine.
* The syntax is LISPish, for reasons of simplicity and small code,
* but this does have the advantage that it encourages meta-programming
* (unlike Turbo-Prolog).
* Very little in the way of space saving techniques have been used (in the
* present version). There is not yet any tail recursion optimisation or
* garbage collection.
*/
#include <stdio.h>
#include "prmachine.h"
#include "prcnsult.h"
#include "prlush.h"
#define CRPLEASE "Press Return"
extern void ini_alloc(), ini_term(), ini_hash(), ini_builtin(), ini_globals();
void init_prolog()/* call this once in your application */
{
/* initialise I-O */
ini_term(); /* in machine dependent file */
/* allocate memory zones */
ini_alloc(); /* in pralloc.c */
/* initialise symbol table */
ini_hash(); /* in prhash.c */
/* make builtin predicates */
ini_builtin(); /* in prbuiltin.c */
/* intialise global variables */
ini_globals(); /* in pralloc.c */
}
int main(int argc,char *argv[])
{
int i;
init_prolog();
pr_string("SMALL PROLOG 2.O \n");
pr_string("by Henri de Feraudy\n");
/* load initial clauses */
load("ini/sprolog.ini"); /* see prconsult.c for load */
/* load files passed as command line arguments */
for(i = 1; i < argc; i++)
{
load(argv[i]);
}
/* execute initial query from file query.ini */
if(initial_query("query.ini"))/* interact with user */
query_loop(); /* in prlush.c */
/* clean up I-O */
exit_term(); /* in machine dependent file */
/* normal exit */
exit(0);
}
/* end of file */