token.bend checks
raw source on the hub · import yaml-for-bend@0.1.0.0/token.bend as Token
The pieces the scanner hands the parser, and the errors both report.
1 import
import Base
Types
type Mark source · line 7 · raw
Data
A place in the text: the line and column (each from 0, a column counted in characters) and the character's index from the start.
Mark@line:Nat -> @col:Nat -> @idx:Nat -> Mark
type Style source · line 11 · raw
Data
How a scalar was written.
PlainStyle
SingleStyle
DoubleStyle
LiteralStyle
FoldedStyle
type Tok source · line 19 · raw
Data
A token, as libyaml names them. A scanner error ends the tokens with Broken.
StreamStartTok
StreamEndTok
VersionDir@major:Nat -> @minor:Nat -> Tok
TagDir@handle:String -> @prefix:String -> Tok
DocStartTok
DocEndTok
BSeqStartTok
BMapStartTok
BEndTok
FSeqStartTok
FSeqEndTok
FMapStartTok
FMapEndTok
BEntryTok
FEntryTok
KeyTokTok
ValueTokTok
AliasTok@name:String -> Tok
AnchorTok@name:String -> Tok
TagTok@handle:String -> @suffix:String -> Tok
ScalarTok@text:String -> @style:Style -> Tok
Broken@error:Error -> Tok
type Token source · line 43 · raw
Data
Token@tok:Tok -> @start:Mark -> @end:Mark -> Token
type Cause source · line 48 · raw
Data
Why a text didn't load: it isn't YAML, or it is but the schema can't load it (a bad !!int, an unknown alias, a repeated key).
SyntaxCause
ContentCause
type Error source · line 55 · raw
Data
What went wrong, where, and why. A syntax error reads as a problem and what was being read: "did not find expected key while parsing a block mapping".
Error@why:String -> @at:Mark -> @cause:Cause -> Error
Definitions
def mark.line source · line 58 · raw
@m:Mark -> Nat
def mark.col source · line 63 · raw
@m:Mark -> Nat
def mark.idx source · line 68 · raw
@m:Mark -> Nat
def mark.show source · line 74 · raw
@m:Mark -> String
"at line 2 column 5", counting from 1.
def error.show source · line 81 · raw
@e:Error -> String
The error as one line: "mapping values are not allowed in this context at line 1 column 5".
def error.why source · line 86 · raw
@e:Error -> String
def error.at source · line 91 · raw
@e:Error -> Mark