Enum scanlex::Token
[−]
[src]
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
Methods
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 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]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more