ragel and ruby

  • Thread starter Philipp Hofmann
  • Start date
P

Philipp Hofmann

Hi,

I've been trying to generate ruby with ragel. But the generated code
is complaing about undefined local variables

Here an excerpt of the generated code:

class MyParser

# more generated code here ...

class << self
attr_accessor :mymachine_start
end

# and here ...

def parse(input)

# ...

begin
cs = mymachine_start
end

# ...

end

end

If I prepend 'type.', which is deprecated, I know, it works for this
case. But there are other accessor that are being set private, e. g.

attr_accessor :_mymachine_trans_actions_wi
private :_mymachine_trans_actions_wi, :_mymachine_trans_actions_wi=

How is this mean to work?

And why isn't an accessor set at class level not accessible from within
an instance of this class in the first place?

g phil
 
J

Judson Lester

This is sort of unconsidered, but it might help. In order to get
Ragel to work for me, I needed to add the following to the code
definition template:


%%{
write init;
}%%
mark = nil
data = io.read
p = 0
pe = data.length
stack = []
top = 0
%%write exec;


If I recall correctly, there's a way to go the other way: to have
Ragel generate different code for getting the next character, but it's
been a little while and I don't remember what it is.
 
P

Philipp Hofmann

thanks for your answer, but i had that already. but for reference i
figured it out: maybe i overread that somewhere, but the generated
ruby class isn't meant to be instanciated. calling MyParser.parse
without instanciation works.

nevertheless the question remains why an accessor set at class level
isn't accessible from an instance of the same class.

g phil



This is sort of unconsidered, but it might help. In order to get
Ragel to work for me, I needed to add the following to the code
definition template:


%%{
write init;
}%%
mark = nil
data = io.read
p = 0
pe = data.length
stack = []
top = 0
%%write exec;


If I recall correctly, there's a way to go the other way: to have
Ragel generate different code for getting the next character, but it's
been a little while and I don't remember what it is.



Hi,

I've been trying to generate ruby with ragel. But the generated code
is complaing about undefined local variables

Here an excerpt of the generated code:

class MyParser

# more generated code here ...

class << self
attr_accessor :mymachine_start
end

# and here ...

def parse(input)

# ...

begin
cs = mymachine_start
end

# ...

end

end

If I prepend 'type.', which is deprecated, I know, it works for this
case. But there are other accessor that are being set private, e. g.

attr_accessor :_mymachine_trans_actions_wi
private :_mymachine_trans_actions_wi, :_mymachine_trans_actions_wi=

How is this mean to work?

And why isn't an accessor set at class level not accessible from within
an instance of this class in the first place?

g phil
 
J

Judson Lester

nevertheless the question remains why an accessor set at class level
isn't accessible from an instance of the same class.

Well, that's because it's a class method. You can reach it as
"self.class.accessor."

Judson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,150
Latest member
MakersCBDReviews
Top