eric6/ThirdParty/Pygments/pygments/lexers/hdl.py

changeset 7701
25f42e208e08
parent 7547
21b0534faebc
child 7983
54c5cfbb1e29
equal deleted inserted replaced
7700:a3cf077a8db3 7701:25f42e208e08
3 pygments.lexers.hdl 3 pygments.lexers.hdl
4 ~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~
5 5
6 Lexers for hardware descriptor languages. 6 Lexers for hardware descriptor languages.
7 7
8 :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. 8 :copyright: Copyright 2006-2020 by the Pygments team, see AUTHORS.
9 :license: BSD, see LICENSE for details. 9 :license: BSD, see LICENSE for details.
10 """ 10 """
11 11
12 import re 12 import re
13 13
103 Name.Builtin), 103 Name.Builtin),
104 104
105 (words(( 105 (words((
106 'byte', 'shortint', 'int', 'longint', 'integer', 'time', 106 'byte', 'shortint', 'int', 'longint', 'integer', 'time',
107 'bit', 'logic', 'reg', 'supply0', 'supply1', 'tri', 'triand', 107 'bit', 'logic', 'reg', 'supply0', 'supply1', 'tri', 'triand',
108 'trior', 'tri0', 'tri1', 'trireg', 'uwire', 'wire', 'wand', 'wo' 108 'trior', 'tri0', 'tri1', 'trireg', 'uwire', 'wire', 'wand', 'wor'
109 'shortreal', 'real', 'realtime'), suffix=r'\b'), 109 'shortreal', 'real', 'realtime'), suffix=r'\b'),
110 Keyword.Type), 110 Keyword.Type),
111 (r'[a-zA-Z_]\w*:(?!:)', Name.Label), 111 (r'[a-zA-Z_]\w*:(?!:)', Name.Label),
112 (r'\$?[a-zA-Z_]\w*', Name), 112 (r'\$?[a-zA-Z_]\w*', Name),
113 (r'\\(\S+)', Name),
113 ], 114 ],
114 'string': [ 115 'string': [
115 (r'"', String, '#pop'), 116 (r'"', String, '#pop'),
116 (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape), 117 (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
117 (r'[^\\"\n]+', String), # all other characters 118 (r'[^\\"\n]+', String), # all other characters
159 (r'/(\\\n)?/(\n|(.|\n)*?[^\\]\n)', Comment.Single), 160 (r'/(\\\n)?/(\n|(.|\n)*?[^\\]\n)', Comment.Single),
160 (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline), 161 (r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
161 (r'[{}#@]', Punctuation), 162 (r'[{}#@]', Punctuation),
162 (r'L?"', String, 'string'), 163 (r'L?"', String, 'string'),
163 (r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char), 164 (r"L?'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])'", String.Char),
165
164 (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float), 166 (r'(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[lL]?', Number.Float),
165 (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float), 167 (r'(\d+\.\d*|\.\d+|\d+[fF])[fF]?', Number.Float),
166 (r'([0-9]+)|(\'h)[0-9a-fA-F]+', Number.Hex), 168
167 (r'([0-9]+)|(\'b)[01]+', Number.Bin), 169 (r'([1-9][_0-9]*)?\s*\'[sS]?[bB]\s*[xXzZ?01][_xXzZ?01]*',
168 (r'([0-9]+)|(\'d)[0-9]+', Number.Integer), 170 Number.Bin),
169 (r'([0-9]+)|(\'o)[0-7]+', Number.Oct), 171 (r'([1-9][_0-9]*)?\s*\'[sS]?[oO]\s*[xXzZ?0-7][_xXzZ?0-7]*',
170 (r'\'[01xz]', Number), 172 Number.Oct),
171 (r'\d+[Ll]?', Number.Integer), 173 (r'([1-9][_0-9]*)?\s*\'[sS]?[dD]\s*[xXzZ?0-9][_xXzZ?0-9]*',
174 Number.Integer),
175 (r'([1-9][_0-9]*)?\s*\'[sS]?[hH]\s*[xXzZ?0-9a-fA-F][_xXzZ?0-9a-fA-F]*',
176 Number.Hex),
177
178 (r'\'[01xXzZ]', Number),
179 (r'[0-9][_0-9]*', Number.Integer),
180
172 (r'\*/', Error), 181 (r'\*/', Error),
182
173 (r'[~!%^&*+=|?:<>/-]', Operator), 183 (r'[~!%^&*+=|?:<>/-]', Operator),
174 (r'[()\[\],.;\']', Punctuation), 184 (words(('inside', 'dist'), suffix=r'\b'), Operator.Word),
185
186 (r'[()\[\],.;\'$]', Punctuation),
175 (r'`[a-zA-Z_]\w*', Name.Constant), 187 (r'`[a-zA-Z_]\w*', Name.Constant),
176 188
177 (words(( 189 (words((
178 'accept_on', 'alias', 'always', 'always_comb', 'always_ff', 190 'accept_on', 'alias', 'always', 'always_comb', 'always_ff',
179 'always_latch', 'and', 'assert', 'assign', 'assume', 'automatic', 191 'always_latch', 'and', 'assert', 'assign', 'assume', 'automatic',
180 'before', 'begin', 'bind', 'bins', 'binsof', 'bit', 'break', 'buf', 192 'before', 'begin', 'bind', 'bins', 'binsof', 'break', 'buf',
181 'bufif0', 'bufif1', 'byte', 'case', 'casex', 'casez', 'cell', 193 'bufif0', 'bufif1', 'case', 'casex', 'casez', 'cell',
182 'chandle', 'checker', 'class', 'clocking', 'cmos', 'config', 194 'checker', 'clocking', 'cmos', 'config',
183 'const', 'constraint', 'context', 'continue', 'cover', 'covergroup', 195 'constraint', 'context', 'continue', 'cover', 'covergroup',
184 'coverpoint', 'cross', 'deassign', 'default', 'defparam', 'design', 196 'coverpoint', 'cross', 'deassign', 'default', 'defparam', 'design',
185 'disable', 'dist', 'do', 'edge', 'else', 'end', 'endcase', 197 'disable', 'do', 'edge', 'else', 'end', 'endcase',
186 'endchecker', 'endclass', 'endclocking', 'endconfig', 'endfunction', 198 'endchecker', 'endclocking', 'endconfig', 'endfunction',
187 'endgenerate', 'endgroup', 'endinterface', 'endmodule', 'endpackage', 199 'endgenerate', 'endgroup', 'endinterface', 'endmodule', 'endpackage',
188 'endprimitive', 'endprogram', 'endproperty', 'endsequence', 200 'endprimitive', 'endprogram', 'endproperty', 'endsequence',
189 'endspecify', 'endtable', 'endtask', 'enum', 'event', 'eventually', 201 'endspecify', 'endtable', 'endtask', 'enum', 'eventually',
190 'expect', 'export', 'extends', 'extern', 'final', 'first_match', 202 'expect', 'export', 'extern', 'final', 'first_match',
191 'for', 'force', 'foreach', 'forever', 'fork', 'forkjoin', 'function', 203 'for', 'force', 'foreach', 'forever', 'fork', 'forkjoin', 'function',
192 'generate', 'genvar', 'global', 'highz0', 'highz1', 'if', 'iff', 204 'generate', 'genvar', 'global', 'highz0', 'highz1', 'if', 'iff',
193 'ifnone', 'ignore_bins', 'illegal_bins', 'implies', 'import', 205 'ifnone', 'ignore_bins', 'illegal_bins', 'implies', 'implements', 'import',
194 'incdir', 'include', 'initial', 'inout', 'input', 'inside', 206 'incdir', 'include', 'initial', 'inout', 'input',
195 'instance', 'int', 'integer', 'interface', 'intersect', 'join', 207 'instance', 'interconnect', 'interface', 'intersect', 'join',
196 'join_any', 'join_none', 'large', 'let', 'liblist', 'library', 208 'join_any', 'join_none', 'large', 'let', 'liblist', 'library',
197 'local', 'localparam', 'logic', 'longint', 'macromodule', 'matches', 209 'local', 'localparam', 'macromodule', 'matches',
198 'medium', 'modport', 'module', 'nand', 'negedge', 'new', 'nexttime', 210 'medium', 'modport', 'module', 'nand', 'negedge', 'nettype', 'new', 'nexttime',
199 'nmos', 'nor', 'noshowcancelled', 'not', 'notif0', 'notif1', 'null', 211 'nmos', 'nor', 'noshowcancelled', 'not', 'notif0', 'notif1', 'null',
200 'or', 'output', 'package', 'packed', 'parameter', 'pmos', 'posedge', 212 'or', 'output', 'package', 'packed', 'parameter', 'pmos', 'posedge',
201 'primitive', 'priority', 'program', 'property', 'protected', 'pull0', 213 'primitive', 'priority', 'program', 'property', 'protected', 'pull0',
202 'pull1', 'pulldown', 'pullup', 'pulsestyle_ondetect', 214 'pull1', 'pulldown', 'pullup', 'pulsestyle_ondetect',
203 'pulsestyle_onevent', 'pure', 'rand', 'randc', 'randcase', 215 'pulsestyle_onevent', 'pure', 'rand', 'randc', 'randcase',
204 'randsequence', 'rcmos', 'real', 'realtime', 'ref', 'reg', 216 'randsequence', 'rcmos', 'ref',
205 'reject_on', 'release', 'repeat', 'restrict', 'return', 'rnmos', 217 'reject_on', 'release', 'repeat', 'restrict', 'return', 'rnmos',
206 'rpmos', 'rtran', 'rtranif0', 'rtranif1', 's_always', 's_eventually', 218 'rpmos', 'rtran', 'rtranif0', 'rtranif1', 's_always', 's_eventually',
207 's_nexttime', 's_until', 's_until_with', 'scalared', 'sequence', 219 's_nexttime', 's_until', 's_until_with', 'scalared', 'sequence',
208 'shortint', 'shortreal', 'showcancelled', 'signed', 'small', 'solve', 220 'showcancelled', 'small', 'soft', 'solve',
209 'specify', 'specparam', 'static', 'string', 'strong', 'strong0', 221 'specify', 'specparam', 'static', 'strong', 'strong0',
210 'strong1', 'struct', 'super', 'supply0', 'supply1', 'sync_accept_on', 222 'strong1', 'struct', 'super', 'sync_accept_on',
211 'sync_reject_on', 'table', 'tagged', 'task', 'this', 'throughout', 223 'sync_reject_on', 'table', 'tagged', 'task', 'this', 'throughout',
212 'time', 'timeprecision', 'timeunit', 'tran', 'tranif0', 'tranif1', 224 'timeprecision', 'timeunit', 'tran', 'tranif0', 'tranif1',
213 'tri', 'tri0', 'tri1', 'triand', 'trior', 'trireg', 'type', 225 'typedef', 'union', 'unique', 'unique0', 'until',
214 'typedef', 'union', 'unique', 'unique0', 'unsigned', 'until', 226 'until_with', 'untyped', 'use', 'vectored',
215 'until_with', 'untyped', 'use', 'uwire', 'var', 'vectored', 227 'virtual', 'wait', 'wait_order', 'weak', 'weak0',
216 'virtual', 'void', 'wait', 'wait_order', 'wand', 'weak', 'weak0', 228 'weak1', 'while', 'wildcard', 'with', 'within',
217 'weak1', 'while', 'wildcard', 'wire', 'with', 'within', 'wor', 229 'xnor', 'xor'),
218 'xnor', 'xor'), suffix=r'\b'), 230 suffix=r'\b'),
219 Keyword), 231 Keyword),
232
233 (r'(class)(\s+)([a-zA-Z_]\w*)',
234 bygroups(Keyword.Declaration, Text, Name.Class)),
235 (r'(extends)(\s+)([a-zA-Z_]\w*)',
236 bygroups(Keyword.Declaration, Text, Name.Class)),
237 (r'(endclass\b)(?:(\s*)(:)(\s*)([a-zA-Z_]\w*))?',
238 bygroups(Keyword.Declaration, Text, Punctuation, Text, Name.Class)),
239
240 (words((
241 # Variable types
242 'bit', 'byte', 'chandle', 'const', 'event', 'int', 'integer',
243 'logic', 'longint', 'real', 'realtime', 'reg', 'shortint',
244 'shortreal', 'signed', 'string', 'time', 'type', 'unsigned',
245 'var', 'void',
246 # Net types
247 'supply0', 'supply1', 'tri', 'triand', 'trior', 'trireg',
248 'tri0', 'tri1', 'uwire', 'wand', 'wire', 'wor'),
249 suffix=r'\b'),
250 Keyword.Type),
220 251
221 (words(( 252 (words((
222 '`__FILE__', '`__LINE__', '`begin_keywords', '`celldefine', 253 '`__FILE__', '`__LINE__', '`begin_keywords', '`celldefine',
223 '`default_nettype', '`define', '`else', '`elsif', '`end_keywords', 254 '`default_nettype', '`define', '`else', '`elsif', '`end_keywords',
224 '`endcelldefine', '`endif', '`ifdef', '`ifndef', '`include', 255 '`endcelldefine', '`endif', '`ifdef', '`ifndef', '`include',
226 '`timescale', '`unconnected_drive', '`undef', '`undefineall'), 257 '`timescale', '`unconnected_drive', '`undef', '`undefineall'),
227 suffix=r'\b'), 258 suffix=r'\b'),
228 Comment.Preproc), 259 Comment.Preproc),
229 260
230 (words(( 261 (words((
231 '$display', '$displayb', '$displayh', '$displayo', '$dumpall', 262 # Simulation control tasks (20.2)
232 '$dumpfile', '$dumpflush', '$dumplimit', '$dumpoff', '$dumpon', 263 '$exit', '$finish', '$stop',
233 '$dumpports', '$dumpportsall', '$dumpportsflush', '$dumpportslimit', 264 # Simulation time functions (20.3)
234 '$dumpportsoff', '$dumpportson', '$dumpvars', '$fclose', 265 '$realtime', '$stime', '$time',
235 '$fdisplay', '$fdisplayb', '$fdisplayh', '$fdisplayo', '$feof', 266 # Timescale tasks (20.4)
236 '$ferror', '$fflush', '$fgetc', '$fgets', '$finish', '$fmonitor', 267 '$printtimescale', '$timeformat',
237 '$fmonitorb', '$fmonitorh', '$fmonitoro', '$fopen', '$fread', 268 # Conversion functions
238 '$fscanf', '$fseek', '$fstrobe', '$fstrobeb', '$fstrobeh', 269 '$bitstoreal', '$bitstoshortreal', '$cast', '$itor',
239 '$fstrobeo', '$ftell', '$fwrite', '$fwriteb', '$fwriteh', '$fwriteo', 270 '$realtobits', '$rtoi', '$shortrealtobits', '$signed',
240 '$monitor', '$monitorb', '$monitorh', '$monitoro', '$monitoroff', 271 '$unsigned',
241 '$monitoron', '$plusargs', '$random', '$readmemb', '$readmemh', 272 # Data query functions (20.6)
242 '$rewind', '$sformat', '$sformatf', '$sscanf', '$strobe', 273 '$bits', '$isunbounded', '$typename',
243 '$strobeb', '$strobeh', '$strobeo', '$swrite', '$swriteb', 274 # Array query functions (20.7)
244 '$swriteh', '$swriteo', '$test', '$ungetc', '$value$plusargs', 275 '$dimensions', '$high', '$increment', '$left', '$low', '$right',
245 '$write', '$writeb', '$writeh', '$writememb', '$writememh', 276 '$size', '$unpacked_dimensions',
246 '$writeo'), suffix=r'\b'), 277 # Math functions (20.8)
278 '$acos', '$acosh', '$asin', '$asinh', '$atan', '$atan2',
279 '$atanh', '$ceil', '$clog2', '$cos', '$cosh', '$exp', '$floor',
280 '$hypot', '$ln', '$log10', '$pow', '$sin', '$sinh', '$sqrt',
281 '$tan', '$tanh',
282 # Bit vector system functions (20.9)
283 '$countbits', '$countones', '$isunknown', '$onehot', '$onehot0',
284 # Severity tasks (20.10)
285 '$info', '$error', '$fatal', '$warning',
286 # Assertion control tasks (20.12)
287 '$assertcontrol', '$assertfailoff', '$assertfailon',
288 '$assertkill', '$assertnonvacuouson', '$assertoff', '$asserton',
289 '$assertpassoff', '$assertpasson', '$assertvacuousoff',
290 # Sampled value system functions (20.13)
291 '$changed', '$changed_gclk', '$changing_gclk', '$falling_gclk',
292 '$fell', '$fell_gclk', '$future_gclk', '$past', '$past_gclk',
293 '$rising_gclk', '$rose', '$rose_gclk', '$sampled', '$stable',
294 '$stable_gclk', '$steady_gclk',
295 # Coverage control functions (20.14)
296 '$coverage_control', '$coverage_get', '$coverage_get_max',
297 '$coverage_merge', '$coverage_save', '$get_coverage',
298 '$load_coverage_db', '$set_coverage_db_name',
299 # Probabilistic distribution functions (20.15)
300 '$dist_chi_square', '$dist_erlang', '$dist_exponential',
301 '$dist_normal', '$dist_poisson', '$dist_t', '$dist_uniform',
302 '$random',
303 # Stochastic analysis tasks and functions (20.16)
304 '$q_add', '$q_exam', '$q_full', '$q_initialize', '$q_remove',
305 # PLA modeling tasks (20.17)
306 '$async$and$array', '$async$and$plane', '$async$nand$array',
307 '$async$nand$plane', '$async$nor$array', '$async$nor$plane',
308 '$async$or$array', '$async$or$plane', '$sync$and$array',
309 '$sync$and$plane', '$sync$nand$array', '$sync$nand$plane',
310 '$sync$nor$array', '$sync$nor$plane', '$sync$or$array',
311 '$sync$or$plane',
312 # Miscellaneous tasks and functions (20.18)
313 '$system',
314 # Display tasks (21.2)
315 '$display', '$displayb', '$displayh', '$displayo', '$monitor',
316 '$monitorb', '$monitorh', '$monitoro', '$monitoroff',
317 '$monitoron', '$strobe', '$strobeb', '$strobeh', '$strobeo',
318 '$write', '$writeb', '$writeh', '$writeo',
319 # File I/O tasks and functions (21.3)
320 '$fclose', '$fdisplay', '$fdisplayb', '$fdisplayh',
321 '$fdisplayo', '$feof', '$ferror', '$fflush', '$fgetc', '$fgets',
322 '$fmonitor', '$fmonitorb', '$fmonitorh', '$fmonitoro', '$fopen',
323 '$fread', '$fscanf', '$fseek', '$fstrobe', '$fstrobeb',
324 '$fstrobeh', '$fstrobeo', '$ftell', '$fwrite', '$fwriteb',
325 '$fwriteh', '$fwriteo', '$rewind', '$sformat', '$sformatf',
326 '$sscanf', '$swrite', '$swriteb', '$swriteh', '$swriteo',
327 '$ungetc',
328 # Memory load tasks (21.4)
329 '$readmemb', '$readmemh',
330 # Memory dump tasks (21.5)
331 '$writememb', '$writememh',
332 # Command line input (21.6)
333 '$test$plusargs', '$value$plusargs',
334 # VCD tasks (21.7)
335 '$dumpall', '$dumpfile', '$dumpflush', '$dumplimit', '$dumpoff',
336 '$dumpon', '$dumpports', '$dumpportsall', '$dumpportsflush',
337 '$dumpportslimit', '$dumpportsoff', '$dumpportson', '$dumpvars',
338 ), suffix=r'\b'),
247 Name.Builtin), 339 Name.Builtin),
248 340
249 (r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
250 (words((
251 'byte', 'shortint', 'int', 'longint', 'integer', 'time',
252 'bit', 'logic', 'reg', 'supply0', 'supply1', 'tri', 'triand',
253 'trior', 'tri0', 'tri1', 'trireg', 'uwire', 'wire', 'wand', 'wo'
254 'shortreal', 'real', 'realtime'), suffix=r'\b'),
255 Keyword.Type),
256 (r'[a-zA-Z_]\w*:(?!:)', Name.Label), 341 (r'[a-zA-Z_]\w*:(?!:)', Name.Label),
257 (r'\$?[a-zA-Z_]\w*', Name), 342 (r'\$?[a-zA-Z_]\w*', Name),
258 ], 343 (r'\\(\S+)', Name),
259 'classname': [
260 (r'[a-zA-Z_]\w*', Name.Class, '#pop'),
261 ], 344 ],
262 'string': [ 345 'string': [
263 (r'"', String, '#pop'), 346 (r'"', String, '#pop'),
264 (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape), 347 (r'\\([\\abfnrtv"\']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})', String.Escape),
265 (r'[^\\"\n]+', String), # all other characters 348 (r'[^\\"\n]+', String), # all other characters

eric ide

mercurial