Struct rustc_lexer::Cursor
source · Expand description
Peekable iterator over a char sequence.
Next characters can be peeked via first
method,
and position can be shifted forward via bump
method.
Fields§
§len_remaining: usize
§chars: Chars<'a>
Iterator over chars. Slightly faster than a &str.
prev: char
Implementations§
source§impl<'a> Cursor<'a>
impl<'a> Cursor<'a>
pub fn new(input: &'a str) -> Cursor<'a>
sourcepub(crate) fn prev(&self) -> char
pub(crate) fn prev(&self) -> char
Returns the last eaten symbol (or '\0'
in release builds).
(For debug assertions only.)
sourcepub(crate) fn first(&self) -> char
pub(crate) fn first(&self) -> char
Peeks the next symbol from the input stream without consuming it.
If requested position doesn’t exist, EOF_CHAR
is returned.
However, getting EOF_CHAR
doesn’t always mean actual end of file,
it should be checked with is_eof
method.
sourcepub(crate) fn second(&self) -> char
pub(crate) fn second(&self) -> char
Peeks the second symbol from the input stream without consuming it.
sourcepub(crate) fn pos_within_token(&self) -> u32
pub(crate) fn pos_within_token(&self) -> u32
Returns amount of already consumed symbols.
sourcepub(crate) fn reset_pos_within_token(&mut self)
pub(crate) fn reset_pos_within_token(&mut self)
Resets the number of bytes consumed to 0.
source§impl Cursor<'_>
impl Cursor<'_>
sourcepub fn advance_token(&mut self) -> Token
pub fn advance_token(&mut self) -> Token
Parses a token from the input string.
pub(crate) fn line_comment(&mut self) -> TokenKind
pub(crate) fn block_comment(&mut self) -> TokenKind
pub(crate) fn whitespace(&mut self) -> TokenKind
pub(crate) fn raw_ident(&mut self) -> TokenKind
pub(crate) fn ident_or_unknown_prefix(&mut self) -> TokenKind
pub(crate) fn fake_ident_or_unknown_prefix(&mut self) -> TokenKind
pub(crate) fn number(&mut self, first_digit: char) -> LiteralKind
pub(crate) fn lifetime_or_char(&mut self) -> TokenKind
pub(crate) fn single_quoted_string(&mut self) -> bool
sourcepub(crate) fn double_quoted_string(&mut self) -> bool
pub(crate) fn double_quoted_string(&mut self) -> bool
Eats double-quoted string and returns true if string is terminated.
sourcepub(crate) fn raw_double_quoted_string(
&mut self,
prefix_len: u32
) -> Result<u8, RawStrError>
pub(crate) fn raw_double_quoted_string(
&mut self,
prefix_len: u32
) -> Result<u8, RawStrError>
Eats the double-quoted string and returns n_hashes
and an error if encountered.
pub(crate) fn raw_string_unvalidated(
&mut self,
prefix_len: u32
) -> Result<u32, RawStrError>
pub(crate) fn eat_decimal_digits(&mut self) -> bool
pub(crate) fn eat_hexadecimal_digits(&mut self) -> bool
sourcepub(crate) fn eat_float_exponent(&mut self) -> bool
pub(crate) fn eat_float_exponent(&mut self) -> bool
Eats the float exponent. Returns true if at least one digit was met, and returns false otherwise.
pub(crate) fn eat_literal_suffix(&mut self)
pub(crate) fn eat_identifier(&mut self)
Auto Trait Implementations§
impl<'a> RefUnwindSafe for Cursor<'a>
impl<'a> Send for Cursor<'a>
impl<'a> Sync for Cursor<'a>
impl<'a> Unpin for Cursor<'a>
impl<'a> UnwindSafe for Cursor<'a>
Blanket Implementations§
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes