I'm having trouble parsing heredocs. I adapted the example document
code[1], and my parser[2] correctly parses "normal heredocs". However
heredocs[3] containing only whitespace (indentation/empty lines) fail to
parse.

Extra information about Rip heredocs might be useful:
* They may not be nested. (or place whatever you want in a heredoc, but Rip
will only see a single string.)
* They follow the same termination rules as Ruby's <<-HEREDOCS. (In other
words heredocs terminators may be indented, but otherwise must appear on a
blank line. Additionally the only thing allowed after the heredoc
terminator is a line break or nothing.)
* In contrast to Ruby heredocs, Rip heredocs consisting solely of multiple
blank lines does not get collapsed into an empty string. (Why does Ruby do
this anyway?)

[2]
https://github.com/rip-lang/rip/blob/heredoc/lib/rip/compiler/parser.rb#L257-L269
[3]
https://github.com/rip-lang/rip/blob/heredoc/spec/unit/rip/compiler/parser_spec.rb#L1449-L1529

-- 
Thomas Ingram

Reply via email to