Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix bug of setting terminator

  • Loading branch information...
commit 3aec533503500e30f9d601d21587feedf0b07d96 1 parent dfa8d41
@sunng87 authored
Showing with 8 additions and 5 deletions.
  1. +6 −4 clj.py
  2. +2 −1  tests/clj-test.py
View
10 clj.py
@@ -143,12 +143,12 @@ def __read_token(self):
v = None
elif t == "number":
- buf = [c]
+ 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)
+ c = fd.read(1)
e = c
- numstr = ''.join(buf[:-1])
+ numstr = ''.join(buf)
v = number(numstr)
elif t == "keyword":
@@ -175,7 +175,8 @@ def __read_token(self):
e = c
if e is self.terminator:
- current_scope, self.terminator, self.container = self.value_stack.pop()
+ current_scope, _, self.container = self.value_stack.pop()
+
if r:
current_scope.append(v)
@@ -190,6 +191,7 @@ def __read_token(self):
if len(self.value_stack) > 0:
self.value_stack[-1][0].append(v)
+ self.terminator = self.value_stack[-1][1]
return v
View
3  tests/clj-test.py
@@ -19,7 +19,8 @@ def setUp(self):
"(\\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 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}}
def test_all_data(self):
for k,v in self.data.items():
Please sign in to comment.
Something went wrong with that request. Please try again.