簡単な例。empty

#!/usr/bin/env ruby

require 'tdp'

include TDParser

parser = TDParser.define {|g|
  g.input = ((token("a") - token("b") - token("c")) | empty()) >> proc {|x| [x[0], x[1], x[2]] }

  def parse(str)
    tokens = str.split(/\s+/)
    input.parse(tokens)
  end
}

p parser.parse("a b c")
p parser.parse("")

で、

["a", "b", "c"]
[nil, nil, nil]
((token("a") - token("b") - token("c")) | empty())

(empty() | (token("a") - token("b") - token("c")))

としたら以下のようになってしまった

[nil, nil, nil]
[nil, nil, nil]