Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removed Ruby warnings.

  • Loading branch information...
commit 4db906f6577e35a5f41ecedbf10ff45715587a4c 1 parent 0edd8e6
Tobias Bühlmann authored
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([
Please sign in to comment.
Something went wrong with that request. Please try again.