package tm-grammars

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file tm_grammar_verilog.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
let lang_id = "verilog"
let json = {json|{
  "displayName": "Verilog",
  "fileTypes": [
    "v",
    "vh"
  ],
  "name": "verilog",
  "patterns": [
    {
      "include": "#comments"
    },
    {
      "include": "#module_pattern"
    },
    {
      "include": "#keywords"
    },
    {
      "include": "#constants"
    },
    {
      "include": "#strings"
    },
    {
      "include": "#operators"
    }
  ],
  "repository": {
    "comments": {
      "patterns": [
        {
          "begin": "(^[\\t ]+)?(?=//)",
          "beginCaptures": {
            "1": {
              "name": "punctuation.whitespace.comment.leading.verilog"
            }
          },
          "end": "(?!\\G)",
          "patterns": [
            {
              "begin": "//",
              "beginCaptures": {
                "0": {
                  "name": "punctuation.definition.comment.verilog"
                }
              },
              "end": "\\n",
              "name": "comment.line.double-slash.verilog"
            }
          ]
        },
        {
          "begin": "/\\*",
          "end": "\\*/",
          "name": "comment.block.c-style.verilog"
        }
      ]
    },
    "constants": {
      "patterns": [
        {
          "match": "`(?!(celldefine|endcelldefine|default_nettype|define|undef|ifdef|ifndef|else|endif|include|resetall|timescale|unconnected_drive|nounconnected_drive))[A-Z_a-z][$0-9A-Z_a-z]*",
          "name": "variable.other.constant.verilog"
        },
        {
          "match": "[0-9]*'[BDHObdho][XZ_xz\\h]+\\b",
          "name": "constant.numeric.sized_integer.verilog"
        },
        {
          "captures": {
            "1": {
              "name": "constant.numeric.integer.verilog"
            },
            "2": {
              "name": "punctuation.separator.range.verilog"
            },
            "3": {
              "name": "constant.numeric.integer.verilog"
            }
          },
          "match": "\\b(\\d+)(:)(\\d+)\\b",
          "name": "meta.block.numeric.range.verilog"
        },
        {
          "match": "\\b\\d[_\\d]*(?i:e\\d+)?\\b",
          "name": "constant.numeric.integer.verilog"
        },
        {
          "match": "\\b\\d+\\.\\d+(?i:e\\d+)?\\b",
          "name": "constant.numeric.real.verilog"
        },
        {
          "match": "#\\d+",
          "name": "constant.numeric.delay.verilog"
        },
        {
          "match": "\\b[01XZxz]+\\b",
          "name": "constant.numeric.logic.verilog"
        }
      ]
    },
    "instantiation_patterns": {
      "patterns": [
        {
          "include": "#keywords"
        },
        {
          "begin": "^\\s*(?!always|and|assign|output|input|inout|wire|module)([A-Za-z][0-9A-Z_a-z]*)\\s+([A-Za-z][0-9A-Z_a-z]*)(?<!begin|if)\\s*(?=\\(|$)",
          "beginCaptures": {
            "1": {
              "name": "entity.name.tag.module.reference.verilog"
            },
            "2": {
              "name": "entity.name.tag.module.identifier.verilog"
            }
          },
          "end": ";",
          "endCaptures": {
            "0": {
              "name": "punctuation.terminator.expression.verilog"
            }
          },
          "name": "meta.block.instantiation.parameterless.verilog",
          "patterns": [
            {
              "include": "#comments"
            },
            {
              "include": "#constants"
            },
            {
              "include": "#strings"
            }
          ]
        },
        {
          "begin": "^\\s*([A-Za-z][0-9A-Z_a-z]*)\\s*(#)(?=\\s*\\()",
          "beginCaptures": {
            "1": {
              "name": "entity.name.tag.module.reference.verilog"
            }
          },
          "end": ";",
          "endCaptures": {
            "0": {
              "name": "punctuation.terminator.expression.verilog"
            }
          },
          "name": "meta.block.instantiation.with.parameters.verilog",
          "patterns": [
            {
              "include": "#parenthetical_list"
            },
            {
              "match": "[A-Za-z][0-9A-Z_a-z]*",
              "name": "entity.name.tag.module.identifier.verilog"
            }
          ]
        }
      ]
    },
    "keywords": {
      "patterns": [
        {
          "match": "\\b(always|and|assign|attribute|begin|buf|bufif0|bufif1|case[xz]?|cmos|deassign|default|defparam|disable|edge|else|end(attribute|case|function|generate|module|primitive|specify|table|task)?|event|for|force|forever|fork|function|generate|genvar|highz(01)|if(none)?|initial|inout|input|integer|join|localparam|medium|module|large|macromodule|nand|negedge|nmos|nor|not|notif(01)|or|output|parameter|pmos|posedge|primitive|pull0|pull1|pulldown|pullup|rcmos|real|realtime|reg|release|repeat|rnmos|rpmos|rtran|rtranif(01)|scalared|signed|small|specify|specparam|strength|strong0|strong1|supply0|supply1|table|task|time|tran|tranif(01)|tri(01)?|tri(and|or|reg)|unsigned|vectored|wait|wand|weak(01)|while|wire|wor|xnor|xor)\\b",
          "name": "keyword.other.verilog"
        },
        {
          "match": "^\\s*`((cell)?define|default_(decay_time|nettype|trireg_strength)|delay_mode_(path|unit|zero)|ifdef|ifndef|include|end(if|celldefine)|else|(no)?unconnected_drive|resetall|timescale|undef)\\b",
          "name": "keyword.other.compiler.directive.verilog"
        },
        {
          "match": "\\$(f(open|close)|readmem([bh])|timeformat|printtimescale|stop|finish|(s|real)?time|realtobits|bitstoreal|rtoi|itor|(f)?(display|write([bh])))\\b",
          "name": "support.function.system.console.tasks.verilog"
        },
        {
          "match": "\\$(random|dist_(chi_square|erlang|exponential|normal|poisson|t|uniform))\\b",
          "name": "support.function.system.random_number.tasks.verilog"
        },
        {
          "match": "\\$((a)?sync\\$((n)?and|(n)or)\\$(array|plane))\\b",
          "name": "support.function.system.pld_modeling.tasks.verilog"
        },
        {
          "match": "\\$(q_(initialize|add|remove|full|exam))\\b",
          "name": "support.function.system.stochastic.tasks.verilog"
        },
        {
          "match": "\\$(hold|nochange|period|recovery|setup(hold)?|skew|width)\\b",
          "name": "support.function.system.timing.tasks.verilog"
        },
        {
          "match": "\\$(dump(file|vars|off|on|all|limit|flush))\\b",
          "name": "support.function.system.vcd.tasks.verilog"
        },
        {
          "match": "\\$(countdrivers|list|input|scope|showscopes|(no)?(key|log)|reset(_(?:count|value))?|(inc)?save|restart|showvars|getpattern|sreadmem([bh])|scale)",
          "name": "support.function.non-standard.tasks.verilog"
        }
      ]
    },
    "module_pattern": {
      "patterns": [
        {
          "begin": "\\b(module)\\s+([A-Za-z][0-9A-Z_a-z]*)",
          "beginCaptures": {
            "1": {
              "name": "storage.type.module.verilog"
            },
            "2": {
              "name": "entity.name.type.module.verilog"
            }
          },
          "end": "\\bendmodule\\b",
          "endCaptures": {
            "0": {
              "name": "storage.type.module.verilog"
            }
          },
          "name": "meta.block.module.verilog",
          "patterns": [
            {
              "include": "#comments"
            },
            {
              "include": "#keywords"
            },
            {
              "include": "#constants"
            },
            {
              "include": "#strings"
            },
            {
              "include": "#instantiation_patterns"
            },
            {
              "include": "#operators"
            }
          ]
        }
      ]
    },
    "operators": {
      "patterns": [
        {
          "match": "[-%*+/]|([<>])=?|([!=])?==?|!|&&?|\\|\\|?|\\^?~|~\\^?",
          "name": "keyword.operator.verilog"
        }
      ]
    },
    "parenthetical_list": {
      "patterns": [
        {
          "begin": "\\(",
          "beginCaptures": {
            "0": {
              "name": "punctuation.section.list.verilog"
            }
          },
          "end": "\\)",
          "endCaptures": {
            "0": {
              "name": "punctuation.section.list.verilog"
            }
          },
          "name": "meta.block.parenthetical_list.verilog",
          "patterns": [
            {
              "include": "#parenthetical_list"
            },
            {
              "include": "#comments"
            },
            {
              "include": "#keywords"
            },
            {
              "include": "#constants"
            },
            {
              "include": "#strings"
            }
          ]
        }
      ]
    },
    "strings": {
      "patterns": [
        {
          "begin": "\"",
          "end": "\"",
          "name": "string.quoted.double.verilog",
          "patterns": [
            {
              "match": "\\\\.",
              "name": "constant.character.escape.verilog"
            }
          ]
        }
      ]
    }
  },
  "scopeName": "source.verilog"
}|json}