From c9ffb78e820c8e80ff1d16e898d04ec7cbf3f0ce Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Wed, 14 May 2014 22:19:20 +0300 Subject: [PATCH] allowing comments instead of newlines and not capturing comments (leave that for later as it messes the output) --- lib/parser/basic_types.rb | 6 +++--- lib/parser/call_site.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/parser/basic_types.rb b/lib/parser/basic_types.rb index ec774e85..b1199d07 100644 --- a/lib/parser/basic_types.rb +++ b/lib/parser/basic_types.rb @@ -6,13 +6,13 @@ module Parser # rule of thumb is that anything eats space behind it, but only space, no newlines rule(:space) { (str('\t') | str(' ')).repeat(1) } rule(:space?) { space.maybe } - rule(:newline){ str("\n") >> space? >> newline.repeat } + rule(:linebreak){ str("\n") >> space? >> linebreak.repeat } rule(:quote) { str('"') } rule(:nonquote) { str('"').absent? >> any } - rule(:comment){ match('#') >> (newline.absent? >> any).repeat.as(:comment) >> newline } - + rule(:comment){ match('#') >> (linebreak.absent? >> any).repeat >> linebreak } + rule(:newline) { linebreak | comment } rule(:eol) { newline | any.absent? } rule(:double_quote){ str('"') } diff --git a/lib/parser/call_site.rb b/lib/parser/call_site.rb index cd747eab..0c5c6403 100644 --- a/lib/parser/call_site.rb +++ b/lib/parser/call_site.rb @@ -9,7 +9,7 @@ module Parser space? >> right_parenthesis } - rule(:call_site) { name.as(:call_site) >> argument_list } + rule(:call_site) { name.as(:call_site) >> argument_list >> comment.maybe} end