Skip to main content

Token

Enum Token 

Source
pub enum Token<'a> {
Show 67 variants SingleLineComment(Cow<'a, str>), MultiLineComment(Cow<'a, str>), DocComment(Cow<'a, str>), KeywordMod, KeywordPart, KeywordSketch, KeywordOp, KeywordFn, KeywordIf, KeywordElse, KeywordUse, KeywordAs, KeywordReturn, KeywordPub, KeywordConst, KeywordProp, KeywordInit, Identifier(Cow<'a, str>), Unit(Cow<'a, str>), LiteralInt(Cow<'a, str>), LiteralFloat(Cow<'a, str>), LiteralBool(bool), LiteralString(Cow<'a, str>), FormatStringStart, FormatStringEnd, StringContent(Cow<'a, str>), Character(char), StringFormatOpen, StringFormatClose, StringFormatPrecision(Cow<'a, str>), StringFormatWidth(Cow<'a, str>), SigilColon, SigilSemiColon, SigilDoubleColon, SigilOpenBracket, SigilCloseBracket, SigilOpenSquareBracket, SigilCloseSquareBracket, SigilOpenCurlyBracket, SigilCloseCurlyBracket, SigilHash, SigilDot, SigilComma, SigilDoubleDot, SigilAt, SigilSingleArrow, SigilQuote, OperatorAdd, OperatorSubtract, OperatorMultiply, OperatorDivide, OperatorUnion, OperatorIntersect, OperatorPowerXor, OperatorGreaterThan, OperatorLessThan, OperatorGreaterEqual, OperatorLessEqual, OperatorNear, OperatorEqual, OperatorNotEqual, OperatorAnd, OperatorOr, OperatorXor, OperatorNot, OperatorAssignment, Error(LexerError),
}
Expand description

Source token for µcad files

Variants§

§

SingleLineComment(Cow<'a, str>)

A single-line comment, starting with //

§

MultiLineComment(Cow<'a, str>)

A multi-line comment, starting with /* and ending with */

§

DocComment(Cow<'a, str>)

A doc-comment, starting with ///

§

KeywordMod

The mod keyword

§

KeywordPart

The part keyword

§

KeywordSketch

The sketch keyword

§

KeywordOp

The op keyword

§

KeywordFn

The fn keyword

§

KeywordIf

The if keyword

§

KeywordElse

The else keyword

§

KeywordUse

The use keyword

§

KeywordAs

The as keyword

§

KeywordReturn

The return keyword

§

KeywordPub

The pub keyword

§

KeywordConst

The const keyword

§

KeywordProp

The prop keyword

§

KeywordInit

The init keyword

§

Identifier(Cow<'a, str>)

An identifier, alphanumeric, starting with either an alpha character or a underscore

§

Unit(Cow<'a, str>)

A unit identifier

§

LiteralInt(Cow<'a, str>)

An integer literal

§

LiteralFloat(Cow<'a, str>)

A float literal

§

LiteralBool(bool)

A boolean literal

§

LiteralString(Cow<'a, str>)

A string literal

§

FormatStringStart

Double-quote indicating the start of a format string

§

FormatStringEnd

Double-quote indicating the end of a format string

§

StringContent(Cow<'a, str>)

Literal string content of a format string

§

Character(char)

Escaped character inside a format string

§

StringFormatOpen

The start of the format expression inside a format string

§

StringFormatClose

The end of the format expression inside a format string

§

StringFormatPrecision(Cow<'a, str>)

The precision specification of the format expression inside a format string

§

StringFormatWidth(Cow<'a, str>)

The width specification of the format expression inside a format string

§

SigilColon

The : symbol

§

SigilSemiColon

The ; symbol

§

SigilDoubleColon

The :: symbol

§

SigilOpenBracket

The ( symbol

§

SigilCloseBracket

The ) symbol

§

SigilOpenSquareBracket

The [ symbol

§

SigilCloseSquareBracket

The ] symbol

§

SigilOpenCurlyBracket

The { symbol

§

SigilCloseCurlyBracket

The } symbol

§

SigilHash

The # symbol

§

SigilDot

The . symbol

§

SigilComma

The , symbol

§

SigilDoubleDot

The .. symbol

§

SigilAt

The @ symbol

§

SigilSingleArrow

The -> symbol

§

SigilQuote

The " symbol

§

OperatorAdd

Add operator: +

§

OperatorSubtract

Subtract operator: -

§

OperatorMultiply

Multiply operator: -

§

OperatorDivide

Divide operator: /

§

OperatorUnion

Union operator: |

§

OperatorIntersect

Intersect operator: &

§

OperatorPowerXor

xor operator: ^

§

OperatorGreaterThan

Greater-than operator: >

§

OperatorLessThan

Less-than operator: <

§

OperatorGreaterEqual

Greater-or-equal operator: >=

§

OperatorLessEqual

Less-or-equal operator: <=

§

OperatorNear

Near operator: ~

§

OperatorEqual

Equal operator: ==

§

OperatorNotEqual

Not-equal operator: !=

§

OperatorAnd

And operator: and

§

OperatorOr

Or operator: or

§

OperatorXor

Xor operator: `xor’

§

OperatorNot

Not operator: !

§

OperatorAssignment

Assignment operator: =

§

Error(LexerError)

A lexer failure

When encountering an error, the lexer attempts to recover and continue emitting further tokens

Implementations§

Source§

impl Token<'_>

Source

pub fn into_owned(self) -> Token<'static>

Create an owned version of the token

Source

pub fn kind(&self) -> &'static str

Get a descriptive name or symbol for the token type

Source

pub fn is_error(&self) -> bool

Check if the token is an error

Trait Implementations§

Source§

impl<'a> Clone for Token<'a>

Source§

fn clone(&self) -> Token<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Token<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Token<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> PartialEq for Token<'a>

Source§

fn eq(&self, other: &Token<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> StructuralPartialEq for Token<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Token<'a>

§

impl<'a> RefUnwindSafe for Token<'a>

§

impl<'a> Send for Token<'a>

§

impl<'a> Sync for Token<'a>

§

impl<'a> Unpin for Token<'a>

§

impl<'a> UnwindSafe for Token<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

Source§

type Proj<U: 'src> = U

Source§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

Source§

impl<'p, T> Seq<'p, T> for T
where T: Clone,

Source§

type Item<'a> = &'a T where T: 'a

The item yielded by the iterator.
Source§

type Iter<'a> = Once<&'a T> where T: 'a

An iterator over the items within this container, by reference.
Source§

fn seq_iter(&self) -> <T as Seq<'p, T>>::Iter<'_>

Iterate over the elements of the container.
Source§

fn contains(&self, val: &T) -> bool
where T: PartialEq,

Check whether an item is contained within this sequence.
Source§

fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>
where 'p: 'b,

Convert an item of the sequence into a MaybeRef.
Source§

impl<T, S> SpanWrap<S> for T
where S: WrappingSpan<T>,

Source§

fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned

Invokes WrappingSpan::make_wrapped to wrap an AST node in a span.
Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> OrderedSeq<'_, T> for T
where T: Clone,