vendor/assets/javascripts/highlight_js/languages/erlang.js in highlight_js-rails-0.0.2 vs vendor/assets/javascripts/highlight_js/languages/erlang.js in highlight_js-rails-7.1.0

- old
+ new

@@ -2,50 +2,31 @@ Language: Erlang Description: Erlang is a general-purpose functional language, with strict evaluation, single assignment, and dynamic typing. Author: Nikolay Zakharov <nikolay.desh@gmail.com>, Dmitry Kovega <arhibot@gmail.com> */ -hljs.LANGUAGES.erlang = function(){ +hljs.LANGUAGES['erlang'] = function(hljs) { var BASIC_ATOM_RE = '[a-z\'][a-zA-Z0-9_\']*'; var FUNCTION_NAME_RE = '(' + BASIC_ATOM_RE + ':' + BASIC_ATOM_RE + '|' + BASIC_ATOM_RE + ')'; var ERLANG_RESERVED = { - 'keyword': { - 'after': 1, - 'and': 1, - 'andalso': 10, - 'band': 1, - 'begin': 1, - 'bnot': 1, - 'bor': 1, - 'bsl': 1, - 'bzr': 1, - 'bxor': 1, - 'case': 1, - 'catch': 1, - 'cond': 1, - 'div': 1, - 'end': 1, - 'fun': 1, - 'let': 1, - 'not': 1, - 'of': 1, - 'orelse': 10, - 'query': 1, - 'receive': 1, - 'rem': 1, - 'try': 1, - 'when': 1, - 'xor': 1 - }, - 'literal': {'false': 1, 'true': 1} + keyword: + 'after and andalso|10 band begin bnot bor bsl bzr bxor case catch cond div end fun let ' + + 'not of orelse|10 query receive rem try when xor', + literal: + 'false true' }; var COMMENT = { className: 'comment', begin: '%', end: '$', relevance: 0 }; + var NUMBER = { + className: 'number', + begin: '\\b(\\d+#[a-fA-F0-9]+|\\d+(\\.\\d+)?([eE][-+]?\\d+)?)', + relevance: 0 + }; var NAMED_FUN = { begin: 'fun\\s+' + BASIC_ATOM_RE + '/\\d+' }; var FUNCTION_CALL = { begin: FUNCTION_NAME_RE + '\\(', end: '\\)', @@ -108,11 +89,11 @@ NAMED_FUN, hljs.inherit(hljs.APOS_STRING_MODE, {className: ''}), BLOCK_STATEMENTS, FUNCTION_CALL, hljs.QUOTE_STRING_MODE, - hljs.C_NUMBER_MODE, + NUMBER, TUPLE, VAR1, VAR2, RECORD_ACCESS ]; @@ -120,11 +101,11 @@ COMMENT, NAMED_FUN, BLOCK_STATEMENTS, FUNCTION_CALL, hljs.QUOTE_STRING_MODE, - hljs.C_NUMBER_MODE, + NUMBER, TUPLE, VAR1, VAR2, RECORD_ACCESS ]; FUNCTION_CALL.contains[1].contains = BASIC_MODES; @@ -132,70 +113,52 @@ RECORD_ACCESS.contains[1].contains = BASIC_MODES; var PARAMS = { className: 'params', begin: '\\(', end: '\\)', - endsWithParent: true, contains: BASIC_MODES }; return { defaultMode: { keywords: ERLANG_RESERVED, illegal: '(</|\\*=|\\+=|-=|/=|/\\*|\\*/|\\(\\*|\\*\\))', contains: [ { className: 'function', - begin: '^' + BASIC_ATOM_RE + '\\(', end: ';|\\.', + begin: '^' + BASIC_ATOM_RE + '\\s*\\(', end: '->', returnBegin: true, + illegal: '\\(|#|//|/\\*|\\\\|:', contains: [ PARAMS, { className: 'title', begin: BASIC_ATOM_RE - }, - { - keywords: ERLANG_RESERVED, - begin: '->', endsWithParent: true, - contains: BASIC_MODES } - ] + ], + starts: { + end: ';|\\.', + keywords: ERLANG_RESERVED, + contains: BASIC_MODES + } }, COMMENT, { className: 'pp', begin: '^-', end: '\\.', relevance: 0, excludeEnd: true, returnBegin: true, lexems: '-' + hljs.IDENT_RE, - keywords: { - '-module':1, - '-record':1, - '-undef':1, - '-export':1, - '-ifdef':1, - '-ifndef':1, - '-author':1, - '-copyright':1, - '-doc':1, - '-vsn':1, - '-import': 1, - '-include': 1, - '-include_lib': 1, - '-compile': 1, - '-define': 1, - '-else': 1, - '-endif': 1, - '-file': 1, - '-behaviour': 1, - '-behavior': 1 - }, + keywords: + '-module -record -undef -export -ifdef -ifndef -author -copyright -doc -vsn ' + + '-import -include -include_lib -compile -define -else -endif -file -behaviour ' + + '-behavior', contains: [PARAMS] }, - hljs.C_NUMBER_MODE, + NUMBER, hljs.QUOTE_STRING_MODE, RECORD_ACCESS, VAR1, VAR2, TUPLE ] } }; -}(); +}(hljs);