~/bend-docscommunity

src/yaml.bend checks

raw source on the hub · import bend-kube-runtime@0.5.3.0/src/yaml.bend as Yaml

2 imports
import Base
import ./json.bend as J

Types

type Line source · line 19 · raw

Data

type YFrame source · line 25 · raw

Data

An open container: a mapping (members reversed, and the key whose value is still to come) or a sequence (items reversed, and, after a bare "- ", the anchor of the item whose block is still to come).

type Flow source · line 32 · raw

Data

mode: 0 between tokens, 1 in "..", 2 in '..', 3 in a plain scalar; buf: the plain scalar so far (reversed); out: JSON text (reversed).

type Blk source · line 39 · raw

Data

A block scalar being read: its key line's indent and text before the indicator, literal (|) or folded (>), chomping (0 clip, 1 strip -, 2 keep +), the content's indent (0 until its first line), and its lines so far (reversed, the content indent removed).

type BH source · line 42 · raw

Data

type LS source · line 46 · raw

Data

The line fold: lines out (reversed), and the block scalar, if inside one.

type AV source · line 50 · raw

Data

A value with its anchor (&name) split off.

type YR source · line 53 · raw

Data

type Num source · line 292 · raw

Data

Numbers, as YAML 1.2's core schema reads them: [-+]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)([eE][-+]?[0-9]+)?, read a character at a time. The digits so far are kept reversed.

type KR source · line 433 · raw

Data

"key: rest" or "key:": the key (unquoted) and the rest, if this is a mapping entry.

Definitions

def Yaml.indent source · line 59 · raw

@s:String -> @+n:U32 -> U32

def Yaml.quote.go source · line 66 · raw

@+q:U32 -> @+k:U32 -> @none:Bool -> @same:Bool -> U32

def Yaml.quote source · line 76 · raw

@+q:U32 -> @+k:U32 -> U32

Entering or leaving a quote of kind k (1 single, 2 double).

def Yaml.nq source · line 80 · raw

@+c:Char -> @+q:U32 -> U32

The quote state after char c.

def Yaml.cut_at source · line 91 · raw

@s:String -> @+q:U32 -> @prev:Bool -> Bool

Whether a comment starts at the head of s: a '#' after a space, outside quotes.

def Yaml.uncomment source · line 99 · raw

@s:String -> @+q:U32 -> @cut:Bool -> String

Drops a comment, to the end of the line.

def Yaml.keep source · line 108 · raw

@+t:String -> Bool

def Yaml.lines.put.go source · line 111 · raw

@+i:U32 -> @text:String -> @rest:List<&2, Line> -> @keep:Bool -> List<&2, Line>

def Yaml.lines.put source · line 118 · raw

@+i:U32 -> @+text:String -> @rest:List<&2, Line> -> List<&2, Line>

def Yaml.head.go source · line 123 · raw

@r:String -> Maybe<&2, BH>

A block scalar's header ("key: |", "- >-", ...): the text before the indicator, its style and chomping.

def Yaml.head source · line 140 · raw

@t:String -> Maybe<&2, BH>

def Yaml.clean source · line 143 · raw

@+l:String -> String

def Yaml.blanks source · line 147 · raw

@xs:List<&2, String> -> @+n:U32 -> U32

Trailing blank lines (of a reversed list): how many, and the rest.

def Yaml.unblank source · line 154 · raw

@xs:List<&2, String> -> List<&2, String>

def Yaml.fold.sep source · line 161 · raw

@prev:Bool -> String

def Yaml.fold source · line 170 · raw

@xs:List<&2, String> -> @prev:Bool -> String

Folded lines: a line break between two text lines becomes a space; blank lines stay line breaks.

def Yaml.block.body source · line 179 · raw

@lines:List<&2, String> -> @folded:Bool -> String

def Yaml.block.tail.go source · line 186 · raw

@+chomp:U32 -> @+n:U32 -> @strip:Bool -> @keep:Bool -> String

