Skip to content

Update extern(C++) grammar to support string namespaces#2716

Merged
Geod24 merged 2 commits intodlang:masterfrom
rmanthorpe:extern-cpp
Jun 17, 2020
Merged

Update extern(C++) grammar to support string namespaces#2716
Geod24 merged 2 commits intodlang:masterfrom
rmanthorpe:extern-cpp

Conversation

@rmanthorpe
Copy link
Copy Markdown
Contributor

The grammar is missing the string-style extern(C++, "a", "b") declaration. The ArgumentList isn't quite right here as it allows a trailing comma but the current implementation in dmd does not. However, this seems more like a bug in dmd since it's inconsistent with the rest of the grammar.

@dlang-bot
Copy link
Copy Markdown
Contributor

Thanks for your pull request and interest in making D better, @rmanthorpe! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

$(GNAME LinkageAttribute):
$(D extern) $(D $(LPAREN)) $(GLINK LinkageType) $(D $(RPAREN))
$(D extern) $(D $(LPAREN)) $(D C++), $(GLINK2 declaration, IdentifierList) $(D $(RPAREN))
$(D extern) $(D $(LPAREN)) $(D C++), $(GLINK2 declaration, ArgumentList) $(D $(RPAREN))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may need to introduce a new rule here. The parser looks for a comma-separated list of conditional expressions, while ArgumentList is a comma-separated list of AssignExpression.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced. As it is it seems to happily parse an AssignExpression. For example extern(C++, (a = "b")) int c(); parses fine, just like the identifier with an assign index works fine: extern(C++, (d[e = f])) int g();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, extern(C++, (a = "b")) int c(); parses, but extern(C++, a = "b") int c(); does not, which is my point. Putting the assign expression inside the parenthesis makes it match the rule for PrimaryExpression, which causes it to match the rule for ConditionalExpression.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah you're quite right - this is not my forte. In that case, is the identifier list grammar wrong too? extern(C++, d[e = f]) int g(); does not parse.

@rmanthorpe
Copy link
Copy Markdown
Contributor Author

@Hackerpilot does that look better now?

@Hackerpilot
Copy link
Copy Markdown
Contributor

I was going to suggest re-ordering things to make the rule left-recursive, but looking over the grammar I can see that the existing style is that rules are right-recursive. My only suggestion is to remove the redundant NamespaceExpression rule and use ConditionalExpression directly.

@rmanthorpe
Copy link
Copy Markdown
Contributor Author

Yes everything is right-recursive so I stuck with the same style. I've removed that redundant expression now.

@rmanthorpe
Copy link
Copy Markdown
Contributor Author

Bump @Hackerpilot

@Hackerpilot
Copy link
Copy Markdown
Contributor

I don't have the ability to merge this.

@PetarKirov
Copy link
Copy Markdown
Member

I can merge, but we need to figure out why the build fails first. I will force push, in order to restart it (assuming it was simply a transient failure).

@rmanthorpe
Copy link
Copy Markdown
Contributor Author

I rebased it just to see if that would help but now it's failing circleci too 🤦‍♂ I really have no idea why this would be. Any thoughts?

MoonlightSentinel added a commit to MoonlightSentinel/libdparse that referenced this pull request Apr 30, 2020
Implemented according to the grammar defined in the pending spec PR
dlang/dlang.org#2716
MoonlightSentinel added a commit to MoonlightSentinel/libdparse that referenced this pull request Apr 30, 2020
Implemented according to the grammar defined in the pending spec PR
dlang/dlang.org#2716
MoonlightSentinel added a commit to MoonlightSentinel/libdparse that referenced this pull request Apr 30, 2020
Implemented according to the grammar defined in the pending spec PR
dlang/dlang.org#2716
MoonlightSentinel added a commit to MoonlightSentinel/libdparse that referenced this pull request Apr 30, 2020
Implemented according to the grammar defined in the pending spec PR
dlang/dlang.org#2716
@Geod24
Copy link
Copy Markdown
Member

Geod24 commented May 1, 2020

Rebased, squashed the commit, and (hopefully) fixed.

I really have no idea why this would be. Any thoughts?

I'm no DDOC expert but I haven't seen any other place in that page where $(D ,) is used. Since it's also used for macro arguments, that might be the source of the error, so I've removed the surrounding $(D ,)

@Geod24 Geod24 force-pushed the extern-cpp branch 2 times, most recently from ee9939b to 4e43384 Compare May 1, 2020 07:11
MoonlightSentinel added a commit to MoonlightSentinel/libdparse that referenced this pull request May 1, 2020
Implemented according to the grammar defined in the pending spec PR
dlang/dlang.org#2716
MoonlightSentinel added a commit to MoonlightSentinel/libdparse that referenced this pull request May 1, 2020
Implemented according to the grammar defined in the pending spec PR
dlang/dlang.org#2716
MoonlightSentinel added a commit to MoonlightSentinel/libdparse that referenced this pull request May 1, 2020
Implemented according to the grammar defined in the pending spec PR
dlang/dlang.org#2716
MoonlightSentinel added a commit to MoonlightSentinel/libdparse that referenced this pull request May 1, 2020
Implemented according to the grammar defined in the pending spec PR
dlang/dlang.org#2716
MoonlightSentinel added a commit to MoonlightSentinel/libdparse that referenced this pull request May 1, 2020
Implemented according to the grammar defined in the pending spec PR
dlang/dlang.org#2716
@rmanthorpe
Copy link
Copy Markdown
Contributor Author

Rebased, squashed the commit, and (hopefully) fixed.

Thanks I'm totally stumped by this!

@Geod24
Copy link
Copy Markdown
Member

Geod24 commented May 1, 2020

Thanks I'm totally stumped by this!

Well, me too. I found two errors, but it's still red. I'm not 100% sure the $(D ,) would lead to error, but what I found was that GLINK and GLINK2 were inverted. GLINK is for links within the page. Since ConditionalExpression is in expression.dd and not attribute.dd, $(GLINK2 expression, ConditonalExpression) was needed. Additionally, $(GLINK2) was used to link to declaration's NamespaceList, however NamespaceList is in attribute, not declaration, so we should use GLINK instead.

Now, even with that fixed, it is still red, and I have no clue why. I'm on Mac so I can't build ATM, going to give it another try later.

@Geod24 Geod24 force-pushed the extern-cpp branch 4 times, most recently from 8abce37 to b853298 Compare May 2, 2020 07:24
@Geod24
Copy link
Copy Markdown
Member

Geod24 commented May 2, 2020

Yeah, I have absolutely no clue what is wrong. There is so much pre-processing going on that linking the error message with the input is near impossible. I tried a few things, including removing all links, and reducing this until it passes. It did pass when the $(GNAME NamespaceList): and following was removed, but I really can't see anything wrong with it.

@CyberShadow : Would it be possible to have artifacts of failing build be published ? I have no clue what was fed to the LaTeX compiler.

@CyberShadow
Copy link
Copy Markdown
Member

Thanks for looking into this.

@CyberShadow : Would it be possible to have artifacts of failing build be published ? I have no clue what was fed to the LaTeX compiler.

It does do that if the test phase fails, but this is a build problem, and I think the latex input is a temporary file (not part of the output) so it wouldn't be accessible anyway.

The software running the build is based on Digger, so you should be able to reproduce build problems locally by running digger build --with=website master+dlang.org#2716 (you may need to install some packages first).

@Geod24
Copy link
Copy Markdown
Member

Geod24 commented Jun 16, 2020

Rebased on master, let's see if it is finally green

Co-authored-by: Florian <moonlightsentinel@disroot.org>
@Geod24 Geod24 merged commit 9c3e74d into dlang:master Jun 17, 2020
@Geod24
Copy link
Copy Markdown
Member

Geod24 commented Jun 17, 2020

Finally! Thanks a lot @rmanthorpe and @MoonlightSentinel . So glad we got rid of that PDF export...

@rmanthorpe rmanthorpe deleted the extern-cpp branch June 17, 2020 04:49
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

Successfully merging this pull request may close these issues.

7 participants