step21.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. Category: syntax
  7. */
  8. function step21(hljs) {
  9. const STEP21_IDENT_RE = '[A-Z_][A-Z0-9_.]*';
  10. const STEP21_KEYWORDS = {
  11. $pattern: STEP21_IDENT_RE,
  12. keyword: [
  13. "HEADER",
  14. "ENDSEC",
  15. "DATA"
  16. ]
  17. };
  18. const STEP21_START = {
  19. className: 'meta',
  20. begin: 'ISO-10303-21;',
  21. relevance: 10
  22. };
  23. const STEP21_CLOSE = {
  24. className: 'meta',
  25. begin: 'END-ISO-10303-21;',
  26. relevance: 10
  27. };
  28. return {
  29. name: 'STEP Part 21',
  30. aliases: [
  31. 'p21',
  32. 'step',
  33. 'stp'
  34. ],
  35. case_insensitive: true, // STEP 21 is case insensitive in theory, in practice all non-comments are capitalized.
  36. keywords: STEP21_KEYWORDS,
  37. contains: [
  38. STEP21_START,
  39. STEP21_CLOSE,
  40. hljs.C_LINE_COMMENT_MODE,
  41. hljs.C_BLOCK_COMMENT_MODE,
  42. hljs.COMMENT('/\\*\\*!', '\\*/'),
  43. hljs.C_NUMBER_MODE,
  44. hljs.inherit(hljs.APOS_STRING_MODE, { illegal: null }),
  45. hljs.inherit(hljs.QUOTE_STRING_MODE, { illegal: null }),
  46. {
  47. className: 'string',
  48. begin: "'",
  49. end: "'"
  50. },
  51. {
  52. className: 'symbol',
  53. variants: [
  54. {
  55. begin: '#',
  56. end: '\\d+',
  57. illegal: '\\W'
  58. }
  59. ]
  60. }
  61. ]
  62. };
  63. }
  64. export { step21 as default };