Perl 6 - the future is here, just unevenly distributed

IRC log for #marpa, 2017-12-18

| Channels | #marpa index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:14 idiosyncrat joined #marpa
00:21 idiosyncrat amon: https://gist.github.com/jeffreykegler/0a589188553530c5a54d794c4136c271
00:22 idiosyncrat The key here is that ranking is within *symbol instances*.  The relative rank of two parse choices which are not in the same symbol instance has no effect.
00:23 idiosyncrat A symbol instance is a <symbol, start, end> triple, where "symbol" is a g1 symbol, and "start" and "end" are G1 positions.
00:24 idiosyncrat For a lexeme, "symbol" is the lexeme symbol.
00:24 idiosyncrat For a rule, "symbol" is the LHS.
00:25 idiosyncrat In your original, the ranks could never have any effect because, while they did share the same symbol instance (LHS), your alternatives could never occur in the same symbol instance, because start and/or end would be different.
00:27 idiosyncrat Note my solution in the gist is somewhat hackish -- it only ranks correctly for a finite number of choices on the LHS.
00:27 idiosyncrat That is very much in the spirit of PEG, however. :-)
00:27 idiosyncrat For a more general solution, ASFs could be used.
00:28 idiosyncrat Note that ASFs are very likely to change totally in Marpa::R3.
00:29 idiosyncrat Another hack-ish extension is to make the lists up out of pieces, where the pieces are assembled in a way the enforces your ranks locally.
00:31 idiosyncrat With regard to the missing parse for the last case, that is interesting, and I will investigate.
00:31 idiosyncrat Thanks, jeffrey
02:58 ilbot3 joined #marpa
02:58 Topic for #marpa is now Start here: http://savage.net.au/Marpa.html - Code paste/run: https://f.perlbot.pl/#marpa - Jeffrey's Marpa site: http://jeffreykegler.github.io/Marpa-web-site/ - IRC log: http://irclog.perlgeek.de/marpa/today - Youtube channel: https://www.youtube.com/channel/UCYKVfGBtfTqbs1JdYq-dc5g
03:32 idiosyncrat amon: I'm still looking into the "missing" parses in your example -- my belief is they're not really missing, but were eliminated by the normal operation of rule ranking.
03:33 idiosyncrat Annoyingly, however, the more I look at rule ranking the more I realize (while I think I understood it once upon a time), I need to work on describing the exact algorithm.
03:34 idiosyncrat amon: the description I gave you beginning at https://irclog.perlgeek.de/marpa/2017-12-18#i_15592055 is not right.
03:35 idiosyncrat And there definitely is no adequate description in the Marpa::R2 docs :-(
03:37 idiosyncrat Again, thanks, amon.  While it's not exactly exhilarating to see the state I left the rule ranking documentation in, and I'm about to rewrite it completely in R3, I need to understand what I did in R2 first.
04:13 ronsavage joined #marpa
05:52 idiosyncrat amon: In the good news --
05:52 idiosyncrat Marpa::R2 ranking is more powerful than I'd remembered.
05:52 idiosyncrat https://gist.github.com/jeffreykegler/ab2d3a78197bda42e976ae2131f49841
05:52 idiosyncrat And it does allow R2 to be used as a better and more powerful PEG.
05:53 idiosyncrat At least, that's my guess.  The gist just pasted shows how to do your example using R2's rule ranks.
09:44 hobbs joined #marpa
09:44 hobbs joined #marpa
10:34 amon_ joined #marpa
10:37 amon_ Re: https://irclog.perlgeek.de/marpa/2017-12-18#i_15593812
10:38 amon_ Thank you, that seems to work. Though I don't really understand why.
10:39 amon_ If I poke at the grammar too much, the weird parses reappear again. For example, why is the production "List ::= Item" necessary? Why isn't "List ::= ;" sufficient?
10:40 amon_ So far, I have been unable to create a sufficiently accurate mental model for rule ranks.
10:43 amon_ Hmm, a genetic algorithm that tries to find correct rules + ranks for a Marpa grammar sounds like “fun”
10:45 amon_ left #marpa
12:28 amon_ joined #marpa
12:29 amon_ I have now finished porting my ad-hoc parser first to Marpa::R2 and then Marpa::R3.
12:29 amon_ For my use case, the ad-hoc parser was actually the fastest, but R3 is bearable.
12:29 amon_ Given the increased maintainability by specifying the grammar as BNF not code, that's a fair tradeoff.
12:29 amon_ Evaluation with R3 is fast, as it should be. No more recce reinitialization :)
12:29 amon_ In my NYTProf profiles, the Lua interface is very prominent. A good part of this will just be from crossing the Perl–XS–Lua boundary repeatedly.
12:30 amon_ But the most time is spent in the Lua block_new().
12:30 amon_ This seems to be because block_new() pre-processes the whole input string, although I only need to parse tiny documents of unknown length within this input.
12:30 amon_ I don't think I can share a pre-processed input block between multiple recces, or reset a parse so that a recce can be reused?
12:31 amon_ In a way, this is related to issue 40 (line and col setter), except that I don't need Marpa to be aware of lines at all.
12:33 amon_ But these are good problems to have – everything is working, just not quite as fast as I would have dreamt.
12:37 amon_ left #marpa
16:27 idiosyncrat joined #marpa
16:27 idiosyncrat amon: re https://irclog.perlgeek.de/marpa/2017-12-18#i_15594458
16:28 idiosyncrat List ::= Item is needed so that it can have its own rank adverb
16:29 idiosyncrat My next priority is to write up how ranks work in R2, and you can be the guinea pig for that document. :-)
16:29 idiosyncrat I don't blame you not understanding.  My docs were no help at all.
16:30 idiosyncrat And it's complicated -- it took me some time reading the code to remind myself how ranks worked.
16:30 idiosyncrat Btw, re
16:30 idiosyncrat LIst ::= ; List::= List Item
16:30 idiosyncrat vs.
16:31 idiosyncrat LIst ::= ; List ::= Item; List::= List Item
16:32 idiosyncrat The first form is used in the literature, because it's shorter and seems more elegant and they don't have to actually implement a fast general parser. :-)
16:33 idiosyncrat In fact, in the implementation, there are 3 cases which must be distinguished, even if in BNF they can be written as 2.
16:34 idiosyncrat List::= Item needs its own rank, and why will (I hope) become clear from its own document.
16:35 idiosyncrat re https://irclog.perlgeek.de/marpa/2017-12-18#i_15594800 -- R3 efficiency
16:36 idiosyncrat There are considerable temporary inefficiencies in R3 because of my incremental conversion.  R3 will always do a lot of Lua/Perl boundary crossing, but currently there is a lot of that that is wasteful and will be eliminated as development proceeds.
16:39 idiosyncrat amon: re https://irclog.perlgeek.de/marpa/2017-12-18#i_15594804 -- I wonder if treating each such "tiny document" as a separate block might not be more efficient in your case.
16:39 idiosyncrat When created, blocks are pre-processed.
16:43 idiosyncrat Perhaps there are possible optimizations lurking in block_new(), but they say not to optimize prematurely and for once it may be best to listen to that advice. :-)
21:05 idiosyncrat joined #marpa
22:06 ronsavage joined #marpa
22:28 ronsavage JK: Re https://irclog.perlgeek.de/marpa/2017-12-18#i_15593812. I've made a note that when the new R2 ranks docs are ready, I'll add this demo to MarpaX::Demo::SampleScripts and the FAQ.
23:45 idiosyncrat ronsavage: re https://irclog.perlgeek.de/marpa/2017-12-18#i_15596903 -- Thanks!

| Channels | #marpa index | Today | | Search | Google Search | Plain-Text | summary