keywords.js 1015 B

1234567891011121314151617181920212223242526272829303132
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. const fs = require('fs');
  6. const path = require('path');
  7. const keywords = getMySQLKeywords();
  8. keywords.sort();
  9. console.log(`'${keywords.join("',\n'")}'`);
  10. function getMySQLKeywords() {
  11. // https://dev.mysql.com/doc/refman/8.0/en/keywords.html
  12. const lines = fs
  13. .readFileSync(path.join(__dirname, 'keywords.mysql.txt'))
  14. .toString()
  15. .split(/\r\n|\r|\n/);
  16. const tokens = [];
  17. for (let line of lines) {
  18. // Treat ; as a comment marker
  19. line = line.replace(/;.*$/, '');
  20. line = line.trim();
  21. // Only consider reserved keywords
  22. if (!/ \(R\)$/.test(line)) {
  23. continue;
  24. }
  25. line = line.replace(/ \(R\)$/, '');
  26. tokens.push(line);
  27. }
  28. return tokens;
  29. }