pub enum Token {
Num(f64),
Int(i64),
Str(String),
Iden(String),
Char(char),
Error(ScanError),
End,
}
Expand description
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§
source§impl Token
impl Token
sourcepub fn to_float_result(self) -> Result<f64, ScanError>
pub fn to_float_result(self) -> Result<f64, ScanError>
extract the float, or complain
sourcepub fn is_integer(&self) -> bool
pub fn is_integer(&self) -> bool
is this token an integer?
sourcepub fn to_integer(self) -> Option<i64>
pub fn to_integer(self) -> Option<i64>
extract the integer
sourcepub fn to_integer_result(self) -> Result<i64, ScanError>
pub fn to_integer_result(self) -> Result<i64, ScanError>
extract the integer, or complain
sourcepub fn to_int_result<I: Int>(self) -> Result<I::Type, ScanError>
pub fn to_int_result<I: Int>(self) -> Result<I::Type, ScanError>
extract the integer as a particular subtype
sourcepub fn to_number_result(self) -> Result<f64, ScanError>
pub fn to_number_result(self) -> Result<f64, ScanError>
extract the number, not caring about float or integer, or complain
sourcepub fn to_string_result(self) -> Result<String, ScanError>
pub fn to_string_result(self) -> Result<String, ScanError>
extract the string, or complain
sourcepub fn to_iden_result(self) -> Result<String, ScanError>
pub fn to_iden_result(self) -> Result<String, ScanError>
extract the identifier, or complain
sourcepub fn to_char_result(self) -> Result<char, ScanError>
pub fn to_char_result(self) -> Result<char, ScanError>
extract the character, or complain