-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
source.tlverilog.js
197 lines (195 loc) · 7.72 KB
/
source.tlverilog.js
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
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/adamint/tlv-vscode>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.tlv'],
names: ['tl-verilog'],
patterns: [
{
match:
'\\b(automatic|cell|config|deassign|defparam|design|disable|edge|endconfig|endgenerate|endspecify|endtable|endtask|event|generate|genvar|ifnone|incdir|instance|liblist|library|localparam|macromodule|negedge|noshowcancelled|posedge|pulsestyle_onevent|pulsestyle_ondetect|real|realtime|scalared|showcancelled|specify|specparam|table|task|time|use|vectored|new)\\b',
name: 'keyword.other.tlverilog'
},
{match: '@\\b(\\d+)\\b', name: 'entity.name.stage.tlverilog'},
{match: '\\|\\b([a-zA-Z0-9_]+)\\b', name: 'entity.name.pipe.tlverilog'},
{match: '\\t', name: 'invalid.illegal.tlverilog'},
{
match: '>([a-zA-Z][a-zA-Z0-9_]+)',
name: 'entity.name.hierarchy.tlverilog'
},
{match: '\\/([a-zA-Z0-9_]+)', name: 'entity.name.hierarchy.tlverilog'},
{
match: '\\?[\\$\\*][a-zA-Z0-9_]+',
name: 'keyword.control.conditional.tlverilog'
},
{
match: '\\$\\b([a-zA-Z_][a-zA-Z0-9_]+)\\b',
name: 'variable.other.tlverilog'
},
{match: '%([+-]\\d+|\\w+)', name: 'entity.name.alignment.tlverilog'},
{match: '\\b([mM]4\\+\\w+)', name: 'support.macro.tlverilog'},
{
match: '^\\s*\\\\(TLV.*|SV.*|m4_TLV_version.*)$',
name: 'keyword.region.tlverilog'
},
{match: '\\*\\b([a-zA-Z_][a-zA-Z0-9_]+)\\b', name: 'variable.sv.tlverilog'},
{
match: '\\#\\b([a-zA-Z_][a-zA-Z0-9_]+)\\b',
name: 'constant.other.tlverilog'
},
{
match: '(<<|<>|>>-?)[a-zA-Z0-9_]+',
name: 'entity.name.alignment.tlverilog'
},
{
match: '\\b(#|@|begin|end|fork|join|join_any|join_none|forkjoin|{|})\\b',
name: 'keyword.other.tlverilog'
},
{
match:
'\\b(initial|always|wait|force|release|assign|always_comb|always_ff|always_latch|forever|repeat|while|for|if|iff|else|case|casex|casez|default|endcase|return|break|continue|do|foreach|randomize|with|inside|dist|clocking|cover|coverpoint|property|bins|binsof|illegal_bins|ignore_bins|randcase|modport|matches|solve|static|assert|assume|before|expect|bind|extends|sequence|var|cross|ref|first_match|srandom|time|struct|packed|final|chandle|alias|tagged|extern|throughout|timeprecision|timeunit|priority|type|union|unique|uwire|wait_order|triggered|randsequence|import|export|context|pure|intersect|wildcard|within|virtual|local|const|typedef|enum|protected|this|super|endmodule|endfunction|endprimitive|endclass|endpackage|endsequence|endprogram|endclocking|endproperty|endgroup|endinterface)\\b',
name: 'keyword.control.tlverilog'
},
{match: '\\b(std)\\b::', name: 'support.class.tlverilog'},
{
match:
'\\.(atob|atohex|atoi|atooct|atoreal|bintoa|hextoa|itoa|octtoa|realtoa|len|getc|putc|toupper|tolower|compare|icompare|substr|num|exists|first|last|name|index|find|find_first|find_last|find_index|find_first_index|find_last_index|min|max|unique|unique_index|sort|rsort|shuffle|reverse|sum|product|xor|status|kill|self|await|suspend|resume|get|put|peek|try_get|try_peek|try_put|data|eq|neq|next|prev|new|size|delete|empty|pop_front|pop_back|front|back|insert|insert_range|erase|erase_range|set|swap|clear|purge|start|finish)\\b',
name: 'support.function.tlverilog'
},
{
match: '\\b(get_randstate|set_randstate)\\b',
name: 'support.function.tlverilog'
},
{match: '\\b(null|void)\\b', name: 'support.constant.tlverilog'},
{
captures: {
1: {name: 'keyword.other.tlverilog'},
2: {name: 'entity.name.type.include.tlverilog'}
},
match: '^\\s*(`include)\\s+(["<].*[">])',
name: 'meta.include.tlverilog'
},
{
match:
'`(celldefine|default_nettype|define|else|elsif|endcelldefine|endif|ifdef|ifndef|include|line|nounconnected_drive|resetall|timescale|unconnected_drive|undef|begin_\\w+|end_\\w+|remove_\\w+|restore_\\w+)\\b',
name: 'constant.other.preprocessor.tlverilog'
},
{include: '#comments'},
{
captures: {
1: {name: 'storage.type.tlverilog'},
3: {name: 'entity.name.type.class.tlverilog'}
},
match:
'\\b(function)\\b\\s+(\\[.*\\])?\\s+\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b',
name: 'meta.definition.tlverilog'
},
{
captures: {
1: {name: 'storage.type.tlverilog'},
2: {name: 'entity.name.type.class.tlverilog'}
},
match:
'^\\s*(module|function|primitive|class|package|constraint|interface|covergroup|program)\\s+\\b([a-zA-Z_][a-zA-Z0-9_]*)\\b',
name: 'meta.definition.tlverilog'
},
{include: '#all-types'},
{match: "'\\s*\\(.+\\)", name: 'keyword.operator.staticcasting.tlverilog'},
{
begin: "'{",
beginCaptures: {
0: {name: 'keyword.operator.unpackaedarrayassignment.begin.tlverilog'}
},
end: '}',
endCaptures: {
0: {name: 'keyword.operator.unpackaedarrayassignment.end.tlverilog'}
},
name: 'keyword.operator.unpackedarrayassignment.tlverilog',
patterns: [{match: '.', name: 'constant.character.escape.tlverilog'}]
},
{
match:
'\\b(output|input|inout|and|nand|nor|or|xor|xnor|buf|not|bufif[01]|notif[01]|r?[npc]mos|tran|r?tranif[01]|pullup|pulldown)\\b',
name: 'support.type.tlverilog'
},
{
match:
"(\\b\\d+)?'[sS]?([bB]\\s*[0-1_xXzZ?]+|[oO]\\s*[0-7_xXzZ?]+|[dD]\\s*[0-9_xXzZ?]+|[hH]\\s*[0-9a-fA-F_xXzZ?]+|[0-1xz])((e|E)(\\+|-)?[0-9]+)?\\b",
name: 'constant.numeric.tlverilog'
},
{include: '#strings'}
],
repository: {
'all-types': {
patterns: [
{include: '#storage-type-tlverilog'},
{include: '#storage-modifier-tlverilog'}
]
},
comments: {
patterns: [
{
begin: '/\\*',
captures: {0: {name: 'punctuation.definition.comment.tlverilog'}},
end: '\\*/',
name: 'comment.block.tlverilog'
},
{
captures: {1: {name: 'punctuation.definition.comment.tlverilog'}},
match: '(//).*$\\n?',
name: 'comment.line.double-slash.tlverilog'
}
]
},
'storage-modifier-tlverilog': {
match:
'\\b(signed|unsigned|small|medium|large|supply[01]|strong[01]|pull[01]|weak[01]|highz[01])\\b',
name: 'storage.modifier.tlverilog'
},
'storage-type-tlverilog': {
match:
'\\b(wire|tri|tri[01]|supply[01]|wand|triand|wor|trior|trireg|reg|parameter|integer|rand|randc|int|longint|shortint|logic|bit|byte|shortreal|string)\\b',
name: 'storage.type.tlverilog'
},
strings: {
patterns: [
{
begin: '"',
beginCaptures: {
0: {name: 'punctuation.definition.string.begin.tlverilog'}
},
end: '"',
endCaptures: {
0: {name: 'punctuation.definition.string.end.tlverilog'}
},
name: 'string.quoted.double.tlverilog',
patterns: [
{match: '\\\\.', name: 'constant.character.escape.tlverilog'}
]
},
{
begin: "'",
beginCaptures: {
0: {name: 'punctuation.definition.string.begin.tlverilog'}
},
end: "'",
endCaptures: {
0: {name: 'punctuation.definition.string.end.tlverilog'}
},
name: 'string.quoted.single.tlverilog',
patterns: [
{match: '\\\\.', name: 'constant.character.escape.tlverilog'}
]
}
]
}
},
scopeName: 'source.tlverilog'
}
export default grammar