Re: generating grammars, capturing in regex interpolation, etc.

2015-04-17 Thread Tobias Leich

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

The comment in  INTERPOLATE is about subcaptures... but if you do not
capture the interpolated regex itself, you break that chain.

Am 17.04.2015 um 04:34 schrieb Nathan Gray:
 On Wed, Apr 15, 2015 at 09:45:39PM -0400, Nathan Gray wrote:
 I had given up on using regexes embedded within regexes, because
 I could not get capturing to work.

 I did a backtrace on one of the test cases that fails, which led
 me to

   src/core/Cursor.pm

 in

   method INTERPOLATE(\var, $i = 0, $s = 0, $a = 0)

 with this comment:

   # Call it if it is a routine. This will capture if requested.
   return (var)(self) if nqp::istype(var,Callable);

 This seems to indicate that captures in the embedded regexes
 should capture.

 When the capture does not happen, is this a bug?

 The test cases I came up with, that illustrate capturing from
 embedded regexes (some which work, some which do not), are
 included below.

 -kolibrie

 use v6;
 use Test;

 my $year = '2015';
 my $month = '04';
 my $day = '11';
 my $date_string = $year-$month-$day;

 my $year_regex = rx/$year=[\d**4]/;
 my $month_regex = rx/$month=[\d\d?]/;
 my $day_regex = rx/$day=[\d\d?]/;
 my $separator = rx/'-'/;

 # Single named capture.
 {
 ok($date_string ~~ $year_regex, 'date string matches year regex');
 is(~$/, $year, 'matched is year string');
 is(~$/year, $year, 'year is captured');
 }

 # Single named capture in slashes.
 {
 ok($date_string ~~ /$year_regex/, 'date string matches year regex
when in slashes');
 is(~$/, $year, 'matched is year string when in slashes');
 is(~$/year, $year, 'year is captured when in slashes');  # Fails
 }

 # Single named capture embedded in named capture.
 {
 ok($date_string ~~ /$pattern=$year_regex/, 'date string matches
year regex when embedded');
 is(~$/, $year, 'matched is year string when embedded');
 is(~$/pattern, $year, 'pattern is captured when embedded');
 is(~$/patternyear, $year, 'year is captured when embedded');
 }

 # Single named capture embedded in named capture with brackets.
 {
 ok($date_string ~~ /$pattern=[$year_regex]/, 'date string
matches year regex when embedded with brackets');
 is(~$/, $year, 'matched is year string when embedded with brackets');
 is(~$/pattern, $year, 'pattern is captured when embedded with
brackets');
 is(~$/patternyear, $year, 'year is captured when embedded with
brackets');  # Fails
 }

 # Multiple named captures.
 {
 ok($date_string ~~ /$year_regex $separator $month_regex $separator
$day_regex/, 'date string matches multiple regexes in slashes');
 is(~$/, $date_string, 'matched is date string in multi regex with
slashes');
 is(~$/year, $year, 'year is captured in multi regex with
slashes');  # Fails
 is(~$/month, $month, 'month is captured in multi regex with
slashes');  # Fails
 is(~$/day, $day, 'day is captured in multi regex with
slashes');  # Fails
 }

 # Multiple named captures embedded in named capture.
 {
 ok($date_string ~~ /$pattern=$year_regex $separator $month_regex
$separator $day_regex/, 'date string matches multiple regexes when
embedded');
 is(~$/, $date_string, 'matched is date string in multi regex when
embedded');
 is(~$/pattern, $year, 'pattern is captured in multi regex when
embedded');
 is(~$/patternyear, $year, 'year is captured in multi regex
when embedded');
 is(~$/month, $month, 'month is captured in multi regex when
embedded');  # Fails
 is(~$/day, $day, 'day is captured in multi regex when
embedded');  # Fails
 }

 # Multiple named captures embedded in named capture with brackets.
 {
 ok($date_string ~~ /$pattern=[$year_regex $separator
$month_regex $separator $day_regex]/, 'date string matches multiple
regexes when embedded with brackets');
 is(~$/, $date_string, 'matched is date string in multi regex when
embedded with brackets');
 is(~$/pattern, $date_string, 'pattern is captured in multi regex
when embedded with brackets');
 is(~$/patternyear, $year, 'year is captured in multi regex
when embedded with brackets');  # Fails
 is(~$/patternmonth, $month, 'month is captured in multi regex
when embedded with brackets');  # Fails
 is(~$/patternday, $day, 'day is captured in multi regex when
embedded with brackets');  # Fails
 }




-BEGIN PGP SIGNATURE-
Version: GnuPG v1

iQEcBAEBAgAGBQJVMLqGAAoJEKo+Od/eKQxFiN0IALO/O2XYMEwDabVIxQ41qBk2
npTfOPFCu/QTewHt0/rFh8ujZnx6APt5J+MDXHobB1v0E3ckMdZymsBgPSVFRYfh
XYgkWX0pelyH6Ys0M7oGEHuqZWPLavLXL5EC5gSNagKkwKdytKVlzMH+UPOEZma2
GX3GDpoCeJNuzwrACbrcwxRHYdGkaTgr19d0IyyPsGrtKKUj83yTKlb3GRPgDWUL
7g9uaIAdN87G8qvGGAdabV96gt8M0s8wRlLmKBL06q0uIs0YQvxbBLLhGrmHmX0r
4/Pc1lnS28tUdb6dfURXI3eSyFe7AmUiMnxUInojgsiJ3mQH/hmDrgOMIJTSCDE=
=K+kk
-END PGP SIGNATURE-



[perl #114388] LTA error when using s[] = rea

2015-04-17 Thread Christian Bartolomaeus via RT
The first evaluation fails again (no method 'subst-mutate' nowadays), so I'm 
re-opening this ticket.

$ perl6 -e 's[ea] = rea;'
Method 'subst-mutate' not found for invocant of class 'Any'
  in block unit at -e:1

We're back to We could improve the error, but what should it say (moritz, 
2012) and Maybe it should mention $_ somewhere, since it tries to call subst 
on $_ (FROGGS, 2013).


[perl #124324] [BUG] cannot use EVAL in a precompiled dependency

2015-04-17 Thread via RT
# New Ticket Created by  Tobias Leich 
# Please include the string:  [perl #124324]
# in the subject line of all future correspondence about this issue. 
# URL: https://rt.perl.org/Ticket/Display.html?id=124324 


$ cat eval.pm
BEGIN { EVAL 'say 42'; 0 }

$ cat use_eval.pm
use lib '.';
use eval;

--

$ perl6 --target=mbc --output=use_eval.pm.moarvm use_eval.pm
42

--

$ perl6 --target=mbc --output=eval.pm.moarvm eval.pm
42
$ perl6 --target=mbc --output=use_eval.pm.moarvm use_eval.pm
===SORRY!===
Missing or wrong version of dependency 'EVAL_0' (from 'eval.pm')

--

$ perl6 --target=mbc --output=eval.pm.moarvm eval.pm
42

$ perl6 use_eval.pm
===SORRY!===
Missing or wrong version of dependency 'EVAL_0' (from 'eval.pm')



[perl #124323] Parse fails due to user-friendlyness on ?? : !!

2015-04-17 Thread Christian Bartolomaeus via RT
This was fixed promptly. The code now dies with the right exception.

$ perl6 -e'my@x=^10;my@y=2..3;my@z=@y??@x[@y]:v!!@x'
===SORRY!=== Error while compiling -e
Precedence of :v is too loose to use inside ?? !!; please parenthesize
at -e:1
-- my@x=^10;my@y=2..3;my@z=@y??@x[@y]:v⏏!!@x
expecting any of:
pair value

Using parentheses as suggested works:

$ perl6 -e'my@x=^10;my@y=2..3;my@z=@y??(@x[@y]:v)!!@x;@z.say'
2 3

I added two tests to S03-operators/ternary.t with commit 
https://github.com/perl6/roast/commit/1790997c8c

I'm closing this ticket as 'resolved'.


[perl #124328] supersede with built-in classes gives errors, LTA syntax errors

2015-04-17 Thread via RT
# New Ticket Created by  Brent Laabs 
# Please include the string:  [perl #124328]
# in the subject line of all future correspondence about this issue. 
# URL: https://rt.perl.org/Ticket/Display.html?id=124328 


labster: m: supersede Cool {}
[8:00pm] camelia: rakudo-moar a24488: OUTPUT«===SORRY!===␤Type 'Cool' is
not declared. Did you mean 'Bool'?␤at /tmp/8fQODkoU6J:1␤-- supersede
Cool ⏏{}␤Malformed supersede␤at /tmp/8fQODkoU6J:1␤-- supersede Cool
⏏{}␤␤»
[8:01pm] labster: m: supersede Bool {}
[8:01pm] camelia: rakudo-moar a24488: OUTPUT«===SORRY!===␤Type 'Bool' is
not declared. Did you mean 'Cool'?␤at /tmp/YQMsgXm0Lq:1␤-- supersede
Bool ⏏{}␤Malformed supersede␤at /tmp/YQMsgXm0Lq:1␤-- supersede Bool
⏏{}␤␤»
[8:02pm] labster: can't win :/
[8:03pm] labster: also LTA error message
[8:06pm] labster: m: supersede class Cool { }
[8:06pm] camelia: rakudo-moar a24488: OUTPUT«===SORRY!=== Error while
compiling /tmp/1FsdHYnu_S␤Cannot use 'supersede' with class declaration␤at
/tmp/1FsdHYnu_S:1␤-- supersede class Cool⏏ { }␤expecting any
of:␤generic role␤»


[perl #124323] Parse fails due to user-friendlyness on ?? : !!

2015-04-17 Thread via RT
# New Ticket Created by  hmbrand 
# Please include the string:  [perl #124323]
# in the subject line of all future correspondence about this issue. 
# URL: https://rt.perl.org/Ticket/Display.html?id=124323 


$ perl6 -e'my@x=^10;my@y=2..3;my@z=@y??@x[@y]:v!!@x'
===SORRY!=== Error while compiling -e
Please use !! rather than :
at -e:1
-- my@x=^10;my@y=2..3;my@z=@y??@x[@y]:v⏏!!@x
 expecting any of:
 pair value

The :v triggers the parse error trying to be helpful even though the !! 
is correctly used


[perl6/specs] 20fd94: Clarify comment in example.

2015-04-17 Thread GitHub
  Branch: refs/heads/master
  Home:   https://github.com/perl6/specs
  Commit: 20fd946a18a1382c5c78c762e7e1ada166019a57
  
https://github.com/perl6/specs/commit/20fd946a18a1382c5c78c762e7e1ada166019a57
  Author: skids b...@abrij.org
  Date:   2015-04-17 (Fri, 17 Apr 2015)

  Changed paths:
M S04-control.pod

  Log Message:
  ---
  Clarify comment in example.
Many people will take useless to mean redundant, rather than impotent.




[perl6/specs] e32d82: s/excuse/cause/ for Promise.

2015-04-17 Thread GitHub
  Branch: refs/heads/master
  Home:   https://github.com/perl6/specs
  Commit: e32d821d994cddaf4d3402e34c0b50119e400124
  
https://github.com/perl6/specs/commit/e32d821d994cddaf4d3402e34c0b50119e400124
  Author: Cédric VINCENT ced...@reproducible.io
  Date:   2015-04-16 (Thu, 16 Apr 2015)

  Changed paths:
M S17-concurrency.pod

  Log Message:
  ---
  s/excuse/cause/ for Promise.




[perl6/specs] 0a559d: Elaborate a bit more on %?RESOURCE

2015-04-17 Thread GitHub
  Branch: refs/heads/master
  Home:   https://github.com/perl6/specs
  Commit: 0a559da0288f0831b1b4acee4ad8213c97a8f8fe
  
https://github.com/perl6/specs/commit/0a559da0288f0831b1b4acee4ad8213c97a8f8fe
  Author: Elizabeth Mattijsen l...@dijkmat.nl
  Date:   2015-04-17 (Fri, 17 Apr 2015)

  Changed paths:
M S22-package-format.pod

  Log Message:
  ---
  Elaborate a bit more on %?RESOURCE




[perl6/specs] d702a9: Fix .cue parameter names.

2015-04-17 Thread GitHub
  Branch: refs/heads/master
  Home:   https://github.com/perl6/specs
  Commit: d702a9ed5a1bacf80c71d7ba789de53c73f4335f
  
https://github.com/perl6/specs/commit/d702a9ed5a1bacf80c71d7ba789de53c73f4335f
  Author: Cédric VINCENT ced...@reproducible.io
  Date:   2015-04-16 (Thu, 16 Apr 2015)

  Changed paths:
M S17-concurrency.pod

  Log Message:
  ---
  Fix .cue parameter names.




[perl #114326] [BUG] `say [] ... []` loops infinitely in Rakudo

2015-04-17 Thread Christian Bartolomaeus via RT
This works now and there is a passing test in S03-sequence/basic.t

$ perl6 -e 'say [] ... []'

$ perl6 -e 'say ([] ... []).perl'
([],)

I'm closing this ticket as 'resolved'.