Perl 6 - the future is here, just unevenly distributed

IRC log for #marpa, 2014-01-16

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

All times shown according to UTC.

Time Nick Message
23:18 ilbot3 joined #marpa
23:18 Topic for #marpa is now Current release: https://metacpan.org/pod/Marpa::R2   Source: https://github.com/jeffreykegler/Marpa--R2   public logs at http://irclog.perlgeek.de/marpa/today
00:29 jeffreykegler joined #marpa
02:59 jeffreykegler joined #marpa
03:50 jeffreykegler1 joined #marpa
05:14 LWA joined #marpa
06:49 jeffreykegler1 left #marpa
08:22 LLamaRider joined #marpa
09:46 ronsavage joined #marpa
13:36 LLamaRider joined #marpa
14:55 lucs If my Marpa::R2::Scanless::R instance has already performed a read(), and I want to parse a different input string, I need to create a new instance?
14:56 lucs (I was thinking there could be a 'reset' method or something, but I'm not finding anything like that.)
15:17 lucs lucs: Yes, you need to create a new instance. Note that the grammar has already been built in a G instance, so a ...::R->new() is roughly equivalent to the 'reset' you want.
15:17 lucs lucs: Ah, okay.
15:17 lucs (I don't always talk to myself, but when I do, it's because I realize I didn't think very far before asking a question.)
15:33 LLamaRider nice discussion there :)
15:39 lucs Thanks ;)
16:10 lucs How can I parse a CSV type list with empty elements, like "a,b,,c"?
16:15 lucs Hmm... I just thought of the fact that I could try something that doesn't use a quantified rule (which keeps leading me to nullable symbol problems).
16:17 lucs Yay!
16:20 lucs (Whoops, ran the wrong test :( )
16:28 lucs Nope, I can't figure it out. I'll keep trying, but I'd appreciate it if someone could point me in the right direction or show me a grammar that can parse 'a,b,,c' into a four-element array, à la CSV.
17:17 rns_ joined #marpa
17:20 LWA joined #marpa
17:25 jeffreykegler joined #marpa
17:26 LWA lucs: The pragmatic answer is "use Text::CSV;"
17:27 LWA Otherwise, could you post a link to the grammar you tried for the "a,b,,c" problem?
17:28 lucs Text::CSV would be fine, but actually I'm trying out stuff to learn Marpa
17:29 jeffreykegler lucs: you need to write the left recursion yourself, in BNF.
17:30 lucs jeffreykegler: Okay. I'll try to work that out.
17:30 jeffreykegler list ::= element ; list ::= list ',' element ; element ::= 'a' | 'b' | 'c'
17:30 jeffreykegler I haven't had coffee yet ...
17:30 jeffreykegler but I hope that's right
17:30 jeffreykegler Oops!
17:31 lucs Hmm... I believe I tried something similar, but couldn't get it to work with empty elements.
17:31 jeffreykegler Forgot the main point: element ::= empty
17:31 lucs Right :)
17:31 jeffreykegler Doesn't that work?
17:31 lucs Let me try again...
17:32 lucs Oh, that's not really what I had.
17:33 lucs (Turns out what I had was a bit screwy now that I compare it to what you just showed.)
17:34 jeffreykegler By the way, you can also write it as a right recursion, and Marpa handles that in linear time ...
17:34 jeffreykegler but with a bit of extra constant-time internal overhead, so with Marpa you should show a slight preference for left recursion.
17:35 jeffreykegler That's a trace of it's Earley heritage.
17:35 lucs I'm at the "get it right" phase at this moment, but thanks for pointing it out.
17:36 jeffreykegler I'm jumping ahead because if you master left- and right- recursion and translation between them ...
17:36 jeffreykegler you are pretty much a BNF expert
18:09 lucs I can't get the semantics together :(  Here is what I have (semanticsless), with test cases. Can someone kindly nopaste a grammar that would make those tests pass? :  http://scsys.co.uk:8002/291625
18:34 jeffreykegler lucs: http://scsys.co.uk:8002/291626
18:36 jeffreykegler I didn't finish it, but I hope gave you enough to take the next step.
18:36 jeffreykegler It's a example of how to set up to work out the semantics.
18:37 jeffreykegler A disadvantage of not using sequences is the you have to unravel the sequence from the left recursion yourself, but you can do this rather elegantly with my standard dwim() action
18:38 lucs jeffreykegler: Thanks a bunch! I'll work on that.
18:38 jeffreykegler That's in my old blog posts in several versions, but basically it's these steps:
18:38 jeffreykegler Is there only one child value?  If so, return it
18:39 jeffreykegler Is there more than one?  If so, return an array of the child values.  (Optionally, you can filter out undef's, if that's better in your case.)
18:40 jeffreykegler The ::array semantics can be looked at as a stupid form of this, which always returns an array even if there is only one child value.
18:41 lucs Ah. I kind of suspected there would be some work necessary outside of the grammar itself, but I thought I might just be missing something.
18:41 lucs Thanks again!
18:41 spacebat joined #marpa
19:12 LWA So, today I wrote my first lexer using the THIF. A quick question on that though:
19:12 LWA jeffreykegler: does Libmarpa guarantee that rule IDs and symbol IDs are a continuous range of integers, so that they can be used for array indexing?
19:13 LWA I can't find an explicit guarantee in the docs
19:14 jeffreykegler LWA: That's deliberate.
19:14 jeffreykegler Right now they are a continuous range, but I chose not to guarantee that.
19:15 jeffreykegler I think you get the idea -- I try to keep backward compatibility on guarantees ...
19:16 LWA ok thanks. so hashes instead of arrays it is.
19:16 jeffreykegler and I try not to paint myself into a corner.  I'm not sure why I would ever need discontinuous ranges, but just in case ...
19:17 jeffreykegler In my processing I use arrays, but check for "missing" or "deleted" elements.
19:17 jeffreykegler In the current implementation, these do not exist, but I've left that open.
19:18 LWA hmm. but are the IDs at least guaranteed to start low (0 or 1) and to always be positive?
19:19 jeffreykegler Yes
19:20 jeffreykegler There is a call to get the highest one, and my code assumes they are thickly populated from 0 to that highest number.
19:21 jeffreykegler If it's enormously convenient, I'll consider issuing the guarantee.
19:21 LWA So what I gather from that is that *technically*, the distribution of rule IDs is undefined behaviour, but I might as well use them as indices as long as I don't assume that each index is actually populated.
19:22 jeffreykegler My own code uses them as indices into an array
19:22 jeffreykegler If that stops being a good idea, I'm in trouble.
19:23 jeffreykegler LWA: Your last is right on the mark.
19:23 jeffreykegler Just don't assume that every index is populated and any misbehavior is a bug in Libmarpa
19:24 LWA well, thanks!
20:52 jeffreykegler left #marpa
22:44 ronsavage LWA and lucs: use Text::CSV::Encoded rather than Text::CSV
22:45 jeffreykegler joined #marpa

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