Skip to main content

Node

Enum Node 

Source
pub enum Node {
Show 38 variants Identifier(Leaf<String>), Numb(Leaf<f64>), Text(Leaf<String>), Nothing(Leaf<()>), Unclosed(Leaf<char>), UnexpectedToken(Leaf<String>), List(UnaryOp), Namespace(UnaryOp), AffirmOp(UnaryOp), NegateOp(UnaryOp), LogicalNegationOp(UnaryOp), LiftingOp(UnaryOp), FunctionDefinitionOp(BinaryOp), ApplicationOp(BinaryOp), PairingOp(BinaryOp), MappingOp(BinaryOp), AssignmentOp(BinaryOp), LabellingOp(BinaryOp), SubcontextingOp(BinaryOp), ThenOp(BinaryOp), PowerOp(BinaryOp), ProductOp(BinaryOp), DivisionOp(BinaryOp), ModuloOp(BinaryOp), SumOp(BinaryOp), SubtractionOp(BinaryOp), EqualToOp(BinaryOp), NotEqualToOp(BinaryOp), LessThanOp(BinaryOp), LessThanOrEqualToOp(BinaryOp), GreaterThanOp(BinaryOp), GreaterThanOrEqualToOp(BinaryOp), AndOp(BinaryOp), OrOp(BinaryOp), ConditionalOp(BinaryOp), AlternativeOp(BinaryOp), CompositionOp(BinaryOp), ReverseCompositionOp(BinaryOp),
}
Expand description

A node of the Swan syntax tree.

The comment on each variant shows the syntax that produces it.

Variants§

§

Identifier(Leaf<String>)

A name, such as x or my_var.

§

Numb(Leaf<f64>)

A number literal, such as 42 or 1.5e-3.

§

Text(Leaf<String>)

A text literal, such as "hello". The value excludes the quotes.

§

Nothing(Leaf<()>)

(), or an empty expression.

§

Unclosed(Leaf<char>)

Syntax error: a group that is not closed. The value is the missing closing bracket (), ] or }).

§

UnexpectedToken(Leaf<String>)

Syntax error: a token that cannot appear where it was found. The value is a debug description of the token.

§

List(UnaryOp)

[X]: a list literal.

§

Namespace(UnaryOp)

{X}: a namespace literal.

§

AffirmOp(UnaryOp)

+X

§

NegateOp(UnaryOp)

-X

§

LogicalNegationOp(UnaryOp)

!X

§

LiftingOp(UnaryOp)

$X

§

FunctionDefinitionOp(BinaryOp)

X -> Y

§

ApplicationOp(BinaryOp)

X Y: function application, written by juxtaposition.

§

PairingOp(BinaryOp)

X , Y

§

MappingOp(BinaryOp)

X => Y

§

AssignmentOp(BinaryOp)

X = Y

§

LabellingOp(BinaryOp)

X : Y

§

SubcontextingOp(BinaryOp)

X . Y

§

ThenOp(BinaryOp)

X ~> Y

§

PowerOp(BinaryOp)

X ^ Y

§

ProductOp(BinaryOp)

X * Y

§

DivisionOp(BinaryOp)

X / Y

§

ModuloOp(BinaryOp)

X % Y

§

SumOp(BinaryOp)

X + Y

§

SubtractionOp(BinaryOp)

X - Y

§

EqualToOp(BinaryOp)

X == Y

§

NotEqualToOp(BinaryOp)

X != Y

§

LessThanOp(BinaryOp)

X < Y

§

LessThanOrEqualToOp(BinaryOp)

X <= Y

§

GreaterThanOp(BinaryOp)

X > Y

§

GreaterThanOrEqualToOp(BinaryOp)

X >= Y

§

AndOp(BinaryOp)

X & Y

§

OrOp(BinaryOp)

X | Y

§

ConditionalOp(BinaryOp)

X ? Y

§

AlternativeOp(BinaryOp)

X ; Y

§

CompositionOp(BinaryOp)

X << Y

§

ReverseCompositionOp(BinaryOp)

X >> Y

Implementations§

Source§

impl Node

Source

pub fn position(&self) -> usize

Returns the source byte offset recorded in this node.

Trait Implementations§

Source§

impl Clone for Node

Source§

fn clone(&self) -> Node

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 Node

Source§

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

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

impl PartialEq for Node

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Node

Auto Trait Implementations§

§

impl Freeze for Node

§

impl RefUnwindSafe for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl UnsafeUnpin for Node

§

impl UnwindSafe for Node

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.