JavaScript: fix handling of parentheses around an rvalue
commit8341228ffa5a69970e85cddc7adb6d1f49f247d9
authorColomban Wendling <ban@herbesfolles.org>
Sun, 3 Aug 2014 21:55:25 +0000 (3 23:55 +0200)
committerColomban Wendling <ban@herbesfolles.org>
Sun, 3 Aug 2014 22:23:13 +0000 (4 00:23 +0200)
treed5aa8ad101a080afe0b7a5d729da98d7a6f5ccb3
parent35e8fbbe2886b2c5c82686f7e0435e5aa6aad32f
JavaScript: fix handling of parentheses around an rvalue

Properly skip parentheses around an rvalue, and then properly recognize
the surrounded value.  This allows to properly recognize e.g. rvalue
`({...})` as an object, or `(function(){})` as a function.  As the
implementation is tolerant regarding garbage after the statement,
function expressions called straight away (`(function(){})()`) are
implicitly supported.

This however removes support for the following invalid JavaScript
syntax that was previously supported as a function/method declaration:

var func = () {}

This syntax is not present in the ECMA standard nor is supported by
popular JavaScript engines.

See:
 * http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
   section 13, "Function Definition"
 * http://ecma262-5.com/ELS5_HTML.htm#Section_13
 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope#Defining_functions
tagmanager/ctags/js.c
tests/ctags/Makefile.am
tests/ctags/parenthesis-rvalue.js [new file with mode: 0644]
tests/ctags/parenthesis-rvalue.js.tags [new file with mode: 0644]
tests/ctags/simple.js