Grammar

Struct Grammar 

Source
pub struct Grammar;
Expand description

The Pest parser struct.

The grammar is included directly from the grammar.pest file.

§Grammar

WHITESPACE = _{ “ “ | “\t” }

not_operator = { “NOT” | “not” | “!” }

and_operator = { “AND” | “and” | “&” }

nand_operator = { “NAND” | “nand” | “!&” }

or_operator = { “OR” | “or” | “|” }

nor_operator = { “NOR” | “nor” | “!|” }

xor_operator = { “XOR” | “xor” | “^” }

xnor_operator = { “XNOR” | “xnor” | “!^” }

left_parenthesis = { “(” }

right_parenthesis = { “)” }

identifier = @{ ASCII_ALPHA_UPPER ~ !(ASCII_ALPHA_UPPER) }

term = { not_operator* ~ (identifier | left_parenthesis ~ expression ~ right_parenthesis) }

xor_clause = { term ~ ((xor_operator | xnor_operator) ~ term)* }

and_clause = { xor_clause ~ ((and_operator | nand_operator) ~ xor_clause)* }

expression = { and_clause ~ ((or_operator | nor_operator) ~ and_clause)* }

NEWLINE = _{ “\n” | “\r\n” }

file = { SOI ~ expression ~ NEWLINE ~ (expression ~ NEWLINE)* ~ EOI }

Trait Implementations§

Source§

impl Parser<Rule> for Grammar

Source§

fn parse<'i>(rule: Rule, input: &'i str) -> Result<Pairs<'i, Rule>, Error<Rule>>

Parses a &str starting from rule.

Auto Trait Implementations§

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