1package n
2
3import (
4 . "github.com/alecthomas/chroma" // nolint
5 "github.com/alecthomas/chroma/lexers/internal"
6)
7
8// Newspeak lexer.
9var Newspeak = internal.Register(MustNewLexer(
10 &Config{
11 Name: "Newspeak",
12 Aliases: []string{"newspeak"},
13 Filenames: []string{"*.ns2"},
14 MimeTypes: []string{"text/x-newspeak"},
15 },
16 Rules{
17 "root": {
18 {`\b(Newsqueak2)\b`, KeywordDeclaration, nil},
19 {`'[^']*'`, LiteralString, nil},
20 {`\b(class)(\s+)(\w+)(\s*)`, ByGroups(KeywordDeclaration, Text, NameClass, Text), nil},
21 {`\b(mixin|self|super|private|public|protected|nil|true|false)\b`, Keyword, nil},
22 {`(\w+\:)(\s*)([a-zA-Z_]\w+)`, ByGroups(NameFunction, Text, NameVariable), nil},
23 {`(\w+)(\s*)(=)`, ByGroups(NameAttribute, Text, Operator), nil},
24 {`<\w+>`, CommentSpecial, nil},
25 Include("expressionstat"),
26 Include("whitespace"),
27 },
28 "expressionstat": {
29 {`(\d+\.\d*|\.\d+|\d+[fF])[fF]?`, LiteralNumberFloat, nil},
30 {`\d+`, LiteralNumberInteger, nil},
31 {`:\w+`, NameVariable, nil},
32 {`(\w+)(::)`, ByGroups(NameVariable, Operator), nil},
33 {`\w+:`, NameFunction, nil},
34 {`\w+`, NameVariable, nil},
35 {`\(|\)`, Punctuation, nil},
36 {`\[|\]`, Punctuation, nil},
37 {`\{|\}`, Punctuation, nil},
38 {`(\^|\+|\/|~|\*|<|>|=|@|%|\||&|\?|!|,|-|:)`, Operator, nil},
39 {`\.|;`, Punctuation, nil},
40 Include("whitespace"),
41 Include("literals"),
42 },
43 "literals": {
44 {`\$.`, LiteralString, nil},
45 {`'[^']*'`, LiteralString, nil},
46 {`#'[^']*'`, LiteralStringSymbol, nil},
47 {`#\w+:?`, LiteralStringSymbol, nil},
48 {`#(\+|\/|~|\*|<|>|=|@|%|\||&|\?|!|,|-)+`, LiteralStringSymbol, nil},
49 },
50 "whitespace": {
51 {`\s+`, Text, nil},
52 {`"[^"]*"`, Comment, nil},
53 },
54 },
55))