Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • That's long overdue! Good work!
    --
    rjbs
  • The only multi-line REPL? Not true! Sepia also does this, by trying to eval the input so far and parsing $@ to guess what went wrong. It's not perfect, but it does a decent job of distinguishing between incomplete input and internal syntax errors.
    • Ah. I've seen Sepia before in search results, but I've never actually checked it out (seeing as how I'm a vim guy).

      Interesting way to solve the same problem. Both have their strengths and weaknesses (PPI is more correct and won't run BEGIN/CHECK blocks, Sepia probably handles more cases, such as s/// and quoted strings)

      • It *should* be possible to integrate Sepia's REPL with vim, or to use it separately with e.g. rlwrap, though I haven't tried it much. And the approach I take is mostly inferior to PPI, other than having far fewer prerequisites.
  • I'm almost certain there is enough information in place in the PPI tree to catch the two cases you want (incomplete regex and incomplete strings, plus you forgot incomplete heredocs, which PPI already detects in ->serialize).
    • Great! I'll have a look soon. I suspected there wasn't because I didn't see anything like the '???' of incomplete structures in the output of PPI::Dumper.
      • It's a little more complex and slightly different in each case, but as an example, look at the exact numbers in the Perl structure of an incomplete quote, you can probably intuit it.

        What might be a better idea though, is to introduce an ->complete or ->incomplete method at the PPI::Element level and abstract the entire thing behind a nice interface.

        • What might be a better idea though, is to introduce an ->complete or ->incomplete method at the PPI::Element level and abstract the entire thing behind a nice interface.

          That would be great. I've taken a stab at implementing it and it looks to be way over my head.