pub enum Token<'input> {
Show 215 variants
Add,
Addrspace,
Adv,
AdvMap,
InsertHdword,
InsertHdwordWithDomain,
InsertHqword,
InsertHperm,
InsertMem,
AdvLoadw,
AdvPipe,
AdvPush,
AdvStack,
PushMapval,
PushMapvaln,
PushMtnode,
And,
Assert,
Assertz,
AssertEq,
AssertEqw,
EvalCircuit,
Begin,
Breakpoint,
Byte,
Caller,
Call,
Cdrop,
Cdropw,
Clk,
Const,
Cswap,
Cswapw,
Debug,
Div,
Drop,
Dropw,
Dup,
Dupw,
Dynexec,
Dyncall,
Else,
Emit,
End,
Enum,
Eq,
Eqw,
Ext2Add,
Ext2Div,
Ext2Inv,
Ext2Mul,
Ext2Neg,
Ext2Sub,
Err,
Exec,
Export,
Exp,
ExpU,
False,
Felt,
FriExt2Fold4,
Gt,
Gte,
Hash,
HasMapkey,
HornerBase,
HornerExt,
Hperm,
Hmerge,
I1,
I8,
I16,
I32,
I64,
I128,
If,
ILog2,
Inv,
IsOdd,
Local,
Locaddr,
LocLoad,
LocLoadw,
LocStore,
LocStorew,
Lt,
Lte,
Mem,
MemLoad,
MemLoadw,
MemLoadwBe,
MemLoadwLe,
MemStore,
MemStorew,
MemStorewBe,
MemStorewLe,
MemStream,
Movdn,
Movdnw,
Movup,
Movupw,
MtreeGet,
MtreeMerge,
MtreeSet,
MtreeVerify,
Mul,
Neg,
Neq,
Not,
Nop,
Or,
Padw,
Pow2,
Proc,
Procref,
Ptr,
Pub,
Push,
Repeat,
Reversew,
Reversedw,
Range,
Sdepth,
Stack,
Struct,
Sub,
Swap,
Swapw,
Swapdw,
Syscall,
Trace,
True,
Type,
Use,
U8,
U16,
U32,
U32And,
U32Assert,
U32Assert2,
U32Assertw,
U32Cast,
U32Div,
U32Divmod,
U32Gt,
U32Gte,
U32Lt,
U32Lte,
U32Max,
U32Min,
U32Mod,
U32Not,
U32Or,
U32OverflowingAdd,
U32OverflowingAdd3,
U32OverflowingMadd,
U32OverflowingMul,
U32OverflowingSub,
U32Popcnt,
U32Clz,
U32Ctz,
U32Clo,
U32Cto,
U32Rotl,
U32Rotr,
U32Shl,
U32Shr,
U32Split,
U32Test,
U32Testw,
U32WrappingAdd,
U32WrappingAdd3,
U32WrappingMadd,
U32WrappingMul,
U32WrappingSub,
U32Xor,
U64,
U128,
While,
Word,
Event,
Xor,
At,
Bang,
Colon,
ColonColon,
Dot,
Comma,
Equal,
Langle,
Lparen,
Lbrace,
Lbracket,
Minus,
Plus,
Semicolon,
SlashSlash,
Slash,
Star,
Rangle,
Rparen,
Rbrace,
Rbracket,
Rstab,
DocComment(DocumentationType),
HexValue(IntValue),
HexWord(WordValue),
BinValue(BinEncodedValue),
Int(u64),
Ident(&'input str),
ConstantIdent(&'input str),
QuotedIdent(&'input str),
QuotedString(&'input str),
Comment,
Eof,
}
Expand description
The token type produced by crate::parser::Lexer, and consumed by the parser.
Variants§
Add
Addrspace
Adv
AdvMap
InsertHdword
InsertHdwordWithDomain
InsertHqword
InsertHperm
InsertMem
AdvLoadw
AdvPipe
AdvPush
AdvStack
PushMapval
PushMapvaln
PushMtnode
And
Assert
Assertz
AssertEq
AssertEqw
EvalCircuit
Begin
Breakpoint
Byte
Caller
Call
Cdrop
Cdropw
Clk
Const
Cswap
Cswapw
Debug
Div
Drop
Dropw
Dup
Dupw
Dynexec
Dyncall
Else
Emit
End
Enum
Eq
Eqw
Ext2Add
Ext2Div
Ext2Inv
Ext2Mul
Ext2Neg
Ext2Sub
Err
Exec
Export
Exp
ExpU
False
Felt
FriExt2Fold4
Gt
Gte
Hash
HasMapkey
HornerBase
HornerExt
Hperm
Hmerge
I1
I8
I16
I32
I64
I128
If
ILog2
Inv
IsOdd
Local
Locaddr
LocLoad
LocLoadw
LocStore
LocStorew
Lt
Lte
Mem
MemLoad
MemLoadw
MemLoadwBe
MemLoadwLe
MemStore
MemStorew
MemStorewBe
MemStorewLe
MemStream
Movdn
Movdnw
Movup
Movupw
MtreeGet
MtreeMerge
MtreeSet
MtreeVerify
Mul
Neg
Neq
Not
Nop
Or
Padw
Pow2
Proc
Procref
Ptr
Pub
Push
Repeat
Reversew
Reversedw
Range
Sdepth
Stack
Struct
Sub
Swap
Swapw
Swapdw
Syscall
Trace
True
Type
Use
U8
U16
U32
U32And
U32Assert
U32Assert2
U32Assertw
U32Cast
U32Div
U32Divmod
U32Gt
U32Gte
U32Lt
U32Lte
U32Max
U32Min
U32Mod
U32Not
U32Or
U32OverflowingAdd
U32OverflowingAdd3
U32OverflowingMadd
U32OverflowingMul
U32OverflowingSub
U32Popcnt
U32Clz
U32Ctz
U32Clo
U32Cto
U32Rotl
U32Rotr
U32Shl
U32Shr
U32Split
U32Test
U32Testw
U32WrappingAdd
U32WrappingAdd3
U32WrappingMadd
U32WrappingMul
U32WrappingSub
U32Xor
U64
U128
While
Word
Event
Xor
At
Bang
Colon
ColonColon
Dot
Comma
Equal
Langle
Lparen
Lbrace
Lbracket
Minus
Plus
Semicolon
SlashSlash
Slash
Star
Rangle
Rparen
Rbrace
Rbracket
Rstab
DocComment(DocumentationType)
HexValue(IntValue)
HexWord(WordValue)
BinValue(BinEncodedValue)
Int(u64)
Ident(&'input str)
ConstantIdent(&'input str)
QuotedIdent(&'input str)
QuotedString(&'input str)
Comment
Eof
Implementations§
Source§impl<'input> Token<'input>
impl<'input> Token<'input>
Sourcepub fn is_instruction(&self) -> bool
pub fn is_instruction(&self) -> bool
Returns true if this token represents the name of an instruction.
This is used to simplify diagnostic output related to expected tokens so as not to overwhelm the user with a ton of possible expected instruction variants.
Sourcepub fn is_type_keyword(&self) -> bool
pub fn is_type_keyword(&self) -> bool
Returns true if this token represents the name of an type or a type-related keyword.
This is used to simplify diagnostic output related to expected tokens so as not to overwhelm the user with a ton of possible expected tokens.
Sourcepub fn keyword_searcher() -> AhoCorasick
pub fn keyword_searcher() -> AhoCorasick
Constructs a DFA capable of recognizing Miden Assembly keywords.
Constructing the state machine is expensive, so it should not be done in hot code. Instead, prefer to construct it once and reuse it many times.
Currently we construct an instance of this searcher in the lexer, which is then used to select a keyword token or construct an identifier token depending on whether a given string is a known keyword.
Sourcepub fn from_keyword_or_ident(s: &'input str) -> Self
pub fn from_keyword_or_ident(s: &'input str) -> Self
Returns an appropriate Token depending on whether the given string is a keyword or an identifier.
NOTE: This constructs and throws away an expensive-to-construct Aho-Corasick state machine. You should not call this from any code on a hot path. Instead, construct the state machine once using Token::keyword_searcher, and reuse it for all searches using Token::from_keyword_or_ident_with_searcher.
Currently, this function is only called along one code path, which is when we are constructing a parser error in which we wish to determine which, if any, of the expected tokens are instruction opcode keywords, so we can collapse them into a more user-friendly error message. This is not on a hot path, so we don’t care if it is a bit slow.
Sourcepub fn from_keyword_or_ident_with_searcher(
s: &'input str,
searcher: &AhoCorasick,
) -> Self
pub fn from_keyword_or_ident_with_searcher( s: &'input str, searcher: &AhoCorasick, ) -> Self
This is the primary function you should use when you wish to get an appropriate token for a given input string, depending on whether it is a keyword or an identifier.
See Token::keyword_searcher for additional information on how this is meant to be used.
Sourcepub fn parse(s: &'input str) -> Option<Token<'input>>
pub fn parse(s: &'input str) -> Option<Token<'input>>
Parses a Token from a string corresponding to that token.
This solely exists to aid in constructing more user-friendly error messages in certain scenarios, and is otherwise not used (nor should it be). It is quite expensive to call due to invoking Token::keyword_searcher under the covers. See the documentation for that function for more details.
Trait Implementations§
Auto Trait Implementations§
impl<'input> Freeze for Token<'input>
impl<'input> RefUnwindSafe for Token<'input>
impl<'input> Send for Token<'input>
impl<'input> Sync for Token<'input>
impl<'input> Unpin for Token<'input>
impl<'input> UnwindSafe for Token<'input>
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§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg
or
a color-specific method, such as OwoColorize::green
, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg
or
a color-specific method, such as OwoColorize::on_yellow
, Read more