public override void Init(Irony.Parsing.ParsingContext context, Irony.Parsing.ParseTreeNode treeNode) { base.Init(context, treeNode); Name = treeNode.ChildNodes[0].FindTokenAndGetText(); ExecuteFrequency = AddChild("executeFrequency", treeNode.ChildNodes[1]) as ExecutonFrequencyAstNode; Statements = (StatementListNode)AddChild("statements", treeNode.ChildNodes[2]); }
/// <summary> /// Transform execute frequency from rule ast node to model /// </summary> /// <param name="tradingRuleAst"></param> /// <returns></returns> private TimeIntervalDefinition ConvertExecutionFrequency(ExecutonFrequencyAstNode executeFrequency) { if (executeFrequency is ConcreteTimeDefinitionAstNode) { return new ConcreteTimeDefinition() { ExecuteTime = ((ConcreteTimeDefinitionAstNode)executeFrequency).ExecuteTime }; } else if (executeFrequency is PeriodicTimeDefinitionAstNode) { PeriodicTimeDefinitionAstNode periodicTimeDefAst = executeFrequency as PeriodicTimeDefinitionAstNode; return new PeriodicTimeDefinition( ConvertExpressionAst(periodicTimeDefAst.Value), PeriodicTypeConvert(periodicTimeDefAst.PeriodicType) ); } else if (executeFrequency is WeekDayTimeDefinitionAstNode) { return new WeekDayTimeDefinition() { DayOfWeek = ((WeekDayTimeDefinitionAstNode)executeFrequency).Weekday.DayOfWeek }; } else throw new TypeAccessException("The type of ExecuteFrequency is not handled. Type of ExecuteFrequency: " + executeFrequency.GetType()); }