示例#1
0
        /// <summary>
        /// Get the next Token
        /// </summary>
        public Token GetNextToken()
        {
            Token matchedToken;
            int   curPos = 0;

            //EOFLoop :
            for (;;)
            {
start_EOF_loop:
                {
                }
                try
                {
                    CurChar = InputStream.BeginToken();
                }
                catch (IOException e)
                {
                    jjmatchedKind = 0;
                    jjmatchedPos  = -1;
                    matchedToken  = JjFillToken();
                    return(matchedToken);
                }

                try
                {
                    InputStream.Backup(0);
                    while (CurChar <= 32 && (0x100002000L & (1L << CurChar)) != 0L)
                    {
                        CurChar = InputStream.BeginToken();
                    }
                }
                catch (IOException e1)
                {
                    //continue EOFLoop;
                    goto start_EOF_loop;
                }
                jjmatchedKind = 0x7fffffff;
                jjmatchedPos  = 0;
                curPos        = JjMoveStringLiteralDfa0_0();
                if (jjmatchedKind != 0x7fffffff)
                {
                    if (jjmatchedPos + 1 < curPos)
                    {
                        InputStream.Backup(curPos - jjmatchedPos - 1);
                    }
                    //if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
                    if ((JjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind % 64))) != 0L)
                    {
                        matchedToken = JjFillToken();
                        return(matchedToken);
                    }
                    else
                    {
                        //continue EOFLoop;
                        goto start_EOF_loop;
                    }
                }
                int    error_line   = InputStream.GetEndLine();
                int    error_column = InputStream.GetEndColumn();
                string error_after  = null;
                bool   EOFSeen      = false;
                try
                {
                    InputStream.ReadChar();
                    InputStream.Backup(1);
                }
                catch (IOException e1)
                {
                    EOFSeen     = true;
                    error_after = curPos <= 1 ? "" : InputStream.GetImage();
                    if (CurChar == '\n' || CurChar == '\r')
                    {
                        error_line++;
                        error_column = 0;
                    }
                    else
                    {
                        error_column++;
                    }
                }
                if (!EOFSeen)
                {
                    InputStream.Backup(1);
                    error_after = curPos <= 1 ? "" : InputStream.GetImage();
                }
                throw new TokenMgrException(EOFSeen, curLexState, error_line, error_column, error_after, CurChar,
                                            TokenMgrException.LexError);
            }
        }