summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2019-11-24 19:17:49 +0100
committerGeorg Brandl <georg@python.org>2019-11-24 19:17:49 +0100
commita0703effd093a09edcec0020210e0f151a2474ba (patch)
tree32174ffc7849849e162fa66b7cbd315f4c555e5d
parentef34358f6a5ef69d06108feeddfd5e86915475db (diff)
downloadpygments-git-a0703effd093a09edcec0020210e0f151a2474ba.tar.gz
Verilog: get rid of "uppercase is constant" highlighting
Seems quite arbitrary and has raised eyebrows (fixes #1204)
-rw-r--r--pygments/lexers/hdl.py126
1 files changed, 60 insertions, 66 deletions
diff --git a/pygments/lexers/hdl.py b/pygments/lexers/hdl.py
index e7c7617b..b45654eb 100644
--- a/pygments/lexers/hdl.py
+++ b/pygments/lexers/hdl.py
@@ -131,15 +131,6 @@ class VerilogLexer(RegexLexer):
]
}
- def get_tokens_unprocessed(self, text):
- for index, token, value in \
- RegexLexer.get_tokens_unprocessed(self, text):
- # Convention: mark all upper case names as constants
- if token is Name:
- if value.isupper():
- token = Name.Constant
- yield index, token, value
-
class SystemVerilogLexer(RegexLexer):
"""
@@ -184,63 +175,75 @@ class SystemVerilogLexer(RegexLexer):
(r'`[a-zA-Z_]\w*', Name.Constant),
(words((
- 'accept_on', 'alias', 'always', 'always_comb', 'always_ff', 'always_latch',
- 'and', 'assert', 'assign', 'assume', 'automatic', 'before', 'begin', 'bind', 'bins',
- 'binsof', 'bit', 'break', 'buf', 'bufif0', 'bufif1', 'byte', 'case', 'casex', 'casez',
- 'cell', 'chandle', 'checker', 'class', 'clocking', 'cmos', 'config', 'const', 'constraint',
- 'context', 'continue', 'cover', 'covergroup', 'coverpoint', 'cross', 'deassign',
- 'default', 'defparam', 'design', 'disable', 'dist', 'do', 'edge', 'else', 'end', 'endcase',
- 'endchecker', 'endclass', 'endclocking', 'endconfig', 'endfunction', 'endgenerate',
- 'endgroup', 'endinterface', 'endmodule', 'endpackage', 'endprimitive',
- 'endprogram', 'endproperty', 'endsequence', 'endspecify', 'endtable',
- 'endtask', 'enum', 'event', 'eventually', 'expect', 'export', 'extends', 'extern',
- 'final', 'first_match', 'for', 'force', 'foreach', 'forever', 'fork', 'forkjoin',
- 'function', 'generate', 'genvar', 'global', 'highz0', 'highz1', 'if', 'iff', 'ifnone',
- 'ignore_bins', 'illegal_bins', 'implies', 'import', 'incdir', 'include',
- 'initial', 'inout', 'input', 'inside', 'instance', 'int', 'integer', 'interface',
- 'intersect', 'join', 'join_any', 'join_none', 'large', 'let', 'liblist', 'library',
- 'local', 'localparam', 'logic', 'longint', 'macromodule', 'matches', 'medium',
- 'modport', 'module', 'nand', 'negedge', 'new', 'nexttime', 'nmos', 'nor', 'noshowcancelled',
- 'not', 'notif0', 'notif1', 'null', 'or', 'output', 'package', 'packed', 'parameter',
- 'pmos', 'posedge', 'primitive', 'priority', 'program', 'property', 'protected',
- 'pull0', 'pull1', 'pulldown', 'pullup', 'pulsestyle_ondetect', 'pulsestyle_onevent',
- 'pure', 'rand', 'randc', 'randcase', 'randsequence', 'rcmos', 'real', 'realtime',
- 'ref', 'reg', 'reject_on', 'release', 'repeat', 'restrict', 'return', 'rnmos',
- 'rpmos', 'rtran', 'rtranif0', 'rtranif1', 's_always', 's_eventually', 's_nexttime',
- 's_until', 's_until_with', 'scalared', 'sequence', 'shortint', 'shortreal',
- 'showcancelled', 'signed', 'small', 'solve', 'specify', 'specparam', 'static',
- 'string', 'strong', 'strong0', 'strong1', 'struct', 'super', 'supply0', 'supply1',
- 'sync_accept_on', 'sync_reject_on', 'table', 'tagged', 'task', 'this', 'throughout',
- 'time', 'timeprecision', 'timeunit', 'tran', 'tranif0', 'tranif1', 'tri', 'tri0',
- 'tri1', 'triand', 'trior', 'trireg', 'type', 'typedef', 'union', 'unique', 'unique0',
- 'unsigned', 'until', 'until_with', 'untyped', 'use', 'uwire', 'var', 'vectored',
- 'virtual', 'void', 'wait', 'wait_order', 'wand', 'weak', 'weak0', 'weak1', 'while',
- 'wildcard', 'wire', 'with', 'within', 'wor', 'xnor', 'xor'), suffix=r'\b'),
+ 'accept_on', 'alias', 'always', 'always_comb', 'always_ff',
+ 'always_latch', 'and', 'assert', 'assign', 'assume', 'automatic',
+ 'before', 'begin', 'bind', 'bins', 'binsof', 'bit', 'break', 'buf',
+ 'bufif0', 'bufif1', 'byte', 'case', 'casex', 'casez', 'cell',
+ 'chandle', 'checker', 'class', 'clocking', 'cmos', 'config',
+ 'const', 'constraint', 'context', 'continue', 'cover', 'covergroup',
+ 'coverpoint', 'cross', 'deassign', 'default', 'defparam', 'design',
+ 'disable', 'dist', 'do', 'edge', 'else', 'end', 'endcase',
+ 'endchecker', 'endclass', 'endclocking', 'endconfig', 'endfunction',
+ 'endgenerate', 'endgroup', 'endinterface', 'endmodule', 'endpackage',
+ 'endprimitive', 'endprogram', 'endproperty', 'endsequence',
+ 'endspecify', 'endtable', 'endtask', 'enum', 'event', 'eventually',
+ 'expect', 'export', 'extends', 'extern', 'final', 'first_match',
+ 'for', 'force', 'foreach', 'forever', 'fork', 'forkjoin', 'function',
+ 'generate', 'genvar', 'global', 'highz0', 'highz1', 'if', 'iff',
+ 'ifnone', 'ignore_bins', 'illegal_bins', 'implies', 'import',
+ 'incdir', 'include', 'initial', 'inout', 'input', 'inside',
+ 'instance', 'int', 'integer', 'interface', 'intersect', 'join',
+ 'join_any', 'join_none', 'large', 'let', 'liblist', 'library',
+ 'local', 'localparam', 'logic', 'longint', 'macromodule', 'matches',
+ 'medium', 'modport', 'module', 'nand', 'negedge', 'new', 'nexttime',
+ 'nmos', 'nor', 'noshowcancelled', 'not', 'notif0', 'notif1', 'null',
+ 'or', 'output', 'package', 'packed', 'parameter', 'pmos', 'posedge',
+ 'primitive', 'priority', 'program', 'property', 'protected', 'pull0',
+ 'pull1', 'pulldown', 'pullup', 'pulsestyle_ondetect',
+ 'pulsestyle_onevent', 'pure', 'rand', 'randc', 'randcase',
+ 'randsequence', 'rcmos', 'real', 'realtime', 'ref', 'reg',
+ 'reject_on', 'release', 'repeat', 'restrict', 'return', 'rnmos',
+ 'rpmos', 'rtran', 'rtranif0', 'rtranif1', 's_always', 's_eventually',
+ 's_nexttime', 's_until', 's_until_with', 'scalared', 'sequence',
+ 'shortint', 'shortreal', 'showcancelled', 'signed', 'small', 'solve',
+ 'specify', 'specparam', 'static', 'string', 'strong', 'strong0',
+ 'strong1', 'struct', 'super', 'supply0', 'supply1', 'sync_accept_on',
+ 'sync_reject_on', 'table', 'tagged', 'task', 'this', 'throughout',
+ 'time', 'timeprecision', 'timeunit', 'tran', 'tranif0', 'tranif1',
+ 'tri', 'tri0', 'tri1', 'triand', 'trior', 'trireg', 'type',
+ 'typedef', 'union', 'unique', 'unique0', 'unsigned', 'until',
+ 'until_with', 'untyped', 'use', 'uwire', 'var', 'vectored',
+ 'virtual', 'void', 'wait', 'wait_order', 'wand', 'weak', 'weak0',
+ 'weak1', 'while', 'wildcard', 'wire', 'with', 'within', 'wor',
+ 'xnor', 'xor'), suffix=r'\b'),
Keyword),
(words((
- '`__FILE__', '`__LINE__', '`begin_keywords', '`celldefine', '`default_nettype',
- '`define', '`else', '`elsif', '`end_keywords', '`endcelldefine', '`endif',
- '`ifdef', '`ifndef', '`include', '`line', '`nounconnected_drive', '`pragma',
- '`resetall', '`timescale', '`unconnected_drive', '`undef', '`undefineall'),
+ '`__FILE__', '`__LINE__', '`begin_keywords', '`celldefine',
+ '`default_nettype', '`define', '`else', '`elsif', '`end_keywords',
+ '`endcelldefine', '`endif', '`ifdef', '`ifndef', '`include',
+ '`line', '`nounconnected_drive', '`pragma', '`resetall',
+ '`timescale', '`unconnected_drive', '`undef', '`undefineall'),
suffix=r'\b'),
Comment.Preproc),
(words((
- '$display', '$displayb', '$displayh', '$displayo', '$dumpall', '$dumpfile',
- '$dumpflush', '$dumplimit', '$dumpoff', '$dumpon', '$dumpports',
- '$dumpportsall', '$dumpportsflush', '$dumpportslimit', '$dumpportsoff',
- '$dumpportson', '$dumpvars', '$fclose', '$fdisplay', '$fdisplayb',
- '$fdisplayh', '$fdisplayo', '$feof', '$ferror', '$fflush', '$fgetc',
- '$fgets', '$finish', '$fmonitor', '$fmonitorb', '$fmonitorh', '$fmonitoro',
- '$fopen', '$fread', '$fscanf', '$fseek', '$fstrobe', '$fstrobeb', '$fstrobeh',
+ '$display', '$displayb', '$displayh', '$displayo', '$dumpall',
+ '$dumpfile', '$dumpflush', '$dumplimit', '$dumpoff', '$dumpon',
+ '$dumpports', '$dumpportsall', '$dumpportsflush', '$dumpportslimit',
+ '$dumpportsoff', '$dumpportson', '$dumpvars', '$fclose',
+ '$fdisplay', '$fdisplayb', '$fdisplayh', '$fdisplayo', '$feof',
+ '$ferror', '$fflush', '$fgetc', '$fgets', '$finish', '$fmonitor',
+ '$fmonitorb', '$fmonitorh', '$fmonitoro', '$fopen', '$fread',
+ '$fscanf', '$fseek', '$fstrobe', '$fstrobeb', '$fstrobeh',
'$fstrobeo', '$ftell', '$fwrite', '$fwriteb', '$fwriteh', '$fwriteo',
'$monitor', '$monitorb', '$monitorh', '$monitoro', '$monitoroff',
- '$monitoron', '$plusargs', '$random', '$readmemb', '$readmemh', '$rewind',
- '$sformat', '$sformatf', '$sscanf', '$strobe', '$strobeb', '$strobeh', '$strobeo',
- '$swrite', '$swriteb', '$swriteh', '$swriteo', '$test', '$ungetc',
- '$value$plusargs', '$write', '$writeb', '$writeh', '$writememb',
- '$writememh', '$writeo'), suffix=r'\b'),
+ '$monitoron', '$plusargs', '$random', '$readmemb', '$readmemh',
+ '$rewind', '$sformat', '$sformatf', '$sscanf', '$strobe',
+ '$strobeb', '$strobeh', '$strobeo', '$swrite', '$swriteb',
+ '$swriteh', '$swriteo', '$test', '$ungetc', '$value$plusargs',
+ '$write', '$writeb', '$writeh', '$writememb', '$writememh',
+ '$writeo'), suffix=r'\b'),
Name.Builtin),
(r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
@@ -276,15 +279,6 @@ class SystemVerilogLexer(RegexLexer):
]
}
- def get_tokens_unprocessed(self, text):
- for index, token, value in \
- RegexLexer.get_tokens_unprocessed(self, text):
- # Convention: mark all upper case names as constants
- if token is Name:
- if value.isupper():
- token = Name.Constant
- yield index, token, value
-
class VhdlLexer(RegexLexer):
"""