Perl 6 - the future is here, just unevenly distributed

IRC log for #marpa, 2014-10-16

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

All times shown according to UTC.

Time Nick Message
01:48 ilbot3 joined #marpa
01:48 Topic for #marpa is now Start here: http://savage.net.au/Marpa.html - Pastebin: http://scsys.co.uk:8002/marpa - Jeffrey's Marpa site: http://jeffreykegler.github.io/Marpa-web-site/ - IRC log: http://irclog.perlgeek.de/marpa/today
03:07 ronsavage joined #marpa
03:13 CQ_ joined #marpa
04:00 rns joined #marpa
05:28 jeffreykegler joined #marpa
05:29 jeffreykegler rns: Actually I'm at the point with MetaLua where I need the details in the manuals.
05:29 jeffreykegler It looks like your original approach to parsing the LUIF will have to be the one we use ...
05:30 jeffreykegler MetaLua's parser is a strictly deterministic "combinator parser" -- a left parsier with a kind of functional programming-friendly interface.
05:31 jeffreykegler It relies on every new statement beginning with a unique keyword to identify it.  (Remember how I said that the Irons 1961 algorithm could be brought out today and presented as new and powerful?)
05:32 jeffreykegler So you can't add a statement of the form "lhs ::= [stuff] ..." and use MetaLua's gg parser.
05:33 jeffreykegler Nevertheless MetaLua has all sort of powerful tools, including a pretty comprehensive facility for going back and forth between Lua code and Lua AST's, so I expect we'll find some use for it.
05:35 jeffreykegler rns: We can parse the LUIF using the approach you've already written up.  Once Jean-Damien's wrapper reaches a sufficient point, we can use that to parse, and move away from the Perl script to a pure Lua approach ...
05:35 jeffreykegler then I'll start bringing in the SLIF features.
05:38 jeffreykegler rns: Switching topics to parse forests ...
05:39 jeffreykegler Grune&Jacobs cite Bernard Lang a lot -- he's put all his papers online -- http://bat8.inria.fr/~lang/papers/
05:41 jeffreykegler I've lots of thoughts on your parse forest work, but I want to think & study a bit more before saying anything.
05:41 jeffreykegler AFK
06:03 jeffreykegler joined #marpa
06:04 jeffreykegler amon: (I assume you're backlogging) -- I saw your answer to a stackexchange question: http://programmers.stackexchange.com/questions/260109/name-for-this-type-of-parser-or-why-it-doesnt-exist
06:04 jeffreykegler and wanted to make a nitty comment, re incremental parsing.
06:05 jeffreykegler I think Marpa may be almost unique is allowing practical incremental parsing -- that is, you can stop and really examine and act on the state of the parse so far.
06:06 jeffreykegler GLR may be capable of this in theory, but in practice pulling the information out of its data structures would be a forbidding task and I don't think there's any tool which allows you to do this.
06:07 jeffreykegler Marpa is Earley-based, so it's a matter of examining the Earley tables and the SLIF and progress reports provide a convenient interface.
06:07 jeffreykegler I think every other answer is of the "something somebody might get working someday" variety.
06:08 jeffreykegler (Chart parsers might also be good at incremental parsing.)
06:10 jeffreykegler amon: To clarify, the way I'm defining "incremental parsing" (and what I think users in practice actually need) is *general* incremental parsing -- which is why I spoke only about general parsers.
06:12 jeffreykegler Deterministic parsers would know (at best) only what they were trying, and whether or not it failed,
06:28 rns joined #marpa
06:48 rns joined #marpa
06:50 rns jeffreykegler: re http://irclog.perlgeek.de/marpa/2014-10-16#i_9517088 — I'm going to focus on bringing Lua::Ast to better shape this weekend.
06:52 rns Thanks for pointing me to Bernard Lang's papers — certainly worth reading.
06:58 rns re PFGs — sure, looking forward to it. Very glad it is worth your interest.
06:58 rns Now, back to $work, will keep you informed.
06:58 rns AFK
12:11 lwa joined #marpa
13:05 jeffreykegler joined #marpa
13:06 jeffreykegler amon: Oops!  Re-reading your stackexchange post, it didn't say what I read it to say, which means my comments above were not really to any point.  Sorry!
13:14 jeffreykegler joined #marpa
13:16 jeffreykegler rns: re Lua:AST.  Perhaps MetaLua can help.  It does have an extensible lexer.  Also, in the series of combinator parsers, you're allowed a default ...
13:16 jeffreykegler So perhaps you can use MetaLua for your lexing, and create a combinator parser which consists only of your Marpa-powered parser ...
13:17 jeffreykegler which just slurps up the entire input stream.
13:26 jeffreykegler This approach extends MetaLua with Marpa, which could pretty much revolutionize that tool.
13:50 rns joined #marpa
13:51 rns jeffreykegler: re http://irclog.perlgeek.de/marpa/2014-10-16#i_9518588 — thanks, will look into it tomorrow noon.
13:51 rns left #marpa
14:23 lwa jeffreykegler: RE the Stack Exchange question: yes, I (amon) only mentioned Marpa for its ASF feature because it's the only parser I know that (efficiently) does this. I'm not sure how suitable Marpa the Perl module currently is for incremental parsing (i.e. something like calling `$r->value` in the middle of the document, then doing `$r->resume` and another `$r->value`) – although I'm certain Marpa the algorithm is
14:23 lwa brilliant for this kind of stuff.
14:59 CQ quick (or not so quick...) question. I want to implement a filtering logic for tags. i.e. foo bar !baz (john || jane) ... any suggestions on how to go about it? define the filtering language, write a grammar?
15:02 CQ perl's grep would work, but be too ugly for normal users... I guess I could take the filter string, and turn it into a perl grep string
15:10 lwa It's difficult to write a regex that matches “any string that does not contain ‘foo’”. Defining a custom language for the filter makes sense, and writing a grammar for your suggested syntax is fairly easy – once you know what you precisely want.
15:12 lwa Ignore that first sentence of mine – you don't seem to be doing general search, just filtering of a set of strings
15:16 CQ lwa I have items with a bunch of tags and want to be able to select a subset using a grammar
15:24 jeffreykegler joined #marpa
15:24 jeffreykegler CQ: I wonder if https://metacpan.org/release/Data-Partial-Google is an approach that would be helpful in your case.
15:26 CQ jeffreykegler: interesting!
15:35 CQ jeffreykegler: not quite sure, it seems to extract data from all levels, but Idon't see where / how to apply a logic to the contents of the poperties... that's the hard part I think
15:37 jeffreykegler Guessing, you might want to rewrite into some kind of language/code that does apply the logic -- that is, applying the logic is not really a parsing problem, the parser is probably only helpful as a front end to the semantics, which are best come up with from somewhere else.
15:40 CQ yes, thats how fas I've gotten thinking about it too. Parsing is easy, then its the logical operations on the dataset that are the interesting challenge
15:41 CQ actually, it's not that hard. take each tag, check ig it exists or not, return a 1 or 0. Then its basically evaluating teh expression in a logical calculator.
15:42 CQ its a (simple?) reduction problem
15:43 jeffreykegler Right, and Marpa doesn't help there, except in the sense it lets you cleanly separate out parsing your representation of the logic on one hand; from carrying it out on the other.
15:44 CQ I mean, if I have foo bar !baz (john || jane), I parse it, check for teh tas, get a 1||0||!0(1||0) I can eval that
15:44 CQ the tags
15:44 jeffreykegler So, for example, you take your representation of the logic and parse it into Perl code -- then you run the Perl code against your actual data.
15:44 CQ yup, exactly
15:45 jeffreykegler As an alternative to 1|0, you could parse into if/then/else logic.
15:46 CQ hm, I don't see how to do that. It seems like that reduces to the binary logic case
15:47 jeffreykegler It's just one suggestion -- and yes one does reduce to the other -- simply an implementation distinction.
15:47 CQ ok, then the binary case seems more obvious to me
16:04 lwa CQ: The grammar needs to be tidied up, but this filter script uses an elegant evaluation strategy: http://paste.scsys.co.uk/431923
16:09 CQ lwa, thanks! I'll have a look at it in 20 mins or so
16:10 jeffreykegler joined #marpa
16:10 jeffreykegler lwa: Thanks.  That might be closer to what CQ had in mind.
16:10 lwa Then maybe look at this fixed version (http://paste.scsys.co.uk/431930) instead
16:12 CQ lwa comma separation is needed too, but thats trivial
16:16 CQ lol http://www.wtfpl.net/about/ ;)
17:14 CQ lwa: can you translate   OP_AND ::=; OP_AND ::= op_and; for me please? the second part is fine, what is teh first part?
17:16 CQ ...or is it just remaining text cruft and should look like OP_OR ... ?
18:27 jeffreykegler joined #marpa
18:28 jeffreykegler CQ: re http://irclog.perlgeek.de/marpa/2014-10-16#i_9519673 -- I'll try to answer this, although it's amon's question, plus for some reason the link to his "fixed" version doesn't work for me.
18:29 CQ I assumed it was a cut and paste error, and should look like the OR
18:29 jeffreykegler "OP_AND ::=;" is an empty rule.
18:29 jeffreykegler It allows OP_AND to match the null string.
18:30 jeffreykegler That makes AND the default in the grammar, which I think is the what you wanted.
18:30 CQ ah, so if you have two things separated by spaces then the AND takes...
18:31 jeffreykegler Right, since it "matches" the nothing in the middle, while everything else needs "something" to match.
18:31 jeffreykegler It's actually, in a prioritized statement, the way amon is using it, a fairly tricky technique, ...
18:31 CQ well, then he shouldn't make it look like a cut-and-paste error to confuse newbies ;)
18:32 jeffreykegler as I think you can see, if you have too much things match nothing, you get *a lot* of ambiguity, but it looks OK in this case (I have not tested)
18:32 jeffreykegler Actually for the format of empty rules, I'm to blame. :-)
18:33 jeffreykegler Although one trick is to create a rule like this "empty ::=", and have everything else be "xyz ::= empty"
18:33 jeffreykegler Another trick is to add a comment like so:
18:34 jeffreykegler OP_AND ::= # emtpy
18:34 CQ btw, something that threw me for a while was the fact that for some rules I get a scalar, for some an array... that gave me a crash that took a while to understand
18:34 jeffreykegler * emtpy -> empty, but you get the idea. :-)
18:35 CQ if you want an example I can give you one... the error message was weird, it claimed that I was trying to use token contents as a reference
18:35 jeffreykegler The ability to return anything you like is a feature, but yes, keeping track of values in the evaluation of a tree can get tricky.
18:36 CQ can't you check that and return a better error?
18:36 jeffreykegler Give the example, and I'll look at it.
18:36 jeffreykegler If it comes from Perl, there may not be much I can do.
18:39 CQ http://paste.debian.net/127222/ ... look for the BUGME line, its an IF that has an ||1 to ignore the check for ARRAY
18:39 CQ to show the bug
18:40 jeffreykegler I don't see an error message, just code.
18:40 CQ run it, you'll get the error
18:40 CQ Can't use string ("// mycomment line3") as an ARRAY ref while "strict refs" in use at ./rtask-v7.pl line 107.
18:41 CQ it got the comment string as a scalar token and tires to access the array element.
18:41 CQ tries
18:41 jeffreykegler That looks like an Perl error message, and that the problem occurred in user code --
18:42 jeffreykegler perhaps as result of a value returned from a Marpa call, but it's a Perl error message.
18:43 CQ ok, then I guess people just have to RTFM to figure it out... I was expecting to always get an array (maybe sometimes with one element only) and never a scalar
18:43 jeffreykegler You want scalar sometimes -- the result may simply be a number or a string.
18:44 jeffreykegler Perl's error messages took some getting used to for me.
18:44 CQ yep, me too
18:45 jeffreykegler I think there is a "use diagnostics" or something, which prints out a long story for each of them.  I never used it, just would look them up in perldiag if I needed to.
18:46 CQ since it didn't look like a normal perl error and mentioned MARPA in bold, I figured Marpa was throwing the error
18:51 jeffreykegler Good luck!  AFK
18:54 ilbot3 joined #marpa
18:54 Topic for #marpa is now Start here: http://savage.net.au/Marpa.html - Pastebin: http://scsys.co.uk:8002/marpa - Jeffrey's Marpa site: http://jeffreykegler.github.io/Marpa-web-site/ - IRC log: http://irclog.perlgeek.de/marpa/today
20:47 ronsavage joined #marpa
20:55 ronsavage RE the Stack Exchange question: I would do it by discarding garbage and regarding each identifiable part as a separate parse, and chop both those types off the start of the string before repeating the process.
21:05 flaviu joined #marpa
22:31 jdurand joined #marpa
22:38 shadowpaste "jdurand" at 88.160.190.154 pasted "Automating bindings generation" (25 lines) at http://scsys.co.uk:8002/432067
22:56 jeffreykegler joined #marpa
23:52 aredridel joined #marpa

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