»ö« Welcome to Perl 6! | perl6.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: irc.perl6.org or colabti.org/irclogger/irclogger_log/perl6 | UTF-8 is our friend! 🦋
Set by Zoffix on 25 July 2018.
dduncan What are the best working examples available now for Perl 6 grammars to parse another programming language or serialization format? I have a quasi-EBNF-rules-hybrid I made for documenting one and now I want to render it as actual Perl 6 rules that I can execute. So I’m looking for some good examples. As my format is like a more strongly typed JSON, an existing grammar to parse JSON is probably a good example. Thank you. 01:05
dduncan To be specific, I want to turn this github.com/muldis/Muldis_Object_No...otation.md into a working Perl 6 grammar. 01:07
timotimo JSON::Tiny has a simple grammar for parsing JSON, that's a good start 01:08
dduncan Thank you. 01:09
timotimo there's a module that parses ANTLR grammars and turns them into perl6 grammars
buggable: eco ANTLR
buggable timotimo, Found 2 results: ANTLR4::Grammar, ANTLR4::Grammar. See modules.perl6.org/s/ANTLR
timotimo buggable: eco Grammar
buggable timotimo, Found 24 results: Grammar::Debugger, ANTLR4::Grammar, ANTLR4::Grammar, Grammar::BNF, GGE. See modules.perl6.org/s/Grammar
dduncan My grammar as seen above is a proprietary format, influenced by EBNF but actually mostly meant to look like Perl 6 rules, so it’ll have to be manual conversion.
Oh sorry, I understand what you meant, thank you. 01:10
timotimo you could derive from ANTLR4's grammar to parse your own self-invented grammar :) :)
Kaiepi unrelated but i need to learn more... creative ways to use grammars for my telnet library, is antlr4 a good way to learn that? 01:12
timotimo not sure
Kaiepi i need either some way to error out or some way to stop parsing if an error is found
timotimo i haven't actually looked at the antlr4 implementation, nor antlr4 itself
or any of the antlrs for that matter
Kaiepi ah 01:13
timotimo YAMLish has some error handling stuff in it
or maybe only in my fork
Kaiepi i'll take a look at it, thanks 01:14
yeah there is some error handling stuff in it 01:19
Xliff If I have a sub(&callback(int32)) is native...; how can I pass NULL as &callback without rakudo blowing up? 01:49
would this work: sub(-> int32 { }) 01:50
Not as efficient as NULL but... 01:51
I'm currently using sub(Callable), which blows up. 01:52
timotimo could try with a $ sigil 01:53
Xliff Would that work as a default for a wrapper? 01:54
so... method wrapper (&func = $) { sub(&func) } 01:55
And... no.
timotimo that's not how i meant it :) 02:21
i meant to have the $ sigil in the signature itself
Xliff Oh 02:22
Thanks! Will try. %)
timotimo: Ever heard of Rudimental?
Music group 02:23
timotimo i have not, though i know like two rudiments that i can "play" on the drums 02:27
Xliff :) 02:28
OK. Error now is.
Native call expected return type with CPointer representation, but got a P6opaque (Scalar)
Which I think is coming from &func.
Since &func == P6opaque
timotimo interesting that it'd see the scalar rather than its inside value 02:29
Xliff Callable == Uninstantiable
Weird thing is that it goes through that call chain once, with no problem. Second time it reports the error. 02:30
Xliff OK. So if I specify NC def as sub(&func (Signature)) it will throw CPointer rep error second time through. 03:06
It doesn't matter WHAT Signature is. &func can even match.
But this is SECOND time around. First time around, it works. 03:07
Xliff Yup. Error occurs second time I run the set-function-sub 04:12
Don't understand why that's a thing. It does the same thing both times.
jmerelo m: say Mu.^methods.elems 09:35
camelia 53
jmerelo m: say Mu.^methods[0].elems
camelia 1
jmerelo m: say Mu.methods
camelia No such method 'methods' for invocant of type 'Mu'
in block <unit> at <tmp> line 1
jmerelo m: say Mu.^methods
camelia (self sink ACCEPTS WHERE WHICH iterator split emit take return-rw return WHY set_why Bool so not defined new is-lazy CREATE bless BUILDALL BUILD_LEAST_DERIVED Numeric Real Str Stringy item say print put note gistseen gist perlseen perl DUMP DUMP-PIECE…
jmerelo m: say sub.^mop 09:36
camelia 5===SORRY!5=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> 3say sub7⏏5.^mop
expecting any of:
new name to be defined
jmerelo m: say sub.^mst
camelia 5===SORRY!5=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> 3say sub7⏏5.^mst
expecting any of:
new name to be defined
jmerelo m: say sub.^mro 09:37
camelia 5===SORRY!5=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> 3say sub7⏏5.^mro
expecting any of:
new name to be defined
jmerelo m: say Sub.^mro
camelia ((Sub) (Routine) (Block) (Code) (Any) (Mu))
buggable New CPAN upload: Archive-Libarchive-0.0.11.tar.gz by FRITH modules.perl6.org/dist/Archive::Lib...cpan:FRITH 09:45
jmerelo m: "👋  mundo".say 09:56
camelia 👋  mundo
jmerelo m: "☻ mundo".say 09:57
camelia ☻ mundo
jmerelo m: say (þor => 127).perl 11:34
camelia :þor(127)
jmerelo m: say (foo => 127).perl 11:35
camelia :foo(127)
jmerelo m: say (foo_bar => 127).perl
camelia :foo_bar(127)
jmerelo m: say (_foobar => 127).perl
camelia :_foobar(127)
jmerelo m: say (foo-bar => 127).perl 11:36
camelia :foo-bar(127)
jmerelo m: say (foo-bar'baz => 127).perl
camelia :foo-bar'baz(127)
jmerelo m: say (foo::bar'baz => 127).perl 11:37
camelia 5===SORRY!5=== Error while compiling <tmp>
Preceding context expects a term, but found infix => instead.
at <tmp>:1
------> 3say (foo::bar'baz =>7⏏5 127).perl
jmerelo m: say (foo:bar'baz => 127).perl
camelia 5===SORRY!5=== Error while compiling <tmp>
Preceding context expects a term, but found infix => instead.
at <tmp>:1
------> 3say (foo:bar'baz =>7⏏5 127).perl
Geth doc: f13eb68f27 | (JJ Merelo)++ | 2 files
Avoiding unwanted like wraps that make tables confusing.

Also adds example of bareword-as-key, refs #2520. Waiting for answer to [this question in SO](stackoverflow.com/q/53977575/891440) for precise definition of what constitutes a codeword.
12:39
tbrowder hi, #perl6! \o/ I hope you had a Merry Christmas // Happy Holiday 15:55
granddaughters got Chromebooks from Santa (‘twasn’t my idea!)—any way to use them for p6 coding? 15:57
timotimo at the very least you can use rakudo.js via 6pad, though it's still a little limited 15:59
tbrowder timotimo: thnx 16:33
jmerelo tbrowder: don't they actually have some kind of linux underneath? Is there any way of getting to the command line? 16:34
tbrowder hi, JJ! i don’t know, but i’m going to see them this pm and will investigate 16:36
jmerelo tbrowder: hi! 16:36
El_Che jmerelo: not without rooting, I thought 16:37
jmerelo tbrowder, El_che: there seems to be something called "crouton": www.reddit.com/r/perl/comments/4eb..._chromeos/ 16:38
Geth doc: 6aa90da588 | (JJ Merelo)++ | 2 files
Clarify appearances of 'fat comma' refs #2520
16:55
doc: aa2eb63f9a | (JJ Merelo)++ | doc/Type/Pair.pod6
Adds information on 'bareword' Pair declaration, closes #2520
synopsebot Link: doc.perl6.org/type/Pair
jmerelo Is there a way to see the programs in code-golf.io? 17:28
I keep circling from leaderboard to leaderboard, but finding the actual code seems impossible...
lizmat jmerelo: this is discussed in github.com/JRaspass/code-golf/issu...-450356444 17:29
in short: no
jmerelo lizmat: does not make a lot of sense... 17:31
lizmat well... depends on how you look at it... :-) but clearly code-golf.io is more about those who can rather than for those who can learn 17:32
jmerelo the thing is, there are not that many sites that published well explained Perl 6 examples 17:33
examples.perl6.org seems a bit abandoned...
timotimo there are some not so stellar examples in there, too. and categories that were obviously meant to become big courses of multiple entries and only have a few, ... 17:52
moritz maybe refurbishing examples.perl6.org would be a better idea than starting new?
I know starting something new is alwasy more fun...
jmerelo moritz: yep... 17:56
I just created an issue today, we could start there...
AlexDaniel squashable6: next 19:40
squashable6 AlexDaniel, ⚠🍕 Next SQUASHathon in 4 days and ≈14 hours (2019-01-05 UTC-12⌁UTC+14). See github.com/rakudo/rakudo/wiki/Mont...Squash-Day
AlexDaniel weekly: better squashathon link here: github.com/rakudo/rakudo/wiki/Test...athon-page 19:40
notable6 AlexDaniel, Noted!
rindolf nadim: hey, what's new? 20:26
masak fun fact: "static" is an even stronger guarantee than "at compile time". 21:16
sena_kun masak, may I ask for an example? 21:27
the phrase is a bit too broad to me. :S 21:28
masak sena_kun: to be clearer, "statically" means "what we can glean from just reading the program" (or some such) 21:33
some things are known at compile time, but not statically
my concrete example right now is, 007 has a (very necessary) `import * from some.module;` form -- the `*` means we just accept everything from the module's export list 21:35
we know what we're importing from that module at compile time/BEGIN time, at the point we're compiling the import (and actually importing the things)...
...but we don't know it statically
sena_kun masak, hmm, it seems our inferential distance is a bit too long. If "statically" as in typing, isn't it available at compile-time anyway? _Plus_ some possible stuff. 21:36
I mean, in strict+static typed language... which 007 clearly is not, of course. 21:37
masak it doesn't have a clean separation between types and values, no 21:38
sena_kun well, types as first-class citizens is another topic
masak there's an issue github.com/masak/007/issues/33 which wants to layer a static type system on top of 007, a la TypeScript 21:39
(but it's kind of low-priority, as it doesn't lie on the critical path of exploring macros) 21:40
sena_kun I mean, for example, you have a strictly typed language where everything is checked at compile-time. And we can bring there in some compile-type code that will be executed too. Of course, it will be appropriately typed and checked too). Of course, static type allow you some reasoning based on that(this is what you possibly can mean with "guarantee"), but given compile-type code works the same way, just compiled more early, I don't grasp 21:43
it. :S
I wonder if there are some prerequisites for it. :)
s/type allow/types allow/ 21:44
loops m: sub x() { KEEP print 2 ; print 1 } ; x 22:01
camelia 12
loops m: sub x() { KEEP print 2 } ; x 22:02
camelia ( no output )
loops ^^ seems odd
timotimo well, how can KEEP know what it'll return before it gets executed?
loops timotimo: isn't the invocation of the sub enough? 22:03
timotimo no, keep only runs when the containing scope has been left with "success"
m: sub x() { KEEP print 2; 0 }; x
camelia 2
loops so returning from an empty sub is not success
timotimo m: sub x() { KEEP print 2; Nil }; x
camelia ( no output )
loops got it.. 22:04
timotimo m: sub x() { KEEP print 2 }; say x
camelia Nil
loops thanks.
timotimo m: sub x() { return 1; KEEP print 2 }; say x
camelia 21
timotimo m: sub x() { return Nil; KEEP print 2 }; say x
camelia Nil
loops timotimo: makes sense, it's not odd at all :-) 22:04
timotimo we don't quite have time travel down yet 22:05
loops timotimo: i'm not sure what you mean by that... but I got it.. the empty sub returns Nil, which isn't successful
loops timotimo: and KEEP only runs on success 22:05
timotimo it's not an empty sub when it has a KEEP in it 22:06
but the KEEP only runs until after the return value has been determined, so it can't contribute to it 22:07
loops timotimo: empty except for the KEEP *
timotimo and KEEP itself evaluates to Nil, and since it's the last thing in the sub, that gets returned
loops timotimo: ah, that's an interesting detail.
lizmat and yet another Perl 6 weekly hits the Net: p6weekly.wordpress.com/2018/12/30/...e-perljam/ 22:29
tadzik :(( 22:30
timotimo :( 22:31
lizmat yeah :-(
masak :( 22:33
buggable New CPAN upload: Hash-Agnostic-0.0.4.tar.gz by ELIZABETH modules.perl6.org/dist/Hash::Agnost...:ELIZABETH 23:15
jnthn masak: Where did you find such a narrow definition of "statically", ooc? I've never consider it that narrow. 23:27
masak dunno. it's also entirely possible that I'm wrong about the definition. 23:29
jnthn We'd probably agree Java is statically typed, and it has the * thing going on in imports too :) 23:30
sena_kun .oO ( and those imports don't exist )
masak hmm. 23:31
sena_kun m: grammar A { token TOP { <value> } proto token value {*}; token value:sym<a> { 'a' }; token a-value { #'( PSEUDOCODE HERE -> ) <value:a> } }
camelia 5===SORRY!5=== Error while compiling <tmp>
Strange text after block (missing semicolon or comma?)
at <tmp>:1
------> 3grammar A { token TOP { <value> }7⏏5 proto token value {*}; token value:sym<
expecting any of:
infix…
masak I wasn't talking about "statically typed" at all, just the notion of some knowledge being static.
sena_kun is there a way to reference a particular rule under proto, not proto rule itself? 23:32
masak but I also realize that my example was a bit wobbly, since... likely one *does* have access, statically, to the imported module, and then everything's analyzable again.
timotimo sena_kun: i'd assume you could use its full name?
masak you can, IIRC
sena_kun timotimo, as in? `<value:a>`?
let me try it...
timotimo probably <value:sym<a>> 23:33
sena_kun hmm, I tried this iirc... let me check again
masak m: grammar G { regex TOP { <x:y> }; proto regex x { * }; regex x:y { "y" } }; say ?G.parse("y")
camelia True
masak ^
sena_kun ok, at least it compiles ok. \o/ 23:34
timotimo, masak: thanks.
though Comma seems to get `sym` part in `<value:sym<number>>` as a sub call. :) 23:35
masak 'night, #perl6
timotimo oh, with a colon? that's a little funky :)
sena_kun masak, night. o/
jnthn sena_kun: That's 'cus I didn't fix that ticket you filed about it a while ago :P
masak: o/
sena_kun lol
jnthn Maybe next week...should be a nice gentle back-to-work task for me :) 23:36
sena_kun It might be. I also filled a ticket regarding regexes rename, will be nice for me to fix too. Spent almost all evening on a certain grammar implementation and it's night already. 23:39
jnthn :) 23:40