Skip to main content

SyntaxKind

Enum SyntaxKind 

Source
pub enum SyntaxKind {
Show 180 variants ERROR = 0, EOF, WHITESPACE, LINEBREAK, COMMENT_LINE, COMMENT_BLOCK, INTEGER, STRING, ADDRESS_LIT, IDENT, KW_TRUE, KW_FALSE, KW_NONE, KW_ADDRESS, KW_BOOL, KW_FIELD, KW_GROUP, KW_SCALAR, KW_SIGNATURE, KW_STRING, KW_RECORD, KW_FUTURE, KW_I8, KW_I16, KW_I32, KW_I64, KW_I128, KW_U8, KW_U16, KW_U32, KW_U64, KW_U128, KW_IF, KW_ELSE, KW_FOR, KW_IN, KW_RETURN, KW_LET, KW_CONST, KW_CONSTANT, KW_FUNCTION, KW_TRANSITION, KW_INLINE, KW_ASYNC, KW_FN, KW_STRUCT, KW_CONSTRUCTOR, KW_PROGRAM, KW_IMPORT, KW_MAPPING, KW_STORAGE, KW_NETWORK, KW_ALEO, KW_SCRIPT, KW_BLOCK, KW_PUBLIC, KW_PRIVATE, KW_AS, KW_SELF, KW_ASSERT, KW_ASSERT_EQ, KW_ASSERT_NEQ, L_PAREN, R_PAREN, L_BRACKET, R_BRACKET, L_BRACE, R_BRACE, COMMA, DOT, DOT_DOT, SEMICOLON, COLON, COLON_COLON, QUESTION, ARROW, FAT_ARROW, UNDERSCORE, AT, EQ, PLUS_EQ, MINUS_EQ, STAR_EQ, SLASH_EQ, PERCENT_EQ, STAR2_EQ, AMP2_EQ, PIPE2_EQ, AMP_EQ, PIPE_EQ, CARET_EQ, SHL_EQ, SHR_EQ, PLUS, MINUS, STAR, SLASH, PERCENT, STAR2, EQ2, BANG_EQ, LT, LT_EQ, GT, GT_EQ, AMP2, PIPE2, BANG, AMP, PIPE, CARET, SHL, SHR, ROOT, PROGRAM_DECL, IMPORT, MAIN_CONTENTS, MODULE_CONTENTS, FUNCTION_DEF, CONSTRUCTOR_DEF, STRUCT_DEF, RECORD_DEF, STRUCT_MEMBER, MAPPING_DEF, STORAGE_DEF, GLOBAL_CONST, ANNOTATION, PARAM, PARAM_LIST, RETURN_TYPE, CONST_PARAM, CONST_PARAM_LIST, CONST_ARG_LIST, LET_STMT, CONST_STMT, RETURN_STMT, EXPR_STMT, ASSIGN_STMT, IF_STMT, FOR_STMT, BLOCK, ASSERT_STMT, ASSERT_EQ_STMT, ASSERT_NEQ_STMT, IDENT_PATTERN, TUPLE_PATTERN, WILDCARD_PATTERN, BINARY_EXPR, UNARY_EXPR, CALL_EXPR, METHOD_CALL_EXPR, FIELD_EXPR, INDEX_EXPR, CAST_EXPR, TERNARY_EXPR, ARRAY_EXPR, TUPLE_EXPR, STRUCT_EXPR, STRUCT_FIELD_INIT, PATH_EXPR, PAREN_EXPR, LITERAL, REPEAT_EXPR, ASYNC_EXPR, ASSOC_FN_EXPR, ASSOC_CONST_EXPR, LOCATOR_EXPR, TUPLE_ACCESS_EXPR, INTRINSIC_EXPR, UNIT_EXPR, TYPE_PATH, TYPE_ARRAY, TYPE_TUPLE, TYPE_OPTIONAL, TYPE_FUTURE, TYPE_MAPPING, ARG_LIST, NAME_REF, NAME, VISIBILITY, // some variants omitted
}
Expand description

All syntax kinds for Leo tokens and nodes.

This enum is intentionally flat (not nested) to satisfy rowan’s requirement for a #[repr(u16)] type. Categories are indicated by comments and helper methods like is_trivia() and is_keyword().

Variants§

§

ERROR = 0

Error node for wrapping parse errors and invalid tokens.

§

EOF

End of file marker.

§

WHITESPACE

Horizontal whitespace: spaces, tabs, form feeds.

§

LINEBREAK

