18 Oct 2021
gfldex consider: (my $oddject = Metamodel::ClassHOW.new_type(name => "")).&{.^add_method('FALLBACK', method ($name) { 'cheating' }); .^compose}; 18:25
Nemokosch oddject xD 19:30
colemanx Hello everyone. I've written a grammar, and it seems to have pinned a cpu, and my program doesn't finish. 23:15
Here is the github gist: envs.sh/AN 23:16
There is some sample data attached there, as well. I am familiar with regex, but not sure why the program doesn't finish. 23:17
[Coke] what are you passing as the path? 23:20
oh, data. 23:22
I recommend using Grammar::Debugger. 23:30
if you install that and use it in your program, you can see that it matches the first sep, and then tries to match an item and immediately goes into the weeds
also: "item" is apparently special, don't use that as a name. 23:40
once it starts parsing, you start getting errors about wrong number of args because it's trying to give it to a different item. 23:41
gist.github.com/coke/f1d594983af0a...3cbc235608 23:42
colemanx Thank you, I was afk for a bit, but I'll install Grammar:Debugger 23:56
19 Oct 2021
CIAvash .tell colemanx your main issue is `\s*`, which should be `\s+`, but also `\w+` won't match punctuation. Also you can match the whole file with grammar, no need to match line by line: `grammar Row { token TOP { <line>+ }; token line { <sep> [ <cell> ** 5 %% <sep> ] \n? }; token sep { '|' }; token cell { <-[|]>+ }; }`. you can make cell `<-[|\n]>`, and remove ` ** 5` if cells are not supposed to have newlines. 05:52
colemanx I have ended up using .split to just solve the problem without grammars. But I will try again on my next parsing problem 17:29
I am reshaping a lot of my company's documentation this sprint, and little scripts are saving my life :) 17:30
I like Raku regexes, I am just not used to writing them, yet
20 Oct 2021
RaycatWhoDat ^ 13:56
22 Oct 2021
mori how can i make rakudo stop creating ~/.raku folder 02:56
i want to use XDG spec for it
Rogue I think `--rakudo-home=XXX` 15:06
24 Oct 2021
Anton Antonov Hi! I think there should be a more direct and concise way to do following check: `‌‌[and] ['dfd', 1, 2, NaN, 32, Whatever].map({ $_ ~~ Numeric or $_ ~~ NaN })` . I want to verify that the elements of an array are one of two possible classes/objects. I tried coming up with an `.all` statement without much success. E.g. `[1, 2, 32, NaN] ~~ (Numeric | NaN)`. 17:41
Hi! I think there should be a more direct and concise way to do the following check: `‌‌[and] ['dfd', 1, 2, NaN, 32, Whatever].map({ $_ ~~ Numeric or $_ ~~ NaN })` . I want to verify that the elements of an array are one of two possible classes/objects. I tried coming up with an `.all` statement without much success. E.g. `[1, 2, 32, NaN] ~~ (Numeric | NaN)`.
Hi! I think there should be a more direct and concise way to do the following check: `‌‌[and] ['dfd', 1, 2, NaN, 32].map({ $_ ~~ Numeric or $_ ~~ NaN })` . I want to verify that the elements of an array are one of two possible classes/objects. I tried coming up with an `.all` statement without much success. E.g. `[1, 2, 32, NaN] ~~ (Numeric | NaN)`.
Bearhug ```perl 17:55
> [1,2,32,NaN].all ~~ (Numeric | NaN)
True
> [1,'s',32,NaN].all ~~ (Numeric | NaN)
False
> [].all ~~ (Numeric | NaN)
True
```
Anton Antonov Hi! I think there should be a more direct and concise way to do the following check: `‌‌[and] ['dfd', 1, 2, NaN, 32].map({ $_ ~~ Numeric or $_ ~~ NaN })` . I want to verify that the elements of an array are one of two possible classes/objects. I tried coming up with an `.all` statement without much success. E.g. `[1, 2, 32, NaN].all ~~ (Numeric | NaN)`. 18:07
@Bearhug#1761 No, that does not work -- I tried that. (I pasted incorrect code in my question above, it is corrected now.) To see that it does not work try this: `‌‌['dfd', 1, 2, 32, NaN].all ~~ (Str | Numeric | NaN)` . 18:11
@Bearhug#1761 No, that does not work -- I tried that. (I pasted incorrect code in my question above, it is corrected now.) To see that it does not work try this: `‌‌['dfd', 1, 2, 32, NaN].all ~~ (Str | Numeric | NaN)` . (Gives `False`.) 18:12
gfldex m: say NaN.WHAT; 18:52
@Anton Antonov#7232 NaN is not a typeobject. You have to use `.isNaN` . 18:53
m:``` 18:55
subset StrNumeric where * ~~ Str | Numeric;
say ('dfd', 1, 2, NaN, 32).all ~~ StrNumeric;
```
Any fancy type check is best placed inside a subset.
Morfent `['dfd', 1, 2, 32, NaN].all ~~ (Str | Numeric | NaN)` doesn't work because it expands to `(.all ~~ Str) | (.all ~~ Numeric) | (.all ~~ NaN)` 18:58
Anton Antonov @Morfent#9811 Thanks, that clarifies it. 19:00
25 Oct 2021
coleman-x Is there any limitation - in principle - to what a Raku grammar can parse? 16:51
My understanding is that Raku itself can be parsed with a Raku grammar.
Is that true?
lizmat yes, that's how the Rakudo is set up, yes 16:58
coleman-x amazing :) 17:34
lizmat and yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2021/10/25/2021-43-thank-you/ 17:49
Anton Antonov coleman-x You might want to be interested to see this repository: github.com/drforr/perl6-Perl6-Parser 20:01
coleman-x You might want to be interested to see this repository: github.com/drforr/perl6-Perl6-Parser 20:02
coleman-x You might be interested to see this repository: github.com/drforr/perl6-Perl6-Parser 20:07