Example #1
0
        public Token NextNonWhiteSpaceToken(MingeTokenizer tk)
        {
            Token tok;

            do {
                tok = tk.GetNextToken ();
            } while (tok.Type == TokenType.TOKEN_WHITESPACE);

            return tok;
        }
Example #2
0
        public void ParseControlBlock(MingeTokenizer tk)
        {
            Token tok;
            StringBuilder builder = new StringBuilder ();

            ParseStatement (tk);
            tok = tk.Current;

            do {
                if (tok.Type == TokenType.TOKEN_BLOCK_END) {
                    return;
                }

                builder.Append (tok.Value);

                tok = tk.GetNextToken ();

            } while (tok.Type != TokenType.TOKEN_EOF);
        }
Example #3
0
        public Page ParsePage(string name, TextReader reader)
        {
            Console.WriteLine ("parsing page:  {0}", name);
            MingeTokenizer tk = new MingeTokenizer (environment, reader);

            current_page = application.CreatePage (name);

            Token tok = null;
            StringBuilder data = new StringBuilder ();

            while (true) {
                tok = tk.GetNextToken ();

                switch (tok.Type) {
                case TokenType.TOKEN_VARIABLE_BEGIN:
                    FlushData (data);
                    ParseVariable (tk);
                    break;
                case TokenType.TOKEN_COMMENT_BEGIN:
                    FlushData (data);
                    ParseComment (tk);
                    break;
                case TokenType.TOKEN_BLOCK_BEGIN:
                    FlushData (data);
                    ParseControlBlock (tk);
                    break;
                case TokenType.TOKEN_EOF:
                    FlushData (data);
                    current_page.Save ();
                    return current_page;
                default:
                    data.Append (tok.Value);
                    break;
                }
            }

            return null;
        }
Example #4
0
        public void ParseComment(MingeTokenizer tk)
        {
            Token tok;
            StringBuilder builder = new StringBuilder ();
            do {
                tok = tk.GetNextToken ();

                if (tok.Type == TokenType.TOKEN_COMMENT_END) {
                    return;
                }

                builder.Append (tok.Value);

            } while (tok.Type != TokenType.TOKEN_EOF);

            // FAIL
        }