citrus 2.2.1 → 2.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/citrus.rb +12 -4
  2. data/test/label_test.rb +10 -0
  3. metadata +2 -2
data/lib/citrus.rb CHANGED
@@ -8,7 +8,7 @@ require 'strscan'
8
8
  module Citrus
9
9
  autoload :File, 'citrus/file'
10
10
 
11
- VERSION = [2, 2, 1]
11
+ VERSION = [2, 2, 2]
12
12
 
13
13
  # Returns the current version of Citrus as a string.
14
14
  def self.version
@@ -611,6 +611,11 @@ module Citrus
611
611
  def inspect # :nodoc:
612
612
  to_s
613
613
  end
614
+
615
+ def extend_match(match) # :nodoc:
616
+ match.names << name if named?
617
+ match.extend(extension) if extension
618
+ end
614
619
  end
615
620
 
616
621
  # A Terminal is a Rule that matches directly on the input stream and may not
@@ -944,6 +949,11 @@ module Citrus
944
949
  def to_s
945
950
  label.to_s + ':' + rule.embed
946
951
  end
952
+
953
+ def extend_match(match) # :nodoc:
954
+ match.names << label
955
+ super
956
+ end
947
957
  end
948
958
 
949
959
  # A Repeat is a Predicate that specifies a minimum and maximum number of times
@@ -1237,11 +1247,9 @@ module Citrus
1237
1247
 
1238
1248
  private
1239
1249
 
1240
- # Extends this match with the extensions provided by its #rules.
1241
1250
  def extend! # :nodoc:
1242
1251
  extenders.each do |rule|
1243
- self.names << rule.name if rule.named?
1244
- extend(rule.extension) if rule.extension
1252
+ rule.extend_match(self)
1245
1253
  end
1246
1254
  end
1247
1255
  end
data/test/label_test.rb CHANGED
@@ -6,6 +6,16 @@ class LabelTest < Test::Unit::TestCase
6
6
  assert_equal(false, rule.terminal?)
7
7
  end
8
8
 
9
+ def test_match
10
+ abc = Rule.new('abc')
11
+ abc.name = 'abc'
12
+ label = Label.new(abc, 'a_label')
13
+ label.name = 'label'
14
+ match = label.parse('abc')
15
+ assert(match)
16
+ assert_equal([:abc, :a_label, :label], match.names)
17
+ end
18
+
9
19
  def test_to_s
10
20
  rule = Label.new('a', 'label')
11
21
  assert_equal('label:"a"', rule.to_s)
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.2.1
4
+ version: 2.2.2
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: 2010-11-15 00:00:00 -08:00
12
+ date: 2010-11-16 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency