hurricup has asked for the wisdom of the Perl Monks concerning the following question:

Recently i've tried different IDEs for perl5 and this experience was... sad...

Before that day i've developed for a long-long time using NP++, no kidding. I'm windows user so no vim or smth.

Padre - seems really cool idea, but unstable and looks abandoned.

Currently working with Komodo, but it's far from perfect, got bugs and even than - costs money.

From my own experience, the most powerful and convenient IDEs are Microsoft VS and Intellij IDEA, so I decided to try to write plugin for IDEA.

First and main problem with perl IDE (as I can see) is too free syntax. No BNF, no nothing. You can't use some generators to make lexer and parser for you. They may help, but only help.

I've tried to dig into perl sources and port toke.c into Java. Bad idea. Too much legacy code, too much little things that i don't understand. And porting of every function adds few more functions to port. And some of them requires very deep understanding of what is going on inside it. So i've dropped the idea and started from scratch.

Currently, i'm building lexer using JFlex and i think it's going pretty well. Some coloring already works.

Now i need to improve lexer, start to write a parser and implement IDEA features. There is a lot of work to do, so if anyone interested in such plugin and would like to participate, you are welcome: https://github.com/hurricup/Perl5-IDEA

You may also contact me via skype: hurricup or my gmail email: hurricup.

I belive that together we can do it.

P.S. To participate you should have some knowlege of perl and Java.

P.S.S. If you have no experience with Java but pretty familiar with Perl's insides - your consultations would be appreciated.

  • Comment on Creating Perl5 plugin for Intellij IDEA (Camelcade)

Replies are listed 'Best First'.
Re: Creating Perl5 plugin for Intellij IDEA (criterias ?)
by LanX (Saint) on Apr 19, 2015 at 19:10 UTC
    > From my own experience, the most powerful and convenient IDEs are Microsoft VS and Intellij IDEA

    Could you please elaborate why? I'd be curious to learn more.

    See also What are the criterias of a "good" Perl IDE?

    From my experience do both Komodo-IDE and Emacs excel on each point listed.

    Emacs has far more flexibility, but it's harder to customize. (it's more an IDE construction set)

    BTW: Komodo-Edit used to be free.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

      Well i could elaborate in details, but need some inspiration.

      For short, in Komodo 8 autocompletion for defined variables doesn't work, jump to definistion by click works from time to time.

        > but need some inspiration.

        The thread I linked was meant as such. :)

        > Komodo 8 autocompletion for defined variables doesn't work, jump to definistion by click works from time to time.

        That's surprising but possible. Unfortunately I can't test ATM, my Komodo installation is supposed to be ready in a week.¹

        Anyway I hope you are aware about the limitations to parse Perl statically.

        If "autocompletion for defined variables" means completing a global variable from a used module, that ain't easy to tell (i.e. which module is used somewhere). Even more for "jump to definistion by click".

        At least I can tell from the corresponding features in Emacs.

        So please don't expect just adding highlighting will make Perl as easy to analyze as static languages are.

        Cheers Rolf
        (addicted to the Perl Programming Language and ☆☆☆☆ :)
        Je suis Charlie!

        ¹) My emacs was up and running my working environment after a day, even without internet access ;)

Re: Creating Perl5 plugin for Intellij IDEA
by Anonymous Monk on Apr 20, 2015 at 00:14 UTC
      Thank you very much! I heard about it but never seen :) Will check sources for some ideas
Re: Creating Perl5 plugin for Intellij IDEA
by SimonPratt (Friar) on Apr 20, 2015 at 10:03 UTC
    A few of us here are using Sublime Text 2. With the ModernPerl plugin, it is excellent (though it doesn't have quite the same level of code completion or error highlighting as VS).

      Sublime is better than NP++, no doubts. But i'm talking about fully-functional IDE here

        Actually, having another look around the 'net, ran into Padre, a Perl IDE written in Perl. Screenshots look alright, but haven't tried it out yet.

Re: Creating Perl5 plugin for Intellij IDEA
by Laurent_R (Canon) on Apr 20, 2015 at 06:35 UTC
    Hm, Notepad ++, Ultra-edit and Crimson, just to name a few editors under Windows, have good Perl syntax support.

    Otherwise, for a full IDE, you might want to take a look at Eclipse (with the Perl plug-in).

    Je suis Charlie.

      I don't really remember what problem i've encountered with Eclipse. but seems it was absolutely fatal for me

        I am currently using the EPIC (version 0.7) plug-in with Eclipse Luna CDT. Regarding functionality, my only issue (so far) with it is that "our" variables are not included in the "Outline view". Also, there are some places, especially the debugger, where EPIC's integration with Eclipse is "klugy". Otherwise, it's been working decently for me.

Re: Creating Perl5 plugin for Intellij IDEA
by MidLifeXis (Monsignor) on Apr 20, 2015 at 14:06 UTC

    If you aren't afraid of lisp, you could check out Emacs' cperl-mode and perl-mode modules. Also see flymake as a way to use perl to do the heavy lifting for you.

    Since "only perl can parse Perl", best attempts and using perl as a back-end for your parser somehow are probably as close as you are going to get.

    --MidLifeXis

Re: Creating Perl5 plugin for Intellij IDEA
by mr_mischief (Monsignor) on Apr 20, 2015 at 20:11 UTC

      Again, I want IDE. Not editor with autocomplete from Webster's dictionary and syntax highlighting.

        If Eclipse hasn't enough features for you, then you need to think really hard about what exactly it is you want.

Re: Creating Perl5 plugin for Intellij IDEA
by RonW (Parson) on Apr 20, 2015 at 18:23 UTC
    The Scintilla editing widget has decent syntax highlighting for Perl and is used by several editors and IDEs. It is open source, so you could try "mining" it for Perl parsing logic.
Re: Creating Perl5 plugin for Intellij IDEA (Camelcade)
by hurricup (Pilgrim) on May 21, 2015 at 14:45 UTC

    Those, who interested, may try first beta version. Jar plugin may be found in repo: https://github.com/hurricup/Perl5-IDEA.

    Feedbacks, suggestions and bugreports are welcome.

    And now I'm even more sure that IDEA is real piece of art.

Camelcade 0.30 beta release
by hurricup (Pilgrim) on Jul 13, 2015 at 19:18 UTC

    Beta 0.30 released:

    • Re-wrote lexer and heavily refactored parser
    • Fixed bug with hanging on Embedded perl files
    • Added support for archaic package name delimiters, Foo'Bar is now valid (NB: refactoring/find usages not working on them yet)
    • Added perl script file detection by shebang line
    • Added variables attributes parsing
    • Added formats parsing
    • Added wiki pages in the repo

    Want to say BIG THANKS to all Monks who answered my sometimes stupid questions. I couldn't do it without you!

Re: Creating Perl5 plugin for Intellij IDEA
by hurricup (Pilgrim) on Apr 25, 2015 at 14:39 UTC

    A little update:

    • I've created basic lexer with JFlex
    • I've created basic bnf-like file which allows to generate parser with Grammar-Kit. It allows different injections, so i think it would be enough to handle perl.
    • I've implemented few built-ins tree building: package, sub, use and require
    • I've created annotator, which allows to show a error message with proper syntax hint.
    • Here is a screenshot.
    • Also, i've created basic lexer and parser for POD format and it looks like this.
    • I've named the project: Camelcade :)

Perl nuances: unnamed variable
by hurricup (Pilgrim) on May 24, 2015 at 11:04 UTC

    Hello. Got an interesting question: what is $:: variable?

    According to perldata there is no such special variable. According to perl variable syntax it's unnamed variable from main package. But if I dump %main:: - it's not there. But it's somewhere, because i can store and retrive data from it.

    Read wonderful article about symbol tables but it didn't helped.

    So, what is this thing?

    And one more question: how several double-colon in a row being treated? Like $::::somevar ?

Perl power: where to draw the line?
by hurricup (Pilgrim) on Apr 25, 2015 at 15:35 UTC

    Perl allows us to do crazy things. And i'm not sure that they all should be implemented in IDE, well, at least most people don't use them. For example, quote-like operations:

    use 5.10.0; say q#7asdf#; say q{6asdf}; say q/5asdf/; say q(4asdf); say q<3asdf>; say q?2asdf?; say q _aasdfa_; #say q aasdfa; say q basdfb; say q casdfc; #say q dasdfd; say q easdfe; #say q fasdff; say q g1asdfg; say q hasdfh; say q iasdfi; say q jasdfj; say q kasdfk; say q lasdfl; say q masdfm; say q nasdfn; say q oasdfo; say q pasdfp; say q qasdfq; say q rasdfr; #say q sasdfs; say q tasdft; say q uasdfu; say q vasdfv; say q wasdfw; say q xasdfx; say q yasdfy; say q zasdfz; my $a = q ksadfk; $a =~ m leasdfl; $a =~ s lasdflfdasl;
    All uncommented lines are valid. Of course, they are interesting to write some unreadable code, but you don't need IDE for that.

    Where is the line of required minimum? And i'm not talking only about this example.

    And by the way, if anyone knows, why 'a', 'd', 'f' and 's' are so special?

      ... why 'a', 'd', 'f' and 's' are so special?

      Because, e.g.,  q aasdfa includes the delimiter in the delimited string.

      c:\@Work\Perl\monks>perl -wMstrict -lE "say q abcda; say q defgd; say q fghif; say q stuvs; " bcd efg ghi tuv


      Give a man a fish:  <%-(-(-(-<

        oh. Don't post in evening. Obvious. Thanks :)
Learning perl, after years...
by hurricup (Pilgrim) on May 03, 2015 at 16:42 UTC

    It's really awesome that perl still has a lot to teach after years of programming experience :)

    Encountered a code, which i can't interpret (so as my parser). This is a part of PPI::Lexer. We've got an array:

    @CURLY_LOOKAHEAD_CLASSES = ( {}, # not used { ';' => 'PPI::Structure::Block', # per perlref '}' => 'PPI::Structure::Constructor', }, { '=>' => 'PPI::Structure::Constructor', }, );
    And somewhere else we have such code:
    elsif ( my $class = $CURLY_LOOKAHEAD_CLASSES[$position] {$Next->content} )
    How does it work? We are assigning list element to the class and what is $Next block?

    Thanks in advance

      You seem to be paying way too much attention to the line break.

      $position is either 1 or 2. $Next->content() is expected to return ';' or '}' when $position is 1 and to return '=>' when $position is 2.

      The code is a rather simple array look-up followed by a hash look-up:

      my $class = $CURLY_LOOKAHEAD_CLASSES[$position]->{ $Next->content() };

      - tye        

        Crap, till now didn't know that $hashref->{key1}->{key2}->{key3} can be written as $hashref->{key1}{key2}{key3} Thank you very much :)

Recursive inclusions parsing
by hurricup (Pilgrim) on May 13, 2015 at 12:29 UTC

    Perl's parsing depends on previously parsed data. Like bareword may be a function if it was declared or defined before with prototype

    But, how it works if we are parsing file, that uses package A, which requires package C, which requires package A?

    In such situation, we need to parse one of the packages without definistions/declarations data from another package.

    Does anyone knows how it really works?

      But, how it works if we are parsing file, that uses package A, which requires package C, which requires package A? Does anyone knows how it really works?

      Most of the time it doesn't work and the poor programmer asks for help :) at which point hes told to stop that :)

      See Exporter behavior / Re: Exporter behavior

Re: Creating Perl5 plugin for Intellij IDEA (Camelcade)
by hurricup (Pilgrim) on Aug 14, 2015 at 08:08 UTC
    It's so sweet to read this now... 4 months after...