pub enum Tok {
Show 97 variants Name { name: String, }, Int { value: BigInt, }, Float { value: f64, }, Complex { real: f64, imag: f64, }, String { value: String, kind: StringKind, triple_quoted: bool, }, Newline, Indent, Dedent, EndOfFile, 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, False, None, True, And, As, Assert, Async, Await, Break, Class, Continue, Def, Del, Elif, Else, Except, Finally, For, From, Global, If, Import, In, Is, Lambda, Nonlocal, Not, Or, Pass, Raise, Return, Try, While, Match, Type, Case, With, Yield, StartModule, StartInteractive, StartExpression,
}
Expand description

The set of tokens the Python source code can be tokenized in.

Variants§

§

Name

Fields

§name: String

The name value.

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

§

Int

Fields

§value: BigInt

The integer value.

Token value for an integer.

§

Float

Fields

§value: f64

The float value.

Token value for a floating point number.

§

Complex

Fields

§real: f64

The real part of the complex number.

§imag: f64

The imaginary part of the complex number.

Token value for a complex number.

§

String

Fields

§value: String

The string value.

§kind: StringKind

The kind of string.

§triple_quoted: bool

Whether the string is triple quoted.

Token value for a string.

§

Newline

Token value for a newline.

§

Indent

Token value for an indent.

§

Dedent

Token value for a dedent.

§

EndOfFile

§

Lpar

Token value for a left parenthesis (.

§

Rpar

Token value for a right parenthesis ).

§

Lsqb

Token value for a left square bracket [.

§

Rsqb

Token value for a right square bracket ].

§

Colon

Token value for a colon :.

§

Comma

Token value for a comma ,.

§

Semi

Token value for a semicolon ;.

§

Plus

Token value for plus +.

§

Minus

Token value for minus -.

§

Star

Token value for star *.

§

Slash

Token value for slash /.

§

Vbar

Token value for vertical bar |.

§

Amper

Token value for ampersand &.

§

Less

Token value for less than <.

§

Greater

Token value for greater than >.

§

Equal

Token value for equal =.

§

Dot

Token value for dot ..

§

Percent

Token value for percent %.

§

Lbrace

Token value for left bracket {.

§

Rbrace

Token value for right bracket }.

§

EqEqual

Token value for double equal ==.

§

NotEqual

Token value for not equal !=.

§

LessEqual

Token value for less than or equal <=.

§

GreaterEqual

Token value for greater than or equal >=.

§

Tilde

Token value for tilde ~.

§

CircumFlex

Token value for caret ^.

§

LeftShift

Token value for left shift <<.

§

RightShift

Token value for right shift >>.

§

DoubleStar

Token value for double star **.

§

DoubleStarEqual

Token value for double star equal **=.

§

PlusEqual

Token value for plus equal +=.

§

MinusEqual

Token value for minus equal -=.

§

StarEqual

Token value for star equal *=.

§

SlashEqual

Token value for slash equal /=.

§

PercentEqual

Token value for percent equal %=.

§

AmperEqual

Token value for ampersand equal &=.

§

VbarEqual

Token value for vertical bar equal |=.

§

CircumflexEqual

Token value for caret equal ^=.

§

LeftShiftEqual

Token value for left shift equal <<=.

§

RightShiftEqual

Token value for right shift equal >>=.

§

DoubleSlash

Token value for double slash //.

§

DoubleSlashEqual

Token value for double slash equal //=.

§

ColonEqual

Token value for colon equal :=.

§

At

Token value for at @.

§

AtEqual

Token value for at equal @=.

§

Rarrow

Token value for arrow ->.

§

Ellipsis

Token value for ellipsis ....

§

False

§

None

§

True

§

And

§

As

§

Assert

§

Async

§

Await

§

Break

§

Class

§

Continue

§

Def

§

Del

§

Elif

§

Else

§

Except

§

Finally

§

For

§

From

§

Global

§

If

§

Import

§

In

§

Is

§

Lambda

§

Nonlocal

§

Not

§

Or

§

Pass

§

Raise

§

Return

§

Try

§

While

§

Match

§

Type

§

Case

§

With

§

Yield

§

StartModule

§

StartInteractive

§

StartExpression

Implementations§

source§

impl Tok

source

pub const fn is_name(&self) -> bool

Returns true if self is of variant Name.

source

pub const fn is_int(&self) -> bool

Returns true if self is of variant Int.

source

pub const fn is_float(&self) -> bool

Returns true if self is of variant Float.

source

pub const fn is_complex(&self) -> bool

Returns true if self is of variant Complex.

source

pub const fn is_string(&self) -> bool

Returns true if self is of variant String.

source

pub const fn is_newline(&self) -> bool

Returns true if self is of variant Newline.

source

pub const fn is_indent(&self) -> bool

