Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"a".1234 parsed as a string and a float #165

Open
finnperl opened this issue Jan 28, 2015 · 1 comment
Open

"a".1234 parsed as a string and a float #165

finnperl opened this issue Jan 28, 2015 · 1 comment

Comments

@finnperl
Copy link

I wanted to report this since I find this module very useful Example code:

use PPI;
use Data::Dumper;
print Dumper(PPI::Document->new('"a".1'));

The output is:

$VAR1 = bless( {
'readonly' => '',
'children' => [
bless( {
'children' => [
bless( {
'separator' => '"',
'content' => '"a"'
}, 'PPI::Token::Quote::Double' ),
bless( {
'content' => '.1'
}, 'PPI::Token::Number::Float' )
]
}, 'PPI::Statement' )
],
'tab_width' => 1
}, 'PPI::Document' );

However, for example

perl -e 'print "a".1'

outputs a1, which implies that perl is able to detect . as the concat operator. Looking at the tokenizer, it seems that PPI does not look backwards when it is checking whether . is an operator or part of a float.

@moregan
Copy link
Collaborator

moregan commented Jan 28, 2015

Confirmed in PPI 1.220 and on my development branches.

ppidump '"a".1'
                    PPI::Document
                      PPI::Statement
[    1,   1,   1 ]     PPI::Token::Quote::Double    '"a"'
[    1,   4,   4 ]     PPI::Token::Number::Float    '.1'

Thank you for your report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants