citrus 2.3.2 → 2.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +30 -10
- data/Rakefile +1 -1
- data/citrus.gemspec +1 -1
- data/doc/syntax.markdown +9 -9
- data/examples/calc.citrus +2 -3
- data/examples/calc.rb +79 -72
- data/examples/ipaddress.citrus +16 -0
- data/examples/ipaddress.rb +23 -0
- data/examples/ipv4address.citrus +26 -0
- data/examples/ipv4address.rb +49 -0
- data/examples/{ip.citrus → ipv6address.citrus} +1 -40
- data/examples/ipv6address.rb +55 -0
- data/lib/citrus.rb +267 -157
- data/lib/citrus/file.rb +58 -64
- data/lib/citrus/version.rb +9 -0
- data/test/alias_test.rb +1 -1
- data/test/file_test.rb +101 -139
- data/test/helper.rb +0 -116
- data/test/match_test.rb +0 -1
- data/test/memoized_input_test.rb +1 -1
- data/test/multibyte_test.rb +57 -6
- data/test/parse_error_test.rb +4 -2
- metadata +112 -108
- data/examples/ip.rb +0 -77
- data/test/calc_file_test.rb +0 -16
- data/test/calc_test.rb +0 -11
data/examples/ip.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
|
2
|
-
|
3
|
-
require 'citrus'
|
4
|
-
|
5
|
-
# This file contains a small suite of tests for the grammars found in ip.citrus.
|
6
|
-
# If this file is run directly (i.e. using `ruby ip.rb') the tests will run.
|
7
|
-
# Otherwise, this file may be required by another that needs access to the IP
|
8
|
-
# address grammars just as any other file would be.
|
9
|
-
|
10
|
-
# Load and evaluate the grammars contained in ip.citrus into the global
|
11
|
-
# namespace.
|
12
|
-
Citrus.load(File.expand_path('../ip', __FILE__))
|
13
|
-
|
14
|
-
if $0 == __FILE__
|
15
|
-
require 'test/unit'
|
16
|
-
|
17
|
-
class IPAddressTest < Test::Unit::TestCase
|
18
|
-
def test_dec_octet
|
19
|
-
match = IPv4Address.parse('0', :root => :'dec-octet')
|
20
|
-
assert(match)
|
21
|
-
|
22
|
-
match = IPv4Address.parse('255', :root => :'dec-octet')
|
23
|
-
assert(match)
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_hexdig
|
27
|
-
match = IPv6Address.parse('0', :root => :HEXDIG)
|
28
|
-
assert(match)
|
29
|
-
|
30
|
-
match = IPv6Address.parse('A', :root => :HEXDIG)
|
31
|
-
assert(match)
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_v4
|
35
|
-
match = IPv4Address.parse('0.0.0.0')
|
36
|
-
assert(match)
|
37
|
-
|
38
|
-
match = IPv4Address.parse('255.255.255.255')
|
39
|
-
assert(match)
|
40
|
-
|
41
|
-
assert_raise Citrus::ParseError do
|
42
|
-
IPv4Address.parse('255.255.255')
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_v6
|
47
|
-
match = IPv6Address.parse('1:2:3:4:5:6:7:8')
|
48
|
-
assert(match)
|
49
|
-
|
50
|
-
match = IPv6Address.parse('12AD:34FC:A453:1922::')
|
51
|
-
assert(match)
|
52
|
-
|
53
|
-
match = IPv6Address.parse('12AD::34FC')
|
54
|
-
assert(match)
|
55
|
-
|
56
|
-
match = IPv6Address.parse('12AD::')
|
57
|
-
assert(match)
|
58
|
-
|
59
|
-
match = IPv6Address.parse('::')
|
60
|
-
assert(match)
|
61
|
-
|
62
|
-
assert_raise Citrus::ParseError do
|
63
|
-
IPv6Address.parse('1:2')
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_all
|
68
|
-
match = IPAddress.parse('1.2.3.4')
|
69
|
-
assert(match)
|
70
|
-
assert_equal(4, match.version)
|
71
|
-
|
72
|
-
match = IPAddress.parse('1:2:3:4::')
|
73
|
-
assert(match)
|
74
|
-
assert_equal(6, match.version)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
data/test/calc_file_test.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require File.expand_path('../helper', __FILE__)
|
2
|
-
|
3
|
-
Citrus.load File.expand_path('../../examples/calc', __FILE__)
|
4
|
-
|
5
|
-
class CalcFileTest < Test::Unit::TestCase
|
6
|
-
include CalcTestMethods
|
7
|
-
|
8
|
-
# It's a bit hacky, but since this test runs before calc_test.rb we can
|
9
|
-
# avoid getting the "already defined constant" error by renaming the Calc
|
10
|
-
# constant here.
|
11
|
-
CalcFile = Object.__send__(:remove_const, :Calc)
|
12
|
-
|
13
|
-
def do_test(expr)
|
14
|
-
super(expr, CalcFile)
|
15
|
-
end
|
16
|
-
end
|
data/test/calc_test.rb
DELETED