Returns true if self is of variant Indent.

source

pub const fn is_dedent(&self) -> bool

Returns true if self is of variant Dedent.

source

pub const fn is_end_of_file(&self) -> bool

Returns true if self is of variant EndOfFile.

source

pub const fn is_lpar(&self) -> bool

Returns true if self is of variant Lpar.

source

pub const fn is_rpar(&self) -> bool

Returns true if self is of variant Rpar.

source

pub const fn is_lsqb(&self) -> bool

Returns true if self is of variant Lsqb.

source

pub const fn is_rsqb(&self) -> bool

Returns true if self is of variant Rsqb.

source

pub const fn is_colon(&self) -> bool

Returns true if self is of variant Colon.

source

pub const fn is_comma(&self) -> bool

Returns true if self is of variant Comma.

source

pub const fn is_semi(&self) -> bool

Returns true if self is of variant Semi.

source

pub const fn is_plus(&self) -> bool

Returns true if self is of variant Plus.

source

pub const fn is_minus(&self) -> bool

Returns true if self is of variant Minus.

source

pub const fn is_star(&self) -> bool

Returns true if self is of variant Star.

source

pub const fn is_slash(&self) -> bool

Returns true if self is of variant Slash.

source

pub const fn is_vbar(&self) -> bool

Returns true if self is of variant Vbar.

source

pub const fn is_amper(&self) -> bool

Returns true if self is of variant Amper.

source

pub const fn is_less(&self) -> bool

Returns true if self is of variant Less.

source

pub const fn is_greater(&self) -> bool

Returns true if self is of variant Greater.

source

pub const fn is_equal(&self) -> bool

Returns true if self is of variant Equal.

source

pub const fn is_dot(&self) -> bool

Returns true if self is of variant Dot.

source

pub const fn is_percent(&self) -> bool

Returns true if self is of variant Percent.

source

pub const fn is_lbrace(&self) -> bool

Returns true if self is of variant Lbrace.

source

pub const fn is_rbrace(&self) -> bool

Returns true if self is of variant Rbrace.

source

pub const fn is_eq_equal(&self) -> bool

Returns true if self is of variant EqEqual.

source

pub const fn is_not_equal(&self) -> bool

Returns true if self is of variant NotEqual.

source

pub const fn is_less_equal(&self) -> bool

Returns true if self is of variant LessEqual.

source

pub const fn is_greater_equal(&self) -> bool

Returns true if self is of variant GreaterEqual.

source

pub const fn is_tilde(&self) -> bool

Returns true if self is of variant Tilde.

source

pub const fn is_circum_flex(&self) -> bool

Returns true if self is of variant CircumFlex.

source

pub const fn is_left_shift(&self) -> bool

Returns true if self is of variant LeftShift.

source

pub const fn is_right_shift(&self) -> bool

Returns true if self is of variant RightShift.

source

pub const fn is_double_star(&self) -> bool

Returns true if self is of variant DoubleStar.

source

pub const fn is_double_star_equal(&self) -> bool

Returns true if self is of variant DoubleStarEqual.

source

pub const fn is_plus_equal(&self) -> bool

Returns true if self is of variant PlusEqual.

source

pub const fn is_minus_equal(&self) -> bool

Returns true if self is of variant MinusEqual.

source

pub const fn is_star_equal(&self) -> bool

Returns true if self is of variant StarEqual.

source

pub const fn is_slash_equal(&self) -> bool

Returns true if self is of variant SlashEqual.

source

pub const fn is_percent_equal(&self) -> bool

Returns true if self is of variant PercentEqual.

source

pub const fn is_amper_equal(&self) -> bool

Returns true if self is of variant AmperEqual.

source

pub const fn is_vbar_equal(&self) -> bool

Returns true if self is of variant VbarEqual.

source

pub const fn is_circumflex_equal(&self) -> bool

Returns true if self is of variant CircumflexEqual.

source

pub const fn is_left_shift_equal(&self) -> bool

Returns true if self is of variant LeftShiftEqual.

source

pub const fn is_right_shift_equal(&self) -> bool

Returns true if self is of variant RightShiftEqual.

source

pub const fn is_double_slash(&self) -> bool

Returns true if self is of variant DoubleSlash.

source

pub const fn is_double_slash_equal(&self) -> bool

Returns true if self is of variant DoubleSlashEqual.

source

pub const fn is_colon_equal(&self) -> bool

Returns true if self is of variant ColonEqual.

source

pub const fn is_at(&self) -> bool

Returns true if self is of variant At.

source

pub const fn is_at_equal(&self) -> bool

Returns true if self is of variant AtEqual.

source

pub const fn is_rarrow(&self) -> bool

Returns true if self is of variant Rarrow.

source

pub const fn is_ellipsis(&self) -> bool

