| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
| |
If a sub exists, it takes precedence over the filehandle
interpretation even without the parens:
$ perl -le 'sub foo { "bar" } print foo;'
bar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When bareword filehandles are disabled, the parser was interpreting
any bareword as a filehandle, even when immediatey followed by parens:
$ perl -M-feature=bareword_filehandles -le 'print foo()'
Bareword filehandle "foo" not allowed under 'no feature "bareword_filehandles"' at -e line 1.
While with the feature enabled, it works and prints the value returned
by the function:
$ perl -le 'sub foo { @_ } print foo("bar")'
bar
As for filehandles versus functions, a space before the parens makes
the difference:
$ perl -le 'print STDOUT ("bar")'
bar
$ perl -le 'print STDOUT("bar")'
Undefined subroutine &main::STDOUT called at -e line 1.
This fixes the bug by using the already-existing "immediate_paren"
variable to make it consistent when the feature is disabled.
Fixes #19271
|
|
|
|
| |
The same holds for newSVpvs* wrappers around newSVpvn* functions.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
No-one had thought to test for this explicitly. After all, both
`for my $foo ...` and `for my$foo ...` are valid syntax, so tweaking the
C lexer code to add an optional '(' should work, surely?
The problem was that, *as was*, the lexer code didn't "accept" those two
syntax variants the way the comments would suggest.
`for my $foo ...` was treated as
1) we saw 'my '
2) we saw the dollar sign
3) success!
but `for my$foo ...` was treated as
0) we didn't see 'my ' or 'our '
1) we saw the literal string 'my' which is valid as a package name
2) we saw the dollar sign
3) success!
ie some sort of mangled variant of `for my Dog $spot ...` without 'my'
*but* as the lexer was happy with what it saw, it returned that the input
stream was valid for a "for" token, and control continues to the grammar.
The grammar, of course, didn't make these mistakes, so parsed everything
properly and built the correct optree.
(And, if presented with `for Dog $spot (...)` the grammar wouldn't match,
so all invalid code was correctly rejected)
However, all this came unstuck with `for my($k` because that didn't
mis-tokenise as some crazy package name 'my(', so it reported a syntax error.
Hence rewrite yyl_foreach() to actually tokenise everything correctly.
"Correctly", to be clear, is bug-for-bug compatible with the current emergent
behaviour for various corner cases for "parses and runs" vs "syntax error".
We don't always report identical error messages for certain syntax errors,
where the precise message reported was itself emergent behaviour from the
bugs in the previous implementation.
|
| |
|
|
|
|
|
|
|
|
|
| |
For example, this now works:
for my ($key, $value) (%hash) { ... }
Only for scalars declared with my as a list in the for loop statement.
As many as you want (unless you want more than 4294967296).
|
|
|
|
| |
The build has been broken since 2009.
|
|
|
|
|
|
|
|
| |
"grandfather return to old style" only really makes sense if you are
familiar with parsing changes between perl 2 and perl 3.
For everyone else, add an explanation of a special case which is still
relevant to the present day.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Each 'try' block has a nextstate COP prepended to it. Currently this cop
has the line number of the line following the end of the try block. Fix
it so that it has the line number of the line containing the 'try'
keyword instead.
This is achieved using the same technique as other block-introducing
keywords like 'while': set the .ival of the 'try' token returned by the
lexer to the current line number, then set PL_parser->copline back to that
value after parsing the block but before creating the COP.
This issue was showing up as a failure in
cd t; ./TEST -deparse op/try.t
since that test script is line-number sensitive.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Adds syntax `defer { BLOCK }` to create a deferred block; code that is
deferred until the scope exits. This syntax is guarded by
use feature 'defer';
Adds a new opcode, `OP_PUSHDEFER`, which is a LOGOP whose `op_other` field
gives the start of an optree to be deferred until scope exit. That op
pointer will be stored on the save stack and invoked as part of scope
unwind.
Included is support for `B::Deparse` to deparse the optree back into
syntax.
|
| |
|
|
|
|
|
|
|
| |
This is a rebasing by @khw of part of GH #18792, which I needed to get
in now to proceed with other commits.
It also strips trailing white space from the affected files.
|
|
|
|
|
|
|
|
|
|
| |
Signed-off-by: James E Keenan <jkeenan@cpan.org>
Remove 2nd const from patch originally submitted in
https://github.com/Perl/perl5/pull/18726; it was causing two build-time
warnings.
Alyssa Ross is now a Perl author.
|
|
|
|
|
|
|
|
|
| |
* Add feature, experimental warning, keyword
* Basic parsing
* Basic implementation as optree fragment
See also
https://github.com/Perl/perl5/issues/18504
|
|
|
|
|
| |
This was the consensus in
http://nntp.perl.org/group/perl.perl5.porters/258489
|
| |
|
|
|
|
|
| |
A future commit will need it to represent just the meaning of the new
name
|
|
|
|
|
|
|
| |
Rather than know how far we have advanced in parsing when we have to
back up, save the checkpoint position and simply backtrack to it. This
results in slightly more maintainable code that a future commit will
take advantage of.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit copies portions of new_regcurly(), which has been around
since 5.28, into plain regcurly(), as a baby step in preparation for
converting entirely to the new one. These functions are used for
parsing {m,n} quantifiers. Future commits will add capabilities not
available using the old version.
The commit adds an optional parameter, to return to the caller
information it gleans during parsing.
regpiece() is changed by this commit to use this information, instead of
itself reparsing the input. Part of the reason for this commit is that
changes are planned soon to what is legal syntax. With this commit in
place, those changes only have to be done once.
This commit also extracts into a function the calculation of the
quantifier bounds. This allows the logic for that to be done in one
place instead of two.
|
| |
|
|
|
|
| |
This disables use of bareword filehandles except for the built-in handles
|
|
|
|
| |
f23102e2d6 removed DOROP token (KEY_err) but related grammar remained
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
| |
regardless of the fact that both have same value
their meaning is different and should not be mixed
|
|
|
|
|
|
|
|
|
|
|
| |
These variables are only used on emitting diagnostic messages.
Calculating them on-demand will make the code slightly faster
on normal cases.
Note: previously bases[], Bases[] and maxima[] may be completely
optimized out by fusing array accesses into if-brances.
Now they become real arrays, and will slightly increase the number
of dynamic relocations on PIC build.
|
| |
|
|
|
|
| |
t/base/num.t: Add some test for "0odddd" octals.
|
|
|
|
| |
which is what it is doing, instead of the more general SvPV_renew.
|
|
|
|
|
| |
This allows to use the current features bundle
defined by the current version of Perl.
|