Line breaks: \n or \r\n.

§

COMMENT_LINE

Line comment: // …

§

COMMENT_BLOCK

Block comment: /* … */

§

INTEGER

Integer literal: 123, 0xFF, 0b101, 0o77

§

STRING

String literal: “…”

§

ADDRESS_LIT

Address literal: aleo1…

§

IDENT

Identifier: foo, Bar, _baz Note: Complex identifiers (paths, program IDs, locators) are deferred to Phase 2. The lexer produces simple IDENT tokens; the parser handles disambiguation of foo::bar, foo.aleo, foo.aleo/bar patterns.

§

KW_TRUE

true

§

KW_FALSE

false

§

KW_NONE

none

§

KW_ADDRESS

address

§

KW_BOOL

bool

§

KW_FIELD

field

§

KW_GROUP

group

§

KW_SCALAR

scalar

§

KW_SIGNATURE

signature

§

KW_STRING

string

§

KW_RECORD

record

§

KW_FUTURE

Future

§

KW_I8

i8

§

KW_I16

i16

§

KW_I32

i32

§

KW_I64

i64

§

KW_I128

i128

§

KW_U8

u8

§

KW_U16

u16

§

KW_U32

u32

§

KW_U64

u64

§

KW_U128

u128

§

KW_IF

if

§

KW_ELSE

else

§

KW_FOR

for

§

KW_IN

in

§

KW_RETURN

return

§

KW_LET

let

§

KW_CONST

const

§

KW_CONSTANT

constant

§

KW_FUNCTION

function

§

KW_TRANSITION

transition

§

KW_INLINE

inline

§

KW_ASYNC

async

§

KW_FN

Fn

§

KW_STRUCT

struct

§

KW_CONSTRUCTOR

constructor

§

KW_PROGRAM

program

§

KW_IMPORT

import

§

KW_MAPPING

mapping

§

KW_STORAGE

storage

§

KW_NETWORK

network

§

KW_ALEO

aleo

§

KW_SCRIPT

script

§

KW_BLOCK

block

§

KW_PUBLIC

public

§

KW_PRIVATE

private

§

KW_AS

as

§

KW_SELF

self

§

KW_ASSERT

assert

§

KW_ASSERT_EQ

assert_eq

§

KW_ASSERT_NEQ

assert_neq

§

L_PAREN

(

§

R_PAREN

)

§

L_BRACKET

[

§

R_BRACKET

]

§

L_BRACE

{

§

R_BRACE

}

§

COMMA

,

§

DOT

.

§

DOT_DOT

..

§

SEMICOLON

;

§

COLON

:

§

COLON_COLON

::

§

QUESTION

?

§

ARROW

->

§

FAT_ARROW

=>

§

UNDERSCORE

_

§

AT

@

§

EQ

=

§

PLUS_EQ

+=

§

MINUS_EQ

-=

§

STAR_EQ

*=

§

SLASH_EQ

/=

§

PERCENT_EQ

%=

§

STAR2_EQ

**=

§

AMP2_EQ

&&=

§

PIPE2_EQ

||=

§

AMP_EQ

&=

§

PIPE_EQ

|=

§

CARET_EQ

^=

§

SHL_EQ

<<=

§

SHR_EQ

>>=

§

PLUS

+

§

MINUS

-

§

STAR

*

§

SLASH

/

§

PERCENT

%

§

STAR2

**

§

EQ2

==

§

BANG_EQ

!=

§

LT

<

§

LT_EQ

<=

§

GT

>

§

GT_EQ

>=

§

AMP2

&&

§

PIPE2

||

§

BANG

!

§

AMP

&

§

PIPE

|

§

CARET

^

§

SHL

<<

§

SHR

>>

§

ROOT

Root node of the syntax tree.

§

PROGRAM_DECL

Program declaration: program foo.aleo { ... }

§

IMPORT

Import statement: import foo.aleo;

§

MAIN_CONTENTS

Main file contents.

§

MODULE_CONTENTS

Module file contents.

§

FUNCTION_DEF

Function definition.

§

CONSTRUCTOR_DEF

Constructor definition.

§

STRUCT_DEF

Struct definition.

§

RECORD_DEF

Record definition.

§

STRUCT_MEMBER

Struct member declaration.

§

MAPPING_DEF

Mapping definition.

§

STORAGE_DEF

Storage definition.

§

GLOBAL_CONST

Global constant definition.

§

ANNOTATION

Annotation: @foo

§

PARAM

Parameter in a function signature.

§

