Re: [perl #75668] [BUG] whitespace before ^ in rule
On Fri, Jun 11, 2010 at 02:16:28PM -0700, Moritz Lenz via RT wrote: > On Thu Jun 10 21:11:42 2010, rir...@comcast.net wrote: > > I think it is a bug that these differ > > rule TOP { ^ } > > rule TOP {^ } > It actually conforms the current spec. Each consecutive run of > whitespace is replaced by a call to <.ws>. So the first rule is > equivalent to > token TOP { <.ws> ^ <.ws> <.ws> } > > When there is leading whitespace in the string, the first <.ws> matches, > and ^ fails. Since there's no backtracking in a token, the match fails. > I agree that that it's not obvious or intuitive, but rakudo should only > special-case it if the spec says so. Thanks for the reply, I'll be slower to submit bugs. I get your point. I think the spec may be open to other interpretations though: ^ and $ now always match the start/end of a string, How can even a zero-width atom ever match before the start of a string? What are we matching against? I think whitespace before a leading/trailing ^/$ needs to be discounted. Dwimmery and elegance demand. It is foul if the "formalization" of matching leads us to rule TOP { : my $dog = "Magic"; ^ } needing to be rule TOP { : my $dog = "Magic";^ } Either way, the spec needs to be clarified. Moritz, I appreciate the time you have taken with me. I'm more or less at 5.005 regarding regexes, so some of the Perl5 refs in the synopses are not so helpful to me. I'm am excited by grammars; they change the mentation of matching. On Perlmonks, I have found your answers satisfying but was disappointed that we seem to be a party of two (at least there is an audience). I feel that I could wear you out with my questions. I like Perlmonks, but could move to another site. Be well, rir
Sidebar for the book: another approach.
Results in this (temporary image): http://lucs.net:/sidebar.png A few notes: - Requires additional LaTeX package 'calc'. - Has some UTF-8 characters in the perl code. - Introduced a main() sub (personal preference -- it bothers me to have floating top level code). - I hope the produced patch is correctly formatted in this email (new to git and its patches). Comments appreciated. Thanks. --- bin/book-to-latex | 130 +++- 1 files changed, 117 insertions(+), 13 deletions(-) diff --git a/bin/book-to-latex b/bin/book-to-latex index a909a46..70dabfb 100644 --- a/bin/book-to-latex +++ b/bin/book-to-latex @@ -2,7 +2,48 @@ use strict; use Pod::PseudoPod::LaTeX 1.101050; -print <<'HEADER'; +# +package Perl6BookLaTeX; + +use base 'Pod::PseudoPod::LaTeX'; + +sub start_sidebar { +my ( $self, $flags ) = @_; +$self->{scratch} .= << 'EOT'; +\begin{figure}[!h] +\footnotesize +\sidebartop +EOT +if ( $flags->{title} ) { +my $title = $self->encode_text( $flags->{title} ); +$self->{scratch} .= << "EOT"; +\\begin{center} +\\vspace{-\\baselineskip} +\\vspace{-\\baselineskip} +\\normalsize{\\bfseries{$title}} +\\end{center} +EOT +} +$self->{scratch} .= "\\vspace{-5pt}%\n"; +} + +# +sub end_sidebar { +my $self = shift; +$self->{scratch} .= << 'EOT'; +\sidebarbottom +\end{figure} +EOT +} + +# +package main; + +main(); + +# +sub main { +print << 'HEADER'; \documentclass[11pt,a4paper,oneside]{report} \usepackage{graphics,graphicx} \usepackage{colortbl} @@ -12,29 +53,92 @@ print <<'HEADER'; \usepackage[utf8]{inputenc} \usepackage{makeidx} \usepackage[colorlinks=true,pagebackref]{hyperref} +\usepackage{calc} \makeindex \title{Using Perl~6} \author{Jonathan S. Duff, Moritz Lenz, Carl Mäsak, Patrick R. Michaud, Jonathan Worthington} - -\begin{document} +HEADER -\maketitle +# Sidebar Info. Units are points. +my %SI = ( +rule_indent => 40, +text_indent => 50, +vert_thick => 1, +big_thick => 1.5, +gap_thick => 1, +sml_thick => 0.6, +tub_thick => 2, +); +$SI{vert_height} = + $SI{big_thick} + $SI{gap_thick} + $SI{sml_thick} + $SI{tub_thick}; +$SI{rule_padding} = ($SI{rule_indent} + $SI{vert_thick}) * 2; +$SI{top_big_elev} = $SI{gap_thick} + $SI{sml_thick} + $SI{tub_thick}; +$SI{top_sml_elev} = $SI{tub_thick}; +$SI{bot_sml_elev} = $SI{big_thick} + $SI{gap_thick}; -\tableofcontents -HEADER +print subst_tokens(\%SI, << 'EOT'); +\newcommand{\sidebartop}{% +\nointerlineskip\vspace{\baselineskip}% +\hskip «rule_indent»pt% +\rule[0pt]{«vert_thick»pt}{«vert_height»pt}% +\rule[«top_big_elev»pt]{\linewidth-«rule_padding»pt}{«big_thick»pt}% +\rule[0pt]{«vert_thick»pt}{«vert_height»pt}% +\par% +\vspace{-\baselineskip}% +\hskip «rule_indent»pt% +\hskip «vert_thick»pt% +\rule[«top_sml_elev»pt]{\linewidth-«rule_padding»pt}{«sml_thick»pt}% +\par% +\vspace{\baselineskip}% +\begingroup% +\leftskip «text_indent»pt% +\rightskip\leftskip% +} +EOT -for (@ARGV) { -my $parser = Pod::PseudoPod::LaTeX->new(); -$parser->codes_in_verbatim(1); -$parser->output_fh( *STDOUT ); -$parser->parse_file( $_ ); +print subst_tokens(\%SI, << 'EOT'); +\newcommand{\sidebarbottom}{% +\endgroup% +\nointerlineskip\vspace{\baselineskip}% +\hskip «rule_indent»pt% +\rule[0pt]{«vert_thick»pt}{«vert_height»pt}% +\rule[0pt]{\linewidth-«rule_padding»pt}{«big_thick»pt}% +\rule[0pt]{«vert_thick»pt}{«vert_height»pt}% +\par% +\vspace{-\baselineskip}% +\hskip «rule_indent»pt% +\hskip «vert_thick»pt% +\rule[«bot_sml_elev»pt]{\linewidth-«rule_padding»pt}{«sml_thick»pt}% +\par% +\vspace{\baselineskip}% } +EOT -print <<'FOOTER'; +print << 'START_DOC'; +\begin{document} +\maketitle +\tableofcontents +START_DOC -\printindex +for (@ARGV) { +my $parser = Perl6BookLaTeX->new(); +$parser->codes_in_verbatim(1); +$parser->output_fh( *STDOUT ); +$parser->parse_file( $_ ); +} +print << 'FOOTER'; +\printindex \end{document} FOOTER +} + +# +sub subst_tokens { +my ($tokens_ref, $text) = @_; +$text =~ s/«([^»]*)»/$tokens_ref->{$1}/g; +return $text; +} + -- 1.6.5
[perl #75650] [PATCH] Add test for loading perl6.pbc as bytecode
I've made a new patch that does not require TAP::Harness 3.x, and uses a Rakudo test with a call to run() to run the Parrot test which loads the bytecode. >From 039c18b01b2c12b95de560c5a26bdc7ac9dd7a32 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 9 Jun 2010 13:44:41 -0700 Subject: [PATCH] Add test for loading perl6.pbc bytecode --- build/Makefile.in |2 +- t/02-embed/01-load.pir | 29 + t/02-embed/01-load.t |3 +++ 3 files changed, 33 insertions(+), 1 deletions(-) create mode 100644 t/02-embed/01-load.pir create mode 100644 t/02-embed/01-load.t diff --git a/build/Makefile.in b/build/Makefile.in index 48eea9b..62606c0 100644 --- a/build/Makefile.in +++ b/build/Makefile.in @@ -395,7 +395,7 @@ test: coretest fulltest: coretest spectest coretest: Test.pir $(PERL6_EXE) - $(PERL) t/harness t/00-parrot t/01-sanity + PARROT=$(PARROT) $(PERL) t/harness t/00-parrot t/01-sanity t/02-embed # Run the spectests that we know work. spectest_regression: spectest diff --git a/t/02-embed/01-load.pir b/t/02-embed/01-load.pir new file mode 100644 index 000..948ed25 --- /dev/null +++ b/t/02-embed/01-load.pir @@ -0,0 +1,29 @@ +=head1 NAME + +t/02-embed/01-load.pir - Tests loading of bytecode + +=head1 SYNOPSIS + +% parrot t/02-embed/01-load.pir + +=head1 DESCRIPTION + +Tests the loading of perl6.pbc . This file is used by t/02-embed/01-load.t + +=cut + +.sub 'main' :main +.include 'test_more.pir' + +plan(1) + +test_load() +.end + +.sub test_load +lives_ok(<<'CODE',"can load_bytecode perl6.pbc") +.sub main +load_bytecode "perl6.pbc" +.end +CODE +.end diff --git a/t/02-embed/01-load.t b/t/02-embed/01-load.t new file mode 100644 index 000..709a5f3 --- /dev/null +++ b/t/02-embed/01-load.t @@ -0,0 +1,3 @@ +use v6; +my $parrot = %*ENV{'PARROT'}; +run("$parrot t/02-embed/01-load.pir"); -- 1.7.0.4
[perl #75486] Excessive resource use of `make spectest`
In edf00722595864310f52ab1f4eb757aff323e09f I've set the default number of jobs to 1, and in a63c7e050fef6a648af234ac551e6b0d04db9fe4 I've moved a long-running test to a separate stresstest target.
[perl #75244] [BUG] Rakudo doesn't recognize \e as a valid escape sequence (but STD does)
On Fri May 21 09:26:38 2010, masak wrote: > rakudo: "\e" > rakudo c950de: OUTPUT«Unrecognized backslash sequence: '\e' [...] > std: "\e" > std 30745: OUTPUT«ok 00:01 114m» > std: "\g" > std 30745: OUTPUT«[31m===[0mSORRY![31m===[0mUnrecognized > backslash sequence: '\g' [...] FAILED 00:01 111m» > * masak submits rakudobug > masak: that one is already re-opened in RT > masak: IIRC > oh, ok. > moritz_: do you know which RT ticket mentions \e? I don't seem > to be able to find it. > * masak times out and submits the \e bug anyway > better having dups than holes in RT. I think pmichaud++ fixed this recently, and cono++ just turned on the tests for it again. Resolving. Thanks, Jonathan
[perl #75526] tests available
This is an automatically generated mail to inform you that tests are now available in t/spec/S03-operators/range-basic.t commit ac7fc85b7ce813eb00872b9bafeeec025783b8e2 Author: moritz Date: Sat Jun 12 11:35:25 2010 + [t/spec] unfudge tests for RT #75526 git-svn-id: http://svn.pugscode.org/p...@31209 c213334d-75ef-0310-aa23-eaa082d1ae64 diff --git a/t/spec/S03-operators/range-basic.t b/t/spec/S03-operators/range-basic.t index 0b92ef1..ef0bb39 100644 --- a/t/spec/S03-operators/range-basic.t +++ b/t/spec/S03-operators/range-basic.t @@ -162,7 +162,6 @@ nok 'h' ~~ 'b'..'g',"not 'h' ~~ 'b'..'g'"; nok 0 ~~ 'a'..'g', "not 0 ~~ 'a'..'g'"; # RT#75526: [BUG] Some non-alphanumeric ranges don't work -#?rakudo skip 'these tests hang forever' { ok ' ' ~~ ' '..' ', "' ' ~~ ' '..' '"; ok ' ' ~~ ' '..'A', "' ' ~~ ' '..'A'";
[perl #75626] [TODO] Implement Any.all (and .any, .one, .none) in Rakudo
On Wed Jun 09 05:12:54 2010, masak wrote: > well, it was $_, so just .all works > ooh! > rakudo: .all > rakudo 34c1ba: OUTPUT«Method 'all' not found for invocant of > class '' [...] > * masak submits rakudobug > What type is .all supposed to be defined on? > Any -> List > Ah, then it is a rakudobug. > rakudo: 42.all > rakudo 34c1ba: OUTPUT«Method 'all' not found for invocant of > class 'Int' [...] > Ah, OK, actually not bug, just NYI. > in any case, it ought to work in your subset of Array > rakudo: my @a = 1,2,3; say @a.all > rakudo 34c1ba: OUTPUT«Method 'all' not found for invocant of > class 'Array' [...] Implemented and tests added by (Vyacheslav Matjukhin)++; resolving. Thanks, Jonathan
[perl #74990] tests available
This is an automatically generated mail to inform you that tests are now available in t/spec/S03-operators/series-simple.t commit b3d941a4f9a902c1b2fa7619dd68f832a2fbb802 Author: mmcleric Date: Sat Jun 12 15:53:47 2010 + test for RT#74990 git-svn-id: http://svn.pugscode.org/p...@31218 c213334d-75ef-0310-aa23-eaa082d1ae64 diff --git a/t/spec/S03-operators/series-simple.t b/t/spec/S03-operators/series-simple.t index 5c74ad4..46653ba 100644 --- a/t/spec/S03-operators/series-simple.t +++ b/t/spec/S03-operators/series-simple.t @@ -73,4 +73,8 @@ is ('c', { $_ } ... *).batch(10).join(', '), 'c, c, c, c, c, c, c, c, c, c', 'se is ('c', 'c' ... *).batch(10).join(', '), 'c, c, c, c, c, c, c, c, c, c', 'series started with two identical letters'; is ('c', 'c', 'c' ... *).batch(10).join(', '), 'c, c, c, c, c, c, c, c, c, c', 'series started with three identical letters'; -done_testing; \ No newline at end of file +# tests for alphabetical series crossing 'z' +#?rakudo 1 todo "RT#74990: Series of letters doesn't stop at end point" +is ('x' ... 'z').join(', '), 'x, y, z', "series ending with 'z' don't cross to two-letter strings"; + +done_testing;
[perl #75674] tests available
This is an automatically generated mail to inform you that tests are now available in t/spec/S03-operators/series.t commit dc653c9531fffc0b0f7ed4ab68cac68200687c53 Author: dimid Date: Sat Jun 12 15:59:07 2010 + [t/spec] Add tests for RT#75674. infix:<...> works with a list to the right git-svn-id: http://svn.pugscode.org/p...@31219 c213334d-75ef-0310-aa23-eaa082d1ae64 diff --git a/t/spec/S03-operators/series.t b/t/spec/S03-operators/series.t index 0123cb6..c0d7d82 100644 --- a/t/spec/S03-operators/series.t +++ b/t/spec/S03-operators/series.t @@ -145,6 +145,11 @@ is (16, 8, 4 ... *).batch(5).join(', '), '16, 8, 4, 2, 1', 'geom decreasing'; 'expression with two magic series operators and non-matching end points'; } +{ +is ~(4 ... ^5), ~<4 3 2 1 0 1 2 3 4>, '4 ... ^5 works'; +is ~(4 ... 0, 1, 2, 3, 4), ~<4 3 2 1 0 1 2 3 4>, '4 ... 0, 1, 2, 3,4 works'; +} + done_testing; # vim: ft=perl6
Re: [perl #75668] [BUG] whitespace before ^ in rule
>... > On Perlmonks, I have found your answers satisfying but was disappointed > that we seem to be a party of two (at least there is an audience). I feel > that I could wear you out with my questions. I like Perlmonks, but could > move to another site. A good thing about perlmonks is that your audience is likely to grow, and those posts will be referenced by future perl6-ers.
Severe performance loss, comparing with perl 5
I'm trying to use use Perl 6 to process some nucleotide sequences. However, I found it strangely slow on substr or string concat operations, compared with its Perl 5 equivalent. Here are the codes, Perl 6 on top, Perl 5 on middle, a test input file on bottom (should be stored to "makeseq.fasta"). The Perl 6's revcom() sub works very slow. #!/usr/bin/perl6use v6;use Bio::SeqIO; say "program initialized";my $IN = Bio::SeqIO.new('fasta','makeseq.fasta'); say "input stream created"; while (my $obj = $IN.next_seq) {say "\tid: <",$obj.display_id,">"; say "\tseq: <{$obj.seq}>"; say "\trev: <{revcom($obj.seq)}>";} sub revcom(Str $seq) { my $len = $seq.chars; my $result; loop (my $i=$len-1; $i>=0; $i--) { given ($seq.substr($i,1)) { when ('A') {$result~='T'} when ('T') {$result~='A'} when ('G') {$result~='C'} when ('C') {$result~='G'} when ('a') {$result~='t'} when ('t') {$result~='a'} when ('g') {$result~='c'} when ('c') {$result~='g'} } } return $result;} #!/usr/bin/perl use strict;use Bio::SeqIO;use feature qw/say switch/; say "program initialized"; my $IN = Bio::SeqIO->new(-file=>'makeseq.fasta'); say "input stream created"; while (my $obj = $IN->next_seq) {say "\tid: <",$obj->display_id,">";say "\tseq: <",$obj->seq,">";say "\trev: <",revcom($obj->seq),">";} sub revcom {my $seq = shift;my $len = length $seq; my $result; for (my $i=$len-1; $i>=0; $i--) { given (substr $seq,$i,1) { when ('A') {$result.='T'} when ('T') {$result.='A'} when ('G') {$result.='C'} when ('C') {$result.='G'} when ('a') {$result.='t'} when ('t') {$result.='a'} when ('g') {$result.='c'} when ('c') {$result.='g'} } } return $result;} >EMBOSS_001ccgacaacgaatatacgggctgtttgcttgcgtttgagaggtcgtattcccagatgcgtaacgtagcgctccactccgttcgaaaggccggaggaaacaatcgctgaacaactgggtagacataaccatgtcgtctctgtgctactcccccacgggtatattaaggcagataaggttgcttagtgggacctataac>EMBOSS_002cggattcagaattggacccggaagcatgcaggcgtggaatgtgggttaagggaccgaagtatttcgttactattccgatagtatccgatgagtccgtagcgggatgcacgtcataatcctagccttgaacgaccgggtactggttacgcaattccacccatgtaccttcccacagcccacatgcgacttatt>EMBOSS_003tctacgtatgggaataggacgtgctcaatacacgcatggcttgccgtccatcgggagcgttgcaagtcaaagagctaggcttaacctggactgagtggtcattgcgccgatgcacggcctgcctcagcgctgggagtaatcgtcaatagcaagtgtattgtagcgtcatcccaggcctcgaggcctaa>EMBOSS_004gttgccgaacgcgccactctcccgcggtgcttaatcgagttggactcaccacctaccacacaacaccggatgcgctaactccgggcatctgtcgcaaggcttcatggaaccctacactggtaatcatggtaatagattcaacgtgggttccgttcatatagacaccactcacaaaggcgttcgtgccctgat>EMBOSS_005atatcactcagcctgtggacgtgagccacccgcgctcactctcgctgtagattatgtcagagaacgtagaatctgtaatcatcggtcatatgaagtaatccaccgacaccgagcaacgttgctactgacaacgggacatttaagagtgctggaaattgagttattccgcctggataattggcggtttg _ Hotmail: Trusted email with powerful SPAM protection. https://signup.live.com/signup.aspx?id=60969