当前位置: 首页>>代码示例>>C#>>正文


C# CstNode.AddLast方法代码示例

本文整理汇总了C#中CstNode.AddLast方法的典型用法代码示例。如果您正苦于以下问题:C# CstNode.AddLast方法的具体用法?C# CstNode.AddLast怎么用?C# CstNode.AddLast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CstNode的用法示例。


在下文中一共展示了CstNode.AddLast方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

 public void Create(CstNode parent, IToken token, string id) {
     if (token != null) {
         var count = token.TokenIndex;
         var tokenName = DetermineElementName(token, Code2XmlConstants.TokenSetElementName);
         var node = CreateTerminalNode(tokenName, token, token.Text, count, id);
         parent.AddLast(node);
         _nextTokenIndex = count + 1;
     }
 }
开发者ID:RainsSoft,项目名称:Code2Xml,代码行数:9,代码来源:CstBuilderForAntlr3.cs

示例2: FinishParsing

 public CstNode FinishParsing(CstNode root) {
     var count = _stream.Count - 1; // Avoid writing "<EOF>"
     while (count > 0 && _stream.Get(count - 1).Type < 0) {
         count--;
     }
     var antlrToken = _stream.Get(count);
     var token = CreateTerminalNode(
             Code2XmlConstants.EofTokenName, antlrToken, string.Empty, count,
             Code2XmlConstants.EofRuleId);
     root.AddLast(token);
     return root;
 }
开发者ID:RainsSoft,项目名称:Code2Xml,代码行数:12,代码来源:CstBuilderForAntlr3.cs

示例3: SetLocationInformation

        public void SetLocationInformation(CstNode tree, string code) {
            var line = 1;
            var pos = 0;
            var index = 0;
            var startHiddenLocation = new CodeLocation(line, pos);
            foreach (var tokenNode in tree.AllTokenNodes()) {
                var token = tokenNode.Token;
                var tokenStr = token.Text;
                if (tokenStr == string.Empty) { // e.g. NEWLINE in Python
                    token.Range = new CodeRange(startHiddenLocation, startHiddenLocation);
                    continue;
                }
                var startHiddenIndex = index;
                var tokenChar = tokenStr[0];
                while (code[index] != tokenChar
                       || code.Substring(index, tokenStr.Length) != tokenStr) {
                    if (code[index] != '\n') {
                        pos++;
                    } else {
                        line++;
                        pos = 0;
                    }
                    index++;
                }
                var endHiddenIndex = index;
                var startTokenLocation = new CodeLocation(line, pos);
                var endIndex = index + tokenStr.Length;
                while (index < endIndex) {
                    if (code[index] != '\n') {
                        pos++;
                    } else {
                        line++;
                        pos = 0;
                    }
                    index++;
                }
                tokenNode.Hiddens.Add(
                        new CstToken(
                                Code2XmlConstants.HiddenElementName,
                                code.Substring(startHiddenIndex, endHiddenIndex - startHiddenIndex),
                                Code2XmlConstants.DefaultHiddenRuleId,
                                new CodeRange(startHiddenLocation, startTokenLocation)));
                startHiddenLocation = new CodeLocation(line, pos); // as endTokenLocation
                token.Range = new CodeRange(startTokenLocation, startHiddenLocation);
            }

            {
                var startHiddenIndex = index;
                var endIndex = code.Length;
                while (index < endIndex) {
                    if (code[index] != '\n') {
                        pos++;
                    } else {
                        line++;
                        pos = 0;
                    }
                    index++;
                }
                var endHiddenLocation = new CodeLocation(line, pos);
                var token = new CstToken(
                        Code2XmlConstants.EofTokenName, String.Empty, Code2XmlConstants.EofRuleId,
                        new CodeRange(endHiddenLocation, endHiddenLocation));
                var eofNode = new CstNode(token);
                eofNode.Hiddens.Add(
                        new CstToken(
                                Code2XmlConstants.HiddenElementName,
                                code.Substring(startHiddenIndex, index - startHiddenIndex),
                                Code2XmlConstants.DefaultHiddenRuleId,
                                new CodeRange(startHiddenLocation, endHiddenLocation)));
                tree.AddLast(eofNode);
            }
        }
开发者ID:RainsSoft,项目名称:Code2Xml,代码行数:72,代码来源:CstGeneratorUsingExternalProgram.cs

示例4: AddChild

 public void AddChild(CstNode parent, CstNode child, string id) {
     parent.AddLast(child);
     child.RuleId = id.Substring(child.Name.Length);
 }
开发者ID:RainsSoft,项目名称:Code2Xml,代码行数:4,代码来源:CstBuilderForAntlr3.cs


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