From 7e5aaa2c6c9bec226e51bcce2e0364ea3fd6a01d Mon Sep 17 00:00:00 2001 From: WebFreak001 Date: Mon, 7 Feb 2022 20:02:45 +0100 Subject: [PATCH] upgrade to libdparse 0.19.0 --- dub.json | 2 +- src/dsymbol/conversion/package.d | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/dub.json b/dub.json index 2698d24..c54fd56 100644 --- a/dub.json +++ b/dub.json @@ -6,7 +6,7 @@ "targetPath": "build", "targetType": "library", "dependencies": { - "libdparse": ">=0.14.0 <0.19.0", + "libdparse": ">=0.19.0 <0.20.0", "emsi_containers": "~>0.8.0", "stdx-allocator": "~>2.77.5" } diff --git a/src/dsymbol/conversion/package.d b/src/dsymbol/conversion/package.d index a1fbddc..47a905f 100644 --- a/src/dsymbol/conversion/package.d +++ b/src/dsymbol/conversion/package.d @@ -148,7 +148,9 @@ class SimpleParser : Parser { // Unlike many of the other parsing functions, it is valid and expected // for this one to return `null` on valid code. Returning `null` in - // this function means that we are looking at a SpecifiedFunctionBody. + // this function means that we are looking at a SpecifiedFunctionBody + // or ShortenedFunctionBody. + // // The super-class will handle re-trying with the correct parsing // function. @@ -177,6 +179,24 @@ class SimpleParser : Parser return allocator.make!SpecifiedFunctionBody; } + override ShortenedFunctionBody parseShortenedFunctionBody() + { + skipContracts(); + if (currentIs(tok!"=>")) + { + while (!currentIs(tok!";") && moreTokens) + { + if (currentIs(tok!"{")) // potential function literal + skipBraces(); + else + advance(); + } + if (moreTokens) + advance(); + } + return allocator.make!ShortenedFunctionBody; + } + /** * Skip contracts, and return `true` if the type of contract used requires * that the next token is `do`.