json/lex.bend checks
raw source on the hub · import cswap-bend-cli@0.1.0.0/json/lex.bend as Lex
1 import
import Base
Types
type Tok source · line 3 · raw
Data
TLBraceTok
TRBraceTok
TLBrackTok
TRBrackTok
TColonTok
TCommaTok
TNullTok
TTrueTok
TFalseTok
TNum@text:String -> Tok
TStr@s:String -> Tok
TSkipTok
TErr@msg:String -> Tok
Definitions
def sel source · line 18 · raw
@c:Bool -> @x:U32 -> @y:U32 -> U32
def sel.s source · line 25 · raw
@c:Bool -> @x:String -> @y:String -> String
def sel.n source · line 32 · raw
@c:Bool -> @x:Nat -> @y:Nat -> Nat
def not source · line 39 · raw
@b:Bool -> Bool
def eqc source · line 42 · raw
@+c:Char -> @+d:Char -> Bool
def is_word source · line 47 · raw
@+c:Char -> Bool
def head_word source · line 50 · raw
@s:String -> Bool
def span_word source · line 58 · raw
@s:String -> @ok:Bool -> Nat
Leading run of word characters.
def span_str source · line 66 · raw
@s:String -> @live:Bool -> @+esc:Bool -> Nat
Chars through the closing quote (or to the end when it is missing).
def num.next2 source · line 73 · raw
@+st:U32 -> @+d:Bool -> @+z:Bool -> @+dot:Bool -> @+ex:Bool -> @+sign:Bool -> @+minus:Bool -> U32
def num.next source · line 87 · raw
@+st:U32 -> @+c:Char -> U32
JSON number grammar as a state machine: 0 start, 1 after -, 2 after 0, 3 int digits, 4 after ., 5 frac digits, 6 after e, 7 after exp sign, 8 exp digits, 99 dead. 2, 3, 5 and 8 accept.
def num.run source · line 90 · raw
@s:String -> @+st:U32 -> U32
def num.acc source · line 97 · raw
@+st:U32 -> Bool
def num.ok source · line 100 · raw
@+s:String -> Bool
def word.num source · line 104 · raw
@ok:Bool -> @w:String -> Tok
What a bare word is: null, true, false, a number, or an error.
def word.pick source · line 111 · raw
@n:Bool -> @t:Bool -> @f:Bool -> @special:Bool -> @+w:String -> Tok
def word.tok source · line 124 · raw
@+w:String -> Tok
def hv source · line 130 · raw
@+c:U32 -> U32
def cc.pick source · line 136 · raw
@m:Maybe<&2, Char> -> U32
Code of the char at index i; 0 past the end.
def cc source · line 143 · raw
@+s:String -> @i:Nat -> U32
def hex4.fin source · line 146 · raw
@+a:U32 -> @+b:U32 -> @+c:U32 -> @+d:U32 -> U32
def hex4 source · line 151 · raw
@+s:String -> U32
The four hex digits at the head of s as a number; U+FFFD when malformed.
def is_hi source · line 154 · raw
@+u:U32 -> Bool
def is_lo source · line 157 · raw
@+u:U32 -> Bool
def pair.ok source · line 161 · raw
@+u1:U32 -> @+t5:String -> Bool
After \uD83D: is the next escape a \uDC00..\uDFFF low half?
def pair.cp source · line 164 · raw
@+u1:U32 -> @+t5:String -> U32
def esc.u2 source · line 167 · raw
@+u1:U32 -> @+t5:String -> U32
def esc.u source · line 170 · raw
@+t:String -> U32
def esc.cp2 source · line 173 · raw
@+e:U32 -> @+t:String -> U32
def esc.cp source · line 183 · raw
@+c:U32 -> @+t:String -> U32
The code point a char (or the escape it starts) stands for.
def esc.sk2 source · line 186 · raw
@+e:U32 -> @+t:String -> U32
def esc.skip source · line 190 · raw
@+c:U32 -> @+t:String -> Nat
Chars after the first that the escape consumes.
def unescape source · line 194 · raw
@fuel:Nat -> @s:String -> String
Decode the escapes of a string body. fuel is its length.
def str.closed source · line 205 · raw
@s:String -> @live:Bool -> @+esc:Bool -> Bool
def str.pick source · line 212 · raw
@closed:Bool -> @+body:String -> Tok
def str.tok source · line 220 · raw
@+t:String -> Tok
t follows the opening quote.
def tk.sel source · line 223 · raw
@c:Bool -> @t:Tok -> @rest:Tok -> Tok
def punct.pick source · line 230 · raw
@lb:Bool -> @rb:Bool -> @ls:Bool -> @rs:Bool -> @co:Bool -> @cm:Bool -> @ws:Bool -> Tok
def punct.tok source · line 233 · raw
@+c:Char -> Tok
def tok.of2 source · line 236 · raw
@q:Bool -> @w:Bool -> @+c:Char -> @+t:String -> Tok
def tok.of source · line 245 · raw
@+c:Char -> @+t:String -> Tok
def tok.adv source · line 248 · raw
@+c:Char -> @+t:String -> Nat
def tok.cons source · line 251 · raw
@t:Tok -> @rest:List<&2, Tok> -> List<&2, Tok>
def lex source · line 259 · raw
@fuel:Nat -> @s:String -> List<&2, Tok>
Tokens of s. fuel is its length.