[][src]Enum scanlex::Token

pub enum Token {
    Num(f64),
    Int(i64),
    Str(String),
    Iden(String),
    Char(char),
    Error(ScanError),
    End,
}

Represents a token returned by Scanner::get

Variants

Num(f64)

a floating-point number, stored as double-precision float

Int(i64)

an integer, stored as eight-byte unsigned

Str(String)

a quoted string

Iden(String)

an identifier \a+[\a\d_]*

Char(char)

a character (anything not recognized as any of the above

Error(ScanError)

represents an error

End

end of stream

Implementations

impl Token[src]

pub fn finished(&self) -> bool[src]

is this the end token?

pub fn is_float(&self) -> bool[src]

is this token a float?

pub fn to_float(self) -> Option<f64>[src]

extract the float

pub fn to_float_result(self) -> Result<f64, ScanError>[src]

extract the float, or complain

pub fn is_integer(&self) -> bool[src]

is this token an integer?

pub fn to_integer(self) -> Option<i64>[src]

extract the integer

pub fn to_integer_result(self) -> Result<i64, ScanError>[src]

extract the integer, or complain

pub fn to_int_result<I: Int>(self) -> Result<I::Type, ScanError>[src]

extract the integer as a particular subtype

pub fn is_number(&self) -> bool[src]

is this token an integer?

pub fn to_number(self) -> Option<f64>[src]

extract the number, not caring about float or integer

pub fn to_number_result(self) -> Result<f64, ScanError>[src]

extract the number, not caring about float or integer, or complain

pub fn is_string(&self) -> bool[src]

is this token a string?

pub fn to_string(self) -> Option<String>[src]

extract the string

pub fn as_string(&self) -> Option<&str>[src]

extract a reference the string

pub fn to_string_result(self) -> Result<String, ScanError>[src]

extract the string, or complain

pub fn is_iden(&self) -> bool[src]

is this token an identifier?

pub fn to_iden(self) -> Option<String>[src]

extract the identifier

pub fn as_iden(&self) -> Option<&str>[src]

extract a reference to the identifier

pub fn to_iden_result(self) -> Result<String, ScanError>[src]

extract the identifier, or complain

pub fn is_char(&self) -> bool[src]

is this token a character?

pub fn to_char(self) -> Option<char>[src]

extract the character

pub fn as_char(&self) -> Option<char>[src]

extract the character

pub fn to_char_result(self) -> Result<char, ScanError>[src]

extract the character, or complain

pub fn is_error(&self) -> bool[src]

is this token an error?

pub fn to_error(self) -> Option<ScanError>[src]

extract the error

Trait Implementations

impl Debug for Token[src]

impl PartialEq<Token> for Token[src]

impl StructuralPartialEq for Token[src]

Auto Trait Implementations

impl RefUnwindSafe for Token

impl Send for Token

impl Sync for Token

impl Unpin for Token

impl UnwindSafe for Token

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.