PageRenderTime 31ms CodeModel.GetById 20ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 1ms

/samples/scalate-presentation/src/highlight/languages/lisp.js

http://github.com/scalate/scalate
JavaScript | 95 lines | 89 code | 1 blank | 5 comment | 0 complexity | f8fb9c4c62b9597ddf0168f5522af940 MD5 | raw file
 1/*
 2Language: Lisp
 3Description: Generic lisp syntax
 4Author: Vasily Polovnyov <vast@whiteants.net>
 5*/
 6
 7hljs.LANGUAGES.lisp = function(){
 8  var LISP_IDENT_RE = '[a-zA-Z_\\-\\+\\*\\/\\<\\=\\>\\&\\#][a-zA-Z0-9_\\-\\+\\*\\/\\<\\=\\>\\&\\#]*'
 9  var LISP_SIMPLE_NUMBER_RE = '(\\-|\\+)?\\d+(\\.\\d+|\\/\\d+)?((d|e|f|l|s)(\\+|\\-)?\\d+)?'
10  return {
11    case_insensitive: true,
12    defaultMode: {
13      lexems: [LISP_IDENT_RE],
14      contains: ['literal', 'number', 'string', 'comment', 'quoted', 'list'],
15      illegal: '[^\\s]'
16    },
17    modes: [
18      {
19        className: 'string',
20        begin: '"', end: '"',
21        contains: ['escape'],
22        relevance: 0
23      },
24      hljs.BACKSLASH_ESCAPE,
25      {
26        className: 'number',
27        begin: LISP_SIMPLE_NUMBER_RE, end: '^'
28      },
29      {
30        className: 'number',
31        begin: '#b[0-1]+(/[0-1]+)?', end: '^'
32      },
33      {
34        className: 'number',
35        begin: '#o[0-7]+(/[0-7]+)?', end: '^'
36      },
37      {
38        className: 'number',
39        begin: '#x[0-9a-f]+(/[0-9a-f]+)?', end: '^'
40      },
41      {
42        className: 'number',
43        begin: '#c\\(' + LISP_SIMPLE_NUMBER_RE + ' +' + LISP_SIMPLE_NUMBER_RE, end: '\\)'
44      },
45      {
46        className: 'comment',
47        begin: ';', end: '$'
48      },
49      {
50        className: 'quoted',
51        begin: '[\'`]\\(', end: '\\)',
52        contains: ['number', 'string', 'variable', 'keyword', 'quoted_list']
53      },
54      {
55        className: 'quoted',
56        begin: '\\(quote ', end: '\\)',
57        contains: ['number', 'string', 'variable', 'keyword', 'quoted_list'],
58        lexems: [LISP_IDENT_RE],
59        keywords: {'title': {'quote': 1}}
60      },
61      {
62        className: 'quoted_list',
63        begin: '\\(', end: '\\)',
64        contains: ['quoted_list', 'literal', 'number', 'string']
65      },
66      {
67        className: 'list',
68        begin: '\\(', end: '\\)',
69        contains: ['title','body']
70      },
71      {
72        className: 'title',
73        begin: LISP_IDENT_RE, end: '^',
74        endsWithParent: true
75      },
76      {
77        className: 'body',
78        begin: '^', endsWithParent: true, excludeEnd: true,
79        contains: ['quoted', 'list', 'literal', 'number', 'string', 'comment', 'variable', 'keyword']
80      },
81      {
82        className: 'keyword',
83        begin: '[:&]' + LISP_IDENT_RE, end: '^'
84      },
85      {
86        className: 'variable',
87        begin: '\\*', end: '\\*'
88      },
89      {
90        className: 'literal',
91        begin: '\\b(t{1}|nil)\\b', end: '^'
92      }
93    ]
94  };
95}();