Enum full_moon::tokenizer::TokenType [−][src]
#[non_exhaustive] pub enum TokenType<'a> { Eof, Identifier { identifier: Cow<'a, str>, }, MultiLineComment { blocks: usize, comment: Cow<'a, str>, }, Number { text: Cow<'a, str>, }, Shebang { line: Cow<'a, str>, }, SingleLineComment { comment: Cow<'a, str>, }, StringLiteral { literal: Cow<'a, str>, multi_line: Option<usize>, quote_type: StringLiteralQuoteType, }, Symbol { symbol: Symbol, }, Whitespace { characters: Cow<'a, str>, }, }
Expand description
The type of tokens in parsed code
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
End of file, should always be the very last token
An identifier, such as foo
A multi line comment in the format of --[[ comment ]]
Show fields
A literal number, such as 3.3
Show fields
A shebang line
A single line comment, such as -- comment
A literal string, such as “Hello, world”
Show fields
Fields of StringLiteral
literal: Cow<'a, str>
The literal itself, ignoring quotation marks
multi_line: Option<usize>
Number of equals signs used for a multi line string, if it is one
For example, [=[string]=]
would have a multi_line
value of Some(1)
[[string]]
would have a multi_line
value of Some(0)
A string such as "string"
would have a multi_line
value of None
quote_type: StringLiteralQuoteType
The type of quotation mark used to make the string
A Symbol
, such as local
or +
Show fields
Fields of Symbol
symbol: Symbol
The symbol itself
Whitespace, such as tabs or new lines
Implementations
Returns whether a token can be practically ignored in most cases
Comments and whitespace will return true
, everything else will return false
Returns the kind of the token type.
use std::borrow::Cow; use full_moon::tokenizer::{TokenKind, TokenType}; assert_eq!( TokenType::Identifier { identifier: Cow::from("hello") }.kind(), TokenKind::Identifier, );
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl<'a> RefUnwindSafe for TokenType<'a>
impl<'a> UnwindSafe for TokenType<'a>
Blanket Implementations
Mutably borrows from an owned value. Read more