Skip to content

Commit

Permalink
Update some of the Slice compiler keyword lists. (zeroc-ice#2791)
Browse files Browse the repository at this point in the history
  • Loading branch information
InsertCreativityHere authored Sep 30, 2024
1 parent e00f874 commit fe55cc6
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 42 deletions.
107 changes: 95 additions & 12 deletions cpp/src/slice2cpp/CPlusPlusUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,18 +640,101 @@ lookupKwd(const string& name)
// so that the keyword list is kept complete.
//
static const string keywordList[] = {
"alignas", "alignof", "and", "and_eq", "asm", "auto", "bitand",
"bitor", "bool", "break", "case", "catch", "char", "char16_t",
"char32_t", "class", "compl", "const", "const_cast", "constexpr", "continue",
"decltype", "default", "delete", "do", "double", "dynamic_cast", "else",
"enum", "explicit", "export", "extern", "false", "float", "for",
"friend", "goto", "if", "inline", "int", "long", "mutable",
"namespace", "new", "noexcept", "not", "not_eq", "nullptr", "operator",
"or", "or_eq", "private", "protected", "public", "register", "reinterpret_cast",
"requires", "return", "short", "signed", "sizeof", "static", "static_assert",
"static_cast", "struct", "switch", "template", "this", "thread_local", "throw",
"true", "try", "typedef", "typeid", "typename", "union", "unsigned",
"using", "virtual", "void", "volatile", "wchar_t", "while", "xor",
"alignas",
"alignof",
"and",
"and_eq",
"asm",
"auto",
"bitand",
"bitor",
"bool",
"break",
"case",
"catch",
"char",
"char16_t",
"char32_t",
"char8_t",
"class",
"co_await",
"co_return",
"co_yield",
"compl",
"concept",
"const",
"const_cast",
"consteval",
"constexpr",
"constinit",
"continue",
"decltype",
"default",
"delete",
"do",
"double",
"dynamic_cast",
"else",
"enum",
"explicit",
"export",
"extern",
"false",
"final",
"float",
"for",
"friend",
"goto",
"if",
"import",
"inline",
"int",
"long",
"module",
"mutable",
"namespace",
"new",
"noexcept",
"not",
"not_eq",
"nullptr",
"operator",
"or",
"or_eq",
"override",
"private",
"protected",
"public",
"register",
"reinterpret_cast",
"requires",
"return",
"short",
"signed",
"sizeof",
"static",
"static_assert",
"static_cast",
"struct",
"switch",
"template",
"this",
"thread_local",
"throw",
"true",
"try",
"typedef",
"typeid",
"typename",
"union",
"unsigned",
"using",
"virtual",
"void",
"volatile",
"wchar_t",
"while",
"xor",
"xor_eq"};
bool found = binary_search(&keywordList[0], &keywordList[sizeof(keywordList) / sizeof(*keywordList)], name);
return found ? "_cpp_" + name : name;
Expand Down
27 changes: 12 additions & 15 deletions cpp/src/slice2cs/CsUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,18 @@ namespace
// Keyword list. *Must* be kept in alphabetical order.
//
static const string keywordList[] = {
"abstract", "as", "async", "await", "base", "bool", "break", "byte",
"case", "catch", "char", "checked", "class", "const", "continue", "decimal",
"default", "delegate", "do", "double", "else", "enum", "event", "explicit",
"extern", "false", "finally", "fixed", "float", "for", "foreach", "goto",
"if", "implicit", "in", "int", "interface", "internal", "is", "lock",
"long", "namespace", "new", "null", "object", "operator", "out", "override",
"params", "private", "protected", "public", "readonly", "ref", "return", "sbyte",
"sealed", "short", "sizeof", "stackalloc", "static", "string", "struct", "switch",
"this", "throw", "true", "try", "typeof", "uint", "ulong", "unchecked",
"unsafe", "ushort", "using", "virtual", "void", "volatile", "while"};
bool found = binary_search(
&keywordList[0],
&keywordList[sizeof(keywordList) / sizeof(*keywordList)],
name,
Slice::CICompare());
"abstract", "as", "async", "await", "base", "bool", "break", "byte",
"case", "catch", "char", "checked", "class", "const", "continue", "decimal",
"default", "delegate", "do", "double", "else", "enum", "event", "explicit",
"extern", "false", "finally", "fixed", "float", "for", "foreach", "goto",
"if", "implicit", "in", "int", "interface", "internal", "is", "lock",
"long", "namespace", "new", "null", "object", "operator", "out", "override",
"params", "private", "protected", "public", "readonly", "record", "ref", "required",
"return", "sbyte", "scoped", "sealed", "short", "sizeof", "stackalloc", "static",
"string", "struct", "switch", "this", "throw", "true", "try", "typeof",
"uint", "ulong", "unchecked", "unsafe", "ushort", "using", "var", "virtual",
"void", "volatile", "while"};
bool found = binary_search(&keywordList[0], &keywordList[sizeof(keywordList) / sizeof(*keywordList)], name);
if (found)
{
return "@" + name;
Expand Down
18 changes: 10 additions & 8 deletions cpp/src/slice2java/JavaUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,16 @@ namespace
// NOTE: Any changes made to this list must also be made in BasicStream.java.
//
static const string keywordList[] = {
"abstract", "assert", "boolean", "break", "byte", "case", "catch", "char",
"checkedCast", "class", "clone", "const", "continue", "default", "do", "double",
"else", "enum", "equals", "extends", "false", "final", "finalize", "finally",
"float", "for", "getClass", "goto", "hashCode", "if", "implements", "import",
"instanceof", "int", "interface", "long", "native", "new", "notify", "notifyAll",
"null", "package", "private", "protected", "public", "return", "short", "static",
"strictfp", "super", "switch", "synchronized", "this", "throw", "throws", "toString",
"transient", "true", "try", "uncheckedCast", "void", "volatile", "wait", "while"};
"abstract", "assert", "boolean", "break", "byte", "case", "catch",
"char", "checkedCast", "class", "clone", "const", "continue", "default",
"do", "double", "else", "enum", "equals", "extends", "false",
"final", "finalize", "finally", "float", "for", "getClass", "goto",
"hashCode", "if", "implements", "import", "instanceof", "int", "interface",
"long", "native", "new", "notify", "notifyAll", "null", "package",
"permits", "private", "protected", "public", "record", "return", "sealed",
"short", "static", "strictfp", "super", "switch", "synchronized", "this",
"throw", "throws", "toString", "transient", "true", "try", "uncheckedCast",
"var", "void", "volatile", "wait", "when", "while", "yield"};
bool found = binary_search(&keywordList[0], &keywordList[sizeof(keywordList) / sizeof(*keywordList)], name);
return found ? "_" + name : name;
}
Expand Down
3 changes: 3 additions & 0 deletions cpp/src/slice2php/PHPUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ lookupKwd(const string& name)
"extends",
"final",
"finally",
"fn",
"for",
"foreach",
"function",
Expand All @@ -78,13 +79,15 @@ lookupKwd(const string& name)
"interface",
"isset",
"list",
"match",
"namespace",
"new",
"or",
"print",
"private",
"protected",
"public",
"readonly",
"require",
"require_once",
"return",
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/slice2py/PythonUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ lookupKwd(const string& name)
"False", "None", "True", "and", "as", "assert", "async", "await", "break", "case",
"class", "continue", "def", "del", "elif", "else", "except", "exec", "finally", "for",
"from", "global", "if", "import", "in", "is", "lambda", "match", "nonlocal", "not",
"or", "pass", "print", "raise", "return", "try", "while", "with", "yield"};
"or", "pass", "print", "raise", "return", "try", "type", "while", "with", "yield"};
bool found = binary_search(&keywordList[0], &keywordList[sizeof(keywordList) / sizeof(*keywordList)], name);
return found ? "_" + name : name;
}
Expand Down
17 changes: 11 additions & 6 deletions cpp/src/slice2swift/SwiftUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,19 @@ namespace
//
static const string keywordList[] = {
"Any",
"Self",
"Type",
"as",
"associatedtype",
"associativity",
"async",
"await",
"borrowing",
"break",
"case",
"catch",
"class",
"consuming",
"continue",
"convenience",
"default",
Expand Down Expand Up @@ -67,13 +73,16 @@ namespace
"mutating",
"nil",
"none",
"nonisolated",
"nonmutating",
"open",
"operator",
"optional",
"override",
"package",
"postfix",
"precedence",
"precedencegroup",
"prefix",
"private",
"protocol",
Expand All @@ -85,6 +94,7 @@ namespace
"right",
"self",
"set",
"some",
"static",
"struct",
"subscript",
Expand All @@ -94,19 +104,14 @@ namespace
"throws",
"true",
"try",
"Type",
"typealias",
"unowned",
"var",
"weak",
"where",
"while",
"willSet"};
bool found = binary_search(
&keywordList[0],
&keywordList[sizeof(keywordList) / sizeof(*keywordList)],
name,
Slice::CICompare());
bool found = binary_search(&keywordList[0], &keywordList[sizeof(keywordList) / sizeof(*keywordList)], name);
if (found)
{
return "`" + name + "`";
Expand Down

0 comments on commit fe55cc6

Please sign in to comment.