1package m
2
3import (
4 . "github.com/alecthomas/chroma" // nolint
5 "github.com/alecthomas/chroma/lexers/internal"
6)
7
8// Mathematica lexer.
9var Mathematica = internal.Register(MustNewLexer(
10 &Config{
11 Name: "Mathematica",
12 Aliases: []string{"mathematica", "mma", "nb"},
13 Filenames: []string{"*.nb", "*.cdf", "*.nbp", "*.ma"},
14 MimeTypes: []string{"application/mathematica", "application/vnd.wolfram.mathematica", "application/vnd.wolfram.mathematica.package", "application/vnd.wolfram.cdf"},
15 },
16 Rules{
17 "root": {
18 {`(?s)\(\*.*?\*\)`, Comment, nil},
19 {"([a-zA-Z]+[A-Za-z0-9]*`)", NameNamespace, nil},
20 {`([A-Za-z0-9]*_+[A-Za-z0-9]*)`, NameVariable, nil},
21 {`#\d*`, NameVariable, nil},
22 {`([a-zA-Z]+[a-zA-Z0-9]*)`, Name, nil},
23 {`-?\d+\.\d*`, LiteralNumberFloat, nil},
24 {`-?\d*\.\d+`, LiteralNumberFloat, nil},
25 {`-?\d+`, LiteralNumberInteger, nil},
26 {Words(``, ``, `;;`, `=`, `=.`, `!===`, `:=`, `->`, `:>`, `/.`, `+`, `-`, `*`, `/`, `^`, `&&`, `||`, `!`, `<>`, `|`, `/;`, `?`, `@`, `//`, `/@`, `@@`, `@@@`, `~~`, `===`, `&`, `<`, `>`, `<=`, `>=`), Operator, nil},
27 {Words(``, ``, `,`, `;`, `(`, `)`, `[`, `]`, `{`, `}`), Punctuation, nil},
28 {`".*?"`, LiteralString, nil},
29 {`\s+`, TextWhitespace, nil},
30 },
31 },
32))