scan.bend checks
raw source on the hub · import yaml-for-bend@0.1.0.0/scan.bend as Scan
The scanner: YAML text to tokens.
It follows the design of libyaml's scanner. One step fetches the next token. Block collections open and close by indentation, so the scanner keeps a stack of indentations and adds BSeqStart, BMapStart and BEnd tokens as they change. A "simple key" (a key without "?") is only known to be a key when its ":" arrives, so the scanner remembers where each possible key started and, at the ":", inserts a KeyTok (and BMapStart) before the key's first token.
It reads YAML 1.2 as the YAML test suite has it: tabs separate tokens but never indent, a flow collection's lines and a quoted scalar's indent past the block around them, a comment follows a blank, anchors take any character but blanks and flow indicators, ":" is a value indicator right after a JSON-like node in flow, and reserved directives are skipped.
An error ends the tokens with a Broken token, so the parser still sees the tokens before it.
2 imports
import Base import ./token.bend as T
Types
type Cur source · line 25 · raw
Data
The text left to read, where it starts, and how many characters are left.
Cur@s:String -> @at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> @left:Nat -> Cur
type SKey source · line 30 · raw
Data
A place a simple key may start: whether one still may, whether it must (a block key at the indentation), the number its first token has, and where.
SKey@possible:Bool -> @required:Bool -> @number:Nat -> @at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> @tab:Bool -> SKey
type Sc source · line 38 · raw
Data
The scanner: the cursor, the block indentation plus one (0 outside any block collection) and the ones it returns to, how deep in flow collections it is, whether a simple key may start here, one possible key per flow level (the block level last), the tokens so far (newest first) and their count.
Sc@cur:Cur -> @ind:Nat -> @inds:List<&2, Nat> -> @flow:Nat -> @allowed:Bool -> @tab:Bool -> @keys:List<&2, SKey> -> @out:List<&2, 0x36754ca959c7683aed7402df6aa2fca0/token.Token> -> @n:Nat -> Sc
type Step source · line 43 · raw
Data
A step goes on, or stops: at the stream's end or at an error, as the last token says.
Go@st:Sc -> Step
Stop@st:Sc -> Step
type Lay source · line 47 · raw
Data
Lay@ind:Nat -> @inds:List<&2, Nat> -> @out:List<&2, 0x36754ca959c7683aed7402df6aa2fca0/token.Token> -> @n:Nat -> Lay
type Skipped source · line 53 · raw
Data
Skipped@cur:Cur -> @allowed:Bool -> @tab:Bool -> @nl:Bool -> @sp:Nat -> @bad:Bool -> Skipped
type Pl source · line 62 · raw
Data
Reading a plain scalar: the cursor, the text so far (reversed), where the last word ended, the blanks after it (reversed), whether a line break came since, how many more breaks did, and whether a word is being read.
Pl@cur:Cur -> @acc:String -> @end:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> @ws:String -> @lead:Bool -> @brks:Nat -> @word:Bool -> @bad:Bool -> Pl
PlDone@cur:Cur -> @acc:String -> @end:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> @lead:Bool -> Pl
PlBad@error:0x36754ca959c7683aed7402df6aa2fca0/token.Error -> Pl
type Qs source · line 74 · raw
Data
Reading a quoted scalar: the cursor, the text so far (reversed), the blanks waiting (reversed), whether a line break came since the last text and how many more did, whether that break was escaped, and whether text (not blanks) is being read.
Qs@cur:Cur -> @acc:String -> @ws:String -> @lead:Bool -> @brks:Nat -> @esc:Bool -> @text:Bool -> @bad:Bool -> Qs
QsDone@cur:Cur -> @acc:String -> Qs
QsBad@error:0x36754ca959c7683aed7402df6aa2fca0/token.Error -> Qs
type Chomp source · line 82 · raw
Data
ClipChomp
StripChomp
KeepChomp
type Head source · line 89 · raw
Data
A block scalar's header: how to chomp, the indentation indicator (0 when there's none), and the cursor after it; or an error.
Head@chomp:Chomp -> @inc:Nat -> @cur:Cur -> Head
HeadBad@why:String -> Head
type BPhase source · line 93 · raw
Data
BreaksBPhase
LineStartBPhase
ContentBPhase
type Bs source · line 102 · raw
Data
Reading a block scalar: the cursor, the text so far (reversed), the content's indentation plus one (0 until known), the deepest blank line, whether a line break waits, whether the last line started with a blank, how many more breaks wait, and the phase: blank lines, a line's start, or content.
Bs@cur:Cur -> @acc:String -> @ind:Nat -> @max:Nat -> @lead:Bool -> @lblank:Bool -> @brks:Nat -> @phase:BPhase -> Bs
BsDone@acc:String -> @lead:Bool -> @brks:Nat -> @cur:Cur -> Bs
BsBad@error:0x36754ca959c7683aed7402df6aa2fca0/token.Error -> Bs
type Taken source · line 111 · raw
Data
What a scan took: the text it read and how many characters that was.
Taken@text:String -> @n:Nat -> Taken
Definitions
def then source · line 115 · raw
@v:Step -> @f:(@_:Sc -> Step) -> Step
The step after +v+, when it goes on.
def when source · line 123 · raw
@-A:Type -> @hit:Bool -> @yes:(@_:Unit -> A) -> @no:(@_:Unit -> A) -> A
+yes+ when +hit+, else +no+; only the one chosen runs.
def code source · line 133 · raw
@c:Char -> U32
def peek source · line 139 · raw
@s:String -> @n:Nat -> Char
The character +n+ places on, or NUL past the end.
def is_blank source · line 150 · raw
@c:Char -> Bool
def is_break source · line 159 · raw
@c:Char -> Bool
def is_end source · line 162 · raw
@c:Char -> Bool
def is_blankz source · line 165 · raw
@+c:Char -> Bool
def is_breakz source · line 168 · raw
@+c:Char -> Bool
def is_flow.ind source · line 171 · raw
@c:Char -> Bool
def between source · line 186 · raw
@+x:U32 -> @lo:U32 -> @hi:U32 -> Bool
def is_digit source · line 189 · raw
@c:Char -> Bool
def is_hex source · line 192 · raw
@+c:Char -> Bool
def is_word source · line 196 · raw
@+c:Char -> Bool
A letter, digit or "-": what a tag handle's name is made of.
def is_in source · line 199 · raw
@c:Char -> @s:String -> Bool
def is_uri source · line 203 · raw
@+c:Char -> Bool
A URI character other than "%" (which starts an escape).
def is_tag source · line 207 · raw
@+c:Char -> Bool
A tag character: a URI character but "!" and the flow indicators.
def is_printable source · line 211 · raw
@c:Char -> Bool
What YAML allows in a document: tab, line feed, and printable characters.
def hex.digit source · line 218 · raw
@c:Char -> U32
def hex.value source · line 222 · raw
@s:String -> @acc:U32 -> U32
def all.hex source · line 229 · raw
@s:String -> Bool
def marker source · line 237 · raw
@+s:String -> @+c:Char -> Bool
"---" or "..." (+c+ thrice) and then a blank, a break or the end.
def is_marker source · line 240 · raw
@+s:String -> Bool
def lf source · line 245 · raw
@s:String -> String
Line breaks as "\n": "\r\n" and a lone "\r" both become one, as YAML reads them.
def strip.bom source · line 260 · raw
@s:String -> String
def past source · line 272 · raw
@at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> @c:Char -> 0x36754ca959c7683aed7402df6aa2fca0/token.Mark
def adv source · line 281 · raw
@c:Cur -> Cur
def adv.n source · line 290 · raw
@n:Nat -> @c:Cur -> Cur
def cur.s source · line 297 · raw
@c:Cur -> String
def cur.at source · line 302 · raw
@c:Cur -> 0x36754ca959c7683aed7402df6aa2fca0/token.Mark
def cur.left source · line 307 · raw
@c:Cur -> Nat
def cur.col source · line 312 · raw
@c:Cur -> Nat
def sc.cur source · line 318 · raw
@st:Sc -> Cur
def sc.s source · line 323 · raw
@st:Sc -> String
def sc.at source · line 326 · raw
@st:Sc -> 0x36754ca959c7683aed7402df6aa2fca0/token.Mark
def sc.col source · line 329 · raw
@st:Sc -> Nat
def sc.ind source · line 332 · raw
@st:Sc -> Nat
def sc.flow source · line 337 · raw
@st:Sc -> Nat
def sc.in_flow source · line 342 · raw
@st:Sc -> Bool
def sc.tab source · line 345 · raw
@st:Sc -> Bool
def sc.allowed source · line 350 · raw
@st:Sc -> Bool
def sc.keys source · line 355 · raw
@st:Sc -> List<&2, SKey>
def sc.out source · line 360 · raw
@st:Sc -> List<&2, 0x36754ca959c7683aed7402df6aa2fca0/token.Token>
def sc.with.cur source · line 365 · raw
@st:Sc -> @c:Cur -> Sc
def sc.allow source · line 370 · raw
@st:Sc -> @b:Bool -> Sc
def sc.with.keys source · line 375 · raw
@st:Sc -> @ks:List<&2, SKey> -> Sc
def skip source · line 380 · raw
@+st:Sc -> @k:Nat -> Sc
def emit.span source · line 384 · raw
@st:Sc -> @tok:0x36754ca959c7683aed7402df6aa2fca0/token.Tok -> @start:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> @end:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Sc
A token from +start+ to +end+.
def emit source · line 390 · raw
@+st:Sc -> @tok:0x36754ca959c7683aed7402df6aa2fca0/token.Tok -> @start:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Sc
A token from +start+ to here.
def single source · line 394 · raw
@+st:Sc -> @tok:0x36754ca959c7683aed7402df6aa2fca0/token.Tok -> Sc
A one-character token here.
def fail source · line 397 · raw
@+st:Sc -> @why:String -> @+at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Step
def fail.with source · line 400 · raw
@+st:Sc -> @e:0x36754ca959c7683aed7402df6aa2fca0/token.Error -> Step
def cannot source · line 406 · raw
@+st:Sc -> Step
"found character that cannot start any token"
def json.tok source · line 412 · raw
@t:0x36754ca959c7683aed7402df6aa2fca0/token.Tok -> Bool
The token before this one: whether it was a JSON-like node (a quoted scalar or a flow collection), after which ":" is a value indicator even without a space.
def json.before source · line 429 · raw
@out:List<&2, 0x36754ca959c7683aed7402df6aa2fca0/token.Token> -> Bool
def key.top source · line 442 · raw
@keys:List<&2, SKey> -> SKey
The possible key on top, which a ":" would make a key.
def key.or source · line 449 · raw
@r:Result<&2, &2, 0x36754ca959c7683aed7402df6aa2fca0/token.Error, List<&2, SKey>> -> @+st:Sc -> Step
def key.removed source · line 456 · raw
@keys:List<&2, SKey> -> Result<&2, &2, 0x36754ca959c7683aed7402df6aa2fca0/token.Error, List<&2, SKey>>
def remove.key source · line 468 · raw
@+st:Sc -> Step
The key on top can no longer be; an error if it had to be.
def key.put source · line 471 · raw
@st:Sc -> @required:Bool -> Sc
def key.saved source · line 476 · raw
@r:Step -> @+required:Bool -> Step
def save.key source · line 485 · raw
@+st:Sc -> Step
A simple key may start here. It must be one (no "?" can come later) when it starts a block line at the indentation.
def stale.cons source · line 489 · raw
@k:SKey -> @r:Result<&2, &2, 0x36754ca959c7683aed7402df6aa2fca0/token.Error, List<&2, SKey>> -> Result<&2, &2, 0x36754ca959c7683aed7402df6aa2fca0/token.Error, List<&2, SKey>>
def stale.go source · line 498 · raw
@keys:List<&2, SKey> -> @+at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Result<&2, &2, 0x36754ca959c7683aed7402df6aa2fca0/token.Error, List<&2, SKey>>
Keys left behind: a simple key stays on one line and within 1024 characters.
def stale source · line 510 · raw
@+st:Sc -> Step
def key.cleared source · line 513 · raw
@keys:List<&2, SKey> -> List<&2, SKey>
def flow.push source · line 522 · raw
@st:Sc -> Sc
def flow.pop source · line 527 · raw
@st:Sc -> Sc
def insert.at source · line 539 · raw
@d:Nat -> @out:List<&2, 0x36754ca959c7683aed7402df6aa2fca0/token.Token> -> @t:0x36754ca959c7683aed7402df6aa2fca0/token.Token -> List<&2, 0x36754ca959c7683aed7402df6aa2fca0/token.Token>
def insert source · line 551 · raw
@out:List<&2, 0x36754ca959c7683aed7402df6aa2fca0/token.Token> -> @n:Nat -> @number:Maybe<&2, Nat> -> @t:0x36754ca959c7683aed7402df6aa2fca0/token.Token -> List<&2, 0x36754ca959c7683aed7402df6aa2fca0/token.Token>
A token at the end, or (+number+) before the token with that number.
def roll.do source · line 558 · raw
@st:Sc -> @col:Nat -> @number:Maybe<&2, Nat> -> @tok:0x36754ca959c7683aed7402df6aa2fca0/token.Tok -> @+at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Sc
def roll source · line 564 · raw
@+st:Sc -> @+col:Nat -> @number:Maybe<&2, Nat> -> @tok:0x36754ca959c7683aed7402df6aa2fca0/token.Tok -> @at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Sc
A block collection starts at +col+ when that's deeper than the indentation.
def unroll.go source · line 567 · raw
@inds:List<&2, Nat> -> @+ind:Nat -> @+lim:Nat -> @+at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> @+out:List<&2, 0x36754ca959c7683aed7402df6aa2fca0/token.Token> -> @+n:Nat -> Lay
def unrolled source · line 574 · raw
@l:Lay -> @cur:Cur -> @flow:Nat -> @allowed:Bool -> @tab:Bool -> @keys:List<&2, SKey> -> Sc
def unroll.do source · line 579 · raw
@st:Sc -> @+lim:Nat -> Sc
def unroll source · line 585 · raw
@+st:Sc -> @+lim:Nat -> Sc
Block collections deeper than +lim+ (a column plus one) end.
def skip.or source · line 588 · raw
@eat:Bool -> @more:(@_:Unit -> Skipped) -> @stop:Skipped -> Skipped
def skip.go source · line 601 · raw
@s:String -> @+at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> @+left:Nat -> @+flow:Bool -> @+ind:Nat -> @+allowed:Bool -> @+comment:Bool -> @+gap:Bool -> @+tab:Bool -> @+nl:Bool -> @+lead:Bool -> @+sp:Nat -> @+bad:Bool -> Skipped
Blanks, comments and line breaks before a token. A "#" starts a comment after a blank or at a line's start (+gap+). A line break in block context lets a simple key start. Along the way: whether a tab came on the token's line (+tab+), whether a line break came (+nl+), the spaces that start the token's line (+sp+, while +lead+), and whether a tab stood where block indentation belongs (+bad+).
def skipped source · line 619 · raw
@k:Skipped -> @st:Sc -> Sc
def last.plain source · line 628 · raw
@out:List<&2, 0x36754ca959c7683aed7402df6aa2fca0/token.Token> -> Bool
Whether the last token was a plain or block scalar, which end past the blanks after them, so a "#" here follows a blank.
def skip.check source · line 651 · raw
@k:Skipped -> @+st:Sc -> Step
What the skipped whitespace allows: no tab where block indentation belongs, and in flow, lines indented past the block around them.
def skip.ws.at source · line 661 · raw
@c:Cur -> @+st:Sc -> Step
def skip.ws source · line 668 · raw
@+st:Sc -> Step
def folded.breaks source · line 672 · raw
@+brks:Nat -> String
Folded line breaks: one break is a space, more are newlines (less one).
def flush source · line 676 · raw
@acc:String -> @ws:String -> @lead:Bool -> @+brks:Nat -> String
The blanks or breaks before a word join the text.
def pl.word source · line 684 · raw
@cur:Cur -> @+acc:String -> @+end:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> @+ws:String -> @+lead:Bool -> @+brks:Nat -> @+flow:Bool -> Pl
In a word: a blank ends it; ": " or a flow indicator in flow ends the scalar.
def pl.blank source · line 698 · raw
@cur:Cur -> @+acc:String -> @+end:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> @+ws:String -> @+lead:Bool -> @+brks:Nat -> @+bad:Bool -> @+ind:Nat -> @+flow:Bool -> @+start:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Pl
Between words: blanks and breaks wait to join the text; then the next word starts, unless the scalar ended (less indented, a document marker, a comment, or the end). A tab may not stand where indentation belongs on a line that goes on.
def pl.step source · line 714 · raw
@p:Pl -> @+ind:Nat -> @+flow:Bool -> @+start:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Pl
def pl.run source · line 725 · raw
@fuel:Nat -> @+ind:Nat -> @+flow:Bool -> @+start:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> @p:Pl -> Pl
def plain.done source · line 736 · raw
@p:Pl -> @+st:Sc -> @start:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Step
def plain.scan source · line 745 · raw
@+st:Sc -> Step
def plain source · line 750 · raw
@+st:Sc -> Step
def q.text source · line 753 · raw
@cur:Cur -> @acc:String -> Qs
def simple.escape source · line 756 · raw
@e:Char -> Maybe<&2, Char>
def q.simple source · line 797 · raw
@m:Maybe<&2, Char> -> @cur:Cur -> @acc:String -> @start:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Qs
def is_scalar.value source · line 805 · raw
@+x:U32 -> Bool
A code point that is a character: not a surrogate, and at most 10FFFF.
def q.hex source · line 809 · raw
@+n:Nat -> @+cur:Cur -> @acc:String -> @+start:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Qs
\x, \u or \U and +n+ hex digits.
def q.escape source · line 818 · raw
@e:Char -> @cur:Cur -> @acc:String -> @start:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Qs
def q.char source · line 831 · raw
@double:Bool -> @c:Char -> @+c1:Char -> @+cur:Cur -> @+acc:String -> @start:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Qs
def q.in.text source · line 848 · raw
@+double:Bool -> @+cur:Cur -> @+acc:String -> @+start:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Qs
def q.joined source · line 858 · raw
@+acc:String -> @ws:String -> @lead:Bool -> @+brks:Nat -> @esc:Bool -> String
The blanks and breaks between text: kept, or folded, once text resumes.
def q.in.blanks source · line 867 · raw
@+cur:Cur -> @+acc:String -> @+ws:String -> @+lead:Bool -> @+brks:Nat -> @+esc:Bool -> @+bad:Bool -> @+ind:Nat -> @+start:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Qs
Between text: blanks and breaks wait to join it. A line after a break must be indented past the block around it (+ind+), with spaces.
def q.step source · line 876 · raw
@q:Qs -> @+double:Bool -> @+ind:Nat -> @+start:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Qs
def q.run source · line 887 · raw
@fuel:Nat -> @+double:Bool -> @+ind:Nat -> @+start:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> @q:Qs -> Qs
def quoted.done source · line 898 · raw
@q:Qs -> @+st:Sc -> @+double:Bool -> @start:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Step
def quoted.scan source · line 907 · raw
@+st:Sc -> @+double:Bool -> Step
def quoted source · line 912 · raw
@+st:Sc -> @+double:Bool -> Step
def digit.value source · line 915 · raw
@c:Char -> Nat
def chomp.of source · line 918 · raw
@c:Char -> Maybe<&2, Chomp>
def chomp.or source · line 927 · raw
@m:Maybe<&2, Chomp> -> @d:Chomp -> Chomp
def is_some.chomp source · line 934 · raw
@m:Maybe<&2, Chomp> -> Bool
def head.tail source · line 942 · raw
@s:String -> @+at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> @+left:Nat -> @+comment:Bool -> @+gap:Bool -> Cur
Past blanks and a comment (after a blank), to a line break or the end.
def head.check source · line 951 · raw
@chomp:Chomp -> @+inc:Nat -> @+cur:Cur -> Head
def head.end source · line 954 · raw
@chomp:Chomp -> @+inc:Nat -> @cur:Cur -> Head
def header source · line 960 · raw
@+cur:Cur -> Head
The indicators after "|" or ">", in either order.
def bs.breaks source · line 979 · raw
@+cur:Cur -> @+acc:String -> @+ind:Nat -> @+max:Nat -> @+lead:Bool -> @+lblank:Bool -> @+brks:Nat -> @+pind:Nat -> @+start:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Bs
Blank lines and the indentation before content. The first content line sets the indentation when the header didn't; no blank line before it may be deeper. A tab may start content but not indentation. A last line of spaces with no break after it still counts as a line.
def bs.line source · line 995 · raw
@+cur:Cur -> @+acc:String -> @+ind:Nat -> @+max:Nat -> @+lead:Bool -> @+lblank:Bool -> @+brks:Nat -> @+folded:Bool -> Bs
A content line starts at the indentation: what waits joins the text.
def bs.content source · line 1004 · raw
@+cur:Cur -> @+acc:String -> @+ind:Nat -> @+max:Nat -> @+lblank:Bool -> Bs
def bs.step source · line 1010 · raw
@b:Bs -> @+folded:Bool -> @+pind:Nat -> @+start:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Bs
def bs.run source · line 1023 · raw
@fuel:Nat -> @+folded:Bool -> @+pind:Nat -> @+start:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> @b:Bs -> Bs
def chomped source · line 1035 · raw
@chomp:Chomp -> @+acc:String -> @+lead:Bool -> @+brks:Nat -> String
The final line break and the blank lines after the text.
def block.done source · line 1044 · raw
@b:Bs -> @chomp:Chomp -> @+st:Sc -> @+folded:Bool -> @start:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Step
def block.body source · line 1053 · raw
@h:Head -> @+st:Sc -> @+folded:Bool -> @+start:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Step
def block.scan source · line 1063 · raw
@+st:Sc -> @+folded:Bool -> Step
def block.scalar source · line 1067 · raw
@+st:Sc -> @+folded:Bool -> Step
def taken.cons source · line 1070 · raw
@c:Char -> @+k:Nat -> @t:Taken -> Taken
def took.or source · line 1075 · raw
@stop:Bool -> @more:(@_:Unit -> Taken) -> Taken
def anchor.name source · line 1083 · raw
@s:String -> Taken
An anchor's name: anything up to a blank, a break or a flow indicator.
def anchor.took source · line 1090 · raw
@t:Taken -> @+st:Sc -> @+is_anchor:Bool -> @+at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Step
def anchor.scan source · line 1098 · raw
@+st:Sc -> @+is_anchor:Bool -> Step
def anchor source · line 1102 · raw
@+st:Sc -> @+is_anchor:Bool -> Step
def taken.skip source · line 1107 · raw
@t:Taken -> Taken
Tag characters, with %XX escapes decoded; +uri+ allows all URI characters (in a verbatim tag or a %TAG prefix).
def tag.chars source · line 1112 · raw
@s:String -> @+uri:Bool -> @+pending:Nat -> Taken
def tag.ends source · line 1129 · raw
@+c:Char -> @+flow:Bool -> Bool
What may follow a tag: a blank, a break, the end, or in flow a flow indicator.
def tag.emit source · line 1132 · raw
@+st:Sc -> @handle:String -> @suffix:String -> @+n:Nat -> @+at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Step
def tag.verbatim source · line 1141 · raw
@t:Taken -> @+st:Sc -> @+at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Step
"!<uri>".
def tag.suffix source · line 1148 · raw
@t:Taken -> @+named:Bool -> @+word:String -> @+k:Nat -> @+st:Sc -> @+at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Step
def tag.short source · line 1158 · raw
@w:Taken -> @+st:Sc -> @+at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Step
"!suffix", "!!suffix", "!name!suffix", or "!" alone.
def word.chars source · line 1165 · raw
@s:String -> Taken
def tag.scan source · line 1172 · raw
@+st:Sc -> Step
def tag source · line 1179 · raw
@+st:Sc -> Step
def count.or source · line 1185 · raw
@go:Bool -> @more:(@_:Unit -> Nat) -> Nat
def blanks source · line 1192 · raw
@s:String -> Nat
def digits source · line 1199 · raw
@s:String -> Taken
def nat.of source · line 1206 · raw
@s:String -> @acc:Nat -> Nat
def directive.put source · line 1213 · raw
@+st:Sc -> @tok:Maybe<&2, 0x36754ca959c7683aed7402df6aa2fca0/token.Tok> -> @at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Sc
def directive.tail source · line 1220 · raw
@+cur:Cur -> @+st:Sc -> @tok:Maybe<&2, 0x36754ca959c7683aed7402df6aa2fca0/token.Tok> -> @+at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Step
def directive.end source · line 1226 · raw
@+st:Sc -> @tok:Maybe<&2, 0x36754ca959c7683aed7402df6aa2fca0/token.Tok> -> @at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Step
After a directive: blanks, a comment, then a line break or the end.
def version.done source · line 1229 · raw
@m:Taken -> @+st:Sc -> @major:String -> @+used:Nat -> @+at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Step
def version.minor source · line 1235 · raw
@m:Taken -> @+st:Sc -> @+b:Nat -> @+at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Step
def version.scan source · line 1246 · raw
@+st:Sc -> @+at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Step
"%YAML 1.2".
def tagdir.prefix source · line 1252 · raw
@p:Taken -> @+st:Sc -> @handle:String -> @+used:Nat -> @+at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Step
def tagdir.handle source · line 1258 · raw
@w:Taken -> @+st:Sc -> @+b:Nat -> @+at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Step
def tagdir.scan source · line 1272 · raw
@+st:Sc -> @+at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Step
"%TAG !e! prefix".
def line.rest source · line 1279 · raw
@s:String -> Nat
Past the rest of a line.
def directive.named source · line 1287 · raw
@+name:String -> @+st:Sc -> @+at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Step
%YAML, %TAG, or a reserved directive, which is skipped.
def directive.name source · line 1292 · raw
@w:Taken -> @+st:Sc -> @+at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Step
def directive.scan source · line 1298 · raw
@+st:Sc -> Step
def directive source · line 1302 · raw
@+st:Sc -> Step
def flow.start source · line 1308 · raw
@+st:Sc -> @t:0x36754ca959c7683aed7402df6aa2fca0/token.Tok -> Step
def flow.end source · line 1311 · raw
@+st:Sc -> @t:0x36754ca959c7683aed7402df6aa2fca0/token.Tok -> Step
def flow.entry source · line 1314 · raw
@+st:Sc -> Step
def block.entry.rest source · line 1317 · raw
@+st:Sc -> Step
def block.entry source · line 1321 · raw
@+st:Sc -> Step
"- ": a block sequence's entry, which may open the sequence.
def key.tok source · line 1327 · raw
@+st:Sc -> Sc
def key.rest source · line 1330 · raw
@+st:Sc -> Step
def key source · line 1334 · raw
@+st:Sc -> Step
"? ": an explicit key.
def value.rest source · line 1340 · raw
@+st:Sc -> Sc
def value.alone source · line 1343 · raw
@+st:Sc -> Step
def insert.key source · line 1348 · raw
@st:Sc -> @number:Nat -> @+at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Sc
def value.with source · line 1355 · raw
@k:SKey -> @+st:Sc -> Step
": ": a value. When a simple key waits, it becomes a key: a KeyTok goes before it, and a block mapping may start at its column.
def value source · line 1364 · raw
@+st:Sc -> Step
def marker.tok source · line 1367 · raw
@+st:Sc -> @t:0x36754ca959c7683aed7402df6aa2fca0/token.Tok -> Sc
def end.mark source · line 1371 · raw
@m:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> 0x36754ca959c7683aed7402df6aa2fca0/token.Mark
The stream ends on a line of its own.
def end.tok source · line 1376 · raw
@+st:Sc -> Sc
def doc.end.check source · line 1380 · raw
@+st:Sc -> @t:0x36754ca959c7683aed7402df6aa2fca0/token.Tok -> Step
def doc.indicator source · line 1388 · raw
@+st:Sc -> @+t:0x36754ca959c7683aed7402df6aa2fca0/token.Tok -> Step
def stream.end source · line 1391 · raw
@+st:Sc -> Step
def is_plain.start source · line 1394 · raw
@+c:Char -> Bool
def fetch.char source · line 1398 · raw
@c:Char -> @+c1:Char -> @+flow:Bool -> @+st:Sc -> Step
The token a character starts.
def fetch.next source · line 1433 · raw
@+st:Sc -> Step
def fetch.after source · line 1443 · raw
@+st:Sc -> Step
def fetch source · line 1447 · raw
@+st:Sc -> Step
One token (and the block tokens before it).
def scan.run source · line 1450 · raw
@fuel:Nat -> @s:Step -> List<&2, 0x36754ca959c7683aed7402df6aa2fca0/token.Token>
def unprintable source · line 1463 · raw
@s:String -> @+at:0x36754ca959c7683aed7402df6aa2fca0/token.Mark -> Maybe<&2, 0x36754ca959c7683aed7402df6aa2fca0/token.Mark>
Where the first character YAML doesn't allow is (a control character, a surrogate), if there is one.
def stream.start source · line 1470 · raw
0x36754ca959c7683aed7402df6aa2fca0/token.Token
def scan.start source · line 1473 · raw
@m:Maybe<&2, 0x36754ca959c7683aed7402df6aa2fca0/token.Mark> -> @+s:String -> List<&2, 0x36754ca959c7683aed7402df6aa2fca0/token.Token>
def scan source · line 1482 · raw
@text:String -> List<&2, 0x36754ca959c7683aed7402df6aa2fca0/token.Token>
The tokens of +text+, from StreamStart to StreamEnd, or to a Broken token at the first error.