本文整理汇总了C#中ParseTreeNode.GetMappedChildNodes方法的典型用法代码示例。如果您正苦于以下问题:C# ParseTreeNode.GetMappedChildNodes方法的具体用法?C# ParseTreeNode.GetMappedChildNodes怎么用?C# ParseTreeNode.GetMappedChildNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParseTreeNode
的用法示例。
在下文中一共展示了ParseTreeNode.GetMappedChildNodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public override void Init(AstContext context, ParseTreeNode treeNode)
{
base.Init(context, treeNode);
var node = treeNode.GetMappedChildNodes()[0];
this.Label = node.Token.ValueString;
}
示例2: Init
// this is where data is initially passed to the item
public override void Init(AstContext context, ParseTreeNode treeNode)
{
string sVal = treeNode.FindTokenAndGetText();
base.Init(context, treeNode);
var nodes = treeNode.GetMappedChildNodes();
var functionOrProperty = AddChild("FunctionOrId", nodes[0]);
if (functionOrProperty is SelectFunctionNode)
{
_TheFunction = (SelectFunctionNode)functionOrProperty;
}
else if (functionOrProperty is SelectPropertyNode)
{
_PropNode = (SelectPropertyNode)functionOrProperty;
}
else
{
throw new Exception("Unmanaged type in selectmemberaccessnode");
}
if (nodes.Count > 1)
{
var child = AddChild("Queue", nodes[1]);
string sval = nodes[1].FindTokenAndGetText();
if (child is LeftObjectNode)
{
_queue = (LeftObjectNode)child;
}
}
}
示例3: BuildAst
public virtual void BuildAst(ParseTreeNode parseNode)
{
var term = parseNode.Term;
if (term.Flags.IsSet(TermFlags.NoAstNode) || parseNode.AstNode != null) return;
//children first
var processChildren = !parseNode.Term.Flags.IsSet(TermFlags.AstDelayChildren) &&
parseNode.ChildNodes.Count > 0;
if (processChildren)
{
var mappedChildNodes = parseNode.GetMappedChildNodes();
for (var i = 0; i < mappedChildNodes.Count; i++)
BuildAst(mappedChildNodes[i]);
}
//create the node
//We know that either NodeCreator or DefaultNodeCreator is set; VerifyAstData create the DefaultNodeCreator
var config = term.AstConfig;
if (config.NodeCreator != null)
{
config.NodeCreator(Context, parseNode);
// We assume that Node creator method creates node and initializes it, so parser does not need to call
// IAstNodeInit.Init() method on node object. But we do call AstNodeCreated custom event on term.
}
else
{
//Invoke the default creator compiled when we verified the data
parseNode.AstNode = config.DefaultNodeCreator();
//Initialize node
var iInit = parseNode.AstNode as IAstNodeInit;
if (iInit != null)
iInit.Init(Context, parseNode);
}
//Invoke the event on term
term.OnAstNodeCreated(parseNode);
} //method
示例4: Init
public override void Init(AstContext context, ParseTreeNode treeNode) {
base.Init(context, treeNode);
var nodes = treeNode.GetMappedChildNodes();
_target = AddChild("Target", nodes.First());
_index = AddChild("Index", nodes.Last());
AsString = "[" + _index + "]";
}
示例5: Init
public override void Init(AstContext context, ParseTreeNode treeNode) {
base.Init(context, treeNode);
var nodes = treeNode.GetMappedChildNodes();
Test = AddChild("Test", nodes[0]);
IfTrue = AddChild("IfTrue", nodes[1]);
if (nodes.Count > 2)
IfFalse = AddChild("IfFalse", nodes[2]);
}
示例6: Init
public override void Init(AstContext context, ParseTreeNode treeNode) {
base.Init(context, treeNode);
var nodes = treeNode.GetMappedChildNodes();
OpSymbol = nodes[0].FindTokenAndGetText();
Argument = AddChild("Arg", nodes[1]);
base.AsString = OpSymbol + "(unary op)";
var interpContext = (InterpreterAstContext)context;
base.ExpressionType = interpContext.OperatorHandler.GetUnaryOperatorExpressionType(OpSymbol);
}
示例7: Init
public override void Init(AstContext context, ParseTreeNode treeNode) {
base.Init(context, treeNode);
var nodes = treeNode.GetMappedChildNodes();
_left = AddChild("Target", nodes[0]);
var right = nodes[nodes.Count - 1];
_memberName = right.FindTokenAndGetText();
ErrorAnchor = right.Span.Location;
AsString = "." + _memberName;
}
示例8: Init
// this is where data is initially passed to the item
public override void Init(AstContext context, ParseTreeNode treeNode)
{
base.Init(context, treeNode);
var nodes = treeNode.GetMappedChildNodes();
if (nodes.Count > 0)
{
propName = nodes[0].FindTokenAndGetText();
}
}
示例9: Init
public override void Init(AstContext context, ParseTreeNode treeNode) {
base.Init(context, treeNode);
var nodes = treeNode.GetMappedChildNodes();
TargetRef = AddChild("Target", nodes[0]);
TargetRef.UseType = NodeUseType.CallTarget;
_targetName = nodes[0].FindTokenAndGetText();
Arguments = AddChild("Args", nodes[1]);
AsString = "Call " + _targetName;
}
示例10: Init
public override void Init(AstContext context, ParseTreeNode treeNode)
{
base.Init(context, treeNode);
var nodes = treeNode.GetMappedChildNodes();
this.Label = nodes[0].FindTokenAndGetText();
// Make a nice display name.
this.AsString = "Label: " + this.Label;
}
示例11: Init
// this is where data is initially passed to the item
public override void Init(AstContext context, ParseTreeNode treeNode)
{
base.Init(context, treeNode);
var nodes = treeNode.GetMappedChildNodes();
if (nodes.Count == 1)
{
actualnode = (AstNode)nodes[0].AstNode;
AddChild(string.Empty, nodes[0]);
}
}
示例12: Init
public override void Init(AstContext context, ParseTreeNode treeNode) {
base.Init(context, treeNode);
var nodes = treeNode.GetMappedChildNodes();
FindOpAndDetectPostfix(nodes);
int argIndex = IsPostfix? 0 : 1;
Argument = AddChild(NodeUseType.ValueReadWrite, "Arg", nodes[argIndex]);
BinaryOpSymbol = OpSymbol[0].ToString(); //take a single char out of ++ or --
var interpContext = (InterpreterAstContext)context;
BinaryOp = interpContext.OperatorHandler.GetOperatorExpressionType(BinaryOpSymbol);
base.AsString = OpSymbol + (IsPostfix ? "(postfix)" : "(prefix)");
}
示例13: Init
public override void Init(AstContext context, ParseTreeNode treeNode) {
base.Init(context, treeNode);
//child #0 is usually a keyword like "def"
var nodes = treeNode.GetMappedChildNodes();
NameNode = AddChild("Name", nodes[1]);
Lambda = new LambdaNode(context, treeNode, nodes[2], nodes[3]);
Lambda.Parent = this;
AsString = "<Function " + NameNode.AsString + ">";
//Lamda will set treeNode.AstNode to itself, we need to set it back to "this" here
treeNode.AstNode = this; //
}
示例14: BuildAst
public override void BuildAst(ParseTreeNode parseNode)
{
if (parseNode.Term.Flags.IsSet(TermFlags.IsList) && parseNode.Term.Flags.IsSet(TermFlags.NoAstNode))
{ // HACK: the default BuildAst does not proceed the children of the list node (is it a bug in Irony, or what?)
var mappedChildNodes = parseNode.GetMappedChildNodes();
foreach (var mappedChildNode in mappedChildNodes)
BuildAst(mappedChildNode);
}
else
base.BuildAst(parseNode);
}
示例15: Init
public override void Init(AstContext context, ParseTreeNode treeNode)
{
base.Init(context, treeNode);
var nodes = treeNode.GetMappedChildNodes();
foreach (var node in nodes.Where(e => e.AstNode is LineNode))
{
AddChild(String.Empty, node);
}
// Make a nice display name.
this.AsString = "Lines";
}