예제 #1
0
        public override void Accept(Token token, HtmlStateMachineGizmo context)
        {
            if (token.Type == TokenType.AttributeName)
            {
                context.Transition(States.Attributes, token);

                return;
            }

            if (token.Type == TokenType.EndTag)
            {
                context.Transition(States.Start, token);

                return;
            }

            if (token.Type == TokenType.SelfCloseTag)
            {
                context.TreeBuilder.CompleteCurrentElement();
                context.Transition(States.Start, token);

                return;
            }

            throw new Exception("I'm sitting here thinking you were going to define a tag, but instead you're doing this: " + token.Type);
        }
예제 #2
0
        public override void Accept(Token token, HtmlStateMachineGizmo context)
        {
            if (token.Type == TokenType.Doctype)
            {
                context.Transition(States.Doctype, token);

                return;
            }

            if (token.Type == TokenType.BeginComment)
            {
                context.Transition(States.Comment, token);

                return;
            }

            if (token.Type == TokenType.EndDoc)
            {
                context.Transition(States.End, token);

                return;
            }

            throw new Exception("Hmm, looks like you started declaring something cool then decided not to: " + token.Type);
        }
예제 #3
0
        public override void Accept(Token token, HtmlStateMachineGizmo context)
        {
            if (!GotTagName)
            {
                if (token.Type == TokenType.TagName)
                {
                    TagName    = token.Value;
                    GotTagName = true;

                    return;
                }

                throw new Exception("I was expecting a Tag Name, but I got: " + token.Type);
            }

            if (token.Type == TokenType.EndTag)
            {
                context.TreeBuilder.CompleteCurrentElement(TagName);
                context.Transition(States.Start, token);

                return;
            }

            throw new Exception("Are you not going to end your tags properly, with a '>', because, whatever: " + token.Type);
        }
예제 #4
0
        public override void Accept(Token token, HtmlStateMachineGizmo context)
        {
            if (token.Type == TokenType.MarkupDecl)
            {
                context.Transition(States.Declaration, token);

                return;
            }

            if (token.Type == TokenType.OpenTag)
            {
                context.Transition(States.Element, token);

                return;
            }

            if (token.Type == TokenType.Text)
            {
                context.TreeBuilder.AddChildText(token.Value);

                return;
            }

            if (token.Type == TokenType.CloseTag)
            {
                context.Transition(States.TagDone, token);

                return;
            }

            if (token.Type == TokenType.Code)
            {
                context.Transition(States.Code, token);

                return;
            }

            if (token.Type == TokenType.EndDoc)
            {
                context.Transition(States.End, token);

                return;
            }

            throw new Exception("I was expecting either a Markup Delcaration or Open Tag, but I got: " + token.Type);
        }
예제 #5
0
        public override void Accept(Token token, HtmlStateMachineGizmo context)
        {
            if (token.Type == TokenType.EndComment)
            {
                context.Transition(States.Start, token);

                return;
            }

            if (token.Type == TokenType.EndDoc)
            {
                context.Transition(States.End, token);

                return;
            }

            throw new Exception("You were making a comment, some profound statement about life or whatever, but then got distracted by fart videos? " + token.Type);
        }
예제 #6
0
        public override void Accept(Token token, HtmlStateMachineGizmo context)
        {
            if (token.Type == TokenType.EndTag)
            {
                context.Transition(States.Start, token);

                return;
            }

            if (token.Type == TokenType.EndDoc)
            {
                context.Transition(States.End, token);

                return;
            }

            throw new Exception("Well, you started declaring a Doctype then decided not to? " + token.Type);
        }
예제 #7
0
        public override void Accept(Token token, HtmlStateMachineGizmo context)
        {
            if (token.Type == TokenType.BeginDoc)
            {
                context.TreeBuilder.CreateRoot();
                context.Transition(States.Start, token);

                return;
            }

            if (token.Type == TokenType.EndDoc)
            {
                context.Transition(States.End, token);

                return;
            }

            throw new Exception("Unexpected token: " + token.Type);
        }
예제 #8
0
        public override void Accept(Token token, HtmlStateMachineGizmo context)
        {
            if (token.Type == TokenType.TagName)
            {
                context.Transition(States.Name, token);

                return;
            }

            throw new Exception("I expected to get a Tag Name, but instead I got " + token.Type);
        }
예제 #9
0
        public override void Accept(Token token, HtmlStateMachineGizmo context)
        {
            if (token.Type == TokenType.AttributeName)
            {
                Name = token.Value;
                context.TreeBuilder.AddAttribute(Name, string.Empty);

                return;
            }

            if (token.Type == TokenType.AttributeValue)
            {
                if (Name.Length == 0)
                {
                    throw new Exception("I think you should try assigning a name to Attribute before giving me a value: " + token.Value);
                }

                context.TreeBuilder.AddAttribute(Name, token.Value);
                Name = string.Empty;

                return;
            }

            if (token.Type == TokenType.EndTag)
            {
                context.Transition(States.Start, token);

                return;
            }

            if (token.Type == TokenType.SelfCloseTag)
            {
                context.TreeBuilder.CompleteCurrentElement();
                context.Transition(States.Start, token);

                return;
            }

            throw new Exception("I was thinking I'd get some Attribute stuff and eventually an End Tag, but instead I got this: " + token.Type);
        }
예제 #10
0
        public override void Accept(Token token, HtmlStateMachineGizmo context)
        {
            if (token.Type == TokenType.Code)
            {
                context.TreeBuilder.AddChildText(token.Value);

                return;
            }

            if (token.Type == TokenType.EndCode)
            {
                context.TreeBuilder.CompleteCurrentElement("script");
                context.Transition(States.Start, token);

                return;
            }

            throw new Exception("I was waiting for some Code stuff, but got this crap: " + token.Type);
        }