Skip to content

Instantly share code, notes, and snippets.

@ericlagergren
Last active January 21, 2016 20:58
Show Gist options
  • Save ericlagergren/4ec6defd29065dbb9112 to your computer and use it in GitHub Desktop.
Save ericlagergren/4ec6defd29065dbb9112 to your computer and use it in GitHub Desktop.
#include <string.h>
// Assuming name is null-terminated.
static bool contains(const char* const* kws, const char* name) {
while (*++kws) {
if (strcmp(*kws, name) == 0) {
return true;
}
}
return false;
}
//http://www.w3schools.com/js/js_reserved.asp
static const char* const js_identifiers[] = {
"abstract", "arguments", "boolean", "break", "byte", "case", "catch", "char", "class"
, "const", "continue", "debugger", "default", "delete", "do", "double", "else", "enum"
, "eval", "export", "extends", "false", "final", "finally", "float", "for", "function"
, "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "let"
, "long", "native", "new", "null", "package", "private", "protected", "public", "return"
, "short", "static", "super", "switch", "synchronized", "this", "throw", "throws"
, "transient", "true", "try", "typeof", "var", "void", "volatile", "while", "with"
, "yield", '\0'
};
//https://secure.php.net/manual/en/reserved.keywords.php
static const char* const php_identifiers[] = {
"__halt_compiler", "abstract", "and", "array", "as", "break", "callable", "case"
, "catch", "class", "clone", "const", "continue", "declare", "default", "die", "do"
, "echo", "else", "elseif", "empty", "enddeclare", "endfor", "endforeach", "endif"
, "endswitch", "endwhile", "eval", "exit", "extends", "final", "finally", "for"
, "foreach", "function", "global", "goto", "if", "implements", "include", "include_once"
, "instanceof", "insteadof", "interface", "isset", "list", "namespace", "new", "or"
, "print", "private", "protected", "public", "require", "require_once", "return"
, "static", "switch", "throw", "trait", "try", "unset", "use", "var", "while", "xor"
, "yield", '\0'
};
//https://docs.python.org/2.5/ref/keywords.html
static const char* const python_identifiers[] = {
"and", "as", "assert", "break", "class", "continue", "def", "del", "elif", "else"
, "except", "exec", "finally", "for", "from", "global", "if", "import", "in", "is"
, "lambda", "not", "or", "pass", "print", "raise", "return", "try", "while", "with"
, "yield", '\0'
};
//https://msdn.microsoft.com/en-us/library/x53a06bb.aspx
static const char* const cs_identifiers[] = {
"abstract", "as", "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", "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", '\0'
};
//http://en.cppreference.com/w/cpp/keyword
static const char* const cpp_identifiers[] = {
"alignas", "alignof", "and", "and_eq", "asm", "auto", "bitand", "bitor", "bool"
, "break", "case", "catch", "char", "char16_t", "char32_t", "class", "compl", "concept"
, "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", "xor_eq", '\0'
};
//https://golang.org/ref/spec#Keywords
static const char* const go_identifiers[] = {
"break", "case", "chan", "const", "continue", "default", "defer", "else", "fallthrough"
, "for", "func", "go", "goto", "if", "import", "interface", "map", "package", "range"
, "return", "select", "struct", "switch", "type", "var", '\0'
};
//https://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html
static const char* const java_identifiers[] = {
"abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class"
, "const", "continue", "default", "do", "double", "else", "enum", "extends", "final"
, "finally", "float", "for", "goto", "if", "implements", "import", "instanceof"
, "int", "interface", "long", "native", "new", "package", "private", "protected"
, "public", "return", "short", "static", "strictfp", "super", "switch", "synchronized"
, "this", "throw", "throws", "transient", "try", "void", "volatile", "while", '\0'
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment