Skip to main content

Syntactically Free Python

Project description

FreeSyntax

Syntactically Free Python

from freesyntax.factory import RuleFactory
from freesyntax.grammar import Optional, Token, Rule, Match
from freesyntax.structs import AutoLeaf
factory = RuleFactory()

@factory.funcdef(
    Match["def"],
    Token["NAME"],
    Rule["parameters"],
    Optional[Match["->"], Rule["test"]],
    Match["YES"],
    Rule["suite"],
)
def fixer(node):
    node.children[3].replace(AutoLeaf.COLON)


print(factory.transform("""
def a() YES
    pass
"""))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

freesyntax-0.0.1.tar.gz (48.2 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page