provide read_term_from_chars/2 (#334)
This commit is contained in:
@@ -1,4 +1,22 @@
|
||||
:- module(charsio, [write_term_to_chars/3]).
|
||||
:- module(charsio, [read_term_from_chars/2,
|
||||
write_term_to_chars/3]).
|
||||
|
||||
:- use_module(library(iso_ext)).
|
||||
|
||||
read_term_from_chars(Chars, Term) :-
|
||||
( var(Chars) ->
|
||||
throw(error(instantiation_error, read_term_from_chars/2))
|
||||
; nonvar(Term) ->
|
||||
throw(error(uninstantiation_error(Term), read_term_from_chars/2))
|
||||
; '$skip_max_list'(_, -1, Chars, Chars0),
|
||||
Chars0 == [],
|
||||
partial_string(Chars) ->
|
||||
true
|
||||
;
|
||||
throw(error(type_error(complete_string, Chars), read_term_from_chars/2))
|
||||
),
|
||||
'$read_term_from_chars'(Chars, Term).
|
||||
|
||||
|
||||
write_term_to_chars(_, Options, _) :-
|
||||
var(Options), throw(error(instantiation_error, write_term_to_chars/3)).
|
||||
|
||||
Reference in New Issue
Block a user