Permalink
Browse files

import char decoding

  • Loading branch information...
1 parent edbe15d commit 340e8e4fde05079ad2d0a3ede0487c4e1114fc9a @sunng87 committed Feb 13, 2012
Showing with 12 additions and 3 deletions.
  1. +8 −2 clj.py
  2. +4 −1 tests/clj-test.py
View
@@ -133,8 +133,13 @@ def __read_token(self):
v = False
elif t == "char":
- v = fd.read(1)
- e = fd.read(1)
+ buf = []
+ while c is not self.terminator and c is not "" and c not in self.stop_chars:
+ c = fd.read(1)
+ buf.append(c)
+
+ e = c
+ v = ''.join(buf[:-1])
elif t == "nil":
e = fd.read(3)[-1]
@@ -154,6 +159,7 @@ def __read_token(self):
while c is not self.terminator and c is not "" and c not in self.stop_chars:
c = fd.read(1)
buf.append(c)
+
e = c
v = ''.join(buf[:-1])
View
@@ -13,14 +13,17 @@ def setUp(self):
":hello": "hello",
r'"string\"ing"': 'string"ing',
'"string\n"': 'string\n',
+ '[:hello]':["hello"],
+ '-10.4':-10.4,
u'"你"': u'',
"[1 2]": [1,2],
"#{true \"hello\" 12}": set([True, "hello", 12]),
"(\\a \\b \\c \\d)": ["a","b","c","d"],
"{:a 1 :b 2 :c 3 :d 4}": {"a":1, "b":2, "c":3,"d":4},
"[1 2 3,4]": [1,2,3,4],
"{:a [1 2 3] :b #{23.1 43.1 33.1}}": {"a":[1,2,3], "b":set([23.1,43.1,33.1])},
- "{:a 1 :b [32 32 43] :c 4}": {"a":1,"b":[32,32,43],"c":4}}
+ "{:a 1 :b [32 32 43] :c 4}": {"a":1,"b":[32,32,43],"c":4},
+ "\\": ""}
def test_all_data(self):
for k,v in self.data.items():

0 comments on commit 340e8e4

Please sign in to comment.