Skip to content

Instantly share code, notes, and snippets.

@eliben
Created February 22, 2014 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eliben/9158261 to your computer and use it in GitHub Desktop.
Save eliben/9158261 to your computer and use it in GitHub Desktop.
embedded comment in next prefix
Input code:
x = 1 # told you
y = 2
Breakdown of the lib2to3 parse tree. The thingies with [N children] are nodes. The rest are leaves.
file_input [3 children]
simple_stmt [2 children]
expr_stmt [3 children]
NAME('x') [lineno=1, column=0, prefix='']
EQUAL('=') [lineno=1, column=2, prefix=' ']
NUMBER('1') [lineno=1, column=4, prefix=' ']
NEWLINE('\n') [lineno=1, column=16, prefix=' # told you']
simple_stmt [2 children]
expr_stmt [3 children]
NAME('y') [lineno=2, column=0, prefix='']
EQUAL('=') [lineno=2, column=2, prefix=' ']
NUMBER('2') [lineno=2, column=4, prefix=' ']
NEWLINE('\n') [lineno=2, column=5, prefix='']
ENDMARKER('') [lineno=3, column=0, prefix='']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment