Style fixes

This commit is contained in:
Paul Tagliamonte 2013-01-12 14:38:53 -05:00
parent 676c4f5448
commit 17b0d56de1
6 changed files with 80 additions and 47 deletions

View File

@ -10,9 +10,6 @@ from hy.lang.list import HYList
from hy.lang.bool import HYBool
from hy.lang.map import HYMap
from hy.lang.builtins import builtins
from hy.lang.natives import natives
def _ast_print(node, children, obj):
""" Handle `print' statements """
@ -30,7 +27,7 @@ def _ast_binop(node, children, obj):
# XXX: Add these folks in
inv = node.get_invocation()
ops = { "+": ast.Add, "/": ast.Div, "*": ast.Mult, "-": ast.Sub }
ops = {"+": ast.Add, "/": ast.Div, "*": ast.Mult, "-": ast.Sub}
op = ops[inv['function']]
left = children.pop(0)
calc = None
@ -261,7 +258,6 @@ class AST27Converter(object):
orelse=orel,
)
def _ast_for(self, node):
i = node.get_invocation()
args = i['args']
@ -398,12 +394,12 @@ class AST27Converter(object):
if inv['function'] in special_cases:
return special_cases[inv['function']](node, c, self)
ret = value=ast.Call(
func=self.render_symbol(inv['function']),
args=c,
keywords=[],
starargs=None,
kwargs=None
ret = ast.Call(
func=self.render_symbol(inv['function']),
args=c,
keywords=[],
starargs=None,
kwargs=None
)
return ret
@ -418,7 +414,6 @@ class AST27Converter(object):
node.lineno = tree.line
node.col_offset = tree.column
if isinstance(ret, list):
for r in ret:
_correct_tree(r, tree)

View File

@ -6,4 +6,4 @@ class HYBool(HYObject):
self._val = val
def eval(self, lns, *args, **kwargs):
return self._val == True
return self._val is True

View File

@ -1,6 +1,5 @@
#
import sys
from hy.lang.internals import HYNamespaceCOW
from hy.lang.string import HYString

View File

@ -3,7 +3,6 @@ from hy.compiler.ast27 import forge_module
from hy.lex.tokenize import tokenize
import sys
import imp
import os

View File

@ -1,4 +1,3 @@
from hy.lang.bool import HYBool
from hy.lex.tokenize import tokenize as _hy_tok
import sys
@ -24,6 +23,7 @@ def _foreach(*args):
for arg in a:
args[1](arg)
def _get(*args):
m = args[0]
k = args[1]
@ -85,7 +85,6 @@ def _ne(*args):
def _gt(*args):
arg = args[0]
for i in range(1, len(args)):
if not (args[i - 1] > args[i]):
return False
@ -93,7 +92,6 @@ def _gt(*args):
def _ge(*args):
arg = args[0]
for i in range(1, len(args)):
if not (args[i - 1] >= args[i]):
return False
@ -101,7 +99,6 @@ def _ge(*args):
def _le(*args):
arg = args[0]
for i in range(1, len(args)):
if not (args[i - 1] <= args[i]):
return False
@ -109,7 +106,6 @@ def _le(*args):
def _lt(*args):
arg = args[0]
for i in range(1, len(args)):
if not (args[i - 1] < args[i]):
return False

View File

@ -74,17 +74,22 @@ class Comment(State):
class Idle(State):
def p(self, x):
if x == "#": return HashExpression
if x == ";": return Comment
if x == "(": return Expression
if x in WHITESPACE: return
if x == "#":
return HashExpression
if x == ";":
return Comment
if x == "(":
return Expression
if x in WHITESPACE:
return
raise LexException("Unknown char: %s" % (x))
class HashExpression(State):
def p(self, x):
if x == "!": return Comment
if x == "!":
return Comment
raise LexException("Unknwon Hash modifier - %s" % (x))
@ -106,13 +111,26 @@ class Expression(State):
self.bulk = ""
def p(self, x):
if x == ")": return Idle
if x in WHITESPACE: self.commit(); return
if x == "\"": self.sub(String); return
if x == "(": self.sub(Expression); return
if x == "[": self.sub(List); return
if x == "{": self.sub(Map); return
if x == ";": self.sub(Comment); return
if x == ")":
return Idle
if x in WHITESPACE:
self.commit()
return
if x == "\"":
self.sub(String)
return
if x == "(":
self.sub(Expression)
return
if x == "[":
self.sub(List)
return
if x == "{":
self.sub(Map)
return
if x == ";":
self.sub(Comment)
return
self.bulk += x
@ -132,13 +150,26 @@ class List(State):
self.bulk = ""
def p(self, x):
if x == "]": return Idle
if x in WHITESPACE: self.commit(); return
if x == "\"": self.sub(String); return
if x == "[": self.sub(List); return
if x == "(": self.sub(Expression); return
if x == "{": self.sub(Map); return
if x == ";": self.sub(Comment); return
if x == "]":
return Idle
if x in WHITESPACE:
self.commit()
return
if x == "\"":
self.sub(String)
return
if x == "[":
self.sub(List)
return
if x == "(":
self.sub(Expression)
return
if x == "{":
self.sub(Map)
return
if x == ";":
self.sub(Comment)
return
self.bulk += x
@ -167,18 +198,31 @@ class Map(State):
self.bulk = ""
def p(self, x):
if x == "}": return Idle
if x in WHITESPACE: self.commit(); return
if x == "\"": self.sub(String); return
if x == "[": self.sub(List); return
if x == "{": self.sub(Map); return
if x == "(": self.sub(Expression); return
if x == ";": self.sub(Comment); return
if x == "}":
return Idle
if x in WHITESPACE:
self.commit()
return
if x == "\"":
self.sub(String)
return
if x == "[":
self.sub(List)
return
if x == "{":
self.sub(Map)
return
if x == "(":
self.sub(Expression)
return
if x == ";":
self.sub(Comment)
return
self.bulk += x
class String(State):
magic = { "n": "\n", "t": "\t", "\\": "\\", "\"": "\"" }
magic = {"n": "\n", "t": "\t", "\\": "\\", "\"": "\""}
def enter(self):
self.buf = ""