@@ -44,6 +44,11 @@ enum {
44
44
KEYWORD_lambda ,
45
45
KEYWORD_pass ,
46
46
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
+
47
52
KEYWORD_REST
48
53
};
49
54
typedef int keywordId ; /* to allow KEYWORD_NONE */
@@ -174,6 +179,7 @@ static const keywordTable PythonKeywordTable[] = {
174
179
{ "lambda" , KEYWORD_lambda },
175
180
{ "pass" , KEYWORD_pass },
176
181
{ "return" , KEYWORD_return },
182
+ { "self" , KEYWORD___noreftag_id },
177
183
};
178
184
179
185
/* Taken from https://docs.python.org/3/reference/lexical_analysis.html#keywords */
@@ -502,7 +508,7 @@ static void ungetToken (tokenInfo *const token)
502
508
copyToken (NextToken , token );
503
509
}
504
510
505
- static void readTokenFullNoRefTag (tokenInfo * const token , bool inclWhitespaces )
511
+ static void readTokenFullNoRefTag (tokenInfo * const token , bool inclWhitespaces , bool * noReftagId )
506
512
{
507
513
int c ;
508
514
int n ;
@@ -689,11 +695,17 @@ static void readTokenFullNoRefTag (tokenInfo *const token, bool inclWhitespaces)
689
695
}
690
696
else
691
697
{
698
+ * noReftagId = false;
692
699
/* FIXME: handle U, B, R and F string prefixes? */
693
700
readIdentifier (token -> string , c );
694
701
token -> keyword = lookupKeyword (vStringValue (token -> string ), Lang_python );
695
702
if (token -> keyword == KEYWORD_NONE )
696
703
token -> type = TOKEN_IDENTIFIER ;
704
+ else if (token -> keyword == KEYWORD___noreftag_id )
705
+ {
706
+ token -> type = TOKEN_IDENTIFIER ;
707
+ * noReftagId = true;
708
+ }
697
709
else
698
710
token -> type = TOKEN_KEYWORD ;
699
711
}
@@ -719,9 +731,11 @@ static void readTokenFullNoRefTag (tokenInfo *const token, bool inclWhitespaces)
719
731
720
732
static void readTokenFull (tokenInfo * const token , bool inclWhitespaces )
721
733
{
722
- readTokenFullNoRefTag (token , inclWhitespaces );
734
+ bool noReftagId ;
735
+ readTokenFullNoRefTag (token , inclWhitespaces , & noReftagId );
723
736
724
737
if (token -> type == TOKEN_IDENTIFIER
738
+ && (!noReftagId )
725
739
/* Don't make a ref tag for a number. */
726
740
&& (vStringLength (token -> string ) > 0 &&
727
741
!isdigit ((unsigned char )vStringChar (token -> string , 0 )))
0 commit comments