You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

35 lines
13 KiB

/*!
* monaco-ace-tokenizer
* Version - 0.1.1
* Author - Brijesh Bittu <brijesh@bitwiser.in> (http://bitwiser.in/)
*/
/*!
* For files in src/ace/
*
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("monaco-editor")):"function"==typeof define&&define.amd?define(["vs/editor/editor.main"],t):"object"==typeof exports?exports.MonacoAceTokenizer=t(require("monaco-editor")):e.MonacoAceTokenizer=t(e.monaco)}(self,function(e){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=2e3,o=function(e){for(var t in this.states=e,this.regExps={},this.matchMappings={},this.states){for(var n=this.states[t],r=[],o=0,i=this.matchMappings[t]={defaultToken:"text"},s="g",u=[],a=0;a<n.length;a++){var l=n[a];if(l.defaultToken&&(i.defaultToken=l.defaultToken),l.caseInsensitive&&(s="gi"),null!=l.regex){l.regex instanceof RegExp&&(l.regex=l.regex.toString().slice(1,-1));var f=l.regex,c=new RegExp("(?:("+f+")|(.))").exec("a").length-2;Array.isArray(l.token)?1==l.token.length||1==c?l.token=l.token[0]:c-1!=l.token.length?(this.reportError("number of classes and regexp groups doesn't match",{rule:l,groupCount:c-1}),l.token=l.token[0]):(l.tokenArray=l.token,l.token=null,l.onMatch=this.$arrayTokens):"function"!=typeof l.token||l.onMatch||(l.onMatch=c>1?this.$applyToken:l.token),c>1&&(/\\\d/.test(l.regex)?f=l.regex.replace(/\\([0-9]+)/g,function(e,t){return"\\"+(parseInt(t,10)+o+1)}):(c=1,f=this.removeCapturingGroups(l.regex)),l.splitRegex||"string"==typeof l.token||u.push(l)),i[o]=a,o+=c,r.push(f),l.onMatch||(l.onMatch=null)}}r.length||(i[0]=0,r.push("$")),u.forEach(function(e){e.splitRegex=this.createSplitterRegexp(e.regex,s)},this),this.regExps[t]=new RegExp("("+r.join(")|(")+")|($)",s)}};(function(){this.$setMaxTokenCount=function(e){r=0|e},this.$applyToken=function(e){var t=this.splitRegex.exec(e).slice(1),n=this.token.apply(this,t);if("string"==typeof n)return[{type:n,value:e}];for(var r=[],o=0,i=n.length;o<i;o++)t[o]&&(r[r.length]={type:n[o],value:t[o]});return r},this.$arrayTokens=function(e){if(!e)return[];var t=this.splitRegex.exec(e);if(!t)return"text";for(var n=[],r=this.tokenArray,o=0,i=r.length;o<i;o++)t[o+1]&&(n[n.length]={type:r[o],value:t[o+1]});return n},this.removeCapturingGroups=function(e){return e.replace(/\\.|\[(?:\\.|[^\\\]])*|\(\?[:=!]|(\()/g,function(e,t){return t?"(?:":e})},this.createSplitterRegexp=function(e,t){if(-1!=e.indexOf("(?=")){var n=0,r=!1,o={};e.replace(/(\\.)|(\((?:\?[=!])?)|(\))|([\[\]])/g,function(e,t,i,s,u,a){return r?r="]"!=u:u?r=!0:s?(n==o.stack&&(o.end=a+1,o.stack=-1),n--):i&&(n++,1!=i.length&&(o.stack=n,o.start=a)),e}),null!=o.end&&/^\)*$/.test(e.substr(o.end))&&(e=e.substring(0,o.start)+e.substr(o.end))}return"^"!=e.charAt(0)&&(e="^"+e),"$"!=e.charAt(e.length-1)&&(e+="$"),new RegExp(e,(t||"").replace("g",""))},this.getLineTokens=function(e,t){if(t&&"string"!=typeof t)"#tmp"===(t=(n=t.slice(0))[0])&&(n.shift(),t=n.shift());else var n=[];var o=t||"start",i=this.states[o];i||(o="start",i=this.states[o]);var s=this.matchMappings[o],u=this.regExps[o];u.lastIndex=0;for(var a,l=[],f=0,c=0,p={type:null,value:""};a=u.exec(e);){var h=s.defaultToken,g=null,d=a[0],y=u.lastIndex;if(y-d.length>f){var v=e.substring(f,y-d.length);p.type==h?p.value+=v:(p.type&&l.push(p),p={type:h,value:v})}for(var x=0;x<a.length-2;x++)if(void 0!==a[x+1]){h=(g=i[s[x]]).onMatch?g.onMatch(d,o,n,e):g.token,g.next&&(o="string"==typeof g.next?g.next:g.next(o,n),(i=this.states[o])||(this.reportError("state doesn't exist",o),o="start",i=this.states[o]),s=this.matchMappings[o],f=y,(u=this.regExps[o]).lastIndex=y),g.consumeLineEnd&&(f=y);break}if(d)if("string"==typeof h)g&&!1===g.merge||p.type!==h?(p.type&&l.push(p),p={type:h,value:d}):p.value+=d;else if(h){p.type&&l.push(p),p={type:null,value:""};for(x=0;x<h.length;x++)l.push(h[x])}if(f==e.length)break;if(f=y,c++>r){for(c>2*e.length&&this.reportError("infinite loop with in ace tokenizer",{startState:t,line:e});f<e.length;)p.type&&l.push(p),p={value:e.substring(f,f+=2e3),type:"overflow"};o="start",n=[];break}}return p.type&&l.push(p),n.length>1&&n[0]!==o&&n.unshift("#tmp",o),{tokens:l,state:n.length?n:o}},this.reportError=function(){console.log(arguments)}}).call(o.prototype),t.default=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function o(e){if("object"!==(void 0===e?"undefined":r(e))||!e)return e;var t;if(Array.isArray(e)){t=[];for(var n=0;n<e.length;n++)t[n]=o(e[n]);return t}if("[object Object]"!==Object.prototype.toString.call(e))return e;for(var n in t={},e)t[n]=o(e[n]);return t}var i=function(){this.$rules={start:[{token:"empty_line",regex:"^$"},{defaultToken:"text"}]}};(function(){this.addRules=function(e,t){if(t)for(var n in e){for(var r=e[n],o=0;o<r.length;o++){var i=r[o];(i.next||i.onMatch)&&("string"==typeof i.next&&0!==i.next.indexOf(t)&&(i.next=t+i.next),i.nextState&&0!==i.nextState.indexOf(t)&&(i.nextState=t+i.nextState))}this.$rules[t+n]=r}else for(var n in e)this.$rules[n]=e[n]},this.getRules=function(){return this.$rules},this.embedRules=function(e,t,n,r,i){var s="function"==typeof e?(new e).getRules():e;if(r)for(var u=0;u<r.length;u++)r[u]=t+r[u];else for(var a in r=[],s)r.push(t+a);if(this.addRules(s,t),n){var l=Array.prototype[i?"push":"unshift"];for(u=0;u<r.length;u++)l.apply(this.$rules[r[u]],o(n))}this.$embeds||(this.$embeds=[]),this.$embeds.push(t)},this.getEmbeds=function(){return this.$embeds};var e=function(e,t){return("start"!=e||t.length)&&t.unshift(this.nextState,e),this.nextState},t=function(e,t){return t.shift(),t.shift()||"start"};this.normalizeRules=function(){var n=0,r=this.$rules;Object.keys(r).forEach(function o(i){var s=r[i];s.processed=!0;for(var u=0;u<s.length;u++){var a=s[u],l=null;Array.isArray(a)&&(l=a,a={}),!a.regex&&a.start&&(a.regex=a.start,a.next||(a.next=[]),a.next.push({defaultToken:a.token},{token:a.token+".end",regex:a.end||a.start,next:"pop"}),a.token=a.token+".start",a.push=!0);var f=a.next||a.push;if(f&&Array.isArray(f)){var c=a.stateName;c||("string"!=typeof(c=a.token)&&(c=c[0]||""),r[c]&&(c+=n++)),r[c]=f,a.next=c,o(c)}else"pop"==f&&(a.next=t);if(a.push&&(a.nextState=a.next||a.push,a.next=e,delete a.push),a.rules)for(var p in a.rules)r[p]?r[p].push&&r[p].push.apply(r[p],a.rules[p]):r[p]=a.rules[p];var h="string"==typeof a?a:a.include;if(h&&(l=Array.isArray(h)?h.map(function(e){return r[e]}):r[h]),l){var g=[u,1].concat(l);a.noEscape&&(g=g.filter(function(e){return!e.next})),s.splice.apply(s,g),u--}a.keywordMap&&(a.token=this.createKeywordMapper(a.keywordMap,a.defaultToken||"text",a.caseInsensitive),delete a.defaultToken)}},this)},this.createKeywordMapper=function(e,t,n,r){var o=Object.create(null);return Object.keys(e).forEach(function(t){var i=e[t];n&&(i=i.toLowerCase());for(var s=i.split(r||"|"),u=s.length;u--;)o[s[u]]=t}),Object.getPrototypeOf(o)&&(o.__proto__=null),this.$keywordList=Object.keys(o),e=null,n?function(e){return o[e.toLowerCase()]||t}:function(e){return o[e]||t}},this.getKeywords=function(){return this.$keywords}}).call(i.prototype),t.TextHighlightRules=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.inherits=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.oop=t.registerRulesForLanguage=t.AVAILABLE_LANGUAGES=t.DocCommentHighlightRules=t.TextHighlightRules=t.Tokenizer=void 0;var r=n(0);Object.defineProperty(t,"Tokenizer",{enumerable:!0,get:function(){return function(e){return e&&e.__esModule?e:{default:e}}(r).default}});var o=n(1);Object.defineProperty(t,"TextHighlightRules",{enumerable:!0,get:function(){return o.TextHighlightRules}});var i=n(4);Object.defineProperty(t,"DocCommentHighlightRules",{enumerable:!0,get:function(){return i.DocCommentHighlightRules}});var s=n(5);Object.defineProperty(t,"AVAILABLE_LANGUAGES",{enumerable:!0,get:function(){return s.AVAILABLE_LANGUAGES}}),Object.defineProperty(t,"registerRulesForLanguage",{enumerable:!0,get:function(){return s.registerRulesForLanguage}});var u=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(n(2));t.oop=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2),o=n(1).TextHighlightRules,i=function e(){this.$rules={start:[{token:"comment.doc.tag",regex:"@[\\w\\d_]+"},e.getTagRule(),{defaultToken:"comment.doc",caseInsensitive:!0}]}};r.inherits(i,o),i.getTagRule=function(e){return{token:"comment.doc.tag.storage.type",regex:"\\b(?:TODO|FIXME|XXX|HACK)\\b"}},i.getStartRule=function(e){return{token:"comment.doc",regex:"\\/\\*(?=\\*)",next:e}},i.getEndRule=function(e){return{token:"comment.doc",regex:"\\*\\/",next:e}},t.DocCommentHighlightRules=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AVAILABLE_LANGUAGES=t.State=void 0;var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();t.registerRulesForLanguage=function(e,t){var n=new i.default(t.getRules());return o.languages.setTokensProvider(e,{getInitialState:function(){return new s("")},tokenize:function(e,t){var r=n.getLineTokens(e,t.state),o=r.tokens,i=r.state,u=0,a=o.map(function(e){var t={startIndex:u,scopes:e.type};return u+=e.value.length,t});return{endState:new s(i),tokens:a}}})};var o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(n(6)),i=function(e){return e&&e.__esModule?e:{default:e}}(n(0));var s=t.State=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.state=t}return r(e,[{key:"equals",value:function(e){return e===this||e.state===this.state}},{key:"clone",value:function(){return new e(this.state)}}]),e}();t.AVAILABLE_LANGUAGES=["c_cpp","csharp","haskell","java","javascript","pascal","python","ruby"]},function(t,n){t.exports=e}])});