Skip to content

Instantly share code, notes, and snippets.

@yanolab
Created December 8, 2011 08:09
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 yanolab/1446431 to your computer and use it in GitHub Desktop.
Save yanolab/1446431 to your computer and use it in GitHub Desktop.
add unless stmt to pypy
diff -r c62cca56f289 pypy/interpreter/pyparser/pytokenizer.py
--- a/pypy/interpreter/pyparser/pytokenizer.py Tue Dec 06 18:47:03 2011 +0900
+++ b/pypy/interpreter/pyparser/pytokenizer.py Thu Dec 08 13:30:38 2011 +0900
@@ -169,7 +169,7 @@
if start == end:
raise TokenError("Unknown character", line,
lnum, start + 1, token_list)
-
+ bpos = pos
pos = end
token, initial = line[start:end], line[start]
if initial in numchars or \
@@ -213,6 +213,11 @@
token_list.append(tok)
last_comment = ''
elif initial in namechars: # ordinary name
+ if token == "unless":
+ line = line[:start] + "if not" + line[start + 6:]
+ pos = bpos
+ continue
+
token_list.append((tokens.NAME, token, lnum, start, line))
last_comment = ''
elif initial == '\\': # continued stmt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment