# 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.
| Modifier and Type | Class and Description |
|---|---|
| private class | |
| private class | |
| private class | |
| private class | |
| private class | |
| private class | ParserImpl.
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.
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.
flow_sequence ::= FLOW-SEQUENCE-START
(flow_sequence_entry FLOW-ENTRY)*
flow_sequence_entry?
|
| private class | |
| private class | |
| private class | |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private Optional | |
| private static final Map | |
| private Map | |
| private final ArrayStack | |
| protected final Scanner | scanner
tokeniser |
| private final LoadSettings | |
| private Optional | |
| private final ArrayStack |
| Access | Constructor and Description |
|---|---|
| public | ParserImpl(StreamReader
- the input reader, LoadSettings - the configuration options settings)
Deprecated
use the other constructor with LoadSettings first
|
| public | |
| public | ParserImpl(Scanner
- input scanner, LoadSettings - configuration options settings)
Deprecated
use the other constructor with LoadSettings first
|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | checkEvent(Event.
Implements org. Check the ID of the next event. |
| public boolean | Returns: true if there is another eventImplements java. Produce the event if not yet present. |
| private Optional | |
| private void | |
| public Event | next()
Implements org. Consume the event (get the next event and removed it). |
| private Event | |
| private Event | |
| private Event | |
| public Event | peekEvent()
Implements org. Get the next event (and keep it). |
| private VersionTagsTuple | |
| private Event | processEmptyScalar(Optional<Mark> mark)
block_mapping ::= BLOCK-MAPPING_START
((KEY block_node_or_indentless_sequence?)?
|
| private void | |
| private CommentEvent |