Skip to content

Instantly share code, notes, and snippets.

@felliott
Created January 7, 2011 13:39
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 felliott/769459 to your computer and use it in GitHub Desktop.
Save felliott/769459 to your computer and use it in GitHub Desktop.
From a21a4c40ef851291584a9ce1eaf9f7a196fdbd7b Mon Sep 17 00:00:00 2001
From: Fitz Elliott <felliott@virginia.edu>
Date: Wed, 5 Jan 2011 12:43:56 -0500
Subject: [PATCH] add thundergnat++'s patch to implement chained ^^s
---
src/Perl6/Grammar.pm | 2 +-
src/core/operators.pm | 15 +++++++++++++++
2 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/src/Perl6/Grammar.pm b/src/Perl6/Grammar.pm
index 5f0c8b2..4391a5b 100644
--- a/src/Perl6/Grammar.pm
+++ b/src/Perl6/Grammar.pm
@@ -1885,7 +1885,7 @@ token dumbsmart {
token infix:sym<&&> { <sym> <O('%tight_and, :pasttype<if>')> }
token infix:sym<||> { <sym> <O('%tight_or, :assoc<left>, :pasttype<unless>')> }
-token infix:sym<^^> { <sym> <O('%tight_or, :pasttype<xor>')> }
+token infix:sym<^^> { <sym> <O('%tight_or')> }
token infix:sym<//> { <sym> <O('%tight_or, :assoc<left>, :pasttype<def_or>')> }
token infix:sym<min> { <sym> >> <O('%tight_or')> }
token infix:sym<max> { <sym> >> <O('%tight_or')> }
diff --git a/src/core/operators.pm b/src/core/operators.pm
index 75840d8..eba3d13 100644
--- a/src/core/operators.pm
+++ b/src/core/operators.pm
@@ -503,6 +503,21 @@ our multi sub infix:<X>($lhs, $rhs) {
}
}
+
+our multi sub infix:<^^>(*@a) {
+ return [^^] @a;
+}
+
+our multi sub prefix:<[^^]>(*@a) {
+ my $a = shift @a;
+ for @a -> $b
+ {
+ return Bool::False if $b && $a;
+ $a ||= $b;
+ };
+ return $a || Bool::False;
+}
+
# if we want &infix:<||> accessible (for example for meta operators), we need
# to define it, because the normal || is short-circuit and special cased by
# the grammar. Same goes for 'or', '&&' and 'and'
--
1.7.3.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment