[ragel-users] Re: ruby code generation question

Chuck Remes cremes.devl... at mac.com
Thu Oct 4 16:33:11 UTC 2007


On Oct 4, 2007, at 10:36 AM, Victor Hugo Borja wrote:

>
> Chuck,
>
>> Looking at the ruby code I see that orcscanner_start is defined  
>> like so:
>>
>> class << self
>>          attr_accessor :orcscanner_start
>> end
>> self.orcscanner_start = 1;
>>
>> This is adding a class method #orcscanner_start to the current class
>> (self). I guess it works fine when adding to Object (the default
>> class) but not my custom class. Why? What am I doing wrong?
>
> According to what I understand from your code, the ragel constants are
> being added to
> your SomeClass' metaclass. You may need to add something like:
>
> class SomeClass
>   def initialize
>     %% write data;
>   end
>
>   # your parse/utility methods here
>   ...
> end

Does it really matter where '%% write data' appears in the class? I  
currently have that code on its own line outside of any method but  
still inside the class definition.

BTW, I just tried it and it worked! I realize this is probably a ruby- 
specific question, but why did it work when I moved that line to the  
class initializer but nowhere else?



More information about the ragel-users mailing list