diff options
Diffstat (limited to 'grammar/src/abnf/boolean_fns.rs')
-rw-r--r-- | grammar/src/abnf/boolean_fns.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/grammar/src/abnf/boolean_fns.rs b/grammar/src/abnf/boolean_fns.rs new file mode 100644 index 0000000..08f317c --- /dev/null +++ b/grammar/src/abnf/boolean_fns.rs @@ -0,0 +1,42 @@ +//! This file collects some functions that return a boolean value from +//! a character. + +pub(super) fn is_wsp(c: char) -> bool { + c == ' ' || c == '\t' +} + +pub(crate) fn is_v_char(c: char) -> bool { + ('!'..='~').contains(&c) +} + +pub(super) fn is_wsp_or_v_char(c: char) -> bool { + is_wsp(c) || is_v_char(c) +} + +pub(super) fn is_not_newline(c: char) -> bool { + c != '\n' && c != '\r' +} + +pub(super) fn is_alpha(c: char) -> bool { + c.is_ascii_alphabetic() +} + +pub(super) fn is_decimal_digit(c: char) -> bool { + c.is_ascii_digit() +} + +pub(super) fn is_binary_digit(c: char) -> bool { + c == '0' || c == '1' +} + +pub(super) fn is_hexadecimal_digit(c: char) -> bool { + is_decimal_digit(c) || ('A'..='F').contains(&c) || ('a'..='f').contains(&c) +} + +pub(super) fn is_alpha_or_digit_or_hyphen(c: char) -> bool { + is_alpha(c) || is_decimal_digit(c) || c == '-' +} + +pub(super) fn is_char_value(c: char) -> bool { + (' '..='~').contains(&c) && c != '"' +} |