Beispiel #1
0
        public override object VisitBody([NotNull] ChatParser.BodyContext context)
        {
            // Default window size is 70
            int windowSize = 70;

            if (context != null)
            {
                if (context.InWin() != null)
                {
                    try
                    {
                        windowSize = Int32.Parse(context.number().GetText());
                    }
                    catch (FormatException)
                    {
                        MessageBox.Show("Incorrect query");
                    }
                }



                if (context.restrictions() != null)
                {
                    // If query / subquery contains only restrictions -- we need only merge restrictions
                    // [x1...xn] -- result for restriction R1
                    // [y1...ym] -- result for restriction R2
                    // Select R1, R2 inwin W
                    // Result is vector of vectors [[xi, yj]] where 0 < yj - xi <= W
                    // So we have only one restriction group

                    var onlyRestrictions   = (MsgGroups)VisitRestrictions(context.restrictions());
                    var mergedRestrcitions = MergeRestrictions(onlyRestrictions, windowSize);

                    return(OnlyRestrictionsToList(mergedRestrcitions));
                }
                else if (context.query_seq() != null)
                {
                    // Now in this query subqueries only.
                    // Also we have invariant: results of son's query are calculated correctlly.
                    // It means that now we have only son's correct accomadation.

                    var subQueryResults = (List <List <MsgGroups> >)VisitQuery_seq(context.query_seq());

                    return(MergeQueries(subQueryResults, windowSize));
                }
            }
            else
            {
                return(null);
            }
            return(null);
        }
 /// <summary>
 /// Visit a parse tree produced by <see cref="ChatParser.body"/>.
 /// <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 VisitBody([NotNull] ChatParser.BodyContext context)
 {
     return(VisitChildren(context));
 }