def Yaml.block.tail source · line 195 · raw

@+chomp:U32 -> @+n:U32 -> @empty:Bool -> String

def Yaml.block.line source · line 203 · raw

@b:Blk -> Line

A finished block scalar, as the one line "prefix <JSON string>".

def Yaml.normal.go source · line 210 · raw

@out:List<&2, Line> -> @+i:U32 -> @+t:String -> @h:Maybe<&2, BH> -> LS

def Yaml.normal source · line 218 · raw

@out:List<&2, Line> -> @+raw:String -> LS

An ordinary line: kept if meaningful, or the start of a block scalar.

def Yaml.in_block.go source · line 221 · raw

@out:List<&2, Line> -> @b:Blk -> @+raw:String -> @blank:Bool -> @deeper:Bool -> @first:Bool -> LS

def Yaml.in_block source · line 235 · raw

@out:List<&2, Line> -> @b:Blk -> @+raw:String -> LS

A raw line inside a block scalar: content while deeper than the key (or blank), else the block ends and the line is read as ordinary.

def Yaml.step_line source · line 241 · raw

@st:LS -> @+raw:String -> LS

def Yaml.lines.fold source · line 248 · raw

@ls:List<&2, String> -> @st:LS -> LS

def Yaml.lines.fin source · line 255 · raw

@st:LS -> List<&2, Line>

def Yaml.lines source · line 264 · raw

@s:String -> List<&2, Line>

The meaningful lines: indentation and text, comments and blanks gone, block scalars (| and >) folded into one line each.

def Yaml.unsingle source · line 270 · raw

@s:String -> String

def Yaml.strip_ends source · line 279 · raw

@+s:String -> String

def Yaml.json_or source · line 282 · raw

@r:Result<&2, &2, String, 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json> -> @s:String -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json

def Num.step source · line 303 · raw

@st:Num -> @+c:Char -> @dig:Bool -> @dot:Bool -> @ex:Bool -> @sg:Bool -> Num

def Num.go source · line 354 · raw

@s:String -> @st:Num -> Num

def Num.sign source · line 363 · raw

@neg:Bool -> String

def Num.int source · line 371 · raw

@cs:List<&2, Char> -> String

The integer digits without leading zeros, "0" for none.

def Num.frac source · line 380 · raw

@f:List<&2, Char> -> String

def Num.fin source · line 388 · raw

@st:Num -> Maybe<&2, String>

The number as JSON writes it, or None when s is not one.

def Num.parse source · line 400 · raw

@s:String -> Maybe<&2, String>

def Yaml.plain.num source · line 403 · raw

@x:String -> @n:Maybe<&2, String> -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json

def Yaml.plain source · line 411 · raw

@s:String -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json

A plain scalar: null, ~, true, false, or a string.

def Flow.peek source · line 424 · raw

@s:String -> Char

def Flow.punct source · line 436 · raw

@+c:Char -> Bool

def Flow.out0.go source · line 453 · raw

@+c:Char -> @out:String -> @punct:Bool -> @space:Bool -> Flow

def Flow.out0 source · line 462 · raw

@+c:Char -> @out:String -> Flow

def Flow.dq source · line 471 · raw

@esc:Bool -> @+c:Char -> @out:String -> Flow

def Flow.sq.quote source · line 482 · raw

@out:String -> @doubled:Bool -> Flow

def Flow.sq source · line 489 · raw

@esc:Bool -> @+c:Char -> @+nxt:Char -> @out:String -> Flow

def Flow.closer source · line 502 · raw

@+c:Char -> Bool

def Flow.ends source · line 514 · raw

@+c:Char -> @+nxt:Char -> Bool

A plain scalar ends at a closer, or at ':' before a space or a closer.

def Flow.emit source · line 517 · raw

@buf:String -> @out:String -> String

def Flow.plain.go source · line 520 · raw

@+c:Char -> @buf:String -> @out:String -> @ends:Bool -> Flow

def Flow.plain source · line 527 · raw

