/*
Language: STEP Part 21 (ISO 10303-21)
Contributors: Adam Joseph Cook <adam.joseph.cook@gmail.com>
Description: Syntax highlighter for STEP Part 21 files (ISO 10303-21).
*/

function(hljs) {
  var STEP21_IDENT_RE = '[A-Z_][A-Z0-9_.]*';
  var STEP21_CLOSE_RE = 'END-ISO-10303-21;';
  var STEP21_KEYWORDS = {
    literal: '',
    built_in: '',
    keyword:
    'HEADER ENDSEC DATA'
  };
  var STEP21_START = {
    className: 'preprocessor',
    begin: 'ISO-10303-21;',
    relevance: 10
  };
  var STEP21_CODE = [
    hljs.C_LINE_COMMENT_MODE,
    hljs.C_BLOCK_COMMENT_MODE,
    hljs.COMMENT('/\\*\\*!', '\\*/'),
    hljs.C_NUMBER_MODE,
    hljs.inherit(hljs.APOS_STRING_MODE, {illegal: null}),
    hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null}),
    {
      className: 'string',
      begin: "'", end: "'"
    },
    {
      className: 'label',
      variants: [
        {
          begin: '#', end: '\\d+',
          illegal: '\\W'
        }
      ]
    }
  ];

  return {
    aliases: ['p21', 'step', 'stp'],
    case_insensitive: true, // STEP 21 is case insensitive in theory, in practice all non-comments are capitalized.
    lexemes: STEP21_IDENT_RE,
    keywords: STEP21_KEYWORDS,
    contains: [
      {
        className: 'preprocessor',
        begin: STEP21_CLOSE_RE,
        relevance: 10
      },
      STEP21_START
    ].concat(STEP21_CODE)
  };
}

@@ -248,38 +248,58 @@
 P21_
-CLOSE_RE = 'END-ISO-10303-21;'
+KEYWORDS = %7B%0A    keyword: 'HEADER ENDSEC DATA'%0A  %7D
 ;%0A  
@@ -305,32 +305,29 @@
  var STEP21_
-KEYWORDS
+START
  = %7B%0A    lit
@@ -327,76 +327,72 @@
     
-literal: '',%0A    built_in: '',%0A    keyword:%0A    'HEADER ENDSEC DATA'
+className: 'meta',%0A    begin: 'ISO-10303-21;',%0A    relevance: 10
 %0A  %7D
@@ -398,37 +398,37 @@
 %7D;%0A  var STEP21_
-START
+CLOSE
  = %7B%0A    classNa
@@ -428,36 +428,28 @@
 className: '
-preprocessor
+meta
 ',%0A    begin
@@ -443,32 +443,36 @@
 a',%0A    begin: '
+END-
 ISO-10303-21;',%0A
@@ -498,30 +498,292 @@
  %7D;%0A
+%0A
   
-var STEP21_CODE = %5B%0A
+return %7B%0A    aliases: %5B'p21', 'step', 'stp'%5D,%0A    case_insensitive: true, // STEP 21 is case insensitive in theory, in practice all non-comments are capitalized.%0A    lexemes: STEP21_IDENT_RE,%0A    keywords: STEP21_KEYWORDS,%0A    contains: %5B%0A      STEP21_START,%0A      STEP21_CLOSE,%0A  
     
@@ -800,32 +800,34 @@
 E_COMMENT_MODE,%0A
+  
     hljs.C_BLOCK
@@ -841,24 +841,26 @@
 T_MODE,%0A    
+ 
+ 
 hljs.COMMENT
@@ -881,16 +881,18 @@
 %5C%5C*/'),%0A
+  
     hljs
@@ -907,24 +907,26 @@
 R_MODE,%0A    
+  
 hljs.inherit
@@ -963,24 +963,26 @@
 al: null%7D),%0A
+  
     hljs.inh
@@ -1028,32 +1028,34 @@
 null%7D),%0A    
+  
 %7B%0A      
 className: '
@@ -1034,32 +1034,34 @@
 ,%0A      %7B%0A      
+ 
+ 
 className: 'stri
@@ -1065,16 +1065,18 @@
 tring',%0A
+  
       be
@@ -1102,17 +1102,23 @@
     
+  
 %7D,%0A    
+ 
+ 
 %7B%0A
+  
     
@@ -1135,16 +1135,19 @@
 e: '
-labe
+symbo
 l',%0A
+  
     
@@ -1156,24 +1156,26 @@
 variants: %5B%0A
+  
         %7B%0A  
@@ -1178,24 +1178,26 @@
 %7B%0A          
+  
 begin: '#', 
@@ -1219,16 +1219,18 @@
         
+  
 illegal:
@@ -1248,421 +1248,35 @@
     
-%7D%0A      %5D%0A    %7D%0A  %5D;%0A%0A  return %7B%0A    aliases: %5B'p21', 'step', 'stp'%5D,%0A    case_insensitive: true, // STEP 21 is case insensitive in theory, in practice all non-comments are capitalized.%0A    lexemes: STEP21_IDENT_RE,%0A    keywords: STEP21_KEYWORDS,%0A    contains: %5B%0A      %7B%0A        className: 'preprocessor',%0A        begin: STEP21_CLOSE_RE,%0A        relevance: 10%0A      %7D,%0A      STEP21_START%0A    %5D.concat(STEP21_CODE)
+  %7D%0A        %5D%0A      %7D%0A    %5D
 %0A  %7D

Update step21 to new styles