citrus 2.1.2 → 2.2.0

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.
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 2
7
- - 1
8
7
  - 2
9
- version: 2.1.2
8
+ - 0
9
+ version: 2.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael Jackson
@@ -14,26 +14,13 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-30 00:00:00 -07:00
17
+ date: 2010-11-11 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: builder
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- version: "0"
31
- type: :runtime
32
- version_requirements: *id001
33
20
  - !ruby/object:Gem::Dependency
34
21
  name: rake
35
22
  prerelease: false
36
- requirement: &id002 !ruby/object:Gem::Requirement
23
+ requirement: &id001 !ruby/object:Gem::Requirement
37
24
  none: false
38
25
  requirements:
39
26
  - - ">="
@@ -42,7 +29,7 @@ dependencies:
42
29
  - 0
43
30
  version: "0"
44
31
  type: :development
45
- version_requirements: *id002
32
+ version_requirements: *id001
46
33
  description: Parsing Expressions for Ruby
47
34
  email: mjijackson@gmail.com
48
35
  executables: []
@@ -52,11 +39,14 @@ extensions: []
52
39
  extra_rdoc_files:
53
40
  - README
54
41
  files:
42
+ - benchmark/after.dat
43
+ - benchmark/before.dat
55
44
  - benchmark/seqpar.citrus
56
45
  - benchmark/seqpar.gnuplot
57
46
  - benchmark/seqpar.rb
58
47
  - doc/background.markdown
59
48
  - doc/example.markdown
49
+ - doc/extras.markdown
60
50
  - doc/index.markdown
61
51
  - doc/license.markdown
62
52
  - doc/links.markdown
@@ -66,7 +56,6 @@ files:
66
56
  - examples/calc.rb
67
57
  - examples/ip.citrus
68
58
  - examples/ip.rb
69
- - lib/citrus/debug.rb
70
59
  - lib/citrus/file.rb
71
60
  - lib/citrus.rb
72
61
  - test/_files/alias.citrus
@@ -77,13 +66,14 @@ files:
77
66
  - test/_files/rule2.citrus
78
67
  - test/_files/rule3.citrus
79
68
  - test/_files/super.citrus
69
+ - test/_files/super2.citrus
80
70
  - test/alias_test.rb
81
71
  - test/and_predicate_test.rb
82
72
  - test/but_predicate_test.rb
83
73
  - test/calc_file_test.rb
84
74
  - test/calc_test.rb
85
75
  - test/choice_test.rb
86
- - test/debug_test.rb
76
+ - test/extension_test.rb
87
77
  - test/file_test.rb
88
78
  - test/grammar_test.rb
89
79
  - test/helper.rb
@@ -94,8 +84,8 @@ files:
94
84
  - test/not_predicate_test.rb
95
85
  - test/parse_error_test.rb
96
86
  - test/repeat_test.rb
97
- - test/rule_test.rb
98
87
  - test/sequence_test.rb
88
+ - test/string_terminal_test.rb
99
89
  - test/super_test.rb
100
90
  - test/terminal_test.rb
101
91
  - citrus.gemspec
@@ -145,7 +135,7 @@ test_files:
145
135
  - test/calc_file_test.rb
146
136
  - test/calc_test.rb
147
137
  - test/choice_test.rb
148
- - test/debug_test.rb
138
+ - test/extension_test.rb
149
139
  - test/file_test.rb
150
140
  - test/grammar_test.rb
151
141
  - test/input_test.rb
@@ -155,7 +145,7 @@ test_files:
155
145
  - test/not_predicate_test.rb
156
146
  - test/parse_error_test.rb
157
147
  - test/repeat_test.rb
158
- - test/rule_test.rb
159
148
  - test/sequence_test.rb
149
+ - test/string_terminal_test.rb
160
150
  - test/super_test.rb
161
151
  - test/terminal_test.rb
data/lib/citrus/debug.rb DELETED
@@ -1,69 +0,0 @@
1
- require 'citrus'
2
- require 'builder'
3
-
4
- module Citrus
5
- class Match
6
- # The offset at which this match was found in the input.
7
- attr_accessor :offset
8
-
9
- def debug_attrs
10
- { "names" => names.join(','),
11
- "text" => to_s,
12
- "offset" => offset
13
- }
14
- end
15
-
16
- # Creates a Builder::XmlMarkup object from this match. Useful when
17
- # inspecting a nested match. The +xml+ argument may be a Hash of
18
- # Builder::XmlMarkup options.
19
- def to_markup(xml={})
20
- if Hash === xml
21
- opt = { :indent => 2 }.merge(xml)
22
- xml = Builder::XmlMarkup.new(opt)
23
- xml.instruct!
24
- end
25
-
26
- if matches.empty?
27
- xml.match(debug_attrs)
28
- else
29
- xml.match(debug_attrs) do
30
- matches.each {|m| m.to_markup(xml) }
31
- end
32
- end
33
-
34
- xml
35
- end
36
-
37
- # Returns the target of #to_markup which is an XML string unless another
38
- # target is specified in +opt+.
39
- def to_xml(opt={})
40
- to_markup(opt).target!
41
- end
42
-
43
- def inspect # :nodoc:
44
- to_xml
45
- end
46
- end
47
-
48
- # Hijack all classes that use Rule#create_match to create matches. Now, when
49
- # matches are created they will also record their offset to help debugging.
50
- # This functionality is included in this file because calculating the offset
51
- # of every match as it is created can slow things down quite a bit.
52
- [ Terminal,
53
- AndPredicate,
54
- NotPredicate,
55
- ButPredicate,
56
- Repeat,
57
- Sequence
58
- ].each do |rule_class|
59
- rule_class.class_eval do
60
- alias original_match match
61
-
62
- def match(input)
63
- m = original_match(input)
64
- m.offset = input.pos - m.length if m
65
- m
66
- end
67
- end
68
- end
69
- end
data/test/debug_test.rb DELETED
@@ -1,23 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
-
3
- # This file tests functionality that is only present when debugging is enabled.
4
-
5
- class DebugTest < Test::Unit::TestCase
6
-
7
- def test_offset
8
- match = Words.parse('one two')
9
- assert(match)
10
- assert_equal(0, match.offset)
11
-
12
- words = match.find(:word)
13
- assert(match)
14
- assert_equal(2, words.length)
15
-
16
- assert_equal('one', words[0])
17
- assert_equal(0, words[0].offset)
18
-
19
- assert_equal('two', words[1])
20
- assert_equal(4, words[1].offset)
21
- end
22
-
23
- end