コード例 #1
0
        /// <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;
        }
コード例 #2
0
 /// <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);
 }
コード例 #3
0
 public FactoryEntry(ASTNodeCreator creator)
 {
     Creator			= creator;
 }
コード例 #4
0
 public FactoryEntry(Type typeObj, ASTNodeCreator creator)
 {
     NodeTypeObject	= typeObj;
     Creator			= creator;
 }
コード例 #5
0
        /// <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;
        }
コード例 #6
0
 /// <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);
 }
コード例 #7
0
 /// <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;
 }
コード例 #8
0
 /// <summary>
 /// Constructs an <c>ASTFactory</c> and use the specified AST node type
 /// as the default.
 /// </summary>
 /// <param name="nodeType">
 ///		MetaType of default AST node type for this factory.
 /// </param>
 public ASTFactory(Type nodeType)
 {
     heteroList_					= new FactoryEntry[Token.MIN_USER_TYPE+1];
     defaultASTNodeTypeObject_	= nodeType;
     defaultCreator_				= null;
     typename2creator_			= new Hashtable(32, (float) 0.3);
     typename2creator_[typeof(antlr.CommonAST).FullName]					= CommonAST.Creator;
     typename2creator_[typeof(antlr.CommonASTWithHiddenTokens).FullName]	= CommonASTWithHiddenTokens.Creator;
 }
コード例 #9
0
 public FactoryEntry(ASTNodeCreator creator)
 {
     Creator = creator;
 }
コード例 #10
0
 public FactoryEntry(Type typeObj, ASTNodeCreator creator)
 {
     NodeTypeObject = typeObj;
     Creator        = creator;
 }
コード例 #11
0
 /// <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;
 }