using System.Collections.Generic;
using Antlr4.Runtime.Sharpen;
using Antlr4.Runtime.Tree;
using Antlr4.Runtime.Tree.Xpath;
namespace Antlr4.Runtime.Tree.Xpath
{
public class XPathTokenElement : XPathElement
{
protected internal int tokenType;
public XPathTokenElement(string tokenName, int tokenType)
: base(tokenName)
{
this.tokenType = tokenType;
}
public override ICollection<IParseTree> Evaluate(IParseTree t)
{
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;
}
}
}