2001-04-09 20:54:03 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* *
|
|
|
|
* YAP Prolog *
|
|
|
|
* *
|
2014-12-24 15:32:29 +00:00
|
|
|
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
2001-04-09 20:54:03 +01:00
|
|
|
* *
|
|
|
|
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
|
|
|
|
* *
|
|
|
|
**************************************************************************
|
|
|
|
* *
|
|
|
|
* File: yio.yap *
|
|
|
|
* Last rev: *
|
|
|
|
* mods: *
|
|
|
|
* comments: Input output predicates *
|
|
|
|
* *
|
|
|
|
*************************************************************************/
|
|
|
|
|
2014-09-11 20:06:57 +01:00
|
|
|
|
|
|
|
|
2014-04-09 12:39:29 +01:00
|
|
|
:- system_module( '$_yio', [at_end_of_line/0,
|
|
|
|
at_end_of_line/1,
|
|
|
|
consult_depth/1,
|
|
|
|
current_char_conversion/2,
|
|
|
|
current_line_number/1,
|
|
|
|
current_line_number/2,
|
|
|
|
current_stream/3,
|
|
|
|
display/1,
|
|
|
|
display/2,
|
|
|
|
exists/1,
|
|
|
|
fileerrors/0,
|
|
|
|
format/1,
|
|
|
|
nofileerrors/0,
|
|
|
|
open_pipe_streams/2,
|
|
|
|
prolog_file_name/2,
|
|
|
|
read/1,
|
|
|
|
read/2,
|
|
|
|
sformat/3,
|
|
|
|
socket/2,
|
|
|
|
socket/4,
|
|
|
|
socket_connect/3,
|
|
|
|
stream_position/2,
|
|
|
|
stream_position/3,
|
|
|
|
stream_position_data/3,
|
|
|
|
ttyget/1,
|
|
|
|
ttyget0/1,
|
|
|
|
ttynl/0,
|
|
|
|
ttyput/1,
|
|
|
|
ttyskip/1,
|
2014-10-05 23:51:43 +01:00
|
|
|
write_depth/2], ['$default_expand'/1,
|
2014-04-09 12:39:29 +01:00
|
|
|
'$extend_file_search_path'/1,
|
|
|
|
'$set_default_expand'/1]).
|
|
|
|
|
|
|
|
:- use_system_module( '$_boot', ['$system_catch'/4]).
|
|
|
|
|
|
|
|
:- use_system_module( '$_errors', ['$do_error'/2]).
|
|
|
|
|
2014-12-24 15:32:29 +00:00
|
|
|
/** @defgroup InputOutput Input/Output Predicates
|
2015-01-04 23:58:23 +00:00
|
|
|
@ingroup builtins
|
2014-12-24 15:32:29 +00:00
|
|
|
|
|
|
|
Some of the Input/Output predicates described below will in certain conditions
|
|
|
|
provide error messages and abort only if the file_errors flag is set.
|
|
|
|
If this flag is cleared the same predicates will just fail. Details on
|
|
|
|
setting and clearing this flag are given under 7.7.
|
|
|
|
|
|
|
|
@{
|
|
|
|
*/
|
|
|
|
|
2001-09-21 18:08:36 +01:00
|
|
|
/* stream predicates */
|
|
|
|
|
2014-09-15 19:10:49 +01:00
|
|
|
/** @defgroup IO_Sockets YAP Old Style Socket and Pipe Interface
|
|
|
|
@ingroup InputOutput
|
|
|
|
@{
|
|
|
|
|
|
|
|
Autoload the socket/pipe library
|
|
|
|
|
|
|
|
*/
|
2014-09-11 20:06:57 +01:00
|
|
|
|
2014-09-15 19:10:49 +01:00
|
|
|
/** @pred socket(+ _DOMAIN_,- _SOCKET_)
|
2014-09-11 20:06:57 +01:00
|
|
|
|
|
|
|
Call socket/4 with _TYPE_ bound to `SOCK_STREAM'` and
|
|
|
|
_PROTOCOL_ bound to `0`.
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
2012-07-26 21:16:26 +01:00
|
|
|
|
2014-09-11 20:06:57 +01:00
|
|
|
/** @pred socket(+ _DOMAIN_,+ _TYPE_,+ _PROTOCOL_,- _SOCKET_)
|
|
|
|
|
|
|
|
Corresponds to the BSD system call `socket`. Create a socket for
|
|
|
|
domain _DOMAIN_ of type _TYPE_ and protocol
|
|
|
|
_PROTOCOL_. Both _DOMAIN_ and _TYPE_ should be atoms,
|
|
|
|
whereas _PROTOCOL_ must be an integer.
|
|
|
|
The new socket object is
|
|
|
|
accessible through a descriptor bound to the variable _SOCKET_.
|
|
|
|
|
|
|
|
The current implementation of YAP accepts socket
|
|
|
|
domains `AF_INET` and `AF_UNIX`.
|
|
|
|
Socket types depend on the
|
|
|
|
underlying operating system, but at least the following types are
|
|
|
|
supported: `SOCK_STREAM'` and `SOCK_DGRAM'` (untested in 6.3).
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
/** @pred socket_connect(+ _SOCKET_, + _PORT_, - _STREAM_)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Interface to system call `connect`, used for clients: connect
|
|
|
|
socket _SOCKET_ to _PORT_. The connection results in the
|
|
|
|
read/write stream _STREAM_.
|
|
|
|
|
|
|
|
Port information depends on the domain:
|
|
|
|
|
|
|
|
+ 'AF_UNIX'(+ _FILENAME_)
|
|
|
|
+ 'AF_FILE'(+ _FILENAME_)
|
|
|
|
connect to socket at file _FILENAME_.
|
|
|
|
|
|
|
|
+ 'AF_INET'(+ _HOST_,+ _PORT_)
|
|
|
|
Connect to socket at host _HOST_ and port _PORT_.
|
|
|
|
*/
|
2012-08-02 15:36:37 +01:00
|
|
|
|
2015-06-19 01:30:13 +01:00
|
|
|
|
2014-09-15 19:10:49 +01:00
|
|
|
/** @pred open_pipe_streams(Read, Write)
|
|
|
|
|
|
|
|
Autoload old pipe access interface
|
|
|
|
|
|
|
|
*/
|
2014-12-24 15:32:29 +00:00
|
|
|
%! @}
|
2014-09-11 20:06:57 +01:00
|
|
|
|
|
|
|
|
2014-09-15 19:10:49 +01:00
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2014-09-11 20:06:57 +01:00
|
|
|
/** @pred exists(+ _F_)
|
|
|
|
|
|
|
|
Checks if file _F_ exists in the current directory.
|
|
|
|
|
|
|
|
*/
|
2011-07-27 16:30:29 +01:00
|
|
|
exists(F) :-
|
|
|
|
absolute_file_name(F, _, [file_errors(fail),access(exist),expand(true)]).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2014-12-24 15:32:29 +00:00
|
|
|
%! @addtogroup ReadTerm
|
2014-09-15 19:10:49 +01:00
|
|
|
% @{
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
/* Term IO */
|
|
|
|
|
2013-11-20 22:30:49 +00:00
|
|
|
|
2014-12-24 15:32:29 +00:00
|
|
|
%! @}
|
2014-09-15 19:10:49 +01:00
|
|
|
|
2014-12-24 15:32:29 +00:00
|
|
|
%! @addtogroup Write
|
2014-09-15 19:10:49 +01:00
|
|
|
% @{
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
/* meaning of flags for '$write' is
|
|
|
|
1 quote illegal atoms
|
|
|
|
2 ignore operator declarations
|
|
|
|
4 output '$VAR'(N) terms as A, B, C, ...
|
|
|
|
8 use portray(_)
|
|
|
|
|
2010-12-13 12:38:37 +00:00
|
|
|
flags are defined in yapio.h
|
|
|
|
*/
|
2001-09-21 18:08:36 +01:00
|
|
|
|
2014-09-11 20:06:57 +01:00
|
|
|
/** @pred display(+ _T_)
|
|
|
|
|
|
|
|
|
|
|
|
Displays term _T_ on the current output stream. All Prolog terms are
|
|
|
|
written in standard parenthesized prefix notation.
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
2011-02-14 20:40:10 +00:00
|
|
|
display(T) :-
|
|
|
|
current_output(Out),
|
|
|
|
write_term(Out, T, [ignore_ops(true)]).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2014-09-11 20:06:57 +01:00
|
|
|
/** @pred display(+ _S_, _T_)
|
|
|
|
|
|
|
|
Like display/1, but using stream _S_ to display the term.
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
2011-02-14 20:40:10 +00:00
|
|
|
display(Stream, T) :-
|
2014-10-07 01:35:41 +01:00
|
|
|
write_term(Stream, T, [ignore_ops(true)]).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
|
|
|
/* interface to user portray */
|
|
|
|
'$portray'(T) :-
|
2001-11-15 00:01:43 +00:00
|
|
|
\+ '$undefined'(portray(_),user),
|
2006-12-13 16:10:26 +00:00
|
|
|
'$system_catch'(call(portray(T)),user,Error,user:'$Error'(Error)), !,
|
2003-08-27 14:37:10 +01:00
|
|
|
set_value('$portray',true), fail.
|
|
|
|
'$portray'(_) :- set_value('$portray',false), fail.
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2014-12-24 15:32:29 +00:00
|
|
|
%! @}
|
2014-09-15 19:10:49 +01:00
|
|
|
|
2014-12-24 15:32:29 +00:00
|
|
|
%! @addtogroup Format
|
2014-09-15 19:10:49 +01:00
|
|
|
% @{
|
|
|
|
|
|
|
|
/** @pred format(+ _T_)
|
|
|
|
|
|
|
|
Print formatted output to the current output stream.
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
format(T) :-
|
|
|
|
format(T, []).
|
|
|
|
|
2014-12-24 15:32:29 +00:00
|
|
|
%! @}
|
2014-09-15 19:10:49 +01:00
|
|
|
|
2014-12-24 15:32:29 +00:00
|
|
|
%! @addtogroup CharsIO
|
2014-09-15 19:10:49 +01:00
|
|
|
% @{
|
|
|
|
|
2001-04-09 20:54:03 +01:00
|
|
|
/* character I/O */
|
|
|
|
|
2014-09-11 20:06:57 +01:00
|
|
|
/** @pred ttyget(- _C_)
|
|
|
|
|
|
|
|
|
|
|
|
The same as `get(C)`, but from stream user_input.
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
2008-03-12 15:37:34 +00:00
|
|
|
ttyget(N) :- get(user_input,N).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2014-09-11 20:06:57 +01:00
|
|
|
/** @pred ttyget0(- _C_)
|
|
|
|
|
|
|
|
|
|
|
|
The same as `get0(C)`, but from stream user_input.
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
2008-03-12 15:37:34 +00:00
|
|
|
ttyget0(N) :- get0(user_input,N).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2014-09-11 20:06:57 +01:00
|
|
|
/** @pred ttyskip(- _C_)
|
|
|
|
|
|
|
|
|
|
|
|
Like skip/1, but always using stream user_input.
|
|
|
|
stream.
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
2001-04-09 20:54:03 +01:00
|
|
|
ttyskip(N) :- N1 is N, '$skip'(user_input,N1).
|
|
|
|
|
2014-09-11 20:06:57 +01:00
|
|
|
/** @pred ttyput(+ _N_)
|
|
|
|
|
|
|
|
|
|
|
|
As `put(N)` but always to user_output.
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
2011-02-14 19:57:22 +00:00
|
|
|
ttyput(N) :- N1 is N, put(user_output,N1).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2014-09-11 20:06:57 +01:00
|
|
|
/** @pred ttynl
|
|
|
|
|
|
|
|
|
|
|
|
Outputs a new line to stream user_output.
|
|
|
|
|
2014-09-15 19:10:49 +01:00
|
|
|
*/
|
|
|
|
ttynl :- nl(user_output).
|
2014-09-11 20:06:57 +01:00
|
|
|
|
2014-12-24 15:32:29 +00:00
|
|
|
%! @}
|
2014-09-11 20:06:57 +01:00
|
|
|
|
2014-12-24 15:32:29 +00:00
|
|
|
%! @addtogroup StreamM
|
2014-09-15 19:10:49 +01:00
|
|
|
% @{
|
2014-09-11 20:06:57 +01:00
|
|
|
|
2014-09-15 19:10:49 +01:00
|
|
|
/** @pred current_line_number(- _LineNumber_)
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2014-09-15 19:10:49 +01:00
|
|
|
Unify _LineNumber_ with the line number for the current output stream.
|
|
|
|
|
|
|
|
*/
|
2001-04-09 20:54:03 +01:00
|
|
|
current_line_number(N) :-
|
2011-02-14 14:59:15 +00:00
|
|
|
current_input(Stream),
|
|
|
|
line_count(Stream, N).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2014-09-11 20:06:57 +01:00
|
|
|
/** @pred current_line_number(+ _Stream_,- _LineNumber_)
|
|
|
|
|
2014-09-15 19:10:49 +01:00
|
|
|
Unify _LineNumber_ with the line number for _Stream_.
|
2014-09-11 20:06:57 +01:00
|
|
|
|
|
|
|
*/
|
2011-02-14 14:59:15 +00:00
|
|
|
current_line_number(Stream,N) :-
|
|
|
|
line_count(Stream, N).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2014-09-11 20:06:57 +01:00
|
|
|
/** @pred stream_position(+ _Stream_,- _StreamPosition_)
|
|
|
|
|
|
|
|
Unify _StreamPosition_ with the packaged information of position on
|
|
|
|
current stream _Stream_. Use stream_position_data/3 to
|
|
|
|
retrieve information on character or line count.
|
|
|
|
|
|
|
|
*/
|
2011-02-14 20:14:31 +00:00
|
|
|
stream_position(Stream, Position) :-
|
|
|
|
stream_property(Stream, position(Position)).
|
2012-08-02 15:36:37 +01:00
|
|
|
|
2014-09-15 19:10:49 +01:00
|
|
|
/** @pred stream_position(+ _Stream_,- _StreamPosition_, +_NewPosition_)
|
|
|
|
|
|
|
|
Unify _StreamPosition_ with the packaged information of position on
|
|
|
|
current stream _Stream_ an then moves to position _NewPosition_.
|
|
|
|
|
|
|
|
*/
|
2011-02-14 20:14:31 +00:00
|
|
|
stream_position(Stream, Position, NewPosition) :-
|
|
|
|
stream_property(Stream, position(Position)),
|
|
|
|
set_stream_position(Stream, NewPosition).
|
2001-04-09 20:54:03 +01:00
|
|
|
|
2014-09-15 19:10:49 +01:00
|
|
|
/** @pred at_end_of_line
|
|
|
|
|
|
|
|
Tests whether the next character in the current input stream is a line break character.
|
|
|
|
*/
|
|
|
|
|
2005-01-29 04:43:14 +00:00
|
|
|
at_end_of_line :-
|
|
|
|
current_input(S),
|
|
|
|
at_end_of_line(S).
|
|
|
|
|
2014-09-15 19:10:49 +01:00
|
|
|
/** @pred at_end_of_line( +Stream )
|
|
|
|
|
|
|
|
Tests whether the next character in the stream is a line break character.
|
|
|
|
*/
|
2005-01-29 04:43:14 +00:00
|
|
|
at_end_of_line(S) :-
|
2014-08-20 15:12:40 +01:00
|
|
|
stream_property(S, end_of_stream(past)), !.
|
2005-01-29 04:43:14 +00:00
|
|
|
at_end_of_line(S) :-
|
2014-08-20 15:12:40 +01:00
|
|
|
peek_code(S,N), ( N = 10 -> true ; N = -1).
|
2005-01-29 04:43:14 +00:00
|
|
|
|
2014-09-11 20:06:57 +01:00
|
|
|
/** @pred current_char_conversion(? _IN_,? _OUT_) is iso
|
|
|
|
|
|
|
|
|
|
|
|
If _IN_ is unbound give all current character
|
|
|
|
translations. Otherwise, give the translation for _IN_, if one
|
|
|
|
exists.
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
2001-04-09 20:54:03 +01:00
|
|
|
current_char_conversion(X,Y) :-
|
|
|
|
var(X), !,
|
|
|
|
'$all_char_conversions'(List),
|
|
|
|
'$fetch_char_conversion'(List,X,Y).
|
|
|
|
current_char_conversion(X,Y) :-
|
|
|
|
'$current_char_conversion'(X,Y).
|
|
|
|
|
|
|
|
|
|
|
|
'$fetch_char_conversion'([X,Y|_],X,Y).
|
|
|
|
'$fetch_char_conversion'([_,_|List],X,Y) :-
|
|
|
|
'$fetch_char_conversion'(List,X,Y).
|
|
|
|
|
2015-11-05 17:25:09 +00:00
|
|
|
split_path_file(File, Path, Name) :-
|
|
|
|
file_directory_name(File, Path),
|
|
|
|
file_base_name(File, Name).
|
2015-06-19 01:30:13 +01:00
|
|
|
|
2014-09-11 20:06:57 +01:00
|
|
|
/** @pred current_stream( _F_, _M_, _S_)
|
|
|
|
|
|
|
|
|
|
|
|
Defines the relation: The stream _S_ is opened on the file _F_
|
|
|
|
in mode _M_. It might be used to obtain all open streams (by
|
|
|
|
backtracking) or to access the stream for a file _F_ in mode
|
|
|
|
_M_, or to find properties for a stream _S_. Notice that some
|
|
|
|
streams might not be associated to a file: in this case YAP tries to
|
|
|
|
return the file number. If that is not available, YAP unifies _F_
|
|
|
|
with _S_.
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
2012-08-02 15:36:37 +01:00
|
|
|
current_stream(File, Mode, Stream) :-
|
2015-06-19 01:30:13 +01:00
|
|
|
|
2012-08-02 15:36:37 +01:00
|
|
|
stream_property(Stream, mode(Mode)),
|
|
|
|
'$stream_name'(Stream, File).
|
|
|
|
|
|
|
|
'$stream_name'(Stream, File) :-
|
|
|
|
stream_property(Stream, file_name(File)), !.
|
|
|
|
'$stream_name'(Stream, file_no(File)) :-
|
|
|
|
stream_property(Stream, file_no(File)), !.
|
|
|
|
'$stream_name'(Stream, Stream).
|
2002-01-07 06:28:04 +00:00
|
|
|
|
2005-10-28 18:38:50 +01:00
|
|
|
'$extend_file_search_path'(P) :-
|
|
|
|
atom_codes(P,S),
|
|
|
|
'$env_separator'(ES),
|
2010-04-14 10:57:00 +01:00
|
|
|
'$split_for_path'(S,0'=,ES,Paths), %'
|
2005-10-28 18:38:50 +01:00
|
|
|
'$add_file_search_paths'(Paths).
|
|
|
|
|
|
|
|
'$split_for_path'([], _, _, []).
|
|
|
|
'$split_for_path'(S, S1, S2, [A1=A2|R]) :-
|
|
|
|
'$fetch_first_path'(S, S1, A1, SR1),
|
|
|
|
'$fetch_second_path'(SR1, S2, A2, SR),
|
|
|
|
'$split_for_path'(SR, S1, S2, R) .
|
|
|
|
|
|
|
|
'$fetch_first_path'([S1|SR],S1,[],SR) :- !.
|
|
|
|
'$fetch_first_path'([C|S],S1,[C|F],SR) :-
|
|
|
|
'$fetch_first_path'(S,S1,F,SR).
|
|
|
|
|
|
|
|
'$fetch_second_path'([],_,[],[]).
|
|
|
|
'$fetch_second_path'([S1|SR],S1,[],SR) :- !.
|
|
|
|
'$fetch_second_path'([C|S],S1,[C|A2],SR) :-
|
|
|
|
'$fetch_second_path'(S,S1,A2,SR).
|
|
|
|
|
|
|
|
'$add_file_search_paths'([]).
|
|
|
|
'$add_file_search_paths'([NS=DS|Paths]) :-
|
|
|
|
atom_codes(N,NS),
|
|
|
|
atom_codes(D,DS),
|
|
|
|
assert(user:file_search_path(N,D)),
|
|
|
|
'$add_file_search_paths'(Paths).
|
|
|
|
|
|
|
|
|
2015-11-05 17:25:09 +00:00
|
|
|
prolog_file_name(File, PrologFileName) :-
|
|
|
|
var(File), !,
|
|
|
|
'$do_error'(instantiation_error, prolog_file_name(File, PrologFileName)).
|
|
|
|
prolog_file_name(user, Out) :- !, Out = user.
|
|
|
|
prolog_file_name(File, PrologFileName) :-
|
|
|
|
atom(File), !,
|
|
|
|
system:true_file_name(File, PrologFileName).
|
|
|
|
prolog_file_name(File, PrologFileName) :-
|
|
|
|
'$do_error'(type_error(atom,File),
|
|
|
|
prolog_file_name(File, PrologFileName)).
|
|
|
|
|
2005-10-28 18:38:50 +01:00
|
|
|
'$format@'(Goal,Out) :-
|
2011-02-12 18:42:44 +00:00
|
|
|
with_output_to(codes(Out), Goal).
|
2005-10-28 18:38:50 +01:00
|
|
|
|
2010-04-13 00:31:48 +01:00
|
|
|
sformat(String, Form, Args) :-
|
2011-02-12 18:42:44 +00:00
|
|
|
format(codes(String, []), Form, Args).
|
2005-10-28 18:38:50 +01:00
|
|
|
|
2011-02-14 14:59:15 +00:00
|
|
|
|
2014-09-11 20:06:57 +01:00
|
|
|
/** @pred stream_position_data(+ _Field_,+ _StreamPosition_,- _Info_)
|
2014-12-24 15:32:29 +00:00
|
|
|
Extract values from stream position objects.
|
2014-09-11 20:06:57 +01:00
|
|
|
|
|
|
|
|
2014-12-24 15:32:29 +00:00
|
|
|
'$stream_position' is of the format '$stream_position'(Byte, Char,
|
|
|
|
Line, LinePos). Given the packaged stream position term
|
|
|
|
_StreamPosition_, unify _Info_ with _Field_ `line_count`,
|
|
|
|
`byte_count`, or `char_count`.
|
2014-09-11 20:06:57 +01:00
|
|
|
|
|
|
|
*/
|
2011-02-14 14:59:15 +00:00
|
|
|
stream_position_data(Prop, Term, Value) :-
|
|
|
|
nonvar(Prop), !,
|
2011-02-14 22:13:45 +00:00
|
|
|
( '$stream_position_field'(Prop, Pos)
|
2011-02-14 14:59:15 +00:00
|
|
|
-> arg(Pos, Term, Value)
|
2015-09-21 23:05:36 +01:00
|
|
|
; '$do_error'(domain_error(stream_position_data), Prop)
|
2011-02-14 14:59:15 +00:00
|
|
|
).
|
|
|
|
stream_position_data(Prop, Term, Value) :-
|
2011-02-14 22:13:45 +00:00
|
|
|
'$stream_position_field'(Prop, Pos),
|
2011-02-14 14:59:15 +00:00
|
|
|
arg(Pos, Term, Value).
|
|
|
|
|
2011-02-14 22:13:45 +00:00
|
|
|
'$stream_position_field'(char_count, 1).
|
|
|
|
'$stream_position_field'(line_count, 2).
|
|
|
|
'$stream_position_field'(line_position, 3).
|
|
|
|
'$stream_position_field'(byte_count, 4).
|
2008-02-12 17:03:59 +00:00
|
|
|
|
2008-02-23 01:32:31 +00:00
|
|
|
|
2015-06-19 01:30:13 +01:00
|
|
|
|
2014-12-24 15:32:29 +00:00
|
|
|
%! @}
|
2010-04-13 00:31:48 +01:00
|
|
|
|
2010-04-14 10:57:00 +01:00
|
|
|
|
|
|
|
'$codes_to_chars'(String0, String, String0) :- String0 == String, !.
|
|
|
|
'$codes_to_chars'(String0, [Code|String], [Char|Chars]) :-
|
|
|
|
atom_codes(Char, [Code]),
|
2010-08-04 13:04:17 +01:00
|
|
|
'$codes_to_chars'(String0, String, Chars).
|
|
|
|
|
2010-12-02 19:57:55 +00:00
|
|
|
|
2014-09-11 20:06:57 +01:00
|
|
|
/**
|
|
|
|
@}
|
|
|
|
*/
|