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: [
  12. "HEADER",
  13. "ENDSEC",
  14. "DATA"
  15. ]
  16. };
  17. const STEP21_START = {
  18. className: 'meta',
  19. begin: 'ISO-10303-21;',
  20. relevance: 10
  21. };
  22. const STEP21_CLOSE = {
  23. className: 'meta',
  24. begin: 'END-ISO-10303-21;',
  25. relevance: 10
  26. };
  27. return {
  28. name: 'STEP Part 21',
  29. aliases: [
  30. 'p21',
  31. 'step',
  32. 'stp'
  33. ],
  34. case_insensitive: true, // STEP 21 is case insensitive in theory, in practice all non-comments are capitalized.
  35. keywords: STEP21_KEYWORDS,
  36. contains: [
  37. STEP21_START,
  38. STEP21_CLOSE,
  39. hljs.C_LINE_COMMENT_MODE,
  40. hljs.C_BLOCK_COMMENT_MODE,
  41. hljs.COMMENT('/\\*\\*!', '\\*/'),
  42. hljs.C_NUMBER_MODE,
  43. hljs.inherit(hljs.APOS_STRING_MODE, { illegal: null }),
  44. hljs.inherit(hljs.QUOTE_STRING_MODE, { illegal: null }),
  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;