#83 New full non-regex PHP parser

open
nobody
None
5
2014-08-26
2013-04-20
No

Rewrite the PHP parser as a real full token-based parser, instead of using regexes. This is more complex but allows for way better parsing.

Tags are generated for:
* classes;
* constants (both "const FOO" and "define('FOO', ...)");
* functions/methods;
* interfaces;
* local variables (disabled by default, need to enable the "l" kind);
* namespaces (both syntax);
* traits;
* global (like locals, but in the root scope) and member variables.

Visible changes from current regex-based parser:
* Scope is reported for each tag;
* Visibility is reported for members and methods;
* Implementation is reported for classes, interfaces and methods;
* Traits are reported;
* Namespaces are reported;
* Separate global and local variables (local ones being disabled by default);
* Constructs outside PHP tags are completely omitted;
* "jsfunction" are not reported any more;
* Function arguments spanning several lines or including comments are properly reported;
* Commented-out code no longer generates tags.

Closes:
* https://sourceforge.net/tracker/?func=detail&aid=3602177&group_id=6556&atid=106556
* https://sourceforge.net/tracker/?func=detail&aid=3220198&group_id=6556&atid=106556
* https://sourceforge.net/tracker/?func=detail&aid=1792989&group_id=6556&atid=356556
* https://sourceforge.net/tracker/?func=detail&aid=960547&group_id=6556&atid=306556
* https://sourceforge.net/tracker/?func=detail&aid=3074659&group_id=6556&atid=306556

About the patch:
The attached patch is the complete patch against trunk. If you want, I can either provide the individual patches (I did 22 patches to get here), or the
new version of each file, just tell me what you prefer.

Discussion

  • Cameron Eagans

    Cameron Eagans - 2013-08-01

    This patch doesn't apply anymore, but I'd really really love to use it. There's not very many good ways to index PHP code without an IDE, and this pretty much solves that problem!

     
  • Colomban Wendling

    An updated version is available on my GitHub repository: https://github.com/b4n/ctags/commits/better-php-parser

    It includes:

    • Fix for a bug leading to an infinite loop and eventually to crash reading an identifier at the very end of the file
    • Support for <script language=php></script> open/close tags

    As always, I can provide a patch against trunk if you want, just ask.

     
  • Eloy Lafuente

    Eloy Lafuente - 2013-10-30

    +10 awesome!

    Without it we, old ViM developers, are dying badly with PHP.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks