Perl-Critic / PPI

53 stars 44 forks source link

Float with no decimals has period parsed as operator when followed immediately by 'e' #141

Closed moregan closed 7 years ago

moregan commented 9 years ago

perl parses this "1." as a float:

perl -WE "print 1.eq 1"
1

but PPI does not when the period is followed by 'e' with no whitespace in between:

ppidump "1.eq 1"
                    PPI::Document
                      PPI::Statement
[    1,   1,   1 ]     PPI::Token::Number       '1'
[    1,   2,   2 ]     PPI::Token::Operator     '.'
[    1,   3,   3 ]     PPI::Token::Operator     'eq'
[    1,   6,   6 ]     PPI::Token::Number       '1'

If you follow the period with something other than 'e', the float parses all right:

ppidump "1.ne 1"
                    PPI::Document
                      PPI::Statement
[    1,   1,   1 ]     PPI::Token::Number::Float        '1.'
[    1,   3,   3 ]     PPI::Token::Operator     'ne'
[    1,   6,   6 ]     PPI::Token::Number       '1'
wchristian commented 9 years ago

@moregan : Pushed a branch with a fix for this, please double-check that it looks sane.

wchristian commented 9 years ago

@moregan : Changed the branch as per your email comments (mostly) and repushed. Please have a look again. :)

moregan commented 9 years ago

Looks good. When you're happy with it, I can run it through my process that detects parse changes. I would expect nearly zero changes, since most of the cases involved don't parse as Perl.

wchristian commented 9 years ago

Please do, once you've confirmed it doesn't regress i'll master it.

moregan commented 9 years ago

No parsing differences in my 113,000 perl files from CPAN.