jParser release in the pipeline

February 24th, 2009 Leave a comment Go to comments

I’ve received quite a few emails recently asking me where the code is for jParser.

I’ve had to disappoint so far, because it’s not currently available for download. My web analytics also tells me that a lot of people are finding this blog by Googling “php javascript parser“. There’s clearly a need out there, so I’d better do something about it.

I know why I want a JavaScript parser, but what kind of things might you need it for? What API features/functions would you like to see? Please post a comment and let me know. Watch this space for a release, and in the mean time here’s some food for thought …

Do you really need a full parser?

Perhaps all you really need is a tokenizer. Suppose you want to highlight JavaScript code – you don’t need a full parser; all you need to do is break the source code into meaningful chunks (strings, numbers etc..) . How these chunks work together to form syntax is not an issue. I envisage releasing a lighter-weight library containing just the tokenizer (jTokenizer I guess). This will work exactly the same as the PHP tokenizer functions.

Minifying, or obfuscating JavaScript

If you’re after a minifier, there are lighter-weight PHP options available. However, I’ve released a command line version of my JavaScript minifier and obfuscator which is quite handy. It’s more powerful than most JavaScript minifiers, because it supports automatic semicolon insertion. This means it can reduce any code to a single line.

  1. September 25th, 2009 at 09:44 | #1

    I’m less interested in the pure javascript parser, but am very interested in the approach that you’ve taken. I’m looking at the feasibility of embedding a VB Script parser within the PHPExcel Open Source project, initially to support user-defined functions within Excel workbooks.

    Ultimately, I want to convert VB code to a set of PHP calls that can be executed to replicate VB functionality read from the workbook when they’re loaded into PHP; and conversely, to validate VBscript macros before they are written to newly created workbooks.

  2. Pascal
    September 26th, 2009 at 17:26 | #2

    I’m searching for a method to minify my js within php, but the use of packer for example is not the best method cause it uses eval and other things i not really like (and with enabled gzip it’s also bigger than reducing it in a less destructive way)
    Another way of using JParser would for my current project where i want to give the user the ability to use their own scripts to enhance their experience, a bit like the apps on the iphone or widgets etc. on igoogle, the yahoo thing or whatever, using just a filter against specific things like the bad eval etc. is a solution but it reduces the abilities for some (mainly stupid or bad) programmers. I could copy the fbopen-platform with it’s fbml-parser but thats quit a big client and i also don’t have the money for an extra server only for the parsing, it should be easy to use ;) (perhaps a port to python, which my provider also enabled, but not something so big)

  3. scott
    October 7th, 2009 at 03:42 | #3

    This is exactly what I was looking for. Well, it’s the starting point I was looking for — I only want a subset of the complete JavaScript functionality and want to add some custom functions for a mini-language. I don’t see any updates on this since February — any chance you’ll still be releasing the source code?

  4. October 7th, 2009 at 19:36 | #4

    I would love to, but I am just too busy with my full time job and also trying to find time to work on TwitBlock.org. Even opening up the project as open source so others can work on it is in itself too time consuming. Sorry to disappoint.

  5. November 14th, 2009 at 17:45 | #5
  6. January 11th, 2010 at 13:42 | #6

    Thank you Tim. You are the daddy!

  7. March 26th, 2010 at 04:28 | #7

    The RPA engine has a PHP extension able to parse pretty much anything if given the appropriate BNF rules. Here is a online demo of the RPA PHP extension parsing JavaScript:
    http://www.rpasearch.com/web/en/parsejavascript.php

  1. No trackbacks yet.