step21.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. Language: STEP Part 21
  3. Contributors: Adam Joseph Cook <adam.joseph.cook@gmail.com>
  4. Description: Syntax highlighter for STEP Part 21 files (ISO 10303-21).
  5. Website: https://en.wikipedia.org/wiki/ISO_10303-21
  6. */
  7. function step21(hljs) {
  8. const STEP21_IDENT_RE = '[A-Z_][A-Z0-9_.]*';
  9. const STEP21_KEYWORDS = {
  10. $pattern: STEP21_IDENT_RE,
  11. keyword: 'HEADER ENDSEC DATA'
  12. };
  13. const STEP21_START = {
  14. className: 'meta',
  15. begin: 'ISO-10303-21;',
  16. relevance: 10
  17. };
  18. const STEP21_CLOSE = {
  19. className: 'meta',
  20. begin: 'END-ISO-10303-21;',
  21. relevance: 10
  22. };
  23. return {
  24. name: 'STEP Part 21',
  25. aliases: [
  26. 'p21',
  27. 'step',
  28. 'stp'
  29. ],
  30. case_insensitive: true, // STEP 21 is case insensitive in theory, in practice all non-comments are capitalized.
  31. keywords: STEP21_KEYWORDS,
  32. contains: [
  33. STEP21_START,
  34. STEP21_CLOSE,
  35. hljs.C_LINE_COMMENT_MODE,
  36. hljs.C_BLOCK_COMMENT_MODE,
  37. hljs.COMMENT('/\\*\\*!', '\\*/'),
  38. hljs.C_NUMBER_MODE,
  39. hljs.inherit(hljs.APOS_STRING_MODE, {
  40. illegal: null
  41. }),
  42. hljs.inherit(hljs.QUOTE_STRING_MODE, {
  43. illegal: null
  44. }),
  45. {
  46. className: 'string',
  47. begin: "'",
  48. end: "'"
  49. },
  50. {
  51. className: 'symbol',
  52. variants: [
  53. {
  54. begin: '#',
  55. end: '\\d+',
  56. illegal: '\\W'
  57. }
  58. ]
  59. }
  60. ]
  61. };
  62. }
  63. module.exports = step21;