8181function process_directives (stream:: EventStream )
8282 stream. yaml_version = nothing
8383 stream. tag_handles = Dict {String, String} ()
84- while typeof ( peek (stream. input)) == DirectiveToken
84+ while peek (stream. input) isa DirectiveToken
8585 token = forward! (stream. input)
8686 if token. name == " YAML"
8787 if stream. yaml_version != = nothing
@@ -136,11 +136,11 @@ end
136136function parse_implicit_document_start (stream:: EventStream )
137137 token = peek (stream. input)
138138 # Parse a byte order mark
139- if typeof ( token) == ByteOrderMarkToken
139+ if token isa ByteOrderMarkToken
140140 forward! (stream. input)
141141 token = peek (stream. input)
142142 end
143- if ! in ( typeof ( token), [ DirectiveToken, DocumentStartToken, StreamEndToken] )
143+ if ! ( token isa Union{ DirectiveToken, DocumentStartToken, StreamEndToken} )
144144 stream. tag_handles = DEFAULT_TAGS
145145 event = DocumentStartEvent (token. span. start_mark, token. span. start_mark,
146146 false )
@@ -157,22 +157,22 @@ end
157157
158158function parse_document_start (stream:: EventStream )
159159 # Parse any extra document end indicators.
160- while typeof ( peek (stream. input)) == DocumentEndToken
160+ while peek (stream. input) isa DocumentEndToken
161161 stream. input = Iterators. rest (stream. input)
162162 end
163163
164164 token = peek (stream. input)
165165 # Parse a byte order mark if it exists
166- if typeof ( token) == ByteOrderMarkToken
166+ if token isa ByteOrderMarkToken
167167 forward! (stream. input)
168168 token = peek (stream. input)
169169 end
170170
171171 # Parse explicit document.
172- if typeof (token) != StreamEndToken
172+ if ! (token isa StreamEndToken)
173173 start_mark = token. span. start_mark
174174 version, tags = process_directives (stream)
175- if typeof (peek (stream. input)) != DocumentStartToken
175+ if ! (peek (stream. input) isa DocumentStartToken)
176176 throw (ParserError (nothing , nothing ,
177177 " expected '<document start>' but found $(typeof (token)) " ))
178178 end
@@ -198,7 +198,7 @@ function parse_document_end(stream::EventStream)
198198 token = peek (stream. input)
199199 start_mark = end_mark = token. span. start_mark
200200 explicit = false
201- if typeof ( token) == DocumentEndToken
201+ if token isa DocumentEndToken
202202 forward! (stream. input)
203203 end_mark = token. span. end_mark
204204 explicit = true
@@ -305,25 +305,25 @@ function _parse_node(token, stream::EventStream, block, indentless_sequence)
305305 anchor = nothing
306306 tag = nothing
307307 start_mark = end_mark = tag_mark = nothing
308- if typeof ( token) == AnchorToken
308+ if token isa AnchorToken
309309 forward! (stream. input)
310310 start_mark = token. span. start_mark
311311 end_mark = token. span. end_mark
312312 anchor = token. value
313313 token = peek (stream. input)
314- if typeof ( token) == TagToken
314+ if token isa TagToken
315315 forward! (stream. input)
316316 tag_mark = token. span. start_mark
317317 end_mark = token. span. end_mark
318318 tag = token. value
319319 end
320- elseif typeof ( token) == TagToken
320+ elseif token isa TagToken
321321 forward! (stream. input)
322322 start_mark = token. span. start_mark
323323 end_mark = token. span. end_mark
324324 tag = token. value
325325 token = peek (stream. input)
326- if typeof ( token) == AnchorToken
326+ if token isa AnchorToken
327327 forward! (stream. input)
328328 end_mark = token. end_mark
329329 anchor = token. value
@@ -351,7 +351,7 @@ function _parse_node(token, stream::EventStream, block, indentless_sequence)
351351
352352 event = nothing
353353 implicit = tag === nothing || tag == " !"
354- if indentless_sequence && typeof ( token) == BlockEntryToken
354+ if indentless_sequence && token isa BlockEntryToken
355355 end_mark = token. span. end_mark
356356 stream. state = parse_indentless_sequence_entry
357357 event = SequenceStartEvent (start_mark, end_mark, anchor, tag, implicit,
377377
378378function parse_block_sequence_entry (stream:: EventStream )
379379 token = peek (stream. input)
380- if typeof ( token) == BlockEntryToken
380+ if token isa BlockEntryToken
381381 forward! (stream. input)
382- if ! in ( typeof ( peek (stream. input)), [ BlockEntryToken, BlockEndToken] )
382+ if ! ( peek (stream. input) isa Union{ BlockEntryToken, BlockEndToken} )
383383 push! (stream. states, parse_block_sequence_entry)
384384 return parse_block_node (stream)
385385 else
@@ -388,7 +388,7 @@ function parse_block_sequence_entry(stream::EventStream)
388388 end
389389 end
390390
391- if typeof (token) != BlockEndToken
391+ if ! (token isa BlockEndToken)
392392 throw (ParserError (" while parsing a block collection" , stream. marks[end ],
393393 " expected <block end>, but found $(typeof (token)) " ,
394394 token. span. start_mark))
403403
404404function parse_indentless_sequence_entry (stream:: EventStream )
405405 token = peek (stream. input)
406- if typeof ( token) == BlockEntryToken
406+ if token isa BlockEntryToken
407407 forward! (stream. input)
408- if ! in ( typeof ( peek (stream. input)), [ BlockEntryToken, KeyToken, ValueToken, BlockEndToken] )
408+ if ! ( peek (stream. input) isa Union{ BlockEntryToken, KeyToken, ValueToken, BlockEndToken} )
409409 push! (stream. states, parse_indentless_sequence_entry)
410410 return parse_block_node (stream)
411411 else
428428
429429function parse_block_mapping_key (stream:: EventStream )
430430 token = peek (stream. input)
431- if typeof ( token) == KeyToken
431+ if token isa KeyToken
432432 forward! (stream. input)
433- if ! in ( typeof ( peek (stream. input)), [ KeyToken, ValueToken, BlockEndToken] )
433+ if ! ( peek (stream. input) isa Union{ KeyToken, ValueToken, BlockEndToken} )
434434 push! (stream. states, parse_block_mapping_value)
435435 return parse_block_node_or_indentless_sequence (stream)
436436 else
@@ -439,7 +439,7 @@ function parse_block_mapping_key(stream::EventStream)
439439 end
440440 end
441441
442- if typeof (token) != BlockEndToken
442+ if ! (token isa BlockEndToken)
443443 throw (ParserError (" while parsing a block mapping" , stream. marks[end ],
444444 " expected <block end>, but found $(typeof (token)) " ,
445445 token. span. start_mark))
454454
455455function parse_block_mapping_value (stream:: EventStream )
456456 token = peek (stream. input)
457- if typeof ( token) == ValueToken
457+ if token isa ValueToken
458458 forward! (stream. input)
459- if ! in ( typeof ( peek (stream. input)), [ KeyToken, ValueToken, BlockEndToken] )
459+ if ! ( peek (stream. input) isa Union{ KeyToken, ValueToken, BlockEndToken} )
460460 push! (stream. states, parse_block_mapping_key)
461461 parse_block_node_or_indentless_sequence (stream)
462462 else
485485
486486function _parse_flow_sequence_entry (token:: Any , stream:: EventStream , first_entry= false )
487487 if ! first_entry
488- if typeof ( token) == FlowEntryToken
488+ if token isa FlowEntryToken
489489 forward! (stream. input)
490490 else
491491 throw (ParserError (" while parsing a flow sequence" ,
515515
516516function parse_flow_sequence_entry_mapping_key (stream:: EventStream )
517517 token = forward! (stream. input)
518- if ! in ( typeof ( token), [ ValueToken, FlowEntryToken, FlowSequenceEndToken] )
518+ if ! ( token isa Union{ ValueToken, FlowEntryToken, FlowSequenceEndToken} )
519519 push! (stream. states, parse_flow_sequence_entry_mapping_value)
520520 parse_flow_node (stream)
521521 else
527527
528528function parse_flow_sequence_entry_mapping_value (stream:: EventStream )
529529 token = peek (stream. input)
530- if typeof ( token) == ValueToken
530+ if token isa ValueToken
531531 forward! (stream. input)
532- if ! in ( typeof ( peek (stream. input)), [ FlowEntryToken, FlowSequenceEndToken] )
532+ if ! ( peek (stream. input) isa Union{ FlowEntryToken, FlowSequenceEndToken} )
533533 push! (stream. states, parse_flow_sequence_entry_mapping_end)
534534 parse_flow_node (stream)
535535 else
559559
560560function parse_flow_mapping_key (stream:: EventStream , first_entry= false )
561561 token = peek (stream. input)
562- if typeof (token) != FlowMappingEndToken
562+ if ! (token isa FlowMappingEndToken)
563563 if ! first_entry
564- if typeof ( token) == FlowEntryToken
564+ if token isa FlowEntryToken
565565 forward! (stream. input)
566566 else
567567 throw (ParserError (" while parsing a flow mapping" ,
@@ -572,16 +572,16 @@ function parse_flow_mapping_key(stream::EventStream, first_entry=false)
572572 end
573573
574574 token = peek (stream. input)
575- if typeof ( token) == KeyToken
575+ if token isa KeyToken
576576 forward! (stream. input)
577- if ! in ( typeof ( peek (stream. input)), [ ValueToken, FlowEntryToken, FlowMappingEndToken] )
577+ if ! ( peek (stream. input) isa Union{ ValueToken, FlowEntryToken, FlowMappingEndToken} )
578578 push! (stream. states, parse_flow_mapping_value)
579579 return parse_flow_node (stream)
580580 else
581581 stream. state = parse_flow_mapping_value
582582 return process_empty_scalar (stream, token. span. end_mark)
583583 end
584- elseif typeof (token) != FlowMappingEndToken
584+ elseif ! (token isa FlowMappingEndToken)
585585 push! (stream. states, parse_flow_mapping_empty_value)
586586 return parse_flow_node (stream)
587587 end
596596
597597function parse_flow_mapping_value (stream:: EventStream )
598598 token = peek (stream. input)
599- if typeof ( token) == ValueToken
599+ if token isa ValueToken
600600 forward! (stream. input)
601- if ! in ( typeof ( peek (stream. input)), [ FlowEntryToken, FlowMappingEndToken] )
601+ if ! ( peek (stream. input) isa Union{ FlowEntryToken, FlowMappingEndToken} )
602602 push! (stream. states, parse_flow_mapping_key)
603603 parse_flow_node (stream)
604604 else
0 commit comments