[][src]Enum saltwater::Definition

pub enum Definition {
    Object(Vec<Token>),
    Function {
        params: Vec<InternedStr>,
        body: Vec<Token>,
    },
}

A macro definition.

Variants

Object(Vec<Token>)

An object macro: #define a b + 1

Function

A function macro: #define f(a) a + 1

Fields of Function

params: Vec<InternedStr>

The function parameters.

In the example above, a is a function parameter. A macro may have 0 or more parameters. Variadic macros (__VA_ARGS__) are not yet implemented.

Note that function macros may be called with an empty replacement list for any parameter. For example, f() is valid and exapands to + 1. Similarly, for #define g(a, b) a + b, g(,) is valid and expands to +.

body: Vec<Token>

The body for a function macro.

The function body itself undergoes recursive macro replacement.

Trait Implementations

impl Clone for Definition[src]

impl Debug for Definition[src]

impl From<Vec<Token>> for Definition[src]

impl PartialEq<Definition> for Definition[src]

impl StructuralPartialEq for Definition[src]

impl<'_> TryFrom<&'_ str> for Definition[src]

type Error = LexError

The type returned in the event of a conversion error.

Auto Trait Implementations

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>,