dictionary parsing didn't work

This commit is contained in:
David Halter
2012-05-05 12:09:12 +02:00
parent b6e98b2eee
commit 5fa627ef58
2 changed files with 11 additions and 5 deletions

View File

@@ -800,7 +800,6 @@ class Array(Call):
one array. one array.
""" """
self.values.append([]) self.values.append([])
self.keys.append(None)
def add_to_current_field(self, tok): def add_to_current_field(self, tok):
""" Adds a token to the latest field (in content). """ """ Adds a token to the latest field (in content). """
@@ -813,12 +812,10 @@ class Array(Call):
def add_dictionary_key(self): def add_dictionary_key(self):
""" """
Only used for dictionaries, automatically adds the tokens added by now Only used for dictionaries, automatically adds the tokens added by now
from the values to keys. from the values to keys, because the parser works this way.
""" """
self.type = Array.DICT self.type = Array.DICT
c = self._counter self.keys.append(self.values.pop())
self.keys[c] = self.values[c]
self.values[c] = []
def get_only_subelement(self): def get_only_subelement(self):
""" """

View File

@@ -32,6 +32,9 @@ list().app
#? ['append'] #? ['append']
[].append [].append
arr2 = [1,2,3]
#? ['append']
arr2.app
# ----------------- # -----------------
# dicts # dicts
@@ -47,6 +50,12 @@ dic2.p
#? ['popitem'] #? ['popitem']
{}.popitem {}.popitem
dic2 = {'asdf': 3}
#? ['popitem']
dic2.popitem
#? ['real']
dic2['asdf'].real
# ----------------- # -----------------
# set # set