1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
lib = File.expand_path('../../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'test/unit'
require 'citrus/core_ext'
class Test::Unit::TestCase
include Citrus
TestGrammar = Grammar.new do
rule :alpha do
/[a-zA-Z]/
end
rule :num do
ext(/[0-9]/) { to_i }
end
rule :alphanum do
any(:alpha, :num)
end
end
Double = Grammar.new do
include TestGrammar
root :double
rule :double do
one_or_more(:num)
end
end
Words = Grammar.new do
include TestGrammar
root :words
rule :word do
one_or_more(:alpha)
end
rule :words do
[ :word, zero_or_more([ ' ', :word ]) ]
end
end
end
|