Skip to content

Commit

Permalink
Empty inline comments are now allowed
Browse files Browse the repository at this point in the history
  • Loading branch information
cjheath committed Jun 2, 2008
1 parent 1dc77b3 commit 91692d4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ end

gemspec = Gem::Specification.new do |s|
s.name = "treetop"
s.version = "1.2.3"
s.version = "1.2.4"
s.author = "Nathan Sobo"
s.email = "nathansobo@gmail.com"
s.homepage = "http://functionalform.blogspot.com"
Expand Down
21 changes: 8 additions & 13 deletions lib/treetop/compiler/metagrammar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def _nt_module_declaration
r3 = _nt_space
s1 << r3
if r3
if input.index(/[A-Z]/, index) == index
if input.index(Regexp.new('[A-Z]'), index) == index
r4 = (SyntaxNode).new(input, index...(index + 1))
@index += 1
else
Expand Down Expand Up @@ -324,7 +324,7 @@ def _nt_grammar_name
end

i0, s0 = index, []
if input.index(/[A-Z]/, index) == index
if input.index(Regexp.new('[A-Z]'), index) == index
r1 = (SyntaxNode).new(input, index...(index + 1))
@index += 1
else
Expand Down Expand Up @@ -523,7 +523,7 @@ def _nt_include_declaration
r2 = _nt_space
s0 << r2
if r2
if input.index(/[A-Z]/, index) == index
if input.index(Regexp.new('[A-Z]'), index) == index
r3 = (SyntaxNode).new(input, index...(index + 1))
@index += 1
else
Expand Down Expand Up @@ -2508,7 +2508,7 @@ def _nt_inline_module
else
i5, s5 = index, []
i6 = index
if input.index(/[{}]/, index) == index
if input.index(Regexp.new('[{}]'), index) == index
r7 = (SyntaxNode).new(input, index...(index + 1))
@index += 1
else
Expand Down Expand Up @@ -2691,7 +2691,7 @@ def _nt_alpha_char
return cached
end

if input.index(/[A-Za-z_]/, index) == index
if input.index(Regexp.new('[A-Za-z_]'), index) == index
r0 = (SyntaxNode).new(input, index...(index + 1))
@index += 1
else
Expand All @@ -2716,7 +2716,7 @@ def _nt_alphanumeric_char
if r1
r0 = r1
else
if input.index(/[0-9]/, index) == index
if input.index(Regexp.new('[0-9]'), index) == index
r2 = (SyntaxNode).new(input, index...(index + 1))
@index += 1
else
Expand Down Expand Up @@ -2841,12 +2841,7 @@ def _nt_comment_to_eol
break
end
end
if s2.empty?
self.index = i2
r2 = nil
else
r2 = SyntaxNode.new(input, i2...index, s2)
end
r2 = SyntaxNode.new(input, i2...index, s2)
s0 << r2
end
if s0.last
Expand All @@ -2870,7 +2865,7 @@ def _nt_white
return cached
end

if input.index(/[ \t\n\r]/, index) == index
if input.index(Regexp.new('[ \\t\\n\\r]'), index) == index
r0 = (SyntaxNode).new(input, index...(index + 1))
@index += 1
else
Expand Down
2 changes: 1 addition & 1 deletion lib/treetop/compiler/metagrammar.treetop
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ module Treetop
end

rule comment_to_eol
'#' (!"\n" .)+
'#' (!"\n" .)*
end

rule white
Expand Down
3 changes: 2 additions & 1 deletion spec/compiler/grammar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ module Bar
describe "a grammar" do
testing_grammar %{
grammar Foo
# This comment should not cause a syntax error.
# This comment should not cause a syntax error, nor should the following empty one
#
include GrammarSpec::Bar
rule foo
Expand Down

0 comments on commit 91692d4

Please sign in to comment.