Merge branch 'master' into pr/187

This commit is contained in:
Paul Tagliamonte 2013-06-18 21:17:13 -04:00
commit b00f181e1e
6 changed files with 28 additions and 11 deletions

View File

@ -11,3 +11,4 @@
* Vladimir Gorbunov <vsg@suburban.me>
* John Jacobsen <john@mail.npxdesigns.com>
* rogererens <roger.erens@e-s-c.biz>
* Thomas Ballinger <thomasballinger@gmail.com>

View File

@ -12,7 +12,7 @@ Theory of Hy
============
Hy maintains, over everything else, 100% compatibility in both directions
with Python it's self. All Hy code follows a few simple rules. Memorize
with Python itself. All Hy code follows a few simple rules. Memorize
this, it's going to come in handy.
These rules help make sure code is idiomatic and interface-able in both

View File

@ -0,0 +1,6 @@
(import [clint.textui [progress]]
[time [sleep]]
[random [random]])
(for [x (.bar progress (range 100))]
(sleep (* (random) 0.1)))

View File

@ -255,8 +255,9 @@ class String(State):
"""
if self.escaped:
self.escaped = False
if char == "n":
self.nodes.append("\n")
simple_escapables = tuple('abfnrtv')
if char in simple_escapables:
self.nodes.append(eval('"\\'+char+'"'))
return
if char == "\\":
self.nodes.append("\\")

View File

@ -57,20 +57,25 @@ def _wrap_value(x):
else:
return wrapper(x)
_wrappers = {int: HyInteger,
bool: lambda x: HySymbol("True") if x else HySymbol("False"),
float: HyFloat,
complex: HyComplex,
str_type: HyString,
dict: lambda d: HyDict(_wrap_value(x) for x in sum(d.items(), ())),
list: lambda l: HyList(_wrap_value(x) for x in l)}
_wrappers = {
int: HyInteger,
bool: lambda x: HySymbol("True") if x else HySymbol("False"),
float: HyFloat,
complex: HyComplex,
str_type: HyString,
dict: lambda d: HyDict(_wrap_value(x) for x in sum(d.items(), ())),
list: lambda l: HyList(_wrap_value(x) for x in l)
}
def process(tree, module_name):
if isinstance(tree, HyExpression):
fn = tree[0]
if fn in ("quote", "quasiquote"):
return tree
ntree = HyExpression([fn] + [process(x, module_name) for x in tree[1:]])
ntree = HyExpression(
[fn] + [process(x, module_name) for x in tree[1:]]
)
ntree.replace(tree)
if isinstance(fn, HyString):

View File

@ -728,3 +728,7 @@
(assert (= x [3 2 1]))
"success")
(except [NameError] "failure")))))
(defn test-encoding-nightmares []
"NATIVE: test unicode encoding escaping crazybits"
(assert (= (len "ℵℵℵ♥♥♥\t♥♥\r\n") 11)))