Woops! Dependencies are managed with bundler. After cloning the project,
run `bundle install` to get the dependencies. You can run the tests with
`bundle exec rspec`. Thanks for your help. I'll work on writing some
documentation tonight.

I'm not sure how to allow an empty heredoc and still have the closing label
constrained to its own line. I suspect I could use a lookbehind in
heredoc_end (see below), but I don't know how.

    rule(:heredoc_content) { (heredoc_end.absent? >>
heredoc_content_any).repeat }
    rule(:heredoc_end) do
      dynamic { |source, context| <lookbehind to ensure label is on own
line> >> str(context.captures[:heredoc_label]) >> (eof.absent? >>
line_break) }
    end



On Wed, May 22, 2013 at 9:23 AM, Kaspar Schiess <[email protected]>wrote:

> Hi Thomas,
>
> I am willing to investigate this, however: your project doesn't say how
> to run these 'broken' specs and I don't have the time to find out.
> Please give us something we can run to verify what we claim before we
> post it. (aka test driven posting)
>
> By glancing at your code, I suspect you simply ask for the heredoc not
> to be empty, which makes the tests fail. Have you excluded that
> possibility?
>
> Greetings,
> kaspar
>
> On 21.05.13 23:24, Thomas Ingram wrote:
> > 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
>
>
>


-- 
Thomas Ingram

Reply via email to