Current section
Files
Jump to
Current section
Files
src/taffy@parser@explicit.erl
-module(taffy@parser@explicit).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/taffy/parser/explicit.gleam").
-export([parse_explicit_mapping/3, parse_explicit_key_value/3]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(false).
-file("src/taffy/parser/explicit.gleam", 273).
?DOC(false).
-spec collect_explicit_key_multiline(
taffy@parser@types:parser(),
binary(),
integer()
) -> {binary(), taffy@parser@types:parser()}.
collect_explicit_key_multiline(Parser, Acc, Min_indent) ->
case taffy@parser@helpers:current(Parser) of
{some, {plain, S}} ->
collect_explicit_key_multiline(
taffy@parser@helpers:advance(Parser),
<<<<Acc/binary, " "/utf8>>/binary, S/binary>>,
Min_indent
);
{some, newline} ->
After_newline = taffy@parser@helpers:advance(Parser),
case taffy@parser@helpers:current(After_newline) of
{some, {indent, N}} when N > Min_indent ->
After_indent = taffy@parser@helpers:advance(After_newline),
case taffy@parser@helpers:current(After_indent) of
{some, colon} ->
{Acc, After_newline};
{some, question} ->
{Acc, After_newline};
{some, {plain, S@1}} ->
collect_explicit_key_multiline(
taffy@parser@helpers:advance(After_indent),
<<<<Acc/binary, " "/utf8>>/binary, S@1/binary>>,
Min_indent
);
_ ->
{Acc, After_newline}
end;
_ ->
{Acc, Parser}
end;
{some, {indent, N@1}} when N@1 > Min_indent ->
After_indent@1 = taffy@parser@helpers:advance(Parser),
case taffy@parser@helpers:current(After_indent@1) of
{some, colon} ->
{Acc, Parser};
{some, question} ->
{Acc, Parser};
{some, {plain, S@2}} ->
collect_explicit_key_multiline(
taffy@parser@helpers:advance(After_indent@1),
<<<<Acc/binary, " "/utf8>>/binary, S@2/binary>>,
Min_indent
);
_ ->
{Acc, Parser}
end;
{some, colon} ->
{Acc, Parser};
{some, question} ->
{Acc, Parser};
{some, {comment, _}} ->
{Acc, Parser};
_ ->
{Acc, Parser}
end.
-file("src/taffy/parser/explicit.gleam", 405).
?DOC(false).
-spec parse_possible_inline_mapping(
taffy@parser@types:parser(),
binary(),
integer()
) -> {ok, {binary(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()}.
parse_possible_inline_mapping(Parser, Key, Min_indent) ->
case taffy@parser@helpers:current(Parser) of
{some, {plain, V}} ->
Parser@1 = taffy@parser@helpers:skip_newlines_and_comments(
taffy@parser@helpers:advance(Parser)
),
Key_str = <<<<<<<<"{"/utf8, Key/binary>>/binary, ": "/utf8>>/binary,
V/binary>>/binary,
"}"/utf8>>,
{ok, {Key_str, Parser@1}};
{some, {single_quoted, V@1}} ->
Key_str@1 = <<<<<<<<"{"/utf8, Key/binary>>/binary, ": "/utf8>>/binary,
V@1/binary>>/binary,
"}"/utf8>>,
{ok, {Key_str@1, taffy@parser@helpers:advance(Parser)}};
{some, {double_quoted, V@1}} ->
Key_str@1 = <<<<<<<<"{"/utf8, Key/binary>>/binary, ": "/utf8>>/binary,
V@1/binary>>/binary,
"}"/utf8>>,
{ok, {Key_str@1, taffy@parser@helpers:advance(Parser)}};
_ ->
{Full_key, Parser@2} = collect_explicit_key_multiline(
Parser,
Key,
Min_indent
),
{ok, {Full_key, Parser@2}}
end.
-file("src/taffy/parser/explicit.gleam", 388).
?DOC(false).
-spec parse_explicit_plain_key(
taffy@parser@types:parser(),
binary(),
integer(),
fun((taffy@parser@types:parser(), integer()) -> {ok,
{taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()})
) -> {ok, {binary(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()}.
parse_explicit_plain_key(Parser, S, Min_indent, _) ->
case taffy@parser@helpers:current(Parser) of
{some, colon} ->
parse_possible_inline_mapping(
taffy@parser@helpers:advance(Parser),
S,
Min_indent
);
_ ->
{Full_key, Parser@1} = collect_explicit_key_multiline(
Parser,
S,
Min_indent
),
{ok, {Full_key, Parser@1}}
end.
-file("src/taffy/parser/explicit.gleam", 500).
?DOC(false).
-spec parse_explicit_value_after_newline(
taffy@parser@types:parser(),
fun((taffy@parser@types:parser(), integer()) -> {ok,
{taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()})
) -> {ok, {taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()}.
parse_explicit_value_after_newline(Parser, Parse_value_fn) ->
case taffy@parser@helpers:current(Parser) of
{some, dash} ->
taffy@parser@block:parse_block_sequence_at(
Parser,
0,
{some, 0},
Parse_value_fn
);
{some, {indent, N}} ->
After_indent = taffy@parser@helpers:advance(Parser),
case taffy@parser@helpers:current(After_indent) of
{some, dash} ->
Parser@1 = taffy@parser@helpers:backtrack(After_indent),
taffy@parser@block:parse_block_sequence_at(
Parser@1,
N,
{some, N},
Parse_value_fn
);
_ ->
Parser@2 = taffy@parser@helpers:backtrack(After_indent),
Parse_value_fn(Parser@2, N)
end;
_ ->
{ok, {null, Parser}}
end.
-file("src/taffy/parser/explicit.gleam", 488).
?DOC(false).
-spec parse_explicit_value(
taffy@parser@types:parser(),
integer(),
fun((taffy@parser@types:parser(), integer()) -> {ok,
{taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()})
) -> {ok, {taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()}.
parse_explicit_value(Parser, Min_indent, Parse_value_fn) ->
case taffy@parser@helpers:current(Parser) of
{some, newline} ->
parse_explicit_value_after_newline(
taffy@parser@helpers:advance(Parser),
Parse_value_fn
);
_ ->
Parse_value_fn(Parser, Min_indent + 1)
end.
-file("src/taffy/parser/explicit.gleam", 71).
?DOC(false).
-spec parse_after_explicit_key(
binary(),
taffy@parser@types:parser(),
integer(),
list({binary(), taffy@value:yaml_value()}),
fun((taffy@parser@types:parser(), integer()) -> {ok,
{taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()})
) -> {ok, {taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()}.
parse_after_explicit_key(Key, Parser, Min_indent, Acc, Parse_value_fn) ->
Parser@1 = taffy@parser@helpers:skip_newlines_and_comments(Parser),
case taffy@parser@helpers:current(Parser@1) of
{some, colon} ->
Parser@2 = taffy@parser@helpers:advance(Parser@1),
gleam@result:'try'(
parse_explicit_value(Parser@2, Min_indent, Parse_value_fn),
fun(_use0) ->
{Val, Parser@3} = _use0,
Acc@1 = [{Key, Val} | Acc],
parse_explicit_mapping_items(
Parser@3,
Min_indent,
Acc@1,
Parse_value_fn
)
end
);
{some, {indent, N}} ->
parse_after_explicit_key_indent(
Key,
taffy@parser@helpers:advance(Parser@1),
N,
Min_indent,
Acc,
Parse_value_fn
);
{some, question} ->
Acc@2 = [{Key, null} | Acc],
parse_explicit_mapping_items(
Parser@1,
Min_indent,
Acc@2,
Parse_value_fn
);
_ ->
Acc@3 = [{Key, null} | Acc],
parse_explicit_mapping_items(
Parser@1,
Min_indent,
Acc@3,
Parse_value_fn
)
end.
-file("src/taffy/parser/explicit.gleam", 110).
?DOC(false).
-spec parse_after_explicit_key_indent(
binary(),
taffy@parser@types:parser(),
integer(),
integer(),
list({binary(), taffy@value:yaml_value()}),
fun((taffy@parser@types:parser(), integer()) -> {ok,
{taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()})
) -> {ok, {taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()}.
parse_after_explicit_key_indent(Key, Parser, N, Min_indent, Acc, Parse_value_fn) ->
case taffy@parser@helpers:current(Parser) of
{some, colon} ->
Parser@1 = taffy@parser@helpers:advance(Parser),
gleam@result:'try'(
Parse_value_fn(Parser@1, N + 1),
fun(_use0) ->
{Val, Parser@2} = _use0,
Acc@1 = [{Key, Val} | Acc],
parse_explicit_mapping_items(
Parser@2,
Min_indent,
Acc@1,
Parse_value_fn
)
end
);
{some, question} ->
Acc@2 = [{Key, null} | Acc],
parse_explicit_mapping_items_at_indent(
Parser,
Min_indent,
N,
Acc@2,
Parse_value_fn
);
{some, {plain, S}} ->
Acc@3 = [{Key, null} | Acc],
try_implicit_key(
S,
taffy@parser@helpers:advance(Parser),
Min_indent,
N + 1,
Acc@3,
Parse_value_fn
);
_ ->
Acc@4 = [{Key, null} | Acc],
parse_explicit_mapping_items(
Parser,
Min_indent,
Acc@4,
Parse_value_fn
)
end.
-file("src/taffy/parser/explicit.gleam", 188).
?DOC(false).
-spec parse_explicit_mapping_items_at_indent(
taffy@parser@types:parser(),
integer(),
integer(),
list({binary(), taffy@value:yaml_value()}),
fun((taffy@parser@types:parser(), integer()) -> {ok,
{taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()})
) -> {ok, {taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()}.
parse_explicit_mapping_items_at_indent(
Parser,
Min_indent,
N,
Acc,
Parse_value_fn
) ->
Parser@1 = taffy@parser@helpers:advance(Parser),
case taffy@parser@helpers:current(Parser@1) of
{some, question} ->
Parser@2 = taffy@parser@helpers:advance(Parser@1),
gleam@result:'try'(
parse_explicit_key_value(Parser@2, N, Parse_value_fn),
fun(_use0) ->
{Key, Parser@3} = _use0,
parse_after_explicit_key_at_indent(
Key,
Parser@3,
Min_indent,
N,
Acc,
Parse_value_fn
)
end
);
{some, {plain, S}} ->
try_implicit_key(
S,
taffy@parser@helpers:advance(Parser@1),
Min_indent,
N + 1,
Acc,
Parse_value_fn
);
{some, {single_quoted, S@1}} ->
try_implicit_key(
S@1,
taffy@parser@helpers:advance(Parser@1),
Min_indent,
N + 1,
Acc,
Parse_value_fn
);
{some, {double_quoted, S@1}} ->
try_implicit_key(
S@1,
taffy@parser@helpers:advance(Parser@1),
Min_indent,
N + 1,
Acc,
Parse_value_fn
);
_ ->
{ok, {{mapping, lists:reverse(Acc)}, Parser@1}}
end.
-file("src/taffy/parser/explicit.gleam", 153).
?DOC(false).
-spec try_implicit_key(
binary(),
taffy@parser@types:parser(),
integer(),
integer(),
list({binary(), taffy@value:yaml_value()}),
fun((taffy@parser@types:parser(), integer()) -> {ok,
{taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()})
) -> {ok, {taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()}.
try_implicit_key(Key, Parser, Min_indent, Value_indent, Acc, Parse_value_fn) ->
case taffy@parser@helpers:current(Parser) of
{some, colon} ->
parse_key_value_pair(
Key,
taffy@parser@helpers:advance(Parser),
Min_indent,
Value_indent,
Acc,
Parse_value_fn
);
_ ->
{ok, {{mapping, lists:reverse(Acc)}, Parser}}
end.
-file("src/taffy/parser/explicit.gleam", 175).
?DOC(false).
-spec parse_key_value_pair(
binary(),
taffy@parser@types:parser(),
integer(),
integer(),
list({binary(), taffy@value:yaml_value()}),
fun((taffy@parser@types:parser(), integer()) -> {ok,
{taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()})
) -> {ok, {taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()}.
parse_key_value_pair(Key, Parser, Min_indent, Value_indent, Acc, Parse_value_fn) ->
gleam@result:'try'(
Parse_value_fn(Parser, Value_indent),
fun(_use0) ->
{Val, Parser@1} = _use0,
Acc@1 = [{Key, Val} | Acc],
parse_explicit_mapping_items(
Parser@1,
Min_indent,
Acc@1,
Parse_value_fn
)
end
).
-file("src/taffy/parser/explicit.gleam", 27).
?DOC(false).
-spec parse_explicit_mapping_items(
taffy@parser@types:parser(),
integer(),
list({binary(), taffy@value:yaml_value()}),
fun((taffy@parser@types:parser(), integer()) -> {ok,
{taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()})
) -> {ok, {taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()}.
parse_explicit_mapping_items(Parser, Min_indent, Acc, Parse_value_fn) ->
Parser@1 = taffy@parser@helpers:skip_newlines_and_comments(Parser),
case taffy@parser@helpers:current(Parser@1) of
{some, question} ->
Parser@2 = taffy@parser@helpers:advance(Parser@1),
gleam@result:'try'(
parse_explicit_key_value(Parser@2, Min_indent, Parse_value_fn),
fun(_use0) ->
{Key, Parser@3} = _use0,
parse_after_explicit_key(
Key,
Parser@3,
Min_indent,
Acc,
Parse_value_fn
)
end
);
{some, {indent, N}} when N >= Min_indent ->
parse_explicit_mapping_items_at_indent(
Parser@1,
Min_indent,
N,
Acc,
Parse_value_fn
);
{some, {plain, S}} when Min_indent =:= 0 ->
try_implicit_key(
S,
taffy@parser@helpers:advance(Parser@1),
Min_indent,
1,
Acc,
Parse_value_fn
);
{some, {single_quoted, S}} when Min_indent =:= 0 ->
try_implicit_key(
S,
taffy@parser@helpers:advance(Parser@1),
Min_indent,
1,
Acc,
Parse_value_fn
);
{some, {double_quoted, S}} when Min_indent =:= 0 ->
try_implicit_key(
S,
taffy@parser@helpers:advance(Parser@1),
Min_indent,
1,
Acc,
Parse_value_fn
);
{some, colon} when Min_indent =:= 0 ->
parse_key_value_pair(
<<""/utf8>>,
taffy@parser@helpers:advance(Parser@1),
Min_indent,
1,
Acc,
Parse_value_fn
);
_ ->
{ok, {{mapping, lists:reverse(Acc)}, Parser@1}}
end.
-file("src/taffy/parser/explicit.gleam", 19).
?DOC(false).
-spec parse_explicit_mapping(
taffy@parser@types:parser(),
integer(),
fun((taffy@parser@types:parser(), integer()) -> {ok,
{taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()})
) -> {ok, {taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()}.
parse_explicit_mapping(Parser, Min_indent, Parse_value_fn) ->
parse_explicit_mapping_items(Parser, Min_indent, [], Parse_value_fn).
-file("src/taffy/parser/explicit.gleam", 235).
?DOC(false).
-spec parse_after_explicit_key_at_indent(
binary(),
taffy@parser@types:parser(),
integer(),
integer(),
list({binary(), taffy@value:yaml_value()}),
fun((taffy@parser@types:parser(), integer()) -> {ok,
{taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()})
) -> {ok, {taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()}.
parse_after_explicit_key_at_indent(
Key,
Parser,
Min_indent,
N,
Acc,
Parse_value_fn
) ->
Parser@1 = taffy@parser@helpers:skip_newlines_and_comments(Parser),
case taffy@parser@helpers:current(Parser@1) of
{some, colon} ->
Parser@2 = taffy@parser@helpers:advance(Parser@1),
gleam@result:'try'(
Parse_value_fn(Parser@2, N + 1),
fun(_use0) ->
{Val, Parser@3} = _use0,
Acc@1 = [{Key, Val} | Acc],
parse_explicit_mapping_items(
Parser@3,
Min_indent,
Acc@1,
Parse_value_fn
)
end
);
{some, {indent, I}} ->
Parser@4 = taffy@parser@helpers:advance(Parser@1),
case taffy@parser@helpers:current(Parser@4) of
{some, colon} ->
Parser@5 = taffy@parser@helpers:advance(Parser@4),
gleam@result:'try'(
Parse_value_fn(Parser@5, I + 1),
fun(_use0@1) ->
{Val@1, Parser@6} = _use0@1,
Acc@2 = [{Key, Val@1} | Acc],
parse_explicit_mapping_items(
Parser@6,
Min_indent,
Acc@2,
Parse_value_fn
)
end
);
_ ->
Acc@3 = [{Key, null} | Acc],
parse_explicit_mapping_items(
Parser@4,
Min_indent,
Acc@3,
Parse_value_fn
)
end;
_ ->
Acc@4 = [{Key, null} | Acc],
parse_explicit_mapping_items(
Parser@1,
Min_indent,
Acc@4,
Parse_value_fn
)
end.
-file("src/taffy/parser/explicit.gleam", 428).
?DOC(false).
-spec parse_anchored_key(
taffy@parser@types:parser(),
binary(),
integer(),
fun((taffy@parser@types:parser(), integer()) -> {ok,
{taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()})
) -> {ok, {binary(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()}.
parse_anchored_key(Parser, Name, Min_indent, Parse_value_fn) ->
Parser@1 = taffy@parser@helpers:advance(Parser),
gleam@result:'try'(
parse_explicit_key_value(Parser@1, Min_indent, Parse_value_fn),
fun(_use0) ->
{Key, Parser@2} = _use0,
Parser@3 = taffy@parser@types:register_anchor(
Parser@2,
Name,
{string, Key}
),
{ok, {Key, Parser@3}}
end
).
-file("src/taffy/parser/explicit.gleam", 325).
?DOC(false).
-spec parse_explicit_key_value(
taffy@parser@types:parser(),
integer(),
fun((taffy@parser@types:parser(), integer()) -> {ok,
{taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()})
) -> {ok, {binary(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()}.
parse_explicit_key_value(Parser, Min_indent, Parse_value_fn) ->
case taffy@parser@helpers:current(Parser) of
{some, {plain, S}} ->
parse_explicit_plain_key(
taffy@parser@helpers:advance(Parser),
S,
Min_indent,
Parse_value_fn
);
{some, {single_quoted, S@1}} ->
{ok, {S@1, taffy@parser@helpers:advance(Parser)}};
{some, {double_quoted, S@1}} ->
{ok, {S@1, taffy@parser@helpers:advance(Parser)}};
{some, {literal, S@2}} ->
{ok, {S@2, taffy@parser@helpers:advance(Parser)}};
{some, {folded, S@2}} ->
{ok, {S@2, taffy@parser@helpers:advance(Parser)}};
{some, dash} ->
gleam@result:'try'(
taffy@parser@block:parse_block_sequence_at(
Parser,
Min_indent,
none,
Parse_value_fn
),
fun(_use0) ->
{Seq_val, Parser@1} = _use0,
{ok,
{taffy@parser@scalar:value_to_key_string(Seq_val),
Parser@1}}
end
);
{some, bracket_open} ->
gleam@result:'try'(
taffy@parser@flow:parse_flow_sequence(
taffy@parser@helpers:advance(Parser)
),
fun(_use0@1) ->
{Val, Parser@2} = _use0@1,
{ok,
{taffy@parser@scalar:value_to_key_string(Val), Parser@2}}
end
);
{some, brace_open} ->
gleam@result:'try'(
taffy@parser@flow:parse_flow_mapping(
taffy@parser@helpers:advance(Parser)
),
fun(_use0@2) ->
{Val@1, Parser@3} = _use0@2,
{ok,
{taffy@parser@scalar:value_to_key_string(Val@1),
Parser@3}}
end
);
{some, {anchor, Name}} ->
parse_anchored_key(Parser, Name, Min_indent, Parse_value_fn);
{some, {alias, Name@1}} ->
Parser@4 = taffy@parser@helpers:advance(Parser),
case taffy@parser@types:resolve_alias(Parser@4, Name@1) of
{ok, {Val@2, Parser@5}} ->
{ok,
{taffy@parser@scalar:value_to_key_string(Val@2),
Parser@5}};
{error, <<"budget exceeded"/utf8>>} ->
{error,
{parse_error,
<<"Alias expansion budget exceeded (possible alias-bomb)"/utf8>>,
erlang:element(4, Parser@4)}};
{error, _} ->
{error,
{parse_error,
<<"Unknown anchor: "/utf8, Name@1/binary>>,
erlang:element(4, Parser@4)}}
end;
{some, {tag, _}} ->
parse_explicit_key_value(
taffy@parser@helpers:advance(Parser),
Min_indent,
Parse_value_fn
);
{some, newline} ->
parse_key_after_newline(
taffy@parser@helpers:advance(Parser),
Min_indent,
Parse_value_fn
);
{some, {indent, N}} ->
parse_key_after_indent_token(Parser, N, Min_indent, Parse_value_fn);
{some, colon} ->
{ok, {<<""/utf8>>, Parser}};
none ->
{ok, {<<""/utf8>>, Parser}};
{some, eof} ->
{ok, {<<""/utf8>>, Parser}};
{some, {comment, _}} ->
parse_explicit_key_value(
taffy@parser@helpers:advance(Parser),
Min_indent,
Parse_value_fn
);
{some, Token} ->
{error,
{parse_error,
<<"Expected explicit key value, got "/utf8,
(taffy@parser@helpers:token_for_error(Token))/binary>>,
erlang:element(4, Parser)}}
end.
-file("src/taffy/parser/explicit.gleam", 465).
?DOC(false).
-spec parse_key_after_indent_token(
taffy@parser@types:parser(),
integer(),
integer(),
fun((taffy@parser@types:parser(), integer()) -> {ok,
{taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()})
) -> {ok, {binary(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()}.
parse_key_after_indent_token(Parser, N, Min_indent, Parse_value_fn) ->
After_indent = taffy@parser@helpers:advance(Parser),
case taffy@parser@helpers:current(After_indent) of
{some, dash} ->
Parser@1 = taffy@parser@helpers:backtrack(After_indent),
gleam@result:'try'(
taffy@parser@block:parse_block_sequence_at(
Parser@1,
N,
{some, N},
Parse_value_fn
),
fun(_use0) ->
{Seq_val, Parser@2} = _use0,
{ok,
{taffy@parser@scalar:value_to_key_string(Seq_val),
Parser@2}}
end
);
{some, colon} ->
{ok, {<<""/utf8>>, Parser}};
_ ->
parse_explicit_key_value(After_indent, Min_indent, Parse_value_fn)
end.
-file("src/taffy/parser/explicit.gleam", 444).
?DOC(false).
-spec parse_key_after_newline(
taffy@parser@types:parser(),
integer(),
fun((taffy@parser@types:parser(), integer()) -> {ok,
{taffy@value:yaml_value(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()})
) -> {ok, {binary(), taffy@parser@types:parser()}} |
{error, taffy@parser@types:parse_error()}.
parse_key_after_newline(Parser, Min_indent, Parse_value_fn) ->
case taffy@parser@helpers:current(Parser) of
{some, dash} ->
gleam@result:'try'(
taffy@parser@block:parse_block_sequence(
Parser,
0,
Parse_value_fn
),
fun(_use0) ->
{Seq_val, Parser@1} = _use0,
{ok,
{taffy@parser@scalar:value_to_key_string(Seq_val),
Parser@1}}
end
);
{some, {indent, N}} ->
parse_key_after_indent_token(Parser, N, Min_indent, Parse_value_fn);
{some, colon} ->
{ok, {<<""/utf8>>, Parser}};
_ ->
{ok, {<<""/utf8>>, Parser}}
end.