Draft of an implementation of char_type

This commit is contained in:
notoria
2020-04-22 00:46:54 +02:00
parent caf20cd43d
commit e3a7f9eb7a
3 changed files with 76 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
:- module(charsio, [get_single_char/1,
:- module(charsio, [char_type/2, get_single_char/1,
read_term_from_chars/2,
write_term_to_chars/3]).
@@ -57,6 +57,13 @@ extend_var_list_([V|Vs], N, VarList, NewVarList, VarType) :-
).
char_type(C, T) :-
( var(C) -> throw(error(instantiation_error, char_type/2))
; atom_length(C, 1) -> '$char_type'(C, T)
; throw(error(type_error(in_character, C), char_type/2))
).
get_single_char(C) :-
( var(C) -> '$get_single_char'(C)
; atom_length(C, 1) -> '$get_single_char'(C)