1package b
2
3import (
4 . "github.com/alecthomas/chroma" // nolint
5 "github.com/alecthomas/chroma/lexers/internal"
6)
7
8// Brainfuck lexer.
9var Brainfuck = internal.Register(MustNewLexer(
10 &Config{
11 Name: "Brainfuck",
12 Aliases: []string{"brainfuck", "bf"},
13 Filenames: []string{"*.bf", "*.b"},
14 MimeTypes: []string{"application/x-brainfuck"},
15 },
16 Rules{
17 "common": {
18 {`[.,]+`, NameTag, nil},
19 {`[+-]+`, NameBuiltin, nil},
20 {`[<>]+`, NameVariable, nil},
21 {`[^.,+\-<>\[\]]+`, Comment, nil},
22 },
23 "root": {
24 {`\[`, Keyword, Push("loop")},
25 {`\]`, Error, nil},
26 Include("common"),
27 },
28 "loop": {
29 {`\[`, Keyword, Push()},
30 {`\]`, Keyword, Pop(1)},
31 Include("common"),
32 },
33 },
34))