openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

cypher.min.js (3627B)


      1 (function(e){if(typeof exports=='object'&&typeof module=='object')e(require('../../lib/codemirror'));else if(typeof define=='function'&&define.amd)define(['../../lib/codemirror'],e);else e(CodeMirror)})(function(e){'use strict';var t=function(e){return new RegExp('^(?:'+e.join('|')+')$','i')};e.defineMode('cypher',function(n){var c=function(e){var t=e.next();if(t==='"'){e.match(/.*?"/);return'string'};if(t==='\''){e.match(/.*?'/);return'string'};if(/[{}\(\),\.;\[\]]/.test(t)){r=t;return'node'}
      2 else if(t==='/'&&e.eat('/')){e.skipToEnd();return'comment'}
      3 else if(a.test(t)){e.eatWhile(a);return null}
      4 else{e.eatWhile(/[_\w\d]/);if(e.eat(':')){e.eatWhile(/[\w\d_\-]/);return'atom'};var n=e.current();if(l.test(n))return'builtin';if(d.test(n))return'def';if(u.test(n))return'keyword';return'variable'}},i=function(e,t,n){return e.context={prev:e.context,indent:e.indent,col:n,type:t}},o=function(e){e.indent=e.context.indent;return e.context=e.context.prev},s=n.indentUnit,r,l=t(['abs','acos','allShortestPaths','asin','atan','atan2','avg','ceil','coalesce','collect','cos','cot','count','degrees','e','endnode','exp','extract','filter','floor','haversin','head','id','keys','labels','last','left','length','log','log10','lower','ltrim','max','min','node','nodes','percentileCont','percentileDisc','pi','radians','rand','range','reduce','rel','relationship','relationships','replace','reverse','right','round','rtrim','shortestPath','sign','sin','size','split','sqrt','startnode','stdev','stdevp','str','substring','sum','tail','tan','timestamp','toFloat','toInt','toString','trim','type','upper']),d=t(['all','and','any','contains','exists','has','in','none','not','or','single','xor']),u=t(['as','asc','ascending','assert','by','case','commit','constraint','create','csv','cypher','delete','desc','descending','detach','distinct','drop','else','end','ends','explain','false','fieldterminator','foreach','from','headers','in','index','is','join','limit','load','match','merge','null','on','optional','order','periodic','profile','remove','return','scan','set','skip','start','starts','then','true','union','unique','unwind','using','when','where','with','call','yield']),a=/[*+\-<>=&|~%^]/;return{startState:function(){return{tokenize:c,context:null,indent:0,col:0}},token:function(t,e){if(t.sol()){if(e.context&&(e.context.align==null)){e.context.align=!1};e.indent=t.indentation()};if(t.eatSpace()){return null};var n=e.tokenize(t,e);if(n!=='comment'&&e.context&&(e.context.align==null)&&e.context.type!=='pattern'){e.context.align=!0};if(r==='('){i(e,')',t.column())}
      5 else if(r==='['){i(e,']',t.column())}
      6 else if(r==='{'){i(e,'}',t.column())}
      7 else if(/[\]\}\)]/.test(r)){while(e.context&&e.context.type==='pattern'){o(e)};if(e.context&&r===e.context.type){o(e)}}
      8 else if(r==='.'&&e.context&&e.context.type==='pattern'){o(e)}
      9 else if(/atom|string|variable/.test(n)&&e.context){if(/[\}\]]/.test(e.context.type)){i(e,'pattern',t.column())}
     10 else if(e.context.type==='pattern'&&!e.context.align){e.context.align=!0;e.context.col=t.column()}};return n},indent:function(n,r){var o=r&&r.charAt(0),t=n.context;if(/[\]\}]/.test(o)){while(t&&t.type==='pattern'){t=t.prev}};var i=t&&o===t.type;if(!t)return 0;if(t.type==='keywords')return e.commands.newlineAndIndent;if(t.align)return t.col+(i?0:1);return t.indent+(i?0:s)}}});e.modeExtensions['cypher']={autoFormatLineBreaks:function(e){var t,n,r,n=e.split('\n'),r=/\s+\b(return|where|order by|match|with|skip|limit|create|delete|set)\b\s/g;for(var t=0;t<n.length;t++)n[t]=n[t].replace(r,' \n$1 ').trim();return n.join('\n')}};e.defineMIME('application/x-cypher-query','cypher')});