Skip to content

Instantly share code, notes, and snippets.

@moritz
Created September 27, 2011 19:09
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 moritz/1245934 to your computer and use it in GitHub Desktop.
Save moritz/1245934 to your computer and use it in GitHub Desktop.
add Match.ast, &make -- slightly borked
From bf992eb4399c387a0ab19de90fe5c7bf0a9e5d9a Mon Sep 17 00:00:00 2001
From: Moritz Lenz <moritz@faui2k3.org>
Date: Tue, 27 Sep 2011 21:07:06 +0200
Subject: [PATCH] add Match.ast, &make (not working)
---
src/core/Match.pm | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/src/core/Match.pm b/src/core/Match.pm
index 099de8e..0b7f267 100644
--- a/src/core/Match.pm
+++ b/src/core/Match.pm
@@ -3,6 +3,7 @@ my class Match is Capture {
has $.from;
has $.to;
has $.CURSOR;
+ has $.ast;
multi method gist(Match:D:) {
$!to > $!from ?? $!orig.substr($!from, $!to-$!from) !! ''
@@ -51,3 +52,12 @@ my class Match is Capture {
}
}
}
+
+sub make(Mu $ast) {
+ nqp::bindattr(
+ pir::find_caller_lex__Ps('$/'),
+ Match,
+ '$!ast',
+ $ast
+ );
+}
--
1.7.2.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment