From 00f655c3a165d1e260be6c2f15d234bdea7ead32 Mon Sep 17 00:00:00 2001 From: Thomas Ballinger Date: Fri, 7 Jun 2013 00:53:53 -0300 Subject: [PATCH 1/6] grammar in api.rst --- docs/language/api.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/language/api.rst b/docs/language/api.rst index 47d99d8..31a32a7 100644 --- a/docs/language/api.rst +++ b/docs/language/api.rst @@ -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 From 00da0468e64cb6a3224adfbdb04ece6880d11033 Mon Sep 17 00:00:00 2001 From: Thomas Ballinger Date: Fri, 7 Jun 2013 17:07:22 -0400 Subject: [PATCH 2/6] larger kludge for escaped characters --- hy/lex/states.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hy/lex/states.py b/hy/lex/states.py index 51255bd..9c81967 100644 --- a/hy/lex/states.py +++ b/hy/lex/states.py @@ -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("\\") From d15aa31a32ce47e993ec4a2ee1ece17711579a3d Mon Sep 17 00:00:00 2001 From: Paul Tagliamonte Date: Sat, 8 Jun 2013 20:10:27 -0400 Subject: [PATCH 3/6] style fixes --- hy/macros.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/hy/macros.py b/hy/macros.py index 5149cc7..d3530fd 100644 --- a/hy/macros.py +++ b/hy/macros.py @@ -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): From 4aca7842cd784f579e7f73b79141b88081f35a78 Mon Sep 17 00:00:00 2001 From: Paul Tagliamonte Date: Sat, 8 Jun 2013 20:17:50 -0400 Subject: [PATCH 4/6] Add regression test for UTF and escapes. --- tests/native_tests/language.hy | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/native_tests/language.hy b/tests/native_tests/language.hy index cf345f4..07ed7db 100644 --- a/tests/native_tests/language.hy +++ b/tests/native_tests/language.hy @@ -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))) From 8935a998adca4f17795839b4c9953cb23868c999 Mon Sep 17 00:00:00 2001 From: Paul Tagliamonte Date: Sat, 8 Jun 2013 20:18:34 -0400 Subject: [PATCH 5/6] Add @thomasballinger to AUTHORS --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 2247f9c..d18f375 100644 --- a/AUTHORS +++ b/AUTHORS @@ -11,3 +11,4 @@ * Vladimir Gorbunov * John Jacobsen * rogererens +* Thomas Ballinger From 2e7cd1616960c91d7de0ed0910ea16efe81a118a Mon Sep 17 00:00:00 2001 From: Paul Tagliamonte Date: Sat, 8 Jun 2013 20:35:50 -0400 Subject: [PATCH 6/6] add in a clint example while I ponder hy scripts using it --- eg/clint/clint-progress.hy | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 eg/clint/clint-progress.hy diff --git a/eg/clint/clint-progress.hy b/eg/clint/clint-progress.hy new file mode 100644 index 0000000..4d247f1 --- /dev/null +++ b/eg/clint/clint-progress.hy @@ -0,0 +1,6 @@ +(import [clint.textui [progress]] + [time [sleep]] + [random [random]]) + +(for [x (.bar progress (range 100))] + (sleep (* (random) 0.1)))