public FactoryEntry(ASTNodeCreator creator) { Creator = creator; }
public FactoryEntry(Type typeObj, ASTNodeCreator creator) { NodeTypeObject = typeObj; Creator = creator; }
/// <summary> /// Register an ASTNodeCreator to be used for creating node by default. /// </summary> /// <param name="creator">The ASTNodeCreator.</param> public void setASTNodeCreator(ASTNodeCreator creator) { defaultCreator_ = creator; }
/// <summary> /// Sets the global default AST Node Type for this ASTFactory instance. /// This method also attempts to load the <see cref="System.Type"/> instance /// for the specified typename. /// </summary> /// <param name="t">Fully qualified AST Node Type name.</param> public virtual void setASTNodeType(string t) { if (defaultCreator_ != null) { if (t != defaultCreator_.ASTNodeTypeName) { defaultCreator_ = null; } } defaultASTNodeTypeObject_ = loadNodeTypeObject(t); }
/// <summary> /// Register an ASTNodeCreator for a given Token type ID. /// </summary> /// <param name="NodeType">The Token type ID.</param> /// <param name="creator">The creater to register.</param> public void setTokenTypeASTNodeCreator(int NodeType, ASTNodeCreator creator) { // check validity of arguments... if (NodeType < Token.MIN_USER_TYPE) throw new ANTLRException("Internal parser error: Cannot change AST Node Type for Token ID '" + NodeType + "'"); // resize up to and including 'type' and initialize any gaps to default // factory. if (NodeType > (heteroList_.Length + 1)) setMaxNodeType(NodeType); // And add new thing.. if (heteroList_[NodeType] == null) heteroList_[NodeType] = new FactoryEntry(creator); else heteroList_[NodeType].Creator = creator; //typename2creator_[NodeType.ToString()] = creator; typename2creator_[creator.ASTNodeTypeName] = creator; }