本文整理汇总了C#中ParseTreeNode类的典型用法代码示例。如果您正苦于以下问题:C# ParseTreeNode类的具体用法?C# ParseTreeNode怎么用?C# ParseTreeNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParseTreeNode类属于命名空间,在下文中一共展示了ParseTreeNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetContent
public void GetContent(CompilerContext context, ParseTreeNode parseNode)
{
if (parseNode.HasChildNodes())
{
ParallelTasks = Convert.ToUInt32(parseNode.ChildNodes[1].Token.Value);
}
}
示例2: PrepareStringInstanceMethodCall
private static MethodInfo PrepareStringInstanceMethodCall(string methodName, ParseTreeNode root, CompilerState state, out Expression value, out Expression pattern)
{
root.RequireChildren(2);
MethodInfo method;
if (0 == StringComparer.OrdinalIgnoreCase.Compare(methodName, "StartsWith"))
{
method = ReflectionHelper.StringStartsWith;
}
else if (0 == StringComparer.OrdinalIgnoreCase.Compare(methodName, "EndsWith"))
{
method = ReflectionHelper.StringEndsWith;
}
else if (0 == StringComparer.OrdinalIgnoreCase.Compare(methodName, "IndexOf"))
{
method = ReflectionHelper.StringIndexOf;
}
else
{
throw new Exception("Could not find method " + methodName);
}
var arg1Node = root.RequireChild(null, 1, 0, 0);
value = state.ParentRuntime.Analyze(arg1Node, state);
value.RequireString(arg1Node);
var arg2Node = root.RequireChild(null, 1, 0, 1);
pattern = state.ParentRuntime.Analyze(arg2Node, state);
pattern.RequireString(arg2Node);
return method;
}
示例3: AddParseNodeRec
private void AddParseNodeRec(int depth, ParseTreeNode node)
{
if (node == null) return;
BnfTerm term = node.Term;
string txt = node.ToString();
if (term == null) {
txt = "NullTerm";
}
else {
txt = term.GetParseNodeCaption(node);
}
//var t = " "*6;
for (int i = 0; i < depth; i++) Console.Write(" ");
if (node.Token != null) {
Console.WriteLine(node.Token.Value + " " + node.Token.Terminal.ToString());
}
else
Console.WriteLine(node.Term.Name);
// Console.WriteLine(node.ToString());
foreach (var child in node.ChildNodes)
AddParseNodeRec(depth + 1, child);
}
示例4: DirectInit
public void DirectInit(ParsingContext context, ParseTreeNode parseNode)
{
var idChain = ((IDNode)parseNode.ChildNodes[2].AstNode).IDChainDefinition;
var tupleDefinition = ((TupleNode)parseNode.ChildNodes[3].AstNode).TupleDefinition;
var AttrName = parseNode.ChildNodes[2].FirstChild.FirstChild.Token.ValueString;
ToBeRemovedList = new AttributeRemoveList(idChain, AttrName, tupleDefinition);
}
示例5: GetContent
public void GetContent(CompilerContext context, ParseTreeNode parseNode)
{
TypesSettingScope? settingType;
if (parseNode.HasChildNodes() && (parseNode.ChildNodes.Count >= 2))
{
switch (parseNode.ChildNodes[1].Token.Text.ToUpper())
{
case "TYPE":
settingType = TypesSettingScope.TYPE;
_DescribeSettingDefinition = new DescribeSettingDefinition(settingType, myTypeName: (parseNode.ChildNodes[2].ChildNodes[0].AstNode as ATypeNode).ReferenceAndType.TypeName);
break;
case "ATTRIBUTE":
settingType = TypesSettingScope.ATTRIBUTE;
_DescribeSettingDefinition = new DescribeSettingDefinition(settingType, myIDChain: (parseNode.ChildNodes[2].ChildNodes[2].AstNode as IDNode).IDChainDefinition);
break;
case "DB":
settingType = TypesSettingScope.DB;
_DescribeSettingDefinition = new DescribeSettingDefinition(settingType);
break;
case "SESSION":
settingType = TypesSettingScope.SESSION;
_DescribeSettingDefinition = new DescribeSettingDefinition(settingType);
break;
default:
settingType = null;
_DescribeSettingDefinition = new DescribeSettingDefinition(settingType);
break;
}
}
}
示例6: InitNode
/// <summary>
/// Converts identifiers to compound symbols (strings in double quotes),
/// expands character strings (in single quotes) to arrays of characters
/// </summary>
public static void InitNode(AstContext context, ParseTreeNode parseNode)
{
foreach (var node in parseNode.ChildNodes)
{
if (node.AstNode is LiteralValueNode)
{
if (node.Term.Name == "Char")
{
var literal = node.AstNode as LiteralValueNode;
literal.Value = literal.Value.ToString().ToCharArray();
}
parseNode.AstNode = node.AstNode;
}
else
{
// identifiers in expressions are treated as strings (True is same as "True")
parseNode.AstNode = new LiteralValueNode()
{
Value = node.FindTokenAndGetText(),
Span = node.Span
};
}
}
}
示例7: Init
public void Init(ParsingContext context, ParseTreeNode parseNode)
{
if (HasChildNodes(parseNode))
{
BinExprNode = (BinaryExpressionNode)parseNode.ChildNodes[1].AstNode;
}
}
示例8: Init
public void Init(ParsingContext context, ParseTreeNode parseNode)
{
if (HasChildNodes(parseNode))
{
//get type
if (parseNode.ChildNodes[1] != null && parseNode.ChildNodes[1].AstNode != null)
{
_Type = ((AstNode)(parseNode.ChildNodes[1].AstNode)).AsString;
}
else
{
throw new NotImplementedQLException("");
}
if (parseNode.ChildNodes[3] != null && HasChildNodes(parseNode.ChildNodes[3]))
{
_AttributeAssignList = new List<AAttributeAssignOrUpdate>((parseNode.ChildNodes[3].AstNode as AttributeUpdateOrAssignListNode).ListOfUpdate.Select(e => e as AAttributeAssignOrUpdate));
}
if (parseNode.ChildNodes[4] != null && ((WhereExpressionNode)parseNode.ChildNodes[4].AstNode).BinaryExpressionDefinition != null)
{
_WhereExpression = ((WhereExpressionNode)parseNode.ChildNodes[4].AstNode).BinaryExpressionDefinition;
}
}
}
示例9: GetContent
public override void GetContent(CompilerContext context, ParseTreeNode parseNode)
{
#region Get the optional type list
if (parseNode.ChildNodes[1].HasChildNodes())
{
_TypesToDump = ((parseNode.ChildNodes[1].ChildNodes[1].AstNode as TypeListNode).Types).Select(tlnode => tlnode.TypeName).ToList();
}
#endregion
_DumpType = (parseNode.ChildNodes[2].AstNode as DumpTypeNode).DumpType;
_DumpFormat = (parseNode.ChildNodes[3].AstNode as DumpFormatNode).DumpFormat;
_DumpableGrammar = context.Compiler.Language.Grammar as IDumpable;
if (_DumpableGrammar == null)
{
throw new GraphDBException(new Error_NotADumpableGrammar(context.Compiler.Language.Grammar.GetType().ToString()));
}
if (parseNode.ChildNodes[4].HasChildNodes())
{
_DumpDestination = parseNode.ChildNodes[4].ChildNodes[1].Token.ValueString;
}
}
示例10: GetContent
public void GetContent(CompilerContext context, ParseTreeNode parseNode)
{
if (parseNode.HasChildNodes())
{
_DescrAggrDefinition = new DescribeAggregateDefinition(parseNode.ChildNodes[1].Token.ValueString.ToUpper());
}
}
示例11: BuildInterfaceMethod
// Build an interface method declaration.
public static void BuildInterfaceMethod(IronyParser parser, Root root, Expression parentExpression, ParseTreeNode currentNode)
{
var method = new MethodDeclaration(parentExpression, currentNode.Token.Convert());
parentExpression.ChildExpressions.Add(method);
// Build the return type of the interface method.
method.ReturnTypeName = parser.CheckAlias(currentNode.ChildNodes[0].ChildNodes[0].FindTokenAndGetText());
// The name of the interface method.
method.Name = currentNode.ChildNodes[0].ChildNodes[1].FindTokenAndGetText();
// Build the list of generic type names.
if (currentNode.ChildNodes[1].ChildNodes.Count > 0)
{
var generics = currentNode.ChildNodes[1].ChildNodes[0].ChildNodes[1];
foreach (string s in IronyParser.InterpretList(generics))
method.GenericTypeNames.Add(parser.CheckAlias(s));
}
// Build the arguments of the method
if (currentNode.ChildNodes[2].ChildNodes.Count > 0)
{
foreach (var n in currentNode.ChildNodes[2].ChildNodes)
{
MethodDeclarationBuilder.BuildArgument(parser, method, n.ChildNodes[0]);
}
}
}
示例12: Init
public override void Init(ParsingContext context, ParseTreeNode treeNode) {
base.Init(context, treeNode);
Value = treeNode.Token.Value;
AsString = Value == null ? "null" : Value.ToString();
if (Value is string)
AsString = "\"" + AsString + "\"";
}
示例13: Init
public override void Init(ParsingContext context, ParseTreeNode treeNode) {
base.Init(context, treeNode);
Test = AddChild("Test", treeNode.ChildNodes[0]);
IfTrue = AddChild("IfTrue", treeNode.ChildNodes[1]);
if (treeNode.ChildNodes.Count > 2)
IfFalse = AddChild("IfFalse", treeNode.ChildNodes[2]);
}
示例14: InitImpl
private void InitImpl(AstContext context, ParseTreeNode parseNode, ParseTreeNode parametersNode, ParseTreeNode bodyNode) {
base.Init(context, parseNode);
Parameters = AddChild("Parameters", parametersNode);
Body = AddChild("Body", bodyNode);
AsString = "Lambda[" + Parameters.ChildNodes.Count + "]";
Body.SetIsTail(); //this will be propagated to the last statement
}
示例15: Init
public override void Init(ParsingContext context, ParseTreeNode treeNode) {
base.Init(context, treeNode);
foreach (var child in treeNode.ChildNodes) {
AddChild("parameter", child);
}
AsString = "Param list";
}