l0bsterssg

node.js static responsive blog post generator
Log | Files | Refs | README

delphi.js (3047B)


      1 /*
      2 Language: Delphi
      3 Website: https://www.embarcadero.com/products/delphi
      4 */
      5 
      6 /** @type LanguageFn */
      7 function delphi(hljs) {
      8   var KEYWORDS =
      9     'exports register file shl array record property for mod while set ally label uses raise not ' +
     10     'stored class safecall var interface or private static exit index inherited to else stdcall ' +
     11     'override shr asm far resourcestring finalization packed virtual out and protected library do ' +
     12     'xorwrite goto near function end div overload object unit begin string on inline repeat until ' +
     13     'destructor write message program with read initialization except default nil if case cdecl in ' +
     14     'downto threadvar of try pascal const external constructor type public then implementation ' +
     15     'finally published procedure absolute reintroduce operator as is abstract alias assembler ' +
     16     'bitpacked break continue cppdecl cvar enumerator experimental platform deprecated ' +
     17     'unimplemented dynamic export far16 forward generic helper implements interrupt iochecks ' +
     18     'local name nodefault noreturn nostackframe oldfpccall otherwise saveregisters softfloat ' +
     19     'specialize strict unaligned varargs ';
     20   var COMMENT_MODES = [
     21     hljs.C_LINE_COMMENT_MODE,
     22     hljs.COMMENT(/\{/, /\}/, {relevance: 0}),
     23     hljs.COMMENT(/\(\*/, /\*\)/, {relevance: 10})
     24   ];
     25   var DIRECTIVE = {
     26     className: 'meta',
     27     variants: [
     28       {begin: /\{\$/, end: /\}/},
     29       {begin: /\(\*\$/, end: /\*\)/}
     30     ]
     31   };
     32   var STRING = {
     33     className: 'string',
     34     begin: /'/, end: /'/,
     35     contains: [{begin: /''/}]
     36   };
     37   var NUMBER = {
     38     className: 'number',
     39     relevance: 0,
     40     // Source: https://www.freepascal.org/docs-html/ref/refse6.html
     41     variants: [
     42       {
     43         // Hexadecimal notation, e.g., $7F.
     44         begin: '\\$[0-9A-Fa-f]+',
     45       },
     46       {
     47         // Octal notation, e.g., &42.
     48         begin: '&[0-7]+',
     49       },
     50       {
     51         // Binary notation, e.g., %1010.
     52         begin: '%[01]+',
     53       }
     54     ]
     55   };
     56   var CHAR_STRING = {
     57     className: 'string', begin: /(#\d+)+/
     58   };
     59   var CLASS = {
     60     begin: hljs.IDENT_RE + '\\s*=\\s*class\\s*\\(', returnBegin: true,
     61     contains: [
     62       hljs.TITLE_MODE
     63     ]
     64   };
     65   var FUNCTION = {
     66     className: 'function',
     67     beginKeywords: 'function constructor destructor procedure', end: /[:;]/,
     68     keywords: 'function constructor|10 destructor|10 procedure|10',
     69     contains: [
     70       hljs.TITLE_MODE,
     71       {
     72         className: 'params',
     73         begin: /\(/, end: /\)/,
     74         keywords: KEYWORDS,
     75         contains: [STRING, CHAR_STRING, DIRECTIVE].concat(COMMENT_MODES)
     76       },
     77       DIRECTIVE
     78     ].concat(COMMENT_MODES)
     79   };
     80   return {
     81     name: 'Delphi',
     82     aliases: ['dpr', 'dfm', 'pas', 'pascal', 'freepascal', 'lazarus', 'lpr', 'lfm'],
     83     case_insensitive: true,
     84     keywords: KEYWORDS,
     85     illegal: /"|\$[G-Zg-z]|\/\*|<\/|\|/,
     86     contains: [
     87       STRING, CHAR_STRING,
     88       hljs.NUMBER_MODE,
     89       NUMBER,
     90       CLASS,
     91       FUNCTION,
     92       DIRECTIVE
     93     ].concat(COMMENT_MODES)
     94   };
     95 }
     96 
     97 module.exports = delphi;