@@ -242,35 +242,17 @@ private void ParseTokens()
242
242
switch ( _tokens . Current . Type )
243
243
{
244
244
case TokenType . Include :
245
- var parsedInclude = ParseInclude ( null ) ;
246
- if ( _root . Type != HoconType . Object )
247
- {
248
- _root . Clear ( ) ;
249
- _root . Add ( parsedInclude . GetObject ( ) ) ;
250
- }
251
- else
252
- _root . Add ( parsedInclude . GetObject ( ) ) ;
245
+ _root . Add ( ParseInclude ( _root ) ) ;
253
246
break ;
254
247
255
248
// Hocon config file may contain one array and one array only
256
249
case TokenType . StartOfArray :
257
- _root . Clear ( ) ;
258
- _root . Add ( ParseArray ( null ) ) ;
259
- ConsumeWhitelines ( ) ;
260
- if ( _tokens . Current . Type != TokenType . EndOfFile )
261
- throw HoconParserException . Create ( _tokens . Current , Path , "Hocon config can only contain one array or one object." ) ;
262
- return ;
250
+ _root . Add ( ParseArray ( _root ) ) ;
251
+ break ;
263
252
264
253
case TokenType . StartOfObject :
265
254
{
266
- var parsedObject = ParseObject ( null ) ;
267
- if ( _root . Type != HoconType . Object )
268
- {
269
- _root . Clear ( ) ;
270
- _root . Add ( parsedObject ) ;
271
- }
272
- else
273
- _root . Add ( parsedObject . GetObject ( ) ) ;
255
+ _root . Add ( ParseObject ( _root ) . GetObject ( ) ) ;
274
256
break ;
275
257
}
276
258
@@ -281,20 +263,12 @@ private void ParseTokens()
281
263
if ( _tokens . Current . Type != TokenType . LiteralValue )
282
264
break ;
283
265
284
- var parsedObject = ParseObject ( null ) ;
285
- if ( _root . Type != HoconType . Object )
286
- {
287
- _root . Clear ( ) ;
288
- _root . Add ( parsedObject ) ;
289
- }
290
- else
291
- _root . Add ( parsedObject . GetObject ( ) ) ;
266
+ _root . Add ( ParseObject ( _root ) . GetObject ( ) ) ;
292
267
break ;
293
268
}
294
269
295
270
case TokenType . Comment :
296
271
case TokenType . EndOfLine :
297
- case TokenType . EndOfFile :
298
272
case TokenType . EndOfObject :
299
273
case TokenType . EndOfArray :
300
274
_tokens . Next ( ) ;
0 commit comments