diff options
author | pommicket <pommicket@gmail.com> | 2022-07-21 23:46:56 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-07-21 23:46:56 -0400 |
commit | 47a65f608f485af32d2df12be489146ad67839e1 (patch) | |
tree | 998051aba1da5da4a75e51bfee9a9a5d5b00b517 /keywords.py | |
parent | 08da42c48bf40f24faa91c00b777ae15ac8f706b (diff) |
minor fixes, syntax highlighting for java & js
Diffstat (limited to 'keywords.py')
-rwxr-xr-x | keywords.py | 63 |
1 files changed, 57 insertions, 6 deletions
diff --git a/keywords.py b/keywords.py index 2413dd9..b7f7432 100755 --- a/keywords.py +++ b/keywords.py @@ -27,6 +27,13 @@ def output_keywords(file, keywords, language): file.write('\t'+', '.join(["['{}'] = syntax_keywords_{}_{}".format(c, language, c) for c in sorted(keywords.keys())]) + '\n') file.write('};\n\n') +def cant_overlap(*args): + for i in range(len(args)): + for j in range(i): + intersection = set(args[i]).intersection(args[j]) + if intersection: + raise ValueError("Argument {} intersects with {}: {}".format(i, j, intersection)) + constants_c = ['CHAR_BIT', 'CHAR_MAX', 'CHAR_MIN', 'DBL_DIG', 'DBL_EPSILON', 'DBL_HAS_SUBNORM', 'DBL_MANT_DIG', 'DBL_MAX', 'DBL_MAX_10_EXP', 'DBL_MAX_EXP', 'DBL_MIN', 'DBL_MIN_EXP', 'DBL_TRUE_MIN', 'DECIMAL_DIG', 'EXIT_FAILURE', 'EXIT_SUCCESS', 'FLT_DECIMAL_DIG', 'FLT_DIG', 'FLT_EVAL_METHOD', 'FLT_HAS_SUBNORM', 'FLT_MANT_DIG', 'FLT_MAX', 'FLT_MAX_10_EXP', 'FLT_MAX_EXP', @@ -151,12 +158,7 @@ keywords_cpp = [ 'xor', 'xor_eq', 'bool', 'wchar_t', ] -def cant_overlap(*args): - for i in range(len(args)): - for j in range(i): - intersection = set(args[i]).intersection(args[j]) - if intersection: - raise ValueError("Argument {} intersects with {}: {}".format(i, j, intersection)) + cant_overlap(keywords_c, keywords_cpp) keywords_rust = [ @@ -253,6 +255,51 @@ builtins_html = [] for attr in attributes_html: builtins_html.append(attr + '=') + +keywords_javascript = [ + 'break', 'case', 'catch', 'class', 'const', + 'continue', 'debugger', 'default', 'delete', + 'do', 'else', 'export', 'extends', 'finally', + 'for', 'function', 'if', 'import', 'in', + 'instanceof', 'new', 'return', 'super', + 'switch', 'this', 'throw', 'try', 'typeof', + 'var', 'void', 'while', 'with', 'yield', + 'let', 'await' +] + +constants_javascript = [ + 'true', 'false' +] + +builtins_javascript = [ + 'AggregateError','Array','ArrayBuffer','AsyncFunction','AsyncGenerator','AsyncGeneratorFunction', + 'Atomics','BigInt','BigInt64Array','BigUint64Array','Boolean','DataView','Date','decodeURI', + 'decodeURIComponent','encodeURI','encodeURIComponent','Error','eval','EvalError','FinalizationRegistry', + 'Float32Array','Float64Array','Function','Generator','GeneratorFunction','globalThis','Infinity', + 'Int16Array','Int32Array','Int8Array','InternalError','Intl','isFinite','isNaN','JSON','Map','Math', + 'NaN','Number','Object','parseFloat','parseInt','Promise','Proxy','RangeError','ReferenceError', + 'Reflect','RegExp','Set','SharedArrayBuffer','String','Symbol','SyntaxError','TypedArray', + 'TypeError','Uint16Array','Uint32Array','Uint8Array','Uint8ClampedArray','undefined', + 'URIError','WeakMap','WeakRef','WeakSet','WebAssembly', 'null' +] + +keywords_java = [ + 'abstract', 'continue', 'for', 'new', 'switch', + 'assert', 'default', 'goto', 'package', 'synchronized', + 'boolean', 'do', 'if', 'private', 'this', + 'break', 'double', 'implements', 'protected', 'throw', + 'byte', 'else', 'import', 'public', 'throws', + 'case', 'enum', 'instanceof', 'return', 'transient', + 'catch', 'extends', 'int', 'short', 'try', + 'char', 'final', 'interface', 'static', 'var', + 'class', 'finally', 'long', 'strictfp', 'void', + 'const', 'float', 'native', 'super', 'volatile', 'while' +] + +constants_java = [ + 'true', 'false', 'null' +] + file = open('keywords.h', 'w') file.write('''// keywords for all languages ted supports // This file was auto-generated by keywords.py @@ -268,6 +315,7 @@ def label(kwds, l): cant_overlap(keywords_c, constants_c, builtins_c) cant_overlap(keywords_rust, builtins_rust, constants_rust) cant_overlap(keywords_python, builtins_python) +cant_overlap(keywords_javascript, builtins_javascript, constants_javascript) c_things = label(keywords_c, SYNTAX_KEYWORD) + label(constants_c, SYNTAX_CONSTANT) + label(builtins_c, SYNTAX_BUILTIN) output_keywords(file, c_things, 'c') cpp_things = c_things + label(keywords_cpp, SYNTAX_KEYWORD) @@ -275,6 +323,9 @@ cpp_things.remove((SYNTAX_BUILTIN, 'bool')) cpp_things.remove((SYNTAX_BUILTIN, 'wchar_t')) output_keywords(file, cpp_things, 'cpp') output_keywords(file, label(keywords_rust, SYNTAX_KEYWORD) + label(builtins_rust, SYNTAX_BUILTIN) + label(constants_rust, SYNTAX_CONSTANT), 'rust') +output_keywords(file, label(keywords_javascript, SYNTAX_KEYWORD) + label(builtins_javascript, SYNTAX_BUILTIN) + + label(constants_javascript, SYNTAX_CONSTANT), 'javascript') +output_keywords(file, label(keywords_java, SYNTAX_KEYWORD) + label(constants_java, SYNTAX_CONSTANT), 'java') output_keywords(file, label(keywords_python, SYNTAX_KEYWORD) + label(builtins_python, SYNTAX_BUILTIN), 'python') output_keywords(file, label(builtins_html, SYNTAX_BUILTIN), 'html') output_keywords(file, label(constants_config, SYNTAX_CONSTANT), 'config') |