more ruby syntax highlighting rules
This commit is contained in:
parent
d291e0aa68
commit
3df5555bd1
1 changed files with 25 additions and 9 deletions
|
|
@ -47,15 +47,27 @@ RubyHighlightRules = function() {
|
||||||
|
|
||||||
var docComment = new DocCommentHighlightRules();
|
var docComment = new DocCommentHighlightRules();
|
||||||
|
|
||||||
|
var builtinFunctions = lang.arrayToMap(
|
||||||
|
("abort|Array|at_exit|autoload|binding|block_given?|callcc|caller|catch|chomp|chomp!|chop|chop!|eval|exec|exit|exit!" +
|
||||||
|
"fail|Float|fork|format|gets|global_variables|gsub|gsub!|Integer|lambda|load|local_variables|loop|open|p|print|" +
|
||||||
|
"printf|proc|putc|puts|raise|rand|readline|readlines|require|scan|select|set_trace_func|sleep|split|sprintf|srand|" +
|
||||||
|
"String|syscall|system|sub|sub!|test|throw|trace_var|trap|untrace_var|" +
|
||||||
|
"atan2|cos|exp|frexp|ldexp|log|log10|sin|sqrt|tan").split("|")
|
||||||
|
);
|
||||||
|
|
||||||
var keywords = lang.arrayToMap(
|
var keywords = lang.arrayToMap(
|
||||||
("alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|false|finally|for|" +
|
("alias|and|BEGIN|begin|break|case|class|def|defined|do|else|elsif|END|end|ensure|__FILE__|finally|for|" +
|
||||||
"if|in|module|next|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield").split("|")
|
"if|in|__LINE__|module|next|not|or|redo|rescue|retry|return|super|then|undef|unless|until|when|while|yield").split("|")
|
||||||
);
|
);
|
||||||
|
|
||||||
var buildinConstants = lang.arrayToMap(
|
var buildinConstants = lang.arrayToMap(
|
||||||
("true|false|nil").split("|")
|
("true|TRUE|false|FALSE|nil|NIL|ARGF|ARGV|DATA|ENV|RUBY_PLATFORM|RUBY_RELEASE_DATE|RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING").split("|")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
var builtinVariables = lang.arrayToMap(
|
||||||
|
("$DEBUG|$defout|$FILENAME|$LOAD_PATH|$SAFE|$stdin|$stdout|$stderr|$VERBOSE").split("|")
|
||||||
|
);
|
||||||
|
|
||||||
var futureReserved = lang.arrayToMap([]);
|
var futureReserved = lang.arrayToMap([]);
|
||||||
|
|
||||||
// regexp must not have capturing parentheses. Use (?:) instead.
|
// regexp must not have capturing parentheses. Use (?:) instead.
|
||||||
|
|
@ -70,7 +82,7 @@ RubyHighlightRules = function() {
|
||||||
docComment.getStartRule("doc-start"),
|
docComment.getStartRule("doc-start"),
|
||||||
{
|
{
|
||||||
token : "comment", // multi line comment
|
token : "comment", // multi line comment
|
||||||
regex : "^\=begin$",
|
regex : "^=begin",
|
||||||
next : "comment"
|
next : "comment"
|
||||||
}, {
|
}, {
|
||||||
token : "string.regexp",
|
token : "string.regexp",
|
||||||
|
|
@ -100,14 +112,18 @@ RubyHighlightRules = function() {
|
||||||
regex : "(?:true|false)\\b"
|
regex : "(?:true|false)\\b"
|
||||||
}, {
|
}, {
|
||||||
token : function(value) {
|
token : function(value) {
|
||||||
if (value == "this")
|
if (value == "self")
|
||||||
return "variable.language";
|
return "variable.language";
|
||||||
else if (keywords[value])
|
else if (keywords[value])
|
||||||
return "keyword";
|
return "keyword";
|
||||||
else if (buildinConstants[value])
|
else if (buildinConstants[value])
|
||||||
return "constant.language";
|
return "constant.language";
|
||||||
else if (futureReserved[value])
|
else if (builtinVariables[value])
|
||||||
return "invalid.illegal";
|
return "variable.language";
|
||||||
|
else if (futureReserved[value])
|
||||||
|
return "invalid.illegal";
|
||||||
|
else if (builtinFunctions[value])
|
||||||
|
return "support.function";
|
||||||
else if (value == "debugger")
|
else if (value == "debugger")
|
||||||
return "invalid.deprecated";
|
return "invalid.deprecated";
|
||||||
else
|
else
|
||||||
|
|
@ -133,7 +149,7 @@ RubyHighlightRules = function() {
|
||||||
"comment" : [
|
"comment" : [
|
||||||
{
|
{
|
||||||
token : "comment", // closing comment
|
token : "comment", // closing comment
|
||||||
regex : "^\=end$",
|
regex : "^=end",
|
||||||
next : "start"
|
next : "start"
|
||||||
}, {
|
}, {
|
||||||
token : "comment", // comment spanning whole line
|
token : "comment", // comment spanning whole line
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue