~/bend-docscommunity

src/rules/tokens.bend checks

raw source on the hub · import bolt@1.52.0.0/src/rules/tokens.bend as Tokens

src/rules/tokens: helpers the token rules share (put, escape, strings, chars, arms): significant tokens, Nat literals, case patterns, and a name's uses under a node.

4 imports
import Base
import ../lazy/lazy.bend as Lazy
import ../syntax/lex.bend as Lex
import ../syntax/tree.bend as Tree

Definitions

def sig source · line 10 · raw

@toks:List<&2, 0xfb394c8f685b7b3a6abb1443099643d8/src/syntax/lex.Tok> -> List<&2, 0xfb394c8f685b7b3a6abb1443099643d8/src/syntax/lex.Tok>

the tokens without space, newlines and comments

def code.cut source · line 19 · raw

@tt:String -> String

a text cut to its first char

def code.tok source · line 27 · raw

@tk:0xfb394c8f685b7b3a6abb1443099643d8/src/syntax/lex.Tok -> 0xfb394c8f685b7b3a6abb1443099643d8/src/syntax/lex.Tok

a string literal cut to its opening quote; any other token as it is

def code.toks source · line 33 · raw

@ts:List<&2, 0xfb394c8f685b7b3a6abb1443099643d8/src/syntax/lex.Tok> -> List<&2, 0xfb394c8f685b7b3a6abb1443099643d8/src/syntax/lex.Tok>

the tokens, each string literal cut to its opening quote

def code source · line 42 · raw

@+tt:String -> String

a text with each string literal cut to its opening quote: what of it is code, as the lexer reads it

def nat_ok source · line 46 · raw

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

digits, then one final n: a Nat literal's chars

def digits_ok source · line 56 · raw

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

digits alone, one or more: a U32 literal's chars

def stem source · line 66 · raw

@+tt:String -> String

the text without its last char (a Nat literal's digits)

def nat_value source · line 70 · raw

@+tt:String -> Maybe<&2, U32>

a Nat literal's value (12n is 12); none for anything else or past U32

def width source · line 74 · raw

@tt:String -> U32

a text's width in chars

def keyword source · line 78 · raw

@nn:0xfb394c8f685b7b3a6abb1443099643d8/src/syntax/tree.Node -> @+word:String -> Bool

is the first node the keyword?

def pattern source · line 87 · raw

@kids:0xfb394c8f685b7b3a6abb1443099643d8/src/syntax/tree.Node -> 0xfb394c8f685b7b3a6abb1443099643d8/src/syntax/tree.Node

a case statement's pattern (its tokens after case, the colon and an inline body included)