Skip to content

Commit

Permalink
rolled back a number of workarounds
Browse files Browse the repository at this point in the history
Things are starting to work almost as well as, sometimes better than, alpha.
This makes me very happy. :>
  • Loading branch information
Carl Masak committed May 31, 2010
1 parent 8677a65 commit 7a46c16
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 57 deletions.
27 changes: 7 additions & 20 deletions lib/GGE/Exp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,14 @@ class GGE::Exp is GGE::Match {

# RAKUDO: [perl #74454]
method getargs($label, $next, %hash is copy) {
# RAKUDO: Still waiting for hash slices to be brought back
# %hash<L S> = $label, $next;
%hash<L> = $label;
%hash<S> = $next;
%hash<L S> = $label, $next;
if %hash.exists('quant') {
my $quant = %hash<quant>;
%hash<m> = $quant<min>;
%hash<M> = %hash<m> == 0 ?? '### ' !! '';
%hash<n> = $quant<max>;
%hash<N> = %hash<n> == Inf ?? '### ' !! '';
# RAKUDO: Waiting for named enums for this one
# RAKUDO: Waiting for proper named enums for this one
# my $bt = ($quant<backtrack>
# // GGE::Exp::Backtracking::GREEDY).name.lc;
my $bt = 'no idea';
Expand Down Expand Up @@ -226,8 +223,7 @@ class GGE::Exp is GGE::Match {
}
}
}
# RAKUDO: Cannot do multiple returns yet.
return ($captgen, $captsave, $captback);
return $captgen, $captsave, $captback;
}
}

