[][src]Enum rune::ast::Expr

pub enum Expr {
    Self_(Self_),
    Path(Path),
    Decl(Decl),
    ExprWhile(ExprWhile),
    ExprLoop(ExprLoop),
    ExprFor(ExprFor),
    ExprLet(ExprLet),
    ExprIndexSet(ExprIndexSet),
    ExprIf(ExprIf),
    ExprMatch(ExprMatch),
    ExprCall(ExprCall),
    ExprFieldAccess(ExprFieldAccess),
    ExprGroup(ExprGroup),
    ExprBinary(ExprBinary),
    ExprUnary(ExprUnary),
    ExprIndexGet(ExprIndexGet),
    ExprBreak(ExprBreak),
    ExprYield(ExprYield),
    ExprBlock(ExprBlock),
    ExprReturn(ExprReturn),
    ExprAwait(ExprAwait),
    ExprTry(ExprTry),
    ExprSelect(ExprSelect),
    ExprClosure(ExprClosure),
    LitUnit(LitUnit),
    LitBool(LitBool),
    LitChar(LitChar),
    LitByte(LitByte),
    LitNumber(LitNumber),
    LitStr(LitStr),
    LitByteStr(LitByteStr),
    LitTemplate(LitTemplate),
    LitVec(LitVec),
    LitObject(LitObject),
    LitTuple(LitTuple),
}

A rune expression.

Variants

Self_(Self_)

The self keyword.

Path(Path)

An path expression.

Decl(Decl)

A declaration.

ExprWhile(ExprWhile)

A while loop.

ExprLoop(ExprLoop)

An unconditional loop.

ExprFor(ExprFor)

An for loop.

ExprLet(ExprLet)

A let expression.

ExprIndexSet(ExprIndexSet)

An index set operation.

ExprIf(ExprIf)

An if expression.

ExprMatch(ExprMatch)

An match expression.

ExprCall(ExprCall)

A function call,

ExprFieldAccess(ExprFieldAccess)

A field access on an expression.

ExprGroup(ExprGroup)

A grouped expression.

ExprBinary(ExprBinary)

A binary expression.

ExprUnary(ExprUnary)

A unary expression.

ExprIndexGet(ExprIndexGet)

An index set operation.

ExprBreak(ExprBreak)

A break expression.

ExprYield(ExprYield)

A yield expression.

ExprBlock(ExprBlock)

A block as an expression.

ExprReturn(ExprReturn)

A return statement.

ExprAwait(ExprAwait)

An await expression.

ExprTry(ExprTry)

Try expression.

ExprSelect(ExprSelect)

A select expression.

ExprClosure(ExprClosure)

A closure expression.

LitUnit(LitUnit)

A unit expression.

LitBool(LitBool)

A boolean literal.

LitChar(LitChar)

A char literal.

LitByte(LitByte)

A byte literal.

LitNumber(LitNumber)

A literal number expression.

LitStr(LitStr)

A literal string expression.

LitByteStr(LitByteStr)

A literal byte string expression.

LitTemplate(LitTemplate)

A literal string expression.

LitVec(LitVec)

A literal vector declaration.

LitObject(LitObject)

A literal object declaration.

LitTuple(LitTuple)

A literal tuple declaration.

Implementations

impl Expr[src]

pub fn produces_nothing(&self) -> bool[src]

Test if the expression implicitly evaluates to nothing.

pub fn is_chainable(&self) -> bool[src]

Test if expression should be chained by default.

pub fn span(&self) -> Span[src]

Get the span of the expression.

pub fn is_const(&self) -> bool[src]

Test if the entire expression is constant.

pub fn parse_open_paren(parser: &mut Parser<'_>) -> Result<Self, ParseError>[src]

Parsing something that opens with a parenthesis.

Trait Implementations

impl Clone for Expr[src]

impl Debug for Expr[src]

impl Parse for Expr[src]

Parsing a block expression.

Examples

use rune::{parse_all, ast};

parse_all::<ast::Expr>("foo[\"foo\"]").unwrap();
parse_all::<ast::Expr>("foo.bar()").unwrap();
parse_all::<ast::Expr>("var()").unwrap();
parse_all::<ast::Expr>("var").unwrap();
parse_all::<ast::Expr>("42").unwrap();
parse_all::<ast::Expr>("1 + 2 / 3 - 4 * 1").unwrap();
parse_all::<ast::Expr>("foo[\"bar\"]").unwrap();
parse_all::<ast::Expr>("let var = 42").unwrap();
parse_all::<ast::Expr>("let var = \"foo bar\"").unwrap();
parse_all::<ast::Expr>("var[\"foo\"] = \"bar\"").unwrap();
parse_all::<ast::Expr>("let var = objects[\"foo\"] + 1").unwrap();
parse_all::<ast::Expr>("var = 42").unwrap();

let expr = parse_all::<ast::Expr>(r#"
    if 1 { } else { if 2 { } else { } }
"#).unwrap();

if let ast::Expr::ExprIf(..) = expr.item {
} else {
    panic!("not an if statement");
}

// Chained function calls.
parse_all::<ast::Expr>("foo.bar.baz()").unwrap();
parse_all::<ast::Expr>("foo[0][1][2]").unwrap();
parse_all::<ast::Expr>("foo.bar()[0].baz()[1]").unwrap();

parse_all::<ast::Expr>("42 is int::int").unwrap();

Auto Trait Implementations

impl RefUnwindSafe for Expr

impl Send for Expr

impl Sync for Expr

impl Unpin for Expr

impl UnwindSafe for Expr

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

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