l0bsterssg

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

smalltalk.js (1509B)


      1 /*
      2 Language: Smalltalk
      3 Description: Smalltalk is an object-oriented, dynamically typed reflective programming language.
      4 Author: Vladimir Gubarkov <xonixx@gmail.com>
      5 Website: https://en.wikipedia.org/wiki/Smalltalk
      6 */
      7 
      8 function smalltalk(hljs) {
      9   var VAR_IDENT_RE = '[a-z][a-zA-Z0-9_]*';
     10   var CHAR = {
     11     className: 'string',
     12     begin: '\\$.{1}'
     13   };
     14   var SYMBOL = {
     15     className: 'symbol',
     16     begin: '#' + hljs.UNDERSCORE_IDENT_RE
     17   };
     18   return {
     19     name: 'Smalltalk',
     20     aliases: ['st'],
     21     keywords: 'self super nil true false thisContext', // only 6
     22     contains: [
     23       hljs.COMMENT('"', '"'),
     24       hljs.APOS_STRING_MODE,
     25       {
     26         className: 'type',
     27         begin: '\\b[A-Z][A-Za-z0-9_]*',
     28         relevance: 0
     29       },
     30       {
     31         begin: VAR_IDENT_RE + ':',
     32         relevance: 0
     33       },
     34       hljs.C_NUMBER_MODE,
     35       SYMBOL,
     36       CHAR,
     37       {
     38         // This looks more complicated than needed to avoid combinatorial
     39         // explosion under V8. It effectively means `| var1 var2 ... |` with
     40         // whitespace adjacent to `|` being optional.
     41         begin: '\\|[ ]*' + VAR_IDENT_RE + '([ ]+' + VAR_IDENT_RE + ')*[ ]*\\|',
     42         returnBegin: true, end: /\|/,
     43         illegal: /\S/,
     44         contains: [{begin: '(\\|[ ]*)?' + VAR_IDENT_RE}]
     45       },
     46       {
     47         begin: '\\#\\(', end: '\\)',
     48         contains: [
     49           hljs.APOS_STRING_MODE,
     50           CHAR,
     51           hljs.C_NUMBER_MODE,
     52           SYMBOL
     53         ]
     54       }
     55     ]
     56   };
     57 }
     58 
     59 module.exports = smalltalk;