• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IAstNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IAstNode的典型用法代码示例。如果您正苦于以下问题:C# IAstNode类的具体用法?C# IAstNode怎么用?C# IAstNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IAstNode类属于命名空间,在下文中一共展示了IAstNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CompareNodes

        public static void CompareNodes(EditorTree editorTree, IAstNode node1, IAstNode node2)
        {
#if ___DEBUG
            Debug.Assert(node1 is RootNode || editorTree.ParseTree.ContainsElement(node1.Key));

            if (!node1.ChildrenInvalidated)
                Debug.Assert(node1.Children.Count == node2.Children.Count);

            Debug.Assert(TextRange.AreEqual(node1.NameRange, node2.NameRange));
            Debug.Assert(node1.Attributes.Count == node2.Attributes.Count);

            Debug.Assert(TextRange.AreEqual(node1.OuterRange, node2.OuterRange));
            Debug.Assert(TextRange.AreEqual(node1.InnerRange, node2.InnerRange));

            Debug.Assert(node1.Start == node2.Start);
            Debug.Assert(node1.End == node2.End);

            if (!node1.ChildrenInvalidated)
            {
                if (node1.Children.Count == node2.Children.Count)
                {
                    for (int i = 0; i < node1.Children.Count; i++)
                    {
                        CompareNodes(editorTree, node1.Children[i], node2.Children[i]);
                    }
                }
            }
#endif
        }
开发者ID:AlexanderSher,项目名称:RTVS-Old,代码行数:29,代码来源:Debug.cs


示例2: Parse

        public override bool Parse(ParseContext context, IAstNode parent) {
            TokenStream<RToken> tokens = context.Tokens;

            if (tokens.CurrentToken.IsVariableKind()) {
                var v = new Variable();
                v.Parse(context, this);

                // Variables don't set parent since during complex
                // exression parsing parent is determined by the
                // expression parser based on precedence and grouping.
                v.Parent = this; 
                this.Variable = v;

                if (tokens.CurrentToken.IsKeywordText(context.TextProvider, "in")) {
                    this.InOperator = new TokenNode();
                    this.InOperator.Parse(context, this);

                    this.Expression = new Expression(inGroup: true);
                    if (this.Expression.Parse(context, this)) {
                        return base.Parse(context, parent);
                    }
                } else {
                    context.AddError(new MissingItemParseError(ParseErrorType.InKeywordExpected, tokens.CurrentToken));
                }
            } else {
                context.AddError(new MissingItemParseError(ParseErrorType.IndentifierExpected, tokens.PreviousToken));
            }

            return false;
        }
开发者ID:Microsoft,项目名称:RTVS,代码行数:30,代码来源:EnumerableExpression.cs


示例3: BuildAddIndexNode

        private void BuildAddIndexNode(IIndexDefinition index, IAstNode parent)
        {
            IAddIndexNode addIndexNode = new AddIndexNode(parent, index.Name);
            parent.ChildNodes.Add(addIndexNode);

            SemanticModelUtil.Copy(index, addIndexNode);
        }
开发者ID:hoonsbara,项目名称:octalforty-wizardby,代码行数:7,代码来源:AstBuilder.cs


示例4: Parse

        public override bool Parse(ParseContext context, IAstNode parent) {
            TokenStream<RToken> tokens = context.Tokens;

            Debug.Assert(context.Tokens.CurrentToken.TokenType == RTokenType.Identifier || 
                         context.Tokens.CurrentToken.TokenType == RTokenType.String);

            this.Identifier = RParser.ParseToken(context, this);
            this.EqualsSign = RParser.ParseToken(context, this);

            if (context.Tokens.CurrentToken.TokenType != RTokenType.Comma && context.Tokens.CurrentToken.TokenType != RTokenType.CloseBrace) {
                Expression exp = new Expression(inGroup: true);
                if (exp.Parse(context, this)) {
                    this.DefaultValue = exp;
                }
            } else {
                this.DefaultValue = new NullExpression();
                if (context.Tokens.IsEndOfStream()) {
                    context.AddError(new ParseError(ParseErrorType.ExpressionExpected, ErrorLocation.Token, context.Tokens.CurrentToken));
                } else {
                    context.AddError(new ParseError(ParseErrorType.ExpressionExpected, ErrorLocation.Token, EqualsSign));
                }
            }

            return base.Parse(context, parent);
        }
