From d1c3348decc96c34b10eb54837d0bd355021dcba Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Tue, 29 Jul 2014 15:10:52 +0200 Subject: Allow global/class/instance variables as Ruby symbol literals See comments in bug [#1627] for some details. --- lexers/LexRuby.cxx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lexers/LexRuby.cxx b/lexers/LexRuby.cxx index 0fdbab7d1..b0b52fd77 100644 --- a/lexers/LexRuby.cxx +++ b/lexers/LexRuby.cxx @@ -882,6 +882,31 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle, preferRE = false; } else if (isSafeWordcharOrHigh(chNext)) { state = SCE_RB_SYMBOL; + } else if ((chNext == '@' || chNext == '$') && + isSafeWordcharOrHigh(chNext2)) { + // instance and global variable followed by an identifier + advance_char(i, ch, chNext, chNext2); + state = SCE_RB_SYMBOL; + } else if (((chNext == '@' && chNext2 == '@') || + (chNext == '$' && chNext2 == '-')) && + isSafeWordcharOrHigh(styler.SafeGetCharAt(i+3))) { + // class variables and special global variable "$-IDENTCHAR" + state = SCE_RB_SYMBOL; + // $-IDENTCHAR doesn't continue past the IDENTCHAR + if (chNext == '$') { + styler.ColourTo(i+3, SCE_RB_SYMBOL); + state = SCE_RB_DEFAULT; + } + i += 3; + chNext = styler.SafeGetCharAt(i+1); + chNext2 = styler.SafeGetCharAt(i+2); + } else if (chNext == '$' && strchr("_~*$?!@/\\;,.=:<>\"&`'+", chNext2)) { + // single-character special global variables + i += 2; + ch = chNext2; + chNext = styler.SafeGetCharAt(i+1); + styler.ColourTo(i, SCE_RB_SYMBOL); + state = SCE_RB_DEFAULT; } else if (strchr("[*!~+-*/%=<>&^|", chNext)) { // Do the operator analysis in-line, looking ahead // Based on the table in pickaxe 2nd ed., page 339 -- cgit v1.2.3