Enum leo_parser::tokenizer::token::Token
source · pub enum Token {
Show 109 variants
CommentLine(String),
CommentBlock(String),
WhiteSpace,
True,
False,
Integer(String),
AddressLit(String),
StaticString(String),
Identifier(Symbol),
Not,
And,
AndAssign,
Or,
OrAssign,
BitAnd,
BitAndAssign,
BitOr,
BitOrAssign,
BitXor,
BitXorAssign,
Eq,
NotEq,
Lt,
LtEq,
Gt,
GtEq,
Add,
AddAssign,
Sub,
SubAssign,
Mul,
MulAssign,
Div,
DivAssign,
Pow,
PowAssign,
Rem,
RemAssign,
Shl,
ShlAssign,
Shr,
ShrAssign,
Assign,
LeftParen,
RightParen,
LeftSquare,
RightSquare,
LeftCurly,
RightCurly,
Comma,
Dot,
DotDot,
Semicolon,
Colon,
DoubleColon,
Question,
Arrow,
BigArrow,
Underscore,
At,
Address,
Bool,
Field,
Group,
I8,
I16,
I32,
I64,
I128,
Record,
Scalar,
Signature,
String,
Struct,
U8,
U16,
U32,
U64,
U128,
Aleo,
As,
Assert,
AssertEq,
AssertNeq,
Async,
Block,
Console,
Const,
Constant,
Else,
Fn,
For,
Function,
Future,
If,
Import,
In,
Inline,
Let,
Mapping,
Network,
Private,
Program,
Public,
Return,
SelfLower,
Transition,
Eof,
Leo,
}
Expand description
Represents all valid Leo syntax tokens.
The notion of ‘token’ here is a bit more general than in the ABNF grammar: since it includes comments and whitespace, it corresponds to the notion of ‘lexeme’ in the ABNF grammar. There are also a few other differences, noted in comments below.
Variants§
CommentLine(String)
CommentBlock(String)
WhiteSpace
True
False
Integer(String)
AddressLit(String)
StaticString(String)
Identifier(Symbol)
Not
And
AndAssign
Or
OrAssign
BitAnd
BitAndAssign
BitOr
BitOrAssign
BitXor
BitXorAssign
Eq
NotEq
Lt
LtEq
Gt
GtEq
Add
AddAssign
Sub
SubAssign
Mul
MulAssign
Div
DivAssign
Pow
PowAssign
Rem
RemAssign
Shl
ShlAssign
Shr
ShrAssign
Assign
LeftParen
RightParen
LeftSquare
RightSquare
LeftCurly
RightCurly
Comma
Dot
DotDot
Semicolon
Colon
DoubleColon
Question
Arrow
BigArrow
Underscore
At
Address
Bool
Field
Group
I8
I16
I32
I64
I128
Record
Scalar
Signature
String
Struct
U8
U16
U32
U64
U128
Aleo
As
Assert
AssertEq
AssertNeq
Async
Block
Console
Const
Constant
Else
Fn
For
Function
Future
If
Import
In
Inline
Let
Mapping
Network
Private
Program
Public
Return
SelfLower
Transition
Eof
Leo
Implementations§
source§impl Token
impl Token
sourcepub fn is_keyword(&self) -> bool
pub fn is_keyword(&self) -> bool
Returns true
if the self
token equals a Leo keyword.
sourcepub fn keyword_to_symbol(&self) -> Option<Symbol>
pub fn keyword_to_symbol(&self) -> Option<Symbol>
Converts self
to the corresponding Symbol
if it is_keyword
.
source§impl Token
impl Token
sourcefn eat_integer(
input: &mut Peekable<impl Iterator<Item = char>>,
) -> Result<(usize, Token)>
fn eat_integer( input: &mut Peekable<impl Iterator<Item = char>>, ) -> Result<(usize, Token)>
Returns a tuple: [(integer length, integer token)] if an integer can be eaten.
An integer can be eaten if its characters are at the front of the given input
string.
If there is no input, this function returns an error.
If there is input but no integer, this function returns the tuple consisting of
length 0 and a dummy integer token that contains an empty string.
However, this function is always called when the next character is a digit.
This function eats a sequence of one or more digits and underscores
(starting from a digit, as explained above, given when it is called),
which corresponds to a numeral in the ABNF grammar.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Token
impl<'de> Deserialize<'de> for Token
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl PartialEq for Token
impl PartialEq for Token
impl Eq for Token
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<'de, T> DeserializeExt<'de> for Twhere
T: DeserializeOwned,
impl<'de, T> DeserializeExt<'de> for Twhere
T: DeserializeOwned,
fn take_from_value<D>(
value: &mut Value,
field: &str,
) -> Result<T, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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