rustre_parser::lexer

Enum Token

Source
#[repr(u16)]
pub enum Token {
Show 174 variants Space = 0, Extern = 1, Unsafe = 2, And = 3, Arrow = 4, Assert = 5, Bar = 6, Bool = 7, CDots = 8, CloseBrace = 9, CloseBracket = 10, ClosePar = 11, CloseStaticPar = 12, Colon = 13, Comma = 14, Const = 15, Current = 16, Diese = 17, Div = 18, DoubleColon = 19, Dot = 20, Equal = 21, Else = 22, Enum = 23, False = 24, Function = 25, Gt = 26, Gte = 27, Hat = 28, IConst = 29, IConstAndCDots = 30, Ident = 31, If = 32, Impl = 33, Int = 34, Let = 35, Lt = 36, Lte = 37, Merge = 38, Minus = 39, Mod = 40, Neq = 41, Node = 42, Nor = 43, Not = 44, OpenBrace = 45, OpenBracket = 46, OpenPar = 47, OpenStaticPar = 48, Operator = 49, Or = 50, Percent = 51, Plus = 52, Power = 53, Pre = 54, FBy = 55, RConst = 56, Real = 57, Returns = 58, Semicolon = 59, Slash = 60, Star = 61, Step = 62, Struct = 63, Tel = 64, Then = 65, True = 66, Type = 67, Var = 68, When = 69, With = 70, Xor = 71, Model = 72, Package = 73, Needs = 74, Provides = 75, Uses = 76, Is = 77, Body = 78, End = 79, Include = 80, Str = 81, InlineComment = 82, Comment = 83, Error = 84, Root = 85, IncludeStatement = 86, PackageDeclNode = 87, PackageDeclBody = 88, PackageAliasNode = 89, UsesNode = 90, ProvidesListNode = 91, ProvidesNode = 92, ModelDeclNode = 93, IdRefNode = 94, IdNode = 95, PragmaNode = 96, TypedIdsNode = 97, TypedValuedLv6IdNode = 98, NodeNode = 99, NodeProfileNode = 100, ParamsNode = 101, VarDeclNode = 102, ConstantDeclNode = 103, OneConstantDeclNode = 104, TypeDeclNode = 105, OneTypeDeclNode = 106, EnumDeclNode = 107, StructDeclNode = 108, TypeNode = 109, ExternalNodeDeclNode = 110, StaticParamsNode = 111, StaticParamNode = 112, EffectiveNodeNode = 113, StaticArgsNode = 114, StaticArgNode = 115, NamedStaticArgsNode = 116, NamedStaticArgNode = 117, BodyNode = 118, AssertEquationNode = 119, EqualsEquationNode = 120, LeftNode = 121, LeftItemListNode = 122, LeftItemNode = 123, LeftFieldAccessNode = 124, LeftTableAccessNode = 125, SelectNode = 126, StepNode = 127, ExpressionNode = 128, ExpressionListNode = 129, ParExpressionNode = 130, ArrayLiteralExpressionNode = 131, IdentExpressionNode = 132, FbyExpressionNode = 133, CallByPosExpressionNode = 134, ArrayAccessExpressionNode = 135, HatExpressionNode = 136, FieldAccessExpressionNode = 137, NegExpressionNode = 138, PreExpressionNode = 139, CurrentExpressionNode = 140, DieseExpressionNode = 141, NorExpressionNode = 142, IntExpressionNode = 143, RealExpressionNode = 144, WhenExpressionNode = 145, PowerExpressionNode = 146, MulExpressionNode = 147, DivExpressionNode = 148, ModExpressionNode = 149, AddExpressionNode = 150, SubExpressionNode = 151, NotExpressionNode = 152, LtExpressionNode = 153, LteExpressionNode = 154, EqExpressionNode = 155, GteExpressionNode = 156, GtExpressionNode = 157, NeqExpressionNode = 158, AndExpressionNode = 159, OrExpressionNode = 160, XorExpressionNode = 161, ImplExpressionNode = 162, ArrowExpressionNode = 163, ConcatExpressionNode = 164, IfExpressionNode = 165, WithExpressionNode = 166, ClockExpressionNode = 167, MergeExpressionNode = 168, MergeCaseNode = 169, PredefOp = 170, CallByNameExpressionNode = 171, CallByNameParamNode = 172, ConstantNode = 173,
}
Expand description

