Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

ASTFactory Class Reference

#include <ASTFactory.hpp>

List of all members.

Public Types

typedef factory_type_ factory_type
typedef factory_descriptor_ factory_descriptor
typedef factory_descriptor_list_ factory_descriptor_list

Public Methods

 ASTFactory ()
 Make new factory. Per default (Ref)CommonAST instances are generated.

 ASTFactory (const char *factory_node_name, factory_type factory)
virtual ~ASTFactory ()
 Destroy factory.

void registerFactory (int type, const char *ast_name, factory_type factory)
 Register a node factory for the node type type with name ast_name.

void setMaxNodeType (int type)
 Set the maximum node (AST) type this factory may encounter.

void addASTChild (ASTPair &currentAST, RefAST child)
 Add a child to the current AST.

virtual RefAST create ()
 Create new empty AST node. The right default type shou.

RefAST create (int type)
 Create AST node of the right type for 'type'.

RefAST create (int type, const ANTLR_USE_NAMESPACE(std) string &txt)
 Create AST node of the right type for 'type' and initialize with txt.

RefAST create (RefAST tr)
 Create duplicate of tr.

RefAST create (RefToken tok)
 Create new AST node and initialize contents from a token.

RefAST create (const ANTLR_USE_NAMESPACE(std) string &txt, ANTLR_USE_NAMESPACE(std) istream &infile)
 Create new AST node and initialize contents from a stream.

RefAST dup (RefAST t)
RefAST dupList (RefAST t)
 Duplicate tree including siblings of root.

RefAST dupTree (RefAST t)
RefAST make (ANTLR_USE_NAMESPACE(std) vector< RefAST > &nodes)
RefAST make (ASTArray *nodes)
void makeASTRoot (ASTPair &currentAST, RefAST root)
 Make an AST the root of current AST.

void setASTNodeFactory (const char *factory_node_name, factory_type factory)

Protected Methods

void loadChildren (ANTLR_USE_NAMESPACE(std) istream &infile, RefAST current)
void loadSiblings (ANTLR_USE_NAMESPACE(std) istream &infile, RefAST current)
bool checkCloseTag (ANTLR_USE_NAMESPACE(std) istream &infile)
RefAST getNodeOfType (unsigned int type)
const char * getASTNodeType (unsigned int type)
 get the name of the node 'type'

factory_type getASTNodeFactory (unsigned int type)

Protected Attributes

factory_descriptor default_factory_descriptor
factory_descriptor_list nodeFactories


Detailed Description

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.


Member Typedef Documentation

typedef factory_descriptor_ ASTFactory::factory_descriptor
 

typedef factory_descriptor_list_ ASTFactory::factory_descriptor_list
 

typedef factory_type_ ASTFactory::factory_type
 


Constructor & Destructor Documentation

ASTFactory::ASTFactory  
 

Make new factory. Per default (Ref)CommonAST instances are generated.

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::ASTFactory const char *    factory_node_name,
factory_type    factory
 

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   [virtual]
 

Destroy factory.


Member Function Documentation

void ASTFactory::addASTChild ASTPair   currentAST,
RefAST    child
 

Add a child to the current AST.

Add a child to the current AST

bool ASTFactory::checkCloseTag ANTLR_USE_NAMESPACE(std) istream &    infile [protected]
 

RefAST ASTFactory::create const ANTLR_USE_NAMESPACE(std) string &    txt,
ANTLR_USE_NAMESPACE(std) istream &    infile
 

Create new AST node and initialize contents from a stream.

RefAST ASTFactory::create RefToken    tok
 

Create new AST node and initialize contents from a token.

RefAST ASTFactory::create RefAST    tr
 

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.

RefAST ASTFactory::create int    type,
const ANTLR_USE_NAMESPACE(std) string &    txt
 

Create AST node of the right type for 'type' and initialize with txt.

RefAST ASTFactory::create int    type
 

Create AST node of the right type for 'type'.

RefAST ASTFactory::create   [virtual]
 

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.

RefAST ASTFactory::dup RefAST    t
 

Deep copy a single node. This function the new clone() methods in the AST interface. Returns a new RefAST(nullASTptr) if t is null.

RefAST ASTFactory::dupList RefAST    t
 

Duplicate tree including siblings of root.

Duplicate tree including siblings of root.

RefAST ASTFactory::dupTree RefAST    t
 

Duplicate a tree, assuming this is a root node of a tree-- duplicate that node and what's below; ignore siblings of root node.

factory_type ASTFactory::getASTNodeFactory unsigned int    type [inline, protected]
 

const char* ASTFactory::getASTNodeType unsigned int    type [inline, protected]
 

get the name of the node 'type'

RefAST ASTFactory::getNodeOfType unsigned int    type [inline, protected]
 

void ASTFactory::loadChildren ANTLR_USE_NAMESPACE(std) istream &    infile,
RefAST    current
[protected]
 

void ASTFactory::loadSiblings ANTLR_USE_NAMESPACE(std) istream &    infile,
RefAST    current
[protected]
 

RefAST ASTFactory::make ASTArray   nodes
 

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

RefAST ASTFactory::make ANTLR_USE_NAMESPACE(std) vector< RefAST > &    nodes
 

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).

void ASTFactory::makeASTRoot ASTPair   currentAST,
RefAST    root
 

Make an AST the root of current AST.

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.

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.

void ASTFactory::setMaxNodeType int    type
 

Set the maximum node (AST) type this factory may encounter.


Member Data Documentation

factory_descriptor ASTFactory::default_factory_descriptor [protected]
 

factory_descriptor_list ASTFactory::nodeFactories [protected]
 


The documentation for this class was generated from the following files:
Generated on Wed Nov 3 12:59:24 2004 for Lemur Toolkit by doxygen1.2.18