示例#1
0
        public virtual object ParseNode()
        {
            // "%label:" prefix
            string label = null;
            if ( ttype == TreePatternLexer.PERCENT )
            {
                ttype = tokenizer.NextToken();
                if ( ttype != TreePatternLexer.ID )
                {
                    return null;
                }
                label = tokenizer.sval.ToString();
                ttype = tokenizer.NextToken();
                if ( ttype != TreePatternLexer.COLON )
                {
                    return null;
                }
                ttype = tokenizer.NextToken(); // move to ID following colon
            }

            // Wildcard?
            if ( ttype == TreePatternLexer.DOT )
            {
                ttype = tokenizer.NextToken();
                IToken wildcardPayload = new CommonToken( 0, "." );
                TreeWizard.TreePattern node =
                    new TreeWizard.WildcardTreePattern( wildcardPayload );
                if ( label != null )
                {
                    node.label = label;
                }
                return node;
            }

            // "ID" or "ID[arg]"
            if ( ttype != TreePatternLexer.ID )
            {
                return null;
            }
            string tokenName = tokenizer.sval.ToString();
            ttype = tokenizer.NextToken();
            if ( tokenName.Equals( "nil" ) )
            {
                return adaptor.Nil();
            }
            string text = tokenName;
            // check for arg
            string arg = null;
            if ( ttype == TreePatternLexer.ARG )
            {
                arg = tokenizer.sval.ToString();
                text = arg;
                ttype = tokenizer.NextToken();
            }

            // create node
            int treeNodeType = wizard.GetTokenType( tokenName );
            if ( treeNodeType == TokenTypes.Invalid )
            {
                return null;
            }
            object node2;
            node2 = adaptor.Create( treeNodeType, text );
            if ( label != null && node2.GetType() == typeof( TreeWizard.TreePattern ) )
            {
                ( (TreeWizard.TreePattern)node2 ).label = label;
            }
            if ( arg != null && node2.GetType() == typeof( TreeWizard.TreePattern ) )
            {
                ( (TreeWizard.TreePattern)node2 ).hasTextArg = true;
            }
            return node2;
        }
示例#2
0
        public object ParseNode()
        {
            // "%label:" prefix
            string label = null;

            if (ttype == TreePatternLexer.PERCENT)
            {
                ttype = tokenizer.NextToken();
                if (ttype != TreePatternLexer.ID)
                {
                    return(null);
                }
                label = tokenizer.sval.ToString();
                ttype = tokenizer.NextToken();
                if (ttype != TreePatternLexer.COLON)
                {
                    return(null);
                }
                ttype = tokenizer.NextToken();                 // move to ID following colon
            }

            // Wildcard?
            if (ttype == TreePatternLexer.DOT)
            {
                ttype = tokenizer.NextToken();
                IToken wildcardPayload      = new CommonToken(0, ".");
                TreeWizard.TreePattern node = new TreeWizard.WildcardTreePattern(wildcardPayload);
                if (label != null)
                {
                    node.label = label;
                }
                return(node);
            }

            // "ID" or "ID[arg]"
            if (ttype != TreePatternLexer.ID)
            {
                return(null);
            }
            string tokenName = tokenizer.sval.ToString();

            ttype = tokenizer.NextToken();
            if (tokenName.Equals("nil"))
            {
                return(adaptor.GetNilNode());
            }
            string text = tokenName;
            // check for arg
            string arg = null;

            if (ttype == TreePatternLexer.ARG)
            {
                arg   = tokenizer.sval.ToString();
                text  = arg;
                ttype = tokenizer.NextToken();
            }

            // create node
            int treeNodeType = wizard.GetTokenType(tokenName);

            if (treeNodeType == Token.INVALID_TOKEN_TYPE)
            {
                return(null);
            }
            object nodeObj;

            nodeObj = adaptor.Create(treeNodeType, text);
            if ((label != null) && (nodeObj.GetType() == typeof(TreeWizard.TreePattern)))
            {
                ((TreeWizard.TreePattern)nodeObj).label = label;
            }
            if ((arg != null) && (nodeObj.GetType() == typeof(TreeWizard.TreePattern)))
            {
                ((TreeWizard.TreePattern)nodeObj).hasTextArg = true;
            }
            return(nodeObj);
        }
