Mercurial > repos > tabletprog
comparison modules/json.tp @ 166:e7642715d575
Handle newlines and carriage returns in JSON decoder
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 11 Aug 2013 02:31:33 -0700 |
parents | fe816637fcc4 |
children | 5a6a55592c45 |
comparison
equal
deleted
inserted
replaced
165:fe816637fcc4 | 166:e7642715d575 |
---|---|
9 nine <- "9" byte: 0 | 9 nine <- "9" byte: 0 |
10 neg <- "-" byte: 0 | 10 neg <- "-" byte: 0 |
11 space <- " " byte: 0 | 11 space <- " " byte: 0 |
12 comma <- "," byte: 0 | 12 comma <- "," byte: 0 |
13 tab <- "\t" byte: 0 | 13 tab <- "\t" byte: 0 |
14 nl <- "\n" byte: 0 | |
15 cr <- "\r" byte: 0 | |
14 colon <- ":" byte: 0 | 16 colon <- ":" byte: 0 |
15 t <- "t" byte: 0 | 17 t <- "t" byte: 0 |
16 f <- "f" byte: 0 | 18 f <- "f" byte: 0 |
17 | 19 |
18 parseNumAt <- :str :at :recvResult { | 20 parseNumAt <- :str :at :recvResult { |
73 b <- text byte: cur | 75 b <- text byte: cur |
74 if: b = endArr { | 76 if: b = endArr { |
75 aft <- cur + 1 | 77 aft <- cur + 1 |
76 cur <- len | 78 cur <- len |
77 } else: { | 79 } else: { |
78 if: b = comma || b = space || b = tab { | 80 if: b = comma || b = space || b = tab || b = nl || b = cr { |
79 cur <- cur + 1 | 81 cur <- cur + 1 |
80 } else: { | 82 } else: { |
81 el <- _decode: text at: cur | 83 el <- _decode: text at: cur |
82 cur <- el after | 84 cur <- el after |
83 val append: (el value) | 85 val append: (el value) |
96 aft <- -1 | 98 aft <- -1 |
97 expectKey <- true | 99 expectKey <- true |
98 key <- "" | 100 key <- "" |
99 while: { cur < len } do: { | 101 while: { cur < len } do: { |
100 b <- text byte: cur | 102 b <- text byte: cur |
101 if: b = comma || b = space || b = tab || b = colon { | 103 if: b = comma || b = space || b = tab || b = colon || b = nl || b = cr { |
102 cur <- cur + 1 | 104 cur <- cur + 1 |
103 } else: { | 105 } else: { |
104 if: expectKey { | 106 if: expectKey { |
105 if: b = endObj { | 107 if: b = endObj { |
106 aft <- cur + 1 | 108 aft <- cur + 1 |