@@ -294,28 +294,34 @@ function _lookahead_index(stream::ParseStream, n::Integer, skip_newlines::Bool)
294
294
end
295
295
296
296
"""
297
- peek(stream [, n=1])
297
+ peek(stream [, n=1]; skip_newlines=false )
298
298
299
299
Look ahead in the stream `n` tokens, returning the token kind. Comments and
300
300
non-newline whitespace are skipped automatically. Whitespace containing a
301
301
single newline is returned as kind `K"NewlineWs"` unless `skip_newlines` is
302
302
true.
303
303
"""
304
- function Base. peek (stream:: ParseStream , n:: Integer = 1 ; skip_newlines:: Bool = false )
305
- kind (peek_token (stream, n; skip_newlines= skip_newlines))
304
+ function Base. peek (stream:: ParseStream , n:: Integer = 1 ;
305
+ skip_newlines:: Bool = false , skip_whitespace= true )
306
+ kind (peek_token (stream, n; skip_newlines= skip_newlines, skip_whitespace= skip_whitespace))
306
307
end
307
308
308
309
"""
309
310
peek_token(stream [, n=1])
310
311
311
312
Like `peek`, but return the full token information rather than just the kind.
312
313
"""
313
- function peek_token (stream:: ParseStream , n:: Integer = 1 ; skip_newlines= false )
314
+ function peek_token (stream:: ParseStream , n:: Integer = 1 ;
315
+ skip_newlines= false , skip_whitespace= true )
314
316
stream. peek_count += 1
315
317
if stream. peek_count > 100_000
316
318
error (" The parser seems stuck at byte $(stream. next_byte) " )
317
319
end
318
- stream. lookahead[_lookahead_index (stream, n, skip_newlines)]
320
+ i = _lookahead_index (stream, n, skip_newlines)
321
+ if ! skip_whitespace
322
+ i = 1
323
+ end
324
+ return stream. lookahead[i]
319
325
end
320
326
321
327
function _peek_behind_fields (ranges, i)
0 commit comments