pub struct TokenParser<'a> { /* private fields */ }Expand description
Helper for the composition expression parser: a cursor over the text that consumes tokens from its start.
TokenParser::position and TokenParser::length count UTF-16 code
units, the unit of the reference implementation.
Implementations§
Source§impl<'a> TokenParser<'a>
impl<'a> TokenParser<'a>
pub fn skip_whitespace(&mut self)
pub fn next_is_whitespace(&self) -> bool
Sourcepub fn try_consume(&mut self, c: char) -> bool
pub fn try_consume(&mut self, c: char) -> bool
Consumes the given character if it is next (after white space).
Sourcepub fn try_consume_str(&mut self, s: &str) -> bool
pub fn try_consume_str(&mut self, s: &str) -> bool
Consumes the given text if it is next (after white space).
Sourcepub fn try_consume_any(&mut self, chars: &str) -> Option<char>
pub fn try_consume_any(&mut self, chars: &str) -> Option<char>
Consumes whichever of the given characters is next (after white space).
Sourcepub fn try_parse_keyword(&mut self, keyword: &str) -> bool
pub fn try_parse_keyword(&mut self, keyword: &str) -> bool
Consumes the given keyword if it is next (after white space) and is not followed by a letter or a digit.
Sourcepub fn try_parse_keyword_lower_case(
&mut self,
keyword_in_lower_case: &str,
) -> bool
pub fn try_parse_keyword_lower_case( &mut self, keyword_in_lower_case: &str, ) -> bool
Like TokenParser::try_parse_keyword, ignoring the case of the
text; the keyword must be given in lower case.
Sourcepub fn try_parse_identifier_with(
&mut self,
extra_valid_chars: &str,
) -> Option<&'a str>
pub fn try_parse_identifier_with( &mut self, extra_valid_chars: &str, ) -> Option<&'a str>
Consumes an identifier: an ASCII letter followed by ASCII letters, digits and any of the extra valid characters.
Sourcepub fn try_parse_identifier(&mut self) -> Option<&'a str>
pub fn try_parse_identifier(&mut self) -> Option<&'a str>
Consumes an identifier: an ASCII letter followed by ASCII letters and digits.
Sourcepub fn try_parse_call(&mut self) -> Option<&'a str>
pub fn try_parse_call(&mut self) -> Option<&'a str>
Consumes a function name (an identifier that may contain dots) together with the opening parenthesis that follows it. Nothing is consumed when the name is not followed by a parenthesis.
Sourcepub fn try_parse_float(&mut self) -> Option<f32>
pub fn try_parse_float(&mut self) -> Option<f32>
Consumes a single-precision number.
Sourcepub fn try_parse_double(&mut self) -> Option<f64>
pub fn try_parse_double(&mut self) -> Option<f64>
Consumes a double-precision number.
Sourcepub fn is_eof_with_whitespace(&mut self) -> bool
pub fn is_eof_with_whitespace(&mut self) -> bool
Whether only white space is left (which is consumed).
Trait Implementations§
Source§impl<'a> Clone for TokenParser<'a>
impl<'a> Clone for TokenParser<'a>
impl<'a> Copy for TokenParser<'a>
Source§impl<'a> Debug for TokenParser<'a>
impl<'a> Debug for TokenParser<'a>
Auto Trait Implementations§
impl<'a> Freeze for TokenParser<'a>
impl<'a> RefUnwindSafe for TokenParser<'a>
impl<'a> Send for TokenParser<'a>
impl<'a> Sync for TokenParser<'a>
impl<'a> Unpin for TokenParser<'a>
impl<'a> UnsafeUnpin for TokenParser<'a>
impl<'a> UnwindSafe for TokenParser<'a>
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
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more