This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html
Set by lizmat on 8 June 2022.
00:13 lizmat_ joined 00:15 lizmat left 00:18 lizmat_ left, lizmat joined 03:18 nicole left, nicole joined 07:40 lucs_ joined 07:44 lucs left 08:14 CIAvash joined 09:07 CIAvash left
librasteve o/ 11:33
(how) can an enum be used in a regex or grammar token to match it's .keys? 11:34
nemokosch Do you know <?{}> 14:15
librasteve oh yes - thanks! 16:53
scullucs Er, I don't. How does that work? 17:24
librasteve i have used it like this before: my regex number { \S+ #grab chars <?{ +"$/" ~~ Real }> #assert coerces via '+' to Real } 17:53
it's a lookahead assertion (ie a wrapper for a function) where the regex matches only if the the fn is True 17:55
so I guess with an enum its like this... 17:57
enum Colour <red green blue>; my regex colour { \S+ #grab chars <?{ "$/" ~~ Colour }> #assert checks match string is Colour } 17:58
18:21 habere-et-disper joined
Nahita m: my enum E<yes no>; say so "this has yes in it" ~~ / @(E.keys) / 18:35
Raku eval True
librasteve m: my enum E<yes no>; say so "this has yes in it" ~~ / @<E.keys> / 18:36
Raku eval False
librasteve m: my enum E<yes no>; say so "this has yes in it" ~~ / <E.keys> / 18:37
Raku eval Exit code: 1 ===SORRY!=== Error while compiling /home/glot/main.raku Unable to parse expression in metachar:sym<assert>; couldn't find final '>' (corresponding starter was at line 1) at /home/glot/main.raku:1 ------> no>; say so "this has yes in it" ~~ / <E⏏.keys> / expecting any of: term
librasteve @Nahita - yes that's even better ...tx! 18:38
(strangely I read the docs about interpolation in a regex like '$()' yesterday, but already forgot the '@()' 18:39
)
scullucs @librasteve, @Nahita thanks for the examples. 19:00
19:07 deadmarshal_ left 19:12 deadmarshal_ joined 20:11 habere-et-disper left 21:17 habere-et-disper joined
habere-et-disper I have a working grammar but the files to parse are embedded in handcrafted HTML. The grammar starts with an unambiguous marker. How do I ignore the cruft on either side of what I want to parse? 21:42
MasterDuke `.*<unambiguous marker>.*`? or maybe try `.subparse`, instead of `.parse` 23:34
habere-et-disper Thanks, I'll give that a go. Rather than `.*` I thought matching anything but the marker would be clearer but I'm not sure how to invert the match of a fixed string. 23:59