Skip to content
This repository was archived by the owner on Oct 1, 2019. It is now read-only.
This repository was archived by the owner on Oct 1, 2019. It is now read-only.

Non-injective token to AST mappings #22

Open
@taion

Description

@taion

There are a number of cases in Python where the token-to-AST mapping is very clearly non-injective, where multiple different-looking statements are syntactically equivalent. We should think about how to handle these; perhaps this will require looking at the actual tokens.

Usually only one use case is common, but mangling tokens might be a bit much.

1. elif (#7)

if foo:
    foo()
elif bar:
    bar()


if foo:
    foo()
else:
    if bar:
        bar()

2. Nested with in Python 2 (#15)

with a, b:
    pass


with a:
    with b:
        pass

3. as in except in Python 2

try:
    foo()
except A as a:
    pass


try:
    foo()
except A, a:
    pass

4. Empty parent class

class Foo:
    pass


class Foo():
    pass

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions