int Scan()

in Pixie/SqlScanner.cs [1994:2269]


        int Scan()
        {
                for (; ; )
                {
                    int next;              // next state to enter                   
#if BACKUP
                    Result rslt = Result.noMatch;
#endif // BACKUP
#if LEFTANCHORS
                    for (;;)
                    {
                        // Discard characters that do not start any pattern.
                        // Must check the left anchor condition after *every* GetChr!
                        state = (lineStartNum == cNum ? anchorState[currentScOrd] : currentStart);
                        if ((next = NextState()) != goStart) 
                            break; // LOOP EXIT HERE...
                        GetChr();
                    }
                    
#else // !LEFTANCHORS
                    state = currentStart;
                    while ((next = NextState()) == goStart)
                        // At this point, the current character has no
                        // transition from the current state.  We discard 
                        // the "no-match" char.   In traditional LEX such 
                        // characters are echoed to the console.
                        GetChr();
#endif // LEFTANCHORS                    
                    // At last, a valid transition ...    
                    MarkToken();
                    state = next;
                    GetChr();
                    
                    while ((next = NextState()) > eofNum) // Exit for goStart AND for eofNum
#if BACKUP
                        if (state <= maxAccept && next > maxAccept) // need to prepare backup data
                        {
                            // ctx is an object. The fields may be 
                            // mutated by the call to Recurse2.
                            // On return the data in ctx is the
                            // *latest* accept state that was found.
                            Context ctx = new Context();
                            rslt = Recurse2(ctx, next);
                            if (rslt == Result.noMatch) 
                                RestoreStateAndPos(ctx);
                            break;
                        }
                        else
#endif // BACKUP
                        {
                            state = next;
                            GetChr();
                        }
                    if (state <= maxAccept) 
                    {
                        MarkEnd();
#region ActionSwitch
#pragma warning disable 162
    switch (state)
    {
        case eofNum:
            if (yywrap())
                return (int)Tokens.EOF;
            break;
        case 1:
        case 2:
        case 3:
return yytext[0];
            break;
        case 4:
yylval.intValue = Int64.Parse(yytext); return (int)Tokens.INTEGER;
            break;
        case 5:
        case 6:
        case 7:
        case 8:
        case 9:
        case 10:
        case 11:
        case 12:
        case 13:
        case 14:
        case 15:
        case 16:
        case 17:
        case 18:
        case 19:
        case 20:
        case 21:
        case 23:
        case 24:
        case 26:
        case 27:
        case 28:
        case 29:
        case 30:
        case 31:
        case 32:
        case 33:
        case 34:
        case 36:
        case 38:
        case 39:
        case 41:
        case 42:
        case 43:
        case 44:
        case 46:
        case 47:
        case 48:
        case 49:
        case 50:
        case 51:
        case 53:
        case 54:
        case 55:
        case 56:
        case 57:
        case 58:
        case 59:
        case 61:
        case 62:
        case 63:
        case 64:
        case 66:
        case 67:
        case 69:
        case 70:
        case 71:
        case 73:
        case 75:
        case 76:
        case 78:
        case 79:
        case 81:
        case 83:
        case 84:
        case 86:
        case 88:
        case 89:
        case 90:
        case 91:
        case 92:
        case 94:
        case 95:
        case 96:
        case 97:
        case 98:
        case 99:
        case 101:
        case 102:
        case 103:
        case 105:
        case 106:
        case 107:
        case 108:
        case 109:
        case 111:
        case 112:
        case 113:
        case 115:
        case 116:
        case 117:
        case 118:
        case 119:
        case 121:
        case 123:
        case 124:
        case 126:
        case 127:
        case 128:
        case 130:
        case 131:
        case 133:
        case 134:
        case 135:
        case 136:
yylval.name = yytext; return (int)Tokens.NAME;
            break;
        case 22:
return (int)Tokens.VALUES;
            break;
        case 25:
return (int)Tokens.TO;
            break;
        case 35:
return (int)Tokens.TRANSACTION;
            break;
        case 37:
return (int)Tokens.TEXT;
            break;
        case 40:
return (int)Tokens.TABLE;
            break;
        case 45:
return (int)Tokens.SHORT;
            break;
        case 52:
return (int)Tokens.SAVEPOINT;
            break;
        case 60:
return (int)Tokens.ROLLBACK;
            break;
        case 65:
return (int)Tokens.RELEASE;
            break;
        case 68:
return (int)Tokens.LONG;
            break;
        case 72:
        case 77:
return (int)Tokens.INT;
            break;
        case 74:
return (int)Tokens.INTO;
            break;
        case 80:
return (int)Tokens.INSERT;
            break;
        case 82:
return (int)Tokens.INDEX;
            break;
        case 85:
return (int)Tokens.GUID;
            break;
        case 87:
return (int)Tokens.END;
            break;
        case 93:
return (int)Tokens.DETACH;
            break;
        case 100:
return (int)Tokens.DATETIME;
            break;
        case 104:
return (int)Tokens.DATABASE;
            break;
        case 110:
return (int)Tokens.CREATE;
            break;
        case 114:
return (int)Tokens.COMMIT;
            break;
        case 120:
return (int)Tokens.BYTE;
            break;
        case 122:
        case 125:
return (int)Tokens.BOOL;
            break;
        case 129:
return (int)Tokens.BINARY;
            break;
        case 132:
return (int)Tokens.BEGIN;
            break;
        case 137:
return (int)Tokens.ATTACH;
            break;
        case 138:
yylval.realValue = Double.Parse(yytext); return (int)Tokens.REAL_NUMBER;
            break;
        case 139:
; /* SQL Comment */
            break;
        case 140:
yylval.stringValue = yytext.Substring(1,yytext.Length-2); return (int)Tokens.STRING;
            break;
        default:
            break;
    }
#pragma warning restore 162
#endregion
                    }
                }
        }