protected SymbolPosition SkipKeyword(string keyword, bool mandatory) { if (Current != TokenType.IdentOrKeyword && CurrentData.ToUpper() != keyword.ToUpper()) { if (!mandatory) { return(null); } throw CreateParseError("DAE-00253 " + keyword + " expected"); } SymbolPosition res = CurrentOriginal; NextToken(); return(res); }
private SymbolPosition[] TestOperator(OperatorDef op) { int steps = 0; List <SymbolPosition> res = new List <SymbolPosition>(); while (steps < op.Tokens.Length && op.AcceptTokenType(Current) && CurrentData.ToUpper() == op.Tokens[steps].ToUpper()) { res.Add(CurrentOriginal); steps++; NextToken(); } if (op.Tokens.Length == steps) { return(res.ToArray()); } GoBack(steps); return(null); }
protected void ParseIdentOrKeyword(string prefix, TokenType token, bool testReserved) { StringBuilder sb = new StringBuilder(prefix); while (Char.IsLetterOrDigit(CurrentCh) || CurrentCh == '_') { sb.Append(CurrentCh); GoToNextChar(); } CurrentData = sb.ToString(); if (testReserved && m_reservedWords.Contains(CurrentData.ToUpper())) { Current = TokenType.Reserved; } else { Current = token; } }
protected bool IsKeyword(string keyword) { return((Current == TokenType.IdentOrKeyword || Current == TokenType.Reserved) && CurrentData.ToUpper() == keyword.ToUpper()); }