pub struct Token {
pub loc: Loc,
/* private fields */
}Expand description
A Token consists of a string (stored in a StringTable) and its location in the parsed files.
Fields§
§loc: LocImplementations§
source§impl Token
impl Token
pub fn new(s: &str, loc: Loc) -> Self
pub fn from_static_str(s: &'static str, loc: Loc) -> Self
pub fn subtoken<R>(&self, range: R, loc: Loc) -> Token
pub fn as_str(&self) -> &str
pub fn is(&self, s: &str) -> bool
pub fn lowercase_is(&self, s: &str) -> bool
pub fn starts_with(&self, s: &str) -> bool
pub fn split(&self, ch: char) -> Vec<Token>
pub fn strip_suffix(&self, sfx: &str) -> Option<Token>
pub fn strip_prefix(&self, pfx: &str) -> Option<Token>
pub fn split_once(&self, ch: char) -> Option<(Token, Token)>
sourcepub fn split_after(&self, ch: char) -> Option<(Token, Token)>
pub fn split_after(&self, ch: char) -> Option<(Token, Token)>
Split the token at the first instance of ch, such that ch is part of the first returned token.
pub fn combine(&mut self, other: &Token, c: char)
pub fn trim(&self) -> Token
pub fn expect_number(&self) -> Option<f64>
pub fn get_number(&self) -> Option<f64>
pub fn is_number(&self) -> bool
pub fn check_number(&self)
sourcepub fn expect_precise_number(&self) -> Option<f64>
pub fn expect_precise_number(&self) -> Option<f64>
Some files seem not to have the 5-decimal limitation
pub fn expect_integer(&self) -> Option<i64>
pub fn get_integer(&self) -> Option<i64>
pub fn is_integer(&self) -> bool
pub fn expect_date(&self) -> Option<Date>
pub fn get_date(&self) -> Option<Date>
pub fn is_date(&self) -> bool
pub fn linked(self, link: Option<Arc<Loc>>) -> Self
Trait Implementations§
source§impl PartialEq for Token
impl PartialEq for Token
Tokens are compared for equality regardless of their loc.
impl Eq for Token
Auto Trait Implementations§
impl RefUnwindSafe for Token
impl Send for Token
impl Sync for Token
impl Unpin for Token
impl UnwindSafe for Token
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