Yes, the Ruby Slippers approach occurred to me. And it can do the kind of stuff you mentioned.
Its downside (and the reason I didn't mention it) is that, in the most naive approach, it would require treating each stacktrace as a single token. Tokens don't have semantics, so that means you could recognize tokens, but not deal with their structure. Of course you can resort to some sort of 2-layer parsing, so that you first recognize stack traces, and then use a 2nd grammar to parse them for structure. That gets complicated, though ultimately it's probably still much simpler than what you wind up with if you use regexes. But perhaps there is some way to adopt Ruby Slippers to this problem. Someday Marpa::R3 will allow tokens to have a semantics as well. But as Marpa is currently funded, that won't happen soon. On Tue, Nov 14, 2017 at 2:24 PM, Jakub Narębski <[email protected]> wrote: > I do wonder if the 2nd problem, namely parsing broken stacktraces and/or > repairing them is possible with 'Ruby slippers' technique. As far as I > understand it, it can add tokens where they are expected (fixing broken or > just loose non-XML-ish HTML like non closing P element), but can it be used > to remove lexem(?) and retry parse (with "\n" removed)? > > On Monday, 13 November 2017 22:53:37 UTC+1, Jeffrey Kegler wrote: >> >> [...] >> >> Repairing broken stack traces is interesting. If I were pursuing it, I'd >> think Marpa's power might be useful -- look for the first match of >> something like >> >> <random lines> <valid stacktrace> >> >> Since you take the first match, it should match after as few random lines >> as possible -- this may be 0 lines. At that point you know where there is >> a valid stacktrace, and you know what the lines are that you need to >> attempt repair on. >> >> You'd need to work out a lexing discipline that both accumulates the >> random lines and allows the parsing of the valid stacktraces. >> >> Again, this is just some thoughts about the approach I'd look at 1st if I >> were trying to solve this in a Marpa-powered way. Note that, if you have >> to fall back to ordinary hacks, Marpa allows all of these. >> >> I hope this helps, jeffrey >> >> On Mon, Nov 13, 2017 at 1:36 PM, Ron Savage <[email protected]> wrote: >> >>> Marpa allows you to discard parts of the input stream. And the tokens to >>> be discarded can have various forms. But you may well be better off >>> matching what you can be certain does appear. That means both defining >>> exactly what you want to find and somehow proving that what's in the part >>> you wish to ignore never matches the part to be captured. See also: Marpa's >>> home page <https://savage.net.au/Marpa.html> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "marpa parser" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- > You received this message because you are subscribed to the Google Groups > "marpa parser" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "marpa parser" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
