Lines Matching refs:token
405 def push(self, token): argument
406 self.tokens.insert(0, token);
413 def token(self): member in CLexer
632 def error(self, msg, token=-1): argument
637 if token != -1:
638 print("Got token ", token)
642 def debug(self, msg, token=-1): argument
644 if token != -1:
645 print("Got token ", token)
676 def parseComment(self, token): argument
678 self.top_comment = token[1]
679 if self.comment == None or token[1][0] == '*':
680 self.comment = token[1];
682 self.comment = self.comment + token[1]
683 token = self.lexer.token()
691 return token
922 def parsePreproc(self, token): argument
924 print("=> preproc ", token, self.lexer.tokens)
925 name = token[1]
927 token = self.lexer.token()
928 if token == None:
930 if token[0] == 'preproc':
931 self.index_add(token[1], self.filename, not self.is_header,
933 return self.lexer.token()
934 return token
936 token = self.lexer.token()
937 if token == None:
939 if token[0] == 'preproc':
941 name = token[1]
943 token = self.lexer.token()
944 while token != None and token[0] == 'preproc' and \
945 token[1][0] != '#':
946 lst.append(token[1])
947 token = self.lexer.token()
955 return token
1011 token = self.lexer.token()
1012 while token != None and token[0] == 'preproc' and \
1013 token[1][0] != '#':
1014 token = self.lexer.token()
1015 return token
1022 def token(self): member in CParser
1025 token = self.lexer.token()
1026 while token != None:
1027 if token[0] == 'comment':
1028 token = self.parseComment(token)
1030 elif token[0] == 'preproc':
1031 token = self.parsePreproc(token)
1033 elif token[0] == "name" and token[1] == "__const":
1034 token = ("name", "const")
1035 return token
1036 elif token[0] == "name" and token[1] == "__attribute":
1037 token = self.lexer.token()
1038 while token != None and token[1] != ";":
1039 token = self.lexer.token()
1040 return token
1041 elif token[0] == "name" and token[1] in ignored_words:
1042 (n, info) = ignored_words[token[1]]
1045 token = self.lexer.token()
1047 token = self.lexer.token()
1051 print("=> ", token)
1052 return token
1058 def parseTypedef(self, token): argument
1059 if token == None:
1061 token = self.parseType(token)
1062 if token == None:
1068 while token != None:
1069 if token[0] == "name":
1070 name = token[1]
1088 token = self.token()
1091 return token
1093 if token != None and token[0] == 'sep' and token[1] == ',':
1095 token = self.token()
1096 while token != None and token[0] == "op":
1097 type = type + token[1]
1098 token = self.token()
1099 elif token != None and token[0] == 'sep' and token[1] == ';':
1101 elif token != None and token[0] == 'name':
1105 self.error("parsing typedef: expecting ';'", token)
1106 return token
1107 token = self.token()
1108 return token
1114 def parseBlock(self, token): argument
1115 while token != None:
1116 if token[0] == "sep" and token[1] == "{":
1117 token = self.token()
1118 token = self.parseBlock(token)
1119 elif token[0] == "sep" and token[1] == "}":
1121 token = self.token()
1122 return token
1125 oldtok = token
1126 token = self.token()
1128 if token[0] == "sep" and token[1] == "(":
1131 token = self.token()
1132 elif token[0] == "name":
1133 token = self.token()
1134 if token[0] == "sep" and (token[1] == ";" or
1135 token[1] == "," or token[1] == "="):
1146 token = self.token()
1147 return token
1152 def parseStruct(self, token): argument
1155 while token != None:
1156 if token[0] == "sep" and token[1] == "{":
1157 token = self.token()
1158 token = self.parseTypeBlock(token)
1159 elif token[0] == "sep" and token[1] == "}":
1163 token = self.token()
1164 return token
1168 token = self.parseType(token)
1170 if token != None and token[0] == "name":
1171 fname = token[1]
1172 token = self.token()
1173 if token[0] == "sep" and token[1] == ";":
1175 token = self.token()
1179 self.error("parseStruct: expecting ;", token)
1180 elif token != None and token[0] == "sep" and token[1] == "{":
1181 token = self.token()
1182 token = self.parseTypeBlock(token)
1183 if token != None and token[0] == "name":
1184 token = self.token()
1185 if token != None and token[0] == "sep" and token[1] == ";":
1186 token = self.token()
1188 self.error("parseStruct: expecting ;", token)
1190 self.error("parseStruct: name", token)
1191 token = self.token()
1196 return token
1201 def parseEnumBlock(self, token): argument
1207 while token != None:
1208 if token[0] == "sep" and token[1] == "{":
1209 token = self.token()
1210 token = self.parseTypeBlock(token)
1211 elif token[0] == "sep" and token[1] == "}":
1217 token = self.token()
1218 return token
1219 elif token[0] == "name":
1225 name = token[1]
1227 token = self.token()
1228 if token[0] == "op" and token[1][0] == "=":
1230 if len(token[1]) > 1:
1231 value = token[1][1:]
1232 token = self.token()
1233 while token[0] != "sep" or (token[1] != ',' and
1234 token[1] != '}'):
1235 value = value + token[1]
1236 token = self.token()
1243 if token[0] == "sep" and token[1] == ",":
1244 token = self.token()
1246 token = self.token()
1247 return token
1253 def parseTypeBlock(self, token): argument
1254 while token != None:
1255 if token[0] == "sep" and token[1] == "{":
1256 token = self.token()
1257 token = self.parseTypeBlock(token)
1258 elif token[0] == "sep" and token[1] == "}":
1259 token = self.token()
1260 return token
1262 token = self.token()
1263 return token
1270 def parseType(self, token): argument
1274 if token == None:
1275 return token
1277 while token[0] == "name" and (
1278 token[1] == "const" or \
1279 token[1] == "unsigned" or \
1280 token[1] == "signed"):
1282 self.type = token[1]
1284 self.type = self.type + " " + token[1]
1285 token = self.token()
1287 if token[0] == "name" and (token[1] == "long" or token[1] == "short"):
1289 self.type = token[1]
1291 self.type = self.type + " " + token[1]
1292 if token[0] == "name" and token[1] == "int":
1298 elif token[0] == "name" and token[1] == "struct":
1300 self.type = token[1]
1302 self.type = self.type + " " + token[1]
1303 token = self.token()
1305 if token[0] == "name":
1306 nametok = token
1307 token = self.token()
1308 if token != None and token[0] == "sep" and token[1] == "{":
1309 token = self.token()
1310 token = self.parseStruct(token)
1311 elif token != None and token[0] == "op" and token[1] == "*":
1313 token = self.token()
1314 while token != None and token[0] == "op" and token[1] == "*":
1316 token = self.token()
1317 if token[0] == "name":
1318 nametok = token
1319 token = self.token()
1321 self.error("struct : expecting name", token)
1322 return token
1323 elif token != None and token[0] == "name" and nametok != None:
1325 return token
1328 self.lexer.push(token)
1329 token = nametok
1330 return token
1332 elif token[0] == "name" and token[1] == "enum":
1334 self.type = token[1]
1336 self.type = self.type + " " + token[1]
1338 token = self.token()
1339 if token != None and token[0] == "sep" and token[1] == "{":
1340 token = self.token()
1341 token = self.parseEnumBlock(token)
1343 self.error("parsing enum: expecting '{'", token)
1345 if token != None and token[0] != "name":
1346 self.lexer.push(token)
1347 token = ("name", "enum")
1349 enum_type = token[1]
1354 return token
1356 elif token[0] == "name":
1358 self.type = token[1]
1360 self.type = self.type + " " + token[1]
1363 token)
1364 return token
1365 token = self.token()
1366 while token != None and (token[0] == "op" or
1367 token[0] == "name" and token[1] == "const"):
1368 self.type = self.type + " " + token[1]
1369 token = self.token()
1374 if token != None and token[0] == "sep" and token[1] == '(':
1375 self.type = self.type + token[1]
1376 token = self.token()
1377 while token != None and token[0] == "op" and token[1] == '*':
1378 self.type = self.type + token[1]
1379 token = self.token()
1380 if token == None or token[0] != "name" :
1381 self.error("parsing function type, name expected", token);
1382 return token
1383 self.type = self.type + token[1]
1384 nametok = token
1385 token = self.token()
1386 if token != None and token[0] == "sep" and token[1] == ')':
1387 self.type = self.type + token[1]
1388 token = self.token()
1389 if token != None and token[0] == "sep" and token[1] == '(':
1390 token = self.token()
1392 token = self.parseSignature(token);
1395 self.error("parsing function type, '(' expected", token);
1396 return token
1398 self.error("parsing function type, ')' expected", token);
1399 return token
1400 self.lexer.push(token)
1401 token = nametok
1402 return token
1407 if token != None and token[0] == "name":
1408 nametok = token
1409 token = self.token()
1410 if token != None and token[0] == "sep" and token[1] == '[':
1412 while token != None and token[0] == "sep" and token[1] == '[':
1413 self.type = self.type + token[1]
1414 token = self.token()
1415 while token != None and token[0] != 'sep' and \
1416 token[1] != ']' and token[1] != ';':
1417 self.type = self.type + token[1]
1418 token = self.token()
1419 if token != None and token[0] == 'sep' and token[1] == ']':
1420 self.type = self.type + token[1]
1421 token = self.token()
1423 self.error("parsing array type, ']' expected", token);
1424 return token
1425 elif token != None and token[0] == "sep" and token[1] == ':':
1427 token = self.token()
1428 token = self.token()
1429 self.lexer.push(token)
1430 token = nametok
1432 return token
1437 def parseSignature(self, token): argument
1439 if token != None and token[0] == "sep" and token[1] == ')':
1441 token = self.token()
1442 return token
1443 while token != None:
1444 token = self.parseType(token)
1445 if token != None and token[0] == "name":
1446 signature.append((self.type, token[1], None))
1447 token = self.token()
1448 elif token != None and token[0] == "sep" and token[1] == ',':
1449 token = self.token()
1451 elif token != None and token[0] == "sep" and token[1] == ')':
1457 if token != None and token[0] == "sep":
1458 if token[1] == ',':
1459 token = self.token()
1461 elif token[1] == ')':
1462 token = self.token()
1465 return token
1471 def parseGlobal(self, token): argument
1473 if token[1] == 'extern':
1474 token = self.token()
1475 if token == None:
1476 return token
1477 if token[0] == 'string':
1478 if token[1] == 'C':
1479 token = self.token()
1480 if token == None:
1481 return token
1482 if token[0] == 'sep' and token[1] == "{":
1483 token = self.token()
1485 while token != None and (token[0] != 'sep' or
1486 token[1] != "}"):
1487 if token[0] == 'name':
1488 token = self.parseGlobal(token)
1492 token[0], token[1]))
1493 token = self.parseGlobal(token)
1495 token = self.token()
1496 return token
1498 return token
1499 elif token[1] == 'static':
1501 token = self.token()
1502 if token == None or token[0] != 'name':
1503 return token
1505 if token[1] == 'typedef':
1506 token = self.token()
1507 return self.parseTypedef(token)
1509 token = self.parseType(token)
1511 if token == None or token[0] != "name":
1512 return token
1514 self.name = token[1]
1515 token = self.token()
1516 while token != None and (token[0] == "sep" or token[0] == "op"):
1517 if token[0] == "sep":
1518 if token[1] == "[":
1519 type = type + token[1]
1520 token = self.token()
1521 while token != None and (token[0] != "sep" or \
1522 token[1] != ";"):
1523 type = type + token[1]
1524 token = self.token()
1526 if token != None and token[0] == "op" and token[1] == "=":
1530 token = self.token()
1531 if token[0] == 'sep' and token[1] == '{':
1532 token = self.token()
1533 token = self.parseBlock(token)
1536 while token != None and (token[0] != "sep" or \
1537 (token[1] != ';' and token[1] != ',')):
1538 token = self.token()
1540 if token == None or token[0] != "sep" or (token[1] != ';' and
1541 token[1] != ','):
1544 if token != None and token[0] == "sep":
1545 if token[1] == ";":
1547 token = self.token()
1555 elif token[1] == "(":
1556 token = self.token()
1557 token = self.parseSignature(token)
1558 if token == None:
1560 if token[0] == "sep" and token[1] == ";":
1565 token = self.token()
1566 elif token[0] == "sep" and token[1] == "{":
1571 token = self.token()
1572 token = self.parseBlock(token);
1573 elif token[1] == ',':
1578 token = self.token()
1579 while token != None and token[0] == "sep":
1580 type = type + token[1]
1581 token = self.token()
1582 if token != None and token[0] == "name":
1583 self.name = token[1]
1584 token = self.token()
1588 return token
1592 token = self.token()
1593 while token != None:
1594 if token[0] == 'name':
1595 token = self.parseGlobal(token)
1598 token[0], token[1]))
1599 token = self.parseGlobal(token)
1640 for token in tokens:
1642 c = token[0]
1645 elif len(token) < 3:
1648 lower = token.lower()
1652 elif token in self.xref:
1653 self.xref[token].append(id)
1655 self.xref[token] = [id]
2026 for token in tokens:
2027 if tok == token:
2029 tok = token
2030 output.write(" <ref name='%s'/>\n" % (token))