pegjs.min.js (1796B)
1 (function(e){if(typeof exports=='object'&&typeof module=='object')e(require('../../lib/codemirror'),require('../javascript/javascript'));else if(typeof define=='function'&&define.amd)define(['../../lib/codemirror','../javascript/javascript'],e);else e(CodeMirror)})(function(e){'use strict';e.defineMode('pegjs',function(t){var n=e.getMode(t,'javascript');function i(e){return e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/)};return{startState:function(){return{inString:!1,stringType:null,inComment:!1,inCharacterClass:!1,braced:0,lhs:!0,localState:null}},token:function(t,r){if(t)if(!r.inString&&!r.inComment&&((t.peek()=='"')||(t.peek()=='\''))){r.stringType=t.peek();t.next();r.inString=!0};if(!r.inString&&!r.inComment&&t.match(/^\/\*/)){r.inComment=!0};if(r.inString){while(r.inString&&!t.eol()){if(t.peek()===r.stringType){t.next();r.inString=!1} 2 else if(t.peek()==='\\'){t.next();t.next()} 3 else{t.match(/^.[^\\"']*/)}};return r.lhs?'property string':'string'} 4 else if(r.inComment){while(r.inComment&&!t.eol()){if(t.match(/\*\//)){r.inComment=!1} 5 else{t.match(/^.[^\*]*/)}};return'comment'} 6 else if(r.inCharacterClass){while(r.inCharacterClass&&!t.eol()){if(!(t.match(/^[^\]\\]+/)||t.match(/^\\./))){r.inCharacterClass=!1}}} 7 else if(t.peek()==='['){t.next();r.inCharacterClass=!0;return'bracket'} 8 else if(t.match(/^\/\//)){t.skipToEnd();return'comment'} 9 else if(r.braced||t.peek()==='{'){if(r.localState===null){r.localState=e.startState(n)};var c=n.token(t,r.localState),l=t.current();if(!c){for(var a=0;a<l.length;a++){if(l[a]==='{'){r.braced++} 10 else if(l[a]==='}'){r.braced--}}};return c} 11 else if(i(t)){if(t.peek()===':'){return'variable'};return'variable-2'} 12 else if(['[',']','(',')'].indexOf(t.peek())!=-1){t.next();return'bracket'} 13 else if(!t.eatSpace()){t.next()};return null}}},'javascript')});