#include <ASTFactory.hpp>
AST Super Factory shared by TreeParser and Parser. This super factory maintains a map of all AST node types to their respective AST factories. One instance should be shared among a parser/treeparser chain.
- Todo
- check all this code for possible use of references in stead of RefAST's.
◆ factory_descriptor
◆ factory_descriptor_list
◆ factory_type
◆ ASTFactory() [1/3]
| ASTFactory::ASTFactory |
( |
| ) |
|
Make new factory. Per default (Ref)CommonAST instances are generated.
Initialize factory.
AST Support code shared by TreeParser and Parser. We use delegation to share code (and have only one bit of code to maintain) rather than subclassing or superclassing (forces AST support code to be loaded even when you don't want to do AST stuff).
This class collects all factories of AST types used inside the code. New AST node types are registered with the registerFactory method. On creation of an ASTFactory object a default AST node factory may be specified.
When registering types gaps between different types are filled with entries for the default factory.
◆ ASTFactory() [2/3]
| ASTFactory::ASTFactory |
( |
const char * | factory_node_name, |
|
|
factory_type | fact ) |
Initialize factory with a non default node type. factory_node_name should be the name of the AST node type the factory generates. (should exist during the existance of this ASTFactory instance)
◆ ~ASTFactory()
| ASTFactory::~ASTFactory |
( |
| ) |
|
|
virtual |
◆ ASTFactory() [3/3]
◆ addASTChild()
| void ASTFactory::addASTChild |
( |
ASTPair & | currentAST, |
|
|
RefAST | child ) |
Add a child to the current AST.
Add a child to the current AST
◆ checkCloseTag()
| bool ASTFactory::checkCloseTag |
( |
std ::istream & | infile | ) |
|
|
protected |
◆ create() [1/6]
Create new empty AST node. The right default type shou.
Create a new empty AST node; if the user did not specify an AST node type, then create a default one: CommonAST.
◆ create() [2/6]
| RefAST ASTFactory::create |
( |
const std ::string & | txt, |
|
|
std ::istream & | infile ) |
Create new AST node and initialize contents from a stream.
◆ create() [3/6]
| RefAST ASTFactory::create |
( |
int | type | ) |
|
Create AST node of the right type for 'type'.
◆ create() [4/6]
| RefAST ASTFactory::create |
( |
int | type, |
|
|
const std ::string & | txt ) |
Create AST node of the right type for 'type' and initialize with txt.
◆ create() [5/6]
Create duplicate of tr.
Create a new empty AST node; if the user did not specify an AST node type, then create a default one: CommonAST.
◆ create() [6/6]
Create new AST node and initialize contents from a token.
◆ dup()
Deep copy a single node. This function the new clone() methods in the AST interface. Returns a new RefAST(nullASTptr) if t is null.
Deep copy a single node. This function the new clone() methods in the AST interface. Returns nullAST if t is null.
◆ dupList()
Duplicate tree including siblings of root.
Duplicate tree including siblings of root.
◆ dupTree()
Duplicate a tree, assuming this is a root node of a tree– duplicate that node and what's below; ignore siblings of root node.
Duplicate a tree, assuming this is a root node of a tree duplicate that node and what's below; ignore siblings of root node.
◆ getASTNodeFactory()
| factory_type ASTFactory::getASTNodeFactory |
( |
unsigned int | type | ) |
|
|
inlineprotected |
◆ getASTNodeType()
| const char * ASTFactory::getASTNodeType |
( |
unsigned int | type | ) |
|
|
inlineprotected |
get the name of the node 'type'
◆ getNodeOfType()
| RefAST ASTFactory::getNodeOfType |
( |
unsigned int | type | ) |
|
|
inlineprotected |
◆ loadChildren()
| void ASTFactory::loadChildren |
( |
std ::istream & | infile, |
|
|
RefAST | current ) |
|
protected |
◆ loadSiblings()
| void ASTFactory::loadSiblings |
( |
std ::istream & | infile, |
|
|
RefAST | current ) |
|
protected |
◆ make() [1/2]
Make a tree from a list of nodes, where the nodes are contained in an ASTArray object. The ASTArray is deleted after use.
- Todo
- FIXME! I have a feeling we can get rid of this ugly ASTArray thing
Make a tree from a list of nodes, where the nodes are contained in an ASTArray object
◆ make() [2/2]
Make a tree from a list of nodes. The first element in the array is the root. If the root is null, then the tree is a simple list not a tree. Handles null children nodes correctly. For example, make(a, b, null, c) yields tree (a b c). make(null,a,b) yields tree (nil a b).
◆ makeASTRoot()
| void ASTFactory::makeASTRoot |
( |
ASTPair & | currentAST, |
|
|
RefAST | root ) |
Make an AST the root of current AST.
◆ operator=()
◆ registerFactory()
| void ASTFactory::registerFactory |
( |
int | type, |
|
|
const char * | ast_name, |
|
|
factory_type | factory ) |
Register a node factory for the node type type with name ast_name.
Register a factory for a given AST type.
◆ setASTNodeFactory()
| void ASTFactory::setASTNodeFactory |
( |
const char * | factory_node_name, |
|
|
factory_type | factory ) |
Set a new default AST type. factory_node_name should be the name of the AST node type the factory generates. (should exist during the existance of this ASTFactory instance). Only change factory between parser runs. You might get unexpected results otherwise.
◆ setMaxNodeType()
| void ASTFactory::setMaxNodeType |
( |
int | type | ) |
|
Set the maximum node (AST) type this factory may encounter.
◆ default_factory_descriptor
◆ nodeFactories
The documentation for this class was generated from the following files: