Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion for Javascript keywords and reserved names #634

Closed
Xotic750 opened this issue Sep 28, 2015 · 11 comments
Closed

Suggestion for Javascript keywords and reserved names #634

Xotic750 opened this issue Sep 28, 2015 · 11 comments

Comments

@Xotic750
Copy link

I'd like to suggest that you change the code starting line 170 of src/python-sitelib/langinfo_prog.py to:

    # These are the keywords that are used in most JavaScript environments.
    common_keywords = set([
                          "arguments",
                          "await",
                          "break",
                          "case",
                          "catch",
                          "class",
                          "const",
                          "continue",
                          "debugger",
                          "default",
                          "delete",
                          "do",
                          "else",
                          "enum",
                          "eval",
                          "export",
                          "extends",
                          "false",
                          "finally",
                          "for",
                          "function",
                          "if",
                          "implements",
                          "import",
                          "in",
                          "instanceof",
                          "interface",
                          "let",
                          "new",
                          "null",
                          "of",
                          "package",
                          "private",
                          "protected",
                          "public",
                          "return",
                          "static",
                          "super",
                          "switch",
                          "this",
                          "throw",
                          "true",
                          "try",
                          "typeof",
                          "var",
                          "void",
                          "while",
                          "with",
                          "yield"
                          ])
    keywords = common_keywords.union(
                # Additional JavaScript reserved keywords.
                set([
                    "Infinity",
                    "NaN",
                    "abstract",
                    "boolean",
                    "break",
                    "byte",
                    "case",
                    "catch",
                    "char",
                    "class",
                    "const",
                    "continue",
                    "debugger",
                    "default",
                    "delete",
                    "do",
                    "double",
                    "else",
                    "enum",
                    "export",
                    "extends",
                    "false",
                    "final",
                    "finally",
                    "float",
                    "for",
                    "function",
                    "goto",
                    "if",
                    "implements",
                    "import",
                    "in",
                    "instanceof",
                    "int",
                    "interface",
                    "long",
                    "native",
                    "new",
                    "null",
                    "package",
                    "private",
                    "protected",
                    "public",
                    "return",
                    "short",
                    "static",
                    "super",
                    "switch",
                    "synchronized",
                    "this",
                    "throw",
                    "throws",
                    "transient",
                    "true",
                    "try",
                    "typeof",
                    "undefined",
                    "var",
                    "void",
                    "volatile",
                    "while",
                    "with"
                  ]))

This is based on information at https://mathiasbynens.be/notes/reserved-keywords and some tests that I performed with the attached code at the end. The reason for this is because there appear to some words missing and the current lists would seem to make maintenance difficult; having the complete lists for keywords and reserved names, which you are making unique and then performing a union upon should help in future. The downside is that there may be a few duplicates between lists and therefore a few extra name entries. I hope that you find this information of use.

/*jshint devel:true */

(function () {
  'use strict';

  // These are the keywords that are used in most JavaScript environments.
  var keywords = [
      'break',
      'case',
      'catch',
      'const',
      'continue',
      'debugger',
      'default',
      'delete',
      'do',
      'else',
      'export',
      'false',
      'finally',
      'for',
      'function',
      'if',
      'import',
      'in',
      'instanceof',
      'let',
      'new',
      'null',
      'of',
      'return',
      'switch',
      'this',
      'throw',
      'true',
      'try',
      'typeof',
      'undefined',
      'var',
      'void',
      'while',
      'with',
      'yield'
    ],

    // Additional JavaScript reserved keywords.
    reserved = [
      'abstract',
      'arguments',
      'boolean',
      'byte',
      'char',
      'class',
      'double',
      'enum',
      'eval',
      'extends',
      'final',
      'float',
      'goto',
      'implements',
      'int',
      'interface',
      'long',
      'native',
      'package',
      'private',
      'protected',
      'public',
      'short',
      'static',
      'super',
      'synchronized',
      'throws',
      'transient',
      'volatile'
    ],

    // ES3 Reserved Property Names
    es3rpn = [
      'abstract',
      'boolean',
      'break',
      'byte',
      'case',
      'catch',
      'char',
      'class',
      'const',
      'continue',
      'debugger',
      'default',
      'delete',
      'do',
      'double',
      'else',
      'enum',
      'export',
      'extends',
      'false',
      'final',
      'finally',
      'float',
      'for',
      'function',
      'goto',
      'if',
      'implements',
      'import',
      'in',
      'instanceof',
      'int',
      'interface',
      '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'
    ],

    // Actual ES3 reserved words.
    /*
    es3 = [
      'abstract',
      'boolean',
      'break',
      'byte',
      'case',
      'catch',
      'char',
      'class',
      'const',
      'continue',
      'debugger',
      'default',
      'delete',
      'do',
      'double',
      'else',
      'enum',
      'export',
      'extends',
      'false',
      'final',
      'finally',
      'float',
      'for',
      'function',
      'goto',
      'if',
      'implements',
      'import',
      'in',
      'instanceof',
      'int',
      'interface',
      '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'
    ],
    */

    // Actual ES5 reserved words.
    /*
    es5 = [
      'arguments',
      'break',
      'case',
      'catch',
      'class',
      'const',
      'continue',
      'debugger',
      'default',
      'delete',
      'do',
      'else',
      'enum',
      'eval',
      'export',
      'extends',
      'false',
      'finally',
      'for',
      'function',
      'if',
      'implements',
      'import',
      'in',
      'instanceof',
      'interface',
      'let',
      'new',
      'null',
      'package',
      'private',
      'protected',
      'public',
      'return',
      'static',
      'super',
      'switch',
      'this',
      'throw',
      'true',
      'try',
      'typeof',
      'var',
      'void',
      'while',
      'with',
      'yield'
    ],
    */

    // Actual ES6 reserved words.
    es6 = [
      'arguments',
      'await',
      'break',
      'case',
      'catch',
      'class',
      'const',
      'continue',
      'debugger',
      'default',
      'delete',
      'do',
      'else',
      'enum',
      'eval',
      'export',
      'extends',
      'false',
      'finally',
      'for',
      'function',
      'if',
      'implements',
      'import',
      'in',
      'instanceof',
      'interface',
      'let',
      'new',
      'null',
      'of',
      'package',
      'private',
      'protected',
      'public',
      'return',
      'static',
      'super',
      'switch',
      'this',
      'throw',
      'true',
      'try',
      'typeof',
      'var',
      'void',
      'while',
      'with',
      'yield',
    ],

    strictReserved = [
      'Infinity',
      'NaN',
      'undefined'
    ],

    // Union of the two Komodi lists.
    komodoSet,
    komodoAll,

    // Results.
    missingES6,
    missingES3Reserved,
    missingES6Strict,
    missingReserved,
    additional,
    suggestedKeywords = es6.slice(),
    suggestedReserved = es3rpn.concat(strictReserved).sort(),
    sugestedSet,
    suggestedAll,
    missing;

  // Union of the three suggested lists.
  sugestedSet = new Set(suggestedKeywords);
  suggestedReserved.forEach(function (name) {
    sugestedSet.add(name);
  });

  suggestedAll = Array.from(sugestedSet).sort();

  // Union of the two Komodi lists.
  komodoSet = new Set(keywords);
  reserved.forEach(function (name) {
    komodoSet.add(name);
  });

  komodoAll = Array.from(komodoSet).sort();

  // Missing ES6 from Komodo
  missingES6 = es6.reduce(function (acc, keyword) {
    if (keywords.indexOf(keyword) === -1) {
      acc.push(keyword);
    }

    return acc;
  }, []);

  // Missing ES3 reserved from Komodo
  missingES3Reserved = es3rpn.reduce(function (acc, keyword) {
    if (reserved.indexOf(keyword) === -1) {
      acc.push(keyword);
    }

    return acc;
  }, []);

  // Missing ES6 strict from Komodo
  missingES6Strict = strictReserved.reduce(function (acc, keyword) {
    if (reserved.indexOf(keyword) === -1) {
      acc.push(keyword);
    }

    return acc;
  }, []);

  missingReserved = missingES3Reserved.concat(missingES6Strict).sort();

  // Additional to Komodo
  additional = komodoAll.reduce(function (acc, keyword) {
    if (suggestedAll.indexOf(keyword) === -1) {
      acc.push(keyword);
    }

    return acc;
  }, []);

  // Additional to Komodo
  missing = suggestedAll.reduce(function (acc, keyword) {
    if (komodoAll.indexOf(keyword) === -1) {
      acc.push(keyword);
    }

    return acc;
  }, []);

  //console.log('missingES6', JSON.stringify(missingES6, null, 2));
  //console.log('missingES3Reserved', JSON.stringify(missingES3Reserved, null, 2));
  //console.log('missingES6Strict', JSON.stringify(missingES6Strict, null, 2));
  //console.log('missingReserved', JSON.stringify(missingReserved, null, 2));
  //console.log('additional', JSON.stringify(additional, null, 2));
  //console.log('missing', JSON.stringify(missing, null, 2));
  console.log('suggestedKeywords', JSON.stringify(suggestedKeywords, null, 2));
  console.log('suggestedReserved', JSON.stringify(suggestedReserved, null, 2));
}());

