Re: re:find_replace_callback() -- example fails

new topic     » goto parent     » topic index » view thread      » older message » newer message
ne1uno said...
_tom said...

Example 1 in the documentation for find_replace_callback() is not working.

A cut and paste copy of the example produces an error...

it does work translated. it also crashes using previous interpreters back to 3155 and probably beyond.

I tested with 3023 and still got a crash.

I just tried it with 3414 and eu.ex, and got the error "Unknown opcode" in line 9.

I suspect we have a fencepost error somewhere in the math that deals with switches for sequences. Changing the following function in execute.e fixes eu.ex and allows the demo to run correctly:

procedure opSWITCH() 
-- pc+1: switch value 
-- pc+2: case values 
-- pc+3: jump_table 
-- pc+4: else jump 
        a = find( val[Code[pc+1]], val[Code[pc+2]] ) 
        if a then 
                pc += val[Code[pc+3]][a] 
                if Code[pc] > MAX_OPCODE then 
                        pc -= 1 
                end if 
        else 
                pc = Code[pc + 4] 
        end if 
end procedure 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu