Perl 6 - the future is here, just unevenly distributed

IRC log for #marpa, 2014-09-28

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

All times shown according to UTC.

Time Nick Message
00:00 jeffreykegler Mapping symches to symbol names is tricky, but the symbol name should be *something* that's in your DSL.
00:01 flaviu The closest I can find is `<Expression List> ::= Expression* separator => comma`, but even that is encompassed in another rule that has more to it.
00:03 flaviu I don't  really like to just dump code, but https://gist.github.com/flaviut/090ec8869c7edc9679e6
00:05 jeffreykegler My guess is those alternatives involving 'Expression' all over the place ...
00:06 jeffreykegler there are lots of different choices for expression.  The grammar does *not* express any precedence and so Marpa is looking at every possible way of re-arranging the operators.
00:09 flaviu So less like   Marpa::R2::Scanless::DSL, more like   Marpa::R2::Tutorial2?
00:12 jeffreykegler Note all the "||" things in the M::R2::S::DSL synopsis.  They are what sets the precedence and cuts down on the possibilities.
00:13 jeffreykegler It'd be useful if you'd look at a standard discussion of BNF precedence -- it's simple, but until you understand the idea of precedence, there'll be endless confusion.
00:13 jeffreykegler I can't think of one off the top of my head that's on-line.
00:14 jeffreykegler Anyway, both the ::DSL and the ::Tutorial2 synopses set precedence, but they do it in 2 different ways,
00:16 jeffreykegler and the code you pasted doesn't use either, so that something like 1+2*3-4 parses IIRC six different ways, and that number increases exponentially with the number of operators.
00:16 flaviu I'm not sure I understand: I do use || extensively for the Expression rule
00:17 jeffreykegler Aha!  I see the issue.
00:17 jeffreykegler The prioritized rule has to be all one thing -- you can't break it up.
00:18 jeffreykegler No wonder your DSL looked so elegant. :-)
00:19 flaviu That isn't a problem, I can use comments instead. Can you elaborate though? I don't see why it should matter.
00:19 jeffreykegler The prioritized rule is all about doing magic with the LHS being in the various RHS alternatives, and the magic does not happen across rules.
00:21 flaviu Well, magic is sufficient explanation for me, Tutorial2 style already confuses me plenty
00:21 jeffreykegler Basically to do what is in ::DSL, the SLIF has to translate it into what is in Tutorial2, and unless the alternatives are all in one statement, the SLIF is not smart enough to figure out what exactly 'Expression' means in each case.
00:22 jeffreykegler Basically, Marpa *always* parses with grammars in the ::Tutorial2 form -- internally, it does not understand prioritized rules, just BNF.
00:23 jeffreykegler So the prioritized rule (a la ::DSL) must be rewritten.  To see something like this done by hand, you can look at Perl's yacc grammar -- it's gruesome.
00:24 jeffreykegler You need to make up a zillion new names, one for the expressions at each precedence level, and then stick them into the right alternative at the right place ...
00:24 jeffreykegler which Marpa's prioritized rule does for you -- but it does insist you gather everything into one rule.
00:24 flaviu That's pretty much why I like marpa: I don't have to figure out what left, right recursions are, factors, terms, operator_lv1-20
00:24 flaviu Makes sense, thanks!
00:25 jeffreykegler Maybe somebody'll write a new interface that's smart enough to allow you to break up a prioritized rule.
00:26 jeffreykegler But right now Marpa's SLIF needs you to put it all together in one rule.
00:26 flaviu Is it theoretically possible to expand the rules?
00:27 flaviu Basically do what I'm doing now manually automatically? - not that I mind or am asking for it as a feature - just curious
00:32 jeffreykegler "Expand the rules" ?
00:33 flaviu Directly substitute the value of the rule for the name of the rule
00:33 flaviu Thinking more about it, it wouldn't work if the rule was recursive
00:35 jeffreykegler Here it might be useful to imagine yourself like 50 years ago, and first encountering an assembler.  Today we'd be stunned at how much grunt work it made the programmer do ...
00:35 jeffreykegler but back then they were used to having to write all the one's and zero's themselves, and assemblers seemed like marvels of automation.
00:37 jeffreykegler Anyway, I expect and hope folks will use Marpa's general BNF capabilities to write stuff on top of it, that allow you to specify languages at a level which makes the SLIF look crude ...
00:37 jeffreykegler but it will be folks like you who do it.
00:42 flaviu I don't want to belittle the inspiring words, but should I take that as "Should be possible, but Marpa::R2 is feature complete"?
00:43 flaviu I'm sorry if I come across as rude - that is not my intent at all.
00:43 jeffreykegler Marpa::R2 is in "near freeze" wrt new features
00:44 jeffreykegler But also, there are so many directions to go in, one person cannot pursue them all.
00:46 jeffreykegler Another consideration is that the person who does the math is usually not the one who comes up with the best high-level interface -- for proof see Knuth's Tex.  Brilliant software, but OMG the interface!
00:47 jeffreykegler A third reason is that every new contributor brings in something original -- the SLIF's form owes a lot to Andrew Rodland and Peter Stuifzand in the Marpa community.
00:48 jeffreykegler Both of them were a bit bolder about using certain Marpa features than I was at the time.
06:16 lwa joined #marpa
07:41 ronsavage joined #marpa
10:57 flaviu1 joined #marpa
12:57 lwa joined #marpa
13:35 lwa flaviu1: Regarding your question yesterday on Python-style indentation parsing: A couple of weeks ago I did some investigation into this topic (using a Markdown subset). The code is in no state to be published, but I used the following approach: I had special tokens Indent, Lead, and Dedent which were wired to prediction events. Actually, Indent was just a marker to increment the indentation level stored in my read-resume
13:35 lwa loop. Lead was an optional newline plus the whitespace at the beginning of a line, read by a regex in an event handler. If the leading whitespace matched the indentation level, the Lead token was emitted. If it was too large, an error was emitted; if it was too small, a Dedent was offered to the recognizer and the indentation level decremented. Dedent did not consume any input, only Lead did. Especially the side-effects-onl
13:35 lwa Indent token did a pretty good job at limiting ambiguity (in this part of the grammar).
17:06 flaviu1 joined #marpa
17:08 flaviu1 I think I've found the weird Expression ::= Expression rules from last night. While using show_rules(3), I have a bunch of rules of that form, where the LHS Expression ID is different from the RHS Expression ID.
17:10 flaviu1 "Internal rule for symbol <Expression> priority transition from 3 to 4"
17:12 flaviu1 So the rules didn't directly exist in my grammar, but were inserted to lower the ::DSL form to the standard ::Tutorial2 form
17:22 jeffreykegler joined #marpa
17:24 jeffreykegler flaviu1: Yes, internally prioritized rules are rewritten -- essentially the same rewrite that's usually done by hand.
17:26 jeffreykegler In diagnostics, prioritized rules are hard to report.reported in an internal-ish form -- that's why the rule descriptions are there -- to explain how the rule relates to your DSL ...
17:27 jeffreykegler an explanation that is really not needed for an ordinary BNF rule, but which can be essential for figuring out where an internal rule comes from.
17:27 flaviu1 I understand what is going on - the same name is generally used since tends to create the best error messages, but internally, a name does not correspond to a single ID.
17:28 jeffreykegler That's right -- internally different symbols must be created for each precedence level ...
17:28 jeffreykegler and that's why using <Expression> outside the prioritized rule doesn't do what you wanted ...
17:29 jeffreykegler The question arises, "Which <Expression>?"
17:29 jeffreykegler That is "Expression at what priority level?"
17:30 flaviu1 Just some feedback on the libmarpa api docs - most pages are just a few paragraphs long, so it's frustrating to spend a lot of time waiting. Perhaps you could add --no-split to makeinfo?
17:31 jeffreykegler You're talking about the HTML versions?
17:31 flaviu1 The total size is ~316K, so it's a practical solution
17:31 flaviu1 yes
17:31 flaviu1 https://jeffreykegler.github.io/Marpa-web-site/libmarpa_api/cpan_indexed/
17:34 jeffreykegler --no-split vs. default looks like a matter of taste -- I admit sometimes I'd like one page, but most often I like it the way it is
17:36 flaviu1 Ok, fair enough. I'd like set up an additional version with the entire API on one page, if you don't mind.
17:38 jeffreykegler I'd be grateful if you did so -- time I spend on the Website is time not spent on improving Marpa.
19:59 flaviu1 It's up at https://flaviut.github.io/libmarpa-api-onepage/
19:59 lwa joined #marpa
20:00 jeffreykegler Cool. It's a lot easier to search in that form, I admit.
20:53 jdurand joined #marpa
20:53 jdurand Jeffrey, unless a bug in my code (quite a good probablity for the moment -;), is it possible that marpa_r_terminals_expected() could return more than once the same symbol Id ?
20:54 jeffreykegler Certainly does not sound desirable.
20:55 jeffreykegler I'd be hard put to call it anything but a misfeature at best, if that's what's happening.
20:56 jdurand Ah..; hang on, I just realize I do not reset my symbol array content
20:57 jeffreykegler Shouldn't scare an old man like that. :-)
21:00 jdurand Yep... sorry to have logged for few minutes only just to scare you - the opportunity to remind that I am still working with Marpa, quite intensively indeed, but a low level
21:01 jdurand "but at low level"
21:01 jeffreykegler I look forward to good news, then.
21:02 jdurand this week-end was very productive, I am now linking everything together, streaming, ICU, SQLite, Marpa -;
21:03 jdurand also I clearly understimated XML as a whole - there is a bunch of subtilities, and producing something new must be compatible with previous frameworks,
21:05 jdurand ok, AFK - I follow the IRC logs regularly and is happy to see interest growing on constantly - see you

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