|
24 | 24 | import argparse |
25 | 25 | import codecs |
26 | 26 | import string |
| 27 | +import copy |
27 | 28 |
|
28 | 29 | try: |
29 | 30 | from itertools import izip as zip |
@@ -340,30 +341,37 @@ def isStdLibId(id_, standard='c99'): |
340 | 341 |
|
341 | 342 | # Reserved keywords defined in ISO/IEC9899:1990 -- ch 6.1.1 |
342 | 343 | C90_KEYWORDS = { |
343 | | - 'auto', 'break', 'double', 'else', 'enum', 'extern', 'float', 'for', |
344 | | - 'goto', 'if', 'case', 'char', 'const', 'continue', 'default', 'do', 'int', |
345 | | - 'long', 'struct', 'switch', 'register', 'typedef', 'union', 'unsigned', |
346 | | - 'void', 'volatile', 'while', 'return', 'short', 'signed', 'sizeof', |
347 | | - 'static' |
| 344 | + 'auto', 'break', 'case', 'char', 'const', 'continue', 'default', 'do', |
| 345 | + 'double', 'else', 'enum', 'extern', 'float', 'for', 'goto', 'if', |
| 346 | + 'int', 'long', 'register', 'return', 'short', 'signed', |
| 347 | + 'sizeof', 'static', 'struct', 'switch', 'typedef', 'union', 'unsigned', |
| 348 | + 'void', 'volatile', 'while' |
348 | 349 | } |
349 | 350 |
|
350 | 351 |
|
351 | 352 | # Reserved keywords defined in ISO/IEC 9899 WF14/N1256 -- ch. 6.4.1 |
352 | | -C99_KEYWORDS = { |
353 | | - 'auto', 'break', 'case', 'char', 'const', 'continue', 'default', 'do', |
354 | | - 'double', 'else', 'enum', 'extern', 'float', 'for', 'goto', 'if', 'inline', |
355 | | - 'int', 'long', 'register', 'restrict', 'return', 'short', 'signed', |
356 | | - 'sizeof', 'static', 'struct', 'switch', 'typedef', 'union', 'unsigned', |
357 | | - 'void', 'volatile', 'while', '_Bool', '_Complex', '_Imaginary' |
| 353 | +C99_ADDED_KEYWORDS = { |
| 354 | + 'inline', 'restrict', '_Bool', '_Complex', '_Imaginary', |
| 355 | + 'bool', 'complex', 'imaginary' |
358 | 356 | } |
359 | 357 |
|
| 358 | +C11_ADDED_KEYWORDS = { |
| 359 | + '_Alignas', '_Alignof', '_Atomic', '_Generic', '_Noreturn', |
| 360 | + '_Statis_assert', '_Thread_local' , |
| 361 | + 'alignas', 'alignof', 'noreturn', 'static_assert' |
| 362 | +} |
360 | 363 |
|
361 | 364 | def isKeyword(keyword, standard='c99'): |
362 | 365 | kw_set = {} |
363 | 366 | if standard == 'c89': |
364 | 367 | kw_set = C90_KEYWORDS |
365 | 368 | elif standard == 'c99': |
366 | | - kw_set = C99_KEYWORDS |
| 369 | + kw_set = copy.copy(C90_KEYWORDS) |
| 370 | + kw_set.update(C99_ADDED_KEYWORDS) |
| 371 | + else: |
| 372 | + kw_set = copy.copy(C90_KEYWORDS) |
| 373 | + kw_set.update(C99_ADDED_KEYWORDS) |
| 374 | + kw_set.update(C11_ADDED_KEYWORDS) |
367 | 375 | return keyword in kw_set |
368 | 376 |
|
369 | 377 |
|
|
0 commit comments