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

Fix grammar around function declaration #660

Merged
merged 6 commits into from Sep 24, 2014
Merged

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Sep 23, 2014

Issue 10235 - Grammar does not contain a rule for function declarations
Issue 12579 - DMD rejects valid function literal
Issue 13523 - Auto function declaration does not match any grammar rule

And I moved function-related grammars, Parameters, FunctionAttribute, MemberFunctionAttribute, etc into the function.html page.

FuncDeclarator is a dup of Declarator, and FuncDeclaratorSuffix is a dup of DeclaratorSuffix

And we need to keep function type aliasing with the old style syntax.
Remove FuncDeclaratorSuffixes to disallow zero, two or more parameter lists

And disallow mixing C-style suffix in function declaration, as follows:

  void foo[](int a);
…ations

Move FuncDeclaration and related non terminal symbols into function.dd

Conflicts:
	declaration.dd
	grammar.dd
@9rnsr
Copy link
Contributor Author

9rnsr commented Sep 23, 2014

@Hackerpilot Could you review this change?


$(GNAME DefaultInitializerExpression):
$(ASSIGNEXPRESSION)
$(GLINK2 traits, SpecialKeyword)
Copy link
Member

Choose a reason for hiding this comment

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

SpecialKeyword is already present in the PrimaryExpression rule. I think we can remove this and let the AssignExpression rule handle special keywords.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, seems correct. I'll file the issue in bugizlla, then open a new PR to fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Hackerpilot
Copy link
Member

This change looks good (ignoring the DefaultInitializerExpression issue).

@9rnsr
Copy link
Contributor Author

9rnsr commented Sep 24, 2014

@Hackerpilot Thanks for your review.
@WalterBright Please merge this cleanup.

@9rnsr
Copy link
Contributor Author

9rnsr commented Sep 24, 2014

I'll merge this PR so this is just a cleanup.

9rnsr added a commit that referenced this pull request Sep 24, 2014
Fix grammar around function declaration
@9rnsr 9rnsr merged commit eb5700c into dlang:master Sep 24, 2014
@9rnsr 9rnsr deleted the fix_function branch September 24, 2014 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants