home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 3
/
FREEWARE.BIN
/
towns_os
/
quasar
/
classic.qsr
next >
Wrap
Text File
|
1980-01-02
|
6KB
|
355 lines
%%%%%%%%%%%%%%%%%%%%%%%%%%%-*-PROLOG-*-%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% classic.qsr %
% %
% --- QuasarProlog --- %
% Portable Extended Prolog Interpreter %
% %
% Copyright (C) 1987, 1988, 1989, 1990 %
% 硴崎 賢一 %
% All rights reserved. %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% '$system_library'('$Header: classic.qsr,v 0.36 90/09/21 02:33:22 ken Locked $').
/***************************************************************/
:- provide(classic).
%%%
%%% DEC-10 PROLOG およびそれに準拠した処理系用に記述されたプログラムを
%%% Quasar Prolog で実行するための互換パッケージ。
%%% 新しくプログラムを記述する場合には、この互換パッケージを
%%% 使用しないことを推奨する。
%%%
%% 変数名の記録を中断し、不必要なメモリの消費を抑制する。
:- reader(variable, off).
%%%
%%% オペレータの優先順位の定義
%%%
:- operator(=.., xfx, 700).
:- operator(is, xfx, 700).
op(Precedence, Type, Op) :-
operator(Op, Type, Precedence).
:- predicate(op, 3, system).
current_op(Precedence, Type, Op) :-
current_operator(Op, Type, Precedence).
:- predicate(current_op, 3, system).
%%%
%%% 算術演算述語
%%%
%% ?Value is +Exp
Result is [Char] :-
!,
'$is_char'(Result, Char).
Result is Exp :-
Result := Exp.
:- predicate(is, 2, system).
'$is_char'(Char, Char) :-
integerp(Char),
!.
'$is_char'(Result, Char) :-
characterp(Char),
!,
char_int(Char, Result).
:- predicate('$is_char', 2, system).
%%%
%%% データ型判定述語
%%%
%% integer(+?Term)
integer(Int) :- integerp(Int).
:- predicate(integer, 1, system).
%% var(+?Term)
var(Var) :- unboundp(Var).
:- predicate(var, 1, system).
%% nonvar(+?Term)
nonvar(Var) :- boundp(Var).
:- predicate(nonvar, 1, system).
%%%
%%% 入力述語
%%%
%% get0(-Char)
get0(C) :-
read_char(Char),
char_int(Char, C).
:- predicate(get0, 1, system).
%% ttyget0(-Char)
ttyget0(C) :-
read_char(Char, user_input),
char_int(Char, C).
:- predicate(ttyget0, 1, system).
%% get(-Char)
get(C) :-
read_char(Char),
char_int(Char, CC),
current_input(Stream),
'$get'(CC, C, Stream).
:- predicate(get, 1, system).
%% ttyget(-Char)
ttyget(C) :-
read_char(Char, user_input),
char_int(Char, CC),
'$get'(CC, C, user_input).
:- predicate(ttyget, 1, system).
'$get'(CC, C, Stream) :-
'$white_char'(CC),
read_char(NewChar, Stream),
char_int(NewChar, NewCC),
!,
'$get'(NewCC, C, Stream).
'$get'(C, C, _).
:- predicate('$get', 3, system).
'$white_char'(Code) :-
Code =< 32.
:- predicate('$white_char', 1, system).
%% skip(+Char)
skip(C) :-
CC is C, % 算術式を受け付けるため
read_char(Char),
char_int(Char, CC),
!.
skip(C) :-
skip(C).
:- predicate(skip, 1, system).
%% ttyskip(+Char)
ttyskip(C) :-
CC is C, % 算術式を受け付けるため
read_char(Char, user_input),
char_int(Char, CC),
!.
ttyskip(C) :-
ttyskip(C).
:- predicate(ttyskip, 1, system).
%%%
%%% 出力述語
%%%
%% tab(+Num)
tab(N) :-
NN is N, % 算術式を受け付けるため
'$spaces'(NN).
:- predicate(tab, 1, system).
%% ttytab(+Num)
ttytab(N) :-
NN is N, % 算術式を受け付けるため
'$spaces'(NN, user_output).
:- predicate(ttytab, 1, system).
%% put(+Char)
put(C) :-
CC is C, % 算術式を受け付けるため
char_int(Char, CC),
write_char(Char).
:- predicate(put, 1, system).
%% ttyput(+Char)
ttyput(C) :-
CC is C, % 算術式を受け付けるため
char_int(Char, CC),
write_char(Char, user_output).
:- predicate(ttyput, 1, system).
%% nl
nl :-
write_char(#\NewLine).
:- predicate(nl, 0, system).
%% ttynl
ttynl :-
write_char(#\NewLine, user_output).
:- predicate(ttynl, 0, system).
%% ttyflush
ttyflush :-
force_output(user_output).
:- predicate(ttyflush, 0, system).
%%%
%%% ファイル操作述語
%%%
%% exists(+File)
exists(File) :-
porobe_file(File).
:- predicate(exists, 1, system).
%% rename(+Old, +New)
rename(_, New) :-
unboundp(New),
!,
fail.
rename(Old, []) :-
!,
delete_file(Old).
rename(Old, New) :-
rename_file(Old, New).
:- predicate(rename, 2, system).
%%%
%%% データ型変換
%%%
%% name(?Atom, ?List)
name(Obj, List) :-
unboundp(Obj),
number_chars(Obj, List),
!.
name(Obj, List) :-
numberp(Obj),
!,
number_chars(Obj, List).
name(Obj, List) :-
symbol_chars(Obj, List).
:- predicate(name, 2, system).
%% ?Structure =.. ?List
Structure =.. List :-
structure_list(Structure, List).
:- predicate(=.., 2, system).
%%%
%%%
%%%
current_atom(Atom) :-
current_symbol(Atom).
:- predicate(current_atom, 1, system).
current_functor(Atom, Functor) :-
current_structure(Atom, Functor).
:- predicate(current_functor, 2, system).
%%%
%%%
%%%
%% statistics
statistics :-
room,
'$times'.
:- predicate(statistics, 0, system).
%% statistics(+Area, -Info)
statistics(X, Y) :-
room(X, Y).
:- predicate(statistics, 2, system).
%%%
%%% ファイル読み込み時の述語名変換
%%%
macro_body(pl, Goal, CGoal) :-
!,
classic_macro(Goal, CGoal).
classic_macro(atom(X), symbolp(X)).
classic_macro(atomic(X), atom(X)).
classic_macro(integer(X), integerp(X)).
classic_macro(var(X), unboundp(X)).
classic_macro(nonvar(X), boundp(X)).
classic_macro(=..(X, Y), structure_list(X, Y)).
classic_macro(current_atom(X), current_symbol(X)).
classic_macro(current_functor(X, Y), current_structure(X, Y)).
classic_macro(op(Prec, Type, Op), operator(Op, Type, Prec)).
classic_macro(current_op(Prec, Type, Op), current_operator(Op, Type, Prec)).
classic_macro(nl, terpri).
classic_macro(exists(File), porobe_file(File)).
classic_macro(delete(File), delete_file(File)).
:- reader(variable, on).
/* End of classic.qsr */