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.
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.
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.