[][src]Macro open_vaf::resolve

macro_rules! resolve {
    ($fold:expr; $name:ident as $($declaration:ident($id:ident) => $block:block),+) => { ... };
}

A macro that hides the boiler plate required for name resolution using the resolver struct It is defined in the name_resolution module but due to limitations of rustdoc can't be shown there in the documentation If $name wasn't found or doesn't math any SymbolDeclaration::$declaration the appropriate errors are added to $self.errors and execution continuous after the macro

Arguments

  • $self - reference to an ast fold (implementation of the Fold trait)

  • $name - The Identifier (type Ident) that should be resolved

The following three arguments can be repeated as often as necessary (like in a match block)

  • $declaration An identifier of an SymbolDeclaration variant which you wish to resolve $nameas

  • $id The identifier under which the ID of the resolved declaration will be available inside the associated `$block

  • $block A block ({statements}) which will be executed when $name is resolved as a SymbolDeclaration::$declaration

Examples

The following tries to resolve ident as a Nature

use OpenVAF::symbol_table::SymbolDeclaration::Nature;
use OpenVAF::symbol_table::SymbolDeclaration::Discipline;

resolve!(fold; ident as
           Nature(id) => {
                println!("Resolved nature")
            }
            Discipline(id) => {
                println!("Resolved a discipline")
            }
);

println!("Not found or not a discipline/nature")