Skip to content

Commit 51e44c2

Browse files
committed
allow variables with spaces after the sigil
1 parent 70d20eb commit 51e44c2

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

Changes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Revision history for Perl extension PPI
22

33
{{$NEXT}}
4+
Summary:
5+
- Allow variable names to have whitespace after the sigil (GH#158)
46

57
1.281 2024-12-27 14:44:47Z
68
Summary:

lib/PPI/Token/Symbol.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ sub __TOKENIZER__on_char {
201201
my $pattern = qr/
202202
^(
203203
[\$@%&*]
204+
\s*
204205
(?:
205206
: (?! : ) # allow single-colon non-magic variables
206207
|

lib/PPI/Token/Unknown.pm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ sub __TOKENIZER__on_char {
115115
return 1;
116116
}
117117

118+
if ( $char eq ' ' ) {
119+
pos $t->{line} = $t->{line_cursor} + 1;
120+
if ( $t->{line} =~ m/\G\s*[a-z_]/gci ) {
121+
$t->{class} = $t->{token}->set_class('Symbol');
122+
return 1;
123+
}
124+
}
125+
118126
# Is it a nameless arg in a signature?
119127
if ( $char eq ')' or $char eq '=' or $char eq ',' ) {
120128
my ($has_sig) = $t->_current_token_has_signatures_active;

t/foreach_whitespace.t

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use PPI::Dumper;
1313
sub test_document;
1414

1515
BASE_SPACE_SYMBOL: {
16-
local $TODO = "crashes";
1716
test_document #
1817
'$ s', #
1918
[
@@ -24,7 +23,6 @@ BASE_SPACE_SYMBOL: {
2423
}
2524

2625
FOR_LOOP: {
27-
local $TODO = "crashes";
2826
test_document
2927
'for my $ s ( qw( a b ) ) { say $s }',
3028
[
@@ -48,7 +46,6 @@ FOR_LOOP: {
4846
}
4947

5048
SIGIL_WITH_TRASH: {
51-
local $TODO = "crashes";
5249
test_document
5350
'$ \"8;b',
5451
[

0 commit comments

Comments
 (0)