public void Expect(char expected) { var found = GetNext(); if (found != expected) { throw ParsingException.UnexpectedCharacter(expected, found, GetLocation()); } }
public SqlToken ParseNext() { var c = _chars.Peek(); if (c == '\0') { return(SqlToken.EndOfInput()); } if (char.IsWhiteSpace(c)) { return(ReadWhitespace()); } if (char.IsNumber(c)) { return(ReadNumber()); } if (char.IsLetter(c) || c == '_') { return(ReadWord()); } if (c == '$' || c == '#') { return(ReadSpecialIdentifier()); } if (c == '@') { return(ReadVariableName()); } if (c == '\'') { return(ReadQuoted()); } if (c == '[') { return(ReadQuotedIdentifier()); } if (c == '-') { _chars.GetNext(); if (_chars.Peek() == '-') { return(ReadSingleLineComment()); } _chars.PutBack(c); // Fall through, in case we're using '-' for some other purpose } if (c == '/') { _chars.GetNext(); if (_chars.Peek() == '*') { return(ReadMultilineComment()); } _chars.PutBack(c); // Fall through, in case we're using '/' for some other purpose } if (char.IsPunctuation(c) || char.IsSymbol(c)) { return(ReadOperator()); } throw ParsingException.UnexpectedCharacter(c, _chars.GetLocation()); }