[−][src]Enum erl_tokenize::Token
Token.
Variants
Atom(AtomToken)
Char(CharToken)
Comment(CommentToken)
Float(FloatToken)
Integer(IntegerToken)
Keyword(KeywordToken)
String(StringToken)
Symbol(SymbolToken)
Variable(VariableToken)
Whitespace(WhitespaceToken)
Methods
impl Token
[src]
pub fn from_text(text: &str, pos: Position) -> Result<Self>
[src]
Tries to convert from any prefixes of the text to a token.
Examples
use erl_tokenize::{Token, Position}; use erl_tokenize::values::Symbol; let pos = Position::new(); // Atom let token = Token::from_text("foo", pos.clone()).unwrap(); assert_eq!(token.as_atom_token().map(|t| t.value()), Some("foo")); // Symbol let token = Token::from_text("[foo]", pos.clone()).unwrap(); assert_eq!(token.as_symbol_token().map(|t| t.value()), Some(Symbol::OpenSquare));
pub fn text(&self) -> &str
[src]
Returns the original textual representation of this token.
Examples
use erl_tokenize::{Token, Position}; let pos = Position::new(); // Comment assert_eq!(Token::from_text("% foo", pos.clone()).unwrap().text(), "% foo"); // Char assert_eq!(Token::from_text(r#"$\t"#, pos.clone()).unwrap().text(), r#"$\t"#);
pub fn is_lexical_token(&self) -> bool
[src]
Returns true
if this is a lexical token, otherwise false
.
[src]
Returns true
if this is a hidden token, otherwise false
.
pub fn into_lexical_token(self) -> Result<LexicalToken, Self>
[src]
Tries to convert into LexicalToken
.
[src]
Tries to convert into HiddenToken
.
pub fn as_atom_token(&self) -> Option<&AtomToken>
[src]
Tries to return the reference to the inner AtomToken
.
pub fn as_char_token(&self) -> Option<&CharToken>
[src]
Tries to return the reference to the inner CharToken
.
pub fn as_float_token(&self) -> Option<&FloatToken>
[src]
Tries to return the reference to the inner FloatToken
.
pub fn as_integer_token(&self) -> Option<&IntegerToken>
[src]
Tries to return the reference to the inner IntegerToken
.
pub fn as_keyword_token(&self) -> Option<&KeywordToken>
[src]
Tries to return the reference to the inner KeywordToken
.
pub fn as_string_token(&self) -> Option<&StringToken>
[src]
Tries to return the reference to the inner StringToken
.
pub fn as_symbol_token(&self) -> Option<&SymbolToken>
[src]
Tries to return the reference to the inner SymbolToken
.
pub fn as_variable_token(&self) -> Option<&VariableToken>
[src]
Tries to return the reference to the inner VariableToken
.
pub fn as_comment_token(&self) -> Option<&CommentToken>
[src]
Tries to return the reference to the inner CommentToken
.
pub fn as_whitespace_token(&self) -> Option<&WhitespaceToken>
[src]
Tries to return the reference to the inner WhitespaceToken
.
pub fn into_atom_token(self) -> Result<AtomToken, Self>
[src]
Tries to return the inner AtomToken
.
pub fn into_char_token(self) -> Result<CharToken, Self>
[src]
Tries to return the inner CharToken
.
pub fn into_float_token(self) -> Result<FloatToken, Self>
[src]
Tries to return the inner FloatToken
.
pub fn into_integer_token(self) -> Result<IntegerToken, Self>
[src]
Tries to return the inner IntegerToken
.
pub fn into_keyword_token(self) -> Result<KeywordToken, Self>
[src]
Tries to return the inner KeywordToken
.
pub fn into_string_token(self) -> Result<StringToken, Self>
[src]
Tries to return the inner StringToken
.
pub fn into_symbol_token(self) -> Result<SymbolToken, Self>
[src]
Tries to return the inner SymbolToken
.
pub fn into_variable_token(self) -> Result<VariableToken, Self>
[src]
Tries to return the inner VariableToken
.
pub fn into_comment_token(self) -> Result<CommentToken, Self>
[src]
Tries to return the inner CommentToken
.
pub fn into_whitespace_token(self) -> Result<WhitespaceToken, Self>
[src]
Tries to return the inner WhitespaceToken
.
Trait Implementations
impl PositionRange for Token
[src]
fn start_position(&self) -> Position
[src]
fn end_position(&self) -> Position
[src]
impl Clone for Token
[src]
fn clone(&self) -> Token
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl From<AtomToken> for Token
[src]
impl From<CharToken> for Token
[src]
impl From<CommentToken> for Token
[src]
fn from(f: CommentToken) -> Self
[src]
impl From<FloatToken> for Token
[src]
fn from(f: FloatToken) -> Self
[src]
impl From<IntegerToken> for Token
[src]
fn from(f: IntegerToken) -> Self
[src]
impl From<KeywordToken> for Token
[src]
fn from(f: KeywordToken) -> Self
[src]
impl From<StringToken> for Token
[src]
fn from(f: StringToken) -> Self
[src]
impl From<SymbolToken> for Token
[src]
fn from(f: SymbolToken) -> Self
[src]
impl From<VariableToken> for Token
[src]
fn from(f: VariableToken) -> Self
[src]
impl From<WhitespaceToken> for Token
[src]
fn from(f: WhitespaceToken) -> Self
[src]
impl From<HiddenToken> for Token
[src]
fn from(f: HiddenToken) -> Self
[src]
impl From<LexicalToken> for Token
[src]
fn from(f: LexicalToken) -> Self
[src]
impl Display for Token
[src]
impl Debug for Token
[src]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,