C# Класс Spring.Expressions.Parser.antlr.ASTFactory

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

Typically, setASTNodeType is used to specify the homogeneous type of node to create, but you can override create() to make heterogeneous nodes etc...

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
defaultASTNodeTypeObject_ Type
defaultCreator_ ASTNodeCreator
heteroList_ FactoryEntry[]
typename2creator_ Hashtable

Открытые методы

Метод Описание
ASTFactory ( ) : System

Constructs an ASTFactory with the default AST node type of antlr.CommonAST.

ASTFactory ( Type nodeType ) : System

Constructs an ASTFactory and use the specified AST node type as the default.

ASTFactory ( string nodeTypeName ) : System

Constructs an ASTFactory and use the specified AST node type as the default.

addASTChild ( ASTPair &currentAST, Spring.Expressions.Parser.antlr.collections.AST child ) : void

Add a child to the current AST

create ( ) : Spring.Expressions.Parser.antlr.collections.AST

Creates a new uninitialized AST node. Since a specific AST Node Type wasn't indicated, the new AST node is created using the current default AST Node type - defaultASTNodeTypeObject_

create ( IToken tok ) : Spring.Expressions.Parser.antlr.collections.AST

Creates and initializes a new AST node using the specified Token instance. The System.Type used for creating this new AST node is determined by the following: the current TokenTypeID-to-ASTNodeType mapping (if any) or, the defaultASTNodeTypeObject_ otherwise

create ( IToken tok, string ASTNodeTypeName ) : Spring.Expressions.Parser.antlr.collections.AST

Creates a new AST node using the specified AST Node Type name.

Once created, the new AST node is initialized with the specified Token instance. The System.Type used for creating this new AST node is determined solely by ASTNodeTypeName.

The AST Node type must have a default/parameterless constructor.

create ( Spring.Expressions.Parser.antlr.collections.AST aNode ) : Spring.Expressions.Parser.antlr.collections.AST

Creates and initializes a new AST node using the specified AST Node instance. the new AST node is initialized with the specified Token type ID and string. The System.Type used for creating this new AST node is determined solely by aNode. The AST Node type must have a default/parameterless constructor.

create ( int type ) : Spring.Expressions.Parser.antlr.collections.AST

Creates and initializes a new AST node using the specified Token Type ID. The System.Type used for creating this new AST node is determined by the following: the current TokenTypeID-to-ASTNodeType mapping (if any) or, the defaultASTNodeTypeObject_ otherwise

create ( int type, string txt ) : Spring.Expressions.Parser.antlr.collections.AST

Creates and initializes a new AST node using the specified Token Type ID. The System.Type used for creating this new AST node is determined by the following: the current TokenTypeID-to-ASTNodeType mapping (if any) or, the defaultASTNodeTypeObject_ otherwise

create ( int type, string txt, string ASTNodeTypeName ) : Spring.Expressions.Parser.antlr.collections.AST

Creates a new AST node using the specified AST Node Type name. Once created, the new AST node is initialized with the specified Token type ID and string. The System.Type used for creating this new AST node is determined solely by ASTNodeTypeName. The AST Node type must have a default/parameterless constructor.

dup ( Spring.Expressions.Parser.antlr.collections.AST t ) : Spring.Expressions.Parser.antlr.collections.AST

Returns a copy of the specified AST Node instance. The copy is obtained by using the ICloneable method Clone().

dupList ( Spring.Expressions.Parser.antlr.collections.AST t ) : Spring.Expressions.Parser.antlr.collections.AST

Duplicate AST Node tree rooted at specified AST node and all of it's siblings.

dupTree ( Spring.Expressions.Parser.antlr.collections.AST t ) : Spring.Expressions.Parser.antlr.collections.AST

Duplicate AST Node tree rooted at specified AST node. Ignore it's siblings.

error ( string e ) : void

