~/bend-docscommunity

src/rules/tokens.bend checks

raw source on the hub · import 0x013e0f9a479bbebad5ed196725eede95/src/rules/tokens.bend as Tokens

src/rules/tokens: helpers the token rules share (put, escape, nat, strings, twice, arms): significant tokens, literal kinds, 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, 0x013e0f9a479bbebad5ed196725eede95/src/syntax/lex.Tok> -> List<&2, 0x013e0f9a479bbebad5ed196725eede95/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:0x013e0f9a479bbebad5ed196725eede95/src/syntax/lex.Tok -> 0x013e0f9a479bbebad5ed196725eede95/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, 0x013e0f9a479bbebad5ed196725eede95/src/syntax/lex.Tok> -> List<&2, 0x013e0f9a479bbebad5ed196725eede95/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 is_lit source · line 46 · raw

@kk:0x013e0f9a479bbebad5ed196725eede95/src/syntax/lex.TokKind -> Bool

a number, a char or a string literal?

def nat_ok source · line 58 · raw

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

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

def stem source · line 68 · raw

@+tt:String -> String

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

def nat_value source · line 72 · 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 76 · raw

@tt:String -> U32

a text's width in chars

def keyword source · line 80 · raw

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

is the first node the keyword?

def pattern source · line 89 · raw

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

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