Source file tm_grammar_cram.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
let lang_id = "cram"
let json = {json|{
  "scopeName": "source.cram",
  "fileTypes": ["t"],
  "patterns": [
    {
      "comment": "command",
      "match": "^  (\\$|>) (.*)$",
      "captures": {
        "1": { "name": "keyword.operator.cram" },
        "2": {
          "name": "source.cram",
          "patterns": [{ "include": "#escape" }, { "include": "#strings" }]
        }
      }
    },
    {
      "comment": "***** UNREACHABLE *****",
      "match": "^  (\\*\\*\\*\\*\\*[[:space:]]UNREACHABLE[[:space:]]\\*\\*\\*\\*\\*)$",
      "captures": {
        "1": { "name": "invalid.unreachable.cram" }
      }
    },
    {
      "comment": "regex output",
      "match": "^  (.*) \\((re)\\)$",
      "captures": {
        "1": {
          "name": "string.other.cram",
          "patterns": [{ "include": "#regex" }]
        },
        "2": { "name": "keyword.other.cram" }
      }
    },
    {
      "comment": "glob output",
      "match": "^  (.*) \\((glob)\\)$",
      "captures": {
        "1": {
          "name": "string.other.cram",
          "patterns": [{ "include": "#glob" }]
        },
        "2": { "name": "keyword.other.cram" }
      }
    },
    {
      "comment": "no end-of-line output",
      "match": "^  (.*) \\((no-eol)\\)$",
      "captures": {
        "1": { "name": "string.other.cram" },
        "2": { "name": "keyword.other.cram" }
      }
    },
    {
      "comment": "escaped output",
      "match": "^  (.*) \\((esc)\\)$",
      "captures": {
        "1": {
          "name": "string.other.cram",
          "patterns": [{ "include": "#escape" }]
        },
        "2": { "name": "keyword.other.cram" }
      }
    },
    {
      "comment": "output",
      "match": "^  (.*)$",
      "captures": {
        "1": { "name": "string.other.cram" }
      }
    },
    {
      "comment": "everything else is a comment",
      "name": "comment.line.cram",
      "match": "^.*$"
    }
  ],
  "repository": {
    "escape": {
      "patterns": [
        {
          "comment": "octal escape",
          "name": "constant.character.escape.cram",
          "match": "\\\\0[[:digit:]]+"
        },
        {
          "comment": "hex escape",
          "name": "constant.character.escape.cram",
          "match": "\\\\x[[:xdigit:]]{2}"
        },
        {
          "comment": "other escaped character",
          "name": "constant.character.escape.cram",
          "match": "\\\\."
        }
      ]
    },
    "strings": {
      "patterns": [
        {
          "name": "string.quoted.double.cram",
          "begin": "\"",
          "end": "\"|$",
          "patterns": [{ "include": "#escape" }]
        },
        {
          "name": "string.quoted.single.cram",
          "begin": "'",
          "end": "'|$",
          "patterns": [{ "include": "#escape" }]
        }
      ]
    },
    "glob": {
      "patterns": [
        {
          "name": "keyword.other.cram",
          "match": "[*?]"
        },
        {
          "name": "keyword.other.cram",
          "match": "\\\\[*?\\\\]"
        }
      ]
    },
    "regex": {
      "patterns": [
        {
          "name": "keyword.other.regex",
          "match": "\\\\."
        },
        {
          "name": "keyword.other.regex",
          "match": "[|^$]"
        },
        {
          "begin": "\\[\\^?",
          "end": "\\]",
          "beginCaptures": [{ "name": "keyword.other.regex" }],
          "endCaptures": [{ "name": "keyword.other.regex" }],
          "contentName": "source.regex",
          "patterns": [{ "name": "keyword.other.regex", "match": "-" }]
        },
        {
          "begin": "\\((\\?[:=!])?",
          "end": "\\)",
          "beginCaptures": [{ "name": "keyword.other.regex" }],
          "endCaptures": [{ "name": "keyword.other.regex" }],
          "contentName": "source.regex",
          "patterns": [{ "include": "#regex" }]
        },
        {
          "begin": "{",
          "end": "}",
          "beginCaptures": [{ "name": "keyword.other.regex" }],
          "endCaptures": [{ "name": "keyword.other.regex" }],
          "contentName": "source.regex",
          "patterns": [
            {
              "name": "constant.numeric.decimal.integer.regex",
              "match": "[[:digit:]]+"
            }
          ]
        }
      ]
    }
  }
}|json}