To change where error messages go, can subclass/override this method and then setASTFactory in Parser and TreeParser. This method removes a prior dependency on class antlr.Tool.

make ( ) : Spring.Expressions.Parser.antlr.collections.AST

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, build(a, b, null, c) yields tree (a b c). build(null,a,b) yields tree (nil a b).

make ( Spring.Expressions.Parser.antlr.collections.impl.ASTArray nodes ) : Spring.Expressions.Parser.antlr.collections.AST

Make a tree from a list of nodes, where the nodes are contained in an ASTArray object.

makeASTRoot ( ASTPair &currentAST, Spring.Expressions.Parser.antlr.collections.AST root ) : void

Make an AST the root of current AST.

setASTNodeCreator ( ASTNodeCreator creator ) : void

Register an ASTNodeCreator to be used for creating node by default.

setASTNodeType ( string t ) : void

Sets the global default AST Node Type for this ASTFactory instance. This method also attempts to load the System.Type instance for the specified typename.

setMaxNodeType ( int NodeType ) : void

Pre-expands the internal list of TokenTypeID-to-ASTNodeType mappings to the specified size. This is primarily a convenience method that can be used to prevent unnecessary and costly re-org of the mappings list.

setTokenTypeASTNodeCreator ( int NodeType, ASTNodeCreator creator ) : void

Register an ASTNodeCreator for a given Token type ID.

setTokenTypeASTNodeType ( int tokenType, string NodeTypeName ) : void

Specify an "override" for the AST type created for the specified Token type.