@+c:Char -> @+nxt:Char -> @buf:String -> @out:String -> Flow

def Flow.step.go source · line 530 · raw

@+m:U32 -> @b:String -> @o:String -> @e:Bool -> @+c:Char -> @+nxt:Char -> @m0:Bool -> @m1:Bool -> @m2:Bool -> Flow

def Flow.step source · line 542 · raw

@st:Flow -> @+c:Char -> @+nxt:Char -> Flow

def Flow.go source · line 547 · raw

@s:String -> @st:Flow -> Flow

def Flow.fin.go source · line 554 · raw

@b:String -> @o:String -> @plain:Bool -> String

def Flow.fin source · line 561 · raw

@st:Flow -> String

def Yaml.flow source · line 567 · raw

@s:String -> String

A flow value's JSON text.

def Yaml.split_word.go source · line 580 · raw

@s:String -> @acc:String -> AV

def Yaml.split_word source · line 590 · raw

@s:String -> AV

The first word and the rest.

def Yaml.scalar.untagged source · line 593 · raw

@+s:String -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json

def Yaml.tagged source · line 603 · raw

@av:AV -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json

A tagged scalar: !!str keeps the text a string; other tags are dropped.

def Yaml.scalar source · line 611 · raw

@+s:String -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json

A scalar or flow value; an alias (*name) or a tag (!!str x) first.

def Yaml.key.go source · line 628 · raw

@s:String -> @acc:String -> Maybe<&2, KR>

def Yaml.unquote_key source · line 639 · raw

@+k:String -> String

def Yaml.key.fin source · line 648 · raw

@m:Maybe<&2, KR> -> Maybe<&2, KR>

def Yaml.key source · line 655 · raw

@+s:String -> Maybe<&2, KR>

def Yaml.rev_kv source · line 669 · raw

@xs:List<&2, 0x4b19fea9f3c794558ea41a0289840d6a/src/json.KV> -> @acc:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json

def Yaml.rev_items source · line 676 · raw

@xs:List<&2, 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json> -> @acc:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json

def Yaml.pend_null source · line 683 · raw

@p:Maybe<&2, String> -> @ms:List<&2, 0x4b19fea9f3c794558ea41a0289840d6a/src/json.KV> -> List<&2, 0x4b19fea9f3c794558ea41a0289840d6a/src/json.KV>

def Yaml.wrap.go source · line 690 · raw

@a:String -> @v:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @none:Bool -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json

def Yaml.wrap source · line 697 · raw

@+a:String -> @v:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json

def Yaml.value source · line 701 · raw

@f:YFrame -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json

A finished container's value.

def Yaml.ctl source · line 713 · raw

@s:String -> @+n:U32 -> Bool

Whether s starts with the control char of code n.

def Yaml.member.split source · line 720 · raw

@parts:List<&2, String> -> @v:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.KV

def Yaml.member.go source · line 727 · raw

@k:String -> @v:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @marked:Bool -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.KV

def Yaml.member source · line 735 · raw

@+k:String -> @v:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.KV

A pending key's member, its anchor (if marked) wrapped around v.

def Yaml.give source · line 740 · raw

@v:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @st:List<&2, YFrame> -> List<&2, YFrame>

Hands v to the container on top: a mapping's pending key, a sequence's next item, or the document itself.

def Yaml.top_indent source · line 755 · raw

@st:List<&2, YFrame> -> U32

def Yaml.ends source · line 766 · raw

@+st:List<&2, YFrame> -> @+i:U32 -> @dash:Bool -> Bool

Whether the top container ends before a line at indent i: it is deeper, or it is a sequence at i and the line is no item of it.

def Yaml.pop source · line 775 · raw

@st:List<&2, YFrame> -> List<&2, YFrame>

def Yaml.close source · line 782 · raw

@fuel:Nat -> @+st:List<&2, YFrame> -> @+i:U32 -> @+dash:Bool -> @ends:Bool -> List<&2, YFrame>

def Yaml.map_at source · line 789 · raw

@+st:List<&2, YFrame> -> @+i:U32 -> Bool

def Yaml.mark.go source · line 796 · raw

@a:String -> @k:String -> @none:Bool -> String

def Yaml.mark source · line 803 · raw

@+a:String -> @k:String -> String

def Yaml.entry.put.go source · line 806 · raw

@st:List<&2, YFrame> -> @k:String -> @+a:String -> @+r:String -> @empty:Bool -> List<&2, YFrame>

def Yaml.entry.put.av source · line 816 · raw

@st:List<&2, YFrame> -> @k:String -> @av:AV -> List<&2, YFrame>

def Yaml.split_anchor source · line 821 · raw

@+s:String -> AV

def Yaml.entry.put source · line 828 · raw

@st:List<&2, YFrame> -> @k:String -> @+r:String -> @empty:Bool -> List<&2, YFrame>

def Yaml.entry.go source · line 837 · raw

@st:List<&2, YFrame> -> @+i:U32 -> @kr:KR -> @here:Bool -> List<&2, YFrame>

def Yaml.entry source · line 845 · raw

@+st:List<&2, YFrame> -> @+i:U32 -> @kr:KR -> List<&2, YFrame>

A mapping entry at indent i: into the open mapping at i, or a new one.

def Yaml.seq_at source · line 848 · raw

@+st:List<&2, YFrame> -> @+i:U32 -> Bool

def Yaml.item.seq.go source · line 856 · raw

@st:List<&2, YFrame> -> @+i:U32 -> @here:Bool -> List<&2, YFrame>

A new item: an item still waiting for its block got none, so it is null.

def Yaml.item.seq source · line 865 · raw

@+st:List<&2, YFrame> -> @+i:U32 -> List<&2, YFrame>

def Yaml.item.value.go source · line 868 · raw

@st:List<&2, YFrame> -> @+a:String -> @+r:String -> @empty:Bool -> List<&2, YFrame>

def Yaml.item.value source · line 877 · raw

@st:List<&2, YFrame> -> @av:AV -> List<&2, YFrame>

"- &a value", "- *a", "- " (a block follows), or "- &a" (an anchored block follows).

def Yaml.item.go source · line 884 · raw

@st:List<&2, YFrame> -> @+i:U32 -> @rest:String -> @kr:Maybe<&2, KR> -> List<&2, YFrame>

The item is a mapping when it reads "key: ..." (its keys then sit at i + 2), else a scalar.

def Yaml.item source · line 892 · raw

@+st:List<&2, YFrame> -> @+i:U32 -> @+rest:String -> List<&2, YFrame>

A "- item" line at indent i: into the open sequence at i, or a new one.

def Yaml.is_dash source · line 895 · raw

@t:String -> Bool

def Yaml.after_dash source · line 904 · raw

@t:String -> String

def Yaml.step.entry source · line 907 · raw

@+st:List<&2, YFrame> -> @+i:U32 -> @+t:String -> @kr:Maybe<&2, KR> -> List<&2, YFrame>

def Yaml.step.go source · line 914 · raw

@+st:List<&2, YFrame> -> @+i:U32 -> @+t:String -> @dash:Bool -> List<&2, YFrame>

def Yaml.step source · line 922 · raw

@+st:List<&2, YFrame> -> @l:Line -> List<&2, YFrame>

One line.

def Yaml.feed source · line 928 · raw

@ls:List<&2, Line> -> @+st:List<&2, YFrame> -> List<&2, YFrame>

def Yaml.result source · line 935 · raw

@st:List<&2, YFrame> -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json

def Yaml.is_open source · line 944 · raw

@st:List<&2, YFrame> -> Bool

def Yaml.close_all.go source · line 953 · raw

@fuel:Nat -> @+st:List<&2, YFrame> -> @open:Bool -> List<&2, YFrame>

def Yaml.close_all source · line 961 · raw

@fuel:Nat -> @+st:List<&2, YFrame> -> List<&2, YFrame>

Closes every open container, into the document.

def YR.json source · line 964 · raw

@r:YR -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json

def YR.anchors source · line 973 · raw

@r:YR -> Map<&2, 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json>

def Yaml.marker.go source · line 978 · raw

@n:String -> @hit:Bool -> Maybe<&2, String>

def Yaml.marker source · line 985 · raw

@s:String -> @+kind:Char -> Maybe<&2, String>

def Yaml.anchor_name source · line 992 · raw

@k:String -> Maybe<&2, String>

def Yaml.res.mem source · line 995 · raw

@k:String -> @h:YR -> @t:YR -> YR

def Yaml.res.cons source · line 1000 · raw

@h:YR -> @t:YR -> YR

def Yaml.merge.take source · line 1005 · raw

@+ms:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json

def Yaml.merge.missing.put source · line 1008 · raw

@k:String -> @v:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @rest:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @h:Bool -> @has:Bool -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json

def Yaml.has source · line 1015 · raw

@ms:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @+k:String -> Bool

def Yaml.merge.missing source · line 1019 · raw

@src:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @+ms:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json

Members whose keys the chain ms lacks, from the merged object's chain.

def Yaml.append_mem source · line 1026 · raw

@ms:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @extra:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json

def Yaml.merge.go source · line 1033 · raw

@src:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @+rest:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json

def Yaml.merge source · line 1041 · raw

@+ms:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json

Applies a "<<" member: its object's members join where keys are absent.

def Yaml.res.obj source · line 1044 · raw

@r:YR -> YR

def Yaml.res.arr source · line 1049 · raw

@r:YR -> YR

def Yaml.is_alias source · line 1054 · raw

@s:String -> Maybe<&2, String>

def Yaml.lookup.fin source · line 1057 · raw

@r:Pair(Map<&2, 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json>, 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json) -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json

def Yaml.alias source · line 1062 · raw

@+name:String -> @+anchors:Map<&2, 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json> -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json

def Yaml.res.str source · line 1065 · raw

@s:String -> @+a:Map<&2, 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json> -> @alias:Maybe<&2, String> -> YR

def Yaml.res.anchor source · line 1072 · raw

@+n:String -> @r:YR -> YR

def Yaml.res.single source · line 1078 · raw

@+k:String -> @n:Maybe<&2, String> -> @+rv:YR -> @tail:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @a:Map<&2, 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json> -> YR

A one-member object: an anchor marker, or a plain object.

def Yaml.res source · line 1086 · raw

@j:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> @+a:Map<&2, 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json> -> YR

The document with anchors recorded, aliases replaced and merges applied.

def Yaml.resolve source · line 1105 · raw

@j:0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json

def Yaml.parse source · line 1109 · raw

@s:String -> 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json

The (first) document as JSON, anchors and aliases resolved.

def Yaml.is_sep source · line 1115 · raw

@+l:String -> Bool

def Yaml.docs.cur source · line 1118 · raw

@+l:String -> @cur:List<&2, String> -> @sep:Bool -> List<&2, String>

def Yaml.docs.done source · line 1125 · raw

@+cur:List<&2, String> -> @done:List<&2, String> -> @sep:Bool -> List<&2, String>

def Yaml.docs.go source · line 1133 · raw

@ls:List<&2, String> -> @+cur:List<&2, String> -> @done:List<&2, String> -> List<&2, String>

Splits a stream at "---" and "..." lines; documents come reversed.

def Yaml.docs.keep source · line 1140 · raw

@d:String -> @acc:List<&2, 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json> -> @empty:Bool -> List<&2, 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json>

def Yaml.docs.parse source · line 1147 · raw

@ds:List<&2, String> -> @acc:List<&2, 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json> -> List<&2, 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json>

def Yaml.parse_all source · line 1156 · raw

@s:String -> List<&2, 0x4b19fea9f3c794558ea41a0289840d6a/src/json.Json>

Every document of a stream (kubectl's multi-document files), in order; empty documents are skipped.