Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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;
            }
        }
Exemplo n.º 4
0
 protected bool IsKeyword(string keyword)
 {
     return((Current == TokenType.IdentOrKeyword || Current == TokenType.Reserved) &&
            CurrentData.ToUpper() == keyword.ToUpper());
 }