Xreate
The Xreate programming language
Public Member Functions | List of all members
AST Class Reference

AST in an inconsistent form during construction. More...

#include <ast.h>

Detailed Description

AST in an inconsistent form during construction.

Represents AST under construction(inconsistent state).

Attention
Clients should use rather xreate::AST unless client's code explicitly works with Syntax Tree during construction.

Typically an instance is created by xreate::XreateManager only and filled out by the parser

See also
xreate::XreateManager::prepare(std::string&&)
Inheritance diagram for AST:
AST

Public Member Functions

void add (Function *f)
 Adds new function to AST. More...
 
void add (MetaRuleAbstract *r)
 Adds new declarative rule to AST. More...
 
ManagedScpPtr add (CodeScope *scope)
 Registers new code block.
 
void add (TypeAnnotation t, Atom< Identifier_t > alias)
 Add new type to AST. More...
 
std::string getModuleName ()
 Current module's name.
 
ManagedPtr< FunctionfindFunction (const std::string &name)
 Looks for function with given name. More...
 
std::list< ManagedFnPtr > getAllFunctions () const
 Returns all function in AST.
 
std::list< ManagedFnPtr > getFunctionSpecializations (const std::string &fnName) const
 Returns all specializations of a function with a given name. More...
 
template<class Target >
ManagedPtr< Target > begin ()
 
xreate::ASTfinalize ()
 Performs all necessary steps after AST is built. More...
 
void addDFAData (Expression &&data)
 Stores DFA scheme for later use by DFA Pass. More...
 
void addExternData (ExternData &&data)
 Stores data for later use by xreate::ExternLayer.
 
void addInterfaceData (const ASTInterface &interface, Expression &&data)
 Generalized function to store particular data for later use by particular pass. More...
 

Symbols Recognition

std::set< std::pair< CodeScope *, Expression > > bucketUnrecognizedIdentifiers
 
void recognizeVariantConstructor (Expression &function)
 Tries to find out whether expression is Variant constructor.
 
Atom< Number_t > recognizeVariantConstructor (Atom< Identifier_t > ident)
 
void postponeIdentifier (CodeScope *scope, const Expression &id)
 Postpones unrecognized identifier for future second round of recognition. More...
 
void recognizePostponedIdentifiers ()
 Second round of identifiers recognition done right after AST is fully constructed.
 

Member Function Documentation

◆ add() [1/3]

void add ( Function f)

Adds new function to AST.

Parameters
fFunction to register

◆ add() [2/3]

void add ( MetaRuleAbstract *  r)

Adds new declarative rule to AST.

Parameters
rDeclarative Rule

◆ add() [3/3]

void add ( TypeAnnotation  t,
Atom< Identifier_t >  alias 
)

Add new type to AST.

Parameters
tType definition
aliasTyper name

◆ addDFAData()

void addDFAData ( Expression &&  data)

Stores DFA scheme for later use by DFA Pass.

Treats expression as a DFA scheme and feeds to the DFA Pass later

Parameters
dataDFA Scheme
See also
xreate::DFAPass

◆ addInterfaceData()

void addInterfaceData ( const ASTInterface &  interface,
Expression &&  data 
)

Generalized function to store particular data for later use by particular pass.

Parameters
interfaceParticular Interface
dataParticular data

◆ begin()

ManagedPtr<Target> begin ( )
Returns
First element in Functions/Scopes/Rules list depending on template parameter
Template Parameters
Targeteither Function or CodeScope or MetaRuleAbstract

◆ finalize()

xreate::AST * finalize ( )

Performs all necessary steps after AST is built.

Performs all finalization steps and moves AST into consistent state represented by xreate::AST

See also
xreate::AST
Returns
AST in consistent state

◆ findFunction()

ManagedPtr< Function > findFunction ( const std::string &  name)

Looks for function with given name.

Parameters
nameFunction name to find
Note
Requires that only one function exists under given name
Returns
Found function

◆ getFunctionSpecializations()

std::list< ManagedFnPtr > getFunctionSpecializations ( const std::string &  fnName) const

Returns all specializations of a function with a given name.

Parameters
fnNamefunction to find
Returns
list of found function specializations

◆ postponeIdentifier()

void postponeIdentifier ( CodeScope scope,
const Expression id 
)

Postpones unrecognized identifier for future second round of recognition.

Parameters
scopeCode block identifier is encountered
idIdentifier

The documentation for this class was generated from the following files: