treetop 1.2.1 → 1.2.2

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.
@@ -317,7 +317,7 @@ module Treetop
317
317
  end
318
318
 
319
319
  rule character_class
320
- '[' characters:(!']' ('\]'/.))+ ']' <CharacterClass> {
320
+ '[' characters:(!']' ('\\' . /!'\\' .))+ ']' <CharacterClass> {
321
321
  def characters
322
322
  super.text_value
323
323
  end
@@ -6,8 +6,9 @@ module Treetop
6
6
  end
7
7
 
8
8
  def single_quote(string)
9
- "'#{string.gsub(/'$/, "\\'")}'"
9
+ # Double any backslashes, then backslash any single-quotes:
10
+ "'#{string.gsub(/\\/) { '\\\\' }.gsub(/'/) { "\\'"}}'"
10
11
  end
11
12
  end
12
13
  end
13
- end
14
+ end
@@ -4,7 +4,7 @@ module Treetop
4
4
  def compile(address, builder, parent_expression = nil)
5
5
  super
6
6
 
7
- builder.if__ "input.index(/#{escaped_text_value}/, index) == index" do
7
+ builder.if__ "input.index(Regexp.new(#{single_quote(text_value)}), index) == index" do
8
8
  assign_result "(#{node_class_name}).new(input, index...(index + 1))"
9
9
  extend_result_with_inline_module
10
10
  builder << "@index += 1"
@@ -14,10 +14,6 @@ module Treetop
14
14
  assign_result 'nil'
15
15
  end
16
16
  end
17
-
18
- def escaped_text_value
19
- text_value.gsub(/\/|#(@|\$)/) {|match| "\\#{match}"}
20
- end
21
17
  end
22
18
  end
23
- end
19
+ end
@@ -1,7 +1,5 @@
1
1
  dir = File.dirname(__FILE__)
2
2
  require "#{dir}/runtime/compiled_parser"
3
3
  require "#{dir}/runtime/syntax_node"
4
- require "#{dir}/runtime/node_cache"
5
- require "#{dir}/runtime/parse_cache"
6
4
  require "#{dir}/runtime/terminal_parse_failure"
7
5
  require "#{dir}/runtime/interval_skip_list"
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: treetop
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.2.1
7
- date: 2008-02-01 00:00:00 -08:00
6
+ version: 1.2.2
7
+ date: 2008-02-29 00:00:00 -08:00
8
8
  summary: A Ruby-based text parsing and interpretation DSL
9
9
  require_paths:
10
10
  - lib
@@ -69,8 +69,6 @@ files:
69
69
  - lib/treetop/runtime/compiled_parser.rb
70
70
  - lib/treetop/runtime/interval_skip_list
71
71
  - lib/treetop/runtime/interval_skip_list.rb
72
- - lib/treetop/runtime/node_cache.rb
73
- - lib/treetop/runtime/parse_cache.rb
74
72
  - lib/treetop/runtime/syntax_node.rb
75
73
  - lib/treetop/runtime/terminal_parse_failure.rb
76
74
  - lib/treetop/runtime/terminal_syntax_node.rb
@@ -130,7 +128,7 @@ dependencies:
130
128
  version_requirement:
131
129
  version_requirements: !ruby/object:Gem::Version::Requirement
132
130
  requirements:
133
- - - ">="
131
+ - - "="
134
132
  - !ruby/object:Gem::Version
135
133
  version: 2.0.2
136
134
  version:
@@ -1,27 +0,0 @@
1
- module Treetop
2
- module Runtime
3
- class NodeCache
4
- attr_reader :parse_results
5
-
6
- def initialize
7
- @parse_results = {}
8
- end
9
-
10
- def empty?
11
- parse_results.empty?
12
- end
13
-
14
- def store(parse_result)
15
- if parse_result.nil?
16
- parse_results[parse_result.index] = parse_result
17
- else
18
- parse_results[parse_result.interval.begin] = parse_result
19
- end
20
- end
21
-
22
- def [](start_index)
23
- parse_results[start_index]
24
- end
25
- end
26
- end
27
- end
@@ -1,19 +0,0 @@
1
- module Treetop
2
- module Runtime
3
- class ParseCache
4
- attr_reader :node_caches
5
-
6
- def initialize
7
- @node_caches = {}
8
- end
9
-
10
- def [](parsing_expression)
11
- node_caches[parsing_expression] ||= NodeCache.new
12
- end
13
-
14
- def empty?
15
- node_caches.empty?
16
- end
17
- end
18
- end
19
- end