pub enum Atom {
NormalChar(char),
CharClass(CharClass),
MatchingList(Vec<BracketExpressionTerm>),
NonmatchingList(Vec<BracketExpressionTerm>),
}
Expand description
Represents a part of an ERE
that matches a single character.
For example, a single char a
, a char class .
, or a bracket expression [a-z]
.
Equality checks are semantic:
use ere_core::parse_tree::Atom;
assert_eq!(
"[abcd]".parse::<Atom>(),
"[a-d]".parse::<Atom>(),
);
assert_eq!(
"[a-z]".parse::<Atom>(),
"[[:lower:]]".parse::<Atom>(),
);
Variants§
NormalChar(char)
Includes normal char and escaped chars
CharClass(CharClass)
MatchingList(Vec<BracketExpressionTerm>)
A matching bracket expression
NonmatchingList(Vec<BracketExpressionTerm>)
A nonmatching bracket expression
Implementations§
Source§impl Atom
impl Atom
pub fn check(&self, c: char) -> bool
Sourcepub fn to_ranges(&self) -> Vec<RangeInclusive<char>>
pub fn to_ranges(&self) -> Vec<RangeInclusive<char>>
Produces the sorted, minimal set of ranges to represent the Atom.
Example:
use ere_core::parse_tree::Atom;
assert_eq!(
"[a-z2-9A-X0-1YZ[:xdigit:]]".parse::<Atom>().unwrap().to_ranges(),
vec!['0'..='9', 'A'..='Z', 'a'..='z'],
);
Trait Implementations§
Source§impl From<Atom> for SimplifiedTreeNode
impl From<Atom> for SimplifiedTreeNode
impl Eq for Atom
Auto Trait Implementations§
impl Freeze for Atom
impl RefUnwindSafe for Atom
impl Send for Atom
impl Sync for Atom
impl Unpin for Atom
impl UnwindSafe for Atom
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more