开发者ID:int19h,项目名称:RTVS-OLD,代码行数:25,代码来源:NamedArgument.cs


示例5: CreateItem

        protected override CommaSeparatedItem CreateItem(IAstNode parent, ParseContext context) {
            RToken currentToken = context.Tokens.CurrentToken;
            RToken nextToken = context.Tokens.NextToken;

            switch (currentToken.TokenType) {
                case RTokenType.Ellipsis:
                    return new EllipsisArgument();

                case RTokenType.Comma:
                    return new MissingArgument();

                case RTokenType.Identifier:
                case RTokenType.String:
                case RTokenType.Logical:
                case RTokenType.Complex:
                case RTokenType.NaN:
                case RTokenType.Null:
                case RTokenType.Number:
                case RTokenType.Infinity:
                    if (nextToken.TokenType == RTokenType.Operator && context.TextProvider.GetText(nextToken) == "=") {
                        return new NamedArgument();
                    }
                    break;

                case RTokenType.CloseBrace:
                    return null; // no arguments supplied
            }

            return new ExpressionArgument();
        }
开发者ID:AlexanderSher,项目名称:RTVS-Old,代码行数:30,代码来源:ArgumentList.cs


示例6: Parse

        public override bool Parse(ParseContext context, IAstNode parent) {
            if (context.Tokens.CurrentToken.TokenType == RTokenType.Comma) {
                this.Comma = RParser.ParseToken(context, this);
            }

            return base.Parse(context, parent);
        }
开发者ID:AlexanderSher,项目名称:RTVS-Old,代码行数:7,代码来源:CommaSeparatedItem.cs


示例7: ParseToken

        public static TokenNode ParseToken(ParseContext context, IAstNode parent) {
            TokenStream<RToken> tokens = context.Tokens;
            TokenNode node = new TokenNode();

            node.Parse(context, parent);
            return node;
        }
开发者ID:Microsoft,项目名称:RTVS,代码行数:7,代码来源:ParserHelpers.cs


示例8: DefaultVisit

 protected override void DefaultVisit(IAstNode node)
 {
     foreach (var child in node.Children)
     {
         child.Accept(this);
     }
 }
开发者ID:scemino,项目名称:nscumm,代码行数:7,代码来源:JumpAstVisitor.cs


示例9: Parse

        public override bool Parse(ParseContext context, IAstNode parent) {
            if (context.Tokens.CurrentToken.TokenType == RTokenType.OpenBrace) {
                context.AddError(new ParseError(ParseErrorType.UnexpectedToken, ErrorLocation.Token, context.Tokens.CurrentToken));
            }

            return false;
        }
开发者ID:Microsoft,项目名称:RTVS,代码行数:7,代码来源:NullExpression.cs


示例10: Parse

        public override bool Parse(ParseContext context, IAstNode parent) {
            TokenStream<RToken> tokens = context.Tokens;

            Debug.Assert(tokens.CurrentToken.TokenType == RTokenType.Keyword);
            this.Keyword = RParser.ParseKeyword(context, this);
            this.Text = context.TextProvider.GetText(this.Keyword);

            if (tokens.CurrentToken.TokenType == RTokenType.OpenBrace) {
                this.OpenBrace = RParser.ParseToken(context, this);

                this.Arguments = new ArgumentList(RTokenType.CloseBrace);
                this.Arguments.Parse(context, this);

                if (tokens.CurrentToken.TokenType == RTokenType.CloseBrace) {
                    this.CloseBrace = RParser.ParseToken(context, this);
                    this.Scope = RParser.ParseScope(context, this, allowsSimpleScope: true, terminatingKeyword: null);
                    if (this.Scope != null) {
                        return base.Parse(context, parent);
                    } else {
                        context.AddError(new ParseError(ParseErrorType.FunctionBodyExpected, ErrorLocation.Token, tokens.PreviousToken));
                    }
                } else {
                    context.AddError(new ParseError(ParseErrorType.CloseBraceExpected, ErrorLocation.Token, tokens.CurrentToken));
                }
            } else {
                context.AddError(new ParseError(ParseErrorType.OpenBraceExpected, ErrorLocation.Token, tokens.CurrentToken));
            }

            return false;
        }
