require 'test/unit' require 'rockit/dparser' class ATestAnyOperator < Test::Unit::TestCase AnyTestGrammar = Rockit::DParser::Grammar.new do start :S, [["a", any("b", "c"), any(:D, :E), ast(:S, 0, 1, 2)]] ("d".."e").map {|s| term(s.upcase.intern, s)} end Parser = AnyTestGrammar.new_parser def test_01 ast = Parser.parse "abd" assert_equal("a", ast[0]) assert_equal("b", ast[1]) assert_equal("d", ast[2]) ast = Parser.parse "abe" assert_equal("a", ast[0]) assert_equal("b", ast[1]) assert_equal("e", ast[2]) ast = Parser.parse "acd" assert_equal("a", ast[0]) assert_equal("c", ast[1]) assert_equal("d", ast[2]) ast = Parser.parse "ace" assert_equal("a", ast[0]) assert_equal("c", ast[1]) assert_equal("e", ast[2]) end end