Terminating Tokens
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.
Posted by munificent on Oct 31, 2018, 7:22 PM
Tags
Related issues
Raise real-world problems, find people facing the same issue, and discuss solutions.4,000 issues0 comments
github (Marketing)
Proposal: Set `debugShowCheckedModeBanner` Default to false
Angular Layout Migration Guides
sitemap.xml
Let’s Define CSS 4
Improve the indexability (SEO) of Flutter apps on the web
ALL twitch.tv issues
Terminating Tokens
Suggestion: Type annotations and interfaces for function declarations
Terminating Tokens
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.
Comments (0)
No comments yet. Start the discussion.