Re: perl6-regex: retaining $/.pos after an unsuccesful match without a temporary variable?

2019-08-21 Thread William Michels via perl6-users
Hi Raymond, Wow that's exciting! I'm sure others will chime in with their thoughts. I wrote two more test cases for your "incremental P5-like parser", that can be appended to the code you posted yesterday (personally I think of incremental matching as being important for matching the linear order

Re: perl6-regex: retaining $/.pos after an unsuccesful match without a temporary variable?

2019-08-21 Thread yary
More literal transcription of your original code is to allow zero-length match, which maintains "pos", and then checking the match length. #!/usr/bin/env perl6 use v6.c; given " foo bar" { die unless m/^\s+/; die unless m:p/ foo\s+ /; die if m:p/[ willnotmatch ]?/ && $/.chars;

Re: perl6-regex: retaining $/.pos after an unsuccesful match without a temporary variable?

2019-08-20 Thread Raymond Dresens
Hello everyone, and thanks everyone for their comments and code snippets with full of syntax that I haven't discovered as of yet, Today I managed to figure out how my provided example code could be rewritten in Perl 6 almost 'verbatim': see the program below in this message. I implemented a '~~~'

Re: perl6-regex: retaining $/.pos after an unsuccesful match without a temporary variable?

2019-08-20 Thread William Michels via perl6-users
Hi Yary, I'd certainly welcome a simpler answer than what I posted--for both 1). incremental search and 2). returning positional values. Below are some links to Regular Expressions in Python and in R. Regular Expressions in Perl 6 should aim to be as good if not better: Python:

Re: perl6-regex: retaining $/.pos after an unsuccesful match without a temporary variable?

2019-08-19 Thread William Michels via perl6-users
Hi Aureliano, It's a good question. The short answer is I haven't had any memory problems with the toy examples so far, but I haven't scaled up the regex to know how it behaves when testing for hundreds (or thousands) of matches. I suppose there might be some way to restrict array values to

Re: perl6-regex: retaining $/.pos after an unsuccesful match without a temporary variable?

2019-08-19 Thread yary
If you do make this a grammar, I think there's more than one way to have " {@a.push($/.pos)}/" fire after every match, and not repeat that code snippit on each rule... keep that in mind as a goal... -y On Tue, Aug 20, 2019 at 7:13 AM William Michels via perl6-users wrote: > > Thanks to Brad

Re: perl6-regex: retaining $/.pos after an unsuccesful match without a temporary variable?

2019-08-19 Thread William Michels via perl6-users
Thanks to Brad Gilbert's code contribution in this thread, I re-wrote a small snippet of his code (code that incrementally checks a series of regex matches), to have it return the last position of each match. Testing with three 'matches' and one 'willnotmatch' returns three positional values, as

Re: perl6-regex: retaining $/.pos after an unsuccesful match without a temporary variable?

2019-08-19 Thread Patrick Spek via perl6-users
On Sun, 18 Aug 2019 13:45:27 -0300 Aureliano Guedes wrote: > Even being another language, Perl6 should be inheriting Perl5's > regexes or even improving it not making it uglier and harder. > > Or I'm seeing how to use it in an easy way. Also, dunno if there is > some GOOD documentation to Perl6

Re: perl6-regex: retaining $/.pos after an unsuccesful match without a temporary variable?

2019-08-18 Thread Aureliano Guedes
Even being another language, Perl6 should be inheriting Perl5's regexes or even improving it not making it uglier and harder. Or I'm seeing how to use it in an easy way. Also, dunno if there is some GOOD documentation to Perl6 regexes. On Sun, Aug 18, 2019 at 12:56 PM Brad Gilbert wrote: > The

Re: perl6-regex: retaining $/.pos after an unsuccesful match without a temporary variable?

2019-08-18 Thread Brad Gilbert
Perl6 improved on regexes precicely by not inheriting decades of accumulated cruft. Perl (prior to 6) has expanded upon regular expressions in ways it was not designed for. (It was not designed to be expanded at all.) That has lead to hard to guess extensions, because they are not all that

Re: perl6-regex: retaining $/.pos after an unsuccesful match without a temporary variable?

2019-08-18 Thread Raymond Dresens
Hi Brad, Thanks for your response! I'll study your examples more carefully in the upcoming days, The grammar system seems to explicitly "enforcing" me to separate the parsing logic and the handling logic, which is a switch that is doable for me... unless both logics get 'inter-mingled'? The

Re: perl6-regex: retaining $/.pos after an unsuccesful match without a temporary variable?

2019-08-18 Thread Brad Gilbert
The Perl6 regex system was simplified. Instead you use the rest of Perl6 to implement those features. Both inside and outside of the regexes. (Which means there are fewer esoteric features that are rarely used, and often forgotten or never learned.) It might be best to just store the position at

perl6-regex: retaining $/.pos after an unsuccesful match without a temporary variable?

2019-08-18 Thread Raymond Dresens
Hello, In the past few days I've been converting some "incremental parsing"-regex code from perl 5 to perl 6 (I haven't not touched grammars, yet...) In Perl 5 I often used the /g and /c modifiers so that the following snippet of code doesn't die: # perl5 my $test = " foo bar";