コード例 #1
0
 public void SkipWhiteSpace()
 {
     while (LexUtils.IsWhitespace(_currChar))
     {
         NextChar();
     }
 }
コード例 #2
0
        private string ParseName()
        {
            var start = _ptrIndex - 1;
            var len   = 0;

            while (LexUtils.IsNcNameChar(_currChar))
            {
                NextChar();
                len++;
            }
            return(_ptr.Substring(start, len));
        }
コード例 #3
0
        public bool NextLexeme()
        {
            switch (_currChar)
            {
            case '\0':
                _kind = LexKind.Eof;
                return(false);

            case '(':
            case ')':
            case '=':
            case '/':
                _kind = (LexKind)Convert.ToInt32(_currChar);
                NextChar();
                break;

            case '^':
                NextChar();
                if (_currChar == '^' || _currChar == '(' || _currChar == ')')
                {
                    _kind = LexKind.EscapedData;
                    NextChar();
                }
                else
                {
                    throw new XPointerSyntaxException(Resources.CircumflexCharMustBeEscaped);
                }
                break;

            default:
                if (Char.IsDigit(_currChar))
                {
                    _kind = LexKind.Number;
                    var start = _ptrIndex - 1;
                    var len   = 0;
                    while (Char.IsDigit(_currChar))
                    {
                        NextChar();
                        len++;
                    }
                    Number = XmlConvert.ToInt32(_ptr.Substring(start, len));
                    break;
                }
                if (LexUtils.IsStartNameChar(_currChar))
                {
                    _kind  = LexKind.NcName;
                    Prefix = String.Empty;
                    NcName = ParseName();
                    if (_currChar == ':')
                    {
                        //QName?
                        NextChar();
                        Prefix = NcName;
                        _kind  = LexKind.QName;
                        if (LexUtils.IsStartNcNameChar(_currChar))
                        {
                            NcName = ParseName();
                        }
                        else
                        {
                            throw new XPointerSyntaxException(String.Format(CultureInfo.CurrentCulture, Resources.InvalidNameToken, Prefix, _currChar));
                        }
                    }
                    CanBeSchemaName = _currChar == '(';
                    break;
                }
                if (LexUtils.IsWhitespace(_currChar))
                {
                    _kind = LexKind.Space;
                    while (LexUtils.IsWhitespace(_currChar))
                    {
                        NextChar();
                    }
                    break;
                }
                _kind = LexKind.EscapedData;
                break;
            }
            return(true);
        }