Top Description Inners Fields Constructors Methods
org.yaml.snakeyaml.parser

public Class ParserImpl

extends Object
implements Parser
Class Inheritance
All Implemented Interfaces
org.yaml.snakeyaml.parser.Parser
Imports
java.util.HashMap, .LinkedList, .List, .Map, org.yaml.snakeyaml.DumperOptions, .DumperOptions.Version, .LoaderOptions, org.yaml.snakeyaml.comments.CommentType, org.yaml.snakeyaml.error.Mark, .YAMLException, org.yaml.snakeyaml.events.AliasEvent, .CommentEvent, .DocumentEndEvent, .DocumentStartEvent, .Event, .ImplicitTuple, .MappingEndEvent, .MappingStartEvent, .ScalarEvent, .SequenceEndEvent, .SequenceStartEvent, .StreamEndEvent, .StreamStartEvent, org.yaml.snakeyaml.nodes.Tag, org.yaml.snakeyaml.reader.StreamReader, org.yaml.snakeyaml.scanner.Scanner, .ScannerImpl, org.yaml.snakeyaml.tokens.AliasToken, .AnchorToken, .BlockEntryToken, .CommentToken, .DirectiveToken, .ScalarToken, .StreamEndToken, .StreamStartToken, .TagToken, .TagTuple, .Token, org.yaml.snakeyaml.util.ArrayStack

# The following YAML grammar is LL(1) and is parsed by a recursive descent
parser.
stream            ::= STREAM-START implicit_document? explicit_document* STREAM-END
implicit_document ::= block_node DOCUMENT-END*
explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END*
block_node_or_indentless_sequence ::=
                      ALIAS
                      | properties (block_content | indentless_block_sequence)?
                      | block_content
                      | indentless_block_sequence
block_node        ::= ALIAS
                      | properties block_content?
                      | block_content
flow_node         ::= ALIAS
                      | properties flow_content?
                      | flow_content
properties        ::= TAG ANCHOR? | ANCHOR TAG?
block_content     ::= block_collection | flow_collection | SCALAR
flow_content      ::= flow_collection | SCALAR
block_collection  ::= block_sequence | block_mapping
flow_collection   ::= flow_sequence | flow_mapping
block_sequence    ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END
indentless_sequence   ::= (BLOCK-ENTRY block_node?)+
block_mapping     ::= BLOCK-MAPPING_START
                      ((KEY block_node_or_indentless_sequence?)?
                      (VALUE block_node_or_indentless_sequence?)?)*
                      BLOCK-END
flow_sequence     ::= FLOW-SEQUENCE-START
                      (flow_sequence_entry FLOW-ENTRY)*
                      flow_sequence_entry?
                      FLOW-SEQUENCE-END
flow_sequence_entry   ::= flow_node | KEY flow_node? (VALUE flow_node?)?
flow_mapping      ::= FLOW-MAPPING-START
                      (flow_mapping_entry FLOW-ENTRY)*
                      flow_mapping_entry?
                      FLOW-MAPPING-END
flow_mapping_entry    ::= flow_node | KEY flow_node? (VALUE flow_node?)?
FIRST sets:
stream: { STREAM-START }
explicit_document: { DIRECTIVE DOCUMENT-START }
implicit_document: FIRST(block_node)
block_node: { ALIAS TAG ANCHOR SCALAR BLOCK-SEQUENCE-START BLOCK-MAPPING-START FLOW-SEQUENCE-START FLOW-MAPPING-START }
flow_node: { ALIAS ANCHOR TAG SCALAR FLOW-SEQUENCE-START FLOW-MAPPING-START }
block_content: { BLOCK-SEQUENCE-START BLOCK-MAPPING-START FLOW-SEQUENCE-START FLOW-MAPPING-START SCALAR }
flow_content: { FLOW-SEQUENCE-START FLOW-MAPPING-START SCALAR }
block_collection: { BLOCK-SEQUENCE-START BLOCK-MAPPING-START }
flow_collection: { FLOW-SEQUENCE-START FLOW-MAPPING-START }
block_sequence: { BLOCK-SEQUENCE-START }
block_mapping: { BLOCK-MAPPING-START }
block_node_or_indentless_sequence: { ALIAS ANCHOR TAG SCALAR BLOCK-SEQUENCE-START BLOCK-MAPPING-START FLOW-SEQUENCE-START FLOW-MAPPING-START BLOCK-ENTRY }
indentless_sequence: { ENTRY }
flow_collection: { FLOW-SEQUENCE-START FLOW-MAPPING-START }
flow_sequence: { FLOW-SEQUENCE-START }
flow_mapping: { FLOW-MAPPING-START }
flow_sequence_entry: { ALIAS ANCHOR TAG SCALAR FLOW-SEQUENCE-START FLOW-MAPPING-START KEY }
flow_mapping_entry: { ALIAS ANCHOR TAG SCALAR FLOW-SEQUENCE-START FLOW-MAPPING-START KEY }
Since writing a recursive-descendant parser is a straightforward task, we do not give many comments here.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private class
private class
private class
private class
private class
ParserImpl.ParseBlockNode

 block_node_or_indentless_sequence ::= ALIAS
               | properties (block_content | indentless_block_sequence)?
private class
private class
private class
private class
private class
private class
private class
private class
private class
ParserImpl.ParseFlowMappingFirstKey

  flow_mapping  ::= FLOW-MAPPING-START
         (flow_mapping_entry FLOW-ENTRY)*
         flow_mapping_entry?
private class
private class
private class
private class
private class
private class
private class
ParserImpl.ParseFlowSequenceFirstEntry

flow_sequence     ::= FLOW-SEQUENCE-START
                      (flow_sequence_entry FLOW-ENTRY)*
                      flow_sequence_entry?
private class
private class
private class
private class
ParserImpl.ParseStreamStart

stream    ::= STREAM-START implicit_document?

Field Summary

Modifier and TypeField and Description
private Event
private static final Map<String, String>
private VersionTagsTuple
private final ArrayStack<Mark>
protected final Scanner
private Production
private final ArrayStack<Production>

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public boolean
checkEvent(Event.ID
Event ID.
choice
)

Implements org.yaml.snakeyaml.parser.Parser.checkEvent.

Check the type of the next event.
public Event
getEvent()

Implements org.yaml.snakeyaml.parser.Parser.getEvent.

Get the next event and proceed further.
private Event
private Event
private Event
parseNode(boolean block, boolean indentlessSequence)

public Event
peekEvent()

Implements org.yaml.snakeyaml.parser.Parser.peekEvent.

Peek the next event (keeping it in the stream)
private VersionTagsTuple

Returns:

directives to be applied for the current document
processDirectives
()

https://yaml.org/spec/1.1/#id898785 says "If the document specifies no directives, it is parsed using the same settings as the previous document.

private Event
processEmptyScalar(Mark mark)

block_mapping     ::= BLOCK-MAPPING_START
          ((KEY block_node_or_indentless_sequence?)?
private CommentEvent
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait