28
28
29
29
import os
30
30
import traceback
31
+ from copy import deepcopy
31
32
32
33
from nsiqcppstyle_outputer import _consoleOutputer as console
33
34
from nsiqcppstyle_rulehelper import * # @UnusedWildImport
80
81
# Delimeters ( ) [ ] { } , . ; :
81
82
"LPAREN" ,
82
83
"RPAREN" ,
84
+ "PARENS" ,
83
85
"LBRACKET" ,
84
86
"RBRACKET" ,
85
87
"LBRACE" ,
@@ -425,7 +427,6 @@ def __init__(self, filename, data=None):
425
427
tok .filename = self .filename
426
428
tok .pp = None
427
429
# self.ProcessIfdef(tok)
428
- self .tokenlistsize = len (self .tokenlist )
429
430
self .PushTokenIndex ()
430
431
while True :
431
432
t = self .GetNextToken ()
@@ -434,6 +435,10 @@ def __init__(self, filename, data=None):
434
435
t .inactive = self .ProcessIfdef (t )
435
436
self .PopTokenIndex ()
436
437
438
+ @property
439
+ def tokenlistsize (self ):
440
+ return len (self .tokenlist )
441
+
437
442
def ProcessIfdef (self , token ):
438
443
if token .type == "PREPROCESSOR" :
439
444
if Match (r"^#\s*if(n)?def$" , token .value ):
@@ -1158,6 +1163,7 @@ def ConstructContextInfo(lexer):
1158
1163
1159
1164
# Function Prediction
1160
1165
elif t .pp is not True and t .type in ("ID" , "OPERATOR" ) and contextPrediction is None :
1166
+ operator_name = None
1161
1167
curNotSigContext = contextStack .Peek ()
1162
1168
if curNotSigContext is not None and curNotSigContext .sig is False :
1163
1169
continue
@@ -1166,10 +1172,12 @@ def ConstructContextInfo(lexer):
1166
1172
if t .type == "ID" :
1167
1173
t2 = lexer .PeekNextTokenSkipWhiteSpaceAndCommentAndPreprocess ()
1168
1174
t4 = lexer .PeekNextTokenSkipWhiteSpaceAndCommentAndPreprocess (2 )
1169
-
1170
1175
else :
1171
1176
t2 = lexer .PeekNextTokenSkipWhiteSpaceAndCommentAndPreprocess ()
1177
+ operator_name = deepcopy (t2 )
1172
1178
if t2 .type == "LPAREN" :
1179
+ operator_name .value = "()" # call operator
1180
+ operator_name .type = "PARENS" # call operator
1173
1181
t2 = lexer .PeekNextTokenSkipWhiteSpaceAndCommentAndPreprocess (3 )
1174
1182
t4 = lexer .PeekNextTokenSkipWhiteSpaceAndCommentAndPreprocess (4 )
1175
1183
else :
@@ -1204,7 +1212,18 @@ def ConstructContextInfo(lexer):
1204
1212
fullName = t .value
1205
1213
lexer .PushTokenIndex ()
1206
1214
if t .type == "OPERATOR" :
1207
- fullName = fullName + t3 .value
1215
+ fullName = fullName + operator_name .value
1216
+ while True :
1217
+ prevName = lexer .GetPrevTokenSkipWhiteSpaceAndCommentAndPreprocess ()
1218
+ if prevName is not None :
1219
+ if prevName .type == "DOUBLECOLON" :
1220
+ fullName = (
1221
+ f"{ lexer .GetPrevTokenSkipWhiteSpaceAndCommentAndPreprocess ().value } ::{ fullName } "
1222
+ )
1223
+ else :
1224
+ break
1225
+ else :
1226
+ break
1208
1227
else :
1209
1228
while True :
1210
1229
prevName = lexer .GetPrevTokenSkipWhiteSpaceAndCommentAndPreprocess ()
@@ -1221,8 +1240,8 @@ def ConstructContextInfo(lexer):
1221
1240
else :
1222
1241
break
1223
1242
lexer .PopTokenIndex ()
1224
- if Match (r"^[A-Z_][A-Z_0-9][A-Z_0-9]+$" , fullName ):
1225
- continue
1243
+ # if Match(r"^[A-Z_][A-Z_0-9][A-Z_0-9]+$", fullName):
1244
+ # continue
1226
1245
impl = lexer .HasBody ()
1227
1246
if impl :
1228
1247
contextStart = lexer .GetNextTokenInType ("LBRACE" )
@@ -1232,10 +1251,13 @@ def ConstructContextInfo(lexer):
1232
1251
1233
1252
# RunFunctionRule(lexer, functionName, decl, contextStack, contextPrediction)
1234
1253
t .type = "FUNCTION"
1254
+ t .value = fullName
1235
1255
t .fullName = fullName
1236
1256
t .context = contextPrediction
1237
1257
t .decl = not impl
1238
1258
lexer .PopTokenIndex ()
1259
+ if operator_name is not None :
1260
+ operator_name = None
1239
1261
# print "TT", lexer.GetCurTokenLine(), impl,
1240
1262
# contextPrediction
1241
1263
t .contextStack = contextStack
0 commit comments