Beispiel #1
0
        public override void ProcessState(IStateContext context)
        {
            IParseString ps = context.GetParseString();
            Tree         v  = new Tree(ps.GetVarNum());

            if (ps.HasChar() && ps.PeekChar() == '"')
            {
                ps.GetChar();
                v.AddNot();
            }
            if (context.GetCurrentConj() == null)
            {
                context.SetCurrentConj(v.ReturnRoot());
            }
            else
            {
                context.SetCurrentConj(new Tree.AndNode((Tree.Node)context.GetCurrentConj(),
                                                        (Tree.Node)v.ReturnRoot()));
            }
            ps.ClearTerm();
            ChangeState(new FindOperationState(GetParent()));
        }
Beispiel #2
0
        public override void ProcessState(IStateContext context)
        {
            IParseString ps = context.GetParseString();

            if (context.GetRoot() != null)
            {
                if (context.GetCurrentConj() != null)
                {
                    context.SetRoot(new Tree.OrNode((Tree.Node)context.GetRoot(), (Tree.Node)context.GetCurrentConj()));
                }
            }
            else
            {
                context.SetRoot(context.GetCurrentConj());
            }
            context.SetCurrentConj(null);
            if (ps.HasChar())
            {
                ChangeState(new InitState(GetParent()));
            }
        }
Beispiel #3
0
        public override void ProcessState(IStateContext context)
        {
            IParseString  ps         = context.GetParseString();
            IStateContext oldcontext = context.GetPrevousContext();

            if (oldcontext == null)
            {
                GetParent().SetError("Unexpected closing parenthesis at pos  " + (ps.GetPosition() - 1).ToString());
                ChangeState(new ErrorState(GetParent()));
                return;
            }
            if (context.GetRoot() == null)
            {
                if (context.GetCurrentConj() != null)
                {
                    context.SetRoot(context.GetCurrentConj()); // êîíåö êîíúþíêöèè
                }
                else
                {
                    GetParent()
                    .SetError("Empty expression between parenthesis at pos " + ((ps.GetPosition() - 1).ToString()));
                    ChangeState(new ErrorState(GetParent()));
                    return;
                }
            }
            else
            {
                if (context.GetCurrentConj() != null)
                {
                    context.SetRoot(
                        new Tree.OrNode((Tree.Node)context.GetRoot(), (Tree.Node)context.GetCurrentConj()));
                }
            }
            context.SetCurrentConj(null);
            if (ps.HasChar() && ps.PeekChar() == '"')
            {
                ps.GetChar();
                if (context.GetRoot() != null)
                {
                    context.SetRoot(new Tree.NotNode((Tree.Node)context.GetRoot()));
                }
            }
            if (oldcontext.GetCurrentConj() != null)
            {
                oldcontext.SetCurrentConj(new Tree.AndNode((Tree.Node)oldcontext.GetCurrentConj(),
                                                           (Tree.Node)context.GetRoot()));
            }
            else
            {
                oldcontext.SetCurrentConj(context.GetRoot());
            }

            GetParent().ChangeContext(oldcontext);
            if (!ps.HasChar() && oldcontext.GetPrevousContext() != null)
            {
                GetParent().SetError("Not found close bracket at pos " + ((ps.GetPosition() - 1).ToString()));
                ChangeState(new ErrorState(GetParent()));
            }
            else
            {
                ChangeState(new InitState(GetParent()));
            }
        }