PageRenderTime 19ms CodeModel.GetById 8ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://github.com/scalate/scalate
JavaScript | 81 lines | 71 code | 1 blank | 9 comment | 0 complexity | 0b7482ff5409611b26a1034b5c089895 MD5 | raw file
 1/*
 2Language: Lua
 3Author: Andrew Fedorov <dmmdrs@mail.ru>
 4*/
 5
 6hljs.LANGUAGES.lua = function(){
 7  var OPENING_LONG_BRACKET = '\\[=*\\[', CLOSING_LONG_BRACKET = '\\]=*\\]';
 8  return {
 9    defaultMode: {
10      lexems: [hljs.UNDERSCORE_IDENT_RE],
11      keywords: {
12        'keyword': {
13          'and': 1, 'break': 1, 'do': 1, 'else': 1, 'elseif': 1, 'end': 1,
14          'false': 1, 'for': 1, 'if': 1, 'in': 1, 'local': 1, 'nil': 1,
15          'not': 1, 'or': 1, 'repeat': 1, 'return': 1, 'then': 1, 'true': 1,
16          'until': 1, 'while': 1
17        },
18        'built_in': {
19          '_G': 1, '_VERSION': 1, 'assert': 1, 'collectgarbage': 1, 'dofile': 1,
20          'error': 1, 'getfenv': 1, 'getmetatable': 1, 'ipairs': 1, 'load': 1,
21          'loadfile': 1, 'loadstring': 1, 'module': 1, 'next': 1, 'pairs': 1,
22          'pcall': 1, 'print': 1, 'rawequal': 1, 'rawget': 1, 'rawset': 1,
23          'require': 1, 'select': 1, 'setfenv': 1, 'setmetatable': 1,
24          'tonumber': 1, 'tostring': 1, 'type': 1, 'unpack': 1, 'xpcall': 1,
25          'coroutine': 1, 'debug': 1, 'io': 1, 'math': 1, 'os': 1, 'package': 1,
26          'string': 1, 'table': 1
27        }
28      },
29      contains: ['comment', 'function', 'number', 'string']
30    },
31    modes: [
32      // comment
33      {
34        className: 'comment',
35        begin: '--(?!' + OPENING_LONG_BRACKET + ')', end: '$'
36      },
37      {
38        className: 'comment',
39        begin: '--' + OPENING_LONG_BRACKET, end: CLOSING_LONG_BRACKET,
40        contains: ['long_brackets'],
41        relevance: 10
42      },
43      // long_brackets
44      {
45        className: 'long_brackets',
46        begin: OPENING_LONG_BRACKET, end: CLOSING_LONG_BRACKET,
47        contains: ['long_brackets'],
48        noMarkup: true
49      },
50      // function
51      {
52        className: 'function',
53        begin: '\\bfunction\\b', end: '\\)',
54        lexems: [hljs.UNDERSCORE_IDENT_RE],
55        keywords: {'function': 1},
56        contains: ['title', 'params', 'comment']
57      },
58      {
59        className: 'title',
60        begin: '([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*', end: '^'
61      },
62      {
63        className: 'params',
64        begin: '\\(', endsWithParent: true,
65        contains: ['comment']
66      },
67      // number
68      hljs.C_NUMBER_MODE,
69      // string
70      hljs.APOS_STRING_MODE,
71      hljs.QUOTE_STRING_MODE,
72      {
73        className: 'string',
74        begin: OPENING_LONG_BRACKET, end: CLOSING_LONG_BRACKET,
75        contains: ['long_brackets'],
76        relevance: 10
77      },
78      hljs.BACKSLASH_ESCAPE
79    ]
80  };
81}();