A token

Variants§

§

Space = 0

Whitespace character

Includes: spaces, tabs, newlines, carriage returns, form feeds

§

Extern = 1

§

Unsafe = 2

§

And = 3

§

Arrow = 4

§

Assert = 5

§

Bar = 6

§

Bool = 7

§

CDots = 8

§

CloseBrace = 9

§

CloseBracket = 10

§

ClosePar = 11

§

CloseStaticPar = 12

§

Colon = 13

§

Comma = 14

§

Const = 15

§

Current = 16

§

Diese = 17

§

Div = 18

§

DoubleColon = 19

§

Dot = 20

§

Equal = 21

§

Else = 22

§

Enum = 23

§

False = 24

§

Function = 25

§

Gt = 26

§

Gte = 27

§

Hat = 28

§

IConst = 29

§

IConstAndCDots = 30

A very special case to handle an IConst directly followed by a .. (CDots) operator.

This specialization is important to be able to parse RConst properly, or else 1..2 would be parsed as 1. . 2 which is a syntax error and not what’s supposed to be parsed in the first place.

This weird trick of treating two tokens as one could be avoided if logos supported regex lookaheads, so RConst could reject a list of digits followed by 2 dots.

§

Ident = 31

§

If = 32

§

Impl = 33

§

Int = 34

§

Let = 35

§

Lt = 36

§

Lte = 37

§

Merge = 38

§

Minus = 39

§

Mod = 40

§

Neq = 41

§

Node = 42

§

Nor = 43

§

Not = 44

§

OpenBrace = 45

§

OpenBracket = 46

§

OpenPar = 47

§

OpenStaticPar = 48

§

Operator = 49

§

Or = 50

§

Percent = 51

§

Plus = 52

§

Power = 53

§

Pre = 54

§

FBy = 55

§

RConst = 56

Recognizes a floating-point literal

The regex is intentionally a bit greedy, but this gives room for better errors if the value is unparseable.

§

Real = 57

§

Returns = 58

§

Semicolon = 59

§

Slash = 60

§

Star = 61

§

Step = 62

§

Struct = 63

§

Tel = 64

§

Then = 65

§

True = 66

§

Type = 67

§

Var = 68

§

When = 69

§

With = 70

§

Xor = 71

§

Model = 72

§

Package = 73

§

Needs = 74

§

Provides = 75

§

Uses = 76

§

Is = 77

§

Body = 78

§

End = 79

§

Include = 80

§

Str = 81

§

InlineComment = 82

§

Comment = 83

§

Error = 84

§

Root = 85

§

IncludeStatement = 86

Children: Include + String

§

PackageDeclNode = 87

§

PackageDeclBody = 88

§

PackageAliasNode = 89

§

UsesNode = 90

§

ProvidesListNode = 91

§

ProvidesNode = 92

§

ModelDeclNode = 93

§

IdRefNode = 94

§

IdNode = 95

§

PragmaNode = 96

§

TypedIdsNode = 97

§

TypedValuedLv6IdNode = 98

§

NodeNode = 99

§

NodeProfileNode = 100

§

ParamsNode = 101

§

VarDeclNode = 102

§

ConstantDeclNode = 103

§

OneConstantDeclNode = 104

§

TypeDeclNode = 105

§

OneTypeDeclNode = 106

§

EnumDeclNode = 107

§

StructDeclNode = 108

§

TypeNode = 109

§

ExternalNodeDeclNode = 110

§

StaticParamsNode = 111

§

StaticParamNode = 112

§

EffectiveNodeNode = 113

§

StaticArgsNode = 114

§

StaticArgNode = 115

§

NamedStaticArgsNode = 116

§

NamedStaticArgNode = 117

§

BodyNode = 118

§

AssertEquationNode = 119

§

EqualsEquationNode = 120

§

LeftNode = 121

§

LeftItemListNode = 122

§

LeftItemNode = 123

§

LeftFieldAccessNode = 124

§

LeftTableAccessNode = 125

§

SelectNode = 126

§

StepNode = 127

§

ExpressionNode = 128

§

ExpressionListNode = 129

§

ParExpressionNode = 130

§

ArrayLiteralExpressionNode = 131

§

IdentExpressionNode = 132

§

FbyExpressionNode = 133

§

CallByPosExpressionNode = 134

