Moved get_single_char from builtins.pl to charsio.pl

This commit is contained in:
notoria
2020-04-18 12:52:49 +02:00
committed by Mark Thom
parent d3a1f11dfe
commit c24ebaf506
2 changed files with 12 additions and 10 deletions

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))