Expand Down Expand Up @@ -261,7 +257,7 @@ class GGE::Exp::Quant is GGE::Exp {
my ($min, $max, $bt) = map { self{$_} },
<min max backtrack>;
$bt //= GGE::Exp::Backtracking::GREEDY;
# RAKUDO: Named enums
# RAKUDO: Proper named enums
# "{$bt.name.lc} $min..$max"
"no idea $min..$max"
}
Expand All @@ -276,10 +272,7 @@ class GGE::Exp::Quant is GGE::Exp {
$seplabel = $code.unique('R');
$nextlabel = $label ~ '_sep';
}
# RAKUDO: Hash slices not implemented yet
# %args<c C> = 0, '### ';
%args<c> = 0;
%args<C> = '### ';
%args<c C> = 0, '### ';
given self<backtrack> {
when GGE::Exp::Backtracking::EAGER() {
$code.emit( q[[
Expand Down Expand Up @@ -313,10 +306,7 @@ class GGE::Exp::Quant is GGE::Exp {
} ]], $replabel, $nextlabel, |%args);
}
when GGE::Exp::Backtracking::NONE() {
# RAKUDO: Hash slices not implemented yet
# %args<c C> = $code.unique(), '';
%args<c> = $code.unique();
%args<C> = '';
%args<c C> = $code.unique(), '';
if self<min> != 0
|| self<max> != Inf {
proceed;
Expand Down Expand Up @@ -665,10 +655,7 @@ class GGE::Exp::CGroup is GGE::Exp::Group {
# RAKUDO: [perl #74454]
my %args = self.getargs($label, $next, {});
my ($captgen, $captsave, $captback) = self.gencapture($label);
# RAKUDO: Hash slices not implemented yet
# %args<c C> = self<cutmark>, '### ';
%args<c> = self<cutmark>;
%args<C> = '### ';
%args<c C> = self<cutmark>, '### ';
%args<X> = self<isscope> ?? '' !! '### ';
$code.emit( q[[
when '%L' { # capture
Expand Down
8 changes: 3 additions & 5 deletions lib/GGE/Match.pm
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,13 @@ class GGE::Match is Cool {
}

method Str() {
# RAKUDO: Stringification needed due to [perl #73462]
(~$!target).substr($!from, $!to - $!from)
$!target.substr($!from, $!to - $!from)
}

method postcircumfix:<{ }>($key) { %!properties{$key} }

# RAKUDO: All these can be shortened down to a 'handles' declaration,
# once Rakudo implements 'handles' again.
# once Rakudo implements 'handles' again. [perl #75386]
method exists($key) { %!properties.exists($key) }
method delete($key) { %!properties.delete($key) }
method keys() { %!properties.keys() }
Expand Down Expand Up @@ -117,8 +116,7 @@ class GGE::Match is Cool {
&& $target.substr($pos, 1) ~~ /\w/;
$mob.to = $pos;
}
# RAKUDO: Putting 'return' here makes Rakudo blow up.
$mob;
return $mob;
}

method name() {
Expand Down
14 changes: 4 additions & 10 deletions lib/GGE/OPTable.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use v6;
use GGE::Match;

class GGE::OPTable {
# RAKUDO: Must define these within the class for them to be visible.
# RAKUDO: Constants-in-classes broke after a merge. Working around.
##constant GGE_OPTABLE_EXPECT_TERM = 0x01;
##constant GGE_OPTABLE_EXPECT_OPER = 0x02;
Expand Down Expand Up @@ -78,22 +77,16 @@ class GGE::OPTable {

my $keylen = $key.chars;
my $key_firstchar = $key.substr(0, 1);
# RAKUDO: max=
if $key_firstchar && (!%!klen.exists($key_firstchar)
|| %!klen{$key_firstchar} < $keylen) {
%!klen{$key_firstchar} = $keylen;
}
%!klen{$key_firstchar} max= $keylen;

# RAKUDO: Comma after %opts shouldn't be necessary
(%!keys{$key} //= []).push({%opts,});
(%!keys{$key} //= []).push({%opts});
}

method parse($mob, *%opts) {
my $m = $mob ~~ GGE::Match ?? GGE::Match.new($mob)
!! GGE::Match.new(:target($mob), :from(0), :to(0));
my $target = $mob ~~ GGE::Match ?? $mob.target !! $mob;
# RAKUDO: Stringification needed due to [perl #73462]
$target = ~$target;
$target = $target;
my $pos = $mob ~~ GGE::Match ?? $mob.to !! 0;
$m.from = $pos;
my $tighter = defined %opts<tighter> && %!tokens.exists(%opts<tighter>)
Expand All @@ -106,6 +99,7 @@ class GGE::OPTable {
}
my $circumnest = 0;
my $expect = GGE_OPTABLE_EXPECT_TERM;
# RAKUDO: Need to manually clone the closure [perl #73034]
my &shift_oper = pir::clone(-> $oper, $token {
push @tokenstack, $token;
push @operstack, $oper;
Expand Down
38 changes: 16 additions & 22 deletions lib/GGE/Perl6Regex.pm
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class GGE::Perl6Regex {
:parsed(&GGE::Perl6Regex::parse_modifier));

method new($pattern, :$debug) {
# RAKUDO: Cannot call a sub named 'regex' without the '&'
# RAKUDO: Cannot call a sub named 'regex' without the '&' [perl #72438]
my $match = &regex($pattern);
die 'Perl6Regex rule error: can not parse expression'
if $match.to < $pattern.chars;
Expand All @@ -139,14 +139,12 @@ class GGE::Perl6Regex {
}

our sub parse_term($mob) {
# RAKUDO: Stringification needed due to [perl #73462]
if (~$mob.target).substr($mob.to, 1) ~~ /\s/ {
if $mob.target.substr($mob.to, 1) ~~ /\s/ {
return parse_term_ws($mob);
}
my $m = GGE::Exp::Literal.new($mob);
my $pos = $mob.to;
# RAKUDO: Stringification needed due to [perl #73462]
my $target = ~$m.target;
my $target = $m.target;
while $target.substr($pos, 1) ~~ /\w/ {
++$pos;
}
Expand All @@ -163,8 +161,7 @@ class GGE::Perl6Regex {
our sub parse_term_ws($mob) {
my $m = GGE::Exp::WS.new($mob);
$m.to = $mob.to;
# RAKUDO: Stringification needed due to [perl #73462]
$m.to++ while (~$m.target).substr($m.to, 1) ~~ /\s/;
$m.to++ while $m.target.substr($m.to, 1) ~~ /\s/;
if (~$m.target).substr($m.to, 1) eq '#' {
my $delim = "\n";
$m.to = defined (~$m.target).index($delim, $m.to)
Expand Down Expand Up @@ -265,8 +262,7 @@ class GGE::Perl6Regex {

our sub parse_subrule($mob) {
my $m = GGE::Exp::Subrule.new($mob);
# RAKUDO: Regex::Match doesn't support .substr
my $target = ~$mob.target;
my $target = $mob.target;
my $key = $mob<KEY>;
if $key eq '<!' {
$m<isnegated> = True;
Expand All @@ -278,7 +274,8 @@ class GGE::Perl6Regex {
my $cname = $subname;
if $target.substr($pos, 1) eq ' ' {
$m.to = ++$pos;
# RAKUDO: Cannot call a sub named 'regex' without the '&'
# RAKUDO: Cannot call a sub named 'regex'
# without the '&' [perl #72438]
my $arg = &regex($m, :stop('>'));
return $m unless $arg;
$m<arg> = ~$arg;
Expand Down Expand Up @@ -446,10 +443,9 @@ class GGE::Perl6Regex {

my $key = $mob<KEY>;
my ($mod2, $mod1);
# RAKUDO: Stringification needed due to [perl #73462]
given ~$m.target {
$mod2 = .substr($mob.to, 2);
$mod1 = .substr($mob.to, 1);
given $m.target {
$mod2 = .substr($mob.to, 2);
$mod1 = .substr($mob.to, 1);
}

$m<min> = 1;
Expand Down Expand Up @@ -493,17 +489,17 @@ class GGE::Perl6Regex {

if $key eq '**' {
# XXX: Should also count ws before quant modifiers -- with tests
# RAKUDO: Stringification needed due to [perl #73462]
my $sepws = ?((~$m.target).substr($m.to, 1) ~~ /\s/);
++$m.to while (~$m.target).substr($m.to, 1) ~~ /\s/;
my $isconst = (~$m.target).substr($m.to, 1) ~~ /\d/;
my $sepws = ?($m.target.substr($m.to, 1) ~~ /\s/);
++$m.to while $m.target.substr($m.to, 1) ~~ /\s/;
my $isconst = $m.target.substr($m.to, 1) ~~ /\d/;
my $sep = !$isconst;
if (~$m.target).substr($m.to, 1) eq '{' {
$sep = False;
++$m.to;
}
if $sep {
# RAKUDO: Cannot call a sub named 'regex' without the '&'
# RAKUDO: Cannot call a sub named 'regex'
# without the '&' [perl #72438]
my $repetition_controller = &regex($m, :tighter<infix:>);
die 'perl6regex parse error: Error in repetition controller'
unless $repetition_controller;
Expand All @@ -529,9 +525,7 @@ class GGE::Perl6Regex {
else {
# XXX: Add test against non-digits inside braces .**{x..z}
# XXX: Need to generalize this into parsing several digits
$m<min> = $m<max>
# RAKUDO: Stringification needed due to [perl #73462]
= (~$m.target).substr($m.to, 1);
$m<min> = $m<max> = $m.target.substr($m.to, 1);
++$m.to;
if (~$m.target).substr($m.to, 2) eq '..' {
$m.to += 2;
Expand Down

0 comments on commit 7a46c16

Please sign in to comment.