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

RT 67831: implicit statement end not recognized for perl 5.12-style package #70

Closed
moregan opened this issue Mar 16, 2014 · 3 comments
Closed
Labels
Milestone

Comments

@moregan
Copy link
Collaborator

moregan commented Mar 16, 2014

https://rt.cpan.org/Public/Bug/Display.html?id=67831

PPI 1.1.215/1.216_01 do not recognize the implicit end of statement that follows the block in a Perl 5.12 package statement:

ppidump 'package Foo {} sub bar { 1; }'
                    PPI::Document
                      PPI::Statement::Package
[    1,   1,   1 ]     PPI::Token::Word         'package'
[    1,   9,   9 ]     PPI::Token::Word         'Foo'
                        PPI::Structure::Block   { ... }
[    1,  16,  16 ]     PPI::Token::Word         'sub'
[    1,  20,  20 ]     PPI::Token::Word         'bar'
                        PPI::Structure::Block   { ... }
                          PPI::Statement
[    1,  26,  26 ]         PPI::Token::Number   '1'
[    1,  27,  27 ]         PPI::Token::Structure        ';'

With an explicit statement terminator, it's fine:

ppidump 'package Foo {} ; sub bar { 1; }'
                    PPI::Document
                      PPI::Statement::Package
[    1,   1,   1 ]     PPI::Token::Word         'package'
[    1,   9,   9 ]     PPI::Token::Word         'Foo'
                        PPI::Structure::Block   { ... }
[    1,  16,  16 ]     PPI::Token::Structure    ';'
                      PPI::Statement::Sub
[    1,  18,  18 ]     PPI::Token::Word         'sub'
[    1,  22,  22 ]     PPI::Token::Word         'bar'
                        PPI::Structure::Block   { ... }
                          PPI::Statement
[    1,  28,  28 ]         PPI::Token::Number   '1'
[    1,  29,  29 ]         PPI::Token::Structure        ';'

The RT ticket includes a patch.

@moregan
Copy link
Collaborator Author

moregan commented Mar 21, 2014

RFC: In the 5.12 "package name version BLOCK" syntax, PPI currently can parse the version component as a float:

ppidump 'package foo 1.11;'
                    PPI::Document
                      PPI::Statement::Package
[    1,   1,   1 ]     PPI::Token::Word         'package'
[    1,   9,   9 ]     PPI::Token::Word         'foo'
[    1,  13,  13 ]     PPI::Token::Number::Float        '1.11'
[    1,  17,  17 ]     PPI::Token::Structure    ';'

though perl does recognize it:

perl -WE 'package foo 1.11 { print $VERSION }'
1.11

Should PPI force anything that can be a version to be a PPI::Token::Number::Version?

@moregan
Copy link
Collaborator Author

moregan commented Mar 25, 2014

Statements like use 5.020 don't have their versions parsed as Versions. Going with the flow would seem to be to leave Float version numbers as Floats.

@wchristian
Copy link
Member

Merged into master with some refactoring.

@wchristian wchristian added this to the 1.222 milestone Nov 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants