Example #1
0
        private void Parser_ContextChanged(object sender, ContextChangedEventArgs e)
        {
            //Console.WriteLine(e.ToString());

            contextSwitch?.TearDownContext();

            switch (e.Context)
            {
            case ParserContext.GlobalBlock:
                globalContextSwitch = new FunctionContextSwitch(this);
                globalContextSwitch.AddNode(GlobalFunctionId, ParserParts.DefOp);
                break;

            case ParserContext.UserFuncBlock:
                contextSwitch = new FunctionContextSwitch(this);
                break;

            case ParserContext.Statement:
                contextSwitch = new StatementContextSwitch()
                {
                    ParentFuncNode = currentFunctionNode
                };
                contextSwitch.AddNode("Statement", ParserParts.NullPart);
                break;

            case ParserContext.Variable:
                contextSwitch = new ParseVariableContextSwitch()
                {
                    ParentFuncNode = currentFunctionNode
                };
                break;

            case ParserContext.Operator:
                contextSwitch = new OperatorContextSwitch()
                {
                    ParentFuncNode = currentFunctionNode
                };
                break;

            case ParserContext.Argument:
                if (!(contextSwitch is ParseArgumentContextSwitch))
                {
                    contextSwitch = new ParseArgumentContextSwitch()
                    {
                        ParentFuncNode = currentFunctionNode
                    }
                }
                ;
                break;

            case ParserContext.AttPredicate:
                contextSwitch = new AttributePredicateSwitch()
                {
                    ParentFuncNode = currentFunctionNode
                };
                break;

            case ParserContext.CountPredicate:
                contextSwitch = new CountPredicateContextSwitch()
                {
                    ParentFuncNode = currentFunctionNode
                };
                break;
            }
        }