Skip to content

Commit e20a2cd

Browse files
authored
Merge pull request #2038 from xushiwei/q
mini spec: Semicolons
2 parents 399ca61 + 7cd282c commit e20a2cd

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

doc/spec-mini.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,21 @@ A _general comment_ containing no newlines acts like a space. Any other comment
8686

8787
Tokens form the vocabulary of the Go+ language. There are four classes: _identifiers_, _keywords_, _operators_ and _punctuation_, and _literals_. White space, formed from spaces (U+0020), horizontal tabs (U+0009), carriage returns (U+000D), and newlines (U+000A), is ignored except as it separates tokens that would otherwise combine into a single token. Also, a newline or end of file may trigger the insertion of a [semicolon](). While breaking the input into tokens, the next token is the longest sequence of characters that form a valid token.
8888

89-
9089
### Semicolons
9190

91+
The formal syntax uses semicolons ";" as terminators in a number of productions. Go+ programs may omit most of these semicolons using the following two rules:
92+
93+
* When the input is broken into tokens, a semicolon is automatically inserted into the token stream immediately after a line's final token if that token is
94+
* an [identifier](#identifiers)
95+
* an [integer](), [floating-point](), [imaginary](), [rune](), or [string]() literal
96+
* one of the [keywords]() `break`, `continue`, `fallthrough`, or `return`
97+
* one of the [operators and punctuation]() `++`, `--`, `)`, `]`, or `}`
98+
* To allow complex statements to occupy a single line, a semicolon may be omitted before a closing `")"` or `"}"`.
99+
100+
To reflect idiomatic use, code examples in this document elide semicolons using these rules.
101+
102+
### Identifiers
103+
92104
TODO
93105

94106
### Integer literals

0 commit comments

Comments
 (0)