예제 #1
0
 /// <summary>
 /// More http://www.w3.org/TR/REC-xml/#sec-pi.
 /// </summary>
 /// <param name="c">The next input character.</param>
 protected XmlToken ProcessingStart(Char c)
 {
     if (c.IsLetter())
     {
         _stringBuffer.Clear();
         _stringBuffer.Append(c);
         return ProcessingTarget(_src.Next, XmlToken.Processing());
     }
     else
     {
         RaiseErrorOccurred(ErrorCode.AmbiguousOpenTag);
         throw new ArgumentException("Invalid processing instruction.");
     }
 }
예제 #2
0
        /// <summary>
        /// Breaks apart an event key into the individual and normalized key and
        /// any modifiers.
        /// </summary>
        /// <param name="evt">The evt.</param>
        /// <param name="key">The key.</param>
        /// <param name="modifiers">The mod.</param>
        public static void DecomposeKeys(
            EventKey evt,
            out Key key,
            out ModifierType modifiers)
        {
            // Use the keymap to decompose various elements of the hardware keys.
            uint keyval;
            int  effectiveGroup,
                 level;
            ModifierType consumedModifiers;

            keymap.TranslateKeyboardState(
                evt.HardwareKeycode,
                evt.State,
                evt.Group,
                out keyval,
                out effectiveGroup,
                out level,
                out consumedModifiers);

            // Break out the identified keys and modifiers.
            key       = (Key)keyval;
            modifiers = evt.State & ~consumedModifiers;

            // Normalize some of the keys that don't make sense.
            if (key == Key.ISO_Left_Tab)
            {
                key        = Key.Tab;
                modifiers |= ModifierType.ShiftMask;
            }

            // Check to see if we are a character and pull out the shift key if
            // it is a capital letter. This is used to normalize so all the
            // keys are uppercase with a shift modifier.
            bool shiftWasConsumed = ((evt.State ^ modifiers) & ModifierType.ShiftMask)
                                    != 0;
            var unicode = (char)Keyval.ToUnicode((uint)key);

            if (shiftWasConsumed && Char.IsUpper(unicode))
            {
                modifiers |= ModifierType.ShiftMask;
            }

            if (Char.IsLetter(unicode) &&
                Char.IsLower(unicode))
            {
                key = (Key)Char.ToUpper(unicode);
            }
        }