This method is useful for situations that ANTLR cannot oridinarily deal with (i.e., when you create a token based upon a nonliteral token symbol like #[LT(1)]. This is a runtime value and ANTLR cannot determine the token type (and hence the AST) statically.

Приватные методы

Метод Описание
createFromAST ( Spring.Expressions.Parser.antlr.collections.AST node ) : Spring.Expressions.Parser.antlr.collections.AST
createFromNodeName ( string nodeTypeName ) : Spring.Expressions.Parser.antlr.collections.AST
createFromNodeType ( int nodeTypeIndex ) : Spring.Expressions.Parser.antlr.collections.AST
createFromNodeTypeObject ( Type nodeTypeObject ) : Spring.Expressions.Parser.antlr.collections.AST
loadNodeTypeObject ( string nodeTypeName ) : Type
registerFactory ( int NodeType, string NodeTypeName ) : void

Описание методов

ASTFactory() публичный Метод

Constructs an ASTFactory with the default AST node type of antlr.CommonAST.
public ASTFactory ( ) : System
Результат System

ASTFactory() публичный Метод

Constructs an ASTFactory and use the specified AST node type as the default.
public ASTFactory ( Type nodeType ) : System
nodeType System.Type /// MetaType of default AST node type for this factory. ///
Результат System

ASTFactory() публичный Метод

Constructs an ASTFactory and use the specified AST node type as the default.
public ASTFactory ( string nodeTypeName ) : System
nodeTypeName string /// Name of default AST node type for this factory. ///
Результат System

addASTChild() публичный Метод

Add a child to the current AST
public addASTChild ( ASTPair &currentAST, Spring.Expressions.Parser.antlr.collections.AST child ) : void
currentAST ASTPair The AST to add a child to
child Spring.Expressions.Parser.antlr.collections.AST The child AST to be added
Результат void

create() публичный Метод

Creates a new uninitialized AST node. Since a specific AST Node Type wasn't indicated, the new AST node is created using the current default AST Node type - defaultASTNodeTypeObject_
public create ( ) : Spring.Expressions.Parser.antlr.collections.AST
Результат Spring.Expressions.Parser.antlr.collections.AST

create() публичный Метод

Creates and initializes a new AST node using the specified Token instance. The System.Type used for creating this new AST node is determined by the following: the current TokenTypeID-to-ASTNodeType mapping (if any) or, the defaultASTNodeTypeObject_ otherwise
public create ( IToken tok ) : Spring.Expressions.Parser.antlr.collections.AST
tok IToken Token instance to be used to create new AST Node.
Результат Spring.Expressions.Parser.antlr.collections.AST

create() публичный Метод

Creates a new AST node using the specified AST Node Type name.
Once created, the new AST node is initialized with the specified Token instance. The System.Type used for creating this new AST node is determined solely by ASTNodeTypeName.

The AST Node type must have a default/parameterless constructor.

public create ( IToken tok, string ASTNodeTypeName ) : Spring.Expressions.Parser.antlr.collections.AST
tok IToken Token instance to be used to initialize the new AST Node.
ASTNodeTypeName string /// Fully qualified name of the Type to be used for creating the new AST Node. ///
Результат Spring.Expressions.Parser.antlr.collections.AST

create() публичный Метод

Creates and initializes a new AST node using the specified AST Node instance. the new AST node is initialized with the specified Token type ID and string. The System.Type used for creating this new AST node is determined solely by aNode. The AST Node type must have a default/parameterless constructor.
public create ( Spring.Expressions.Parser.antlr.collections.AST aNode ) : Spring.Expressions.Parser.antlr.collections.AST
aNode Spring.Expressions.Parser.antlr.collections.AST AST Node instance to be used for creating the new AST Node.
Результат Spring.Expressions.Parser.antlr.collections.AST

create() публичный Метод

Creates and initializes a new AST node using the specified Token Type ID. The System.Type used for creating this new AST node is determined by the following: the current TokenTypeID-to-ASTNodeType mapping (if any) or, the defaultASTNodeTypeObject_ otherwise
public create ( int type ) : Spring.Expressions.Parser.antlr.collections.AST
type int Token type ID to be used to create new AST Node.
Результат Spring.Expressions.Parser.antlr.collections.AST

create() публичный Метод

Creates and initializes a new AST node using the specified Token Type ID. The System.Type used for creating this new AST node is determined by the following: the current TokenTypeID-to-ASTNodeType mapping (if any) or, the defaultASTNodeTypeObject_ otherwise
public create ( int type, string txt ) : Spring.Expressions.Parser.antlr.collections.AST
type int Token type ID to be used to create new AST Node.
txt string Text for initializing the new AST Node.
Результат Spring.Expressions.Parser.antlr.collections.AST

create() публичный Метод

Creates a new AST node using the specified AST Node Type name. Once created, the new AST node is initialized with the specified Token type ID and string. The System.Type used for creating this new AST node is determined solely by ASTNodeTypeName. The AST Node type must have a default/parameterless constructor.
public create ( int type, string txt, string ASTNodeTypeName ) : Spring.Expressions.Parser.antlr.collections.AST
type int Token type ID to be used to create new AST Node.
txt string Text for initializing the new AST Node.
ASTNodeTypeName string Fully qualified name of the Type to be used for creating the new AST Node.
Результат Spring.Expressions.Parser.antlr.collections.AST

dup() публичный Метод

Returns a copy of the specified AST Node instance. The copy is obtained by using the ICloneable method Clone().
public dup ( Spring.Expressions.Parser.antlr.collections.AST t ) : Spring.Expressions.Parser.antlr.collections.AST
t Spring.Expressions.Parser.antlr.collections.AST AST Node to copy.
Результат Spring.Expressions.Parser.antlr.collections.AST

dupList() публичный Метод

Duplicate AST Node tree rooted at specified AST node and all of it's siblings.
public dupList ( Spring.Expressions.Parser.antlr.collections.AST t ) : Spring.Expressions.Parser.antlr.collections.AST
t Spring.Expressions.Parser.antlr.collections.AST Root of AST Node tree.
Результат Spring.Expressions.Parser.antlr.collections.AST

dupTree() публичный Метод

Duplicate AST Node tree rooted at specified AST node. Ignore it's siblings.
public dupTree ( Spring.Expressions.Parser.antlr.collections.AST t ) : Spring.Expressions.Parser.antlr.collections.AST
t Spring.Expressions.Parser.antlr.collections.AST Root of AST Node tree.
Результат Spring.Expressions.Parser.antlr.collections.AST

error() публичный Метод

To change where error messages go, can subclass/override this method and then setASTFactory in Parser and TreeParser. This method removes a prior dependency on class antlr.Tool.
public error ( string e ) : void
e string
Результат void

make() публичный Метод

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, build(a, b, null, c) yields tree (a b c). build(null,a,b) yields tree (nil a b).
public make ( ) : Spring.Expressions.Parser.antlr.collections.AST
Результат Spring.Expressions.Parser.antlr.collections.AST

make() публичный Метод

Make a tree from a list of nodes, where the nodes are contained in an ASTArray object.
public make ( Spring.Expressions.Parser.antlr.collections.impl.ASTArray nodes ) : Spring.Expressions.Parser.antlr.collections.AST
nodes Spring.Expressions.Parser.antlr.collections.impl.ASTArray List of Nodes.
Результат Spring.Expressions.Parser.antlr.collections.AST

makeASTRoot() публичный Метод

Make an AST the root of current AST.
public makeASTRoot ( ASTPair &currentAST, Spring.Expressions.Parser.antlr.collections.AST root ) : void
currentAST ASTPair
root Spring.Expressions.Parser.antlr.collections.AST
Результат void

setASTNodeCreator() публичный Метод

Register an ASTNodeCreator to be used for creating node by default.
public setASTNodeCreator ( ASTNodeCreator creator ) : void
creator ASTNodeCreator The ASTNodeCreator.
Результат void

setASTNodeType() публичный Метод

Sets the global default AST Node Type for this ASTFactory instance. This method also attempts to load the System.Type instance for the specified typename.
public setASTNodeType ( string t ) : void
t string Fully qualified AST Node Type name.
Результат void

setMaxNodeType() публичный Метод

Pre-expands the internal list of TokenTypeID-to-ASTNodeType mappings to the specified size. This is primarily a convenience method that can be used to prevent unnecessary and costly re-org of the mappings list.
public setMaxNodeType ( int NodeType ) : void
NodeType int Maximum Token Type ID.
Результат void

setTokenTypeASTNodeCreator() публичный Метод

Register an ASTNodeCreator for a given Token type ID.
public setTokenTypeASTNodeCreator ( int NodeType, ASTNodeCreator creator ) : void
NodeType int The Token type ID.
creator ASTNodeCreator The creater to register.
Результат void

setTokenTypeASTNodeType() публичный Метод

Specify an "override" for the AST type created for the specified Token type.
This method is useful for situations that ANTLR cannot oridinarily deal with (i.e., when you create a token based upon a nonliteral token symbol like #[LT(1)]. This is a runtime value and ANTLR cannot determine the token type (and hence the AST) statically.
public setTokenTypeASTNodeType ( int tokenType, string NodeTypeName ) : void
tokenType int Token type to override.
NodeTypeName string /// Fully qualified AST typename (or null to specify /// the factory's default AST type). ///
Результат void

Описание свойств

defaultASTNodeTypeObject_ защищенное свойство

Stores the Type of the default AST node class to be used during tree construction.
protected Type defaultASTNodeTypeObject_
Результат Type

defaultCreator_ защищенное свойство

protected ASTNodeCreator defaultCreator_
Результат ASTNodeCreator

heteroList_ защищенное свойство

Stores the mapping between custom AST NodeTypes and their NodeTypeName/NodeTypeClass and ASTNodeCreator.
protected FactoryEntry[] heteroList_
Результат FactoryEntry[]

typename2creator_ защищенное свойство

Stores the mapping between AST node typenames and their token ID.
protected Hashtable typename2creator_
Результат Hashtable