Saturday, July 2, 2011

Getting close to mid-term targets

Last two weeks were quite productive. I've finished most issues on my to-do list for first half of GSoC, and now working on the mid-term target - getting translator translate itself.

No more translation errors for python 2.7 syntax

There are no more red items at libs status page - pyjamas now understands all 2.7 syntax, and produces some kind of output for it. Sometimes it still results in JS syntax errors, but its good enough to correctly translate most of python stdlib without any modifications.
This includes:
  • Complex assignments, including deep unpacking - ((a, b), [c, d]), e = someiterable is working as expected (issue #527)
  • Assignments in `for` statements - turns out you can do things like `for x.a.b, d[key] in iterable` in python, and you can do same in pyjamas now.
  • Tuple key assignment works correctly (issue #496)
  • Set literals
  • Set and dict comprehensions
  • `With` statement, including support for `with ctxt1() as v1, ctxt2() as v2`  notation
  • "Discard expressions" - often used for NameError checking. Needs some more work on corner cases, but works in general (issue #584)
  • [::] and slice() now return sliceobjects, which are part of new slice protocol (issues #585, #364, and some other)
  • Getattr and callfunc over expressions, like `('a' + 'b').strip()` (issue #591)
  • Callfunc decorators, like `@decorator()` (issue #369)
  • Complex type, including complex literals, like `1+1j`
  • Top-level assert statements
Some builtin modules
I've added some typically builtin modules, like `operator`, `errno`, `weakref`. They are generally useless in pyjamas (except operator, but thats still rare), but some stdlib modules depend on them, so its good to have them.
sys module received some enhancement, esp. for PyV8 environment - now it retrieves stdin, stdout, stderr pipes from parent app correctly, and also retrieves correctly trimmed argv, so modules like optparse could work correctly.

Compiler module passes most of the tests
This is another significant milestone reached - pyjs now can correctly compile compiler/parser/grammar modules into javascript, and resulting javascript can parse python syntax and generate appropriate AST. Parser/tokenize still fails on some input due to regex incompatibility and obscure pyjs bugs, but 18 of 21 tests passed is good.

I'm going to keep working on making compiler pass existing tests and adding new tests for 2-3 more days, and then switch to `pyjs.translator`. There are some bugs - mainly class-related, like try/except in class definition scope - I also hoped to fix before mid-term, but since there are only two weeks left, translator is top priority for now.

No comments:

Post a Comment