1package e
2
3import (
4 . "github.com/alecthomas/chroma" // nolint
5 "github.com/alecthomas/chroma/lexers/internal"
6)
7
8// Ebnf lexer.
9var Ebnf = internal.Register(MustNewLexer(
10 &Config{
11 Name: "EBNF",
12 Aliases: []string{"ebnf"},
13 Filenames: []string{"*.ebnf"},
14 MimeTypes: []string{"text/x-ebnf"},
15 },
16 Rules{
17 "root": {
18 Include("whitespace"),
19 Include("comment_start"),
20 Include("identifier"),
21 {`=`, Operator, Push("production")},
22 },
23 "production": {
24 Include("whitespace"),
25 Include("comment_start"),
26 Include("identifier"),
27 {`"[^"]*"`, LiteralStringDouble, nil},
28 {`'[^']*'`, LiteralStringSingle, nil},
29 {`(\?[^?]*\?)`, NameEntity, nil},
30 {`[\[\]{}(),|]`, Punctuation, nil},
31 {`-`, Operator, nil},
32 {`;`, Punctuation, Pop(1)},
33 {`\.`, Punctuation, Pop(1)},
34 },
35 "whitespace": {
36 {`\s+`, Text, nil},
37 },
38 "comment_start": {
39 {`\(\*`, CommentMultiline, Push("comment")},
40 },
41 "comment": {
42 {`[^*)]`, CommentMultiline, nil},
43 Include("comment_start"),
44 {`\*\)`, CommentMultiline, Pop(1)},
45 {`[*)]`, CommentMultiline, nil},
46 },
47 "identifier": {
48 {`([a-zA-Z][\w \-]*)`, Keyword, nil},
49 },
50 },
51))