PARAM_LIST

Parameter list: (a: u32, b: u32)

§

RETURN_TYPE

Function output type.

§

CONST_PARAM

Const generic parameter.

§

CONST_PARAM_LIST

Const generic parameter list.

§

CONST_ARG_LIST

Const generic argument list.

§

LET_STMT

Let statement: let x = ...;

§

CONST_STMT

Const statement: const x = ...;

§

RETURN_STMT

Return statement: return ...;

§

EXPR_STMT

Expression statement: foo();

§

ASSIGN_STMT

Assignment statement: x = ...;

§

IF_STMT

If statement: if ... { } else { }

§

FOR_STMT

For loop: for i in 0..10 { }

§

BLOCK

Block: { ... }

§

ASSERT_STMT

Assert statement: assert(...);

§

ASSERT_EQ_STMT

Assert equals statement: assert_eq(...);

§

ASSERT_NEQ_STMT

Assert not equals statement: assert_neq(...);

§

IDENT_PATTERN

Identifier pattern: x

§

TUPLE_PATTERN

Tuple pattern: (a, b, c)

§

WILDCARD_PATTERN

Wildcard pattern: _

§

BINARY_EXPR

Binary expression: a + b

§

UNARY_EXPR

Unary expression: !a, -a

§

CALL_EXPR

Function call: foo(a, b)

§

METHOD_CALL_EXPR

Method call: a.foo(b)

§

FIELD_EXPR

Member access: a.b

§

INDEX_EXPR

Array/tuple index: a[0]

§

CAST_EXPR

Cast expression: a as u32

§

TERNARY_EXPR

Ternary expression: a ? b : c

§

ARRAY_EXPR

Array literal: [1, 2, 3]

§

TUPLE_EXPR

Tuple literal: (1, 2, 3)

§

STRUCT_EXPR

Struct literal: Foo { a: 1, b: 2 }

§

STRUCT_FIELD_INIT

Struct field initializer: a: 1

§

PATH_EXPR

Path expression: foo::bar

§

PAREN_EXPR

Parenthesized expression: (a + b)

§

LITERAL

Literal expression (wraps INTEGER, STRING, ADDRESS_LIT, or keywords).

§

REPEAT_EXPR

Repeat expression: [0u8; 32]

§

ASYNC_EXPR

Async expression: async foo()

§

ASSOC_FN_EXPR

Associated function call: Foo::bar()

§

ASSOC_CONST_EXPR

Associated constant: Foo::BAR

§

LOCATOR_EXPR

Locator expression: foo.aleo/bar

§

TUPLE_ACCESS_EXPR

Tuple access: a.0

§

INTRINSIC_EXPR

Intrinsic expression: _foo()

§

UNIT_EXPR

Unit expression: ()

§

TYPE_PATH

Named/path type: u32, Foo, foo::Bar

§

TYPE_ARRAY

Array type: [u32; 10]

§

TYPE_TUPLE

Tuple type: (u32, u32)

§

TYPE_OPTIONAL

Optional type: u32? (Future feature)

§

TYPE_FUTURE

Future type: Future<Foo>

§

TYPE_MAPPING

Mapping type in storage.

§

ARG_LIST

Argument list: (a, b, c)

§

NAME_REF

Name reference (identifier in expression context).

§

NAME

Name definition (identifier in binding context).

§

VISIBILITY

Visibility modifier: public, private

Implementations§

Source§

impl SyntaxKind

Source

pub fn is_trivia(self) -> bool

Check if this is a trivia token (whitespace or comment).

Source

pub fn is_keyword(self) -> bool

Check if this is a keyword.

Source

pub fn is_type_keyword(self) -> bool

Check if this is a type keyword.

Source

pub fn is_literal(self) -> bool

Check if this is a literal token.

Source

pub fn is_punctuation(self) -> bool

Check if this is a punctuation token.

Source

pub fn is_operator(self) -> bool

Check if this is an operator token.

Trait Implementations§

Source§

impl Clone for SyntaxKind

Source§

fn clone(&self) -> SyntaxKind

Returns a duplicate 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 SyntaxKind

Source§

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

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

impl From<SyntaxKind> for SyntaxKind

Source§

fn from(kind: SyntaxKind) -> Self

Converts to this type from the input type.
Source§

impl Hash for SyntaxKind

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 SyntaxKind

Source§

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

Source§

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

Source§

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

Source§

impl Eq for SyntaxKind

Source§

impl StructuralPartialEq for SyntaxKind

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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
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<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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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