Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@b2gills
Created September 8, 2017 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b2gills/7e2781dfd781368b63337c59bd751115 to your computer and use it in GitHub Desktop.
Save b2gills/7e2781dfd781368b63337c59bd751115 to your computer and use it in GitHub Desktop.
Partial Perl 6 implementations

This document is a guide for implementors of dialects of Perl 6

The restrictions here apply to only program files that can reasonably be assumed to be written in Perl 6 rather than your dialect of Perl 6.

  • Any file with an extension of .pl6 .p6 .pm6 can be assumed to be written in Perl 6.
  • Any file with an extension of .pl .pm can be assumed to be written in either Perl 5 or Perl 6 (or Perl 7).
  • Any file that has a use v6.c or similar statement can be assumed to be written in Perl 6.

If your implementation is given a Perl 6 program, it should fail to compile if that program uses a feature that your implementation does not have.

If your implementation re-uses a syntactic feature but does so incompatibly, it should require a Perl 6 program to have a use slang statement to enable your implementation to allow its use.

For example, if you reuse the grammar feature, but you use another parsing syntax.

The following should fail to compile:

use v6.c;
# BNF
grammar Foo {
  <bar> ::= "bar"
}

If your implementation doesn't know how to handle Perl 6 parsing syntax the following should also fail to compile.

use v6.c;
grammar Foo {
  token bar { "bar" }
}

While this can compile, and can use your incompatible parsing feature:

use v6.c;
# can be any module name of your choice
# (doesn't have to actually exist as a module)
use Slang::Grammar::BNF;

# BNF
grammar Foo {
  <bar> ::= "bar"
}

If your implementation is given a file that can reasonably be assumed to be in your specific dialect you do not need such a use statement, but it is highly recommended.

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