vhdl.js 2.8 KB

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