[][src]Struct leo_grammar::Grammar

pub struct Grammar<'ast> { /* fields omitted */ }

The pest abstract syntax tree (ast) for a Leo program.

The Grammar type represents a Leo program as a series of recursive data types. These data types form a tree that begins from a [File] type root.

A new Grammar type can be created from a *.leo file at a Path. A Grammar type can be used to create a new [Ast] type.

Implementations

impl<'ast> Grammar<'ast>[src]

pub fn new(
    file_path: &'ast Path,
    program_string: &'ast str
) -> Result<Self, ParserError>
[src]

Creates a new abstract syntax tree given the file path.

pub fn load_file(file_path: &'ast Path) -> Result<String, ParserError>[src]

Loads the Leo code as a string from the given file path.

pub fn as_repr(&self) -> &File<'ast>[src]

Returns a reference to the inner abstract syntax tree representation.

pub fn to_json_string(&self) -> Result<String, ParserError>[src]

Serializes the abstract syntax tree into a JSON string.

Auto Trait Implementations

impl<'ast> RefUnwindSafe for Grammar<'ast>[src]

impl<'ast> Send for Grammar<'ast>[src]

impl<'ast> Sync for Grammar<'ast>[src]

impl<'ast> Unpin for Grammar<'ast>[src]

impl<'ast> UnwindSafe for Grammar<'ast>[src]

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> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[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.