示例#1
0
        public override ParserNode Optimize(ParserNodeContext Context)
        {
            ParserNodeContainer OptimizedNode = CreateThisInstanceAs <ParserNodeContainer>();

            foreach (var Node in Nodes)
            {
                OptimizedNode.Add(Node.Optimize(Context));
            }
            return(OptimizedNode);
        }
示例#2
0
        public ParserNode HandleLevel_Root()
        {
            var ParserNodeContainer = new ParserNodeContainer();

            try
            {
                while (Tokens.HasMore)
                {
                    //Console.WriteLine(CurrentToken);
                    switch (CurrentTokenType)
                    {
                        case "RawTemplateToken":
                            ParserNodeContainer.Add(new ParserNodeLiteral()
                            {
                                Text = ((RawTemplateToken)CurrentToken).Text,
                            });
                            Tokens.MoveNext();
                            break;
                        case "OpenTagTemplateToken":
                            string OpenType = CurrentToken.Text;

                            Tokens.MoveNext();

                            switch (OpenType)
                            {
                                case "{{":
                                    ParserNodeContainer.Add(new ParserNodeOutputExpression() { Parent = HandleLevel_Tag() });
                                    Tokens.ExpectValueAndNext("}}");
                                    break;
                                case "{%": {
                                    ParserNode ParserNode = HandleLevel_TagSpecial();
                                    ParserNodeContainer.Add(ParserNode);
                                    //ParserNode.Dump();
                                } break;
                            }
                            break;
                        default:
                            throw (new Exception(String.Format("Unprocessed Token Type '{0}'('{1}')", CurrentTokenType, CurrentToken.Text)));
                    }
                }
            }
            catch (Finalize_HandlingLevel_Root)
            {
            }

            return ParserNodeContainer;
        }