Enum erl_tokenize::Token [] [src]

pub enum Token {
    Atom(AtomToken),
    Char(CharToken),
    Comment(CommentToken),
    Float(FloatToken),
    Integer(IntegerToken),
    Keyword(KeywordToken),
    String(StringToken),
    Symbol(SymbolToken),
    Variable(VariableToken),
    Whitespace(WhitespaceToken),
}

Token.

Variants

Methods

impl Token
[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));

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"#);

Returns true if this is a lexical token, otherwise false.

Returns true if this is a hidden token, otherwise false.

Tries to convert into LexicalToken.

Tries to convert into HiddenToken.

Tries to return the reference to the inner AtomToken.

Tries to return the reference to the inner CharToken.

Tries to return the reference to the inner FloatToken.

Tries to return the reference to the inner IntegerToken.

Tries to return the reference to the inner KeywordToken.

Tries to return the reference to the inner StringToken.

Tries to return the reference to the inner SymbolToken.

Tries to return the reference to the inner VariableToken.

Tries to return the reference to the inner CommentToken.

Tries to return the reference to the inner WhitespaceToken.

Tries to return the inner AtomToken.

Tries to return the inner CharToken.

Tries to return the inner FloatToken.

Tries to return the inner IntegerToken.

Tries to return the inner KeywordToken.

Tries to return the inner StringToken.

Tries to return the inner SymbolToken.

Tries to return the inner VariableToken.

Tries to return the inner CommentToken.

Tries to return the inner WhitespaceToken.

Trait Implementations

impl Debug for Token
[src]

Formats the value using the given formatter.

impl Clone for Token
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl From<AtomToken> for Token
[src]

Performs the conversion.

impl From<CharToken> for Token
[src]

Performs the conversion.

impl From<CommentToken> for Token
[src]

Performs the conversion.

impl From<FloatToken> for Token
[src]

Performs the conversion.

impl From<IntegerToken> for Token
[src]

Performs the conversion.

impl From<KeywordToken> for Token
[src]

Performs the conversion.

impl From<StringToken> for Token
[src]

Performs the conversion.

impl From<SymbolToken> for Token
[src]

Performs the conversion.

impl From<VariableToken> for Token
[src]

Performs the conversion.

impl From<WhitespaceToken> for Token
[src]

Performs the conversion.

impl From<HiddenToken> for Token
[src]

Performs the conversion.

impl From<LexicalToken> for Token
[src]

Performs the conversion.

impl PositionRange for Token
[src]

Returns the (inclusive) start position of this.

Returns the (exclusive) end position of this.

impl Display for Token
[src]

Formats the value using the given formatter. Read more