File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ export function* tokenise(input: string): Iterator<Token> {
123
123
let name = "" ;
124
124
for ( let i = 0 ; i < input . length ; i ++ ) {
125
125
let char = input [ i ] ;
126
- if ( char === ":" || char === " " || char === "\n" ) {
126
+ if ( char === ":" || char === " " || char === "\n" || char === "," ) {
127
127
break ;
128
128
} else {
129
129
name += char ;
@@ -228,18 +228,25 @@ export class Parser {
228
228
invariant ( key , "Expected a key" ) ;
229
229
230
230
let keys = [ key ] ;
231
+ this . next ( ) ;
231
232
232
233
// support multiple keys
233
- while ( this . eat ( TOKEN_TYPES . comma ) ) {
234
+ while ( this . token . type === TOKEN_TYPES . comma ) {
235
+ this . next ( ) ; // skip comma
236
+
234
237
let keyToken = this . token ;
235
- this . expect ( TOKEN_TYPES . string ) ;
238
+ if ( keyToken . type !== TOKEN_TYPES . string ) {
239
+ this . unexepcted ( "Expected string" ) ;
240
+ }
236
241
237
242
let key = keyToken . value ;
238
243
invariant ( key , "Expected a key" ) ;
239
244
keys . push ( key ) ;
245
+ this . next ( ) ;
240
246
}
241
247
242
- let valToken = this . next ( ) ;
248
+ let valToken = this . token ;
249
+
243
250
if ( valToken . type === TOKEN_TYPES . colon ) { // object
244
251
this . next ( ) ;
245
252
You can’t perform that action at this time.
0 commit comments