Skip to content

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Sep 27, 2014

Issue 13538 - Divide old C style syntax from D style grammar rule
Issue 13539 - Disallow optional template parameters with C-style syntax

@quickfur
Copy link
Member

Excellent idea!

@ghost ghost changed the title Issue 13538 & 13539 - Improve variable declaration grammar for old C style synatx Issue 13538 & 13539 - Improve variable declaration grammar for old C style syntax Sep 30, 2014
@9rnsr
Copy link
Contributor Author

9rnsr commented Oct 1, 2014

@Hackerpilot How do you think about this separation?

@Hackerpilot
Copy link
Contributor

This still allows int *a, *b; for D-style declarations, unless I misread it.

@9rnsr
Copy link
Contributor Author

9rnsr commented Oct 2, 2014

Right. This PR still accepts any C-style syntax, but after the change we can easily say "All AltXXX rules are now deprecated to recommend proper D style syntax." It's far better than current confusing grmmar rules.

@Hackerpilot
Copy link
Contributor

VarDeclarator still allows BasicType2, so removing the Alt rules will still allow int *a, *b;.

@9rnsr
Copy link
Contributor Author

9rnsr commented Oct 2, 2014

VarDeclarator still allows BasicType2, so removing the Alt rules will still allow int *a, *b;.

The BasicType2 in VarDeclarator rule only consumes the first ** before a. The remain part *b is consumed by DeclaratorIdentifierList, but surprisingly, current grammar does not accept the token * before b.

To recognize all C-style declarations in grammar rule, I added AltDeclaratorIdentifier in the last commit.

@9rnsr
Copy link
Contributor Author

9rnsr commented Oct 9, 2014

@Hackerpilot Do you have a time re-review this PR?

@WalterBright You're going to make all C-style declarations errors. This PR will help it from grammar side.

@Hackerpilot
Copy link
Contributor

It looks good to me.

MartinNowak added a commit that referenced this pull request Oct 12, 2014
Issue 13538 & 13539 - Improve variable declaration grammar for old C style syntax
@MartinNowak MartinNowak merged commit 3b11015 into dlang:master Oct 12, 2014
@9rnsr
Copy link
Contributor Author

9rnsr commented Oct 13, 2014

Thanks!

@9rnsr 9rnsr deleted the fix_declaration branch November 2, 2014 03:06
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.

4 participants