开发者ID:Microsoft,项目名称:RTVS,代码行数:30,代码来源:FunctionDefinition.cs


示例11: Parse

        public override bool Parse(ParseContext context, IAstNode parent) {
            if (ParseExpression(context) && this.Children.Count > 0) {
                return base.Parse(context, parent);
            }

            return false;
        }
开发者ID:Microsoft,项目名称:RTVS,代码行数:7,代码来源:Expression.cs


示例12: StatementIndent

 public StatementIndent(IAstNode node)
 {
     BeforeNode = node.BeforeNode;
     AfterNode = node;
     node.BeforeNode = this;
     ParentNode = (Statement)node.ParentNode;
 }
开发者ID:NaoyaOura,项目名称:SqlFormatter,代码行数:7,代码来源:StatementIndent.cs


示例13: CreateIAstNode

 public IAstNode CreateIAstNode(IAstNode beforeNode, string token)
 {
     if ((token[0] == '@' || token[0] == ':') && token.Length > 1)
     {
         // If the variable name is quoted
         if (token[1] == '"' || token[1] == '\'')
         {
             //_regex r2 = new _regex(@"^(((""[^""\\]*(?:\\.[^""\\]*)*(""|$))+)|(('[^'\\]*(?:\\.[^'\\]*)*('|$))+))\s");
             //TODO Valiable Node
             //return new ASTNode(   TokenType.VARIABLE
             //                ,   token[0] + r2.Match(token.Substring(1)).OriginalValue);
         }
         else
         {
             Match match = _regex.Match(token);
             if (match.Success)
             {
                 //TODO ValiableNode
                 //return new ASTNode(   TokenType.VARIABLE
                 //                ,   m3.OriginalValue
                 //                );
             }
         }
     }
     return null;
 }
开发者ID:NaoyaOura,项目名称:SqlFormatter,代码行数:26,代码来源:UserDefinedVariableTokenizer.cs


示例14: Create

        /// <summary>
        /// Abstract factory creating statements depending on current
        /// token and the following token sequence
        /// </summary>
        /// <returns></returns>
        public static IStatement Create(ParseContext context, IAstNode parent, string terminatingKeyword) {
            TokenStream<RToken> tokens = context.Tokens;
            RToken currentToken = tokens.CurrentToken;

            IStatement statement = null;

            switch (currentToken.TokenType) {
                case RTokenType.Keyword:
                    // If statement starts with a keyword, it is not an assignment
                    // hence we should always try keyword based statements first.
                    // Some of the statements may be R-values like typeof() but
                    // in case of the statement appearing on its own return value
                    // will be simply ignored. IDE may choose to show a warning.
                    if (currentToken.SubType == RTokenSubType.BuiltinFunction && tokens.NextToken.TokenType != RTokenType.OpenBrace) {
                        // 'return <- x + y' is allowed
                        statement = new ExpressionStatement(terminatingKeyword);
                    } else {
                        statement = KeywordStatement.CreateStatement(context, parent);
                    }
                    break;

                case RTokenType.Semicolon:
                    statement = new EmptyStatement();
                    break;

                default:
                    // Possible L-value in a left-hand assignment, 
                    // a function call or R-value in a right hand assignment.
                    statement = new ExpressionStatement(terminatingKeyword);
                    break;
            }

            return statement;
        }
开发者ID:Microsoft,项目名称:RTVS,代码行数:39,代码来源:Statement.cs


示例15: RemoveChildren

        public void RemoveChildren(int start, int count) {
            if (count == 0)
                return;

            if (start < 0 || start >= Children.Count)
                throw new ArgumentOutOfRangeException("start");

            if (count < 0 || count > Children.Count || start + count > Children.Count)
                throw new ArgumentOutOfRangeException("count");

            if (Children.Count == count) {
                _children = new TextRangeCollection<IAstNode>();
            } else {
                var newChildren = new IAstNode[Children.Count - count];

                int j = 0;

                for (int i = 0; i < start; i++, j++)
                    newChildren[j] = Children[i];

                for (int i = start; i < start + count; i++)
                    Children[i].Parent = null;

                for (int i = start + count; i < Children.Count; i++, j++)
                    newChildren[j] = Children[i];

                _children = new TextRangeCollection<IAstNode>(newChildren);
            }
        }
