highlight-ts
Version:
Highlight.JS in TypeScript (and ES6).
111 lines • 3.32 kB
JavaScript
;
/*
Language: Haskell
Author: Jeremy Hull <sourdrums@gmail.com>
Contributors: Zena Treep <zena.treep@gmail.com>
Category: functional
*/
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var common_1 = require("../common");
var COMMENT = {
variants: [
common_1.COMMENT('--', '$'),
common_1.COMMENT('{-', '-}', {
contains: ['self']
})
]
};
var PRAGMA = {
className: 'meta',
begin: '{-#', end: '#-}'
};
var PREPROCESSOR = {
className: 'meta',
begin: '^#', end: '$'
};
var CONSTRUCTOR = {
className: 'type',
begin: '\\b[A-Z][\\w\']*',
relevance: 0
};
var LIST = {
begin: '\\(', end: '\\)',
illegal: '"',
contains: [
PRAGMA,
PREPROCESSOR,
{ className: 'type', begin: '\\b[A-Z][\\w]*(\\((\\.\\.|,|\\w+)\\))?' },
tslib_1.__assign({}, common_1.TITLE_MODE, { begin: '[_a-z][\\w\']*' }),
COMMENT
]
};
var RECORD = {
begin: '{', end: '}',
contains: LIST.contains
};
exports.Haskell = {
name: 'haskell',
aliases: ['hs'],
keywords: 'let in if then else case of where do module import hiding ' +
'qualified type data newtype deriving class instance as default ' +
'infix infixl infixr foreign export ccall stdcall cplusplus ' +
'jvm dotnet safe unsafe family forall mdo proc rec',
contains: [
// Top-level constructions.
{
beginKeywords: 'module', end: 'where',
keywords: 'module where',
contains: [LIST, COMMENT],
illegal: '\\W\\.|;'
},
{
begin: '\\bimport\\b', end: '$',
keywords: 'import qualified as hiding',
contains: [LIST, COMMENT],
illegal: '\\W\\.|;'
},
{
className: 'class',
begin: '^(\\s*)?(class|instance)\\b', end: 'where',
keywords: 'class family instance where',
contains: [CONSTRUCTOR, LIST, COMMENT]
},
{
className: 'class',
begin: '\\b(data|(new)?type)\\b', end: '$',
keywords: 'data family type newtype deriving',
contains: [PRAGMA, CONSTRUCTOR, LIST, RECORD, COMMENT]
},
{
beginKeywords: 'default', end: '$',
contains: [CONSTRUCTOR, LIST, COMMENT]
},
{
beginKeywords: 'infix infixl infixr', end: '$',
contains: [common_1.C_NUMBER_MODE, COMMENT]
},
{
begin: '\\bforeign\\b', end: '$',
keywords: 'foreign import export ccall stdcall cplusplus jvm ' +
'dotnet safe unsafe',
contains: [CONSTRUCTOR, common_1.QUOTE_STRING_MODE, COMMENT]
},
{
className: 'meta',
begin: '#!\\/usr\\/bin\\/env\ runhaskell', end: '$'
},
// "Whitespaces".
PRAGMA,
PREPROCESSOR,
// Literals and names.
// TODO: characters.
common_1.QUOTE_STRING_MODE,
common_1.C_NUMBER_MODE,
CONSTRUCTOR,
tslib_1.__assign({}, common_1.TITLE_MODE, { begin: '^[_a-z][\\w\']*' }),
COMMENT,
{ begin: '->|<-' } // No markup, relevance booster
]
};
//# sourceMappingURL=haskell.js.map