Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
rename regex grammar/actions, and setup grep/map/sort grammar
  • Loading branch information
FROGGS committed May 17, 2013
1 parent b5ea707 commit 74866d9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
27 changes: 17 additions & 10 deletions lib/Perl5/Actions.nqp
Expand Up @@ -3964,6 +3964,13 @@ class Perl5::Actions is HLL::Actions does STDActions {
return $past;
}

method term:sym<blocklist>($/) {
$V5DEBUG && say("term:sym<blocklist>($/)");
# my $past := $<args>.ast;
# $past.unshift( self.make_indirect_lookup(['&' ~ $<identifier>]) );
# make $past;
}

method term:sym<identifier>($/) {
$V5DEBUG && say("term:sym<identifier>($/)");
my $past := $<args>.ast;
Expand Down Expand Up @@ -6279,15 +6286,15 @@ class Perl5::QActions is HLL::Actions does STDActions {
}
}
#class Perl6::P5RegexActions is QRegex::P5Regex::Actions does STDActions {
# method create_regex_code_object($block) {
# $*W.create_code_object($block, 'Regex',
# $*W.create_signature(nqp::hash('parameters', [])))
# }
#
# method store_regex_nfa($code_obj, $block, $nfa) {
# $code_obj.SET_NFA($nfa.save);
# }
#}
class Perl5::RegexActions is QRegex::P5Regex::Actions does STDActions {
method create_regex_code_object($block) {
$*W.create_code_object($block, 'Regex',
$*W.create_signature(nqp::hash('parameters', [])))
}

method store_regex_nfa($code_obj, $block, $nfa) {
$code_obj.SET_NFA($nfa.save);
}
}

# vim: ft=perl6
23 changes: 11 additions & 12 deletions lib/Perl5/Grammar.nqp
Expand Up @@ -335,7 +335,7 @@ role STD5 {
my $name := $varast.name;
if $name ne '%_' && $name ne '@_' && !$*W.is_lexical($name) {
if $var<sigil> ne '&' {
if !%pragmas<strict><vars> {
if !%pragmas<strict><vars> || ($*IN_SORT && ($name eq '$a' || $name eq '$b')) {

my $BLOCK := $*W.cur_lexpad();

Expand Down Expand Up @@ -3701,14 +3701,13 @@ grammar Perl5::Grammar is HLL::Grammar does STD5 {
<sym> <O('%comma, :fiddly<0>')>
}

token term:sym<blocklist>
{
# :my $name;
# :my $pos;
$<identifier> = ['map'|'grep'|'sort'] <.ws>
[ :my $*IN_SORT := $<identifier>.Str eq 'sort'; <?before '{'> <block> <.ws>]?
<arglist>
# { self.add_mystery($name,$pos,substr($*ORIG,$pos,1)) unless $<args><invocant>; }
token term:sym<blocklist> {
:my $*IN_SORT := 0;
$<identifier> = [ 'map' |'grep' | 'sort' { $*IN_SORT := 1; } ] <.ws>
[
| '(' ~ ')' [ [ <?before '{'> <block> <.ws> ]? <arglist> ]
| [ [ <?before '{'> <block> <.ws> ]? <arglist> ]
]
<O('%term')>
}

Expand Down Expand Up @@ -4135,8 +4134,8 @@ grammar Perl5::QGrammar is HLL::Grammar does STD5 {
}
} # end grammar

#grammar Perl6::P5RegexGrammar is QRegex::P5Regex::Grammar does STD {
# token rxstopper { <stopper> }
#}
grammar Perl5::RegexGrammar is QRegex::P5Regex::Grammar does STD5 {
token rxstopper { <stopper> }
}

## vim: expandtab sw=4 ft=perl6

0 comments on commit 74866d9

Please sign in to comment.