Draft of an implementation of char_type
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user