/* ***************************************************************** * * * SB-Prolog * * Copyright SUNY at Stony Brook, 1986 * * * ****************************************************************** */ /*----------------------------------------------------------------- SB-Prolog is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. No author or distributor accepts responsibility to anyone for the consequences of using it or for whether it serves any particular purpose or works at all, unless he says so in writing. Refer to the SB-Prolog General Public License for full details. Everyone is granted permission to copy, modify and redistribute SB-Prolog, but only under the conditions described in the SB-Prolog General Public License. A copy of this license is supposed to have been given to you along with SB-Prolog so you can know your rights and responsibilities. It should be in a file named COPYING. Among other things, the copyright notice and this notice must be preserved on all copies. ------------------------------------------------------------------ */ /* This Prolog program is a first attempt to take an input Prolog program in a simple syntax, relatively close to standard Prolog, and to output an annotated term, with pragmas attached, so that the pilgen translator can generate correct intermediate code. The input clauses will be read (using Prolog's read command) one at a time from standard input (for now), until end-of-file is reached. During the translation of a clause, a Symbol Table (St) is constructed. It contains information on each occurrence of a variable in the clause, as follows. It is a record st(Clist,Vlist); where Clist is the list of records c(Litno,Npars,Pragma) where Litno is the number of the literal on the rhs of the rule, Npars is the number of arguments to that literal, and Pragma is the pragma associated with the _call record for that literal in the clause; Vlist is a list of records, v(id,Occlist), one for each variable; where id the unique identifier for the variable, and Occlist is a list of occurrence records, o(Occno,Litno,Argno,Context,Pragma), one for each occurrence of the variable in the clause; where Occno uniquely determines the occurrence of this variable; Litno is the number of the literal (0=head, 1=first on rhs,...); Argno is the number of the argument in which it appears (starting with 1) Context is `s' if it is in a structure and `t' if it is at the top level; and Pragma is the list that is the Pragma for the occurrence of the variable in the code. */ $compile_export([$compile/0,$compile/1,$compile/2,$compile/3,$compile/4]). $compile_use($name,[$name/2,_]). $compile_use($blist,[$append/3,$member/2,$member1/2]). $compile_use($bio,[$writename/1,$writeqname/1,$put/1,$nl/0,$tab/1,$tell/1, $telling/1,$told/0,$get/1,$get0/1,$see/1,$seeing/1,$seen/0]). $compile_use($bmeta,[$atom/1,$atomic/1,$integer/1,$number/1,$structure/1, $functor0/2,$bldstr/3,$arg/3,$arity/2,$real/1,$floor/2]). $compile_use($prag,[$get_prag/2]). $compile_use($osys,[$cputime/1,_,_,_]). $compile_use($compare,['$=='/2,_,_,_,_,_,_]). /* ********************************************************************** $compile_use($aux1,[$roundtosq/2,$get_compiletime/2,$message1/1, $output_msg/3,$umsg/1,$name_aslfile/2,_,_,_]). $compile_use($translate1,[$translateasm/3,$translate/3]). ********************************************************************** */ $compile :- $writename('compile: Usage: compile( [,, [,