VHDL: Add `private`, `view` keywords; Distinguish `attribute` from `keyword` (#3389)
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
diff --git a/components/prism-vhdl.js b/components/prism-vhdl.js
index c898cc5..7426fa2 100644
--- a/components/prism-vhdl.js
+++ b/components/prism-vhdl.js
@@ -11,9 +11,12 @@ Prism.languages.vhdl = {
alias: 'function'
},
'string': /"(?:[^\\"\r\n]|\\(?:\r\n|[\s\S]))*"/,
- 'constant': /\b(?:library|use)\b/i,
+ 'attribute': {
+ pattern: /\b'\w+/,
+ alias: 'attr-name'
+ },
// support for predefined attributes included
- '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,
+ 'keyword': /\b(?: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|private|procedure|process|pure|range|record|register|reject|report|return|select|severity|shared|signal|subtype|then|to|transport|type|unaffected|units|until|use|variable|view|wait|when|while|with)\b/i,
'boolean': /\b(?:false|true)\b/i,
'function': /\w+(?=\()/,
// decimal, based, physical, and exponential numbers supported
diff --git a/components/prism-vhdl.min.js b/components/prism-vhdl.min.js
index 0153228..17fd67d 100644
--- a/components/prism-vhdl.min.js
+++ b/components/prism-vhdl.min.js
@@ -1 +1 @@
-Prism.languages.vhdl={comment:/--.+/,"vhdl-vectors":{pattern:/\b[oxb]"[\da-f_]+"|"[01uxzwlh-]+"/i,alias:"number"},"quoted-function":{pattern:/"\S+?"(?=\()/,alias:"function"},string:/"(?:[^\\"\r\n]|\\(?:\r\n|[\s\S]))*"/,constant:/\b(?:library|use)\b/i,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,boolean:/\b(?:false|true)\b/i,function:/\w+(?=\()/,number:/'[01uxzwlh-]'|\b(?:\d+#[\da-f_.]+#|\d[\d_.]*)(?:e[-+]?\d+)?/i,operator:/[<>]=?|:=|[-+*/&=]|\b(?:abs|and|mod|nand|nor|not|or|rem|rol|ror|sla|sll|sra|srl|xnor|xor)\b/i,punctuation:/[{}[\];(),.:]/};
\ No newline at end of file
+Prism.languages.vhdl={comment:/--.+/,"vhdl-vectors":{pattern:/\b[oxb]"[\da-f_]+"|"[01uxzwlh-]+"/i,alias:"number"},"quoted-function":{pattern:/"\S+?"(?=\()/,alias:"function"},string:/"(?:[^\\"\r\n]|\\(?:\r\n|[\s\S]))*"/,attribute:{pattern:/\b'\w+/,alias:"attr-name"},keyword:/\b(?: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|private|procedure|process|pure|range|record|register|reject|report|return|select|severity|shared|signal|subtype|then|to|transport|type|unaffected|units|until|use|variable|view|wait|when|while|with)\b/i,boolean:/\b(?:false|true)\b/i,function:/\w+(?=\()/,number:/'[01uxzwlh-]'|\b(?:\d+#[\da-f_.]+#|\d[\d_.]*)(?:e[-+]?\d+)?/i,operator:/[<>]=?|:=|[-+*/&=]|\b(?:abs|and|mod|nand|nor|not|or|rem|rol|ror|sla|sll|sra|srl|xnor|xor)\b/i,punctuation:/[{}[\];(),.:]/};
\ No newline at end of file
diff --git a/tests/languages/vhdl/attribute_feature.test b/tests/languages/vhdl/attribute_feature.test
new file mode 100644
index 0000000..d4df31b
--- /dev/null
+++ b/tests/languages/vhdl/attribute_feature.test
@@ -0,0 +1,25 @@
+T'BASE
+T'IMAGE(X)
+A'RANGE
+A'RANGE(N)
+A'REVERSE_RANGE
+A'REVERSE_RANGE(N)
+S'DELAYED(t)
+E'INSTANCE_NAME
+
+----------------------------------------------------
+
+[
+ "T", ["attribute", "'BASE"],
+ "\r\nT", ["attribute", "'IMAGE"], ["punctuation", "("], "X", ["punctuation", ")"],
+ "\r\nA", ["attribute", "'RANGE"],
+ "\r\nA", ["attribute", "'RANGE"], ["punctuation", "("], "N", ["punctuation", ")"],
+ "\r\nA", ["attribute", "'REVERSE_RANGE"],
+ "\r\nA", ["attribute", "'REVERSE_RANGE"], ["punctuation", "("], "N", ["punctuation", ")"],
+ "\r\nS", ["attribute", "'DELAYED"], ["punctuation", "("], "t", ["punctuation", ")"],
+ "\r\nE", ["attribute", "'INSTANCE_NAME"]
+]
+
+----------------------------------------------------
+
+Checks for attributes.
diff --git a/tests/languages/vhdl/constant_feature.test b/tests/languages/vhdl/constant_feature.test
deleted file mode 100644
index 345bfaa..0000000
--- a/tests/languages/vhdl/constant_feature.test
+++ /dev/null
@@ -1,13 +0,0 @@
-use
-library
-
-----------------------------------------------------
-
-[
- ["constant", "use"],
- ["constant", "library"]
-]
-
-----------------------------------------------------
-
-Checks for constants.
\ No newline at end of file
diff --git a/tests/languages/vhdl/keyword_feature.test b/tests/languages/vhdl/keyword_feature.test
index e67f11e..23c5af6 100644
--- a/tests/languages/vhdl/keyword_feature.test
+++ b/tests/languages/vhdl/keyword_feature.test
@@ -1,34 +1,3 @@
-A'active
-A'ascending
-A'base
-A'delayed
-A'driving
-A'driving_value
-A'event
-A'high
-A'image
-A'instance_name
-A'last_active
-A'last_event
-A'last_value
-A'left
-A'leftof
-A'length
-A'low
-A'path_name
-A'pos
-A'pred
-A'quiet
-A'range
-A'reverse_range
-A'right
-A'rightof
-A'simple_name
-A'stable
-A'succ
-A'transaction
-A'val
-A'value
access
after
alias
@@ -67,6 +36,7 @@ inertial
inout
is
label
+library
linkage
literal
loop
@@ -82,6 +52,7 @@ out
package
port
postponed
+private
procedure
process
pure
@@ -103,7 +74,9 @@ type
unaffected
units
until
+use
variable
+view
wait
when
while
@@ -112,37 +85,6 @@ with
----------------------------------------------------
[
- "A", ["keyword", "'active"],
- "\r\nA", ["keyword", "'ascending"],
- "\r\nA", ["keyword", "'base"],
- "\r\nA", ["keyword", "'delayed"],
- "\r\nA", ["keyword", "'driving"],
- "\r\nA", ["keyword", "'driving_value"],
- "\r\nA", ["keyword", "'event"],
- "\r\nA", ["keyword", "'high"],
- "\r\nA", ["keyword", "'image"],
- "\r\nA", ["keyword", "'instance_name"],
- "\r\nA", ["keyword", "'last_active"],
- "\r\nA", ["keyword", "'last_event"],
- "\r\nA", ["keyword", "'last_value"],
- "\r\nA", ["keyword", "'left"],
- "\r\nA", ["keyword", "'leftof"],
- "\r\nA", ["keyword", "'length"],
- "\r\nA", ["keyword", "'low"],
- "\r\nA", ["keyword", "'path_name"],
- "\r\nA", ["keyword", "'pos"],
- "\r\nA", ["keyword", "'pred"],
- "\r\nA", ["keyword", "'quiet"],
- "\r\nA", ["keyword", "'range"],
- "\r\nA", ["keyword", "'reverse_range"],
- "\r\nA", ["keyword", "'right"],
- "\r\nA", ["keyword", "'rightof"],
- "\r\nA", ["keyword", "'simple_name"],
- "\r\nA", ["keyword", "'stable"],
- "\r\nA", ["keyword", "'succ"],
- "\r\nA", ["keyword", "'transaction"],
- "\r\nA", ["keyword", "'val"],
- "\r\nA", ["keyword", "'value"],
["keyword", "access"],
["keyword", "after"],
["keyword", "alias"],
@@ -181,6 +123,7 @@ with
["keyword", "inout"],
["keyword", "is"],
["keyword", "label"],
+ ["keyword", "library"],
["keyword", "linkage"],
["keyword", "literal"],
["keyword", "loop"],
@@ -196,6 +139,7 @@ with
["keyword", "package"],
["keyword", "port"],
["keyword", "postponed"],
+ ["keyword", "private"],
["keyword", "procedure"],
["keyword", "process"],
["keyword", "pure"],
@@ -217,7 +161,9 @@ with
["keyword", "unaffected"],
["keyword", "units"],
["keyword", "until"],
+ ["keyword", "use"],
["keyword", "variable"],
+ ["keyword", "view"],
["keyword", "wait"],
["keyword", "when"],
["keyword", "while"],
@@ -226,4 +172,4 @@ with
----------------------------------------------------
-Checks for all keywords.
\ No newline at end of file
+Checks for all keywords.