From 7ad2e99db48ee53f389c4090ed2d87de9d2f3bdf Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Tue, 15 Feb 2011 14:11:52 +0100 Subject: [PATCH] add perl mode to the makefiles and convert tabs to spaces --- Makefile.dryice.js | 5 +- Makefile.dryice.textarea.js | 5 +- lib/ace/mode/perl_highlight_rules.js | 126 +++++++++++++-------------- 3 files changed, 71 insertions(+), 65 deletions(-) diff --git a/Makefile.dryice.js b/Makefile.dryice.js index a9e9df4d..b32685d7 100755 --- a/Makefile.dryice.js +++ b/Makefile.dryice.js @@ -169,7 +169,10 @@ copy({ console.log('# ace modes ---------'); project.assumeAllFilesLoaded(); -["css", "html", "javascript", "php", "python", "xml", "ruby", "java", "c_cpp", "coffee"].forEach(function(mode) { +[ + "css", "html", "javascript", "php", "python", "xml", "ruby", "java", "c_cpp", + "coffee", "perl" +].forEach(function(mode) { console.log("mode " + mode); copy({ source: [ diff --git a/Makefile.dryice.textarea.js b/Makefile.dryice.textarea.js index 1cb0ffd6..dd1420c5 100755 --- a/Makefile.dryice.textarea.js +++ b/Makefile.dryice.textarea.js @@ -136,7 +136,10 @@ console.log('# ace modes ---------'); // create modes project.assumeAllFilesLoaded(); -["css", "html", "javascript", "php", "python", "xml", "ruby", "java", "c_cpp", "coffee"].forEach(function(mode) { +[ + "css", "html", "javascript", "php", "python", "xml", "ruby", "java", "c_cpp", + "coffee", "perl" +].forEach(function(mode) { console.log("mode " + mode); copy({ source: [ diff --git a/lib/ace/mode/perl_highlight_rules.js b/lib/ace/mode/perl_highlight_rules.js index 676725c2..0a0f7beb 100644 --- a/lib/ace/mode/perl_highlight_rules.js +++ b/lib/ace/mode/perl_highlight_rules.js @@ -41,7 +41,7 @@ var oop = require("pilot/oop"); var lang = require("pilot/lang"); var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules; -PerlHighlightRules = function() { +var PerlHighlightRules = function() { var keywords = lang.arrayToMap( ("base|constant|continue|else|elsif|for|foreach|format|goto|if|last|local|my|next|" + @@ -82,77 +82,77 @@ PerlHighlightRules = function() { this.$rules = { "start" : [ - { - token : "comment", + { + token : "comment", regex : "#.*$" - }, { - token : "string.regexp", - regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" - }, { - token : "string", // single line - regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' - }, { - token : "string", // multi line string start - regex : '["].*\\\\$', - next : "qqstring" - }, { - token : "string", // single line - regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" - }, { - token : "string", // multi line string start - regex : "['].*\\\\$", - next : "qstring" - }, { - token : "constant.numeric", // hex - regex : "0x[0-9a-fA-F]+\\b" - }, { - token : "constant.numeric", // float - regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" - }, { - token : function(value) { - if (keywords.hasOwnProperty(value)) - return "keyword"; - else if (buildinConstants.hasOwnProperty(value)) - return "constant.language"; + }, { + token : "string.regexp", + regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)" + }, { + token : "string", // single line + regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + }, { + token : "string", // multi line string start + regex : '["].*\\\\$', + next : "qqstring" + }, { + token : "string", // single line + regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']" + }, { + token : "string", // multi line string start + regex : "['].*\\\\$", + next : "qstring" + }, { + token : "constant.numeric", // hex + regex : "0x[0-9a-fA-F]+\\b" + }, { + token : "constant.numeric", // float + regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" + }, { + token : function(value) { + if (keywords.hasOwnProperty(value)) + return "keyword"; + else if (buildinConstants.hasOwnProperty(value)) + return "constant.language"; else if (builtinFunctions.hasOwnProperty(value)) return "support.function"; - else - return "identifier"; - }, - regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" - }, { - token : "keyword.operator", + else + return "identifier"; + }, + regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" + }, { + token : "keyword.operator", regex : "\\.\\.\\.|\\|\\|=|>>=|<<=|<=>|&&=|=>|!~|\\^=|&=|\\|=|\\.=|x=|%=|\\/=|\\*=|\\-=|\\+=|=~|\\*\\*|\\-\\-|\\.\\.|\\|\\||&&|\\+\\+|\\->|!=|==|>=|<=|>>|<<|,|=|\\?\\:|\\^|\\||x|%|\\/|\\*|<|&|\\\\|~|!|>|\\.|\\-|\\+|\\-C|\\-b|\\-S|\\-u|\\-t|\\-p|\\-l|\\-d|\\-f|\\-g|\\-s|\\-z|\\-k|\\-e|\\-O|\\-T|\\-B|\\-M|\\-A|\\-X|\\-W|\\-c|\\-R|\\-o|\\-x|\\-w|\\-r|\\b(?:and|cmp|eq|ge|gt|le|lt|ne|not|or|xor)" - }, { - token : "lparen", - regex : "[[({]" - }, { - token : "rparen", - regex : "[\\])}]" - }, { - token : "text", - regex : "\\s+" - } + }, { + token : "lparen", + regex : "[[({]" + }, { + token : "rparen", + regex : "[\\])}]" + }, { + token : "text", + regex : "\\s+" + } ], "qqstring" : [ { - token : "string", - regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"', - next : "start" - }, { - token : "string", - regex : '.+' - } + token : "string", + regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"', + next : "start" + }, { + token : "string", + regex : '.+' + } ], "qstring" : [ - { - token : "string", - regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'", - next : "start" - }, { - token : "string", - regex : '.+' - } + { + token : "string", + regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'", + next : "start" + }, { + token : "string", + regex : '.+' + } ] }; };