~/bend-docscommunity

token.bend checks

raw source on the hub · import bend-osdev-apparmor@0.1.0.0/token.bend as Token

bend-osdev-apparmor: the profile language's tokens (apparmor.d(5), "FORMAT"), and the terms a rule is written in.

Tokens: words, quoted strings, { } ( ) and the comma that ends a rule. '#' at the start of a token begins a comment to the end of the line, except "#include". Inside a word a '{' ... '}' group is part of the word (a glob), so are ',' inside it and a ',' followed by a word character; a word ends at white space, a '"', a ',' before white space, the end, '}', ')', '#' or ',', a '(' after '=', a ')' inside parentheses, and a '}' outside a group.

Terms: a rule's tokens read as words, quoted strings, parenthesised lists, conditions key=value and the arrow ->.

2 imports
import Base
import ./text.bend as X

Types

type AaTok source · line 16 · raw

Data

type AaLxMode source · line 62 · raw

Data

type AaLex source · line 71 · raw

Data

mode, current line, parenthesis depth, tokens (last first), still well formed, and the line of the first fault

type AaLxCh source · line 74 · raw

Data

type AaTerm source · line 366 · raw

Data

type AaKV source · line 381 · raw

Data

a condition's key and the text after its '='

type AaTmFrame source · line 402 · raw

Data

the builder: a stack of open lists (innermost first), each its terms (last first) and a key waiting for its value

type AaTmB source · line 405 · raw

Data

Definitions

def AaTok.line source · line 25 · raw

@t:AaTok -> U32

def AaTok.is source · line 43 · raw

@t:AaTok -> @s:String -> Bool

the token is the word s

def AaLxCh.ws source · line 86 · raw

@+h:U32 -> Bool

def AaLxCh.of source · line 89 · raw

@+h:U32 -> AaLxCh

def AaLxCh.ends source · line 93 · raw

@+n:U32 -> Bool

a character after which a ',' ends a word: white space, the end, '}', ')', '#', ','

def AaLex.fail source · line 96 · raw

@st:AaLex -> AaLex

def AaLex.mode source · line 101 · raw

@st:AaLex -> @m:AaLxMode -> AaLex

def AaLex.push source · line 106 · raw

@st:AaLex -> @t:AaTok -> AaLex

def AaLex.line source · line 111 · raw

@st:AaLex -> U32

def AaLex.pdepth source · line 116 · raw

@st:AaLex -> Nat

def AaLex.bump source · line 122 · raw

@st:AaLex -> AaLex

one more line, the mode unchanged

def AaLex.newline source · line 127 · raw

@st:AaLex -> AaLex

def AaLex.open_paren source · line 130 · raw

@st:AaLex -> AaLex

def AaLex.close_paren.go source · line 135 · raw

@p:Nat -> @st:AaLex -> AaLex

def AaLex.close_paren source · line 144 · raw

@+st:AaLex -> AaLex

def AaLex.after_arrow source · line 149 · raw

@st:AaLex -> Bool

the last token is the word "->": a '{' after it starts a pattern (change_profile -> {a,b}), not a block

def AaLex.open source · line 158 · raw

@+st:AaLex -> AaLex

def AaLex.space.go source · line 162 · raw

@k:AaLxCh -> @+st:AaLex -> @h:U32 -> AaLex

a character between tokens

def AaLex.space source · line 185 · raw

@st:AaLex -> @+h:U32 -> AaLex

def AaLex.word_end source · line 189 · raw

@+st:AaLex -> @acc:List<&2, U32> -> AaLex

the word in acc (last character first) ends

def AaLex.keep source · line 192 · raw

@st:AaLex -> @acc:List<&2, U32> -> @depth:Nat -> @h:U32 -> AaLex

def AaLex.word.comma source · line 195 · raw

@keep:Bool -> @+st:AaLex -> @acc:List<&2, U32> -> @depth:Nat -> @h:U32 -> AaLex

def AaLex.word.lp source · line 203 · raw

@split:Bool -> @st:AaLex -> @acc:List<&2, U32> -> @depth:Nat -> @h:U32 -> AaLex

def AaLex.word.rp source · line 210 · raw

@split:Bool -> @st:AaLex -> @acc:List<&2, U32> -> @depth:Nat -> @h:U32 -> AaLex

def AaLex.word.close source · line 217 · raw

@depth:Nat -> @st:AaLex -> @acc:List<&2, U32> -> @h:U32 -> AaLex

def AaLex.word.go source · line 225 · raw

@k:AaLxCh -> @+st:AaLex -> @+acc:List<&2, U32> -> @+depth:Nat -> @+h:U32 -> @+next:U32 -> AaLex

def AaLex.quote.go source · line 248 · raw

@esc:Bool -> @+st:AaLex -> @+acc:List<&2, U32> -> @+h:U32 -> AaLex

def AaLex.inc source · line 256 · raw

@n:Nat -> U32

the letters of "include"

def AaLex.comment source · line 283 · raw

@+st:AaLex -> @+h:U32 -> AaLex

def AaLex.hash.go source · line 286 · raw

@more:Bool -> @+st:AaLex -> @+n:Nat -> @+h:U32 -> AaLex

