UNPKG

1.5 kBJavaScriptView Raw
1/*
2Language: STEP Part 21
3Contributors: Adam Joseph Cook <adam.joseph.cook@gmail.com>
4Description: Syntax highlighter for STEP Part 21 files (ISO 10303-21).
5Website: https://en.wikipedia.org/wiki/ISO_10303-21
6*/
7
8function 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
29 return {
30 name: 'STEP Part 21',
31 aliases: [
32 'p21',
33 'step',
34 'stp'
35 ],
36 case_insensitive: true, // STEP 21 is case insensitive in theory, in practice all non-comments are capitalized.
37 keywords: STEP21_KEYWORDS,
38 contains: [
39 STEP21_START,
40 STEP21_CLOSE,
41 hljs.C_LINE_COMMENT_MODE,
42 hljs.C_BLOCK_COMMENT_MODE,
43 hljs.COMMENT('/\\*\\*!', '\\*/'),
44 hljs.C_NUMBER_MODE,
45 hljs.inherit(hljs.APOS_STRING_MODE, {
46 illegal: null
47 }),
48 hljs.inherit(hljs.QUOTE_STRING_MODE, {
49 illegal: null
50 }),
51 {
52 className: 'string',
53 begin: "'",
54 end: "'"
55 },
56 {
57 className: 'symbol',
58 variants: [
59 {
60 begin: '#',
61 end: '\\d+',
62 illegal: '\\W'
63 }
64 ]
65 }
66 ]
67 };
68}
69
70export { step21 as default };