vhdl.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. Language: VHDL
  3. Author: Igor Kalnitsky <igor@kalnitsky.org>
  4. Contributors: Daniel C.K. Kho <daniel.kho@tauhop.com>, Guillaume Savaton <guillaume.savaton@eseo.fr>
  5. Description: VHDL is a hardware description language used in electronic design automation to describe digital and mixed-signal systems.
  6. Website: https://en.wikipedia.org/wiki/VHDL
  7. */
  8. function vhdl(hljs) {
  9. // Regular expression for VHDL numeric literals.
  10. // Decimal literal:
  11. const INTEGER_RE = '\\d(_|\\d)*';
  12. const EXPONENT_RE = '[eE][-+]?' + INTEGER_RE;
  13. const DECIMAL_LITERAL_RE = INTEGER_RE + '(\\.' + INTEGER_RE + ')?' + '(' + EXPONENT_RE + ')?';
  14. // Based literal:
  15. const BASED_INTEGER_RE = '\\w+';
  16. const BASED_LITERAL_RE = INTEGER_RE + '#' + BASED_INTEGER_RE + '(\\.' + BASED_INTEGER_RE + ')?' + '#' + '(' + EXPONENT_RE + ')?';
  17. const NUMBER_RE = '\\b(' + BASED_LITERAL_RE + '|' + DECIMAL_LITERAL_RE + ')';
  18. return {
  19. name: 'VHDL',
  20. case_insensitive: true,
  21. keywords: {
  22. keyword:
  23. 'abs access after alias all and architecture array assert assume assume_guarantee attribute ' +
  24. 'begin block body buffer bus case component configuration constant context cover disconnect ' +
  25. 'downto default else elsif end entity exit fairness file for force function generate ' +
  26. 'generic group guarded if impure in inertial inout is label library linkage literal ' +
  27. 'loop map mod nand new next nor not null of on open or others out package parameter port ' +
  28. 'postponed procedure process property protected pure range record register reject ' +
  29. 'release rem report restrict restrict_guarantee return rol ror select sequence ' +
  30. 'severity shared signal sla sll sra srl strong subtype then to transport type ' +
  31. 'unaffected units until use variable view vmode vprop vunit wait when while with xnor xor',
  32. built_in:
  33. 'boolean bit character ' +
  34. 'integer time delay_length natural positive ' +
  35. 'string bit_vector file_open_kind file_open_status ' +
  36. 'std_logic std_logic_vector unsigned signed boolean_vector integer_vector ' +
  37. 'std_ulogic std_ulogic_vector unresolved_unsigned u_unsigned unresolved_signed u_signed ' +
  38. 'real_vector time_vector',
  39. literal:
  40. 'false true note warning error failure ' + // severity_level
  41. 'line text side width' // textio
  42. },
  43. illegal: /\{/,
  44. contains: [
  45. hljs.C_BLOCK_COMMENT_MODE, // VHDL-2008 block commenting.
  46. hljs.COMMENT('--', '$'),
  47. hljs.QUOTE_STRING_MODE,
  48. {
  49. className: 'number',
  50. begin: NUMBER_RE,
  51. relevance: 0
  52. },
  53. {
  54. className: 'string',
  55. begin: '\'(U|X|0|1|Z|W|L|H|-)\'',
  56. contains: [ hljs.BACKSLASH_ESCAPE ]
  57. },
  58. {
  59. className: 'symbol',
  60. begin: '\'[A-Za-z](_?[A-Za-z0-9])*',
  61. contains: [ hljs.BACKSLASH_ESCAPE ]
  62. }
  63. ]
  64. };
  65. }
  66. module.exports = vhdl;