citrus 2.3.5 → 2.3.6

Sign up to get free protection for your applications and to get access to all the features.
data/lib/citrus.rb CHANGED
@@ -308,7 +308,11 @@ module Citrus
308
308
 
309
309
  if memo[position]
310
310
  @cache_hits += 1
311
- events.concat(memo[position])
311
+ c = memo[position]
312
+ unless c.empty?
313
+ events.concat(c)
314
+ self.pos += events[-1]
315
+ end
312
316
  else
313
317
  index = events.size
314
318
  rule.exec(self, events)
@@ -1,6 +1,6 @@
1
1
  module Citrus
2
2
  # The current version of Citrus as [major, minor, patch].
3
- VERSION = [2, 3, 5]
3
+ VERSION = [2, 3, 6]
4
4
 
5
5
  # Returns the current version of Citrus as a string.
6
6
  def self.version
@@ -26,7 +26,7 @@ class MemoizedInputTest < Test::Unit::TestCase
26
26
  def test_cache_hits1
27
27
  input = MemoizedInput.new('a')
28
28
  input.exec(LetterA.rule(:top))
29
- assert_equal(2, input.cache_hits)
29
+ assert_equal(3, input.cache_hits)
30
30
  end
31
31
 
32
32
  def test_cache_hits2
@@ -40,4 +40,25 @@ class MemoizedInputTest < Test::Unit::TestCase
40
40
  input.exec(LetterA.rule(:top))
41
41
  assert_equal(0, input.cache_hits)
42
42
  end
43
+
44
+ grammar :LettersABC do
45
+ rule :top do
46
+ any(all(:a,:b,:c), all(:b,:a,:c), all(:b,:c,:a))
47
+ end
48
+ rule :a do
49
+ "a"
50
+ end
51
+ rule :b do
52
+ "b"
53
+ end
54
+ rule :c do
55
+ "c"
56
+ end
57
+ end
58
+
59
+ def test_memoization
60
+ match = LettersABC.parse('bca',{:memoize=>true})
61
+ assert_equal('bca',match)
62
+ end
63
+
43
64
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: citrus
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.5
4
+ version: 2.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Jackson
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2011-02-07 00:00:00 -08:00
12
+ date: 2011-02-19 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency