Ejemplo n.º 1
0
static traceback *getStatePrefix( a_state *s, a_state *initial_parent )
{
    traceback       *list;
    a_parent        *parent;
    a_state         *min;
    a_state         *min_check;
    a_shift_action  *t;

    list = NULL;
    for( ;; ) {
        parent = s->parents;
        if( parent == NULL ) break;
        if( initial_parent != NULL ) {
            min = initial_parent;
            initial_parent = NULL;
        } else {
            min = parent->state;
            for( parent = parent->next; parent != NULL; parent = parent->next ) {
                min_check = parent->state;
                if( min_check->sidx < min->sidx ) {
                    min = min_check;
                }
            }
        }
        for( t = min->trans; t->sym != NULL; ++t ) {
            if( t->state == s ) {
                pushTrace( &list, s, t->sym );
            }
        }
        s = min;
    }
    pushTrace( &list, s, NULL );
    return( list );
}
Ejemplo n.º 2
0
static void performShift( traceback **h, a_sym *sym )
{
    a_state     *state;

    state = findNewShiftState( (*h)->state, sym );
    pushTrace( h, state, sym );
}
Ejemplo n.º 3
0
static traceback *makeReversedCopy( traceback *top )
{
    traceback   *parse_stack;
    traceback   *curr;

    parse_stack = NULL;
    for( curr = top; curr != NULL; curr = curr->next ) {
        pushTrace( &parse_stack, curr->state, curr->sym );
    }
    return( parse_stack );
}
Ejemplo n.º 4
0
    bool Environment::eval(const char *string) {
        pushTrace();
        int error = luaL_loadstring(L, string) || lua_pcall(L, 0, 0, 1);
        remove(1);
        if (error) {

            const char *errmsg = to(-1, wrapType<const char *>());

            conoutf(CON_ERROR, "Could not execute string: %s", errmsg);

            pop(1);
            return false;
        }
        return false;
    }
Ejemplo n.º 5
0
int label1()
{
DWORD r, rr, s;
   // I like to give this guy some more priority or power to overide some constraints
   // namely It is worth try to find label blocks.... I guess
   r=label_start_pos+4;s=r;
   while (isLabelCheckable(r))
   {
       rr=(DWORD)getIntFile(r);
       if (!isGoodAddress(rr)) return 1;
       i_col=4;
       pushTrace(305);
       if (nextMode>0) EnterLabel(166, rr, r); 
       popTrace();
       r+=4;
   }
   return 1;
}
Ejemplo n.º 6
0
    bool Environment::run(const char *file) {
#ifdef EXCEPTIONS_ENABLED
        lua_pushlightuserdata(L, (void *) wrap_exceptions);
        luaJIT_setmode(L, -1, LUAJIT_MODE_WRAPCFUNC | LUAJIT_MODE_ON);
        pop(1);
#endif

        pushTrace();
        int error = luaL_loadfile(L, findfile(file, "r")) || lua_pcall(L, 0, 0, 1);
        remove(1);

        if (error) {

            const char *errmsg = to(-1, wrapType<const char *>());

            conoutf(CON_ERROR, "Could not execute file (%s):\n%s", file, errmsg);
            pop(1);

            return false;
        }

        return true;
    }
Ejemplo n.º 7
0
static void doRunUntilShift( traceback **h, a_sym *sym, traceback **ht, unsigned count )
{
    index_t             sidx;
    a_sym               *chk_sym;
    a_state             *state;
    a_state             *top;
    a_reduce_action     *raction;

    for( ;; ) {
        if( *h == NULL ) break;
        top = (*h)->state;
        if( top == NULL ) {
            flushStack( h );
            break;
        }
        state = findNewShiftState( top, sym );
        if( state != NULL ) {
            pushTrace( h, state, sym );
            pushTrace( ht, NULL, sym );
            if( sym == eofsym ) {
                break;
            }
            for( ;; ) {
                if( *h == NULL ) break;
                top = (*h)->state;
                if( top->redun->pro == NULL ) break;
                performReduce( h, top->redun->pro );
            }
            break;
        }
        sidx = sym->idx;
        for( raction = top->redun; raction->pro != NULL; ++raction ) {
            if( IsBitSet( raction->follow, sidx ) ) {
                performReduce( h, raction->pro );
                break;
            }
        }
        if( raction->pro == NULL ) {
            if( sym != eofsym ) {
                /* a syntax error will result */
                flushStack( h );
                break;
            }
            if( top->redun->pro != NULL ) {
                performReduce( h, top->redun->pro );
            } else {
                if( count ) {
                    --count;
                    chk_sym = findNewShiftSym( top, ht );
                } else {
                    chk_sym = NULL;
                }
                if( chk_sym != NULL ) {
                    doRunUntilShift( h, chk_sym, ht, count );
                } else {
                    /* a syntax error will result */
                    flushStack( h );
                    break;
                }
            }
        }
    }
}