Skip to main content

TokenKind

Enum TokenKind 

Source
pub enum TokenKind {
Show 107 variants Name, Int, Float, Complex, String, FStringStart, FStringMiddle, FStringEnd, TStringStart, TStringMiddle, TStringEnd, IpyEscapeCommand, Comment, Newline, NonLogicalNewline, Indent, Dedent, EndOfFile, Question, Exclamation, Lpar, Rpar, Lsqb, Rsqb, Colon, Comma, Semi, Plus, Minus, Star, Slash, Vbar, Amper, Less, Greater, Equal, Dot, Percent, Lbrace, Rbrace, EqEqual, NotEqual, LessEqual, GreaterEqual, Tilde, CircumFlex, LeftShift, RightShift, DoubleStar, DoubleStarEqual, PlusEqual, MinusEqual, StarEqual, SlashEqual, PercentEqual, AmperEqual, VbarEqual, CircumflexEqual, LeftShiftEqual, RightShiftEqual, DoubleSlash, DoubleSlashEqual, ColonEqual, At, AtEqual, Rarrow, Ellipsis, And, As, Assert, Async, Await, Break, Class, Continue, Def, Del, Elif, Else, Except, False, Finally, For, From, Global, If, Import, In, Is, Lambda, None, Nonlocal, Not, Or, Pass, Raise, Return, True, Try, While, With, Yield, Case, Lazy, Match, Type, Unknown,
}
Expand description

A kind of a token.

Variants§

§

Name

Token kind for a name, commonly known as an identifier.

§

Int

Token kind for an integer.

§

Float

Token kind for a floating point number.

§

Complex

Token kind for a complex number.

§

String

Token kind for a string.

§

FStringStart

Token kind for the start of an f-string. This includes the f/F/fr prefix and the opening quote(s).

§

FStringMiddle

Token kind that includes the portion of text inside the f-string that’s not part of the expression part and isn’t an opening or closing brace.

§

FStringEnd

Token kind for the end of an f-string. This includes the closing quote.

§

TStringStart

Token kind for the start of a t-string. This includes the t/T/tr prefix and the opening quote(s).

§

TStringMiddle

Token kind that includes the portion of text inside the t-string that’s not part of the interpolation part and isn’t an opening or closing brace.

§

TStringEnd

Token kind for the end of a t-string. This includes the closing quote.

§

IpyEscapeCommand

Token kind for a IPython escape command.

§

Comment

Token kind for a comment. These are filtered out of the token stream prior to parsing.

§

Newline

Token kind for a newline.

§

NonLogicalNewline

Token kind for a newline that is not a logical line break. These are filtered out of the token stream prior to parsing.

§

Indent

Token kind for an indent.

§

Dedent

Token kind for a dedent.

§

EndOfFile

§

Question

Token kind for a question mark ?.

§

Exclamation

Token kind for an exclamation mark !.

§

Lpar

Token kind for a left parenthesis (.

§

Rpar

Token kind for a right parenthesis ).

§

Lsqb

Token kind for a left square bracket [.

§

Rsqb

Token kind for a right square bracket ].

§

Colon

Token kind for a colon :.

§

Comma

Token kind for a comma ,.

§

Semi

Token kind for a semicolon ;.

§

Plus

Token kind for plus +.

§

Minus

Token kind for minus -.

§

Star

Token kind for star *.

§

Slash

Token kind for slash /.

§

Vbar

Token kind for vertical bar |.

§

Amper

Token kind for ampersand &.

§

Less

Token kind for less than <.

§

Greater

Token kind for greater than >.

§

Equal

Token kind for equal =.

§

Dot

Token kind for dot ..

§

Percent

Token kind for percent %.

§

Lbrace

Token kind for left bracket {.

§

Rbrace

Token kind for right bracket }.

§

EqEqual

Token kind for double equal ==.

§

NotEqual

Token kind for not equal !=.

§

LessEqual

Token kind for less than or equal <=.

§

GreaterEqual

Token kind for greater than or equal >=.

§

Tilde

Token kind for tilde ~.

§

CircumFlex

Token kind for caret ^.

§

LeftShift

Token kind for left shift <<.

§

RightShift

Token kind for right shift >>.

§

DoubleStar

Token kind for double star **.

§

DoubleStarEqual

Token kind for double star equal **=.

§

PlusEqual

Token kind for plus equal +=.

§

MinusEqual

Token kind for minus equal -=.

§

StarEqual

Token kind for star equal *=.

§

SlashEqual

Token kind for slash equal /=.

§

PercentEqual

Token kind for percent equal %=.

§

AmperEqual

Token kind for ampersand equal &=.

§

VbarEqual

Token kind for vertical bar equal |=.

§

CircumflexEqual

Token kind for caret equal ^=.

§

LeftShiftEqual

Token kind for left shift equal <<=.

§

RightShiftEqual

Token kind for right shift equal >>=.

§

DoubleSlash

Token kind for double slash //.

§

DoubleSlashEqual

Token kind for double slash equal //=.

§

ColonEqual

Token kind for colon equal :=.

§

At

Token kind for at @.

§

AtEqual

Token kind for at equal @=.

§

Rarrow

Token kind for arrow ->.

§

Ellipsis

Token kind for ellipsis ....

§

And

§

As

§

Assert

§

Async

§

Await

§

Break

§

Class

§

Continue

§

Def

§

Del

§

Elif

§

Else

§

Except

§

False

§

Finally

§

For

§

From

§

Global

§

If

§

Import

§

In

§

Is

§

Lambda

§

None

§

Nonlocal

§

Not

§

Or

§

Pass

