~/bend-docscommunity

syntax/word.bend checks

raw source on the hub · import 0x729eecea86ea5a2cdba3a2856a313bca/syntax/word.bend as MWord

syntax/word: the name under a (line, col), both 0-based. A name is letters, digits, _ and . (dots are just characters in a Bend name, and a module alias rides in front: Frame.decode). A position right after a name counts as on it, as editors put the cursor there.

2 imports
import Base
import ../lazy/lazy.bend as Lazy

Types

type W source · line 10 · raw

Data

i: the column of the next char; start: where the current run began; run: the current name, reversed; hit: the name found

Definitions

def is_name source · line 14 · raw

@+c:Char -> Bool

a char a name may hold: letters, digits, _ and .

def text source · line 18 · raw

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

the run's chars (reversed) as a string

def close source · line 22 · raw

@+i:U32 -> @+start:U32 -> @+run:List<&2, Char> -> @+hit:Maybe<&2, String> -> @+col:U32 -> Maybe<&2, String>

a run that ends at column i holds col when start <= col <= i

def step source · line 30 · raw

@+c:Char -> @st:W -> @+col:U32 -> W

one char: it extends the run of name chars, or ends it (a run holding the column is the answer)

def scan source · line 37 · raw

@cs:List<&2, Char> -> @st:W -> @+col:U32 -> W

every char, in order

def finish source · line 45 · raw

@st:W -> @col:U32 -> String

the run that held the column, else ""

def in_line source · line 50 · raw

@line:String -> @+col:U32 -> String

the name at a column of a line

def at source · line 54 · raw

@source:String -> @line:U32 -> @col:U32 -> String

the name under a (line, col) of a source, "" when none

def cut.go source · line 58 · raw

@cs:List<&2, Char> -> @acc:List<&2, Char> -> Pair(String, String)

Alias.rest cut at its first dot: ("Alias", "rest"); no dot: (name, "")

def cut source · line 68 · raw

@name:String -> Pair(String, String)

Alias.rest cut at its first dot: ("Alias", "rest"); no dot: (name, "")

def fst source · line 72 · raw

@p:Pair(String, String) -> String

a pair's first

def snd source · line 77 · raw

@p:Pair(String, String) -> String

a pair's second

def rest source · line 86 · raw

@name:String -> String

the part after the first dot, "" when there is none

def run_of source · line 90 · raw

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

the leading run of name chars

def before source · line 98 · raw

@source:String -> @line:U32 -> @col:U32 -> String

the name that ends at (line, col): what is being typed, for completion