@th3coop
Copy link
Member

th3coop commented Sep 28, 2015

Hey there @Xotic750,

This is awesome! Thanks for taking the time to contact us about this change. I have one request though. Could you close this and submit your changes as a pull request so we can properly integrate and test it without having to copy/paste?

Please don't hesitate to ask if you need assistance.

  • Carey

@Xotic750
Copy link
Author

@cgchoffman I am just trying to clone and build KE on my PC, to see how it goes, once done and all seems to be working then I'll fork and send in a request.

@th3coop
Copy link
Member

th3coop commented Sep 28, 2015

Great, thanks a lot @Xotic750 .

@Xotic750
Copy link
Author

@cgchoffman Well, several hours and 2 failed builds of mozila; searching google hasn't helped to find a resolution. Anyone know anything? So, I am currently unable to test any changes that I make. I can fork the project and submit the changes, but without any kind of guarantee of it being mistake free.

67:44.50 libgfx_layers.a.desc
67:44.62 /home/graham/source_projects/KomodoEdit/mozilla/build/moz3500-ko9.10/mozilla/config/recurse.mk:36: recipe for target 'compile' failed
67:44.62 gmake[3]: *** [compile] Error 2
67:44.62 /home/graham/source_projects/KomodoEdit/mozilla/build/moz3500-ko9.10/mozilla/config/rules.mk:551: recipe for target 'default' failed
67:44.63 gmake[2]: *** [default] Error 2
67:44.63 /home/graham/source_projects/KomodoEdit/mozilla/build/moz3500-ko9.10/mozilla/client.mk:398: recipe for target 'realbuild' failed
67:44.63 gmake[1]: *** [realbuild] Error 2
67:44.63 client.mk:171: recipe for target 'build' failed
67:44.63 gmake: *** [build] Error 2
67:44.66 68 compiler warnings present.
67:46.02 Failed to parse ccache stats output: primary config                      /home/graham/.ccache/ccache.conf
Traceback (most recent call last):
  File "build.py", line 2959, in <module>
    sys.exit( main(sys.argv) )
  File "build.py", line 2955, in main
    return build(args)
  File "build.py", line 2779, in build
    newArgv = targetFunc(argv)
  File "build.py", line 2466, in target_all
    target_mozilla()
  File "build.py", line 2371, in target_mozilla
    buildDir, log.info)
  File "build.py", line 249, in _run_in_dir
    _run(cmd, logstream=None)
  File "build.py", line 231, in _run
    raise OSError("error running '%s': %r" % (cmd, status))
OSError: error running 'python mach --log-file /home/graham/source_projects/KomodoEdit/mozilla/build/moz3500-ko9.10/mozilla/mach.log build ': 2

@Defman21
Copy link
Contributor

Leave it to me. I'll test your changes tomorrow :)

@Defman21
Copy link
Contributor

Your changes works perfectly as far as I can see. I'll send a PR if you don't mind (Of course it's YOUR changes, not mine 😃)

@Xotic750
Copy link
Author

@Defman21 Thank you! Hopefully I may find a solution as to why mozilla doesn't build so that I can make future contributions.

@Naatan
Copy link
Member

Naatan commented Sep 29, 2015

Closing this, we'll track it via the PR. Thanks guys!

@Naatan Naatan closed this as completed Sep 29, 2015
@Xotic750
Copy link
Author

With whom would I approach regarding the Komodo-Mozilla build? Is this dealt with here or is this something that I would have to take up with Mozilla?

@th3coop
Copy link
Member

th3coop commented Sep 29, 2015

@Xotic750 If you continue to have that build issue, please start a forum thread for help. I remember hitting that issue but don't recall how I got around it. I'm rebuilding mozilla on my mac right now to see if I can hit it again.

EDIT: Mozilla built no problem :( Still make the thread in the forums to get assistance.

@Xotic750
Copy link
Author

@cgchoffman Thanks, I have created a topic http://forum.komodoide.com/t/failing-to-build-mozilla-from-trunk/2087

@tonyattwood
Copy link

Hi,
I found that amazing stuff and I can tell it's the best of its kind, just take a look http://explore.sameera.info/e4sjt
tony.attwood

@tonyattwood
Copy link

Hello!
Here are some useful links that I've chosen just for you, check it out http://explore.sameera.info/e4mod

Good wishes, tony.attwood

@tonyattwood
Copy link

Hello!

I've found some fresh information that you were looking for, it may be useful for you, just take a look http://caquedaquu.openella.com/e4hpb

All the best, tony.attwood

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants