Perl 6 - the future is here, just unevenly distributed

IRC log for #marpa, 2014-09-05

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

All times shown according to UTC.

Time Nick Message
00:12 ronsavage Seeking bnf for double-quoted string which accepts escaped double-quote. Any ideas?
00:13 ronsavage I've looked at JSON's bnf and C.AST's bnf but they have prioritized and/or quantized rules, and I'm trying to trigger an event on this double-quoted string.
04:39 ronsavage joined #marpa
04:50 rns ronsavage: re http://irclog.perlgeek.de/marpa/2014-09-05#i_9300590 — can this gist https://gist.github.com/rns/96647c9205db54e087a5 (output in the comment) do the job?
04:55 rns joined #marpa
05:02 jdurand joined #marpa
05:02 jdurand Re http://irclog.perlgeek.de/marpa/2014-09-05#i_9300595 - isn't extracting the STRING_LITERAL_UNIT lexeme from the C AST fulfuiling your requirement?
06:43 ronsavage jdurand: Almost. But Marpa won't accept an event on a lexeme which is qualified or prioritized.
07:16 MintberryCruNCH joined #marpa
07:55 rns joined #marpa
08:01 rns re http://irclog.perlgeek.de/marpa/2014-09-05#i_9301388 — :lexeme ~ lstring pause => before at https://github.com/jeffreykegler/Marpa--R2/blob/master/cpan/t/sl_json.t looks like what you need.
08:01 rns https://github.com/jeffreykegler/Marpa--R2/blob/master/cpan/t/sl_json.t#L284 to be more precise.
08:28 daxim where is the mistake?   http://paste.scsys.co.uk/421481
08:43 shadowpaste "rns" at 77.120.243.111 pasted "full gist" (33 lines) at http://scsys.co.uk:8002/421483
08:43 ronsavage rns: Ahhhhh. It's different from the bnf I added just a couple of days ago to MarpaX :: Demo :: JSONParser, also from Jeffrey. It looks perfect. $many x $thanx;
08:44 rns s/escapedquote        ~ '\\' '"'/escapedquote        ~ '\"'/ as in http://scsys.co.uk:8002/421483 adapted slightly to my settting?
08:46 rns ronsavage: glad it worked.
08:49 ronsavage rns: Aggghhhh again. The gist you kindly posted dies:
08:49 ronsavage Error in SLIF parse: No lexeme found at line 1, column 5
08:49 ronsavage * String before error: "foo
08:49 ronsavage * The error was at line 1, column 5, and at character 0x005c '\', ...
08:49 ronsavage * here: \\"bar"
08:50 ronsavage I tried chopping out N{REVERSE SOLIDUS} to leave "foo\"bar" but that dies too.
08:52 daxim that's what I am asking, why does it fail to parse?  my pastebin has the full error message
08:54 rns sorry, this one must work https://gist.github.com/rns/17faef77b8d3468fb7fe
08:54 ronsavage daxim: Sorry - I could not work out /for sure/ who you were addressing with your question. Sometimes it's obvious of course, but sometimes it isn't.
08:55 rns daxim: this one is https://gist.github.com/rns/17faef77b8d3468fb7fe hopefull working, output is in the comment.
08:55 daxim if I don't prefix with a name, then everyone
08:57 ronsavage I copied the program and replaced the grammar with the one rns referred to: "https://github.com/jeffreykegler/Marpa--R2/blob/master/cpan/t/sl_json.t#L284 to be more precise." But now value() returns undef.
08:57 ronsavage daxim: ok.
08:57 daxim why is it both '\' and [\\] for a single backslash?
08:58 rns ronsavage: daxim: this gist https://gist.github.com/rns/17faef77b8d3468fb7fe parses the input to the ast in the comment.
09:04 MintberryCruNCH joined #marpa
09:17 rns daxim: re http://irclog.perlgeek.de/marpa/2014-09-05#i_9301813 — '\' is a string, [\\] a charclass, both match \. Or am I misundertsanding?
09:18 rns daxim: BTW, just installed and tried DDS (noted in your script), looks useful, thanks.
09:19 daxim yes, you are.  I was asking why it is the way it is.  this design mistake cost me quite some time
09:23 rns daxim: both charclasses and strings and supported, can mean the same thing (TIMTOWTDI), can't honestly see a problem I'm afraid.
09:26 daxim the problem is that a single backslash is expressed as both '\' and [\\].  you knew that for some reason.  I did not.  it isn't explained in the docs either.  coming from general programming and other BNF parsers, I assumed bs must be always expressed as \\
09:36 MintberryCruNCH joined #marpa
09:42 ronsavage joined #marpa
09:44 ronsavage '\' is not a valid string, because the \ escapes the 2nd ', so you need '\\' or '\'' (That's 2 separate single quotes).
09:47 ronsavage rns: Yes, it works. I must now examine the difference between your 2 gists. Well done!
09:49 daxim that's wrong.  you just made the same mistake as I did.  in marpa dsl, '\' is in fact a valid string and expresses a single backslash
09:51 daxim can we agree that this is horribly confusing and needs some better documentation and examples?
09:52 ronsavage Ummm. It works with "foo\N{REVERSE SOLIDUS}"bar" but dies with "foo\"bar".
09:53 daxim yeah, perl strings work different than marpa strings.  that the point of the confusion
09:54 ronsavage I changed  $parser->read(\qq("foo\"bar")); to $parser->read(\q("foo\"bar")); Ie. made the input a /single/ quoted string. Still, I'm impressed.
10:20 rns ronsavage: re http://irclog.perlgeek.de/marpa/2014-09-05#i_9302018 — \q("foo\"bar") prints as "foo\"bar", just as qq("foo\N{REVERSE SOLIDUS}"bar") — https://gist.github.com/rns/8e5df459febbcd03a909, output in the comment.
10:24 rns I mean q("foo\"bar") doesn't look like a /single/ quoted string or am I missing something?
10:26 ronsavage This works: \qq("foo\N{REVERSE SOLIDUS}"bar"). With \q(...) it fails. This works: \q("foo\"bar"). This fails: \qq("foo\"bar").
10:27 ronsavage And this fails: \qq("foo\\"bar")
10:27 rns Yep, looking into it
10:33 daxim because the perl \N{} construct requires an interpolating context, just the same as \n, \t, \x{} etc.
10:36 rns q doesn't interpolate, so q("foo\N{REVERSE SOLIDUS}"bar") is effectively "foo\N{REVERSE SOLIDUS}"bar" and this fails. I updated the gist https://gist.github.com/rns/8e5df459febbcd03a909 for all 4 to parse (and failt) as needed, output in the comment.
10:36 rns daxim: absolutely.
10:37 rns daxim: absolutely re http://irclog.perlgeek.de/marpa/2014-09-05#i_9302102, that is.
10:48 rns_ joined #marpa
10:53 rns daxim: re http://irclog.perlgeek.de/marpa/2014-09-05#i_9301990 and http://irclog.perlgeek.de/marpa/2014-09-05#i_9302007 — The docs says: Single-quoted strings do not allow "escaped" characters. A backslash ("\") represents itself and has no effect on the interpretation of the next character. https://metacpan.org/pod/distribution/Marpa-R2/pod/Scanless/DSL.pod#Single-quoted-strings
18:28 jeffreykegler joined #marpa
18:37 jeffreykegler Re SLIF DSL backslashed -- because Marpa::R2 is near-frozen, it's not likely they'll change.
18:38 jeffreykegler Explaining why might help with keeping it in mind, and perhaps even reconcile users a bit to the status quo.
18:39 jeffreykegler I've found the backslashing convention in practice to be awful -- in shell scripts it's nearly impossible to figure out what a series of backslashes will look like by the time it hits your tool.
18:40 Aria Heh, yeah. Layers of quoting blows chunks.
18:41 jeffreykegler Internally Marpa's SLIF passes strings through multiple layers of interpretation, and I having the same problem -- and I asked myself why can't I have one way of specifying strings that actually passes thru just what you give it to the maximum extent possible.
18:42 jeffreykegler And single-quoted-ness seemed the right syntax for that concept.
18:44 jeffreykegler A 2nd consideration: a compact representation using multiple escaping conventions is not all that readable -- for example, "abc\xbeef\n\a\\\\\ \x{ab}\N{MU}"
18:45 jeffreykegler If the user was forced to break something like that up and spread it out, it struck me that that was not entirely a bad thing.
18:46 Aria For sure.
18:46 Aria Though there's other escaping conventions that don't pile up so non-obviously. %byte for one.
18:48 jeffreykegler daxim: Anyway, because of the near-freeze and backward compatibility, you have to put up with the status quo, but I hope the preceding makes you feel better about that.
20:43 ronsavage Absolutely q() does not interpolate - Even I understand that.
20:45 ronsavage BTW: I'm processing Graphviz DOT files, which use double-quotes and recognize some escaped chars.
22:58 ronsavage joined #marpa

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