diff --git a/src/Regex/P6Grammar.pir b/src/Regex/P6Grammar.pir index b35705b..3db5703 100644 --- a/src/Regex/P6Grammar.pir +++ b/src/Regex/P6Grammar.pir @@ -16,7 +16,7 @@ Regex::P6Grammar - scaffolding compiler for NQP / Perl 6 grammars load_bytecode 'p6regex.pbc' .local pmc p6meta, p6grammar p6meta = get_hll_global 'P6metaclass' - p6grammar = p6meta.'new_class'('Regex::P6Grammar', 'parent'=>'PCT::HLLCompiler') + p6grammar = p6meta.'new_class'('Regex::P6Grammar::Compiler', 'parent'=>'PCT::HLLCompiler') p6grammar.'language'('Regex::P6Grammar') $P0 = get_hll_namespace ['Regex';'P6Grammar';'Grammar'] p6grammar.'parsegrammar'($P0) diff --git a/src/Regex/P6Grammar/Actions.pm b/src/Regex/P6Grammar/Actions.pm index 17f7410..dd9a111 100644 --- a/src/Regex/P6Grammar/Actions.pm +++ b/src/Regex/P6Grammar/Actions.pm @@ -1,7 +1,7 @@ class Regex::P6Grammar::Actions is Regex::P6Regex::Actions; method TOP($/) { - my $past := PAST::Stmts.new(); + my $past := $.ast; for $ { $past.push( $_.ast ); } @@ -9,6 +9,22 @@ method TOP($/) { } +method grammar_stmt($/) { + my @ns := Regex::P6Grammar::Compiler.parse_name( ~$ ); + my $past := PAST::Block.new( :namespace(@ns) ); + my $init := + PAST::Op.new( + PAST::Var.new( :name('P6metaclass'), :scope('package'), + :namespace('') ), + ~$, + PAST::Val.new( :value('Regex::Cursor'), :named('parent') ), + :pasttype('callmethod'), :name('new_class') + ); + $past.loadinit($init); + make $past; +} + + method regex_stmt($/, $key?) { my @MODIFIERS := Q:PIR { %r = get_hll_global ['Regex';'P6Regex';'Actions'], '@MODIFIERS'