Misra add c11 keywords (#3448)
This commit is contained in:
parent
d4174a31ba
commit
42f66433bc
|
@ -159,7 +159,7 @@ class ValueType:
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
attrs = ["type", "sign", "bits", "typeScopeId", "originalTypeName",
|
attrs = ["type", "sign", "bits", "typeScopeId", "originalTypeName",
|
||||||
"constness", "constness", "pointer"]
|
"constness", "pointer"]
|
||||||
return "{}({})".format(
|
return "{}({})".format(
|
||||||
"ValueType",
|
"ValueType",
|
||||||
", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
|
", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
|
||||||
|
@ -198,7 +198,7 @@ class Token:
|
||||||
isName Is this token a symbol name
|
isName Is this token a symbol name
|
||||||
isNumber Is this token a number, for example 123, 12.34
|
isNumber Is this token a number, for example 123, 12.34
|
||||||
isInt Is this token a int value such as 1234
|
isInt Is this token a int value such as 1234
|
||||||
isFloat Is this token a int value such as 12.34
|
isFloat Is this token a float value such as 12.34
|
||||||
isString Is this token a string literal such as "hello"
|
isString Is this token a string literal such as "hello"
|
||||||
strlen string length for string literal
|
strlen string length for string literal
|
||||||
isChar Is this token a char literal such as 'x'
|
isChar Is this token a char literal such as 'x'
|
||||||
|
|
|
@ -24,6 +24,7 @@ import os
|
||||||
import argparse
|
import argparse
|
||||||
import codecs
|
import codecs
|
||||||
import string
|
import string
|
||||||
|
import copy
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from itertools import izip as zip
|
from itertools import izip as zip
|
||||||
|
@ -340,30 +341,37 @@ def isStdLibId(id_, standard='c99'):
|
||||||
|
|
||||||
# Reserved keywords defined in ISO/IEC9899:1990 -- ch 6.1.1
|
# Reserved keywords defined in ISO/IEC9899:1990 -- ch 6.1.1
|
||||||
C90_KEYWORDS = {
|
C90_KEYWORDS = {
|
||||||
'auto', 'break', 'double', 'else', 'enum', 'extern', 'float', 'for',
|
'auto', 'break', 'case', 'char', 'const', 'continue', 'default', 'do',
|
||||||
'goto', 'if', 'case', 'char', 'const', 'continue', 'default', 'do', 'int',
|
'double', 'else', 'enum', 'extern', 'float', 'for', 'goto', 'if',
|
||||||
'long', 'struct', 'switch', 'register', 'typedef', 'union', 'unsigned',
|
'int', 'long', 'register', 'return', 'short', 'signed',
|
||||||
'void', 'volatile', 'while', 'return', 'short', 'signed', 'sizeof',
|
'sizeof', 'static', 'struct', 'switch', 'typedef', 'union', 'unsigned',
|
||||||
'static'
|
'void', 'volatile', 'while'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Reserved keywords defined in ISO/IEC 9899 WF14/N1256 -- ch. 6.4.1
|
# Reserved keywords defined in ISO/IEC 9899 WF14/N1256 -- ch. 6.4.1
|
||||||
C99_KEYWORDS = {
|
C99_ADDED_KEYWORDS = {
|
||||||
'auto', 'break', 'case', 'char', 'const', 'continue', 'default', 'do',
|
'inline', 'restrict', '_Bool', '_Complex', '_Imaginary',
|
||||||
'double', 'else', 'enum', 'extern', 'float', 'for', 'goto', 'if', 'inline',
|
'bool', 'complex', 'imaginary'
|
||||||
'int', 'long', 'register', 'restrict', 'return', 'short', 'signed',
|
|
||||||
'sizeof', 'static', 'struct', 'switch', 'typedef', 'union', 'unsigned',
|
|
||||||
'void', 'volatile', 'while', '_Bool', '_Complex', '_Imaginary'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
C11_ADDED_KEYWORDS = {
|
||||||
|
'_Alignas', '_Alignof', '_Atomic', '_Generic', '_Noreturn',
|
||||||
|
'_Statis_assert', '_Thread_local' ,
|
||||||
|
'alignas', 'alignof', 'noreturn', 'static_assert'
|
||||||
|
}
|
||||||
|
|
||||||
def isKeyword(keyword, standard='c99'):
|
def isKeyword(keyword, standard='c99'):
|
||||||
kw_set = {}
|
kw_set = {}
|
||||||
if standard == 'c89':
|
if standard == 'c89':
|
||||||
kw_set = C90_KEYWORDS
|
kw_set = C90_KEYWORDS
|
||||||
elif standard == 'c99':
|
elif standard == 'c99':
|
||||||
kw_set = C99_KEYWORDS
|
kw_set = copy.copy(C90_KEYWORDS)
|
||||||
|
kw_set.update(C99_ADDED_KEYWORDS)
|
||||||
|
else:
|
||||||
|
kw_set = copy.copy(C90_KEYWORDS)
|
||||||
|
kw_set.update(C99_ADDED_KEYWORDS)
|
||||||
|
kw_set.update(C11_ADDED_KEYWORDS)
|
||||||
return keyword in kw_set
|
return keyword in kw_set
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue