本文整理汇总了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;
}
}
示例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;
}
示例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);
}
}
示例4: AddChild
public void AddChild(CstNode parent, CstNode child, string id) {
parent.AddLast(child);
child.RuleId = id.Substring(child.Name.Length);
}