Merge branch 'master' into pr/187
This commit is contained in:
commit
b00f181e1e
1
AUTHORS
1
AUTHORS
@ -11,3 +11,4 @@
|
|||||||
* Vladimir Gorbunov <vsg@suburban.me>
|
* Vladimir Gorbunov <vsg@suburban.me>
|
||||||
* John Jacobsen <john@mail.npxdesigns.com>
|
* John Jacobsen <john@mail.npxdesigns.com>
|
||||||
* rogererens <roger.erens@e-s-c.biz>
|
* rogererens <roger.erens@e-s-c.biz>
|
||||||
|
* Thomas Ballinger <thomasballinger@gmail.com>
|
||||||
|
@ -12,7 +12,7 @@ Theory of Hy
|
|||||||
============
|
============
|
||||||
|
|
||||||
Hy maintains, over everything else, 100% compatibility in both directions
|
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.
|
this, it's going to come in handy.
|
||||||
|
|
||||||
These rules help make sure code is idiomatic and interface-able in both
|
These rules help make sure code is idiomatic and interface-able in both
|
||||||
|
6
eg/clint/clint-progress.hy
Normal file
6
eg/clint/clint-progress.hy
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
(import [clint.textui [progress]]
|
||||||
|
[time [sleep]]
|
||||||
|
[random [random]])
|
||||||
|
|
||||||
|
(for [x (.bar progress (range 100))]
|
||||||
|
(sleep (* (random) 0.1)))
|
@ -255,8 +255,9 @@ class String(State):
|
|||||||
"""
|
"""
|
||||||
if self.escaped:
|
if self.escaped:
|
||||||
self.escaped = False
|
self.escaped = False
|
||||||
if char == "n":
|
simple_escapables = tuple('abfnrtv')
|
||||||
self.nodes.append("\n")
|
if char in simple_escapables:
|
||||||
|
self.nodes.append(eval('"\\'+char+'"'))
|
||||||
return
|
return
|
||||||
if char == "\\":
|
if char == "\\":
|
||||||
self.nodes.append("\\")
|
self.nodes.append("\\")
|
||||||
|
21
hy/macros.py
21
hy/macros.py
@ -57,20 +57,25 @@ def _wrap_value(x):
|
|||||||
else:
|
else:
|
||||||
return wrapper(x)
|
return wrapper(x)
|
||||||
|
|
||||||
_wrappers = {int: HyInteger,
|
_wrappers = {
|
||||||
bool: lambda x: HySymbol("True") if x else HySymbol("False"),
|
int: HyInteger,
|
||||||
float: HyFloat,
|
bool: lambda x: HySymbol("True") if x else HySymbol("False"),
|
||||||
complex: HyComplex,
|
float: HyFloat,
|
||||||
str_type: HyString,
|
complex: HyComplex,
|
||||||
dict: lambda d: HyDict(_wrap_value(x) for x in sum(d.items(), ())),
|
str_type: HyString,
|
||||||
list: lambda l: HyList(_wrap_value(x) for x in l)}
|
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):
|
def process(tree, module_name):
|
||||||
if isinstance(tree, HyExpression):
|
if isinstance(tree, HyExpression):
|
||||||
fn = tree[0]
|
fn = tree[0]
|
||||||
if fn in ("quote", "quasiquote"):
|
if fn in ("quote", "quasiquote"):
|
||||||
return tree
|
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)
|
ntree.replace(tree)
|
||||||
|
|
||||||
if isinstance(fn, HyString):
|
if isinstance(fn, HyString):
|
||||||
|
@ -728,3 +728,7 @@
|
|||||||
(assert (= x [3 2 1]))
|
(assert (= x [3 2 1]))
|
||||||
"success")
|
"success")
|
||||||
(except [NameError] "failure")))))
|
(except [NameError] "failure")))))
|
||||||
|
|
||||||
|
(defn test-encoding-nightmares []
|
||||||
|
"NATIVE: test unicode encoding escaping crazybits"
|
||||||
|
(assert (= (len "ℵℵℵ♥♥♥\t♥♥\r\n") 11)))
|
||||||
|
Loading…
Reference in New Issue
Block a user