Moved get_single_char from builtins.pl to charsio.pl

This commit is contained in:
notoria
2020-04-18 12:52:49 +02:00
parent 1ea6ae9fd9
commit 11ea92288d
2 changed files with 12 additions and 10 deletions

View File

@@ -47,8 +47,8 @@ user:term_expansion((:- op(Pred, Spec, [Op | OtherOps])), OpResults) :-
current_input/1, current_output/1, current_op/3,
current_predicate/1, current_prolog_flag/2,
expand_goal/2, expand_term/2, fail/0, false/0,
findall/3, findall/4, get_char/1, get_single_char/1,
halt/0, max_arity/1, number_chars/2, number_codes/2,
findall/3, findall/4, get_char/1, halt/0,
max_arity/1, number_chars/2, number_codes/2,
once/1, op/3, read_term/2, repeat/0, retract/1,
set_prolog_flag/2, set_input/1, set_output/1,
setof/3, sub_atom/5, subsumes_term/2,
@@ -933,13 +933,6 @@ get_char(C) :-
; throw(error(type_error(in_character, C), get_char/1))
).
get_single_char(C) :-
( var(C) -> '$get_single_char'(C)
; C == end_of_file -> '$get_single_char'(C)
; atom_length(C, 1) -> '$get_single_char'(C)
; throw(error(type_error(in_character, C), get_char/1))
).
can_be_number(N, PI) :-
( var(N) -> true
; must_be_number(N, PI)

View File

@@ -1,4 +1,5 @@
:- module(charsio, [read_term_from_chars/2,
:- module(charsio, [get_single_char/1,
read_term_from_chars/2,
write_term_to_chars/3]).
:- use_module(library(iso_ext)).
@@ -56,6 +57,14 @@ extend_var_list_([V|Vs], N, VarList, NewVarList, VarType) :-
).
get_single_char(C) :-
( var(C) -> '$get_single_char'(C)
; C == end_of_file -> '$get_single_char'(C)
; atom_length(C, 1) -> '$get_single_char'(C)
; throw(error(type_error(in_character, C), get_char/1))
).
read_term_from_chars(Chars, Term) :-
( var(Chars) ->
throw(error(instantiation_error, read_term_from_chars/2))