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

Grammar breaks intermittently after changing role to grammar #2933

Open
hythm7 opened this issue May 28, 2019 · 6 comments
Open

Grammar breaks intermittently after changing role to grammar #2933

hythm7 opened this issue May 28, 2019 · 6 comments

Comments

@hythm7
Copy link

hythm7 commented May 28, 2019

I have a grammar that broke after updating rakudo to latest: i made a small version of the grammar in this gist : https://gist.github.com/hythm7/dedb6638105029f7b103b7f99f04e323

in the gist there is output file, with the perl6 version that works consistently. basically latest breaks intermittently

Also please see https://colabti.org/irclogger/irclogger_log/perl6?date=2019-05-28#l723

Please check the comments below, I reopened the issue again because the grammar now breaks if used as grammar instead of a role.

Environment

  • Operating system: Linux
  • Compiler version (perl6 -v): This is Rakudo version 2019.03.1 built on MoarVM version 2019.03
    implementing Perl 6.d.
@hythm7
Copy link
Author

hythm7 commented May 28, 2019

Closing since building rakudo with rakudebrew build moar master instead of rakudobrew build moar fixed the issue.

@hythm7 hythm7 closed this as completed May 28, 2019
@hythm7
Copy link
Author

hythm7 commented Jun 6, 2019

Reopenning:
If changed role to grammar I see the issue again:

#!/usr/bin/env perl6

grammar Pkg {         # no issue if useing role

  token TOP { <pkg> }

  proto token pkg { * }

  token pkg:sym<tag>     { <name> <.hyphen> <version> <.hyphen> <arch> <.hyphen> <build> <.hyphen> <tag> <ext>? }
  token pkg:sym<build>   { <name> <.hyphen> <version> <.hyphen> <arch> <.hyphen> <form> <ext>? }
  token pkg:sym<arch>    { <name> <.hyphen> <version> <.hyphen> <arch> }
  token pkg:sym<version> { <name> <.hyphen> <version> }
  token pkg:sym<name>    { <name> }

  token name { [ [ <.alnum>+ <!before <dot>> ]+ % <hyphen> ] }
  token version  { [ [ <.digit>+ | '*' ]+ % <dot> ] <plus>? }
  token arch { 'x86_64' | 'i386' }
  token build { <.digit>+ }
  token tag  { <.alnum>+ }

  token ext { <.dot> 'ext' }

  token dot    { '.' }
  token plus   { '+' }
  token hyphen { '-' }
}

grammar Cmd {
  also is Pkg;

  rule TOP    { <pkgs> }

  token pkgs { [ <.pkg>+ % <.blank> ] }

}

say so Cmd.parse('raku-0.0.1');

Output:

hythm@galaxy$ for i in $(seq 10); do /tmp/grammar.p6; done
False
False
True
True
False
True
False
True
False
False

hythm@galaxy$ perl6 --version
This is Rakudo version 2019.03.1-572-g89f8f60 built on MoarVM version 2019.05-36-ge865f43
implementing Perl 6.d.

@hythm7 hythm7 reopened this Jun 6, 2019
@hythm7 hythm7 changed the title Grammar broke after updating to latest rakudo "2019.03.1" Grammar breaks intermittently after changing role to grammar Jun 7, 2019
@hythm7
Copy link
Author

hythm7 commented Jun 11, 2019

I tried the above grammar on few releases of moar, below table shows that grammar is working (consistently) with 2017.07, after that it breaks (intermittently) due to two reasons:

declaring grammar "Pkg" with grammar vs with role

Release  grammar   role
2017.07     ✓       ✓
2018.04     ✓       ✓
2018.05     ✗       ✗ 
2018.12     ✗       ✗ 
master      ✗       ✓

@ugexe
Copy link
Member

ugexe commented Jun 11, 2019

Your example doesn't help -- I changed your code grammar to role and got the same behavior

@hythm7
Copy link
Author

hythm7 commented Jun 11, 2019

Are you running latest perl6?

#!/usr/bin/env perl6

role Pkg {

  token TOP { <pkg> }

  proto token pkg { * }

  token pkg:sym<tag>     { <name> <.hyphen> <version> <.hyphen> <arch> <.hyphen> <build> <.hyphen> <tag> <ext>? }
  token pkg:sym<build>   { <name> <.hyphen> <version> <.hyphen> <arch> <.hyphen> <form> <ext>? }
  token pkg:sym<arch>    { <name> <.hyphen> <version> <.hyphen> <arch> }
  token pkg:sym<version> { <name> <.hyphen> <version> }
  token pkg:sym<name>    { <name> }

  token name { [ [ <.alnum>+ <!before <dot>> ]+ % <hyphen> ] }
  token version  { [ [ <.digit>+ | '*' ]+ % <dot> ] <plus>? }
  token arch { 'x86_64' | 'i386' }
  token build { <.digit>+ }
  token tag  { <.alnum>+ }

  token ext { <.dot> 'ext' }

  token dot    { '.' }
  token plus   { '+' }
  token hyphen { '-' }
}

grammar Cmd {
  also does Pkg;

  rule TOP    { <pkgs> }

  token pkgs { [ <.pkg>+ % <.blank> ] }

}

say so Cmd.parse('raku-0.0.1');


hythm@galaxy$ for i in $(seq 7); do /tmp/grammar.p6; done
True
True
True
True
True
True
True

hythm@galaxy$ perl6 --version
This is Rakudo version 2019.03.1-594-gbed0695 built on MoarVM version 2019.05-53-gcce71cd
implementing Perl 6.d.

@hythm7
Copy link
Author

hythm7 commented Jun 11, 2019

/usr/bin/env perl6

grammar Pkg {

  token TOP { <pkg> }

  proto token pkg { * }

  token pkg:sym<tag>     { <name> <.hyphen> <version> <.hyphen> <arch> <.hyphen> <build> <.hyphen> <tag> <ext>? }
  token pkg:sym<build>   { <name> <.hyphen> <version> <.hyphen> <arch> <.hyphen> <form> <ext>? }
  token pkg:sym<arch>    { <name> <.hyphen> <version> <.hyphen> <arch> }
  token pkg:sym<version> { <name> <.hyphen> <version> }
  token pkg:sym<name>    { <name> }

  token name { [ [ <.alnum>+ <!before <dot>> ]+ % <hyphen> ] }
  token version  { [ [ <.digit>+ | '*' ]+ % <dot> ] <plus>? }
  token arch { 'x86_64' | 'i386' }
  token build { <.digit>+ }
  token tag  { <.alnum>+ }

  token ext { <.dot> 'ext' }

  token dot    { '.' }
  token plus   { '+' }
  token hyphen { '-' }
}

grammar Cmd {
  also is Pkg;

  rule TOP    { <pkgs> }

  token pkgs { [ <.pkg>+ % <.blank> ] }

}

say so Cmd.parse('raku-0.0.1');


hythm@galaxy$ for i in $(seq 7); do /tmp/grammar.p6; done
True
True
False
True
False
True
False

hythm@galaxy$ perl6 --version
This is Rakudo version 2019.03.1-594-gbed0695 built on MoarVM version 2019.05-53-gcce71cd
implementing Perl 6.d.

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

No branches or pull requests

2 participants