I have this parser:
class Parser
%%{
machine test_lexer;
action s { s = p; puts "s#{p}" }
action e { e = p; puts "e#{p}" }
action captured {
puts "captured #{s} #{e}"
}
key_value = "a" %s ("b" | "x" "c")+ %e %captured;
tags = ("x"+)? key_value;
main := tags*;
}%%
def initialize(data)
data = data
eof = data.length
%% write data;
%% write init;
%% write exec;
end
end
Parser.new(ARGV.first)
And I hit it with abxc then why does it call the captured twice / the e twice, and how can I prevent this ?
ragel -R simple.rl && ruby simple.rb "abxc"
s1
e2
captured 1 2
e4
captured 1 4
on github: https://github.com/grosser/ragel_example