Skip to main content

MojoElementType

Enum MojoElementType 

Source
pub enum MojoElementType {
Show 75 variants Fn, Struct, Var, Let, If, Else, While, For, In, Return, Break, Continue, Import, From, True, False, None, Identifier, Integer, Float, String, Plus, Minus, Star, Slash, Percent, Equal, EqualEqual, NotEqual, Less, LessEqual, Greater, GreaterEqual, And, Or, Not, LeftParen, RightParen, LeftBracket, RightBracket, LeftBrace, RightBrace, Comma, Dot, Colon, Semicolon, Arrow, Whitespace, Newline, Comment, Indent, Dedent, EndOfStream, FunctionDef, StructDef, VariableDecl, Assignment, IfStatement, WhileStatement, ForStatement, ReturnStatement, ExpressionStatement, BinaryExpr, UnaryExpr, CallExpr, LiteralExpr, IdentifierExpr, MemberExpr, ListExpr, ParamList, ArgList, Block, Root, Grouping, Error,
}
Expand description

Element types for the Mojo language parser.

This enum represents all possible element types in the Mojo language, including tokens mapped from MojoTokenType, statement types, expression types, and special node types.

Variants§

§

Fn

Function keyword fn.

§

Struct

Struct keyword struct.

§

Var

Variable keyword var.

§

Let

Let keyword let.

§

If

If keyword if.

§

Else

Else keyword else.

§

While

While keyword while.

§

For

For keyword for.

§

In

In keyword in.

§

Return

Return keyword return.

§

Break

Break keyword break.

§

Continue

Continue keyword continue.

§

Import

Import keyword import.

§

From

From keyword from.

§

True

Boolean literal True.

§

False

Boolean literal False.

§

None

None literal.

§

Identifier

Identifier token.

§

Integer

Integer literal token.

§

Float

Float literal token.

§

String

String literal token.

§

Plus

Plus operator +.

§

Minus

Minus operator -.

§

Star

Star operator *.

§

Slash

Slash operator /.

§

Percent

Percent operator %.

§

Equal

Assignment operator =.

§

EqualEqual

Equality operator ==.

§

NotEqual

Inequality operator !=.

§

Less

Less than operator <.

§

LessEqual

Less than or equal operator <=.

§

Greater

Greater than operator >.

§

GreaterEqual

Greater than or equal operator >=.

§

And

Logical and operator and.

§

Or

Logical or operator or.

§

Not

Logical not operator not.

§

LeftParen

Left parenthesis (.

§

RightParen

Right parenthesis ).

§

LeftBracket

Left bracket [.

§

RightBracket

Right bracket ].

§

LeftBrace

Left brace {.

§

RightBrace

Right brace }.

§

Comma

Comma ,.

§

Dot

Dot ..

§

Colon

Colon :.

§

Semicolon

Semicolon ;.

§

Arrow

Arrow operator ->.

§

Whitespace

Whitespace token.

§

Newline

Newline token.

§

Comment

Comment token.

§

Indent

Indent token for significant whitespace.

§

Dedent

Dedent token for significant whitespace.

§

EndOfStream

End of stream marker.

§

FunctionDef

Function definition statement.

§

StructDef

Struct definition statement.

§

VariableDecl

Variable declaration statement.

§

Assignment

Assignment statement.

§

IfStatement

If statement.

§

WhileStatement

While statement.

§

ForStatement

For statement.

§

ReturnStatement

Return statement.

§

ExpressionStatement

Expression statement.

§

BinaryExpr

Binary expression.

§

UnaryExpr

Unary expression.

§

CallExpr

Function call expression.

§

LiteralExpr

Literal expression.

§

IdentifierExpr

Identifier expression.

§

MemberExpr

Member access expression.

§

ListExpr

List expression.

§

ParamList

Parameter list.

§

ArgList

Argument list.

§

Block

Code block.

§

Root

Root node of the AST.

§

Grouping

Grouping expression.

§

Error

Error node.

Implementations§

Source§

impl MojoElementType

Source

pub fn is_trivia(&self) -> bool

Checks if the node is trivia (whitespace, comments, etc.).

Trait Implementations§

Source§

impl Clone for MojoElementType

Source§

fn clone(&self) -> MojoElementType

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 MojoElementType

Source§

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

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

impl<'de> Deserialize<'de> for MojoElementType

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl ElementType for MojoElementType

Source§

type Role = UniversalElementRole

The associated role type for this element kind.
Source§

fn role(&self) -> Self::Role

Returns the general syntactic role of this element. Read more
Source§

fn is_role(&self, role: Self::Role) -> bool

Returns true if this element matches the specified language-specific role.
Source§

fn is_universal(&self, role: UniversalElementRole) -> bool

Returns true if this element matches the specified universal role.
Source§

fn is_root(&self) -> bool

Returns true if this element represents the root of the parsed tree.
Source§

fn is_error(&self) -> bool

Returns true if this element represents an error condition.
Source§

impl From<MojoTokenType> for MojoElementType

Source§

fn from(token: MojoTokenType) -> Self

Converts to this type from the input type.
Source§

impl Hash for MojoElementType

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 PartialEq for MojoElementType

Source§

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

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for MojoElementType

Source§

impl Eq for MojoElementType

Source§

impl StructuralPartialEq for MojoElementType

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, 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,