public static void AddOptionalSimpleProperty( ExprNode exprNode, IToken token, VariableCompileTimeResolver variableCompileTimeResolver, StatementSpecRaw spec) { if (token == null) { return; } ExprNode node = ASTExprHelper.ResolvePropertyOrVariableIdentifier(token.Text, variableCompileTimeResolver, spec); exprNode.AddChildNode(node); }
public static ExprTimePeriod TimePeriodGetExprAllParams( EsperEPL2GrammarParser.TimePeriodContext ctx, IDictionary<ITree, ExprNode> astExprNodeMap, VariableCompileTimeResolver variableCompileTimeResolver, StatementSpecRaw spec, Configuration config, TimeAbacus timeAbacus) { ExprNode[] nodes = new ExprNode[9]; for (int i = 0; i < ctx.ChildCount; i++) { IParseTree unitRoot = ctx.GetChild(i); ExprNode valueExpr; if (ASTUtil.IsTerminatedOfType(unitRoot.GetChild(0), EsperEPL2GrammarLexer.IDENT)) { string ident = unitRoot.GetChild(0).GetText(); valueExpr = ASTExprHelper.ResolvePropertyOrVariableIdentifier(ident, variableCompileTimeResolver, spec); } else { AtomicReference<ExprNode> @ref = new AtomicReference<ExprNode>(); ExprAction action = (exprNode, astExprNodeMapX, node) => { astExprNodeMapX.Remove(node); @ref.Set(exprNode); }; ASTExprHelper.RecursiveFindRemoveChildExprNode(unitRoot.GetChild(0), astExprNodeMap, action); valueExpr = @ref.Get(); } if (ASTUtil.GetRuleIndexIfProvided(unitRoot) == EsperEPL2GrammarParser.RULE_microsecondPart) { nodes[8] = valueExpr; } if (ASTUtil.GetRuleIndexIfProvided(unitRoot) == EsperEPL2GrammarParser.RULE_millisecondPart) { nodes[7] = valueExpr; } if (ASTUtil.GetRuleIndexIfProvided(unitRoot) == EsperEPL2GrammarParser.RULE_secondPart) { nodes[6] = valueExpr; } if (ASTUtil.GetRuleIndexIfProvided(unitRoot) == EsperEPL2GrammarParser.RULE_minutePart) { nodes[5] = valueExpr; } if (ASTUtil.GetRuleIndexIfProvided(unitRoot) == EsperEPL2GrammarParser.RULE_hourPart) { nodes[4] = valueExpr; } if (ASTUtil.GetRuleIndexIfProvided(unitRoot) == EsperEPL2GrammarParser.RULE_dayPart) { nodes[3] = valueExpr; } if (ASTUtil.GetRuleIndexIfProvided(unitRoot) == EsperEPL2GrammarParser.RULE_weekPart) { nodes[2] = valueExpr; } if (ASTUtil.GetRuleIndexIfProvided(unitRoot) == EsperEPL2GrammarParser.RULE_monthPart) { nodes[1] = valueExpr; } if (ASTUtil.GetRuleIndexIfProvided(unitRoot) == EsperEPL2GrammarParser.RULE_yearPart) { nodes[0] = valueExpr; } } ExprTimePeriod timeNode = new ExprTimePeriodImpl( nodes[0] != null, nodes[1] != null, nodes[2] != null, nodes[3] != null, nodes[4] != null, nodes[5] != null, nodes[6] != null, nodes[7] != null, nodes[8] != null, timeAbacus); foreach (ExprNode node in nodes) { if (node != null) { timeNode.AddChildNode(node); } } return timeNode; }