GenerateReservedWordsJS.py (858B)
1 # This Source Code Form is subject to the terms of the Mozilla Public 2 # License, v. 2.0. If a copy of the MPL was not distributed with this 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 5 import buildconfig 6 import os 7 import sys 8 9 sys.path.append(os.path.join(buildconfig.topsrcdir, "js", "src", "frontend")) 10 import ReservedWordReader 11 12 13 def line(opt, s): 14 opt["output"].write("{}\n".format(s)) 15 16 17 def main(output, reserved_words_h, *args): 18 reserved_word_list = ReservedWordReader.read_reserved_word_list( 19 reserved_words_h, *args 20 ) 21 22 opt = {"output": output} 23 24 line(opt, "const JS_RESERVED_WORDS = [") 25 for index, word in reserved_word_list: 26 line(opt, ' "{}",'.format(word)) 27 line(opt, "];") 28 line(opt, "module.exports = JS_RESERVED_WORDS;") 29 30 31 if __name__ == "__main__": 32 main(sys.stdout, *sys.argv[1:])