# New Ticket Created by Konrad Borowski
# Please include the string: [perl #123496]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=123496 >
---
src/Perl6/Grammar.nqp | 32 +++++++++++++++++++++++---------
src/core/Exception.pm | 7 +++++++
2 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/src/Perl6/Grammar.nqp b/src/Perl6/Grammar.nqp
index 2000376..69bef42 100644
--- a/src/Perl6/Grammar.nqp
+++ b/src/Perl6/Grammar.nqp
@@ -1576,15 +1576,29 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
$<doc>=[ 'DOC' \h+ ]**0..1
<sym> <.ws>
[
- | <version> [ <?{ ~$<version><vnum>[0] eq '5' }> {
- my $module := $*W.load_module($/, 'Perl5', {},
$*GLOBALish);
- do_import($/, $module, 'Perl5');
- $/.CURSOR.import_EXPORTHOW($/, $module);
- } ]?
- [ <?{ ~$<version><vnum>[0] eq '6' }> {
- $*MAIN := 'MAIN';
- $*STRICT := 1 if $*begin_compunit;
- } ]?
+ | <version> [
+ || <?{ $<version><vnum>[0] == 5 }> {
+ my $module := $*W.load_module($/, 'Perl5', {},
$*GLOBALish);
+ do_import($/, $module, 'Perl5');
+ $/.CURSOR.import_EXPORTHOW($/, $module);
+ }
+ || <?{ $<version><vnum>[0] == 6 }> {
+ my $version_parts := $<version><vnum>;
+ my $tokens := +$version_parts;
+ my $position := 1;
+ while $position < $tokens {
+ if $version_parts[$position] != 0 {
+ $/.CURSOR.typed_panic:
'X::Language::Unsupported', version => ~$<version>;
+ }
+ $position++;
+ }
+ $*MAIN := 'MAIN';
+ $*STRICT := 1 if $*begin_compunit;
+ }
+ || {
+ $/.CURSOR.typed_panic: 'X::Language::Unsupported',
version => ~$<version>;
+ }
+ ]
| <module_name>
{
$longname := $<module_name><longname>;
diff --git a/src/core/Exception.pm b/src/core/Exception.pm
index 1bc3739..4b26419 100644
--- a/src/core/Exception.pm
+++ b/src/core/Exception.pm
@@ -1614,4 +1614,11 @@ my class X::EXPORTHOW::Conflict does X::Comp {
}
}
+my class X::Language::Unsupported is Exception {
+ has $.version;
+ method message() {
+ "No compiler available for Perl $.version"
+ }
+}
+
# vim: ft=perl6 expandtab sw=4
--
2.2.1