Pop indentation levels from the indents stack until the current level becomes less or equal to the column. For each indentation level, append the BLOCK-END token.
(parser *yaml_parser_t, column int, scan_mark yaml_mark_t)
| 1027 | // becomes less or equal to the column. For each indentation level, append |
| 1028 | // the BLOCK-END token. |
| 1029 | func yaml_parser_unroll_indent(parser *yaml_parser_t, column int, scan_mark yaml_mark_t) bool { |
| 1030 | // In the flow context, do nothing. |
| 1031 | if parser.flow_level > 0 { |
| 1032 | return true |
| 1033 | } |
| 1034 | |
| 1035 | block_mark := scan_mark |
| 1036 | block_mark.index-- |
| 1037 | |
| 1038 | // Loop through the indentation levels in the stack. |
| 1039 | for parser.indent > column { |
| 1040 | |
| 1041 | // [Go] Reposition the end token before potential following |
| 1042 | // foot comments of parent blocks. For that, search |
| 1043 | // backwards for recent comments that were at the same |
| 1044 | // indent as the block that is ending now. |
| 1045 | stop_index := block_mark.index |
| 1046 | for i := len(parser.comments) - 1; i >= 0; i-- { |
| 1047 | comment := &parser.comments[i] |
| 1048 | |
| 1049 | if comment.end_mark.index < stop_index { |
| 1050 | // Don't go back beyond the start of the comment/whitespace scan, unless column < 0. |
| 1051 | // If requested indent column is < 0, then the document is over and everything else |
| 1052 | // is a foot anyway. |
| 1053 | break |
| 1054 | } |
| 1055 | if comment.start_mark.column == parser.indent+1 { |
| 1056 | // This is a good match. But maybe there's a former comment |
| 1057 | // at that same indent level, so keep searching. |
| 1058 | block_mark = comment.start_mark |
| 1059 | } |
| 1060 | |
| 1061 | // While the end of the former comment matches with |
| 1062 | // the start of the following one, we know there's |
| 1063 | // nothing in between and scanning is still safe. |
| 1064 | stop_index = comment.scan_mark.index |
| 1065 | } |
| 1066 | |
| 1067 | // Create a token and append it to the queue. |
| 1068 | token := yaml_token_t{ |
| 1069 | typ: yaml_BLOCK_END_TOKEN, |
| 1070 | start_mark: block_mark, |
| 1071 | end_mark: block_mark, |
| 1072 | } |
| 1073 | yaml_insert_token(parser, -1, &token) |
| 1074 | |
| 1075 | // Pop the indentation level. |
| 1076 | parser.indent = parser.indents[len(parser.indents)-1] |
| 1077 | parser.indents = parser.indents[:len(parser.indents)-1] |
| 1078 | } |
| 1079 | return true |
| 1080 | } |
| 1081 | |
| 1082 | // Initialize the scanner and produce the STREAM-START token. |
| 1083 | func yaml_parser_fetch_stream_start(parser *yaml_parser_t) bool { |
no test coverage detected