Returns true if self is of variant Ellipsis.

source

pub const fn is_false(&self) -> bool

Returns true if self is of variant False.

source

pub const fn is_none(&self) -> bool

Returns true if self is of variant None.

source

pub const fn is_true(&self) -> bool

Returns true if self is of variant True.

source

pub const fn is_and(&self) -> bool

Returns true if self is of variant And.

source

pub const fn is_as(&self) -> bool

Returns true if self is of variant As.

source

pub const fn is_assert(&self) -> bool

Returns true if self is of variant Assert.

source

pub const fn is_async(&self) -> bool

Returns true if self is of variant Async.

source

pub const fn is_await(&self) -> bool

Returns true if self is of variant Await.

source

pub const fn is_break(&self) -> bool

Returns true if self is of variant Break.

source

pub const fn is_class(&self) -> bool

Returns true if self is of variant Class.

source

pub const fn is_continue(&self) -> bool

Returns true if self is of variant Continue.

source

pub const fn is_def(&self) -> bool

Returns true if self is of variant Def.

source

pub const fn is_del(&self) -> bool

Returns true if self is of variant Del.

source

pub const fn is_elif(&self) -> bool

Returns true if self is of variant Elif.

source

pub const fn is_else(&self) -> bool

Returns true if self is of variant Else.

source

pub const fn is_except(&self) -> bool

Returns true if self is of variant Except.

source

pub const fn is_finally(&self) -> bool

Returns true if self is of variant Finally.

source

pub const fn is_for(&self) -> bool

Returns true if self is of variant For.

source

pub const fn is_from(&self) -> bool

Returns true if self is of variant From.

source

pub const fn is_global(&self) -> bool

Returns true if self is of variant Global.

source

pub const fn is_if(&self) -> bool

Returns true if self is of variant If.

source

pub const fn is_import(&self) -> bool

Returns true if self is of variant Import.

source

pub const fn is_in(&self) -> bool

Returns true if self is of variant In.

source

pub const fn is_is(&self) -> bool

Returns true if self is of variant Is.

source

pub const fn is_lambda(&self) -> bool

Returns true if self is of variant Lambda.

source

pub const fn is_nonlocal(&self) -> bool

Returns true if self is of variant Nonlocal.

source

pub const fn is_not(&self) -> bool

Returns true if self is of variant Not.

source

pub const fn is_or(&self) -> bool

Returns true if self is of variant Or.

source

pub const fn is_pass(&self) -> bool

Returns true if self is of variant Pass.

source

pub const fn is_raise(&self) -> bool

Returns true if self is of variant Raise.

source

pub const fn is_return(&self) -> bool

Returns true if self is of variant Return.

source

pub const fn is_try(&self) -> bool

Returns true if self is of variant Try.

source

pub const fn is_while(&self) -> bool

Returns true if self is of variant While.

source

pub const fn is_match(&self) -> bool

Returns true if self is of variant Match.

source

pub const fn is_type(&self) -> bool

Returns true if self is of variant Type.

source

pub const fn is_case(&self) -> bool

Returns true if self is of variant Case.

source

pub const fn is_with(&self) -> bool

Returns true if self is of variant With.

source

pub const fn is_yield(&self) -> bool

Returns true if self is of variant Yield.

source

pub const fn is_start_module(&self) -> bool

Returns true if self is of variant StartModule.

source

pub const fn is_start_interactive(&self) -> bool

Returns true if self is of variant StartInteractive.

source

pub const fn is_start_expression(&self) -> bool

Returns true if self is of variant StartExpression.

source§

impl Tok

source

pub fn start_marker(mode: Mode) -> Self

Trait Implementations§

source§

impl Clone for Tok

source§

fn clone(&self) -> Tok

Returns a copy 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 Tok

source§

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

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

impl Display for Tok

source§

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

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

impl PartialEq<Tok> for Tok

source§

fn eq(&self, other: &Tok) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for Tok

Auto Trait Implementations§

§

impl RefUnwindSafe for Tok

§

impl Send for Tok

§

impl Sync for Tok

§

impl Unpin for Tok

§

impl UnwindSafe for Tok

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

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

§

fn exact_from(value: T) -> U

§

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

§

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 Twhere 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.

§

impl<T, U> OverflowingInto<U> for Twhere U: OverflowingFrom<T>,

§

fn overflowing_into(self) -> (U, bool)

§

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

§

fn rounding_into(self, rm: RoundingMode) -> U

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
§

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

§

fn saturating_into(self) -> U

§

impl<T> ToDebugString for Twhere T: Debug,

§

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 Twhere T: Clone,

§

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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

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

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

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T, U> WrappingInto<U> for Twhere U: WrappingFrom<T>,

§

fn wrapping_into(self) -> U