Enum Primary

Source
pub enum Primary {
    Literal(Literal),
    Paren(Paren),
    Block(Block),
    If(If),
    Loop(Loop),
    While(While),
    Break(Break),
    Continue(Continue),
    Call(Call),
}
Expand description

Represents a primary expression in CalcScript.

Primary expressions are the simplest expressions, and are the building blocks of more complex expressions. Primary expressions are also self-contained. This means that primary expressions within a larger expression can be replaced with equivalent, but different kinds of primary expressions, and the larger expression will still be valid.

Variants§

§

Literal(Literal)

A literal value.

§

Paren(Paren)

A parenthesized expression, such as (1 + 2).

§

Block(Block)

A blocked expression, such as {1 + 2}.

§

If(If)

An if expression, such as if x > 0 then x else -x.

§

Loop(Loop)

A loop expression, as in loop { ... }.

§

While(While)

A while loop expression, as in while x > 0 then { ... }.

§

Break(Break)

A break expression, used to exit a loop, optionally with a value.

§

Continue(Continue)

A continue expression, used to skip the rest of a loop iteration.

§

Call(Call)

A function call, such as abs(-1).

Implementations§

Source§

impl Primary

Source

pub fn span(&self) -> Range<usize>

Returns the span of the primary expression.

Trait Implementations§

Source§

impl Clone for Primary

Source§

fn clone(&self) -> Primary

Returns a copy 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 Primary

Source§

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

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

impl From<Primary> for Expr

Source§

fn from(primary: Primary) -> Self

Converts to this type from the input type.
Source§

impl<'source> Parse<'source> for Primary

Source§

fn std_parse( input: &mut Parser<'source>, recoverable_errors: &mut Vec<Error>, ) -> Result<Self, Vec<Error>>

Parses a value from the given stream of tokens, advancing the stream past the consumed tokens if parsing is successful. Read more
Source§

fn parse(input: &mut Parser<'source>) -> ParseResult<Self>

Parses a value from the given stream of tokens, advancing the stream past the consumed tokens if parsing is successful. Read more
Source§

impl PartialEq for Primary

Source§

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

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.