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

Foo::_foo() parsefails #950

Closed
p6rt opened this issue Apr 25, 2009 · 10 comments
Closed

Foo::_foo() parsefails #950

p6rt opened this issue Apr 25, 2009 · 10 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Apr 25, 2009

Migrated from rt.perl.org#65138 (status was 'resolved')

Searchable as RT65138$

@p6rt
Copy link
Author

p6rt commented Apr 25, 2009

From @japhb

Rakudo doesn't parse Foo​::_foo() properly, while Foo​::foo() works fine.

Before patch​:

$ ./perl6 -e 'module Foo { sub _foo { say "foo" } }; Foo​::_foo()'
Statement not terminated properly at line 1, near "_foo()"

current instr.​: 'parrot;PGE;Util;die' pc 129 (runtime/parrot/library/PGE/Util.pir​:85)
called from Sub 'parrot;Perl6;Grammar;eat_terminator' pc 86107 (src/gen_grammar.pir​:2292)
called from Sub 'parrot;Perl6;Grammar;statementlist' pc 84764 (src/gen_grammar.pir​:1770)
called from Sub 'parrot;Perl6;Grammar;statement_block' pc 82197 (src/gen_grammar.pir​:750)
called from Sub 'parrot;Perl6;Grammar;TOP' pc 76936 (src/gen_setting.pir​:16404)
called from Sub 'parrot;PCT;HLLCompiler;parse' pc 665 (src/PCT/HLLCompiler.pir​:402)
called from Sub 'parrot;PCT;HLLCompiler;compile' pc 428 (src/PCT/HLLCompiler.pir​:303)
called from Sub 'parrot;PCT;HLLCompiler;eval' pc 920 (src/PCT/HLLCompiler.pir​:521)
called from Sub 'parrot;PCT;HLLCompiler;command_line' pc 1510 (src/PCT/HLLCompiler.pir​:800)
called from Sub 'parrot;Perl6;Compiler;main' pc 23787 (perl6.pir​:164)

After patch​:

$ ./perl6 -e 'module Foo { sub _foo { say "foo" } }; Foo​::_foo()'
foo

The patch is trivial​:

Inline Patch
diff --git a/src/parser/grammar.pg b/src/parser/grammar.pg
index 50b95e7..9c0b5b2 100644
--- a/src/parser/grammar.pg
+++ b/src/parser/grammar.pg
@@ -815,7 +815,7 @@ token name {
 token morename {
     '::'
     [
-        <?before '(' | <alpha> >
+        <?before '(' | <ident> >
         [
         | <identifier>
         | '(' <EXPR> ')'


I was unable to add a test for this, as for some reason I can't checkout the spectest suite right now \.\.\.\.

-'f

@p6rt
Copy link
Author

p6rt commented Apr 26, 2009

From @moritz

On Sat Apr 25 16​:33​:44 2009, japhb wrote​:

token morename {
'​::'
[
- <?before '(' | <alpha> >
+ <?before '(' | <ident> >
[
| <identifier>
| '(' <EXPR> ')'

In STD.pm the token alpha is define is <ident> \w* - so maybe even
<?before '(' | \w >
would be enough?
At least it makes your test pass, and the test suite is also clean.

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Apr 26, 2009

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Apr 27, 2009

From @pmichaud

On Sat, Apr 25, 2009 at 04​:33​:44PM -0700, Geoffrey Broadwell wrote​:

Rakudo doesn't parse Foo​::_foo() properly, while Foo​::foo() works fine.
[...]
$ ./perl6 -e 'module Foo { sub _foo { say "foo" } }; Foo​::_foo()'
Statement not terminated properly at line 1, near "_foo()"

While the patch appears to solve the issue, it also deviates from
the definition given in STD.pm, which uses <alpha> instead of <ident>.
(Also, testing for <ident> is a fair bit more expensive than simply
testing for <alpha>.)

STD.pm appears to parse the above okay, though, so we need to
determine why STD.pm is succeeding here and see if Rakudo should
match that.

Patch rejected (for now), but we'll leave the ticket open until
we can find a solution to the leading underscore problem.

Thanks!

Pm

@p6rt
Copy link
Author

p6rt commented Apr 27, 2009

From @pmichaud

On Mon, Apr 27, 2009 at 08​:31​:38AM -0500, Patrick R. Michaud wrote​:

On Sat, Apr 25, 2009 at 04​:33​:44PM -0700, Geoffrey Broadwell wrote​:

Rakudo doesn't parse Foo​::_foo() properly, while Foo​::foo() works fine.
[...]
$ ./perl6 -e 'module Foo { sub _foo { say "foo" } }; Foo​::_foo()'
Statement not terminated properly at line 1, near "_foo()"

While the patch appears to solve the issue, it also deviates from
the definition given in STD.pm, which uses <alpha> instead of <ident>.
(Also, testing for <ident> is a fair bit more expensive than simply
testing for <alpha>.)

STD.pm appears to parse the above okay, though, so we need to
determine why STD.pm is succeeding here and see if Rakudo should
match that.

Answered on #perl6​:
  16​:14 <TimToady> pmichaud​: _ is considered an alpha

So, we need to patch PGE so that <alpha> matches underscore, and
we need some tests to match.

Pm

@p6rt
Copy link
Author

p6rt commented Apr 27, 2009

From @coke

On Mon, Apr 27, 2009 at 12​:26 PM, Patrick R. Michaud <pmichaud@​pobox.com> wrote​:

Answered on #perl6​:
   16​:14 <TimToady> pmichaud​: _ is considered an alpha

So, we need to patch PGE so that <alpha> matches underscore, and
we need some tests to match.

Pm

Created TT #​585 for parrot to track this issue.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Apr 27, 2009

From @pmichaud

Now fixed in f93154a.

We need to verify there's a spectest for this particular
problem. We should also add spectests to make sure that <alpha>
matches underscores.

Assigning to moritz++ for test updates.

Thanks!

Pm

1 similar comment
@p6rt
Copy link
Author

p6rt commented Apr 27, 2009

From @pmichaud

Now fixed in f93154a.

We need to verify there's a spectest for this particular
problem. We should also add spectests to make sure that <alpha>
matches underscores.

Assigning to moritz++ for test updates.

Thanks!

Pm

@p6rt
Copy link
Author

p6rt commented Apr 27, 2009

From @moritz

Test added to t/spec/S02-names_and_variables/names.t

Cheers,
Moritz

@p6rt p6rt closed this as completed Apr 27, 2009
@p6rt
Copy link
Author

p6rt commented Apr 27, 2009

@moritz - Status changed from 'open' to 'resolved'

@p6rt p6rt added the patch label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant