dart-lang / dart-lang/language

Terminating Tokens

Open
#72 51 comments 278 reactions 1 assignee Claimed by @munificent View on GitHub
feature state-backlog
Dominant language
TeX
Stars
2.9k
Forks
239
Avg merge
2d 18h
Merged PRs (30d)
14

Description

This is a proposed solution #69, optional semicolons.

I'm calling it "terminating tokens" to differentiate it from other semicolon insertion rules we might investigate. In this proposal, the rules are roughly:

* A "terminating token" is a token with a newline between it and the previous token.

* In places where a semicolon is currently allowed, if the next token is a terminating token, no semicolon is required.

* This leads to ambiguity since the existing grammar rules ignore whether or not a token is terminating. To resolve this, the grammar is changed so that a newline *cannot* be ignored in each place where that leads to a known ambiguity.

The "known ambiguity" part means that newlines are *only* used to act as implicit semicolons or to resolve ambiguities. A newline won't *cause* a syntax error on the next line. This lets us ignore most newlines, which minimizes the amount of migration and breakage.

On the other hand, the rules are fairly complex and subtle. We may not catch all of the ambiguities, and it may make it harder to introduce syntax in the future because it might cause a new ambiguity.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.