UNPKG

livescript

Version:

LiveScript is a language which compiles to JavaScript. It has a straightforward mapping to JavaScript and allows you to write expressive code devoid of repetitive boilerplate. While LiveScript adds many features to assist in functional style programming,

21 lines 2.47 kB
// Generated by LiveScript 1.6.0 var tint, ident, kwend, interps, regexes; tint = function(ext, shortcuts, fallthroughs){ var i$, len$, rule; for (i$ = 0, len$ = shortcuts.length; i$ < len$; ++i$) { rule = shortcuts[i$]; if (rule.length < 4) { rule.splice(2, 0, 0); } } return PR.registerLangHandler(PR.createSimpleLexer(shortcuts, fallthroughs), [ext]); }; ident = '(?![\\d\\s])[$\\w\\xAA-\\uFFDC](?:(?!\\s)[$\\w\\xAA-\\uFFDC]|-[A-Za-z])*'; kwend = '(?!(?!\\s)[$\\w\\xAA-\\uFFDC]|-[A-Za-z])'; tint('ls', [['str', /^'(?:''[\S\s]*?''|[^\\']*(?:\\[\S\s][^\\']*)*)'/, '\''], ['lang-ls-qq', /(^"(?:""[\S\s]*?""|[^\\"]*(?:\\[\S\s][^\\"]*)*)")/, '"'], ['lang-ls-qr', /(^\/\/[\S\s]*?\/\/[gimy$?]{0,4})/, '/'], ['lang-ls-at', RegExp('(^@@?' + ident + '?)'), '@'], ['com', /^#.*/, '#'], ['typ', /^(?:0x[\da-f][\da-f_]*|(?:[2-9]|[12]\d|3[0-6])r[\da-z][\da-z_]*|\d[\d_]*(?:\.\d[\d_]*)?(?:e[+-]?\d[\d_]*)?[\w$]*)/i, '0123456789'], ['lang-js', /^`([^\\`]*(?:\\[\S\s][^\\`]*)*)`/, '`']], [['str', /^\\\S[^\s,;)}\]]*/], ['com', /^\/\*[\S\s]*\*\//], ['pln', RegExp('^(?:\\.{3}|(?:\\.\\s*(?:(?:[-+*/%&|^:]|>>>?|<<)?=|[~!@])?\\s*|[)}\\]?]|::)(?:' + ident + '[?~!@]?)+|' + ident + '[^\\n\\S]*:(?![:=]))')], ['kwd', RegExp('^(?![$_-])(?:t(?:ry|h(?:row|en)|ypeof!?)|f(?:or(?:[^\\n\\S]+(?:own|ever))?|inally|unction)|n(?:ew|ot|o)|c(?:on(?:tinue|st)|a(?:se|tch)|lass)|i(?:[fs]|n(?:stanceof)?|mp(?:ort(?:[^\\n\\S]+all)?|lements))|e(?:lse|x(?:tends|port))|d(?:e(?:fault|lete|bugger)|o)|un(?:less|til)|w(?:hile|ith|hen)|s(?:witch|uper)|a(?:nd|wait)|o[frn]|off|return|break|let|var|loop|yes|yield)' + kwend)], ['typ', RegExp('^(?:true|false|null|void)' + kwend)], ['ctx', RegExp('^(?:t(?:h(?:is|at)|o|il)|f(?:rom|allthrough)|e(?:val)?|it|arguments|by|constructor|prototype|superclass|async)' + kwend)], ['glb', RegExp('^(?:Array|Boolean|Date|Error|Function|JSON|Math|Number|Object|RegExp|S(?:tring|yntaxError)|TypeError|is(?:NaN|Finite)|parse(?:Int|Float)|(?:en|de)codeURI(?:Component)?)' + kwend)], ['var', RegExp('^' + ident)], ['str', /^<\[[\S\s]*?]>/], ['lang-ls-r', /^[^\/](\/(?![\s\/])[^[\/\n\\]*(?:(?:\\.|\[[^\]\n\\]*(?:\\.[^\]\n\\]*)*\])[^[\/\n\\]*)*\/[gimy$]{0,4})(?!\d)/]]); interps = ['lang-ls', RegExp('^#({[\\S\\s]*?}|' + ident + ')'), '#']; regexes = ['lit', /^[\S\s]+?/]; tint('ls-qq', [interps], [['str', /^[\S\s]+?/]]); tint('ls-qr', [interps], [['com', /^\s#(?!{).*/], regexes]); tint('ls-r', [], [regexes]); tint('ls-at', [['ctx', /^@+/, '@']], []);