In perl.git, the branch topic/indented-here-docs has been created
<http://perl5.git.perl.org/perl.git/commitdiff/c7abe651894378744f39c9b14083002a2c67d954?hp=0000000000000000000000000000000000000000>
at c7abe651894378744f39c9b14083002a2c67d954 (commit)
- Log -----------------------------------------------------------------
commit c7abe651894378744f39c9b14083002a2c67d954
Author: Matthew Horsfall <[email protected]>
Date: Thu Jul 7 16:33:14 2016 -0400
Support <<~EOF inside of string evals and regexps.
M toke.c
commit a028aaa7fb4a01ffb41a617cf7e9ef111521c947
Author: Matthew Horsfall <[email protected]>
Date: Thu Jul 7 06:33:20 2016 -0400
Fix parsing of indented heredocs with delimiter look-alikes.
The following would fail as indent_len was never reset on each
possible match of the delimiter:
print <<~EOF;
x EOF
hello there
EOF
M t/op/heredoc.t
M toke.c
commit a03095128d9192c7a97db64b10c2527b26897b94
Author: Matthew Horsfall <[email protected]>
Date: Wed Jul 6 21:03:57 2016 -0400
Use ninstr to allow for delimiters with NUL characters.
This allows for delimiters to have null characters with indented
heredocs, but does not currently work due to a bug earlier in the
delimiter processing phase.
M toke.c
commit b421548caa41c2bf2e57eb4edf450ca7ed82876a
Author: Matthew Horsfall <[email protected]>
Date: Wed Jul 6 19:26:03 2016 -0400
Add test for <<~`END` with indented heredoc.
M t/op/exec.t
commit 7f8bd48de6d9cb0de07b525946d77bb5a0b21c98
Author: Matthew Horsfall <[email protected]>
Date: Wed Jul 6 19:24:23 2016 -0400
Add test for now fixed indented heredoc missing terminator error.
M t/op/heredoc.t
commit 1ab0f4d04c65c2b248ab5c403deb73b74bec3c11
Author: Matthew Horsfall <[email protected]>
Date: Wed Jul 6 19:19:19 2016 -0400
Replace ninstr with instr() for simplicity.
We are checking line by line for the delimiter, so NUL characters in the
heredoc body aren't a problem.
M toke.c
commit b05601ee911f54147c8533ba41d76bdd753e18d7
Author: Matthew Horsfall <[email protected]>
Date: Wed Jul 6 18:44:20 2016 -0400
Guard ninstr and memEQ appropriately.
M toke.c
commit c88d30839c64be4585dc7d95fb3a4cb41cce14b3
Author: Matthew Horsfall <[email protected]>
Date: Thu Jun 30 21:01:52 2016 -0400
Add a test case for indented heredocs with no indentation.
M t/op/heredoc.t
M toke.c
commit aa9a17aba69cecf6fbb7c2af929731e7df9f181b
Author: Matthew Horsfall <[email protected]>
Date: Thu Jun 30 20:22:48 2016 -0400
Allow indented heredocs.
This adds a new modifier '~' to heredocs that tells the parser
that it should look for /^\s*$DELIM\n/ as the closing delimiter.
These syntaxes are all supported:
<<~EOF;
<<~'EOF';
<<~"EOF";
<<~\EOF;
The '~' modifier will strip, from each line in the heredoc, the
same whitespace that appears before the delimiter.
Newlines will be copied as is, and lines that don't include the
proper beginning whitespace will throw warnings.
Some examples:
if (1) {
print <<~EOF;
Hello there
EOF
}
prints "Hello there\n";
The following:
if (1) {
print <<~EOF;
Hello There
EOF
warns and prints:
Indentation on line 1 of heredoc doesn't match delimiter at
/home/mhorsfall/eof.pl line 6.
Hello there
M t/op/heredoc.t
M toke.c
-----------------------------------------------------------------------
--
Perl5 Master Repository