- EditAreaLoader.prototype.get_regexp= function(text_array){\r
- //res="( |=|\\n|\\r|\\[|\\(|ยต|)(";\r
- res="(\\b)(";\r
- for(i=0; i<text_array.length; i++){\r
- if(i>0)\r
- res+="|";\r
- //res+="("+ tab_text[i] +")";\r
- //res+=tab_text[i].replace(/(\.|\?|\*|\+|\\|\(|\)|\[|\]|\{|\})/g, "\\$1");\r
- res+=this.get_escaped_regexp(text_array[i]);\r
- }\r
- //res+=")( |\\.|:|\\{|\\(|\\)|\\[|\\]|\'|\"|\\r|\\n|\\t|$)";\r
- res+=")(\\b)";\r
- reg= new RegExp(res);\r
- \r
- return res;\r
- };\r
- \r
- \r
- EditAreaLoader.prototype.get_escaped_regexp= function(str){\r
- return str.toString().replace(/(\.|\?|\*|\+|\\|\(|\)|\[|\]|\}|\{|\$|\^|\|)/g, "\\$1");\r
- };\r
- \r
- EditAreaLoader.prototype.init_syntax_regexp= function(){\r
- var lang_style= {}; \r
- for(var lang in this.load_syntax){\r
- if(!this.syntax[lang]) // init the regexp if not already initialized\r
- {\r
- this.syntax[lang]= {};\r
- this.syntax[lang]["keywords_reg_exp"]= {};\r
- this.keywords_reg_exp_nb=0;\r
- \r
- if(this.load_syntax[lang]['KEYWORDS']){\r
- param="g";\r
- if(this.load_syntax[lang]['KEYWORD_CASE_SENSITIVE']===false)\r
- param+="i";\r
- for(var i in this.load_syntax[lang]['KEYWORDS']){\r
- if(typeof(this.load_syntax[lang]['KEYWORDS'][i])=="function") continue;\r
- this.syntax[lang]["keywords_reg_exp"][i]= new RegExp(this.get_regexp( this.load_syntax[lang]['KEYWORDS'][i] ), param);\r
- this.keywords_reg_exp_nb++;\r
- }\r
- }\r
- \r
- if(this.load_syntax[lang]['OPERATORS']){\r
- var str="";\r
- var nb=0;\r
- for(var i in this.load_syntax[lang]['OPERATORS']){\r
- if(typeof(this.load_syntax[lang]['OPERATORS'][i])=="function") continue;\r
- if(nb>0)\r
- str+="|"; \r
- str+=this.get_escaped_regexp(this.load_syntax[lang]['OPERATORS'][i]);\r
- nb++;\r
- }\r
- if(str.length>0)\r
- this.syntax[lang]["operators_reg_exp"]= new RegExp("("+str+")","g");\r
- }\r
- \r
- if(this.load_syntax[lang]['DELIMITERS']){\r
- var str="";\r
- var nb=0;\r
- for(var i in this.load_syntax[lang]['DELIMITERS']){\r
- if(typeof(this.load_syntax[lang]['DELIMITERS'][i])=="function") continue;\r
- if(nb>0)\r
- str+="|";\r
- str+=this.get_escaped_regexp(this.load_syntax[lang]['DELIMITERS'][i]);\r
- nb++;\r
- }\r
- if(str.length>0)\r
- this.syntax[lang]["delimiters_reg_exp"]= new RegExp("("+str+")","g");\r
- }\r
- \r
- \r
- // /(("(\\"|[^"])*"?)|('(\\'|[^'])*'?)|(//(.|\r|\t)*\n)|(/\*(.|\n|\r|\t)*\*/)|(<!--(.|\n|\r|\t)*-->))/gi\r
- var syntax_trace=[];\r
- \r
- // /("(?:[^"\\]*(\\\\)*(\\"?)?)*("|$))/g\r
- \r
- this.syntax[lang]["quotes"]={};\r
- var quote_tab= [];\r
- if(this.load_syntax[lang]['QUOTEMARKS']){\r
- for(var i in this.load_syntax[lang]['QUOTEMARKS']){ \r
- if(typeof(this.load_syntax[lang]['QUOTEMARKS'][i])=="function") continue; \r
- var x=this.get_escaped_regexp(this.load_syntax[lang]['QUOTEMARKS'][i]);\r
- this.syntax[lang]["quotes"][x]=x;\r
- //quote_tab[quote_tab.length]="("+x+"(?:\\\\"+x+"|[^"+x+"])*("+x+"|$))";\r
- //previous working : quote_tab[quote_tab.length]="("+x+"(?:[^"+x+"\\\\]*(\\\\\\\\)*(\\\\"+x+"?)?)*("+x+"|$))";\r
- quote_tab[quote_tab.length]="("+ x +"(\\\\.|[^"+ x +"])*(?:"+ x +"|$))";\r
- \r
- syntax_trace.push(x); \r
- } \r
- }\r
- \r
- this.syntax[lang]["comments"]={};\r
- if(this.load_syntax[lang]['COMMENT_SINGLE']){\r
- for(var i in this.load_syntax[lang]['COMMENT_SINGLE']){ \r
- if(typeof(this.load_syntax[lang]['COMMENT_SINGLE'][i])=="function") continue; \r
- var x=this.get_escaped_regexp(this.load_syntax[lang]['COMMENT_SINGLE'][i]);\r
- quote_tab[quote_tab.length]="("+x+"(.|\\r|\\t)*(\\n|$))";\r
- syntax_trace.push(x);\r
- this.syntax[lang]["comments"][x]="\n";\r
- } \r
- } \r
- // (/\*(.|[\r\n])*?\*/)\r
- if(this.load_syntax[lang]['COMMENT_MULTI']){\r
- for(var i in this.load_syntax[lang]['COMMENT_MULTI']){\r
- if(typeof(this.load_syntax[lang]['COMMENT_MULTI'][i])=="function") continue; \r
- var start=this.get_escaped_regexp(i);\r
- var end=this.get_escaped_regexp(this.load_syntax[lang]['COMMENT_MULTI'][i]);\r
- quote_tab[quote_tab.length]="("+start+"(.|\\n|\\r)*?("+end+"|$))";\r
- syntax_trace.push(start);\r
- syntax_trace.push(end);\r
- this.syntax[lang]["comments"][i]=this.load_syntax[lang]['COMMENT_MULTI'][i];\r
- } \r
- } \r
- if(quote_tab.length>0)\r
- this.syntax[lang]["comment_or_quote_reg_exp"]= new RegExp("("+quote_tab.join("|")+")","gi");\r
- \r
- if(syntax_trace.length>0) // /((.|\n)*?)(\\*("|'|\/\*|\*\/|\/\/|$))/g\r
- this.syntax[lang]["syntax_trace_regexp"]= new RegExp("((.|\n)*?)(\\\\*("+ syntax_trace.join("|") +"|$))", "gmi");\r
- \r
- if(this.load_syntax[lang]['SCRIPT_DELIMITERS']){\r
- this.syntax[lang]["script_delimiters"]= {};\r
- for(var i in this.load_syntax[lang]['SCRIPT_DELIMITERS']){\r
- if(typeof(this.load_syntax[lang]['SCRIPT_DELIMITERS'][i])=="function") continue; \r
- this.syntax[lang]["script_delimiters"][i]= this.load_syntax[lang]['SCRIPT_DELIMITERS'];\r
- } \r
- }\r
- \r
- this.syntax[lang]["custom_regexp"]= {};\r
- if(this.load_syntax[lang]['REGEXPS']){\r
- for(var i in this.load_syntax[lang]['REGEXPS']){\r
- if(typeof(this.load_syntax[lang]['REGEXPS'][i])=="function") continue;\r
- var val= this.load_syntax[lang]['REGEXPS'][i];\r
- if(!this.syntax[lang]["custom_regexp"][val['execute']])\r
- this.syntax[lang]["custom_regexp"][val['execute']]= {};\r
- this.syntax[lang]["custom_regexp"][val['execute']][i]={'regexp' : new RegExp(val['search'], val['modifiers'])\r
- , 'class' : val['class']};\r
- }\r
- }\r
- \r
- if(this.load_syntax[lang]['STYLES']){ \r
- lang_style[lang]= {};\r
- for(var i in this.load_syntax[lang]['STYLES']){\r
- if(typeof(this.load_syntax[lang]['STYLES'][i])=="function") continue;\r
- if(typeof(this.load_syntax[lang]['STYLES'][i]) != "string"){\r
- for(var j in this.load_syntax[lang]['STYLES'][i]){ \r
- lang_style[lang][j]= this.load_syntax[lang]['STYLES'][i][j];\r
- }\r
- }else{\r
- lang_style[lang][i]= this.load_syntax[lang]['STYLES'][i];\r
- }\r
- }\r
- }\r
- // build style string\r
- var style=""; \r
- for(var i in lang_style[lang]){\r
- if(lang_style[lang][i].length>0){\r
- style+= "."+ lang +" ."+ i.toLowerCase() +" span{"+lang_style[lang][i]+"}\n";\r
- style+= "."+ lang +" ."+ i.toLowerCase() +"{"+lang_style[lang][i]+"}\n"; \r
- }\r
- }\r
- this.syntax[lang]["styles"]=style;\r
- }\r
- } \r
- };\r
- \r
- editAreaLoader.waiting_loading["reg_syntax.js"]= "loaded";\r