diff --git a/Units/parser-javascript.r/js-fields.d/expected.tags b/Units/parser-javascript.r/js-fields.d/expected.tags index 5ab16ad5ed..b9030c39fa 100644 --- a/Units/parser-javascript.r/js-fields.d/expected.tags +++ b/Units/parser-javascript.r/js-fields.d/expected.tags @@ -17,6 +17,8 @@ field13 input.js /^ ['field13'];$/;" M class:Class0 ['field1' + '4'] input.js /^ ['field1' + '4']$/;" M class:Class0 field15 input.js /^ field15 = 1$/;" M class:Class0 field16 input.js /^ field16 = [ function() {return}, function() {return} ]$/;" M class:Class0 +anonymousFunction391993410100 input.js /^ field16 = [ function() {return}, function() {return} ]$/;" f class:Class0 +anonymousFunction391993410200 input.js /^ field16 = [ function() {return}, function() {return} ]$/;" f class:Class0 method2 input.js /^ method2() {$/;" m class:Class0 method3 input.js /^ method3() {$/;" m class:Class0 Class1 input.js /^class Class1 {$/;" c diff --git a/Units/parser-javascript.r/js-null-tag-for-broken-input3.d/expected.tags b/Units/parser-javascript.r/js-null-tag-for-broken-input3.d/expected.tags index 15da2661d9..0e5ba2ace4 100644 --- a/Units/parser-javascript.r/js-null-tag-for-broken-input3.d/expected.tags +++ b/Units/parser-javascript.r/js-null-tag-for-broken-input3.d/expected.tags @@ -1 +1,2 @@ a input.js /^"a".prototype = function() {}$/;" c +anonymousFunction2e03ffc00100 input.js /^"a".prototype = function() {}$/;" f diff --git a/Units/parser-javascript.r/js-self-invoking-anon-func.d/args.ctags b/Units/parser-javascript.r/js-self-invoking-anon-func.d/args.ctags new file mode 100644 index 0000000000..5ee5f79f70 --- /dev/null +++ b/Units/parser-javascript.r/js-self-invoking-anon-func.d/args.ctags @@ -0,0 +1 @@ +--sort=no diff --git a/Units/parser-javascript.r/js-self-invoking-anon-func.d/expected.ctags b/Units/parser-javascript.r/js-self-invoking-anon-func.d/expected.ctags new file mode 100644 index 0000000000..a5bf2f6fe2 --- /dev/null +++ b/Units/parser-javascript.r/js-self-invoking-anon-func.d/expected.ctags @@ -0,0 +1,10 @@ +anonymousFunction204aa80e0100 input.js /^(function(x) {$/;" f +a input.js /^ var a = function (o) { return o; };$/;" f function:anonymousFunction204aa80e0100 +anonymousFunction204aa80e0200 input.js /^(function(y) {$/;" f +b input.js /^ const b = function (p) { return p; };$/;" f function:anonymousFunction204aa80e0200 +anonymousFunction204aa80e0300 input.js /^!function(z) {$/;" f +c input.js /^ const c = function (r) { return r; };$/;" f function:anonymousFunction204aa80e0300 +anonymousFunction204aa80e0400 input.js /^console.log("a" + (function (A) {$/;" f +anonymousFunction204aa80e0500 input.js /^}((function (B) {$/;" f +anonymousFunction204aa80e0600 input.js /^}(!function(C) {$/;" f +f input.js /^ var f = function (t) {$/;" f function:anonymousFunction204aa80e0600 diff --git a/Units/parser-javascript.r/js-self-invoking-anon-func.d/input.js b/Units/parser-javascript.r/js-self-invoking-anon-func.d/input.js new file mode 100644 index 0000000000..d8ebac59af --- /dev/null +++ b/Units/parser-javascript.r/js-self-invoking-anon-func.d/input.js @@ -0,0 +1,26 @@ +(function(x) { + var a = function (o) { return o; }; + return x + a (1); +})(1); + +(function(y) { + const b = function (p) { return p; }; + return y - b (1); +}(1)); + +!function(z) { + const c = function (r) { return r; }; + return z * c (1); +}(1); + +console.log("a" + (function (A) { + return A; +}((function (B) { + return B; +}(!function(C) { + var f = function (t) { + return !t; + } + return f(C); +}(true) + ))))); diff --git a/parsers/jscript.c b/parsers/jscript.c index d5e6c2aa88..c56715bf2d 100644 --- a/parsers/jscript.c +++ b/parsers/jscript.c @@ -2357,6 +2357,8 @@ static bool parseStatement (tokenInfo *const token, bool is_inside_class) { if (isType (token, TOKEN_OPEN_CURLY)) parseBlock (token, CORK_NIL); + else if (isKeyword (token, KEYWORD_function)) + parseFunction (token); /* Potentially the name of the function */ if (isType (token, TOKEN_PERIOD))