本文整理汇总了C#中Irony.Ast.AstContext类的典型用法代码示例。如果您正苦于以下问题:C# AstContext类的具体用法?C# AstContext怎么用?C# AstContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AstContext类属于Irony.Ast命名空间,在下文中一共展示了AstContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: 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
};
}
}
}
开发者ID:androdev4u,项目名称:XLParser,代码行数:29,代码来源:LiteralValueNodeHelper.cs
示例2: Init
/// <summary>Initializes the current AST node with the specified <paramref name="context" /> and <paramref name="treeNode" />.</summary>
/// <param name="context">The AST context.</param>
/// <param name="treeNode">The parse tree node associated with the current AST node.</param>
public override void Init(AstContext context, ParseTreeNode treeNode)
{
base.Init(context, treeNode);
AsString=treeNode.ChildNodes[0].Token.Text;
_GeometryType=(GeometryType)Enum.Parse(typeof(GeometryType), AsString, true);
}
开发者ID:mcartoixa,项目名称:GeoSIK,代码行数:10,代码来源:GeometryNode.cs
示例3: Init
public override void Init(AstContext context, ParseTreeNode treeNode)
{
base.Init(context, treeNode);
Text = treeNode.Token.Text;
AsString = "StringValue";
}
开发者ID:Afr0Games,项目名称:Project-Dollhouse,代码行数:7,代码来源:StringValueNode.cs
示例4: Init
public override void Init(AstContext context, ParseTreeNode treeNode)
{
base.Init(context, treeNode);
AstNode sn=AddChild("from", treeNode.ChildNodes[0]);
AstNode en=AddChild("to", treeNode.ChildNodes[2]);
var dtsn=sn as DateTimeLiteralNode;
var dten=en as DateTimeLiteralNode;
if (dtsn!=null)
{
_StartDate=dtsn.Value;
if (dten!=null)
_EndDate=dten.Value;
else
_EndDate=_StartDate+((DurationLiteralNode)en).Value;
} else
{
_EndDate=dten.Value;
_StartDate=_EndDate-((DurationLiteralNode)sn).Value;
}
AsString="period";
}
开发者ID:mcartoixa,项目名称:GeoSIK,代码行数:25,代码来源:DateTimePeriodNode.cs
示例5: 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;
}
}
}
开发者ID:bnaand,项目名称:xBim-Toolkit,代码行数:29,代码来源:SelectMemberAccessNode.cs
示例6: 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 + "]";
}
开发者ID:androdev4u,项目名称:XLParser,代码行数:7,代码来源:IndexedAccessNode.cs
示例7: Init
public override void Init(AstContext context, ParseTreeNode treeNode) {
base.Init(context, treeNode);
foreach (var child in treeNode.ChildNodes) {
AddChild(NodeUseType.Parameter, "expr", child);
}
AsString = "Expression list";
}
开发者ID:Rezura,项目名称:LiveSplit,代码行数:7,代码来源:ExpressionListNode.cs
示例8: Init
public override void Init(AstContext context, ParseTreeNode treeNode)
{
base.Init(context, treeNode);
foreach (var node in treeNode.ChildNodes)
{
// linearize AuxiliaryNode children
if (node.AstNode is AuxiliaryNode)
{
var auxNode = node.AstNode as AuxiliaryNode;
foreach (var n in auxNode.ChildNodes)
ChildNodes.Add(n);
foreach (var n in auxNode.ChildParseNodes)
ChildParseNodes.Add(n);
continue;
}
// copy AstNode nodes
if (node.AstNode is AstNode)
{
ChildNodes.Add(node.AstNode as AstNode);
continue;
}
// otherwise, save parse nodes
ChildParseNodes.Add(node);
}
}
开发者ID:dbremner,项目名称:irony,代码行数:31,代码来源:AuxiliaryNode.cs
示例9: Init
public override void Init(AstContext context, ParseTreeNode treeNode)
{
base.Init(context, treeNode);
var node = treeNode.GetMappedChildNodes()[0];
this.Label = node.Token.ValueString;
}
开发者ID:jwvdiermen,项目名称:0x1DE,代码行数:7,代码来源:LabelValueNode.cs
示例10: Init
public override void Init(AstContext context, ParseTreeNode treeNode)
{
base.Init(context, treeNode);
var term = TerminalFactory.CreateCSharpIdentifier("text");
var tok = new Token(term, Location, "text", System.String.Join("_", treeNode.ChildNodes.Select(cn => cn.Term.Name)));
treeNode.Token = tok;
}
开发者ID:jamescurran,项目名称:ShakespeareCompiler,代码行数:7,代码来源:MultiWordTermialNode.cs
示例11: Init
public override void Init(AstContext context, ParseTreeNode parseNode)
{
base.Init(context, parseNode);
foreach (var node in parseNode.ChildNodes)
{
if (node.AstNode is Expression)
{
Expression = (node.AstNode as Expression);
}
else if (node.AstNode is AuxiliaryNode)
{
var nodes = (node.AstNode as AuxiliaryNode).ChildNodes;
Pattern = nodes.OfType<Pattern>().FirstOrDefault();
Block = nodes.OfType<Block>().FirstOrDefault();
MoreConditions = nodes.OfType<Conditions>().FirstOrDefault();
ResultExpression = nodes.OfType<Expression>().FirstOrDefault();
}
foreach (var astNode in new AstNode[] { Expression, Pattern, Block, MoreConditions, ResultExpression })
{
if (astNode != null)
astNode.Parent = this;
}
}
AsString = Block != null ? "with-clause" : "where-clause";
}
开发者ID:androdev4u,项目名称:XLParser,代码行数:28,代码来源:Conditions.cs
示例12: Init
public override void Init(AstContext context, ParseTreeNode parseNode)
{
base.Init(context, parseNode);
foreach (var node in parseNode.ChildNodes)
{
if (node.AstNode is Function)
{
AddFunction(node.AstNode as Function);
}
else if (node.AstNode is AuxiliaryNode)
{
var ids = (node.AstNode as AuxiliaryNode).ChildNodes.OfType<IdentifierNode>();
foreach (var id in ids)
{
ExternalFunction ef = new ExternalFunction();
ef.SetSpan(id.Span);
ef.Name = id.Symbol;
AddFunction(ef);
}
}
}
AsString = "Refal-5 program";
}
开发者ID:androdev4u,项目名称:XLParser,代码行数:26,代码来源:Program.cs
示例13: Init
public override void Init(AstContext context, ParseTreeNode treeNode)
{
base.Init(context, treeNode);
foreach (var child in treeNode.ChildNodes)
AddChild(NodeUseType.Parameter, "param", child);
AsString = "param_list[" + ChildNodes.Count + "]";
}
开发者ID:dbremner,项目名称:irony,代码行数:7,代码来源:ParamListNode.cs
示例14: Init
public override void Init(AstContext context, ParseTreeNode treeNode) {
base.Init(context, treeNode);
Value = treeNode.Token.Value;
AsString = Value == null ? "null" : Value.ToString();
if (Value is string)
AsString = "\"" + AsString + "\"";
}
开发者ID:Rezura,项目名称:LiveSplit,代码行数:7,代码来源:LiteralValueNode.cs
示例15: 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
}
开发者ID:androdev4u,项目名称:XLParser,代码行数:7,代码来源:LambdaNode.cs
示例16: Init
public override void Init(AstContext context, ParseTreeNode parseNode)
{
base.Init(context, parseNode);
foreach (var node in parseNode.ChildNodes)
{
if (node.AstNode is Pattern)
{
Pattern = node.AstNode as Pattern;
}
else if (node.AstNode is AuxiliaryNode)
{
var nodes = (node.AstNode as AuxiliaryNode).ChildNodes;
Conditions = nodes.OfType<Conditions>().FirstOrDefault();
Expression = nodes.OfType<Expression>().FirstOrDefault();
}
}
foreach (var astNode in new AstNode[] { Pattern, Conditions, Expression })
{
if (astNode != null)
{
astNode.Parent = this;
}
}
AsString = "match";
}
开发者ID:PrototypeAlpha,项目名称:LiveSplit,代码行数:28,代码来源:Sentence.cs
示例17: BuildAst
public virtual void BuildAst(LanguageData language, ParseTree parseTree)
{
if (!LanguageFlags.IsSet(LanguageFlags.CreateAst))
return;
var astContext = new AstContext(language);
var astBuilder = new AstBuilder(astContext);
astBuilder.BuildAst(parseTree);
}
开发者ID:HyperSharp,项目名称:Hyperspace.DotLua,代码行数:8,代码来源:Grammar.cs
示例18: Init
public override void Init(AstContext Context, ParseTreeNode ParseNode)
{
IsDefault = (ParseNode.ChildNodes[0].FindTokenAndGetText() == "default");
if (!IsDefault)
{
Value = ParseNode.ChildNodes[1];
}
}
开发者ID:soywiz,项目名称:nphp,代码行数:8,代码来源:SwitchCaseSentenceNode.cs
示例19: Init
public override void Init(AstContext context, ParseTreeNode treeNode)
{
base.Init(context, treeNode);
_eventEmitter = AddChild(string.Empty, treeNode.ChildNodes[0]) as AstNode;
_eventName = (treeNode.ChildNodes[1].AstNode as AstNode).AsString;
_listener = AddChild(string.Empty, treeNode.ChildNodes[2]) as AstNode;
}
开发者ID:fabriceleal,项目名称:Multitasks,代码行数:8,代码来源:MtListenerStatement.cs
示例20: Init
public override void Init(AstContext context, ParseTreeNode parseNode)
{
Debug.Assert("for" == parseNode.ChildNodes[0].FindTokenAndGetText());
InitialSentence = parseNode.ChildNodes[1];
ConditionExpresion = parseNode.ChildNodes[2];
PostSentence = parseNode.ChildNodes[3];
LoopSentence = parseNode.ChildNodes[4];
}
开发者ID:soywiz,项目名称:nphp,代码行数:8,代码来源:ForNode.cs
注:本文中的Irony.Ast.AstContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论