示例#3
0
        public virtual object ParseNode()
        {
            // "%label:" prefix
            string label = null;

            if (ttype == TreePatternLexer.Percent)
            {
                ttype = tokenizer.NextToken();
                if (ttype != TreePatternLexer.Id)
                {
                    return(null);
                }
                label = tokenizer.sval.ToString();
                ttype = tokenizer.NextToken();
                if (ttype != TreePatternLexer.Colon)
                {
                    return(null);
                }
                ttype = tokenizer.NextToken(); // move to ID following colon
            }

            // Wildcard?
            if (ttype == TreePatternLexer.Dot)
            {
                ttype = tokenizer.NextToken();
                IToken wildcardPayload      = new CommonToken(0, ".");
                TreeWizard.TreePattern node =
                    new TreeWizard.WildcardTreePattern(wildcardPayload);
                if (label != null)
                {
                    node.label = label;
                }
                return(node);
            }

            // "ID" or "ID[arg]"
            if (ttype != TreePatternLexer.Id)
            {
                return(null);
            }
            string tokenName = tokenizer.sval.ToString();

            ttype = tokenizer.NextToken();
            if (tokenName.Equals("nil"))
            {
                return(adaptor.Nil());
            }
            string text = tokenName;
            // check for arg
            string arg = null;

            if (ttype == TreePatternLexer.Arg)
            {
                arg   = tokenizer.sval.ToString();
                text  = arg;
                ttype = tokenizer.NextToken();
            }

            // create node
            int treeNodeType = wizard.GetTokenType(tokenName);

            if (treeNodeType == TokenTypes.Invalid)
            {
                return(null);
            }
            object node2;

            node2 = adaptor.Create(treeNodeType, text);
            if (label != null && node2.GetType() == typeof(TreeWizard.TreePattern))
            {
                ((TreeWizard.TreePattern)node2).label = label;
            }
            if (arg != null && node2.GetType() == typeof(TreeWizard.TreePattern))
            {
                ((TreeWizard.TreePattern)node2).hasTextArg = true;
            }
            return(node2);
        }
 public virtual object ParseNode()
 {
     string str = null;
     if (this.ttype == 5)
     {
         this.ttype = this.tokenizer.NextToken();
         if (this.ttype != 3)
         {
             return null;
         }
         str = this.tokenizer.sval.ToString();
         this.ttype = this.tokenizer.NextToken();
         if (this.ttype != 6)
         {
             return null;
         }
         this.ttype = this.tokenizer.NextToken();
     }
     if (this.ttype == 7)
     {
         this.ttype = this.tokenizer.NextToken();
         IToken payload = new CommonToken(0, ".");
         TreeWizard.TreePattern pattern = new TreeWizard.WildcardTreePattern(payload);
         if (str != null)
         {
             pattern.label = str;
         }
         return pattern;
     }
     if (this.ttype != 3)
     {
         return null;
     }
     string tokenName = this.tokenizer.sval.ToString();
     this.ttype = this.tokenizer.NextToken();
     if (tokenName.Equals("nil"))
     {
         return this.adaptor.Nil();
     }
     string text = tokenName;
     string str4 = null;
     if (this.ttype == 4)
     {
         str4 = this.tokenizer.sval.ToString();
         text = str4;
         this.ttype = this.tokenizer.NextToken();
     }
     int tokenType = this.wizard.GetTokenType(tokenName);
     if (tokenType == 0)
     {
         return null;
     }
     object obj2 = this.adaptor.Create(tokenType, text);
     if ((str != null) && (obj2.GetType() == typeof(TreeWizard.TreePattern)))
     {
         ((TreeWizard.TreePattern) obj2).label = str;
     }
     if ((str4 != null) && (obj2.GetType() == typeof(TreeWizard.TreePattern)))
     {
         ((TreeWizard.TreePattern) obj2).hasTextArg = true;
     }
     return obj2;
 }