§

Raise

§

Return

§

True

§

Try

§

While

§

With

§

Yield

§

Case

§

Lazy

§

Match

§

Type

§

Unknown

Implementations§

Source§

impl TokenKind

Source

pub const fn is_eof(self) -> bool

Returns true if this is an end of file token.

Source

pub const fn is_any_newline(self) -> bool

Returns true if this is either a newline or non-logical newline token.

Source

pub fn is_keyword(self) -> bool

Returns true if the token is a keyword (including soft keywords).

See also is_soft_keyword, is_non_soft_keyword.

Source

pub fn is_soft_keyword(self) -> bool

Returns true if the token is strictly a soft keyword.

See also is_keyword, is_non_soft_keyword.

Source

pub fn is_non_soft_keyword(self) -> bool

Returns true if the token is strictly a non-soft keyword.

See also is_keyword, is_soft_keyword.

Source

pub const fn is_operator(self) -> bool

Source

pub const fn is_singleton(self) -> bool

Returns true if this is a singleton token i.e., True, False, or None.

Source

pub const fn is_trivia(&self) -> bool

Returns true if this is a trivia token i.e., a comment or a non-logical newline.

Source

pub const fn is_comment(&self) -> bool

Returns true if this is a comment token.

Source

pub const fn is_arithmetic(self) -> bool

Source

pub const fn is_bitwise_or_shift(self) -> bool

Source

pub const fn is_unary_arithmetic_operator(self) -> bool

Returns true if the current token is a unary arithmetic operator.

Source

pub const fn is_interpolated_string_end(self) -> bool

Source

pub const fn as_unary_arithmetic_operator(self) -> Option<UnaryOp>

Returns the UnaryOp that corresponds to this token kind, if it is a unary arithmetic operator, otherwise return None.

Use as_unary_operator to match against any unary operator.

Source

pub const fn as_unary_operator(self) -> Option<UnaryOp>

Returns the UnaryOp that corresponds to this token kind, if it is a unary operator, otherwise return None.

Use as_unary_arithmetic_operator to match against only an arithmetic unary operator.

Source

pub const fn as_bool_operator(self) -> Option<BoolOp>

Returns the BoolOp that corresponds to this token kind, if it is a boolean operator, otherwise return None.

Source

pub const fn as_binary_operator(self) -> Option<Operator>

Returns the binary Operator that corresponds to the current token, if it’s a binary operator, otherwise return None.

Use as_augmented_assign_operator to match against an augmented assignment token.

Source

pub const fn as_augmented_assign_operator(self) -> Option<Operator>

Returns the Operator that corresponds to this token kind, if it is an augmented assignment operator, or None otherwise.

Trait Implementations§

Source§

impl Clone for TokenKind

Source§

fn clone(&self) -> TokenKind

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 Debug for TokenKind

Source§

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

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

impl Display for TokenKind

Source§

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

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

impl From<BoolOp> for TokenKind

Source§

fn from(op: BoolOp) -> TokenKind

Converts to this type from the input type.
Source§

impl From<Operator> for TokenKind

Source§

fn from(op: Operator) -> TokenKind

Converts to this type from the input type.
Source§

impl From<UnaryOp> for TokenKind

Source§

fn from(op: UnaryOp) -> TokenKind

Converts to this type from the input type.
Source§

impl GetSize for TokenKind

Source§

fn get_heap_size(&self) -> usize

Determines how many bytes this object occupies inside the heap. Read more
Source§

fn get_heap_size_with_tracker<TRACKER>( &self, tracker: TRACKER, ) -> (usize, TRACKER)
where TRACKER: GetSizeTracker,

Determines how many bytes this object occupies inside the heap while using a tracker. Read more
Source§

fn get_stack_size() -> usize

Determines how may bytes this object occupies inside the stack. Read more
Source§

fn get_size(&self) -> usize

Determines the total size of the object. Read more
Source§

fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)
where T: GetSizeTracker,

Determines the total size of the object while using a tracker. Read more
Source§

impl Hash for TokenKind

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for TokenKind

Source§

fn cmp(&self, other: &TokenKind) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for TokenKind

Source§

fn eq(&self, other: &TokenKind) -> 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 PartialOrd for TokenKind

Source§

fn partial_cmp(&self, other: &TokenKind) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for TokenKind

Source§

impl Eq for TokenKind

Source§

impl StructuralPartialEq for TokenKind

Auto Trait Implementations§

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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

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

Source§

fn exact_from(value: T) -> U

Source§

impl<T, U> ExactInto<U> for T
where U: ExactFrom<T>,

Source§

fn exact_into(self) -> U

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<T, U> OverflowingInto<U> for T
where U: OverflowingFrom<T>,

Source§

impl<T, U> RoundingInto<U> for T
where U: RoundingFrom<T>,

Source§

impl<T, U> SaturatingInto<U> for T
where U: SaturatingFrom<T>,

Source§

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

Source§

impl<T> ToDebugString for T
where T: Debug,

Source§

fn to_debug_string(&self) -> String

Returns the String produced by Ts Debug implementation.

§Examples
use malachite_base::strings::ToDebugString;

assert_eq!([1, 2, 3].to_debug_string(), "[1, 2, 3]");
assert_eq!(
    [vec![2, 3], vec![], vec![4]].to_debug_string(),
    "[[2, 3], [], [4]]"
);
assert_eq!(Some(5).to_debug_string(), "Some(5)");
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, U> WrappingInto<U> for T
where U: WrappingFrom<T>,

Source§

fn wrapping_into(self) -> U

Source§

impl<T> PyThreadingConstraint for T