Skip to content

Fix and formalize newline and semicolon behavior in methodmaps. (bug 6175)#88

Merged
dvander merged 2 commits intomasterfrom
bug-6175
Jul 13, 2014
Merged

Fix and formalize newline and semicolon behavior in methodmaps. (bug 6175)#88
dvander merged 2 commits intomasterfrom
bug-6175

Conversation

@dvander
Copy link
Member

@dvander dvander commented Jul 12, 2014

This patch formalizes line endings a bit for methodmaps. The new rules are:

  • The body of a methodmap or class may end in a semicolon.
  • Native declarations in a methodmap or class may end in a semicolon.
  • "Assignment" declarations in a methodmap may end in a semicolon.
  • Function and property bodies may not end in a semicolon.
  • All declarations in a methodmap or class, including the body itself, must end in a newline. If a semicolon is present, the semicolon must be on the same line as both the newline and the terminating token.

The way this is implemented is via a new peek_same_line construct in the lexer. This will return either end-of-line, or a token ID that is not on the same line. The lexer now attaches line/col information into token data to make this work.

I am gunning to remove #pragma semicolon in a future version of SourcePawn, and to revise official style to dissuade them. If we can get there, this patch will be mostly pointless, but for now I've tried to match what other Pawn constructs do. Getting the correct newline behavior at least is a step forward.

@dvander
Copy link
Member Author

dvander commented Jul 12, 2014

Rational behind semicolon removal: they don't do much except make C/C++ programmers feel at home. There's nothing real bad about that and the behavior in this patch should match what would be natural in a C++ environment. But pragma semicolon itself forces this particular style in ways that prevent code sharing, and it strikes me that it does more nonsense than good.

Dissuading them in official style is sort of predicated on an SP-aware lint tool though, which does not exist yet.

@TheDS
Copy link
Member

TheDS commented Jul 13, 2014

🚢

dvander added a commit that referenced this pull request Jul 13, 2014
Fix and formalize newline and semicolon behavior in methodmaps. (bug 6175)
@dvander dvander merged commit cd6997c into master Jul 13, 2014
@asherkin asherkin deleted the bug-6175 branch July 13, 2014 18:17
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.

2 participants