cairo_lang_syntax_codegen::spec

Struct NodesAggregator

source
pub struct NodesAggregator { /* private fields */ }
Expand description

A tool to aggregate/gather nodes in various forms and eventually emit them as a vector.

Implementations§

source§

impl NodesAggregator

source

pub fn get(self) -> Vec<Node>

Gets all the aggregated nodes.

source

pub fn add_struct(self, builder: StructBuilder) -> Self

Adds a struct node.

source

pub fn add_enum(self, builder: EnumBuilder) -> Self

Adds an enum node.

source

pub fn add_list(self, name: &str, element_type: &str) -> Self

Adds a node for a list of syntax elements.

source

pub fn add_separated_list( self, name: &str, element_type: &str, separator_type: &str, ) -> Self

Adds a node for a list of syntax elements separated by a terminal.

source

pub fn add_token(self, pure_name: &str) -> Self

Adds a non-keyword node for a token node (similar to an empty struct).

source

pub fn add_keyword_token(self, pure_name: &str) -> Self

Adds a keyword node for a token node (similar to an empty struct).

source

pub fn add_terminal(self, pure_name: &str, is_keyword: bool) -> Self

Adds a node for a token node (similar to an empty struct).

source

pub fn add_keyword_token_and_terminal(self, pure_name: &str) -> Self

Adds a keyword token node and a keyword terminal node of the relevant names. e.g. for pure_name=“Identifier” it creates TokenIdentifier and TerminalIdentifier.

source

pub fn add_token_and_terminal(self, pure_name: &str) -> Self

Adds a non-keyword token node and a non-keyword terminal node of the relevant names. e.g. for pure_name=“Identifier” it creates TokenIdentifier and TerminalIdentifier.

source

pub fn add_option(self, name: &str) -> Self

Adds an enum node for an option with 2 variants: empty and non-empty. Creates the empty struct to be used for the empty variant. The Type for the non-empty variant is name and it should exist independently of this call.

For example, for name=TypeClause, creates an enum OptionTypeClause with variants Empty(OptionTypeClauseEmpty) and TypeClause(TypeClause), where OptionTypeClauseEmpty is created here and TypeClause should exist independently.

source

pub fn add_all_tokens_enum(self, name: &str) -> Self

Adds an enum containing all the tokens as variants.

Trait Implementations§

source§

impl Default for NodesAggregator

source§

fn default() -> NodesAggregator

Returns the “default value” for a type. Read more

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.