public override object VisitAggregator(CryslGrammarParser.AggregatorContext context)
        {
            Aggregator         aggregator      = new Aggregator();
            List <Aggregators> aggregatorsList = new List <Aggregators>();

            foreach (var varName in context.VARNAME())
            {
                Aggregators aggregators = new Aggregators();
                //check for aggregators name
                if (varName.Symbol.TokenIndex < context.COLON().Symbol.TokenIndex&& varName.Symbol.TokenIndex < context.EQUALS().Symbol.TokenIndex)
                {
                    aggregator.Aggregator_Name = varName.GetText();
                }

                //check for aggregators varname and regex between aggregators
                if (varName.Symbol.TokenIndex > context.COLON().Symbol.TokenIndex&& varName.Symbol.TokenIndex > context.EQUALS().Symbol.TokenIndex)
                {
                    //aggregatorsDict.Add("aggregator_event_varname", varName.GetText());
                    aggregators.Aggregator_Event_Varname = varName.GetText();

                    //Check for OR symbol
                    foreach (var aggOrSymbol in context.OR())
                    {
                        if (!String.IsNullOrEmpty(aggOrSymbol.GetText()))
                        {
                            int tokenDifference = aggOrSymbol.Symbol.TokenIndex - varName.Symbol.TokenIndex;
                            if (tokenDifference == 1)
                            {
                                aggregators.Aggregator_Regex = aggOrSymbol.GetText();
                            }
                        }
                    }

                    //check for AND symbol
                    foreach (var aggAndSymbol in context.AND())
                    {
                        if (!String.IsNullOrEmpty(aggAndSymbol.GetText()))
                        {
                            int tokenDifference = aggAndSymbol.Symbol.TokenIndex - varName.Symbol.TokenIndex;
                            if (tokenDifference == 1)
                            {
                                //aggregatorsDict.Add("aggregator_regex", aggAndSymbol.GetText());
                                aggregators.Aggregator_Regex = aggAndSymbol.GetText();
                            }
                        }
                    }
                }
                if (!String.IsNullOrEmpty(aggregators.Aggregator_Event_Varname))
                {
                    aggregatorsList.Add(aggregators);
                }
            }
            aggregator.Aggregators = aggregatorsList;
            return(aggregator);
        }
Пример #2
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="CryslGrammarParser.aggregator"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitAggregator([NotNull] CryslGrammarParser.AggregatorContext context)
 {
     return(VisitChildren(context));
 }