Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created October 10, 2017 23:33
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 zoffixznet/ff4aa31a820449793bcd6b2d9d44ead2 to your computer and use it in GitHub Desktop.
Save zoffixznet/ff4aa31a820449793bcd6b2d9d44ead2 to your computer and use it in GitHub Desktop.
diff --git a/src/Perl6/Grammar.nqp b/src/Perl6/Grammar.nqp
index 730b764..409315a 100644
--- a/src/Perl6/Grammar.nqp
+++ b/src/Perl6/Grammar.nqp
@@ -62,6 +62,15 @@ role STD {
token stopper { <!> }
my %quote_lang_cache := nqp::hash();
+ method quote_lang_clear_cache() {
+ nqp::say("CLEARING CACHE")
+ if nqp::atkey(nqp::getenvhash(), 'ZZZ2');
+ nqp::say('ZZ (' ~ nqp::elems(%quote_lang_cache) ~ ')')
+ if nqp::atkey(nqp::getenvhash(), 'ZZZ');
+ nqp::deletekey(%quote_lang_cache,$_) for %quote_lang_cache;
+ nqp::say('ZZ (' ~ nqp::elems(%quote_lang_cache) ~ ')')
+ if nqp::atkey(nqp::getenvhash(), 'ZZZ');
+ }
method quote_lang($l, $start, $stop, @base_tweaks?, @extra_tweaks?) {
sub lang_key() {
my $stopstr := nqp::istype($stop,VMArray) ?? nqp::join(' ',$stop) !! $stop;
@@ -71,11 +80,16 @@ role STD {
}
for @extra_tweaks {
if $_[0] eq 'to' {
+ nqp::say("BAILING - NOCACHE")
+ if nqp::atkey(nqp::getenvhash(), 'ZZZ2');
return 'NOCACHE';
}
@keybits.push($_[0] ~ '=' ~ $_[1]);
}
- nqp::join("\0", @keybits)
+ my $v := nqp::join("\0", @keybits);
+ nqp::say($l.HOW.name($l) ~ ' ' ~ $v ~ '(' ~ nqp::elems(%quote_lang_cache) ~ ')')
+ if nqp::atkey(nqp::getenvhash(), 'ZZZ');
+ $v
}
sub con_lang() {
my $lang := $l.'!cursor_init'(self.orig(), :p(self.pos()), :shared(self.'!shared'()));
@@ -4752,6 +4766,9 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
'infix:sym<~~>', '(consider implementing an ACCEPTS method)',
'prefix:sym<|>', NQPMu);
method add_categorical($category, $opname, $canname, $subname, $declarand?, :$defterm) {
+ nqp::say("adding categorical")
+ if nqp::atkey(nqp::getenvhash(), 'ZZZ2');
+
my $actions := self.actions;
# Ensure it's not a null name or a compiler-handled op.
@@ -4906,6 +4923,8 @@ if $*COMPILING_CORE_SETTING {
}
self.HOW.mixin(self, Circumfix.HOW.curry(Circumfix, $canname, @parts[0], @parts[1]));
}
+ # dump cached quote langs, since we modified our main lang
+ Perl6::QGrammar.quote_lang_clear_cache();
# This also becomes the current MAIN. Also place it in %?LANG.
%*LANG<MAIN> := self.WHAT;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment