ADDED: octet_character and octet_chars, testing for strings that represent bytes.
This commit is contained in:
@@ -35,6 +35,8 @@
|
|||||||
- in_character
|
- in_character
|
||||||
- integer
|
- integer
|
||||||
- list
|
- list
|
||||||
|
- octet_character
|
||||||
|
- octet_chars
|
||||||
- term
|
- term
|
||||||
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
||||||
|
|
||||||
@@ -63,6 +65,17 @@ must_be_(chars, Ls) :-
|
|||||||
true
|
true
|
||||||
; all_characters(Ls)
|
; all_characters(Ls)
|
||||||
).
|
).
|
||||||
|
must_be_(octet_character, C) :-
|
||||||
|
must_be(character, C),
|
||||||
|
( octet_character(C) -> true
|
||||||
|
; domain_error(octet_character, C, must_be/2)
|
||||||
|
).
|
||||||
|
must_be_(octet_chars, Cs) :-
|
||||||
|
must_be(chars, Cs),
|
||||||
|
( '$first_non_octet'(Cs, C) ->
|
||||||
|
domain_error(octet_character, C, must_be/2)
|
||||||
|
; true
|
||||||
|
).
|
||||||
must_be_(list, Term) :- check_(error:ilist, list, Term).
|
must_be_(list, Term) :- check_(error:ilist, list, Term).
|
||||||
must_be_(type, Term) :- check_(error:type, type, Term).
|
must_be_(type, Term) :- check_(error:type, type, Term).
|
||||||
must_be_(boolean, Term) :- check_(error:boolean, boolean, Term).
|
must_be_(boolean, Term) :- check_(error:boolean, boolean, Term).
|
||||||
@@ -94,6 +107,10 @@ character(C) :-
|
|||||||
atom(C),
|
atom(C),
|
||||||
atom_length(C, 1).
|
atom_length(C, 1).
|
||||||
|
|
||||||
|
octet_character(C) :-
|
||||||
|
char_code(C, Code),
|
||||||
|
0 =< Code, Code =< 0xff.
|
||||||
|
|
||||||
in_character(C) :-
|
in_character(C) :-
|
||||||
( character(C)
|
( character(C)
|
||||||
; C == end_of_file
|
; C == end_of_file
|
||||||
@@ -111,6 +128,8 @@ type(integer).
|
|||||||
type(atom).
|
type(atom).
|
||||||
type(character).
|
type(character).
|
||||||
type(in_character).
|
type(in_character).
|
||||||
|
type(octet_character).
|
||||||
|
type(octet_chars).
|
||||||
type(chars).
|
type(chars).
|
||||||
type(list).
|
type(list).
|
||||||
type(var).
|
type(var).
|
||||||
@@ -147,6 +166,17 @@ can_(chars, Ls) :-
|
|||||||
; can_be(list, Ls),
|
; can_be(list, Ls),
|
||||||
can_be_chars(Ls)
|
can_be_chars(Ls)
|
||||||
).
|
).
|
||||||
|
can_(octet_character, C) :-
|
||||||
|
( octet_character(C) -> true
|
||||||
|
; domain_error(octet_character, C, can_be/2)
|
||||||
|
).
|
||||||
|
can_(octet_chars, Cs) :-
|
||||||
|
can_be(chars, Cs),
|
||||||
|
( '$skip_max_list'(_, _, Cs, []), % temporarily turn Cs into a list
|
||||||
|
'$first_non_octet'(Cs, C) ->
|
||||||
|
domain_error(octet_character, C, can_be/2)
|
||||||
|
; true
|
||||||
|
).
|
||||||
can_(list, Term) :- list_or_partial_list(Term).
|
can_(list, Term) :- list_or_partial_list(Term).
|
||||||
can_(boolean, Term) :- boolean(Term).
|
can_(boolean, Term) :- boolean(Term).
|
||||||
can_(term, Term) :-
|
can_(term, Term) :-
|
||||||
|
|||||||
Reference in New Issue
Block a user