开发者ID:AlexanderSher,项目名称:RTVS-Old,代码行数:29,代码来源:AstNode.cs


示例16: TableOrColumnName

        public TableOrColumnName(IAstNode preNode, string originalValue)
            : base(preNode, originalValue)
        {
            // SQLが成立していないとき
            if (ParentNode == null || ParentNode.ParentNode == null)
            {
                Order = OrderType.Unknown;
                throw new Exception("SQLが成立していません");
            }

            // 定義の親がStatementでその親が予約語
            if (ParentNode.ParentNode.GetType() == typeof (ReservedTopLevel))
            {
                string reservedWord = ParentNode.ParentNode.OriginalValue;
                Match m = _regex.Match(reservedWord);
                if (m.Success)
                {
                    // FROMやUPDATEなど、カラム名称が定義されない予約語ならテーブル名
                    Order = OrderType.Table;
                }
                else
                {
                    // SELECT句やWHERE区ででてきたカラム定義
                    Order = OrderType.Column;
                }
            }
            else
            {
                // JOIN句など、予約語とは違うネスト階層により出現する定義
                Order = OrderType.Column;
            }
        }
开发者ID:NaoyaOura,项目名称:SqlFormatter,代码行数:32,代码来源:TableOreColumnName.cs


示例17: Parse

        public override bool Parse(ParseContext context, IAstNode parent) {
            // Remove comments from the token stream
            this.Comments = new CommentsCollection(context.Comments);

            GlobalScope globalScope = new GlobalScope();
            return globalScope.Parse(context, this);
        }
开发者ID:Microsoft,项目名称:RTVS,代码行数:7,代码来源:AstRoot.cs


示例18: Parse

        public override bool Parse(ParseContext context, IAstNode parent) {
            // First parse base which should pick up keyword, braces, inner
            // expression and either full or simple (single statement) scope
            if (!base.Parse(context, parent)) {
                return false;
            }

            // At this point we should be either at 'else' token or 
            // at the next statement. In the latter case we are done.
            TokenStream<RToken> tokens = context.Tokens;

            if (tokens.CurrentToken.IsKeywordText(context.TextProvider, "else")) {
                bool allowLineBreak = AllowLineBreakBeforeElse(context);
                if (!allowLineBreak) {
                    // Verify that there is no line break before the 'else'
                    if (context.Tokens.IsLineBreakAfter(context.TextProvider, tokens.Position - 1)) {
                        context.AddError(new ParseError(ParseErrorType.UnexpectedToken, ErrorLocation.Token, tokens.CurrentToken));
                        return true;
                    }
                }
                this.Else = new KeywordScopeStatement(allowsSimpleScope: true);
                return this.Else.Parse(context, this);
            }

            // Not at 'else' so we are done here
            return true;
        }
开发者ID:Microsoft,项目名称:RTVS,代码行数:27,代码来源:If.cs


示例19: Parse

        public override bool Parse(ParseContext context, IAstNode parent) {
            RToken currentToken = context.Tokens.CurrentToken;

            this.Token = currentToken;
            context.Tokens.MoveToNextToken();

            return base.Parse(context, parent);
        }
开发者ID:Microsoft,项目名称:RTVS,代码行数:8,代码来源:TokenNode.cs


示例20: CreateIAstNode

 public IAstNode CreateIAstNode(IAstNode beforeNode, string token)
 {
     if (token[0] == '(' || token[0] == ')')
     {
         return new Bracket(beforeNode, token[0].ToString());
     }
     return null;
 }
开发者ID:NaoyaOura,项目名称:SqlFormatter,代码行数:8,代码来源:BracketTokenizer.cs



注:本文中的IAstNode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IAstVisitor类代码示例发布时间:2022-05-24
下一篇:
C# IAssociationType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap