l0bsterssg

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

brainfuck.js (879B)


      1 /*
      2 Language: Brainfuck
      3 Author: Evgeny Stepanischev <imbolk@gmail.com>
      4 Website: https://esolangs.org/wiki/Brainfuck
      5 */
      6 
      7 /** @type LanguageFn */
      8 function brainfuck(hljs) {
      9   var LITERAL = {
     10     className: 'literal',
     11     begin: '[\\+\\-]',
     12     relevance: 0
     13   };
     14   return {
     15     name: 'Brainfuck',
     16     aliases: ['bf'],
     17     contains: [
     18       hljs.COMMENT(
     19         '[^\\[\\]\\.,\\+\\-<> \r\n]',
     20         '[\\[\\]\\.,\\+\\-<> \r\n]',
     21         {
     22           returnEnd: true,
     23           relevance: 0
     24         }
     25       ),
     26       {
     27         className: 'title',
     28         begin: '[\\[\\]]',
     29         relevance: 0
     30       },
     31       {
     32         className: 'string',
     33         begin: '[\\.,]',
     34         relevance: 0
     35       },
     36       {
     37         // this mode works as the only relevance counter
     38         begin: /(?:\+\+|\-\-)/,
     39         contains: [LITERAL]
     40       },
     41       LITERAL
     42     ]
     43   };
     44 }
     45 
     46 module.exports = brainfuck;