[][src]Enum glitter_lang::ast::Expression

pub enum Expression {
    Named {
        name: Name,
        sub: Tree,
    },
    Format {
        style: Vec<Style>,
        sub: Tree,
    },
    Group {
        l: String,
        r: String,
        sub: Tree,
    },
    Literal(String),
}

The types of possible expressions which form an expression tree

The gist format has three types of valid expressions:

  1. Named expressions
  2. Group Expressions
  3. Literal Expressions

The interpreter transforms these expressions to their final output after they have been parsed from the input string.

Named expressions take one of two forms: the plain form with no arguments, or with arguments

  • \name plain form
  • \name(\exp1\exp2...\expn) any number of expressions, no separaters

Group expressions are set of expressions, which are not comma seperated. There are a few base group types:

  • \() parentheses - wrap with parens
  • \{} curly braces - wrap with curly braces
  • \[] square brackets - wrap contents with square brackets
  • \<> angle brackets - wrap contenst with angle brackets

By nesting groups of expressions, we can create an implicit tree.

A literal expression is any valid utf8 characters between single quites, except for single quotes and backslashes.

'hello''we''are''literal''expressions''I am one including whitespace'

Variants

Named

An expression with a name and optional arguments which represents git repository stats

Fields of Named

name: Name

Name of the expression

sub: Tree

Arguments to the expression, zero or more

Format

An expression which represents terminal text formatting

Fields of Format

style: Vec<Style>sub: Tree
Group

A group of sub-expressions which forms an expression tree

Fields of Group

l: String

Left delimiter

r: String

Right delimiter

sub: Tree

A tree of sub expressions

Literal(String)

Literal characters including whitespace, surrounded by single quotes

Trait Implementations

impl Eq for Expression[src]

impl Clone for Expression[src]

impl PartialEq<Expression> for Expression[src]

impl Debug for Expression[src]

impl Display for Expression[src]

Auto Trait Implementations

Blanket Implementations

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

type Owned = T

The resulting type after obtaining ownership.

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

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

impl<T> ToString for T where
    T: Display + ?Sized
[src]

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<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

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