本文整理汇总了C#中Irony类的典型用法代码示例。如果您正苦于以下问题:C# Irony类的具体用法?C# Irony怎么用?C# Irony使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Irony类属于命名空间,在下文中一共展示了Irony类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public override void Init(Irony.Parsing.ParsingContext context, Irony.Parsing.ParseTreeNode treeNode)
{
base.Init(context, treeNode);
instruction = (Instructions)Enum.Parse(typeof(Instructions), treeNode.ChildNodes[0].FindTokenAndGetText());
AddChild("firstOperand", treeNode.ChildNodes[1]);
AddChild("secondOperand", treeNode.ChildNodes[2]);
}
示例2: Init
public override void Init(Irony.Parsing.ParsingContext context, Irony.Parsing.ParseTreeNode treeNode)
{
base.Init(context, treeNode);
AddChild("LValue", treeNode.ChildNodes[0].ChildNodes[0]);
AddChild("RValue", treeNode.ChildNodes[2]);
@operator = treeNode.ChildNodes[1].FindTokenAndGetText();
ResultType = "word";
if (opcodes == null)
{
opcodes = new Dictionary<string, Instructions>();
opcodes.Add("=", Instructions.SET);
opcodes.Add("+=", Instructions.ADD);
opcodes.Add("-=", Instructions.SUB);
opcodes.Add("*=", Instructions.MUL);
opcodes.Add("/=", Instructions.DIV);
opcodes.Add("-*=", Instructions.MLI);
opcodes.Add("-/=", Instructions.DVI);
opcodes.Add("%=", Instructions.MOD);
opcodes.Add("-%=", Instructions.MDI);
opcodes.Add("<<=", Instructions.SHL);
opcodes.Add(">>=", Instructions.SHR);
opcodes.Add("&=", Instructions.AND);
opcodes.Add("|=", Instructions.BOR);
opcodes.Add("^=", Instructions.XOR);
}
}
示例3: Init
public override void Init(Irony.Parsing.ParsingContext context, Irony.Parsing.ParseTreeNode treeNode)
{
base.Init(context, treeNode);
if (treeNode.ChildNodes.Count == 1)
{
Value = new IntegerAstNode()
{
Value = 1
};
PeriodicType = PeriodicTypeAst.Day;
}
else
{
Value = AddChild("value", treeNode.FirstChild) as ExpressionAstNode;
string periodType = treeNode.ChildNodes[1].FindTokenAndGetText().ToLower();
switch (periodType)
{
case "month":
case "months": PeriodicType = PeriodicTypeAst.Month; break;
case "days":
case "day": PeriodicType = PeriodicTypeAst.Day; break;
default:
throw new ArgumentException("Unregconized period type:" + periodType);
}
}
}
示例4: DoEvaluate
protected override object DoEvaluate(Irony.Interpreter.ScriptThread thread)
{
object retval = null;
thread.CurrentNode = this; //standard prolog
if (Left != null)
{
if (_TheFunction != null)
{
_TheFunction.Left = Left;
retval = _TheFunction.Evaluate(thread);
}
else if (_PropNode != null)
{
_PropNode.Left = Left;
retval = _PropNode.Evaluate(thread);
}
}
if (_queue != null)
{
_queue.Left = retval;
retval = _queue.Evaluate(thread);
}
thread.CurrentNode = Parent; //standard epilog
return retval;
}
示例5: Init
public override void Init(Irony.Parsing.ParsingContext context, Irony.Parsing.ParseTreeNode treeNode)
{
base.Init(context, treeNode);
_globalParamDef = new List<GlobalIdentifierAstNode>();
foreach (var node in treeNode.ChildNodes[0].ChildNodes)
{
_globalParamDef.Add((GlobalIdentifierAstNode)node.AstNode );
}
PositionSets = new List<DefinePositionSetAstNode>();
StrategyParameters = new List<StrategyParameterAstNode>();
Irony.Ast.AstNode targetAstNode;
foreach (var node in treeNode.ChildNodes[1].ChildNodes)
{
targetAstNode = node.FirstChild.AstNode as Irony.Ast.AstNode;
if (targetAstNode is DefinePositionSetAstNode)
PositionSets.Add(targetAstNode as DefinePositionSetAstNode);
else if (targetAstNode is StrategyParameterAstNode)
StrategyParameters.Add(targetAstNode as StrategyParameterAstNode);
}
TradingRules = new List<GeneralRuleAstNode>();
foreach (var node in treeNode.ChildNodes[2].ChildNodes)
{
TradingRules.Add(node.AstNode as GeneralRuleAstNode);
}
}
示例6: Evaluate
public override void Evaluate(Irony.Interpreter.EvaluationContext context, AstMode mode)
{
_x.Evaluate (context, AstMode.Read);
_y.Evaluate (context, AstMode.Read);
_z.Evaluate (context, AstMode.Read);
_dx.Evaluate (context, AstMode.Read);
_dy.Evaluate (context, AstMode.Read);
_dz.Evaluate (context, AstMode.Read);
_ux.Evaluate (context, AstMode.Read);
_uy.Evaluate (context, AstMode.Read);
_uz.Evaluate (context, AstMode.Read);
double x = Convert.ToDouble (context.Data[8]);
double y = Convert.ToDouble (context.Data[7]);
double z = Convert.ToDouble (context.Data[6]);
double ux = Convert.ToDouble (context.Data[2]);
double uy = Convert.ToDouble (context.Data[1]);
double uz = Convert.ToDouble (context.Data[0]);
double dx = Convert.ToDouble (context.Data[5]);
double dy = Convert.ToDouble (context.Data[4]);
double dz = Convert.ToDouble (context.Data[3]);
Api.LookAt (x, y, z, ux, uy, uz, dx, dy, dz);
}
示例7: Init
public override void Init(Irony.Parsing.ParsingContext context, Irony.Parsing.ParseTreeNode treeNode)
{
base.Init(context, treeNode);
AddChild("instruction", treeNode.ChildNodes[0]);
AddChild("firstOperand", treeNode.ChildNodes[1]);
AddChild("secondOperand", treeNode.ChildNodes[2]);
}
示例8: Init
public override void Init(Irony.Parsing.ParsingContext context, Irony.Parsing.ParseTreeNode treeNode)
{
base.Init (context, treeNode);
_paramName = AddChild ("name", treeNode.ChildNodes[0]);
_array = AddChild ("array", treeNode.ChildNodes[1]);
}
示例9: convert
public override bool convert( Irony.Parsing.ParseTreeNode node, Compiler c )
{
base.convert( node, c );
if( node.Term.Name == "DictExpr" )
{
var elems = node.ChildNodes[1];
if( elems.Term.Name != "DictElements" )
throw new CompilationException( "Expected DictElements", node );
foreach( var child in elems.ChildNodes )
{
if( child.Term.Name != "DictElement" )
throw new CompilationException( "Expected DictElement", child );
Pair p = new Pair()
{
key = c.convertNode( child.ChildNodes[0] ),
value = c.convertNode( child.ChildNodes[1] )
};
this.pairs.Add( p );
}
return true;
}
return false;
}
示例10: DoEvaluate
protected override object DoEvaluate(Irony.Interpreter.ScriptThread thread)
{
// List<object> retval = new List<object>();
object retval = null;
thread.CurrentNode = this; //standard prolog
string propertyName = property.ChildNodes[0].FindTokenAndGetText();
if (Left is IEnumerable<object>)
{
IEnumerable<object> o = Left as IEnumerable<object>;
foreach (var origItem in o)
{
IPersistIfcEntity entity = origItem as IPersistIfcEntity;
retval = entity.GetPropertyByName(propertyName);
}
}
else if (Left is IPersistIfcEntity)
{
IPersistIfcEntity entity = Left as IPersistIfcEntity;
retval = entity.GetPropertyByName(propertyName);
}
thread.CurrentNode = Parent; //standard epilog
return retval;
}
示例11: Evaluate
public override void Evaluate(Irony.Interpreter.EvaluationContext context, AstMode mode)
{
_paramName.Evaluate (context, AstMode.Read);
_array.Evaluate (context, AstMode.Read);
_name = (_paramName as Irony.Ast.LiteralValueNode).Value as string;
}
示例12: Init
public override void Init(Irony.Parsing.ParsingContext context, Irony.Parsing.ParseTreeNode treeNode)
{
base.Init(context, treeNode);
if (treeNode.ChildNodes[1].FirstChild.ChildNodes.Count > 0)
AddChild("value", treeNode.ChildNodes[1].FirstChild.FirstChild);
this.AsString = treeNode.FindTokenAndGetText();
}
示例13: Init
public override void Init(Irony.Parsing.ParsingContext context, Irony.Parsing.ParseTreeNode treeNode)
{
base.Init(context, treeNode);
AddChild("Expression", treeNode.ChildNodes[1].FirstChild);
AddChild("Block", treeNode.ChildNodes[2]);
this.AsString = "While";
}
示例14: Init
public override void Init(Irony.Parsing.ParsingContext context, Irony.Parsing.ParseTreeNode treeNode)
{
base.Init(context, treeNode);
_exchangeRateAccessor = AddChild("exchangeRateAccessor", treeNode.ChildNodes[0]) as ExchangeRateAccessorAstNode;
_dateExpr = AddChild("dateExpr", treeNode.ChildNodes[1]) as ExpressionAstNode;
}
示例15: Init
public override void Init(Irony.Parsing.ParsingContext context, Irony.Parsing.ParseTreeNode treeNode)
{
base.Init(context, treeNode);
_positionSetAstNode = (PositionSetAstNode)AddChild("PositionSetAstNode", treeNode.ChildNodes[0]);
_expressionAstNode = (ExpressionAstNode)AddChild("ExpressionAstNode", treeNode.ChildNodes[1]);
}