Created
November 22, 2013 20:38
-
-
Save josephcc/7606454 to your computer and use it in GitHub Desktop.
This file contains 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 re | |
from sys import stdin | |
def uncnf(g): | |
return type(g) not in (list, tuple) and g or map(uncnf, g[g[0]=='<DEL>':]) | |
for line in stdin: | |
line = re.sub(' +', ',', re.sub('([^() ]+)', r"'\1'", re.sub('([()])', r' \1 ', line).strip())) | |
line = eval(re.sub(r'\[X[1-9][0-9]*\]', '<DEL>', line.replace('(,', '('))) | |
print uncnf(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment