src/text.bend checks
raw source on the hub · import bend-toon-codec@0.1.0.0/src/text.bend as Text
3 imports
import Base import ./num.bend as N import ./head.bend as Hd
Types
type Cut source · line 10 · raw
Data
A decoded value with the text that follows it.
Cut@val:String -> @rest:String -> Cut
type Us source · line 15 · raw
Data
Unescape state: normal, after a backslash, or reading the hex digits of a
\uXXXX escape (k digits to go, acc so far).
UNUs
UBUs
UH@k:U32 -> @acc:U32 -> Us
type Ek source · line 21 · raw
Data
What one character does to the output.
EkChar@u:U32 -> Ek
EkNoneEk
EkEndEk
EkErr@m:String -> Ek
Definitions
def is_ws source · line 29 · raw
@+c:U32 -> Bool
The whitespace JavaScript's String.trim removes: what section 7.2 means by leading or trailing whitespace.
def head_ws source · line 35 · raw
@+s:String -> Bool
def last_ws source · line 42 · raw
@+s:String -> Bool
def sel.s source · line 45 · raw
@+b:Bool -> @+x:String -> @+y:String -> String
def sel.u source · line 54 · raw
@+b:Bool -> @+x:U32 -> @+y:U32 -> U32
def hexd source · line 61 · raw
@+n:U32 -> Char
def esc.ctl source · line 65 · raw
@+c:U32 -> String
\u00xx for a control character, lowercase hex.
def esc.other source · line 68 · raw
@+c:U32 -> String
def esc.char source · line 72 · raw
@+c:U32 -> String
One character inside quotes (section 7.1 encoder column).
def esc.body source · line 79 · raw
@+s:String -> String
def quote source · line 87 · raw
@+s:String -> String
"text" with escapes.
def special source · line 92 · raw
@+c:U32 -> @+d:U32 -> Bool
A character that forces quotes anywhere in a string value: colon, double quote, backslash, brackets, braces, control characters, or the delimiter.
def has_special source · line 97 · raw
@+s:String -> @+d:U32 -> Bool
def is_some source · line 104 · raw
@+m:Maybe<&2, 0x12996a27cbeef5e5ba1e8cd909be0e05/src/num.Num> -> Bool
def numeric_like source · line 111 · raw
@+s:String -> Bool
def starts_hyphen source · line 114 · raw
@+s:String -> Bool
def reserved source · line 117 · raw
@+s:String -> Bool
def needs_quote source · line 123 · raw
@+s:String -> @+d:U32 -> Bool
Section 7.2: must this string value be quoted? d is the delimiter that
applies (the document delimiter for field values, the active delimiter for
array cells), as a code point.
def enc.str source · line 128 · raw
@+s:String -> @+d:U32 -> String
A string value, quoted when it must be.
def key_start source · line 131 · raw
@+c:Char -> Bool
def key_rest source · line 134 · raw
@+c:Char -> Bool
def key_tail source · line 137 · raw
@+s:String -> Bool
def key_plain source · line 145 · raw
@+s:String -> Bool
^[A-Za-z_][A-Za-z0-9_.]*$.
def enc.key source · line 152 · raw
@+k:String -> String
def hex.pick source · line 157 · raw
@+dg:Bool -> @+lo:Bool -> @+up:Bool -> @+c:U32 -> Maybe<&2, U32>
def hex.val source · line 168 · raw
@+c:U32 -> Maybe<&2, U32>
def push source · line 172 · raw
@+c:U32 -> @+r:Result<&2, &2, String, Cut> -> Result<&2, &2, String, Cut>
def esc.code source · line 180 · raw
@+e:U32 -> U32
The code point a simple escape letter stands for, or the sentinel 4294967295.
def us.pick source · line 184 · raw
@+b:Bool -> @+x:Us -> @+y:Us -> Us
def hex.next source · line 191 · raw
@+m:Maybe<&2, U32> -> @+k:U32 -> @+acc:U32 -> Us
def next source · line 199 · raw
@+st:Us -> @+c:U32 -> Us
The state after reading character c.
def ek.pick source · line 208 · raw
@+b:Bool -> @+x:Ek -> @+y:Ek -> Ek
def simple.emit source · line 215 · raw
@+code:U32 -> Ek
def unit.emit source · line 219 · raw
@+n:U32 -> Ek
A finished \uXXXX value: a surrogate is refused (section 7.1).
def hex.emit source · line 222 · raw
@+m:Maybe<&2, U32> -> @+k:U32 -> @+acc:U32 -> Ek
def emit source · line 230 · raw
@+st:Us -> @+c:U32 -> Ek
What character c emits in state st.
def unq.k source · line 239 · raw
@+ek:Ek -> @+t:String -> @+r:Result<&2, &2, String, Cut> -> Result<&2, &2, String, Cut>
def unq.go source · line 250 · raw
@+s:String -> @+st:Us -> Result<&2, &2, String, Cut>
def unq source · line 259 · raw
@+s:String -> Result<&2, &2, String, Cut>
Unescape a quoted string whose opening quote is already consumed; the result carries the text after the closing quote.