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>,
    },
}

The type of tokens in parsed code

Variants (Non-exhaustive)

Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Eof

End of file, should always be the very last token

Identifier

An identifier, such as foo

Fields of Identifier

identifier: Cow<'a, str>

The identifier itself

MultiLineComment

A multi line comment in the format of --[[ comment ]]

Fields of MultiLineComment

blocks: usize

Number of equals signs, if any, for the multi line comment For example, --[=[ would have a blocks value of 1

comment: Cow<'a, str>

The comment itself, ignoring opening and closing tags

Number

A literal number, such as 3.3

Fields of Number

text: Cow<'a, str>

The text representing the number, includes details such as 0x

Shebang

A shebang line

Fields of Shebang

line: Cow<'a, str>

The shebang line itself

SingleLineComment

A single line comment, such as -- comment

Fields of SingleLineComment

comment: Cow<'a, str>

The comment, ignoring initial --

StringLiteral

A literal string, such as “Hello, world”

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

Symbol

A Symbol, such as local or +

Fields of Symbol

symbol: Symbol

The symbol itself

Whitespace

Whitespace, such as tabs or new lines

Fields of Whitespace

characters: Cow<'a, str>

Characters consisting of the whitespace

Implementations

impl<'a> TokenType<'a>[src]

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

Returns whether a token can be practically ignored in most cases Comments and whitespace will return true, everything else will return false

pub fn kind(&self) -> TokenKind[src]

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,
);

pub fn spaces(spaces: usize) -> Self[src]

Returns a whitespace TokenType consisting of spaces

pub fn tabs(tabs: usize) -> Self[src]

Returns a whitespace TokenType consisting of tabs

Trait Implementations

impl<'a> Clone for TokenType<'a>[src]

impl<'a> Debug for TokenType<'a>[src]

impl<'de: 'a, 'a> Deserialize<'de> for TokenType<'a>[src]

impl<'a> Eq for TokenType<'a>[src]

impl Owned for TokenType<'_>[src]

type Owned = TokenType<'static>

What an owned version of the object looks like. Usually contains a 'static lifetime.

impl<'a> PartialEq<TokenType<'a>> for TokenType<'a>[src]

impl<'a> Serialize for TokenType<'a>[src]

impl<'a> StructuralEq for TokenType<'a>[src]

impl<'a> StructuralPartialEq for TokenType<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for TokenType<'a>

impl<'a> Send for TokenType<'a>

impl<'a> Sync for TokenType<'a>

impl<'a> Unpin for TokenType<'a>

impl<'a> UnwindSafe for TokenType<'a>

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> Conv for T

impl<T> Conv for T

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> FmtForward for T

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

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

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T

impl<T> TryConv for T

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.