Struct erg_parser::token::Token
source · pub struct Token {
pub kind: TokenKind,
pub content: Str,
pub lineno: u32,
pub col_begin: u32,
pub col_end: u32,
}
Fields§
§kind: TokenKind
§content: Str
§lineno: u32
1 origin
col_begin: u32
A pointer from which the token starts (0 origin)
col_end: u32
A pointer to the end position of the token.
col_end - col_start
does not necessarily equal content.len()
Implementations§
source§impl Token
impl Token
pub const DUMMY: Token = _
pub const fn dummy(kind: TokenKind, content: &'static str) -> Self
pub fn new<S: Into<Str>>( kind: TokenKind, cont: S, lineno: u32, col_begin: u32, ) -> Self
pub fn new_fake<S: Into<Str>>( kind: TokenKind, cont: S, lineno: u32, col_begin: u32, col_end: u32, ) -> Self
pub fn new_with_loc( kind: TokenKind, cont: impl Into<Str>, loc: Location, ) -> Self
pub fn from_str(kind: TokenKind, cont: &str) -> Self
pub fn symbol(cont: &str) -> Self
pub fn symbol_with_line(cont: &str, lineno: u32) -> Self
pub fn symbol_with_loc<S: Into<Str>>(cont: S, loc: Location) -> Self
pub const fn static_symbol(s: &'static str) -> Self
pub fn deep_eq(&self, other: &Self) -> bool
pub fn loc(&self) -> Location
pub const fn category(&self) -> TokenCategory
pub fn category_is(&self, category: TokenCategory) -> bool
pub fn is(&self, kind: TokenKind) -> bool
pub const fn is_block_op(&self) -> bool
pub const fn inspect(&self) -> &Str
pub fn is_procedural(&self) -> bool
pub fn is_const(&self) -> bool
Trait Implementations§
source§impl DequeStream<Token> for TokenStream
impl DequeStream<Token> for TokenStream
fn payload(self) -> VecDeque<Token>
fn ref_payload(&self) -> &VecDeque<Token>
fn ref_mut_payload(&mut self) -> &mut VecDeque<Token>
fn is_empty(&self) -> bool
fn push(&mut self, elem: T)
fn push_front(&mut self, elem: T)
fn pop_front(&mut self) -> Option<T>
fn get(&self, idx: usize) -> Option<&T>
fn first(&self) -> Option<&T>
fn last(&self) -> Option<&T>
fn iter(&self) -> Iter<'_, T>
fn len(&self) -> usize
source§impl FromIterator<Token> for TokenStream
impl FromIterator<Token> for TokenStream
source§impl Locational for Token
impl Locational for Token
impl Eq for Token
Auto Trait Implementations§
impl Freeze for Token
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)