[ragel-users] Re: Ruby and Java code generation

Erich Ocean er... at atlasocean.com
Fri Sep 28 22:29:14 UTC 2007


Duff's device can be used with Java, so you might be able to use that  
technique to jump back into the middle of the processing loop.

See http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html for  
an example.

Best, Erich

On Sep 28, 2007, at 3:23 PM, Adrian Thurston wrote:

> Hi,
> What is now needed in Ruby and Java code is a jump back into the
> processing loop just like that found at rlgen-cd/tabcodegen.cpp:1041.
> -Adrian
> Adrian Thurston wrote:
>> Before loop breaks and variables were used in Ruby code call/cc  
>> features
>> were used. This was found to be very slow (about 10 times slower than
>> the current). Do you think throw/catch would be any better than  
>> call/cc?
>> Later today I'm going to commit my work on the C version. I'll  
>> highlight
>> the part that is troublesome and maybe someone that knows Java and  
>> Ruby
>> well can suggest something.
>> Adrian
>> Ryan King wrote:
>>> On Sep 28, 2007, at 12:02 PM, Adrian Thurston wrote:
>>>> Hi,
>>>> I'm having some trouble with Ruby and Java code generation as I
>>>> implement 6.0 features. The main problem with targeting both of  
>>>> these
>>>> languages is the lack of goto statement. This is problematic  
>>>> even for
>>>> the table-driven machine. There are a number of places in the  
>>>> driver
>>>> where a jump in or jump out of the processing loop is required.  
>>>> So far
>>>> I've gotten away with using named loops in Java and control flow
>>>> variables in Ruby, however with the latest changes things are  
>>>> getting
>>>> really ugly. I don't have a solution yet. I'm not sure what to do
>>>> right
>>>> now, so for the time being I will continue ahead with the 6.0  
>>>> features
>>>> and stall work on Ruby and Java code generation.
>>> You can emulate GOTO-ish behavior in ruby with throw and catch:
>>> catch(:foo) do
>>>   ...
>>>   throw(:foo)
>>>   ...
>>> end
>>> There are limits to how the code can be structured in these cases  
>>> (in
>>> blocks).
>>> -ryan
>>> >>>

More information about the ragel-users mailing list