§

ArrayAccessExpressionNode = 135

§

HatExpressionNode = 136

§

FieldAccessExpressionNode = 137

§

NegExpressionNode = 138

§

PreExpressionNode = 139

§

CurrentExpressionNode = 140

§

DieseExpressionNode = 141

§

NorExpressionNode = 142

§

IntExpressionNode = 143

§

RealExpressionNode = 144

§

WhenExpressionNode = 145

§

PowerExpressionNode = 146

§

MulExpressionNode = 147

§

DivExpressionNode = 148

§

ModExpressionNode = 149

§

AddExpressionNode = 150

§

SubExpressionNode = 151

§

NotExpressionNode = 152

§

LtExpressionNode = 153

§

LteExpressionNode = 154

§

EqExpressionNode = 155

§

GteExpressionNode = 156

§

GtExpressionNode = 157

§

NeqExpressionNode = 158

§

AndExpressionNode = 159

§

OrExpressionNode = 160

§

XorExpressionNode = 161

§

ImplExpressionNode = 162

§

ArrowExpressionNode = 163

§

ConcatExpressionNode = 164

§

IfExpressionNode = 165

§

WithExpressionNode = 166

§

ClockExpressionNode = 167

§

MergeExpressionNode = 168

§

MergeCaseNode = 169

§

PredefOp = 170

§

CallByNameExpressionNode = 171

§

CallByNameParamNode = 172

§

ConstantNode = 173

Implementations§

Source§

impl Token

Source

pub fn is_trivia(self) -> bool

Returns true if and only if a token is considered “trivia” (space or comment)

Source

pub fn is_non_trivia(self) -> bool

Returns true if and only if a token is not considered “trivia” (space or comment)

Most tokens are not trivia.

Trait Implementations§

Source§

impl Clone for Token

Source§

fn clone(&self) -> Token

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 Token

Source§

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

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

impl From<Token> for SyntaxKind

Source§

fn from(tok: Token) -> Self

Converts to this type from the input type.
Source§

impl Hash for Token

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<'s> Logos<'s> for Token

Source§

type Error = ()

Error type returned by the lexer. This can be set using #[logos(error = MyError)]. Defaults to () if not set.
Source§

type Extras = ()

Associated type Extras for the particular lexer. This can be set using #[logos(extras = MyExtras)] and accessed inside callbacks.
Source§

type Source = str

Source type this token can be lexed from. This will default to str, unless one of the defined patterns explicitly uses non-unicode byte values or byte slices, in which case that implementation will use [u8].
Source§

fn lex(lex: &mut Lexer<'s, Self>)

The heart of Logos. Called by the Lexer. The implementation for this function is generated by the logos-derive crate.
Source§

fn lexer(source: &'source Self::Source) -> Lexer<'source, Self>
where Self::Extras: Default,

Create a new instance of a Lexer that will produce tokens implementing this Logos.
Source§

fn lexer_with_extras( source: &'source Self::Source, extras: Self::Extras, ) -> Lexer<'source, Self>

Create a new instance of a Lexer with the provided Extras that will produce tokens implementing this Logos.
Source§

impl Ord for Token

Source§

fn cmp(&self, other: &Token) -> 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 Ordinalize for Token

Source§

const VARIANT_COUNT: usize = 174usize

The count of variants.
Source§

const VARIANTS: &'static [Self] = _

List of this enum’s variants.
Source§

const VALUES: &'static [u16] = _

List of values for all variants of this enum.
Source§

type VariantType = u16

The type of the values of the variants.
Source§

fn ordinal(&self) -> u16

Retrieve the integer number of this variant.
Source§

unsafe fn from_ordinal_unsafe(number: u16) -> Self

Obtain a variant based on an integer number. Read more
Source§

fn from_ordinal(number: u16) -> Option<Self>

Obtain a variant based on an integer number.
Source§

impl PartialEq for Token

Source§

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

Source§

fn partial_cmp(&self, other: &Token) -> 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 Token

Source§

impl Eq for Token

Source§

impl StructuralPartialEq for Token

Auto Trait Implementations§

§

impl Freeze for Token

§

impl RefUnwindSafe for Token

§

impl Send for Token

§

impl Sync for Token

§

impl Unpin for Token

§

impl UnwindSafe for Token

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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

Checks if this value is equivalent to the given key. 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, 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.