Grammar doesn't seem to match any token

2018-09-23 Thread Mark Carter

My grammar doesn't seem to match the 'other' rule. What's wrong with it?

grammar Weave {
    token TOP {   * }
    rule el {   |  |   }
    rule lt { '<'  }
    rule tilde { '~' \S+ }
    rule other { .  }
}

class Weaver {
    has Str $.outstr;

    method TOP   ($/) { make $ ; put("top called") ; put($) }
    method el    ($/) { put($/) }
    method tilde ($/) { say 'tilde called' }
    method lt    ($/) { make '' ; put(''); $!outstr ~= 'X' }
    method other ($/) { $!outstr ~= '.'; say 'other called'; 
put('.'); }


}

$input = '~i <

Re: Fwd: Re: Is win 32 being worked on?

2017-07-25 Thread Mark Carter



On 25/07/2017 20:31, Darren Duncan wrote:
I would question why any desktop computer manufacturers were still 
even shipping non-64-bit capable hardware in 2010.
I dual-boot (rarely) with it, and it runs 64-bit Ubuntu. I am using a 
Dell, which came with 32-bit Win 7.


Fwd: Re: Is win 32 being worked on?

2017-07-25 Thread Mark Carter


On 2017-07-25 11:05 AM, Mark Carter wrote:



On 25/07/2017 18:34, Darren Duncan wrote:



How often would someone reasonably be using a cutting edge tool like Rakudo on
Windows without having a 64 bit Windows these days?


Thing is, I have a computer from 2010, Win 7 32-bit. It's fast enough for me,
and does what I want it to do. I'm not going to spend money just to run Perl6.
It doesn't even compile on cygwin.

Python is available in 32-bit. Why not perl6?



Re: Announce: Rakudo Star Release 2017.07

2017-07-25 Thread Mark Carter

Attempted build on Arch Linux:

perl Configure.pl --prefix=$HOME/.local --backend=moar --gen-moar --gen-moar

Resulting in:

Building NQP ...
/usr/bin/perl Configure.pl --prefix=/home/mcarter/.local --backends=moar 
--make-install

Creating tools/build/install-jvm-runner.pl ...

===SORRY!===
Found /home/mcarter/.local/bin/moar version 2017.04-53-g66c6dda, which is too 
old. Wanted at least 2017.07

No suitable MoarVM (moar executable) found using the --prefix
(You can get a MoarVM built automatically with --gen-moar.)

Command failed (status 65280): /usr/bin/perl Configure.pl 
--prefix=/home/mcarter/.local --backends=moar --make-install


Re: Is win 32 being worked on?

2017-07-21 Thread Mark Carter



On 21/07/2017 09:50, Todd Chester wrote:


I may be wrong, but I do believe what you want is called
"Rakudo Star".  You can download it from

https://rakudo.perl6.org/downloads/star/

But no recent win 32-bit.


Is win 32 being worked on?

2017-07-21 Thread Mark Carter
I noticed that there is no Windows 32-bit version of rakudo, and it 
won't even compile on cygwin.


Are there plans for fixing this?


Why is my class rejecting new()?

2017-07-20 Thread Mark Carter

I have a class definition:

class Etran {
has $.dstamp is rw;
has $.folio is rw;
has $.ticker is rw;
has $.qty is rw;
has $.amount is rw;
has $.desc is rw;

method new($line) {
my ($cmd, $dstamp, $folio, $ticker, $qty, $amount, $way, $desc) 
= shlex-fields $line;
$!dstamp = $dstamp;
$!folio = $folio;
$!ticker = $ticker;
$!qty = $way == "B" ?? $qty !! - $qty;
$!amount = $amount;
$!desc = $desc;
}

}**
which I instantiate with
my $e = Etran.new($line);

However, it gives an error message:
Cannot look up attributes in a Etran type object
at the line
$!dstamp = $dstamp;

Why that, and how do I fix it?

Also, I don't really understand the difference between using the twigils "." and using 
"!",
and have yet to see an explanation that I understand.



Re: Where's the filter command?

2017-07-18 Thread Mark Carter



On 18/07/2017 09:53, Brent Laabs wrote:

Are you looking for grep()? https://docs.perl6.org/routine/grep

Ah yes. Thanks for that.
Pretty good:

say ($schema.lines().map: ).grep: { .elems() > 0; } ;


Re: Is there a bash/shlex-like processor with double-quotes handling?

2017-07-14 Thread Mark Carter



On 14/07/2017 15:23, Lucas Buchala wrote:

Alternatively, the «...» builtin operator already does some kind of
word splitting respecting quotes, if that fits your needs:



Thanks. I take it you are referring to the "hyper" operator (?) It looks 
good, but it doesn't quite work:

 my $d = "hello \"there world\"";
my @f = << $d >>;
 @f[1] ; # "there


As it happens, I did manage to create a grammar that respects quoting, 
and even escaped quoting:


grammar Shlex {
token TOP {<.ws>? (|)* <.ws>?}
token ws { \s+ }
rule word { <[a..zA..Z0..9\\-]>+ }
token ascii_char { <-["\\]> } # anything not a " or \
token escaped_char { "\\\"" } # literal \"
token qstring { '"' [|]* '"' <.ws>?  }
}

my $m = Shlex.parse(Q[goodbye "\"cruel\" world"  ]);
say "First  component:$m[0][0].Str()"; # OUTPUT: First  component:goodbye
say "Second component:$m[0][1].Str()"; # OUTPUT: Second component:"\"cruel\" 
world"


Is there a bash/shlex-like processor with double-quotes handling?

2017-07-14 Thread Mark Carter
Is there a function that can decompose a string to an array separated by 
whitespace, but also respecting double quotes, and prefereably escape 
sequences?


So, for example:

my $d="hello   \"cruel world\"";

something-something($d) ; => ("hello", "cruel world")


Re: Perl6 NCurses module under Arch: libncursesw.so.6

2017-04-18 Thread Mark Carter



On 18/04/17 15:56, Dominique Dumont wrote:

You should be able to install ncurses 5 on arch:
https://aur.archlinux.org/packages/ncurses5-compat-libs/
NCurses has changed recently to take into account ncurses 6 so that in 
future everything should work out of the box. Fingers crossed.


Perl6 NCurses module under Arch: libncursesw.so.6

2017-04-12 Thread mark carter

I'm running:
This is Rakudo version 2017.01 built on MoarVM version 2017.01
implementing Perl 6.c.
under Arch.

When I do
$perl6 starfield.pl6
I get:
Cannot locate native library 'libncursesw.so.5': libncursesw.so.5: 
cannot open shared object file: No such file or directory


That is because version 6 of the ncurses library is installed, rather 
than 5.