Style fixes
This commit is contained in:
parent
676c4f5448
commit
17b0d56de1
@ -10,9 +10,6 @@ from hy.lang.list import HYList
|
|||||||
from hy.lang.bool import HYBool
|
from hy.lang.bool import HYBool
|
||||||
from hy.lang.map import HYMap
|
from hy.lang.map import HYMap
|
||||||
|
|
||||||
from hy.lang.builtins import builtins
|
|
||||||
from hy.lang.natives import natives
|
|
||||||
|
|
||||||
|
|
||||||
def _ast_print(node, children, obj):
|
def _ast_print(node, children, obj):
|
||||||
""" Handle `print' statements """
|
""" Handle `print' statements """
|
||||||
@ -30,7 +27,7 @@ def _ast_binop(node, children, obj):
|
|||||||
# XXX: Add these folks in
|
# XXX: Add these folks in
|
||||||
|
|
||||||
inv = node.get_invocation()
|
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']]
|
op = ops[inv['function']]
|
||||||
left = children.pop(0)
|
left = children.pop(0)
|
||||||
calc = None
|
calc = None
|
||||||
@ -261,7 +258,6 @@ class AST27Converter(object):
|
|||||||
orelse=orel,
|
orelse=orel,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _ast_for(self, node):
|
def _ast_for(self, node):
|
||||||
i = node.get_invocation()
|
i = node.get_invocation()
|
||||||
args = i['args']
|
args = i['args']
|
||||||
@ -398,12 +394,12 @@ class AST27Converter(object):
|
|||||||
if inv['function'] in special_cases:
|
if inv['function'] in special_cases:
|
||||||
return special_cases[inv['function']](node, c, self)
|
return special_cases[inv['function']](node, c, self)
|
||||||
|
|
||||||
ret = value=ast.Call(
|
ret = ast.Call(
|
||||||
func=self.render_symbol(inv['function']),
|
func=self.render_symbol(inv['function']),
|
||||||
args=c,
|
args=c,
|
||||||
keywords=[],
|
keywords=[],
|
||||||
starargs=None,
|
starargs=None,
|
||||||
kwargs=None
|
kwargs=None
|
||||||
)
|
)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@ -418,7 +414,6 @@ class AST27Converter(object):
|
|||||||
node.lineno = tree.line
|
node.lineno = tree.line
|
||||||
node.col_offset = tree.column
|
node.col_offset = tree.column
|
||||||
|
|
||||||
|
|
||||||
if isinstance(ret, list):
|
if isinstance(ret, list):
|
||||||
for r in ret:
|
for r in ret:
|
||||||
_correct_tree(r, tree)
|
_correct_tree(r, tree)
|
||||||
|
@ -6,4 +6,4 @@ class HYBool(HYObject):
|
|||||||
self._val = val
|
self._val = val
|
||||||
|
|
||||||
def eval(self, lns, *args, **kwargs):
|
def eval(self, lns, *args, **kwargs):
|
||||||
return self._val == True
|
return self._val is True
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#
|
#
|
||||||
import sys
|
import sys
|
||||||
from hy.lang.internals import HYNamespaceCOW
|
|
||||||
from hy.lang.string import HYString
|
from hy.lang.string import HYString
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ from hy.compiler.ast27 import forge_module
|
|||||||
|
|
||||||
from hy.lex.tokenize import tokenize
|
from hy.lex.tokenize import tokenize
|
||||||
import sys
|
import sys
|
||||||
import imp
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
from hy.lang.bool import HYBool
|
|
||||||
from hy.lex.tokenize import tokenize as _hy_tok
|
from hy.lex.tokenize import tokenize as _hy_tok
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@ -24,6 +23,7 @@ def _foreach(*args):
|
|||||||
for arg in a:
|
for arg in a:
|
||||||
args[1](arg)
|
args[1](arg)
|
||||||
|
|
||||||
|
|
||||||
def _get(*args):
|
def _get(*args):
|
||||||
m = args[0]
|
m = args[0]
|
||||||
k = args[1]
|
k = args[1]
|
||||||
@ -85,7 +85,6 @@ def _ne(*args):
|
|||||||
|
|
||||||
|
|
||||||
def _gt(*args):
|
def _gt(*args):
|
||||||
arg = args[0]
|
|
||||||
for i in range(1, len(args)):
|
for i in range(1, len(args)):
|
||||||
if not (args[i - 1] > args[i]):
|
if not (args[i - 1] > args[i]):
|
||||||
return False
|
return False
|
||||||
@ -93,7 +92,6 @@ def _gt(*args):
|
|||||||
|
|
||||||
|
|
||||||
def _ge(*args):
|
def _ge(*args):
|
||||||
arg = args[0]
|
|
||||||
for i in range(1, len(args)):
|
for i in range(1, len(args)):
|
||||||
if not (args[i - 1] >= args[i]):
|
if not (args[i - 1] >= args[i]):
|
||||||
return False
|
return False
|
||||||
@ -101,7 +99,6 @@ def _ge(*args):
|
|||||||
|
|
||||||
|
|
||||||
def _le(*args):
|
def _le(*args):
|
||||||
arg = args[0]
|
|
||||||
for i in range(1, len(args)):
|
for i in range(1, len(args)):
|
||||||
if not (args[i - 1] <= args[i]):
|
if not (args[i - 1] <= args[i]):
|
||||||
return False
|
return False
|
||||||
@ -109,7 +106,6 @@ def _le(*args):
|
|||||||
|
|
||||||
|
|
||||||
def _lt(*args):
|
def _lt(*args):
|
||||||
arg = args[0]
|
|
||||||
for i in range(1, len(args)):
|
for i in range(1, len(args)):
|
||||||
if not (args[i - 1] < args[i]):
|
if not (args[i - 1] < args[i]):
|
||||||
return False
|
return False
|
||||||
|
@ -74,17 +74,22 @@ class Comment(State):
|
|||||||
|
|
||||||
class Idle(State):
|
class Idle(State):
|
||||||
def p(self, x):
|
def p(self, x):
|
||||||
if x == "#": return HashExpression
|
if x == "#":
|
||||||
if x == ";": return Comment
|
return HashExpression
|
||||||
if x == "(": return Expression
|
if x == ";":
|
||||||
if x in WHITESPACE: return
|
return Comment
|
||||||
|
if x == "(":
|
||||||
|
return Expression
|
||||||
|
if x in WHITESPACE:
|
||||||
|
return
|
||||||
|
|
||||||
raise LexException("Unknown char: %s" % (x))
|
raise LexException("Unknown char: %s" % (x))
|
||||||
|
|
||||||
|
|
||||||
class HashExpression(State):
|
class HashExpression(State):
|
||||||
def p(self, x):
|
def p(self, x):
|
||||||
if x == "!": return Comment
|
if x == "!":
|
||||||
|
return Comment
|
||||||
|
|
||||||
raise LexException("Unknwon Hash modifier - %s" % (x))
|
raise LexException("Unknwon Hash modifier - %s" % (x))
|
||||||
|
|
||||||
@ -106,13 +111,26 @@ class Expression(State):
|
|||||||
self.bulk = ""
|
self.bulk = ""
|
||||||
|
|
||||||
def p(self, x):
|
def p(self, x):
|
||||||
if x == ")": return Idle
|
if x == ")":
|
||||||
if x in WHITESPACE: self.commit(); return
|
return Idle
|
||||||
if x == "\"": self.sub(String); return
|
if x in WHITESPACE:
|
||||||
if x == "(": self.sub(Expression); return
|
self.commit()
|
||||||
if x == "[": self.sub(List); return
|
return
|
||||||
if x == "{": self.sub(Map); return
|
if x == "\"":
|
||||||
if x == ";": self.sub(Comment); return
|
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
|
self.bulk += x
|
||||||
|
|
||||||
|
|
||||||
@ -132,13 +150,26 @@ class List(State):
|
|||||||
self.bulk = ""
|
self.bulk = ""
|
||||||
|
|
||||||
def p(self, x):
|
def p(self, x):
|
||||||
if x == "]": return Idle
|
if x == "]":
|
||||||
if x in WHITESPACE: self.commit(); return
|
return Idle
|
||||||
if x == "\"": self.sub(String); return
|
if x in WHITESPACE:
|
||||||
if x == "[": self.sub(List); return
|
self.commit()
|
||||||
if x == "(": self.sub(Expression); return
|
return
|
||||||
if x == "{": self.sub(Map); return
|
if x == "\"":
|
||||||
if x == ";": self.sub(Comment); return
|
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
|
self.bulk += x
|
||||||
|
|
||||||
|
|
||||||
@ -167,18 +198,31 @@ class Map(State):
|
|||||||
self.bulk = ""
|
self.bulk = ""
|
||||||
|
|
||||||
def p(self, x):
|
def p(self, x):
|
||||||
if x == "}": return Idle
|
if x == "}":
|
||||||
if x in WHITESPACE: self.commit(); return
|
return Idle
|
||||||
if x == "\"": self.sub(String); return
|
if x in WHITESPACE:
|
||||||
if x == "[": self.sub(List); return
|
self.commit()
|
||||||
if x == "{": self.sub(Map); return
|
return
|
||||||
if x == "(": self.sub(Expression); return
|
if x == "\"":
|
||||||
if x == ";": self.sub(Comment); return
|
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
|
self.bulk += x
|
||||||
|
|
||||||
|
|
||||||
class String(State):
|
class String(State):
|
||||||
magic = { "n": "\n", "t": "\t", "\\": "\\", "\"": "\"" }
|
magic = {"n": "\n", "t": "\t", "\\": "\\", "\"": "\""}
|
||||||
|
|
||||||
def enter(self):
|
def enter(self):
|
||||||
self.buf = ""
|
self.buf = ""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user