Esempio n. 1
0
        public override bool Process(Token token)
        {
            // start tag, end tag, doctype, comment, character, eof
            switch (token.Type)
            {
            case Token.TokenType.StartTag:
                Insert(token.AsStartTag());
                break;

            case Token.TokenType.EndTag:
                PopStackToClose(token.AsEndTag());
                break;

            case Token.TokenType.Comment:
                Insert(token.AsComment());
                break;

            case Token.TokenType.Character:
                Insert(token.AsCharacter());
                break;

            case Token.TokenType.Doctype:
                Insert(token.AsDoctype());
                break;

            case Token.TokenType.EOF:     // could put some normalisation here if desired
                break;

            default:
                throw new Exception("Unexpected token type: " + token.Type);
            }
            return(true);
        }