Skip to main content

TokenKind

Enum TokenKind 

Source
#[non_exhaustive]
#[repr(u8)]
pub enum TokenKind {
Show 54 variants Whitespace = 0, Comment = 1, BareWord = 2, Number = 3, StringLiteral = 4, QuotedIdentifier = 5, OpeningRoundBracket = 6, ClosingRoundBracket = 7, OpeningSquareBracket = 8, ClosingSquareBracket = 9, OpeningCurlyBrace = 10, ClosingCurlyBrace = 11, Comma = 12, Semicolon = 13, VerticalDelimiter = 14, Dot = 15, Asterisk = 16, HereDoc = 17, DollarSign = 18, Plus = 19, Minus = 20, Slash = 21, Percent = 22, Arrow = 23, QuestionMark = 24, Colon = 25, Caret = 26, DoubleColon = 27, Equals = 28, NotEquals = 29, Less = 30, Greater = 31, LessOrEquals = 32, GreaterOrEquals = 33, Spaceship = 34, PipeMark = 35, PipeOperator = 36, Concatenation = 37, Tilde = 38, TildeAsterisk = 39, NotTilde = 40, NotTildeAsterisk = 41, At = 42, DoubleAt = 43, EndOfStream = 44, Error = 45, ErrorMultilineCommentIsNotClosed = 46, ErrorSingleQuoteIsNotClosed = 47, ErrorDoubleQuoteIsNotClosed = 48, ErrorBackQuoteIsNotClosed = 49, ErrorSingleExclamationMark = 50, ErrorSinglePipeMark = 51, ErrorWrongNumber = 52, ErrorMaxQuerySizeExceeded = 53,
}
Expand description

The TokenType enum of ClickHouse’s src/Parsers/Lexer.h, in the same order.

The discriminants are positional and only valid together with the lexer compiled from the same revision, which is what this crate guarantees. Upstream may add variants in a patch release, hence non_exhaustive.

Variants (Non-exhaustive)§

This enum is marked as 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.
§

Whitespace = 0

§

Comment = 1

§

BareWord = 2

Either keyword (SELECT) or identifier (column)

§

Number = 3

Always non-negative. No leading plus. 123 or something like 123.456e12, 0x123p12

§

StringLiteral = 4

‘hello word’, ‘hello’‘word’, ‘hello'word\’

§

QuotedIdentifier = 5

“x”, x

§

OpeningRoundBracket = 6

§

ClosingRoundBracket = 7

§

OpeningSquareBracket = 8

§

ClosingSquareBracket = 9

§

OpeningCurlyBrace = 10

§

ClosingCurlyBrace = 11

§

Comma = 12

§

Semicolon = 13

§

VerticalDelimiter = 14

Vertical delimiter \G

§

Dot = 15

Compound identifiers, like a.b or tuple access operator a.1, (x, y).2.

§

Asterisk = 16

Need to be distinguished from floating point number with omitted integer part: .1 Could be used as multiplication operator or on it’s own: “SELECT *”

§

HereDoc = 17

§

DollarSign = 18

§

Plus = 19

§

Minus = 20

§

Slash = 21

§

Percent = 22

§

Arrow = 23

->. Should be distinguished from minus operator.

§

QuestionMark = 24

§

Colon = 25

§

Caret = 26

§

DoubleColon = 27

§

Equals = 28

§

NotEquals = 29

§

Less = 30

§

Greater = 31

§

LessOrEquals = 32

§

GreaterOrEquals = 33

§

Spaceship = 34

<=>. Used in MySQL for NULL-safe equality comparison.

§

PipeMark = 35

§

PipeOperator = 36

|>. Pipe operator: FROM t |> WHERE x |> SELECT y

§

Concatenation = 37

String concatenation operator: ||

§

Tilde = 38

~. Used in PostgreSQL as the regular expression match operator.

§

TildeAsterisk = 39

~*. Used in PostgreSQL as the case-insensitive regular expression match operator.

§

NotTilde = 40

!~. Used in PostgreSQL as the regular expression not-match operator.

§

NotTildeAsterisk = 41

!~*. Used in PostgreSQL as the case-insensitive regular expression not-match operator.

§

At = 42

@. Used for specifying user names and also for MySQL-style variables.

§

DoubleAt = 43

@@. Used for MySQL-style global variables.

§

EndOfStream = 44

Order is important. EndOfStream goes after all usual tokens, and special error tokens goes after EndOfStream.

§

Error = 45

Something unrecognized.

§

ErrorMultilineCommentIsNotClosed = 46

Something is wrong and we have more information.

§

ErrorSingleQuoteIsNotClosed = 47

§

ErrorDoubleQuoteIsNotClosed = 48

§

ErrorBackQuoteIsNotClosed = 49

§

ErrorSingleExclamationMark = 50

§

ErrorSinglePipeMark = 51

§

ErrorWrongNumber = 52

§

ErrorMaxQuerySizeExceeded = 53

Implementations§

Source§

impl TokenKind

Source

pub const ALL: &'static [TokenKind]

Every kind, in discriminant order.

Source

pub fn from_raw(raw: u8) -> Option<TokenKind>

The kind with this discriminant, as returned by the C API.

Source

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

The upstream enum variant name, e.g. "BareWord".

Source§

impl TokenKind

Source

pub fn is_significant(self) -> bool

Neither whitespace nor a comment.

Source

pub fn is_error(self) -> bool

One of the Error* kinds, which end lexing.

Source

pub fn is_end(self) -> bool

EndOfStream.

Trait Implementations§

Source§

impl Clone for TokenKind

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for TokenKind

Source§

impl Debug for TokenKind

Source§

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

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

impl Display for TokenKind

Source§

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

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

impl Eq for TokenKind

Source§

impl Hash for TokenKind

Source§

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

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: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

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

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

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for TokenKind

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialOrd for TokenKind

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 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<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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.