Permalink
Browse files

implement m:/\Q\E/

  • Loading branch information...
1 parent 67fcb5f commit dc5a1ff741055b408796e1973c35e291addb4fe5 @FROGGS FROGGS committed Dec 15, 2013
Showing with 33 additions and 2 deletions.
  1. +19 −0 src/Perl6/Actions.nqp
  2. +13 −1 src/Perl6/Grammar.nqp
  3. +1 −1 tools/build/NQP_REVISION
View
@@ -6599,6 +6599,25 @@ class Perl6::P5RegexActions is QRegex::P5Regex::Actions does STDActions {
:rxtype<subrule>, :subtype<method>, :node($/));
}
+ method p5metachar:sym<var>($/) {
+ if $*INTERPOLATE {
+ make QAST::Regex.new( QAST::Node.new(
+ QAST::SVal.new( :value('INTERPOLATE') ),
+ $<var>.ast,
+ QAST::IVal.new( :value(%*RX<i> ?? 1 !! 0) ),
+ QAST::IVal.new( :value($*SEQ ?? 1 !! 0) ),
+ QAST::IVal.new( :value(1) ) ),
+ :rxtype<subrule>, :subtype<method>, :node($/));
+ }
+ else {
+ make QAST::Regex.new( QAST::Node.new(
+ QAST::SVal.new( :value('!LITERAL') ),
+ $<var>.ast,
+ QAST::IVal.new( :value(%*RX<i> ?? 1 !! 0) ) ),
+ :rxtype<subrule>, :subtype<method>, :node($/));
+ }
+ }
+
method codeblock($/) {
my $blockref := $<block>.ast;
my $past :=
View
@@ -2485,6 +2485,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
token regex_declarator:sym<rule> {
<sym>
:my %*RX;
+ :my $*INTERPOLATE := 1;
:my $*METHODTYPE := 'rule';
:my $*IN_DECL := 'rule';
{
@@ -2496,6 +2497,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
token regex_declarator:sym<token> {
<sym>
:my %*RX;
+ :my $*INTERPOLATE := 1;
:my $*METHODTYPE := 'token';
:my $*IN_DECL := 'token';
{
@@ -2506,6 +2508,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
token regex_declarator:sym<regex> {
<sym>
:my %*RX;
+ :my $*INTERPOLATE := 1;
:my $*METHODTYPE := 'regex';
:my $*IN_DECL := 'regex';
<regex_def>
@@ -2925,12 +2928,14 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
token quote:sym</null/> { '/' \s* '/' <.typed_panic: "X::Syntax::Regex::NullRegex"> }
token quote:sym</ /> {
:my %*RX;
+ :my $*INTERPOLATE := 1;
'/' <nibble(self.quote_lang(%*LANG<Regex>, '/', '/'))> [ '/' || <.panic: "Unable to parse regex; couldn't find final '/'"> ]
<.old_rx_mods>?
}
token quote:sym<rx> {
<sym> >>
:my %*RX;
+ :my $*INTERPOLATE := 1;
<rx_adverbs>
<quibble(%*RX<P5> ?? %*LANG<P5Regex> !! %*LANG<Regex>)>
<!old_rx_mods>
@@ -2939,6 +2944,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
token quote:sym<m> {
<sym> (s)**0..1>>
:my %*RX;
+ :my $*INTERPOLATE := 1;
{ %*RX<s> := 1 if $/[0] }
<rx_adverbs>
<quibble(%*RX<P5> ?? %*LANG<P5Regex> !! %*LANG<Regex>)>
@@ -2976,6 +2982,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
token quote:sym<s> {
<sym> (s)**0..1 >>
:my %*RX;
+ :my $*INTERPOLATE := 1;
{
%*RX<s> := 1 if $/[0]
}
@@ -3004,6 +3011,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
token quote:sym<tr> {
<sym>
:my %*RX;
+ :my $*INTERPOLATE := 1;
<rx_adverbs>
<tribble(%*RX<P5> ?? %*LANG<P5Regex> !! %*LANG<Regex>, %*LANG<Q>, ['cc'])>
<.old_rx_mods>?
@@ -4232,7 +4240,11 @@ grammar Perl6::P5RegexGrammar is QRegex::P5Regex::Grammar does STD {
token p5metachar:sym<(??{ })> {
'(??' <?[{]> <codeblock> ')'
}
-
+
+ token p5metachar:sym<var> {
+ <?[$]> <var=.LANG('MAIN', 'variable')>
+ }
+
token codeblock {
<block=.LANG('MAIN','block')>
}
View
@@ -1 +1 @@
-2013.11.1-81-gf7176a8
+2013.11.1-82-g565cce8

0 comments on commit dc5a1ff

Please sign in to comment.