Skip to main content

Expr

Enum Expr 

Source
pub enum Expr {
Show 14 variants Int(i128), Double(f64), Bool(bool), Ident(String), Unary { op: UnOp, operand: Box<Expr>, }, Binary { op: BinOp, lhs: Box<Expr>, rhs: Box<Expr>, }, Ternary { cond: Box<Expr>, then: Box<Expr>, els: Box<Expr>, }, Call { name: String, args: Vec<Expr>, }, Index { base: Box<Expr>, index: Box<Expr>, }, Field { base: Box<Expr>, name: String, }, Assign { lhs: Box<Expr>, op: AssignOp, rhs: Box<Expr>, }, Step { step: Step, prefix: bool, operand: Box<Expr>, }, Comma(Vec<Expr>), Verbatim(String),
}
Expand description

An expression: what a declaration, a function body or a transition label is built from.

Compound forms print fully parenthesised. UPPAAL’s precedence table is not C’s — T_MIN/T_MAX and the bit operators sit in places a reader does not expect — so the printer never relies on it.

Variants§

§

Int(i128)

An integer literal.

§

Double(f64)

A floating-point literal.

§

Bool(bool)

true / false.

§

Ident(String)

A bare identifier.

§

Unary

op operand.

Fields

§op: UnOp

The operator.

§operand: Box<Expr>

The operand.

§

Binary

lhs op rhs.

Fields

§op: BinOp

The operator.

§lhs: Box<Expr>

Left operand.

§rhs: Box<Expr>

Right operand.

§

Ternary

cond ? then : els.

Fields

§cond: Box<Expr>

The condition.

§then: Box<Expr>

Value when the condition holds.

§els: Box<Expr>

Value otherwise.

§

Call

f(a, b).

Fields

§name: String

The function name.

§args: Vec<Expr>

The arguments, in order.

§

Index

base[index].

Fields

§base: Box<Expr>

The indexed expression.

§index: Box<Expr>

The index.

§

Field

base.name.

Fields

§base: Box<Expr>

The struct-valued expression.

§name: String

The field name.

§

Assign

lhs op rhs: an assignment is an expression in UTAP, as in C.

Fields

§lhs: Box<Expr>

The assigned location.

§op: AssignOp

The operator.

§rhs: Box<Expr>

The assigned value.

§

Step

++x, x++, --x or x--.

Fields

§step: Step

Increment or decrement.

§prefix: bool

++x rather than x++.

§operand: Box<Expr>

The stepped location.

§

Comma(Vec<Expr>)

a, b, c: the comma list (ExprList), as an update label is.

§

Verbatim(String)

Pre-rendered UPPAAL text, spliced in as written.

The escape hatch for what the enum cannot hold: one of the placeholder comments the transpiler emits where a foreign call has no usable contract (/* io.f() */ 0). Everything that can be structured should be.

Implementations§

Source§

impl Expr

Source

pub fn ident(name: impl Into<String>) -> Self

An identifier expression.

Source

pub fn binary(op: BinOp, lhs: Expr, rhs: Expr) -> Self

lhs op rhs.

Source

pub fn unary(op: UnOp, operand: Expr) -> Self

op operand.

Source

pub fn assign(lhs: Expr, op: AssignOp, rhs: Expr) -> Self

lhs op rhs, an assignment.

Trait Implementations§

Source§

impl Clone for Expr

Source§

fn clone(&self) -> Expr

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 Debug for Expr

Source§

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

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

impl Display for Expr

Source§

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

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

impl PartialEq for Expr

Source§

fn eq(&self, other: &Expr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 Expr

Auto Trait Implementations§

§

impl Freeze for Expr

§

impl RefUnwindSafe for Expr

§

impl Send for Expr

§

impl Sync for Expr

§

impl Unpin for Expr

§

impl UnsafeUnpin for Expr

§

impl UnwindSafe for Expr

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
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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.

§

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
§

impl<T> Pointee for T

§

type Metadata = ()

The metadata type for pointers and references to this type.
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.