1 package m
2
3 import (
4 . "github.com/alecthomas/chroma"
5 "github.com/alecthomas/chroma/lexers/internal"
6 )
7
8
9 var MZN = internal.Register(MustNewLazyLexer(
10 &Config{
11 Name: "MiniZinc",
12 Aliases: []string{"minizinc", "MZN", "mzn"},
13 Filenames: []string{"*.mzn", "*.dzn", "*.fzn"},
14 MimeTypes: []string{"text/minizinc"},
15 },
16 mznRules,
17 ))
18
19 func mznRules() Rules {
20 return Rules{
21 "root": {
22 {`\n`, Text, nil},
23 {`\s+`, Text, nil},
24 {`\\\n`, Text, nil},
25 {`\%(.*?)\n`, CommentSingle, nil},
26 {`/(\\\n)?[*](.|\n)*?[*](\\\n)?/`, CommentMultiline, nil},
27 {`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
28 {Words(`\b`, `\b`, `ann`, `annotation`, `any`, `constraint`, `function`, `include`, `list`, `of`, `op`, `output`, `minimize`, `maximize`, `par`, `predicate`, `record`, `satisfy`, `solve`, `test`, `type`, `var`), Keyword, nil},
29 {Words(`\b`, `\b`, `array`, `set`, `bool`, `enum`, `float`, `int`, `string`, `tuple`), KeywordType, nil},
30 {Words(`\b`, `\b`, `for`, `forall`, `if`, `then`, `else`, `endif`, `where`), Keyword, nil},
31 {Words(`\b`, `\b`, `abort`, `abs`, `acosh`, `array_intersect`, `array_union`, `array1d`, `array2d`, `array3d`, `array4d`, `array5d`, `array6d`, `asin`, `assert`, `atan`, `bool2int`, `card`, `ceil`, `concat`, `cos`, `cosh`, `dom`, `dom_array`, `dom_size`, `fix`, `exp`, `floor`, `index_set`, `index_set_1of2`, `index_set_2of2`, `index_set_1of3`, `index_set_2of3`, `index_set_3of3`, `int2float`, `is_fixed`, `join`, `lb`, `lb_array`, `length`, `ln`, `log`, `log2`, `log10`, `min`, `max`, `pow`, `product`, `round`, `set2array`, `show`, `show_int`, `show_float`, `sin`, `sinh`, `sqrt`, `sum`, `tan`, `tanh`, `trace`, `ub`, `ub_array`), NameBuiltin, nil},
32 {`(not|<->|->|<-|\\/|xor|/\\)`, Operator, nil},
33 {`(<|>|<=|>=|==|=|!=)`, Operator, nil},
34 {`(\+|-|\*|/|div|mod)`, Operator, nil},
35 {Words(`\b`, `\b`, `in`, `subset`, `superset`, `union`, `diff`, `symdiff`, `intersect`), Operator, nil},
36 {`(\\|\.\.|\+\+)`, Operator, nil},
37 {`[|()\[\]{},:;]`, Punctuation, nil},
38 {`(true|false)\b`, KeywordConstant, nil},
39 {`([+-]?)\d+(\.(?!\.)\d*)?([eE][-+]?\d+)?`, LiteralNumber, nil},
40 {`::\s*([^\W\d]\w*)(\s*\([^\)]*\))?`, NameDecorator, nil},
41 {`\b([^\W\d]\w*)\b(\()`, ByGroups(NameFunction, Punctuation), nil},
42 {`[^\W\d]\w*`, NameOther, nil},
43 },
44 }
45 }
46
View as plain text