예제 #3
0
        public void Indent1SuccessTest()
        {
            var toks    = Seq(new Tok(1, 1, 'a'), new Tok(2, 1, 'b'), new Tok(2, 2, 'c'), new Tok(1, 3, 'd'), new Tok(1, 4, '1'));
            var letter  = satisfy <Tok>(t => Char.IsLetter(t.Val));
            var digit   = satisfy <Tok>(t => Char.IsDigit(t.Val));
            var letters = many1(attempt(letter));
            var digits  = many1(attempt(digit));

            var block = from ls1 in indented1 <Tok, Seq <Tok> >(letters)
                        from ls2 in indented1 <Tok, Seq <Tok> >(letters)
                        from dg1 in indented1 <Tok, Seq <Tok> >(digits)
                        from ___ in eof <Tok>()
                        select(ls1, ls2, dg1);

            var res = block.Parse(toks, t => new Pos(t.Ln - 1, t.Col - 1)).ToEither().IfLeft(() => default);
예제 #4
0
        /// <summary>
        /// Gets the encoding specified in the text declaration.
        /// </summary>
        /// <param name="c">The character.</param>
        /// <param name="decl">The current declaration.</param>
        /// <returns>The token.</returns>
        DtdToken TextDeclEncoding(Char c, DtdDeclToken decl)
        {
            if (c == Specification.EQ)
            {
                var q = _stream.Next;

                if (q == Specification.DQ || q == Specification.SQ)
                {
                    _stringBuffer.Clear();
                    c = _stream.Next;

                    if (c.IsLetter())
                    {
                        do
                        {
                            _stringBuffer.Append(c);
                            c = _stream.Next;
                        }
                        while (c.IsAlphanumericAscii() || c == Specification.DOT || c == Specification.UNDERSCORE || c == Specification.MINUS);
                    }

                    if (c == q)
                    {
                        decl.Encoding = _stringBuffer.ToString();
                        return TextDeclAfter(_stream.Next, decl);
                    }
                }
            }

            throw Errors.Xml(ErrorCode.DtdTextDeclInvalid);
        }
예제 #5
0
        private HtmlToken ScriptData(Char c)
        {
            var length = _lastStartTag.Length;
            var scriptLength = TagNames.Script.Length;
            var state = ScriptState.Normal;
            var offset = 0;

            while (true)
            {
                switch (state)
                {
                    // See 8.2.4.6 Script data state
                    case ScriptState.Normal:
                    {
                        switch (c)
                        {
                            case Symbols.Null:
                                AppendReplacement();
                                break;

                            case Symbols.LessThan:
                                StringBuffer.Append(Symbols.LessThan);
                                state = ScriptState.OpenTag;
                                continue;

                            case Symbols.EndOfFile:
                                Back();
                                return NewCharacter();

                            default:
                                StringBuffer.Append(c);
                                break;
                        }

                        c = GetNext();
                        break;
                    }

                    // See 8.2.4.17 Script data less-than sign state
                    case ScriptState.OpenTag:
                    {
                        c = GetNext();

                        if (c == Symbols.Solidus)
                        {
                            state = ScriptState.EndTag;
                        }
                        else if (c == Symbols.ExclamationMark)
                        {
                            state = ScriptState.StartEscape;
                        }
                        else
                        {
                            state = ScriptState.Normal;
                        }

                        break;
                    }

                    // See 8.2.4.20 Script data escape start state
                    case ScriptState.StartEscape:
                    {
                        StringBuffer.Append(Symbols.ExclamationMark);
                        c = GetNext();

                        if (c == Symbols.Minus)
                        {
                            state = ScriptState.StartEscapeDash;
                        }
                        else
                        {
                            state = ScriptState.Normal;
                        }

                        break;
                    }

                    // See 8.2.4.21 Script data escape start dash state
                    case ScriptState.StartEscapeDash:
                    {
                        c = GetNext();
                        StringBuffer.Append(Symbols.Minus);

                        if (c == Symbols.Minus)
                        {
                            StringBuffer.Append(Symbols.Minus);
                            state = ScriptState.EscapedDashDash;
                        }
                        else
                        {
                            state = ScriptState.Normal;
                        }

                        break;
                    }

                    // See 8.2.4.18 Script data end tag open state
                    case ScriptState.EndTag:
                    {
                        c = GetNext();
                        offset = StringBuffer.Append(Symbols.Solidus).Length;
                        var tag = NewTagClose();

                        while (c.IsLetter())
                        {
                            // See 8.2.4.19 Script data end tag name state
                            StringBuffer.Append(c);
                            c = GetNext();
                            var isspace = c.IsSpaceCharacter();
                            var isclosed = c == Symbols.GreaterThan;
                            var isslash = c == Symbols.Solidus;
                            var hasLength = StringBuffer.Length - offset == length;

                            if (hasLength && (isspace || isclosed || isslash))
                            {
                                var name = StringBuffer.ToString(offset, length);

                                if (name.Isi(_lastStartTag))
                                {
                                    if (offset > 2)
                                    {
                                        Back(3 + length);
                                        StringBuffer.Remove(offset - 2, length + 2);
                                        return NewCharacter();
                                    }

                                    StringBuffer.Clear();

                                    if (isspace)
                                    {
                                        tag.Name = _lastStartTag;
                                        return ParseAttributes(tag);
                                    }
                                    else if (isslash)
                                    {
                                        tag.Name = _lastStartTag;
                                        return TagSelfClosing(tag);
                                    }
                                    else if (isclosed)
                                    {
                                        tag.Name = _lastStartTag;
                                        return EmitTag(tag);
                                    }
                                }
                            }
                        }

                        state = ScriptState.Normal;
                        break;
                    }

                    // See 8.2.4.22 Script data escaped state
                    case ScriptState.Escaped:
                    {
                        switch (c)
                        {
                            case Symbols.Minus:
                                StringBuffer.Append(Symbols.Minus);
                                c = GetNext();
                                state = ScriptState.EscapedDash;
                                continue;
                            case Symbols.LessThan:
                                c = GetNext();
                                state = ScriptState.EscapedOpenTag;
                                continue;
                            case Symbols.Null:
                                AppendReplacement();
                                break;
                            case Symbols.EndOfFile:
                                Back();
                                return NewCharacter();
                            default:
                                state = ScriptState.Normal;
                                continue;
                        }

                        c = GetNext();
                        break;
                    }

                    // See 8.2.4.23 Script data escaped dash state
                    case ScriptState.EscapedDash:
                    {
                        switch (c)
                        {
                            case Symbols.Minus:
                                StringBuffer.Append(Symbols.Minus);
                                state = ScriptState.EscapedDashDash;
                                continue;
                            case Symbols.LessThan:
                                c = GetNext();
                                state = ScriptState.EscapedOpenTag;
                                continue;
                            case Symbols.Null:
                                AppendReplacement();
                                break;
                            case Symbols.EndOfFile:
                                Back();
                                return NewCharacter();
                            default:
                                StringBuffer.Append(c);
                                break;
                        }

                        c = GetNext();
                        state = ScriptState.Escaped;
                        break;
                    }

                    // See 8.2.4.24 Script data escaped dash dash state
                    case ScriptState.EscapedDashDash:
                    {
                        c = GetNext();

                        switch (c)
                        {
                            case Symbols.Minus:
                                StringBuffer.Append(Symbols.Minus);
                                break;
                            case Symbols.LessThan:
                                c = GetNext();
                                state = ScriptState.EscapedOpenTag;
                                continue;
                            case Symbols.GreaterThan:
                                StringBuffer.Append(Symbols.GreaterThan);
                                c = GetNext();
                                state = ScriptState.Normal;
                                continue;
                            case Symbols.Null:
                                AppendReplacement();
                                c = GetNext();
                                state = ScriptState.Escaped;
                                continue;
                            case Symbols.EndOfFile:
                                return NewCharacter();
                            default:
                                StringBuffer.Append(c);
                                c = GetNext();
                                state = ScriptState.Escaped;
                                continue;
                        }

                        break;
                    }

                    // See 8.2.4.25 Script data escaped less-than sign state
                    case ScriptState.EscapedOpenTag:
                    {
                        if (c == Symbols.Solidus)
                        {
                            c = GetNext();
                            state = ScriptState.EscapedEndTag;
                        }
                        else if (c.IsLetter())
                        {
                            offset = StringBuffer.Append(Symbols.LessThan).Length;
                            StringBuffer.Append(c);
                            state = ScriptState.StartDoubleEscape;
                        }
                        else
                        {
                            StringBuffer.Append(Symbols.LessThan);
                            state = ScriptState.Escaped;
                        }

                        break;
                    }

                    // See 8.2.4.26 Script data escaped end tag open state
                    case ScriptState.EscapedEndTag:
                    {
                        offset = StringBuffer.Append(Symbols.LessThan).Append(Symbols.Solidus).Length;

                        if (c.IsLetter())
                        {
                            StringBuffer.Append(c);
                            state = ScriptState.EscapedNameEndTag;
                        }
                        else
                        {
                            state = ScriptState.Escaped;
                        }

                        break;
                    }

                    // See 8.2.4.27 Script data escaped end tag name state
                    case ScriptState.EscapedNameEndTag:
                    {
                        c = GetNext();
                        var hasLength = StringBuffer.Length - offset == scriptLength;

                        if (hasLength && (c == Symbols.Solidus || c == Symbols.GreaterThan || c.IsSpaceCharacter()) &&
                            StringBuffer.ToString(offset, scriptLength).Isi(TagNames.Script))
                        {
                            Back(scriptLength + 3);
                            StringBuffer.Remove(offset - 2, scriptLength + 2);
                            return NewCharacter();
                        }
                        else if (!c.IsLetter())
                        {
                            state = ScriptState.Escaped;
                        }
                        else
                        {
                            StringBuffer.Append(c);
                        }

                        break;
                    }

                    // See 8.2.4.28 Script data double escape start state
                    case ScriptState.StartDoubleEscape:
                    {
                        c = GetNext();
                        var hasLength = StringBuffer.Length - offset == scriptLength;

                        if (hasLength && (c == Symbols.Solidus || c == Symbols.GreaterThan || c.IsSpaceCharacter()))
                        {
                            var isscript = StringBuffer.ToString(offset, scriptLength).Isi(TagNames.Script);
                            StringBuffer.Append(c);
                            c = GetNext();
                            state = isscript ? ScriptState.EscapedDouble : ScriptState.Escaped;
                        }
                        else if (c.IsLetter())
                        {
                            StringBuffer.Append(c);
                        }
                        else
                        {
                            state = ScriptState.Escaped;
                        }

                        break;
                    }

                    // See 8.2.4.29 Script data double escaped state
                    case ScriptState.EscapedDouble:
                    {
                        switch (c)
                        {
                            case Symbols.Minus:
                                StringBuffer.Append(Symbols.Minus);
                                c = GetNext();
                                state = ScriptState.EscapedDoubleDash;
                                continue;

                            case Symbols.LessThan:
                                StringBuffer.Append(Symbols.LessThan);
                                c = GetNext();
                                state = ScriptState.EscapedDoubleOpenTag;
                                continue;

                            case Symbols.Null:
                                AppendReplacement();
                                break;

                            case Symbols.EndOfFile:
                                RaiseErrorOccurred(HtmlParseError.EOF);
                                Back();
                                return NewCharacter();
                        }

                        StringBuffer.Append(c);
                        c = GetNext();
                        break;
                    }

                    // See 8.2.4.30 Script data double escaped dash state
                    case ScriptState.EscapedDoubleDash:
                    {
                        switch (c)
                        {
                            case Symbols.Minus:
                                StringBuffer.Append(Symbols.Minus);
                                state = ScriptState.EscapedDoubleDashDash;
                                continue;

                            case Symbols.LessThan:
                                StringBuffer.Append(Symbols.LessThan);
                                c = GetNext();
                                state = ScriptState.EscapedDoubleOpenTag;
                                continue;

                            case Symbols.Null:
                                RaiseErrorOccurred(HtmlParseError.Null);
                                c = Symbols.Replacement;
                                break;

                            case Symbols.EndOfFile:
                                RaiseErrorOccurred(HtmlParseError.EOF);
                                Back();
                                return NewCharacter();
                        }

                        state = ScriptState.EscapedDouble;
                        break;
                    }

                    // See 8.2.4.31 Script data double escaped dash dash state
                    case ScriptState.EscapedDoubleDashDash:
                    {
                        c = GetNext();

                        switch (c)
                        {
                            case Symbols.Minus:
                                StringBuffer.Append(Symbols.Minus);
                                break;

                            case Symbols.LessThan:
                                StringBuffer.Append(Symbols.LessThan);
                                c = GetNext();
                                state = ScriptState.EscapedDoubleOpenTag;
                                continue;

                            case Symbols.GreaterThan:
                                StringBuffer.Append(Symbols.GreaterThan);
                                c = GetNext();
                                state = ScriptState.Normal;
                                continue;

                            case Symbols.Null:
                                AppendReplacement();
                                c = GetNext();
                                state = ScriptState.EscapedDouble;
                                continue;

                            case Symbols.EndOfFile:
                                RaiseErrorOccurred(HtmlParseError.EOF);
                                Back();
                                return NewCharacter();

                            default:
                                StringBuffer.Append(c);
                                c = GetNext();
                                state = ScriptState.EscapedDouble;
                                continue;
                        }

                        break;
                    }

                    // See 8.2.4.32 Script data double escaped less-than sign state
                    case ScriptState.EscapedDoubleOpenTag:
                    {
                        if (c == Symbols.Solidus)
                        {
                            offset = StringBuffer.Append(Symbols.Solidus).Length;
                            state = ScriptState.EndDoubleEscape;
                        }
                        else
                        {
                            state = ScriptState.EscapedDouble;
                        }

                        break;
                    }

                    // See 8.2.4.33 Script data double escape end state
                    case ScriptState.EndDoubleEscape:
                    {
                        c = GetNext();
                        var hasLength = StringBuffer.Length - offset == scriptLength;

                        if (hasLength && (c.IsSpaceCharacter() || c == Symbols.Solidus || c == Symbols.GreaterThan))
                        {
                            var isscript = StringBuffer.ToString(offset, scriptLength).Isi(TagNames.Script);
                            StringBuffer.Append(c);
                            c = GetNext();
                            state = isscript ? ScriptState.Escaped : ScriptState.EscapedDouble;
                        }
                        else if (c.IsLetter())
                        {
                            StringBuffer.Append(c);
                        }
                        else
                        {
                            state = ScriptState.EscapedDouble;
                        }

                        break;
                    }
                }
            }
        }
예제 #6
0
        /// <summary>
        /// See 8.2.4.28 Script data double escape start state
        /// </summary>
        /// <param name="c">The next input character.</param>
        HtmlToken ScriptDataStartDoubleEscape(Char c)
        {
            if (c.IsSpaceCharacter() || c == Specification.SOLIDUS || c == Specification.GT)
            {
                _buffer.Append(c);

                if (String.Compare(_stringBuffer.ToString(), Tags.SCRIPT, StringComparison.OrdinalIgnoreCase) == 0)
                    return ScriptDataEscapedDouble(_src.Next);

                return ScriptDataEscaped(_src.Next);
            }
            else if (c.IsLetter())
            {
                _stringBuffer.Append(c);
                _buffer.Append(c);
                return ScriptDataStartDoubleEscape(_src.Next);
            }

            return ScriptDataEscaped(c);
        }
예제 #7
0
 /// <summary>
 /// More http://www.w3.org/TR/REC-xml/#dt-etag.
 /// </summary>
 /// <param name="c">The next input character.</param>
 XmlToken TagEnd(Char c)
 {
     if (c.IsLetter())
     {
         _stringBuffer.Clear();
         _stringBuffer.Append(c);
         return TagName(_src.Next, XmlToken.CloseTag());
     }
     else if (c == Specification.EOF)
     {
         _src.Back();
         RaiseErrorOccurred(ErrorCode.EOF);
         return XmlToken.EOF;
     }
     else
     {
         RaiseErrorOccurred(ErrorCode.TagClosedWrong);
         return Data(_src.Next);
     }
 }
예제 #8
0
        /// <summary>
        /// See 8.2.4.25 Script data escaped less-than sign state
        /// </summary>
        /// <param name="c">The next input character.</param>
        HtmlToken ScriptDataEscapedLT(Char c)
        {
            if (c == Specification.SOLIDUS)
            {
                return ScriptDataEndTag(_src.Next);
            }
            else if (c.IsLetter())
            {
                _stringBuffer.Clear();
                _stringBuffer.Append(c);
                _buffer.Append(Specification.LT);
                _buffer.Append(c);
                return ScriptDataStartDoubleEscape(_src.Next);
            }

            _buffer.Append(Specification.LT);
            return ScriptDataEscaped(c);
        }
예제 #9
0
        /// <summary>
        /// See 8.2.4.19 Script data end tag name state
        /// </summary>
        /// <param name="c">The next input character.</param>
        /// <param name="tag">The current tag token.</param>
        /// <returns>The emitted token.</returns>
        HtmlToken ScriptDataNameEndTag(Char c, HtmlTagToken tag)
        {
            var name = _stringBuffer.ToString().ToLower();
            var appropriateEndTag = name == _lastStartTag;

            if (appropriateEndTag && c.IsSpaceCharacter())
            {
                tag.Name = name;
                return AttributeBeforeName(_src.Next, tag);
            }
            else if (appropriateEndTag && c == Specification.SOLIDUS)
            {
                tag.Name = name;
                return TagSelfClosing(_src.Next, tag);
            }
            else if (appropriateEndTag && c == Specification.GT)
            {
                tag.Name = name;
                return EmitTag(tag);
            }
            else if (c.IsLetter())
            {
                _stringBuffer.Append(c);
                return ScriptDataNameEndTag(_src.Next, tag);
            }

            _buffer.Append(Specification.LT).Append(Specification.SOLIDUS);
            _buffer.Append(_stringBuffer.ToString());
            return ScriptData(c);
        }
예제 #10
0
        /// <summary>
        /// See 8.2.4.26 Script data escaped end tag open state
        /// </summary>
        /// <param name="c">The next input character.</param>
        HtmlToken ScriptDataEscapedEndTag(Char c)
        {
            var offset = _stringBuffer.Append(Symbols.LessThan).Append(Symbols.Solidus).Length;

            if (c.IsLetter())
            {
                _stringBuffer.Append(c);
                return ScriptDataEscapedNameEndTag(NewTagClose(), offset);
            }
            else
            {
                return ScriptDataEscaped(c);
            }
        }
예제 #11
0
        /// <summary>
        /// More http://www.w3.org/TR/REC-xml/#NT-EncodingDecl.
        /// </summary>
        /// <param name="c">The next input character.</param>
        /// <param name="decl">The current declaration token.</param>
        XmlToken DeclarationEncodingBeforeValue(Char c, XmlDeclarationToken decl)
        {
            while (c.IsSpaceCharacter())
                c = _src.Next;

            if (c == Specification.DQ || c == Specification.SQ)
            {
                var q = c;
                _stringBuffer.Clear();
                c = _src.Next;

                if (c.IsLetter())
                    return DeclarationEncodingValue(c, q, decl);
            }

            throw Errors.Xml(ErrorCode.XmlDeclarationInvalid);
        }
예제 #12
0
        /// <summary>
        /// See 8.2.4.27 Script data escaped end tag name state
        /// </summary>
        /// <param name="c">The next input character.</param>
        /// <param name="tag">The current tag token.</param>
        /// <returns>The emitted token.</returns>
        HtmlToken ScriptDataEscapedNameTag(Char c, HtmlTagToken tag)
        {
            var name = _stringBuffer.ToString().ToLower();
            var appropriateEndTag = name == _lastStartTag;

            if (appropriateEndTag && c.IsSpaceCharacter())
            {
                tag.Name = name;
                return AttributeBeforeName(Next, tag);
            }
            else if (appropriateEndTag && c == Specification.Solidus)
            {
                tag.Name = name;
                return TagSelfClosing(Next, tag);
            }
            else if (appropriateEndTag && c == Specification.GreaterThan)
            {
                tag.Name = name;
                return EmitTag(tag);
            }
            else if (c.IsLetter())
            {
                _stringBuffer.Append(c);
                return ScriptDataEscapedNameTag(Next, tag);
            }

            _buffer.Append(Specification.LessThan).Append(Specification.Solidus);
            _buffer.Append(_stringBuffer.ToString());
            return ScriptDataEscaped(c);
        }
예제 #13
0
        /// <summary>
        /// See 8.2.4.17 Script data less-than sign state
        /// </summary>
        /// <param name="c">The next input character.</param>
        HtmlToken ScriptDataLt(Char c)
        {
            _stringBuffer.Append(Symbols.LessThan);

            if (c == Symbols.Solidus)
            {
                // See 8.2.4.18 Script data end tag open state
                c = GetNext();
                var offset = _stringBuffer.Append(Symbols.Solidus).Length;

                if (c.IsLetter())
                {
                    _stringBuffer.Append(c);
                    return ScriptDataNameEndTag(NewTagClose(), offset);
                }
            }
            else if (c == Symbols.ExclamationMark)
            {
                // See 8.2.4.20 Script data escape start state
                _stringBuffer.Append(Symbols.ExclamationMark);
                c = GetNext();

                if (c == Symbols.Minus)
                    return ScriptDataEscapeDashLt(GetNext());
            }

            return ScriptData(c);
        }
예제 #14
0
        /// <summary>
        /// See 8.2.4.25 Script data escaped less-than sign state
        /// </summary>
        /// <param name="c">The next input character.</param>
        HtmlToken ScriptDataEscapedLT(Char c)
        {
            if (c == Specification.Solidus)
            {
                return ScriptDataEndTag(Next);
            }
            else if (c.IsLetter())
            {
                _stringBuffer.Clear();
                _stringBuffer.Append(c);
                _buffer.Append(Specification.LessThan);
                _buffer.Append(c);
                return ScriptDataStartDoubleEscape(Next);
            }

            _buffer.Append(Specification.LessThan);
            return ScriptDataEscaped(c);
        }
예제 #15
0
        /// <summary>
        /// See 8.2.4.26 Script data escaped end tag open state
        /// </summary>
        /// <param name="c">The next input character.</param>
        /// <param name="tag">The current tag token.</param>
        /// <returns>The emitted token.</returns>
        HtmlToken ScriptDataEscapedEndTag(Char c, HtmlTagToken tag)
        {
            if (c.IsLetter())
            {
                _stringBuffer.Clear();
                _stringBuffer.Append(c);
                return ScriptDataEscapedEndTag(Next, tag);
            }

            _buffer.Append(Specification.LessThan).Append(Specification.Solidus);
            return ScriptDataEscaped(c);
        }
예제 #16
0
        /// <summary>
        /// See 8.2.4.18 Script data end tag open state
        /// </summary>
        /// <param name="c">The next input character.</param>
        HtmlToken ScriptDataEndTag(Char c)
        {
            if (c.IsLetter())
            {
                _stringBuffer.Clear();
                _stringBuffer.Append(c);
                return ScriptDataNameEndTag(Next, HtmlToken.CloseTag());
            }

            _buffer.Append(Specification.LessThan).Append(Specification.Solidus);
            return ScriptData(c);
        }
예제 #17
0
        /// <summary>
        /// See 8.2.4.33 Script data double escape end state
        /// </summary>
        /// <param name="c">The next input character.</param>
        HtmlToken ScriptDataEndDoubleEscape(Char c)
        {
            if (c.IsSpaceCharacter() || c == Specification.Solidus || c == Specification.GreaterThan)
            {
                _buffer.Append(c);

                if (String.Compare(_stringBuffer.ToString(), Tags.Script, StringComparison.OrdinalIgnoreCase) == 0)
                    return ScriptDataEscaped(Next);

                return ScriptDataEscapedDouble(Next);
            }
            else if (c.IsLetter())
            {
                _stringBuffer.Append(c);
                _buffer.Append(c);
                return ScriptDataEndDoubleEscape(Next);
            }

            return ScriptDataEscapedDouble(c);
        }
예제 #18
0
        /// <summary>
        /// More http://www.w3.org/TR/REC-xml/#sec-starttags.
        /// </summary>
        /// <param name="c">The next input character.</param>
        XmlToken TagOpen(Char c)
        {
            if (c == Specification.EM)
            {
                return MarkupDeclaration(_src.Next);
            }
            else if (c == Specification.QM)
            {
                c = _src.Next;

                if (_src.ContinuesWith("xml", false))
                {
                    _src.Advance(2);
                    return DeclarationStart(_src.Next);
                }

                return ProcessingStart(c);
            }
            else if (c == Specification.SOLIDUS)
            {
                return TagEnd(_src.Next);
            }
            else if (c.IsLetter())
            {
                _stringBuffer.Clear();
                _stringBuffer.Append(c);
                return TagName(_src.Next, XmlToken.OpenTag());
            }
            else
            {
                RaiseErrorOccurred(ErrorCode.AmbiguousOpenTag);
                return XmlToken.Character(Specification.LT);
            }
        }
예제 #19
0
        /// <summary>
        /// See 8.2.4.25 Script data escaped less-than sign state
        /// </summary>
        /// <param name="c">The next input character.</param>
        HtmlToken ScriptDataEscapedLT(Char c)
        {
            if (c == Symbols.Solidus)
                return ScriptDataEscapedEndTag(GetNext());

            if (c.IsLetter())
            {
                var offset = _stringBuffer.Append(Symbols.LessThan).Length;
                _stringBuffer.Append(c);
                return ScriptDataStartDoubleEscape(offset);
            }
            else
            {
                _stringBuffer.Append(Symbols.LessThan);
                return ScriptDataEscaped(c);
            }
        }
예제 #20
0
        /// <summary>
        /// See 8.2.4.18 Script data end tag open state
        /// </summary>
        /// <param name="c">The next input character.</param>
        HtmlToken ScriptDataEndTag(Char c)
        {
            if (c.IsLetter())
            {
                _stringBuffer.Clear();
                _stringBuffer.Append(c);
                return ScriptDataNameEndTag(_src.Next, HtmlToken.CloseTag());
            }

            _buffer.Append(Specification.LT).Append(Specification.SOLIDUS);
            return ScriptData(c);
        }
예제 #21
0
        /// <summary>
        /// More http://www.w3.org/TR/REC-xml/#NT-EncodingDecl.
        /// </summary>
        /// <param name="c">The next input character.</param>
        /// <param name="decl">The current declaration token.</param>
        XmlToken DeclarationEncodingBeforeValue(Char c, XmlDeclarationToken decl)
        {
            while (c.IsSpaceCharacter())
                c = GetNext();

            if (c == Symbols.DoubleQuote || c == Symbols.SingleQuote)
            {
                var q = c;
                c = GetNext();

                if (c.IsLetter())
                    return DeclarationEncodingValue(c, q, decl);
            }

            throw XmlParseError.XmlDeclarationInvalid.At(GetCurrentPosition());
        }
예제 #22
0
        /// <summary>
        /// See 8.2.4.26 Script data escaped end tag open state
        /// </summary>
        /// <param name="c">The next input character.</param>
        /// <param name="tag">The current tag token.</param>
        /// <returns>The emitted token.</returns>
        HtmlToken ScriptDataEscapedEndTag(Char c, HtmlTagToken tag)
        {
            if (c.IsLetter())
            {
                _stringBuffer.Clear();
                _stringBuffer.Append(c);
                return ScriptDataEscapedEndTag(_src.Next, tag);
            }

            _buffer.Append(Specification.LT).Append(Specification.SOLIDUS);
            return ScriptDataEscaped(c);
        }