Path: blob/master/web-gui/buildyourownbotnet/assets/js/codemirror/mode/perl/perl.js
1294 views
// CodeMirror2 mode/perl/perl.js (text/x-perl) beta 0.10 (2011-11-08)1// This is a part of CodeMirror from https://github.com/sabaca/CodeMirror_mode_perl ([email protected])2CodeMirror.defineMode("perl",function(){3// http://perldoc.perl.org4var PERL={ // null - magic touch5// 1 - keyword6// 2 - def7// 3 - atom8// 4 - operator9// 5 - variable-2 (predefined)10// [x,y] - x=1,2,3; y=must be defined if x{...}11// PERL operators12'->' : 4,13'++' : 4,14'--' : 4,15'**' : 4,16// ! ~ \ and unary + and -17'=~' : 4,18'!~' : 4,19'*' : 4,20'/' : 4,21'%' : 4,22'x' : 4,23'+' : 4,24'-' : 4,25'.' : 4,26'<<' : 4,27'>>' : 4,28// named unary operators29'<' : 4,30'>' : 4,31'<=' : 4,32'>=' : 4,33'lt' : 4,34'gt' : 4,35'le' : 4,36'ge' : 4,37'==' : 4,38'!=' : 4,39'<=>' : 4,40'eq' : 4,41'ne' : 4,42'cmp' : 4,43'~~' : 4,44'&' : 4,45'|' : 4,46'^' : 4,47'&&' : 4,48'||' : 4,49'//' : 4,50'..' : 4,51'...' : 4,52'?' : 4,53':' : 4,54'=' : 4,55'+=' : 4,56'-=' : 4,57'*=' : 4, // etc. ???58',' : 4,59'=>' : 4,60'::' : 4,61// list operators (rightward)62'not' : 4,63'and' : 4,64'or' : 4,65'xor' : 4,66// PERL predefined variables (I know, what this is a paranoid idea, but may be needed for people, who learn PERL, and for me as well, ...and may be for you?;)67'BEGIN' : [5,1],68'END' : [5,1],69'PRINT' : [5,1],70'PRINTF' : [5,1],71'GETC' : [5,1],72'READ' : [5,1],73'READLINE' : [5,1],74'DESTROY' : [5,1],75'TIE' : [5,1],76'TIEHANDLE' : [5,1],77'UNTIE' : [5,1],78'STDIN' : 5,79'STDIN_TOP' : 5,80'STDOUT' : 5,81'STDOUT_TOP' : 5,82'STDERR' : 5,83'STDERR_TOP' : 5,84'$ARG' : 5,85'$_' : 5,86'@ARG' : 5,87'@_' : 5,88'$LIST_SEPARATOR' : 5,89'$"' : 5,90'$PROCESS_ID' : 5,91'$PID' : 5,92'$$' : 5,93'$REAL_GROUP_ID' : 5,94'$GID' : 5,95'$(' : 5,96'$EFFECTIVE_GROUP_ID' : 5,97'$EGID' : 5,98'$)' : 5,99'$PROGRAM_NAME' : 5,100'$0' : 5,101'$SUBSCRIPT_SEPARATOR' : 5,102'$SUBSEP' : 5,103'$;' : 5,104'$REAL_USER_ID' : 5,105'$UID' : 5,106'$<' : 5,107'$EFFECTIVE_USER_ID' : 5,108'$EUID' : 5,109'$>' : 5,110'$a' : 5,111'$b' : 5,112'$COMPILING' : 5,113'$^C' : 5,114'$DEBUGGING' : 5,115'$^D' : 5,116'${^ENCODING}' : 5,117'$ENV' : 5,118'%ENV' : 5,119'$SYSTEM_FD_MAX' : 5,120'$^F' : 5,121'@F' : 5,122'${^GLOBAL_PHASE}' : 5,123'$^H' : 5,124'%^H' : 5,125'@INC' : 5,126'%INC' : 5,127'$INPLACE_EDIT' : 5,128'$^I' : 5,129'$^M' : 5,130'$OSNAME' : 5,131'$^O' : 5,132'${^OPEN}' : 5,133'$PERLDB' : 5,134'$^P' : 5,135'$SIG' : 5,136'%SIG' : 5,137'$BASETIME' : 5,138'$^T' : 5,139'${^TAINT}' : 5,140'${^UNICODE}' : 5,141'${^UTF8CACHE}' : 5,142'${^UTF8LOCALE}' : 5,143'$PERL_VERSION' : 5,144'$^V' : 5,145'${^WIN32_SLOPPY_STAT}' : 5,146'$EXECUTABLE_NAME' : 5,147'$^X' : 5,148'$1' : 5, // - regexp $1, $2...149'$MATCH' : 5,150'$&' : 5,151'${^MATCH}' : 5,152'$PREMATCH' : 5,153'$`' : 5,154'${^PREMATCH}' : 5,155'$POSTMATCH' : 5,156"$'" : 5,157'${^POSTMATCH}' : 5,158'$LAST_PAREN_MATCH' : 5,159'$+' : 5,160'$LAST_SUBMATCH_RESULT' : 5,161'$^N' : 5,162'@LAST_MATCH_END' : 5,163'@+' : 5,164'%LAST_PAREN_MATCH' : 5,165'%+' : 5,166'@LAST_MATCH_START' : 5,167'@-' : 5,168'%LAST_MATCH_START' : 5,169'%-' : 5,170'$LAST_REGEXP_CODE_RESULT' : 5,171'$^R' : 5,172'${^RE_DEBUG_FLAGS}' : 5,173'${^RE_TRIE_MAXBUF}' : 5,174'$ARGV' : 5,175'@ARGV' : 5,176'ARGV' : 5,177'ARGVOUT' : 5,178'$OUTPUT_FIELD_SEPARATOR' : 5,179'$OFS' : 5,180'$,' : 5,181'$INPUT_LINE_NUMBER' : 5,182'$NR' : 5,183'$.' : 5,184'$INPUT_RECORD_SEPARATOR' : 5,185'$RS' : 5,186'$/' : 5,187'$OUTPUT_RECORD_SEPARATOR' : 5,188'$ORS' : 5,189'$\\' : 5,190'$OUTPUT_AUTOFLUSH' : 5,191'$|' : 5,192'$ACCUMULATOR' : 5,193'$^A' : 5,194'$FORMAT_FORMFEED' : 5,195'$^L' : 5,196'$FORMAT_PAGE_NUMBER' : 5,197'$%' : 5,198'$FORMAT_LINES_LEFT' : 5,199'$-' : 5,200'$FORMAT_LINE_BREAK_CHARACTERS' : 5,201'$:' : 5,202'$FORMAT_LINES_PER_PAGE' : 5,203'$=' : 5,204'$FORMAT_TOP_NAME' : 5,205'$^' : 5,206'$FORMAT_NAME' : 5,207'$~' : 5,208'${^CHILD_ERROR_NATIVE}' : 5,209'$EXTENDED_OS_ERROR' : 5,210'$^E' : 5,211'$EXCEPTIONS_BEING_CAUGHT' : 5,212'$^S' : 5,213'$WARNING' : 5,214'$^W' : 5,215'${^WARNING_BITS}' : 5,216'$OS_ERROR' : 5,217'$ERRNO' : 5,218'$!' : 5,219'%OS_ERROR' : 5,220'%ERRNO' : 5,221'%!' : 5,222'$CHILD_ERROR' : 5,223'$?' : 5,224'$EVAL_ERROR' : 5,225'$@' : 5,226'$OFMT' : 5,227'$#' : 5,228'$*' : 5,229'$ARRAY_BASE' : 5,230'$[' : 5,231'$OLD_PERL_VERSION' : 5,232'$]' : 5,233// PERL blocks234'if' :[1,1],235elsif :[1,1],236'else' :[1,1],237'while' :[1,1],238unless :[1,1],239'for' :[1,1],240foreach :[1,1],241// PERL functions242'abs' :1, // - absolute value function243accept :1, // - accept an incoming socket connect244alarm :1, // - schedule a SIGALRM245'atan2' :1, // - arctangent of Y/X in the range -PI to PI246bind :1, // - binds an address to a socket247binmode :1, // - prepare binary files for I/O248bless :1, // - create an object249bootstrap :1, //250'break' :1, // - break out of a "given" block251caller :1, // - get context of the current subroutine call252chdir :1, // - change your current working directory253chmod :1, // - changes the permissions on a list of files254chomp :1, // - remove a trailing record separator from a string255chop :1, // - remove the last character from a string256chown :1, // - change the owership on a list of files257chr :1, // - get character this number represents258chroot :1, // - make directory new root for path lookups259close :1, // - close file (or pipe or socket) handle260closedir :1, // - close directory handle261connect :1, // - connect to a remote socket262'continue' :[1,1], // - optional trailing block in a while or foreach263'cos' :1, // - cosine function264crypt :1, // - one-way passwd-style encryption265dbmclose :1, // - breaks binding on a tied dbm file266dbmopen :1, // - create binding on a tied dbm file267'default' :1, //268defined :1, // - test whether a value, variable, or function is defined269'delete' :1, // - deletes a value from a hash270die :1, // - raise an exception or bail out271'do' :1, // - turn a BLOCK into a TERM272dump :1, // - create an immediate core dump273each :1, // - retrieve the next key/value pair from a hash274endgrent :1, // - be done using group file275endhostent :1, // - be done using hosts file276endnetent :1, // - be done using networks file277endprotoent :1, // - be done using protocols file278endpwent :1, // - be done using passwd file279endservent :1, // - be done using services file280eof :1, // - test a filehandle for its end281'eval' :1, // - catch exceptions or compile and run code282'exec' :1, // - abandon this program to run another283exists :1, // - test whether a hash key is present284exit :1, // - terminate this program285'exp' :1, // - raise I to a power286fcntl :1, // - file control system call287fileno :1, // - return file descriptor from filehandle288flock :1, // - lock an entire file with an advisory lock289fork :1, // - create a new process just like this one290format :1, // - declare a picture format with use by the write() function291formline :1, // - internal function used for formats292getc :1, // - get the next character from the filehandle293getgrent :1, // - get next group record294getgrgid :1, // - get group record given group user ID295getgrnam :1, // - get group record given group name296gethostbyaddr :1, // - get host record given its address297gethostbyname :1, // - get host record given name298gethostent :1, // - get next hosts record299getlogin :1, // - return who logged in at this tty300getnetbyaddr :1, // - get network record given its address301getnetbyname :1, // - get networks record given name302getnetent :1, // - get next networks record303getpeername :1, // - find the other end of a socket connection304getpgrp :1, // - get process group305getppid :1, // - get parent process ID306getpriority :1, // - get current nice value307getprotobyname :1, // - get protocol record given name308getprotobynumber :1, // - get protocol record numeric protocol309getprotoent :1, // - get next protocols record310getpwent :1, // - get next passwd record311getpwnam :1, // - get passwd record given user login name312getpwuid :1, // - get passwd record given user ID313getservbyname :1, // - get services record given its name314getservbyport :1, // - get services record given numeric port315getservent :1, // - get next services record316getsockname :1, // - retrieve the sockaddr for a given socket317getsockopt :1, // - get socket options on a given socket318given :1, //319glob :1, // - expand filenames using wildcards320gmtime :1, // - convert UNIX time into record or string using Greenwich time321'goto' :1, // - create spaghetti code322grep :1, // - locate elements in a list test true against a given criterion323hex :1, // - convert a string to a hexadecimal number324'import' :1, // - patch a module's namespace into your own325index :1, // - find a substring within a string326'int' :1, // - get the integer portion of a number327ioctl :1, // - system-dependent device control system call328'join' :1, // - join a list into a string using a separator329keys :1, // - retrieve list of indices from a hash330kill :1, // - send a signal to a process or process group331last :1, // - exit a block prematurely332lc :1, // - return lower-case version of a string333lcfirst :1, // - return a string with just the next letter in lower case334length :1, // - return the number of bytes in a string335'link' :1, // - create a hard link in the filesytem336listen :1, // - register your socket as a server337local : 2, // - create a temporary value for a global variable (dynamic scoping)338localtime :1, // - convert UNIX time into record or string using local time339lock :1, // - get a thread lock on a variable, subroutine, or method340'log' :1, // - retrieve the natural logarithm for a number341lstat :1, // - stat a symbolic link342m :null, // - match a string with a regular expression pattern343map :1, // - apply a change to a list to get back a new list with the changes344mkdir :1, // - create a directory345msgctl :1, // - SysV IPC message control operations346msgget :1, // - get SysV IPC message queue347msgrcv :1, // - receive a SysV IPC message from a message queue348msgsnd :1, // - send a SysV IPC message to a message queue349my : 2, // - declare and assign a local variable (lexical scoping)350'new' :1, //351next :1, // - iterate a block prematurely352no :1, // - unimport some module symbols or semantics at compile time353oct :1, // - convert a string to an octal number354open :1, // - open a file, pipe, or descriptor355opendir :1, // - open a directory356ord :1, // - find a character's numeric representation357our : 2, // - declare and assign a package variable (lexical scoping)358pack :1, // - convert a list into a binary representation359'package' :1, // - declare a separate global namespace360pipe :1, // - open a pair of connected filehandles361pop :1, // - remove the last element from an array and return it362pos :1, // - find or set the offset for the last/next m//g search363print :1, // - output a list to a filehandle364printf :1, // - output a formatted list to a filehandle365prototype :1, // - get the prototype (if any) of a subroutine366push :1, // - append one or more elements to an array367q :null, // - singly quote a string368qq :null, // - doubly quote a string369qr :null, // - Compile pattern370quotemeta :null, // - quote regular expression magic characters371qw :null, // - quote a list of words372qx :null, // - backquote quote a string373rand :1, // - retrieve the next pseudorandom number374read :1, // - fixed-length buffered input from a filehandle375readdir :1, // - get a directory from a directory handle376readline :1, // - fetch a record from a file377readlink :1, // - determine where a symbolic link is pointing378readpipe :1, // - execute a system command and collect standard output379recv :1, // - receive a message over a Socket380redo :1, // - start this loop iteration over again381ref :1, // - find out the type of thing being referenced382rename :1, // - change a filename383require :1, // - load in external functions from a library at runtime384reset :1, // - clear all variables of a given name385'return' :1, // - get out of a function early386reverse :1, // - flip a string or a list387rewinddir :1, // - reset directory handle388rindex :1, // - right-to-left substring search389rmdir :1, // - remove a directory390s :null, // - replace a pattern with a string391say :1, // - print with newline392scalar :1, // - force a scalar context393seek :1, // - reposition file pointer for random-access I/O394seekdir :1, // - reposition directory pointer395select :1, // - reset default output or do I/O multiplexing396semctl :1, // - SysV semaphore control operations397semget :1, // - get set of SysV semaphores398semop :1, // - SysV semaphore operations399send :1, // - send a message over a socket400setgrent :1, // - prepare group file for use401sethostent :1, // - prepare hosts file for use402setnetent :1, // - prepare networks file for use403setpgrp :1, // - set the process group of a process404setpriority :1, // - set a process's nice value405setprotoent :1, // - prepare protocols file for use406setpwent :1, // - prepare passwd file for use407setservent :1, // - prepare services file for use408setsockopt :1, // - set some socket options409shift :1, // - remove the first element of an array, and return it410shmctl :1, // - SysV shared memory operations411shmget :1, // - get SysV shared memory segment identifier412shmread :1, // - read SysV shared memory413shmwrite :1, // - write SysV shared memory414shutdown :1, // - close down just half of a socket connection415'sin' :1, // - return the sine of a number416sleep :1, // - block for some number of seconds417socket :1, // - create a socket418socketpair :1, // - create a pair of sockets419'sort' :1, // - sort a list of values420splice :1, // - add or remove elements anywhere in an array421'split' :1, // - split up a string using a regexp delimiter422sprintf :1, // - formatted print into a string423'sqrt' :1, // - square root function424srand :1, // - seed the random number generator425stat :1, // - get a file's status information426state :1, // - declare and assign a state variable (persistent lexical scoping)427study :1, // - optimize input data for repeated searches428'sub' :1, // - declare a subroutine, possibly anonymously429'substr' :1, // - get or alter a portion of a stirng430symlink :1, // - create a symbolic link to a file431syscall :1, // - execute an arbitrary system call432sysopen :1, // - open a file, pipe, or descriptor433sysread :1, // - fixed-length unbuffered input from a filehandle434sysseek :1, // - position I/O pointer on handle used with sysread and syswrite435system :1, // - run a separate program436syswrite :1, // - fixed-length unbuffered output to a filehandle437tell :1, // - get current seekpointer on a filehandle438telldir :1, // - get current seekpointer on a directory handle439tie :1, // - bind a variable to an object class440tied :1, // - get a reference to the object underlying a tied variable441time :1, // - return number of seconds since 1970442times :1, // - return elapsed time for self and child processes443tr :null, // - transliterate a string444truncate :1, // - shorten a file445uc :1, // - return upper-case version of a string446ucfirst :1, // - return a string with just the next letter in upper case447umask :1, // - set file creation mode mask448undef :1, // - remove a variable or function definition449unlink :1, // - remove one link to a file450unpack :1, // - convert binary structure into normal perl variables451unshift :1, // - prepend more elements to the beginning of a list452untie :1, // - break a tie binding to a variable453use :1, // - load in a module at compile time454utime :1, // - set a file's last access and modify times455values :1, // - return a list of the values in a hash456vec :1, // - test or set particular bits in a string457wait :1, // - wait for any child process to die458waitpid :1, // - wait for a particular child process to die459wantarray :1, // - get void vs scalar vs list context of current subroutine call460warn :1, // - print debugging info461when :1, //462write :1, // - print a picture record463y :null}; // - transliterate a string464465var RXstyle="string-2";466var RXmodifiers=/[goseximacplud]/; // NOTE: "m", "s", "y" and "tr" need to correct real modifiers for each regexp type467468function tokenChain(stream,state,chain,style,tail){ // NOTE: chain.length > 2 is not working now (it's for s[...][...]geos;)469state.chain=null; // 12 3tail470state.style=null;471state.tail=null;472state.tokenize=function(stream,state){473var e=false,c,i=0;474while(c=stream.next()){475if(c===chain[i]&&!e){476if(chain[++i]!==undefined){477state.chain=chain[i];478state.style=style;479state.tail=tail;}480else if(tail)481stream.eatWhile(tail);482state.tokenize=tokenPerl;483return style;}484e=!e&&c=="\\";}485return style;};486return state.tokenize(stream,state);}487488function tokenSOMETHING(stream,state,string){489state.tokenize=function(stream,state){490if(stream.string==string)491state.tokenize=tokenPerl;492stream.skipToEnd();493return "string";};494return state.tokenize(stream,state);}495496function tokenPerl(stream,state){497if(stream.eatSpace())498return null;499if(state.chain)500return tokenChain(stream,state,state.chain,state.style,state.tail);501if(stream.match(/^\-?[\d\.]/,false))502if(stream.match(/^(\-?(\d*\.\d+(e[+-]?\d+)?|\d+\.\d*)|0x[\da-fA-F]+|0b[01]+|\d+(e[+-]?\d+)?)/))503return 'number';504if(stream.match(/^<<(?=\w)/)){ // NOTE: <<SOMETHING\n...\nSOMETHING\n505stream.eatWhile(/\w/);506return tokenSOMETHING(stream,state,stream.current().substr(2));}507if(stream.sol()&&stream.match(/^\=item(?!\w)/)){// NOTE: \n=item...\n=cut\n508return tokenSOMETHING(stream,state,'=cut');}509var ch=stream.next();510if(ch=='"'||ch=="'"){ // NOTE: ' or " or <<'SOMETHING'\n...\nSOMETHING\n or <<"SOMETHING"\n...\nSOMETHING\n511if(stream.prefix(3)=="<<"+ch){512var p=stream.pos;513stream.eatWhile(/\w/);514var n=stream.current().substr(1);515if(n&&stream.eat(ch))516return tokenSOMETHING(stream,state,n);517stream.pos=p;}518return tokenChain(stream,state,[ch],"string");}519if(ch=="q"){520var c=stream.look(-2);521if(!(c&&/\w/.test(c))){522c=stream.look(0);523if(c=="x"){524c=stream.look(1);525if(c=="("){526stream.eatSuffix(2);527return tokenChain(stream,state,[")"],RXstyle,RXmodifiers);}528if(c=="["){529stream.eatSuffix(2);530return tokenChain(stream,state,["]"],RXstyle,RXmodifiers);}531if(c=="{"){532stream.eatSuffix(2);533return tokenChain(stream,state,["}"],RXstyle,RXmodifiers);}534if(c=="<"){535stream.eatSuffix(2);536return tokenChain(stream,state,[">"],RXstyle,RXmodifiers);}537if(/[\^'"!~\/]/.test(c)){538stream.eatSuffix(1);539return tokenChain(stream,state,[stream.eat(c)],RXstyle,RXmodifiers);}}540else if(c=="q"){541c=stream.look(1);542if(c=="("){543stream.eatSuffix(2);544return tokenChain(stream,state,[")"],"string");}545if(c=="["){546stream.eatSuffix(2);547return tokenChain(stream,state,["]"],"string");}548if(c=="{"){549stream.eatSuffix(2);550return tokenChain(stream,state,["}"],"string");}551if(c=="<"){552stream.eatSuffix(2);553return tokenChain(stream,state,[">"],"string");}554if(/[\^'"!~\/]/.test(c)){555stream.eatSuffix(1);556return tokenChain(stream,state,[stream.eat(c)],"string");}}557else if(c=="w"){558c=stream.look(1);559if(c=="("){560stream.eatSuffix(2);561return tokenChain(stream,state,[")"],"bracket");}562if(c=="["){563stream.eatSuffix(2);564return tokenChain(stream,state,["]"],"bracket");}565if(c=="{"){566stream.eatSuffix(2);567return tokenChain(stream,state,["}"],"bracket");}568if(c=="<"){569stream.eatSuffix(2);570return tokenChain(stream,state,[">"],"bracket");}571if(/[\^'"!~\/]/.test(c)){572stream.eatSuffix(1);573return tokenChain(stream,state,[stream.eat(c)],"bracket");}}574else if(c=="r"){575c=stream.look(1);576if(c=="("){577stream.eatSuffix(2);578return tokenChain(stream,state,[")"],RXstyle,RXmodifiers);}579if(c=="["){580stream.eatSuffix(2);581return tokenChain(stream,state,["]"],RXstyle,RXmodifiers);}582if(c=="{"){583stream.eatSuffix(2);584return tokenChain(stream,state,["}"],RXstyle,RXmodifiers);}585if(c=="<"){586stream.eatSuffix(2);587return tokenChain(stream,state,[">"],RXstyle,RXmodifiers);}588if(/[\^'"!~\/]/.test(c)){589stream.eatSuffix(1);590return tokenChain(stream,state,[stream.eat(c)],RXstyle,RXmodifiers);}}591else if(/[\^'"!~\/(\[{<]/.test(c)){592if(c=="("){593stream.eatSuffix(1);594return tokenChain(stream,state,[")"],"string");}595if(c=="["){596stream.eatSuffix(1);597return tokenChain(stream,state,["]"],"string");}598if(c=="{"){599stream.eatSuffix(1);600return tokenChain(stream,state,["}"],"string");}601if(c=="<"){602stream.eatSuffix(1);603return tokenChain(stream,state,[">"],"string");}604if(/[\^'"!~\/]/.test(c)){605return tokenChain(stream,state,[stream.eat(c)],"string");}}}}606if(ch=="m"){607var c=stream.look(-2);608if(!(c&&/\w/.test(c))){609c=stream.eat(/[(\[{<\^'"!~\/]/);610if(c){611if(/[\^'"!~\/]/.test(c)){612return tokenChain(stream,state,[c],RXstyle,RXmodifiers);}613if(c=="("){614return tokenChain(stream,state,[")"],RXstyle,RXmodifiers);}615if(c=="["){616return tokenChain(stream,state,["]"],RXstyle,RXmodifiers);}617if(c=="{"){618return tokenChain(stream,state,["}"],RXstyle,RXmodifiers);}619if(c=="<"){620return tokenChain(stream,state,[">"],RXstyle,RXmodifiers);}}}}621if(ch=="s"){622var c=/[\/>\]})\w]/.test(stream.look(-2));623if(!c){624c=stream.eat(/[(\[{<\^'"!~\/]/);625if(c){626if(c=="[")627return tokenChain(stream,state,["]","]"],RXstyle,RXmodifiers);628if(c=="{")629return tokenChain(stream,state,["}","}"],RXstyle,RXmodifiers);630if(c=="<")631return tokenChain(stream,state,[">",">"],RXstyle,RXmodifiers);632if(c=="(")633return tokenChain(stream,state,[")",")"],RXstyle,RXmodifiers);634return tokenChain(stream,state,[c,c],RXstyle,RXmodifiers);}}}635if(ch=="y"){636var c=/[\/>\]})\w]/.test(stream.look(-2));637if(!c){638c=stream.eat(/[(\[{<\^'"!~\/]/);639if(c){640if(c=="[")641return tokenChain(stream,state,["]","]"],RXstyle,RXmodifiers);642if(c=="{")643return tokenChain(stream,state,["}","}"],RXstyle,RXmodifiers);644if(c=="<")645return tokenChain(stream,state,[">",">"],RXstyle,RXmodifiers);646if(c=="(")647return tokenChain(stream,state,[")",")"],RXstyle,RXmodifiers);648return tokenChain(stream,state,[c,c],RXstyle,RXmodifiers);}}}649if(ch=="t"){650var c=/[\/>\]})\w]/.test(stream.look(-2));651if(!c){652c=stream.eat("r");if(c){653c=stream.eat(/[(\[{<\^'"!~\/]/);654if(c){655if(c=="[")656return tokenChain(stream,state,["]","]"],RXstyle,RXmodifiers);657if(c=="{")658return tokenChain(stream,state,["}","}"],RXstyle,RXmodifiers);659if(c=="<")660return tokenChain(stream,state,[">",">"],RXstyle,RXmodifiers);661if(c=="(")662return tokenChain(stream,state,[")",")"],RXstyle,RXmodifiers);663return tokenChain(stream,state,[c,c],RXstyle,RXmodifiers);}}}}664if(ch=="`"){665return tokenChain(stream,state,[ch],"variable-2");}666if(ch=="/"){667if(!/~\s*$/.test(stream.prefix()))668return "operator";669else670return tokenChain(stream,state,[ch],RXstyle,RXmodifiers);}671if(ch=="$"){672var p=stream.pos;673if(stream.eatWhile(/\d/)||stream.eat("{")&&stream.eatWhile(/\d/)&&stream.eat("}"))674return "variable-2";675else676stream.pos=p;}677if(/[$@%]/.test(ch)){678var p=stream.pos;679if(stream.eat("^")&&stream.eat(/[A-Z]/)||!/[@$%&]/.test(stream.look(-2))&&stream.eat(/[=|\\\-#?@;:&`~\^!\[\]*'"$+.,\/<>()]/)){680var c=stream.current();681if(PERL[c])682return "variable-2";}683stream.pos=p;}684if(/[$@%&]/.test(ch)){685if(stream.eatWhile(/[\w$\[\]]/)||stream.eat("{")&&stream.eatWhile(/[\w$\[\]]/)&&stream.eat("}")){686var c=stream.current();687if(PERL[c])688return "variable-2";689else690return "variable";}}691if(ch=="#"){692if(stream.look(-2)!="$"){693stream.skipToEnd();694return "comment";}}695if(/[:+\-\^*$&%@=<>!?|\/~\.]/.test(ch)){696var p=stream.pos;697stream.eatWhile(/[:+\-\^*$&%@=<>!?|\/~\.]/);698if(PERL[stream.current()])699return "operator";700else701stream.pos=p;}702if(ch=="_"){703if(stream.pos==1){704if(stream.suffix(6)=="_END__"){705return tokenChain(stream,state,['\0'],"comment");}706else if(stream.suffix(7)=="_DATA__"){707return tokenChain(stream,state,['\0'],"variable-2");}708else if(stream.suffix(7)=="_C__"){709return tokenChain(stream,state,['\0'],"string");}}}710if(/\w/.test(ch)){711var p=stream.pos;712if(stream.look(-2)=="{"&&(stream.look(0)=="}"||stream.eatWhile(/\w/)&&stream.look(0)=="}"))713return "string";714else715stream.pos=p;}716if(/[A-Z]/.test(ch)){717var l=stream.look(-2);718var p=stream.pos;719stream.eatWhile(/[A-Z_]/);720if(/[\da-z]/.test(stream.look(0))){721stream.pos=p;}722else{723var c=PERL[stream.current()];724if(!c)725return "meta";726if(c[1])727c=c[0];728if(l!=":"){729if(c==1)730return "keyword";731else if(c==2)732return "def";733else if(c==3)734return "atom";735else if(c==4)736return "operator";737else if(c==5)738return "variable-2";739else740return "meta";}741else742return "meta";}}743if(/[a-zA-Z_]/.test(ch)){744var l=stream.look(-2);745stream.eatWhile(/\w/);746var c=PERL[stream.current()];747if(!c)748return "meta";749if(c[1])750c=c[0];751if(l!=":"){752if(c==1)753return "keyword";754else if(c==2)755return "def";756else if(c==3)757return "atom";758else if(c==4)759return "operator";760else if(c==5)761return "variable-2";762else763return "meta";}764else765return "meta";}766return null;}767768return{769startState:function(){770return{771tokenize:tokenPerl,772chain:null,773style:null,774tail:null};},775token:function(stream,state){776return (state.tokenize||tokenPerl)(stream,state);},777electricChars:"{}"};});778779CodeMirror.defineMIME("text/x-perl", "perl");780781// it's like "peek", but need for look-ahead or look-behind if index < 0782CodeMirror.StringStream.prototype.look=function(c){783return this.string.charAt(this.pos+(c||0));};784785// return a part of prefix of current stream from current position786CodeMirror.StringStream.prototype.prefix=function(c){787if(c){788var x=this.pos-c;789return this.string.substr((x>=0?x:0),c);}790else{791return this.string.substr(0,this.pos-1);}};792793// return a part of suffix of current stream from current position794CodeMirror.StringStream.prototype.suffix=function(c){795var y=this.string.length;796var x=y-this.pos+1;797return this.string.substr(this.pos,(c&&c<y?c:x));};798799// return a part of suffix of current stream from current position and change current position800CodeMirror.StringStream.prototype.nsuffix=function(c){801var p=this.pos;802var l=c||(this.string.length-this.pos+1);803this.pos+=l;804return this.string.substr(p,l);};805806// eating and vomiting a part of stream from current position807CodeMirror.StringStream.prototype.eatSuffix=function(c){808var x=this.pos+c;809var y;810if(x<=0)811this.pos=0;812else if(x>=(y=this.string.length-1))813this.pos=y;814else815this.pos=x;};816817818