Skip to content

Commit

Permalink
Use 6.e Grammar class as default for grammar decalarations
Browse files Browse the repository at this point in the history
Do it with EXPORTHOW and specialized HOW metaclass.
  • Loading branch information
vrurg committed Sep 1, 2019
1 parent 617999c commit 46c0503
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/core.c/Grammar.pm6
Expand Up @@ -28,9 +28,9 @@ my class Grammar is Match {
),
$match := ($cursor := $cursor.'!cursor_next'()).MATCH
),
$match || Nil,
$match || Nil
),
Nil,
Nil
)
)
)
Expand Down
7 changes: 4 additions & 3 deletions src/core.c/core_prologue.pm6
@@ -1,3 +1,7 @@
# This constant must specify current CORE revision.
# Must preceede class declarations to allow correct recording of their respective language version.
my constant CORE-SETTING-REV = 'c';

# Stub a few things the compiler wants to have really early on.
my class Pair { ... } # must be first for some reason
my class Block { ... }
Expand Down Expand Up @@ -67,7 +71,4 @@ PROCESS::<$SCHEDULER> = JavaScriptScheduler.new();
BEGIN {nqp::p6setassociativetype(Associative);}
#?endif

# This constant must specify current CORE revision
my constant CORE-SETTING-REV = 'c';

# vim: ft=perl6 expandtab sw=4
1 change: 1 addition & 0 deletions src/core.d/core_prologue.pm6
@@ -1,6 +1,7 @@
use nqp;

# This constant must specify current CORE revision
# Must preceede class declarations to allow correct recording of their respective language version.
my constant CORE-SETTING-REV = 'd';

# vim: ft=perl6 expandtab sw=4
17 changes: 17 additions & 0 deletions src/core.e/EXPORTHOW.pm6
@@ -0,0 +1,17 @@
# Bind the HOWs into the EXPORTHOW package under the package declarator
# names.

{
# Don't expose this name in CORE's namespace
class Perl6::Metamodel::v6e::GrammarHOW
is Perl6::Metamodel::ClassHOW
does Perl6::Metamodel::DefaultParent
{
}

# Set 6.e Grammar as the default for grammars
Perl6::Metamodel::v6e::GrammarHOW.set_default_parent_type(Grammar);
EXPORTHOW.WHO<grammar> := Perl6::Metamodel::v6e::GrammarHOW;
}

# vim: ft=perl6 expandtab sw=4
1 change: 1 addition & 0 deletions src/core.e/core_prologue.pm6
@@ -1,6 +1,7 @@
use nqp;

# This constant must specify current CORE revision
# Must preceede class declarations to allow correct recording of their respective language version.
my constant CORE-SETTING-REV = 'e';

# vim: ft=perl6 expandtab sw=4
1 change: 1 addition & 0 deletions tools/templates/6.e/core_sources
@@ -1,3 +1,4 @@
src/core.e/core_prologue.pm6
src/core.e/PseudoStash.pm6
src/core.e/Grammar.pm6
src/core.e/EXPORTHOW.pm6

0 comments on commit 46c0503

Please sign in to comment.