You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/_docs/internals/syntax.md
+25-10Lines changed: 25 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,20 @@ layout: doc-page
3
3
title: "Scala 3 Syntax Summary"
4
4
---
5
5
6
+
<!--
7
+
8
+
This page has a companion page at _docs/reference/syntax.md.
9
+
10
+
!! Make sure to edit both pages in sync. !!
11
+
12
+
reference/syntax.md shows the official Scala 3 syntax, without deprecated or experimental features.
13
+
14
+
internals/syntax.md shows the Scala 3 syntax as supported by the parser, including
15
+
deprecated and experimental features. It also gives some indications how
16
+
productions map to AST nodes.
17
+
18
+
-->
19
+
6
20
The following description of Scala tokens uses literal characters `‘c’` when
7
21
referring to the ASCII fragment `\u0000` – `\u007F`.
8
22
@@ -88,7 +102,6 @@ nl ::= “new line character”
88
102
semi ::= ‘;’ | nl {nl}
89
103
```
90
104
91
-
92
105
## Optional Braces
93
106
94
107
The lexical analyzer also inserts `indent` and `outdent` tokens that represent regions of indented code [at certain points](../reference/other-new-features/indentation.md)
@@ -127,7 +140,7 @@ type val var while with yield
127
140
### Soft keywords
128
141
129
142
```
130
-
as derives end extension infix inline opaque open transparent using | * + -
143
+
as derives end extension infix inline opaque open throws transparent using | * + -
131
144
```
132
145
133
146
See the [separate section on soft keywords](../reference/soft-modifier.md) for additional
@@ -95,13 +110,17 @@ The lexical analyzer also inserts `indent` and `outdent` tokens that represent r
95
110
In the context-free productions below we use the notation `<<< ts >>>`
96
111
to indicate a token sequence `ts` that is either enclosed in a pair of braces `{ ts }` or that constitutes an indented region `indent ts outdent`. Analogously, the
97
112
notation `:<<< ts >>>` indicates a token sequence `ts` that is either enclosed in a pair of braces `{ ts }` or that constitutes an indented region `indent ts outdent` that follows
98
-
a `:` at the end of a line.
113
+
a `colon` token.
114
+
115
+
A `colon` token reads as the standard colon "`:`" but is generated instead of it where `colon` is legal according to the context free syntax, but only if the previous token
116
+
is an alphanumeric identifier, a backticked identifier, or one of the tokens `this`, `super`, `new`, "`)`", and "`]`".
99
117
100
118
```
119
+
colon ::= ':' -- with side conditions explained above
101
120
<<< ts >>> ::= ‘{’ ts ‘}’
102
121
| indent ts outdent
103
122
:<<< ts >>> ::= [nl] ‘{’ ts ‘}’
104
-
| `:` indent ts outdent
123
+
| colon indent ts outdent
105
124
```
106
125
107
126
## Keywords
@@ -115,15 +134,14 @@ given if implicit import lazy match new
0 commit comments