Mercurial > lbo > hg > pcombinators
changeset 56:571cbdc11361 draft
Further speed up JSON by 2x - removed distinction between entry/midentry
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Fri, 24 May 2019 00:53:06 +0200 |
parents | 20b76a3c3211 |
children | 66da7e4ab989 |
files | pcombinators/json_test.py |
diffstat | 1 files changed, 2 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/pcombinators/json_test.py Fri May 24 00:11:18 2019 +0200 +++ b/pcombinators/json_test.py Fri May 24 00:53:06 2019 +0200 @@ -42,16 +42,13 @@ assert False, "Unexpected list format: {}".format(l) # An entry is any value. -entry = Value() -# A mid entry is a value followed by a comma. Last ensures that the result -# is an entry, not a list of one entry. -midentry = Last(entry + Skip(String(','))) +entry = Last(Value() + Skip(String(',') | Nothing())) # A list is a [, followed by mid entries, followed by a final entry, and a # closing ]. The list is wrapped in a list to prevent merging in other parsers. # Flatten() takes care that the list from Repeat() and the single entry are made # into one list. List = Last(Skip(String('[')) + - ((Repeat(midentry, -1) + entry) >> concat_elems_elem) + + Repeat(entry, -1) + Skip(String(']'))) # DICTS