@@ -44,6 +44,11 @@ enum {
4444 KEYWORD_lambda ,
4545 KEYWORD_pass ,
4646 KEYWORD_return ,
47+
48+ /* Used only in readTokenFullNoRefTag to represent the identifiers
49+ that should not be tagged as reference tags. */
50+ KEYWORD___noreftag_id ,
51+
4752 KEYWORD_REST
4853};
4954typedef int keywordId ; /* to allow KEYWORD_NONE */
@@ -174,6 +179,7 @@ static const keywordTable PythonKeywordTable[] = {
174179 { "lambda" , KEYWORD_lambda },
175180 { "pass" , KEYWORD_pass },
176181 { "return" , KEYWORD_return },
182+ { "self" , KEYWORD___noreftag_id },
177183};
178184
179185/* Taken from https://docs.python.org/3/reference/lexical_analysis.html#keywords */
@@ -502,7 +508,7 @@ static void ungetToken (tokenInfo *const token)
502508 copyToken (NextToken , token );
503509}
504510
505- static void readTokenFullNoRefTag (tokenInfo * const token , bool inclWhitespaces )
511+ static void readTokenFullNoRefTag (tokenInfo * const token , bool inclWhitespaces , bool * noReftagId )
506512{
507513 int c ;
508514 int n ;
@@ -689,11 +695,17 @@ static void readTokenFullNoRefTag (tokenInfo *const token, bool inclWhitespaces)
689695 }
690696 else
691697 {
698+ * noReftagId = false;
692699 /* FIXME: handle U, B, R and F string prefixes? */
693700 readIdentifier (token -> string , c );
694701 token -> keyword = lookupKeyword (vStringValue (token -> string ), Lang_python );
695702 if (token -> keyword == KEYWORD_NONE )
696703 token -> type = TOKEN_IDENTIFIER ;
704+ else if (token -> keyword == KEYWORD___noreftag_id )
705+ {
706+ token -> type = TOKEN_IDENTIFIER ;
707+ * noReftagId = true;
708+ }
697709 else
698710 token -> type = TOKEN_KEYWORD ;
699711 }
@@ -719,9 +731,11 @@ static void readTokenFullNoRefTag (tokenInfo *const token, bool inclWhitespaces)
719731
720732static void readTokenFull (tokenInfo * const token , bool inclWhitespaces )
721733{
722- readTokenFullNoRefTag (token , inclWhitespaces );
734+ bool noReftagId ;
735+ readTokenFullNoRefTag (token , inclWhitespaces , & noReftagId );
723736
724737 if (token -> type == TOKEN_IDENTIFIER
738+ && (!noReftagId )
725739 /* Don't make a ref tag for a number. */
726740 && (vStringLength (token -> string ) > 0 &&
727741 !isdigit ((unsigned char )vStringChar (token -> string , 0 )))
0 commit comments