Skip to main content

Statement

Enum Statement 

Source
pub enum Statement<'s> {
Show 13 variants Empty(TokenRef<'s>), Expression(Box<Expression<'s>>, TokenRef<'s>), BlockExpression(Box<Expression<'s>>), Module(Option<TokenRef<'s>>, TokenRef<'s>, TokenRef<'s>, Box<Expression<'s>>), Bind(Option<TokenRef<'s>>, TokenRef<'s>, Box<Pattern<'s>>, TokenRef<'s>, Box<Expression<'s>>, TokenRef<'s>), Rebind(Box<Pattern<'s>>, TokenRef<'s>, Box<Expression<'s>>, TokenRef<'s>), Const(Option<TokenRef<'s>>, TokenRef<'s>, TokenRef<'s>, TokenRef<'s>, Box<Expression<'s>>, TokenRef<'s>), Assign(Box<Expression<'s>>, TokenRef<'s>, Box<Expression<'s>>, TokenRef<'s>), Function(Option<TokenRef<'s>>, TokenRef<'s>, TokenRef<'s>, Option<ParameterList<'s>>, Box<Expression<'s>>), Return(TokenRef<'s>, Option<Box<Expression<'s>>>, TokenRef<'s>), Break(TokenRef<'s>, Option<Box<Expression<'s>>>, TokenRef<'s>), Continue(TokenRef<'s>, TokenRef<'s>), Unknown { tokens: Vec<TokenRef<'s>>, errors: Vec<SourceDiagnostic>, },
}

Variants§

§

Empty(TokenRef<'s>)

';'

An empty statement.

§

Expression(Box<Expression<'s>>, TokenRef<'s>)

expression ';'

§

BlockExpression(Box<Expression<'s>>)

expression_ends_with_block

No trailing semicolon in this case. For expressions that end with a semicolon, use Statement::Expression.

§

Module(Option<TokenRef<'s>>, TokenRef<'s>, TokenRef<'s>, Box<Expression<'s>>)

'pub'? 'mod' identifier block_expression_no_expr

§

Bind(Option<TokenRef<'s>>, TokenRef<'s>, Box<Pattern<'s>>, TokenRef<'s>, Box<Expression<'s>>, TokenRef<'s>)

'pub'? 'let' pattern '=' expression ';'

§

Rebind(Box<Pattern<'s>>, TokenRef<'s>, Box<Expression<'s>>, TokenRef<'s>)

pattern_rebind '=' expression ';'

§

Const(Option<TokenRef<'s>>, TokenRef<'s>, TokenRef<'s>, TokenRef<'s>, Box<Expression<'s>>, TokenRef<'s>)

'pub'? 'const' @id '=' expression ';'

§

Assign(Box<Expression<'s>>, TokenRef<'s>, Box<Expression<'s>>, TokenRef<'s>)

expression ('=' | '+=' | '-=' | '*=' | '/=' | '%=' | '^=' | '&&=' | '||=') expression ';'

The assigner must be one of the following:

  • identifier
  • expression_access where the accessed is an extern
  • expression_index where the indexed is an extern
§

Function(Option<TokenRef<'s>>, TokenRef<'s>, TokenRef<'s>, Option<ParameterList<'s>>, Box<Expression<'s>>)

'pub'? 'fn' identifier (parameters) block_expression

Parameters are a list of identifiers, trailing comma is optional.

If parameters and parentheses are omitted, the function is considered with an implicit parameter called it.

fn filter { it % 2 == 0 }

The function body is a block expression.

§

Return(TokenRef<'s>, Option<Box<Expression<'s>>>, TokenRef<'s>)

return expression; or return;

If the expression is omitted, the return value is nil.

§

Break(TokenRef<'s>, Option<Box<Expression<'s>>>, TokenRef<'s>)

break expression; or break;

The expression is only allowed in a loop expression.

§

Continue(TokenRef<'s>, TokenRef<'s>)

continue;

§

Unknown

Unknown statement.

Fields

§tokens: Vec<TokenRef<'s>>

Implementations§

Source§

impl<'s> Statement<'s>

Source

pub const fn is_empty(&self) -> bool

Returns true if the enum is Statement::Empty otherwise false

Source

pub const fn is_expression(&self) -> bool

Returns true if the enum is Statement::Expression otherwise false

Source

pub const fn is_block_expression(&self) -> bool

Returns true if the enum is Statement::BlockExpression otherwise false

Source

pub const fn is_module(&self) -> bool

Returns true if the enum is Statement::Module otherwise false

Source

pub const fn is_bind(&self) -> bool

Returns true if the enum is Statement::Bind otherwise false

Source

pub const fn is_rebind(&self) -> bool

Returns true if the enum is Statement::Rebind otherwise false

Source

pub const fn is_const(&self) -> bool

Returns true if the enum is Statement::Const otherwise false

Source

pub const fn is_assign(&self) -> bool

Returns true if the enum is Statement::Assign otherwise false

Source

pub const fn is_function(&self) -> bool

Returns true if the enum is Statement::Function otherwise false

Source

pub const fn is_return(&self) -> bool

Returns true if the enum is Statement::Return otherwise false

Source

pub const fn is_break(&self) -> bool

Returns true if the enum is Statement::Break otherwise false

Source

pub const fn is_continue(&self) -> bool

Returns true if the enum is Statement::Continue otherwise false

Source

pub const fn is_unknown(&self) -> bool

Returns true if the enum is Statement::Unknown otherwise false

Trait Implementations§

Source§

impl<'s> Clone for Statement<'s>

Source§

fn clone(&self) -> Statement<'s>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'s> Debug for Statement<'s>

Source§

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

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

impl<'s> PartialEq for Statement<'s>

Source§

fn eq(&self, other: &Statement<'s>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'s> StructuralPartialEq for Statement<'s>

Auto Trait Implementations§

§

impl<'s> Freeze for Statement<'s>

§

impl<'s> RefUnwindSafe for Statement<'s>

§

impl<'s> Send for Statement<'s>

§

impl<'s> Sync for Statement<'s>

§

impl<'s> Unpin for Statement<'s>

§

impl<'s> UnsafeUnpin for Statement<'s>

§

impl<'s> UnwindSafe for Statement<'s>

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.