[pypy-dev] Parsing in PyPy (and runicode)

Jim Baker jbaker at zyasoft.com
Thu Feb 26 19:44:07 CET 2009

Perhaps consider Antlr? We've had good success with this for Jython, and
it's now also used by NetBeans support for Python in general. I took a look
at http://www.antlr.org/grammar/list, and there are a number of options for
JS. Most importantly, Antlr supports the parser chain in Python, so it's
possible this could be more readily converted to RPython.
Some potential issues:
Chris Lambrou has a parser for EcmaScript 3.0. But there's no license here,
so you'd definitely have to contact him on this. Like standalone grammars in
general, it's rather unlikely to have been extensively tested. With Jython
we started with a reference parser that Terrence Parr had made, and taking
CPython as reference here as to what the AST should be, over time we
targeted that by explicitly comparing ASTS. Some time later, including
incremental parse support and various syntax errors, we're pretty confident
that it's basically done.

- Jim

On Thu, Feb 26, 2009 at 11:29 AM, Leonardo Santagada <santagada at gmail.com>wrote:

> On Feb 26, 2009, at 2:40 PM, Carl Friedrich Bolz wrote:
> > Hi Leonardo,
> >
> > Leonardo Santagada wrote:
> >> I remember some time ago people on #pypy were talking about redoing
> >> the parser for python because it was not good enough or something.
> >> Also the parser generator that cfbolz wrote doesn't support unicode
> >> and was not suited for automatic-semicolon-insertion.
> >>
> >> I think it would be good for a javascript parser that supports
> >> unicode
> >> because the specs call for it and maybe it would be good to python
> >> too
> >> (don't know about prolog/smalltalk though). What would be better, to
> >> have a parser generator that supports unicode or just everyone write
> >> their own recursive descendant parser by hand?
> >
> > Are you sure that we shouldn't rather try to steal one of the existing
> > JS parsers? If license really is a problem, maybe we could ask the
> > authors whether they would be fine with relicensing under MIT.
> All the ones that come from narcissus are actually just licensed by
> Mozilla, so we should talk to them. But I don't know if it is complete
> and without bugs (I think there was one with narcissus but I don't
> remember what was it) so maybe we should use one used by a functioning
> js interpreters like Rhino of JavascriptCore (Squirrelfish Extreme or
> whatever its name is now). Both uses an incompatible license, and I
> think it is on purpose... so I don't know how to deal with this.
> The V8 parser is BSD so I think it is compatible, but it will be some
> work to convert it from c++ to rpython (
> http://code.google.com/p/v8/source/browse/trunk/src/parser.cc
>  )
> My final answer would be, "I don't know, what do you guys think?".
> --
> Leonardo Santagada
> santagada at gmail.com
> _______________________________________________
> pypy-dev at codespeak.net
> http://codespeak.net/mailman/listinfo/pypy-dev

Jim Baker
jbaker at zyasoft.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20090226/6d34d67f/attachment.html>

More information about the Pypy-dev mailing list