buff = ["a","b","a"] rule = token(/\w/)/:x - token("b") - backref(:x) >> proc{|x| x} assert_equal(["a","b","a"], rule.parse(buff))より文法っぽく書くとこんな感じ。
parser = TDParser.define{|g| g.char = /\w/ g.word = g.char/:x - g.char - backref(:x) >> proc{|x| x} } parser.parse(buff)