apacheconfig icon indicating copy to clipboard operation
apacheconfig copied to clipboard

Unable to parse heredoc inside a block properly

Open bpradeep20 opened this issue 7 years ago • 7 comments

Config:

<main>
    PYTHON <<MYPYTHON
        def a():
            x = y
            return
    MYPYTHON
</main>

With python version of config parser I am getting parse error

But with perl version:

$VAR1 = {
          'main' => {
                      'PYTHON' => 'def a():
        x = y
        return'
                    }
        };

Can you please check?

bpradeep20 avatar Jul 23 '18 12:07 bpradeep20

The issue here is that closing MYPYTHON anchor is indented. I've modified the lexer to allow that (see commit 8a9f5b34bb1bd07e44fa94fb0b9b76181d37bb58).

But now I am curious how would you include MYPYTHON content into the heredoc block? There should be some sort of escaping, right?

etingof avatar Jul 24 '18 07:07 etingof

Hmm, is it a good idea to allow whitespaces around the anchor? At least with bash, this is not allowed.

etingof avatar Jul 30 '18 06:07 etingof

This is working with current version of code.

bpradeep20 avatar Dec 05 '18 04:12 bpradeep20

It does, but I feel like this may break things elsewhere. May be we should better make this behavior configurable.

etingof avatar Dec 05 '18 07:12 etingof

I agree. It would be great of we have some option to enable PERL heredoc and keep default as BASH here doc.

bpradeep20 avatar Dec 05 '18 10:12 bpradeep20

Hey, @sydneyli! Do you think this has been fixed lately?

etingof avatar Nov 17 '19 08:11 etingof

The behavior in the original issue fixed, but extra whitespaces after the closing heredoc anchor seems to still break things. Edit: It might be good to change the title of this issue to reflect the above?

sydneyli avatar Nov 18 '19 21:11 sydneyli