monaco-editor/out/languages/amd-tsc/language/json/tokenization.js
2023-02-23 11:08:13 +00:00

1 line
No EOL
2.8 KiB
JavaScript

define(["require","exports","jsonc-parser"],(function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TOKEN_COMMENT_LINE=e.TOKEN_COMMENT_BLOCK=e.TOKEN_PROPERTY_NAME=e.TOKEN_VALUE_NUMBER=e.TOKEN_VALUE_STRING=e.TOKEN_VALUE_NULL=e.TOKEN_VALUE_BOOLEAN=e.TOKEN_DELIM_COMMA=e.TOKEN_DELIM_COLON=e.TOKEN_DELIM_ARRAY=e.TOKEN_DELIM_OBJECT=e.createTokenizationSupport=void 0,e.createTokenizationSupport=function(t){return{getInitialState:function(){return new a(null,null,!1,null)},tokenize:function(s,o){return function(t,s,o,E){void 0===E&&(E=0);var _=0,i=!1;switch(o.scanError){case 2:s='"'+s,_=1;break;case 1:s="/*"+s,_=2}for(var O=n.createScanner(s),N=o.lastWasColon,c=o.parents,T={tokens:[],endState:o.clone()};;){var u=E+O.getPosition(),L="",p=O.scan();if(17===p)break;if(u===E+O.getPosition())throw new Error("Scanner did not advance, next 3 characters are: "+s.substr(O.getPosition(),3));switch(i&&(u-=_),i=_>0,p){case 1:c=r.push(c,0),L=e.TOKEN_DELIM_OBJECT,N=!1;break;case 2:c=r.pop(c),L=e.TOKEN_DELIM_OBJECT,N=!1;break;case 3:c=r.push(c,1),L=e.TOKEN_DELIM_ARRAY,N=!1;break;case 4:c=r.pop(c),L=e.TOKEN_DELIM_ARRAY,N=!1;break;case 6:L=e.TOKEN_DELIM_COLON,N=!0;break;case 5:L=e.TOKEN_DELIM_COMMA,N=!1;break;case 8:case 9:L=e.TOKEN_VALUE_BOOLEAN,N=!1;break;case 7:L=e.TOKEN_VALUE_NULL,N=!1;break;case 10:var M=c?c.type:0;L=N||1===M?e.TOKEN_VALUE_STRING:e.TOKEN_PROPERTY_NAME,N=!1;break;case 11:L=e.TOKEN_VALUE_NUMBER,N=!1}if(t)switch(p){case 12:L=e.TOKEN_COMMENT_LINE;break;case 13:L=e.TOKEN_COMMENT_BLOCK}T.endState=new a(o.getStateData(),O.getTokenError(),N,c),T.tokens.push({startIndex:u,scopes:L})}return T}(t,s,o)}}},e.TOKEN_DELIM_OBJECT="delimiter.bracket.json",e.TOKEN_DELIM_ARRAY="delimiter.array.json",e.TOKEN_DELIM_COLON="delimiter.colon.json",e.TOKEN_DELIM_COMMA="delimiter.comma.json",e.TOKEN_VALUE_BOOLEAN="keyword.json",e.TOKEN_VALUE_NULL="keyword.json",e.TOKEN_VALUE_STRING="string.value.json",e.TOKEN_VALUE_NUMBER="number.json",e.TOKEN_PROPERTY_NAME="string.key.json",e.TOKEN_COMMENT_BLOCK="comment.block.json",e.TOKEN_COMMENT_LINE="comment.line.json";var r=function(){function t(t,e){this.parent=t,this.type=e}return t.pop=function(t){return t?t.parent:null},t.push=function(e,n){return new t(e,n)},t.equals=function(t,e){if(!t&&!e)return!0;if(!t||!e)return!1;for(;t&&e;){if(t===e)return!0;if(t.type!==e.type)return!1;t=t.parent,e=e.parent}return!0},t}(),a=function(){function t(t,e,n,r){this._state=t,this.scanError=e,this.lastWasColon=n,this.parents=r}return t.prototype.clone=function(){return new t(this._state,this.scanError,this.lastWasColon,this.parents)},t.prototype.equals=function(e){return e===this||!!(e&&e instanceof t)&&this.scanError===e.scanError&&this.lastWasColon===e.lastWasColon&&r.equals(this.parents,e.parents)},t.prototype.getStateData=function(){return this._state},t.prototype.setStateData=function(t){this._state=t},t}()}));