本文整理汇总了C#中IParseTree类的典型用法代码示例。如果您正苦于以下问题:C# IParseTree类的具体用法?C# IParseTree怎么用?C# IParseTree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IParseTree类属于命名空间,在下文中一共展示了IParseTree类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ParseTreePattern
/// <summary>
/// Construct a new instance of the
/// <see cref="ParseTreePattern"/>
/// class.
/// </summary>
/// <param name="matcher">
/// The
/// <see cref="ParseTreePatternMatcher"/>
/// which created this
/// tree pattern.
/// </param>
/// <param name="pattern">The tree pattern in concrete syntax form.</param>
/// <param name="patternRuleIndex">
/// The parser rule which serves as the root of the
/// tree pattern.
/// </param>
/// <param name="patternTree">
/// The tree pattern in
/// <see cref="Antlr4.Runtime.Tree.IParseTree"/>
/// form.
/// </param>
public ParseTreePattern(ParseTreePatternMatcher matcher, string pattern, int patternRuleIndex, IParseTree patternTree)
{
this.matcher = matcher;
this.patternRuleIndex = patternRuleIndex;
this.pattern = pattern;
this.patternTree = patternTree;
}
开发者ID:sharwell,项目名称:antlr4cs,代码行数:28,代码来源:ParseTreePattern.cs
示例2: Evaluate
public override ICollection<IParseTree> Evaluate(IParseTree t)
{
if (invert)
{
return new List<IParseTree>();
}
// !* is weird but valid (empty)
return Trees.Descendants(t);
}
开发者ID:RainerBosch,项目名称:antlr4,代码行数:9,代码来源:XPathWildcardAnywhereElement.cs
示例3: Descendants
public static IList<IParseTree> Descendants(IParseTree t)
{
List<IParseTree> nodes = new List<IParseTree>();
nodes.Add(t);
int n = t.ChildCount;
for (int i = 0; i < n; i++)
{
nodes.AddRange(Descendants(t.GetChild(i)));
}
return nodes;
}
开发者ID:antlr,项目名称:antlr4,代码行数:11,代码来源:Trees.cs
示例4: Same
/// <summary>
/// Проверяет два синтаксических дерева на сходство, игнорируя вертикальные "цепочки" и скобки.
/// </summary>
public static bool Same(this IParseTree tree1, IParseTree tree2)
{
tree1 = tree1.Collapse();
tree2 = tree2.Collapse();
if (tree1.ChildCount == 0 || tree2.ChildCount == 0) return tree1.GetText() == tree2.GetText();
if (tree1.ChildCount != tree2.ChildCount) return false;
for (int i = 0; i < tree1.ChildCount; i++)
{
if (!tree1.GetChild(i).Same(tree2.GetChild(i))) return false;
}
return true;
}
开发者ID:sandwwraith,项目名称:mathlogic,代码行数:17,代码来源:TreeUtils.cs
示例5: Evaluate
public override ICollection<IParseTree> Evaluate(IParseTree t)
{
if (invert)
{
return new List<IParseTree>();
}
// !* is weird but valid (empty)
IList<IParseTree> kids = new List<IParseTree>();
foreach (ITree c in Trees.GetChildren(t))
{
kids.Add((IParseTree)c);
}
return kids;
}
开发者ID:RainerBosch,项目名称:antlr4,代码行数:14,代码来源:XPathWildcardElement.cs
示例6: VBComponentParseResult
public VBComponentParseResult(VBComponent component, IParseTree parseTree, IEnumerable<CommentNode> comments, ITokenStream tokenStream)
{
_component = component;
_qualifiedName = new QualifiedModuleName(component);
_parseTree = parseTree;
_comments = comments;
_tokenStream = tokenStream;
var listener = new DeclarationSymbolsListener(_qualifiedName, Accessibility.Implicit, _component.Type);
var walker = new ParseTreeWalker();
walker.Walk(listener, _parseTree);
_declarations.AddRange(listener.Declarations.Items);
}
开发者ID:ThunderFrame,项目名称:Rubberduck,代码行数:14,代码来源:VBComponentParseResult.cs
示例7: GetFirstTerminalNode
// --- Get tokens in terminal nodes ---
public static ITerminalNode GetFirstTerminalNode(IParseTree node)
{
while (!(node is ITerminalNode))
{
if (node.ChildCount == 0)
{
return null;
}
else
{
node = node.GetChild(0);
}
}
return (ITerminalNode)node;
}
开发者ID:osmedile,项目名称:TypeCobol,代码行数:16,代码来源:ParseTreeUtils.cs
示例8: GetIntegerLiteral
public static long? GetIntegerLiteral(IParseTree node)
{
if (node != null)
{
ITerminalNode terminalNode = GetFirstTerminalNode(node);
if (terminalNode != null)
{
Token integerLiteralToken = GetTokenFromTerminalNode(terminalNode);
if (integerLiteralToken.TokenType == TokenType.IntegerLiteral)
{
return ((IntegerLiteralTokenValue)integerLiteralToken.LiteralValue).Number;
}
}
}
return null;
}
开发者ID:osmedile,项目名称:TypeCobol,代码行数:16,代码来源:ParseTreeUtils.cs
示例9: GetAlphanumericLiteral
public static string GetAlphanumericLiteral(IParseTree node)
{
if (node != null)
{
ITerminalNode terminalNode = GetFirstTerminalNode(node);
if (terminalNode != null)
{
Token alphaNumericLiteralToken = GetTokenFromTerminalNode(terminalNode);
if (alphaNumericLiteralToken.TokenFamily == TokenFamily.AlphanumericLiteral)
{
return ((AlphanumericLiteralTokenValue)alphaNumericLiteralToken.LiteralValue).Text;
}
}
}
return null;
}
开发者ID:osmedile,项目名称:TypeCobol,代码行数:16,代码来源:ParseTreeUtils.cs
示例10: Semantic
public Semantic(IParseTree root)
{
_root = root;
_listener = new DefinitionListener();
ParseTreeWalker.Default.Walk(_listener, root);
_errors.AddRange(_listener.Errors);
var resolvingListener = new ResolvingListener(this);
ParseTreeWalker.Default.Walk(resolvingListener, root);
_errors.AddRange(resolvingListener.Errors);
}
开发者ID:mdelol,项目名称:Compiler,代码行数:16,代码来源:Semantic.cs
示例11: Evaluate
public override ICollection<IParseTree> Evaluate(IParseTree t)
{
// return all children of t that match nodeName
IList<IParseTree> nodes = new List<IParseTree>();
foreach (ITree c in Trees.GetChildren(t))
{
if (c is ParserRuleContext)
{
ParserRuleContext ctx = (ParserRuleContext)c;
if ((ctx.RuleIndex == ruleIndex && !invert) || (ctx.RuleIndex != ruleIndex && invert))
{
nodes.Add(ctx);
}
}
}
return nodes;
}
开发者ID:antlr,项目名称:antlr4,代码行数:17,代码来源:XPathRuleElement.cs
示例12: Evaluate
public override ICollection<IParseTree> Evaluate(IParseTree t)
{
// return all children of t that match nodeName
IList<IParseTree> nodes = new List<IParseTree>();
foreach (ITree c in Trees.GetChildren(t))
{
if (c is ITerminalNode)
{
ITerminalNode tnode = (ITerminalNode)c;
if ((tnode.Symbol.Type == tokenType && !invert) || (tnode.Symbol.Type != tokenType && invert))
{
nodes.Add(tnode);
}
}
}
return nodes;
}
开发者ID:antlr,项目名称:antlr4,代码行数:17,代码来源:XPathTokenElement.cs
示例13: MapToMessage
/// <summary>
/// Mapira na Message
/// </summary>
/// <param name="node"></param>
/// <returns></returns>
public static Message MapToMessage(IParseTree node)
{
log.Debug("Mapper:MapToMessage");
try
{
MessageId message_id = node.GetNodes()[0].GetNodes()[10].GetValue();
if (message_id != "None")
{
Message message = Message.Create(message_id);
int i = 0;
bool result_record_processing = false;
foreach (IParseTree item in node.GetNodes())
{
Record record = MapToRecord(item);
if (record.Type == RecordId.ResultRecord)
{
result_record_processing = true;
((Results)message[i]).ResultComment.Add(new ResultCommentPair() { Result = (ResultRecord)record });
}
else if (record.Type == RecordId.CommentRecord)
{
result_record_processing = true;
((Results)message[i]).ResultComment[((Results)message[i]).ResultComment.Count - 1].Comment = (CommentRecord)record;
}
else
{
if (result_record_processing == true)
i++;
message[i++] = record;
result_record_processing = false;
}
}
return message;
}
return null;
}
catch (Exception ex)
{
log.Error(ex.ToString());
throw;
}
}
开发者ID:buskovic,项目名称:cobas,代码行数:51,代码来源:Mapper.cs
示例14: Populate
public static void Populate(TreeView treeview, IParseTree parsetree)
{
treeview.Visible = false;
treeview.SuspendLayout();
treeview.Nodes.Clear();
treeview.Tag = parsetree;
IParseNode start = parsetree.INodes[0];
TreeNode node = new TreeNode(start.Text);
node.Tag = start;
node.ForeColor = Color.SteelBlue;
treeview.Nodes.Add(node);
PopulateNode(node, start);
treeview.ExpandAll();
treeview.ResumeLayout();
treeview.Visible = true;
}
开发者ID:hvacengi,项目名称:TinyPG,代码行数:18,代码来源:ParseTreeViewer.cs
示例15: GetFirstToken
public static Token GetFirstToken(IParseTree node)
{
if (node != null)
{
ITerminalNode terminalNode = GetFirstTerminalNode(node);
if (terminalNode != null)
{
return GetTokenFromTerminalNode(terminalNode);
}
else
{
return null;
}
}
else
{
return null;
}
}
开发者ID:osmedile,项目名称:TypeCobol,代码行数:19,代码来源:ParseTreeUtils.cs
示例16: ParseTreeMatch
/// <summary>
/// Constructs a new instance of
/// <see cref="ParseTreeMatch"/>
/// from the specified
/// parse tree and pattern.
/// </summary>
/// <param name="tree">The parse tree to match against the pattern.</param>
/// <param name="pattern">The parse tree pattern.</param>
/// <param name="labels">
/// A mapping from label names to collections of
/// <see cref="Antlr4.Runtime.Tree.IParseTree"/>
/// objects located by the tree pattern matching process.
/// </param>
/// <param name="mismatchedNode">
/// The first node which failed to match the tree
/// pattern during the matching process.
/// </param>
/// <exception>
/// IllegalArgumentException
/// if
/// <paramref name="tree"/>
/// is
/// <see langword="null"/>
/// </exception>
/// <exception>
/// IllegalArgumentException
/// if
/// <paramref name="pattern"/>
/// is
/// <see langword="null"/>
/// </exception>
/// <exception>
/// IllegalArgumentException
/// if
/// <paramref name="labels"/>
/// is
/// <see langword="null"/>
/// </exception>
public ParseTreeMatch(IParseTree tree, ParseTreePattern pattern, MultiMap<string, IParseTree> labels, IParseTree mismatchedNode)
{
if (tree == null)
{
throw new ArgumentException("tree cannot be null");
}
if (pattern == null)
{
throw new ArgumentException("pattern cannot be null");
}
if (labels == null)
{
throw new ArgumentException("labels cannot be null");
}
this.tree = tree;
this.pattern = pattern;
this.labels = labels;
this.mismatchedNode = mismatchedNode;
}
开发者ID:sharwell,项目名称:antlr4cs,代码行数:57,代码来源:ParseTreeMatch.cs
示例17: Walk
public virtual void Walk(IParseTreeListener listener, IParseTree t)
{
if (t is IErrorNode)
{
listener.VisitErrorNode((IErrorNode)t);
return;
}
else
{
if (t is ITerminalNode)
{
listener.VisitTerminal((ITerminalNode)t);
return;
}
}
IRuleNode r = (IRuleNode)t;
EnterRule(listener, r);
int n = r.ChildCount;
for (int i = 0; i < n; i++)
{
Walk(listener, r.GetChild(i));
}
ExitRule(listener, r);
}
开发者ID:RainerBosch,项目名称:antlr4,代码行数:24,代码来源:ParseTreeWalker.cs
示例18: setNodeCommand
public void setNodeCommand(IParseTree node, Command value)
{
nodeCmd.Put(node, value);
}
开发者ID:paulochang,项目名称:DecafIde,代码行数:4,代码来源:NewDecafCodeGenerator.cs
示例19: getNodeCommand
public Command getNodeCommand(IParseTree node)
{
return nodeCmd.Get(node);
}
开发者ID:paulochang,项目名称:DecafIde,代码行数:4,代码来源:NewDecafCodeGenerator.cs
示例20: FindAllTokenNodes
public static ICollection<IParseTree> FindAllTokenNodes(IParseTree t, int ttype)
{
return FindAllNodes(t, ttype, true);
}
开发者ID:antlr,项目名称:antlr4,代码行数:4,代码来源:Trees.cs
注:本文中的IParseTree类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论