def AaLex.step.mode source · line 293 · raw

@m:AaLxMode -> @+st:AaLex -> @+h:U32 -> @+next:U32 -> AaLex

def AaLex.step source · line 306 · raw

@st:AaLex -> @+h:U32 -> @+next:U32 -> AaLex

def AaLex.finish.go source · line 311 · raw

@m:AaLxMode -> @+st:AaLex -> AaLex

def AaLex.finish.paren source · line 324 · raw

@p:Nat -> @st:AaLex -> AaLex

def AaLex.finish source · line 331 · raw

@st:AaLex -> AaLex

def AaLex.run source · line 337 · raw

@xs:List<&2, U32> -> @st:AaLex -> AaLex

def AaTok.rev_onto source · line 344 · raw

@xs:List<&2, AaTok> -> @acc:List<&2, AaTok> -> List<&2, AaTok>

def AaLex.result source · line 351 · raw

@st:AaLex -> Result<&2, &2, U32, List<&2, AaTok>>

def AaTok.lex source · line 361 · raw

@xs:List<&2, U32> -> Result<&2, &2, U32, List<&2, AaTok>>

the tokens of a text, or the line of its first fault

def AaTerm.key_char source · line 374 · raw

@+c:U32 -> Bool

a character of a condition's key: a letter, a digit, '_' or '.'

def AaTerm.letter source · line 377 · raw

@+c:U32 -> Bool

def AaTerm.split.go source · line 385 · raw

@xs:List<&2, U32> -> @+acc:List<&2, U32> -> Maybe<&2, AaKV>

key=rest: the key (last character first) read so far

def AaTerm.split source · line 393 · raw

@xs:List<&2, U32> -> Maybe<&2, AaKV>

a word key=rest, split, when the key is a letter then key characters

def AaTmB.fail source · line 408 · raw

@b:AaTmB -> AaTmB

def AaTmFrame.add source · line 413 · raw

@f:AaTmFrame -> @t:AaTerm -> AaTmFrame

def AaTmB.add source · line 422 · raw

@b:AaTmB -> @t:AaTerm -> AaTmB

def AaTmFrame.set_key source · line 431 · raw

@f:AaTmFrame -> @k:List<&2, U32> -> Maybe<&2, AaTmFrame>

def AaTmB.key.go source · line 440 · raw

@m:Maybe<&2, AaTmFrame> -> @rest:List<&2, AaTmFrame> -> @ok:Bool -> AaTmB

def AaTmB.key source · line 447 · raw

@b:AaTmB -> @k:List<&2, U32> -> AaTmB

def AaTmB.cond.go source · line 456 · raw

@r:List<&2, U32> -> @b:AaTmB -> @k:List<&2, U32> -> AaTmB

def AaTmB.cond source · line 463 · raw

@m:Maybe<&2, AaKV> -> @b:AaTmB -> @w:List<&2, U32> -> AaTmB

def AaTmB.word source · line 472 · raw

@+b:AaTmB -> @+w:List<&2, U32> -> AaTmB

def AaTmB.open source · line 475 · raw

@b:AaTmB -> AaTmB

def AaTerm.rev_onto source · line 480 · raw

@xs:List<&2, AaTerm> -> @acc:List<&2, AaTerm> -> List<&2, AaTerm>

def AaTmB.close source · line 487 · raw

@b:AaTmB -> AaTmB

def AaTmB.comma source · line 503 · raw

@b:AaTmB -> AaTmB

inside parentheses a comma separates; elsewhere it is out of place

def AaTmB.step source · line 516 · raw

@b:AaTmB -> @t:AaTok -> AaTmB

def AaTmB.run source · line 533 · raw

@ts:List<&2, AaTok> -> @b:AaTmB -> AaTmB

def AaTmB.result source · line 540 · raw

@b:AaTmB -> Maybe<&2, List<&2, AaTerm>>

def AaTerm.of_toks source · line 564 · raw

@ts:List<&2, AaTok> -> Maybe<&2, List<&2, AaTerm>>

a statement's tokens as terms, or None if its parentheses or conditions are malformed

def AaTerm.is source · line 569 · raw

@t:AaTerm -> @s:String -> Bool

def AaTerm.is_one_of source · line 582 · raw

@t:AaTerm -> @ns:List<&2, String> -> Bool

def AaTerm.text source · line 596 · raw

@t:AaTerm -> Maybe<&2, List<&2, U32>>

a word or quoted string's text

def AaTerm.texts.cons source · line 610 · raw

@a:Maybe<&2, List<&2, U32>> -> @b:Maybe<&2, List<&2, List<&2, U32>>> -> Maybe<&2, List<&2, List<&2, U32>>>

the texts of a value: one word or string, or the words and strings of a list

def AaTerm.texts.go source · line 621 · raw

@xs:List<&2, AaTerm> -> Maybe<&2, List<&2, List<&2, U32>>>

def AaTerm.texts source · line 628 · raw

@t:AaTerm -> Maybe<&2, List<&2, List<&2, U32>>>

def AaTerm.is_arrow source · line 641 · raw

@t:AaTerm -> Bool