jython / jython3

A sandboxed attempt at v3 (not maintained)
Other
299 stars 59 forks source link

#10 Ellipsis (...) should be expr #15

Closed isaiah closed 8 years ago

fwierzbicki commented 8 years ago

Hi Isaiah, thanks for looking at this! There is a corner case that needs to be handled that I don't have a good answer for:

from ...foo import bar

Fails with

$ ./dist/bin/jython -S foo.py
  File "foo.py", line 1
    from ...foo import bar
        ^
SyntaxError: no viable alternative at input '...'

The parser should create a node tree that looks like: ('Module', ('body', ('ImportFrom (1,0)', ('module', 'foo'), ('names', ('alias', ('name', 'bar'), ('asname', None))), ('level', 3))))

BTW an easy way to generate the above is with a helper script at:

ast/astview.py

The script needs to be modified since pprint doesn't work right now - just remove pprint and use a basic print instead. My github credentials are goofed up right now, as soon as find some time this week I'll update astview.py this way. Anyway, if I put some code into a file called foo.py and run:

python3 ast/astview.py foo.py

I'll get the node tree as Python3 sees it, then

./dist/bin/jython -S ast/astvew.py foo.py

can be used to spot any differences. I'm guessing that you must have noticed that Jython3's site.py is broken and so we have to use -S for now.

isaiah commented 8 years ago

Hi @fwierzbicki , turns out I went too far with the ellipsis fix, it works once I replaced the ELLIPSIS token with DOT DOT DOT.

As for pprint in astview.py, don't worry about it, it's because site.py is broken in the master branch, I have [a branch[(https://github.com/isaiah/jython3) that has site.py working and astview.py works fine.

Thanks for pointing out the astview utility, it helped a lot.

fwierzbicki commented 8 years ago

Hi @isaiah - Great! Which pull request includes the fix to site.py? I'll be sure to look at that one next!

isaiah commented 8 years ago

@fwierzbicki This is the one https://github.com/jython/jython3/pull/19, it includes all the changes I did in order to get site.py working, the other pull requestes are code that cherry-picked from that branch.

fwierzbicki commented 8 years ago

Ah, the entire set of pull requests gets us to site.py functioning. Great! I'll work through them as quick as I can, thanks.