~/bend-docscommunity

src/text.bend checks

raw source on the hub · import bend-semver-checks@0.1.0.0/src/text.bend as Text

1 import
import Base

Types

type Mode source · line 17 · raw

Data

Where the scanner is inside a source line. MCode ordinary code MStr inside "..." MStrEsc after a backslash in one MQuote right after an opening ' (char literal); the next char is copied MQuoteEsc after '\ MQuoteEnd expecting the closing ' MComment after #, to the end of the line

type St source · line 101 · raw

Data

Scanner state: the mode, a pending gap (whitespace seen in code, written as one space before the next char), and the output so far, reversed.

type DSt source · line 169 · raw

Data

Definitions

def advance.code source · line 27 · raw

@+c:Char -> Mode

The mode after a char read in code.

def advance.str source · line 38 · raw

@+c:Char -> Mode

def advance.quote source · line 47 · raw

@+c:Char -> Mode

def norm.end source · line 55 · raw

@+c:Char -> Mode

A lone prime that is not a char literal falls back to code.

def norm source · line 62 · raw

@+m:Mode -> @+c:Char -> Mode

def advance source · line 80 · raw

@+m:Mode -> @+c:Char -> Mode

The mode after c; m is already normalised.

def put.gap source · line 105 · raw

@+acc:String -> @+c:Char -> String

A pending gap is written as one space, never at the start of the output.

def put source · line 112 · raw

@+gap:Bool -> @+c:Char -> @+acc:String -> String

def clean.code source · line 120 · raw

@+sp:Bool -> @+c:Char -> @+gap:Bool -> @+acc:String -> St

A char read in code (mode MCode): space opens a gap, # starts a comment.

def clean.step1 source · line 131 · raw

@+m:Mode -> @+c:Char -> @+sp:Bool -> @+gap:Bool -> @+acc:String -> St

def clean.step source · line 148 · raw

@+m:Mode -> @+c:Char -> @+gap:Bool -> @+acc:String -> St

def clean.go source · line 151 · raw

@+s:String -> @+st:St -> String

def clean source · line 164 · raw

@+s:String -> String

Drop a # comment (outside strings and char literals), collapse runs of whitespace outside strings to one space, trim both ends.

def dec.if source · line 172 · raw

@+z:Bool -> @+d:U32 -> U32

def dec source · line 179 · raw

@+d:U32 -> U32

def bracket source · line 183 · raw

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

Depth change for a char read in code.

def depth.step1 source · line 200 · raw

@+m:Mode -> @+c:Char -> @+d:U32 -> DSt

def depth.go source · line 217 · raw

@+s:String -> @+st:DSt -> U32

def depth_after source · line 229 · raw

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

Open-bracket depth after s, starting from depth d (saturating at 0).

def blank source · line 234 · raw

@+s:String -> Bool

def indented source · line 241 · raw

@+s:String -> Bool

def hex_digit.if source · line 256 · raw

@+lt:Bool -> @+d:U32 -> Char

def hex_digit source · line 263 · raw

@+d:U32 -> Char

def esc.ctl source · line 266 · raw

@+lt:Bool -> @+x:U32 -> @+c:Char -> String

def esc.char source · line 273 · raw

@+c:Char -> String

def esc source · line 288 · raw

@+s:String -> String

def jstr source · line 296 · raw

@+s:String -> String

A JSON string literal.

def jstrs.go source · line 299 · raw

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

def jstrs source · line 307 · raw

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

A JSON array of strings.