l0bsterssg

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

sml.js (2233B)


      1 /*
      2 Language: SML (Standard ML)
      3 Author: Edwin Dalorzo <edwin@dalorzo.org>
      4 Description: SML language definition.
      5 Website: https://www.smlnj.org
      6 Origin: ocaml.js
      7 Category: functional
      8 */
      9 function sml(hljs) {
     10   return {
     11     name: 'SML (Standard ML)',
     12     aliases: ['ml'],
     13     keywords: {
     14       $pattern: '[a-z_]\\w*!?',
     15       keyword:
     16         /* according to Definition of Standard ML 97  */
     17         'abstype and andalso as case datatype do else end eqtype ' +
     18         'exception fn fun functor handle if in include infix infixr ' +
     19         'let local nonfix of op open orelse raise rec sharing sig ' +
     20         'signature struct structure then type val with withtype where while',
     21       built_in:
     22         /* built-in types according to basis library */
     23         'array bool char exn int list option order real ref string substring vector unit word',
     24       literal:
     25         'true false NONE SOME LESS EQUAL GREATER nil'
     26     },
     27     illegal: /\/\/|>>/,
     28     contains: [
     29       {
     30         className: 'literal',
     31         begin: /\[(\|\|)?\]|\(\)/,
     32         relevance: 0
     33       },
     34       hljs.COMMENT(
     35         '\\(\\*',
     36         '\\*\\)',
     37         {
     38           contains: ['self']
     39         }
     40       ),
     41       { /* type variable */
     42         className: 'symbol',
     43         begin: '\'[A-Za-z_](?!\')[\\w\']*'
     44         /* the grammar is ambiguous on how 'a'b should be interpreted but not the compiler */
     45       },
     46       { /* polymorphic variant */
     47         className: 'type',
     48         begin: '`[A-Z][\\w\']*'
     49       },
     50       { /* module or constructor */
     51         className: 'type',
     52         begin: '\\b[A-Z][\\w\']*',
     53         relevance: 0
     54       },
     55       { /* don't color identifiers, but safely catch all identifiers with '*/
     56         begin: '[a-z_]\\w*\'[\\w\']*'
     57       },
     58       hljs.inherit(hljs.APOS_STRING_MODE, {className: 'string', relevance: 0}),
     59       hljs.inherit(hljs.QUOTE_STRING_MODE, {illegal: null}),
     60       {
     61         className: 'number',
     62         begin:
     63           '\\b(0[xX][a-fA-F0-9_]+[Lln]?|' +
     64           '0[oO][0-7_]+[Lln]?|' +
     65           '0[bB][01_]+[Lln]?|' +
     66           '[0-9][0-9_]*([Lln]|(\\.[0-9_]*)?([eE][-+]?[0-9_]+)?)?)',
     67         relevance: 0
     68       },
     69       {
     70         begin: /[-=]>/ // relevance booster
     71       }
     72     ]
     73   };
     74 }
     75 
     76 module.exports = sml;