Skip to content

Loading…

Removed Ruby warnings #42

Merged
merged 1 commit into from

3 participants

@tbuehlmann

Adapted the code to remove Ruby warnings.

Tobias Bühlmann Removed Ruby warnings. 4db906f
@mjackson mjackson merged commit 3d30eab into mjackson:master
@mjackson
Owner

Looks great. Thanks!

@vipulnsward

@mjijackson can we have a new release, with this fix?
I think its been a long time since last release.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 2, 2013
  1. Removed Ruby warnings.

    Tobias Bühlmann committed
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 12 deletions.
  1. +1 −1 Rakefile
  2. +12 −3 lib/citrus.rb
  3. +0 −2 test/alias_test.rb
  4. +2 −2 test/grammar_test.rb
  5. +0 −4 test/super_test.rb
View
2 Rakefile
@@ -15,7 +15,7 @@ desc "Generate API documentation"
task :api => 'lib/citrus.rb' do |t|
output_dir = ENV['OUTPUT_DIR'] || 'api'
rm_rf output_dir
- sh((<<-SH).gsub(/[\s\n]+/, ' ').strip)
+ sh((<<-SH).gsub(/\s+/, ' ').strip)
hanna
--op #{output_dir}
--promiscuous
View
15 lib/citrus.rb
@@ -480,9 +480,16 @@ def rule(name, obj=nil, &block)
# Gets/sets the +name+ of the root rule of this grammar. If no root rule is
# explicitly specified, the name of this grammar's first rule is returned.
def root(name=nil)
- @root = name.to_sym if name
- # The first rule in a grammar is the default root.
- @root || rule_names.first
+ if name
+ @root = name.to_sym
+ else
+ # The first rule in a grammar is the default root.
+ if instance_variable_defined?(:@root)
+ @root
+ else
+ rule_names.first
+ end
+ end
end
# Creates a new rule that will match any single character. A block may be
@@ -1268,6 +1275,8 @@ class Match
def initialize(input, events=[], offset=0)
@input = input
@offset = offset
+ @captures = nil
+ @matches = nil
if events.length > 0
elisions = []
View
2 test/alias_test.rb
@@ -12,7 +12,6 @@ def test_exec
rule :b, 'abc'
}
rule_a = grammar.rule(:a)
- rule_b = grammar.rule(:b)
events = rule_a.exec(Input.new('abc'))
assert_equal([rule_a, CLOSE, 3], events)
end
@@ -36,7 +35,6 @@ def test_exec_included
rule :b, :a
}
rule_b2 = grammar2.rule(:b)
- rule_a1 = grammar1.rule(:a)
events = rule_b2.exec(Input.new('abc'))
assert_equal([rule_b2, CLOSE, 3], events)
end
View
4 test/grammar_test.rb
@@ -74,7 +74,7 @@ def test_parse_sequence_short
rule(:num) { all(1, 2, 3) }
}
assert_raise ParseError do
- match = grammar.parse('12')
+ grammar.parse('12')
end
end
@@ -99,7 +99,7 @@ def test_parse_choice_miss
rule(:alphanum) { any(/[a-z]/, 0..9) }
}
assert_raise ParseError do
- match = grammar.parse('A')
+ grammar.parse('A')
end
end
View
4 test/super_test.rb
@@ -18,7 +18,6 @@ def test_exec
rule_2a = grammar2.rule(:a)
rule_2a_als = rule_2a.rules[0]
rule_2a_sup = rule_2a.rules[1]
- rule_1a = grammar1.rule(:a)
events = rule_2a.exec(Input.new('abc'))
assert_equal([
@@ -58,12 +57,9 @@ def test_exec_aliased
rule :a, any(sup, :b)
rule :b, sup
}
- rule_1a = grammar1.rule(:a)
- rule_1b = grammar1.rule(:b)
rule_2a = grammar2.rule(:a)
rule_2a_sup = rule_2a.rules[0]
rule_2a_als = rule_2a.rules[1]
- rule_2b = grammar2.rule(:b)
events = rule_2a.exec(Input.new('abc'))
assert_equal([
Something went wrong with that request. Please try again.