@@ -87,7 +87,7 @@ namespace {
8787#define SUB_HAS_PROTO 1 // only 'prototype' attribute allows prototypes
8888#define SUB_HAS_ATTRIB 2 // other attributes can exist leftward
8989#define SUB_HAS_MODULE 3 // sub name can have a ::identifier part
90- #define SUB_HAS_SUB 4 // 'sub' keyword
90+ #define SUB_HAS_SUB 4 // 'sub' (or 'method') keyword
9191
9292// all interpolated styles are different from their parent styles by a constant difference
9393// we also assume SCE_PL_STRING_VAR is the interpolated style with the smallest value
@@ -131,8 +131,9 @@ int disambiguateBareword(LexAccessor &styler, Sci_PositionU bk, Sci_PositionU fw
131131 // ->bareword: part of variable spec
132132 || styler.Match (bk - 1 , " ::" )
133133 // ::bareword: part of module spec
134- || styler.Match (bk - 2 , " sub" )) {
135- // sub bareword: subroutine declaration
134+ || styler.Match (bk - 2 , " sub" )
135+ || styler.Match (bk - 5 , " method" )) {
136+ // 'sub' or 'method' bareword: subroutine declaration
136137 // (implied BACK_KEYWORD, no keywords end in 'sub'!)
137138 result |= 1 ;
138139 }
@@ -299,9 +300,10 @@ bool styleCheckSubPrototype(LexAccessor &styler, Sci_PositionU bk) {
299300 state = SUB_HAS_MODULE;
300301 } else
301302 break ;
302- } else if (style1 == SCE_PL_WORD && len1 == 3 &&
303- styler.Match (pos1, " sub" )) { // 'sub'
304- if (style2 == SCE_PL_IDENTIFIER) { // 'sub' <identifier>
303+ } else if ((style1 == SCE_PL_WORD || style1 == SCE_PL_IDENTIFIER) &&
304+ ((len1 == 3 && styler.Match (pos1, " sub" )) || // 'sub'
305+ (len1 == 6 && styler.Match (pos1, " method" )))) { // or 'method
306+ if (style2 == SCE_PL_IDENTIFIER) { // ('sub' | 'method') <identifier>
305307 state = SUB_HAS_SUB;
306308 } else
307309 break ;
0 commit comments