Example #1
0
 public void SkipWhiteSpace()
 {
     while (LexUtils.IsWhitespace(_currChar))
     {
         NextChar();
     }
 }
Example #2
0
        private string ParseName()
        {
            int start = _ptrIndex - 1;
            int len   = 0;

            while (LexUtils.IsNCNameChar(_currChar))
            {
                NextChar(); len++;
            }
            return(_ptr.Substring(start, len));
        }
Example #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(Properties.Resources.CircumflexCharMustBeEscaped);
                }
                break;

            default:
                if (Char.IsDigit(_currChar))
                {
                    _kind = LexKind.Number;
                    int start = _ptrIndex - 1;
                    int len   = 0;
                    while (Char.IsDigit(_currChar))
                    {
                        NextChar(); len++;
                    }
                    _number = XmlConvert.ToInt32(_ptr.Substring(start, len));
                    break;
                }
                else 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, Properties.Resources.InvalidNameToken, _prefix, _currChar));
                        }
                    }
                    _canBeSchemaName = _currChar == '(';
                    break;
                }
                else if (LexUtils.IsWhitespace(_currChar))
                {
                    _kind = LexKind.Space;
                    while (LexUtils.IsWhitespace(_currChar))
                    {
                        NextChar();
                    }
                    break;
                }
                else
                {
                    _kind = LexKind.EscapedData;
                    break;
                }
            }
            return(true);
        }