Skip to content

Commit 4533f17

Browse files
committed
VHDL: Move operator overloading before strings, don't capture if not needed, handle \r\n and \r, fix numbers
1 parent 2d8271f commit 4533f17

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

components/prism-vhdl.js

+12-13
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@ Prism.languages.vhdl = {
55
'pattern': /\b[oxb]"[\da-f_]+"|"[01uxzwlh-]+"/i,
66
'alias': 'number'
77
},
8-
'string': /"(\\\n|\\?.)*?"/,
9-
'constant': /\b(use|library)\b/i,
10-
// support for predefined attributes included
11-
'keyword': /\b('active|'ascending|'base|'delayed|'driving|'driving_value|'event|'high|'image|'instance_name|'last_active|'last_event|'last_value|'left|'leftof|'length|'low|'path_name|'pos|'pred|'quiet|'range|'reverse_range|'right|'rightof|'simple_name|'stable|'succ|'transaction|'val|'value|access|after|alias|all|architecture|array|assert|attribute|begin|block|body|buffer|bus|case|component|configuration|constant|disconnect|downto|else|elsif|end|entity|exit|file|for|function|generate|generic|group|guarded|if|impure|in|inertial|inout|is|label|library|linkage|literal|loop|map|new|next|null|of|on|open|others|out|package|port|postponed|procedure|process|pure|range|record|register|reject|report|return|select|severity|shared|signal|subtype|then|to|transport|type|unaffected|units|until|use|variable|wait|when|while|with)\b/i,
12-
'boolean': /\b(true|false)\b/i,
13-
'function': {
14-
// support for operator overloading included
15-
pattern: /([a-z0-9_]+|"\S+")\(/i,
16-
inside: {
17-
punctuation: /\(/
18-
}
8+
// support for operator overloading included
9+
'quoted-function': {
10+
pattern: /"\S+?"(?=\()/,
11+
alias: 'function'
1912
},
13+
'string': /"(?:[^\\\r\n]|\\?(?:\r\n|[\s\S]))*?"/,
14+
'constant': /\b(?:use|library)\b/i,
15+
// support for predefined attributes included
16+
'keyword': /\b(?:'active|'ascending|'base|'delayed|'driving|'driving_value|'event|'high|'image|'instance_name|'last_active|'last_event|'last_value|'left|'leftof|'length|'low|'path_name|'pos|'pred|'quiet|'range|'reverse_range|'right|'rightof|'simple_name|'stable|'succ|'transaction|'val|'value|access|after|alias|all|architecture|array|assert|attribute|begin|block|body|buffer|bus|case|component|configuration|constant|disconnect|downto|else|elsif|end|entity|exit|file|for|function|generate|generic|group|guarded|if|impure|in|inertial|inout|is|label|library|linkage|literal|loop|map|new|next|null|of|on|open|others|out|package|port|postponed|procedure|process|pure|range|record|register|reject|report|return|select|severity|shared|signal|subtype|then|to|transport|type|unaffected|units|until|use|variable|wait|when|while|with)\b/i,
17+
'boolean': /\b(?:true|false)\b/i,
18+
'function': /[a-z0-9_]+(?=\()/i,
2019
// decimal, based, physical, and exponential numbers supported
21-
'number': /'[01uxzwlh-]'|\b\d+[_.]*(#[\da-f_.]+#)?(e[-+]?\d+)?/i,
22-
'operator': /<=?|>=?|:=|[-+*/&=]|\b(abs|not|mod|rem|sll|srl|sla|sra|rol|ror|and|or|nand|xnor|xor|nor)\b/i,
20+
'number': /'[01uxzwlh-]'|\b(?:\d+#[\da-f_.]+#|\d[\d_.]*)(?:e[-+]?\d+)?/i,
21+
'operator': /[<>]=?|:=|[-+*/&=]|\b(?:abs|not|mod|rem|sll|srl|sla|sra|rol|ror|and|or|nand|xnor|xor|nor)\b/i,
2322
'punctuation': /[{}[\];(),.:]/
2423
};

components/prism-vhdl.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)