allowing comments instead of newlines and not capturing comments (leave that for later as it messes the output)

This commit is contained in:
Torsten Ruger 2014-05-14 22:19:20 +03:00
parent 3912e0cd31
commit c9ffb78e82
2 changed files with 4 additions and 4 deletions

View File

@ -6,13 +6,13 @@ module Parser
# rule of thumb is that anything eats space behind it, but only space, no newlines # rule of thumb is that anything eats space behind it, but only space, no newlines
rule(:space) { (str('\t') | str(' ')).repeat(1) } rule(:space) { (str('\t') | str(' ')).repeat(1) }
rule(:space?) { space.maybe } rule(:space?) { space.maybe }
rule(:newline){ str("\n") >> space? >> newline.repeat } rule(:linebreak){ str("\n") >> space? >> linebreak.repeat }
rule(:quote) { str('"') } rule(:quote) { str('"') }
rule(:nonquote) { str('"').absent? >> any } 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(:eol) { newline | any.absent? }
rule(:double_quote){ str('"') } rule(:double_quote){ str('"') }

View File

@ -9,7 +9,7 @@ module Parser
space? >> right_parenthesis space? >> right_parenthesis
} }
rule(:call_site) { name.as(:call_site) >> argument_list } rule(:call_site) { name.as(:call_site) >> argument_list >> comment.maybe}
end end