1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#![allow(non_snake_case)]

//!
//! Parsing of ABNF Core Rules
//!
//! See https://tools.ietf.org/html/rfc5234#appendix-B.1
//!

pub mod complete;
//pub mod streaming; // (NIY)

pub fn is_ALPHA(c: char) -> bool {
    c.is_ascii_alphabetic()
}

pub fn is_BIT(c: char) -> bool {
    c == '0' || c == '1'
}

pub fn is_CHAR(c: char) -> bool {
    match c {
        '\x01'..='\x7F' => true,
        _ => false,
    }
}

pub fn is_CR(c: char) -> bool {
    c == '\r'
}

// CRLF

pub fn is_CTL(c: char) -> bool {
    match c {
        '\x00'..='\x1F' | '\x7F' => true,
        _ => false,
    }
}

pub fn is_DIGIT(c: char) -> bool {
    c.is_ascii_digit()
}

pub fn is_DQUOTE(c: char) -> bool {
    c == '"'
}

pub fn is_HEXDIG(c: char) -> bool {
    c.is_ascii_hexdigit()
}

// HTAB

// LF

// LWSP

// OCTET

// SP

// VCHAR

// WSP

pub fn is_VCHAR(c: char) -> bool {
    match c {
        '\x21'..='\x7E' => true,
        _ => false,
    }
}

pub fn is_WSP(c: char) -> bool {
    match c {
        '\x20' | '\x09' => true,
        _ => false,
    }
}