From 442bbc78f999fac7985a901e2f5eb8930de53d2e Mon Sep 17 00:00:00 2001 From: Kein-Hong Man Date: Tue, 5 Jan 2016 23:58:17 +1100 Subject: Fix module ::-syntax when special characters such as 'x' are used. Added ' and " detection as prefix chars for x repetition operator. --- lexers/LexPerl.cxx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lexers') diff --git a/lexers/LexPerl.cxx b/lexers/LexPerl.cxx index dccad1542..3b10b47e6 100644 --- a/lexers/LexPerl.cxx +++ b/lexers/LexPerl.cxx @@ -111,9 +111,11 @@ static int disambiguateBareword(LexAccessor &styler, Sci_PositionU bk, Sci_Posit // &bareword: subroutine call || styler.Match(bk - 1, "->") // ->bareword: part of variable spec + || styler.Match(bk - 1, "::") + // ::bareword: part of module spec || styler.Match(bk - 2, "sub")) { - // sub bareword: subroutine declaration - // (implied BACK_KEYWORD, no keywords end in 'sub'!) + // sub bareword: subroutine declaration + // (implied BACK_KEYWORD, no keywords end in 'sub'!) result |= 1; } // next, scan forward after word past tab/spaces only; @@ -127,7 +129,7 @@ static int disambiguateBareword(LexAccessor &styler, Sci_PositionU bk, Sci_Posit if ((ch == '}' && brace) // {bareword}: variable spec || styler.Match(fw, "=>")) { - // [{(, bareword=>: hash literal + // [{(, bareword=>: hash literal result |= 2; } } @@ -599,6 +601,7 @@ void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int CharacterSet setNonHereDoc(CharacterSet::setDigits, "=$@"); CharacterSet setHereDocDelim(CharacterSet::setAlphaNum, "_"); CharacterSet setSubPrototype(CharacterSet::setNone, "\\[$@%&*+];_ \t"); + CharacterSet setRepetition(CharacterSet::setDigits, ")\"'"); // for format identifiers CharacterSet setFormatStart(CharacterSet::setAlpha, "_="); CharacterSet &setFormat = setHereDocDelim; @@ -1339,7 +1342,7 @@ void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int fw++; } else if (sc.ch == 'x' && (sc.chNext == '=' || // repetition !setWord.Contains(sc.chNext) || - ((IsADigit(sc.chPrev) || sc.chPrev == ')') && IsADigit(sc.chNext)))) { + (setRepetition.Contains(sc.chPrev) && IsADigit(sc.chNext)))) { sc.ChangeState(SCE_PL_OPERATOR); } // if potentially a keyword, scan forward and grab word, then check -- cgit v1.2.3