Created
November 29, 2013 02:43
-
-
Save tarmstrong/7700893 to your computer and use it in GitHub Desktop.
ghgghughghghghghghghghghghg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lib2to3.pygram | |
import lib2to3.pgen2.driver as driver | |
class Tree(object): | |
def __init__(self, n): | |
self.n = n | |
self.used_names = set() | |
def __getitem__(self, idx): | |
return self.n[idx] | |
def blaconvert(g, n): | |
return Tree(n) | |
d = driver.Driver(lib2to3.pygram.python_grammar, blaconvert) | |
result = d.parse_string('a = 10\nclass Taco(object):\n def __init__(self):\n self.x = 10\n\n def bla(self):\n self.y = 2\n\n') | |
print result[0] | |
print result[1] | |
print [i[2] for i in result[3][1][3]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment