Skip to content

Commit 3353672

Browse files
moreganwchristian
authored andcommitted
RT 68176 and 71705 -- support all augmented assignment operators
1 parent 172bd53 commit 3353672

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

lib/PPI/Token/Operator.pm

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ PPI::Token::Operator - Token class for operators
2020
<< >> lt gt le ge cmp ~~
2121
== != <=> . .. ... ,
2222
& | ^ && || //
23-
? : = += -= *= .= //=
24-
< > <= >= <> => ->
25-
and or dor not eq ne
23+
? : **= += -= .= *= /=
24+
%= x= &= |= ^= <<= >>= &&=
25+
||= //= < > <= >= <> => ->
26+
and or xor not eq ne
27+
2628
2729
=head1 DESCRIPTION
2830
@@ -58,7 +60,8 @@ BEGIN {
5860
< > <= >= lt gt le ge
5961
== != <=> eq ne cmp ~~
6062
& | ^ && || // .. ...
61-
? : = += -= *= .= /= //=
63+
? :
64+
= **= += -= .= *= /= %= x= &= |= ^= <<= >>= &&= ||= //=
6265
=> <>
6366
and or xor not
6467
}, ',' # Avoids "comma in qw{}" warning

lib/PPI/Token/Whitespace.pm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,12 @@ sub __TOKENIZER__on_char {
391391
}
392392
}
393393

394+
# Special Case: "x" recognized as a word here
395+
# might be the beginning of the "x=" operator.
396+
if ( $nextchar eq '=' ) {
397+
return 'Operator';
398+
}
399+
394400
# Otherwise, commit like a normal bareword
395401
return PPI::Token::Word->__TOKENIZER__commit($t);
396402

t/ppi_lexer.t

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/usr/bin/perl
22

3-
# Unit testing for PPI, generated by Test::Inline
4-
53
use strict;
64
use File::Spec::Functions ':ALL';
75
BEGIN {
@@ -89,7 +87,7 @@ isa_ok( $statements[9]->schild(1), 'PPI::Structure::Block',
8987
'The curly in ' . $statements[9]);
9088
isa_ok( $statements[10]->schild(2), 'PPI::Structure::Constructor',
9189
'The curly in ' . $statements[10]);
92-
isa_ok( $statements[11]->schild(3), 'PPI::Structure::Constructor',
90+
isa_ok( $statements[11]->schild(2), 'PPI::Structure::Constructor',
9391
'The curly in ' . $statements[11]);
9492
isa_ok( $statements[12]->schild(2), 'PPI::Structure::Constructor',
9593
'The curly in ' . $statements[12]);

t/ppi_token_operator.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ BEGIN {
1111
}
1212
use PPI;
1313

14-
use Test::More tests => 235;
14+
use Test::More tests => 275;
1515

1616

1717
FIND_ONE_OP: {

0 commit comments

Comments
 (0)