1package a
2
3import (
4 . "github.com/alecthomas/chroma" // nolint
5 "github.com/alecthomas/chroma/lexers/internal"
6)
7
8// Angular2 lexer.
9var Angular2 = internal.Register(MustNewLexer(
10 &Config{
11 Name: "Angular2",
12 Aliases: []string{"ng2"},
13 Filenames: []string{},
14 MimeTypes: []string{},
15 },
16 Rules{
17 "root": {
18 {`[^{([*#]+`, Other, nil},
19 {`(\{\{)(\s*)`, ByGroups(CommentPreproc, Text), Push("ngExpression")},
20 {`([([]+)([\w:.-]+)([\])]+)(\s*)(=)(\s*)`, ByGroups(Punctuation, NameAttribute, Punctuation, Text, Operator, Text), Push("attr")},
21 {`([([]+)([\w:.-]+)([\])]+)(\s*)`, ByGroups(Punctuation, NameAttribute, Punctuation, Text), nil},
22 {`([*#])([\w:.-]+)(\s*)(=)(\s*)`, ByGroups(Punctuation, NameAttribute, Punctuation, Operator), Push("attr")},
23 {`([*#])([\w:.-]+)(\s*)`, ByGroups(Punctuation, NameAttribute, Punctuation), nil},
24 },
25 "ngExpression": {
26 {`\s+(\|\s+)?`, Text, nil},
27 {`\}\}`, CommentPreproc, Pop(1)},
28 {`:?(true|false)`, LiteralStringBoolean, nil},
29 {`:?"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
30 {`:?'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil},
31 {`[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?`, LiteralNumber, nil},
32 {`[a-zA-Z][\w-]*(\(.*\))?`, NameVariable, nil},
33 {`\.[\w-]+(\(.*\))?`, NameVariable, nil},
34 {`(\?)(\s*)([^}\s]+)(\s*)(:)(\s*)([^}\s]+)(\s*)`, ByGroups(Operator, Text, LiteralString, Text, Operator, Text, LiteralString, Text), nil},
35 },
36 "attr": {
37 {`".*?"`, LiteralString, Pop(1)},
38 {`'.*?'`, LiteralString, Pop(1)},
39 {`[^\s>]+`, LiteralString, Pop(1)},
40 },
41 },
42))