Skip to content

Commit ed4d759

Browse files
committed
Update syntax.md
1 parent b960949 commit ed4d759

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,12 +1572,12 @@ object Parsers {
15721572
/** The block in a quote or splice */
15731573
def stagedBlock() = inBraces(block(simplify = true))
15741574

1575-
/** Splice ::= ‘$’ id if inside quoted block
1576-
* | ‘$’ ‘{’ Block ‘}’ unless inside quoted pattern
1577-
* | ‘$’ ‘{’ Pattern ‘}’ when inside quoted pattern
1578-
* | ‘$’ id if inside quoted type // Deprecated syntax
1579-
* | ‘$’ ‘{’ Block ‘}’ unless inside quoted type pattern // Deprecated syntax
1580-
* | ‘$’ ‘{’ Pattern ‘}’ when inside quoted type pattern // Deprecated syntax
1575+
/** ExprSplice ::= ‘$’ spliceId -- if inside quoted block
1576+
* | ‘$’ ‘{’ Block ‘}’ -- unless inside quoted pattern
1577+
* | ‘$’ ‘{’ Pattern ‘}’ -- when inside quoted pattern
1578+
* TypeSplice ::= ‘$’ spliceId -- if inside quoted type
1579+
* | ‘$’ ‘{’ Block ‘}’ -- unless inside quoted type pattern
1580+
* | ‘$’ ‘{’ Pattern ‘}’ -- when inside quoted type pattern
15811581
*/
15821582
def splice(isType: Boolean): Tree =
15831583
val start = in.offset
@@ -1646,7 +1646,7 @@ object Parsers {
16461646
* | Singleton `.' type
16471647
* | ‘(’ ArgTypes ‘)’
16481648
* | Refinement
1649-
* | Splice
1649+
* | TypeSplice -- deprecated syntax (since 3.0.0)
16501650
* | SimpleType1 TypeArgs
16511651
* | SimpleType1 `#' id
16521652
*/
@@ -2248,7 +2248,7 @@ object Parsers {
22482248
/** SimpleExpr ::= ‘new’ ConstrApp {`with` ConstrApp} [TemplateBody]
22492249
* | ‘new’ TemplateBody
22502250
* | BlockExpr
2251-
* | Splice
2251+
* | ExprSplice
22522252
* | Quoted
22532253
* | quoteId
22542254
* | SimpleExpr1 [`_`]

docs/_docs/internals/syntax.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ upper ::= ‘A’ | … | ‘Z’ | ‘\$’ | ‘_’ “… and U
2727
lower ::= ‘a’ | … | ‘z’ “… and Unicode category Ll” ;
2828
letter ::= upper | lower “… and Unicode categories Lo, Lt, Lm, Nl” ;
2929
digit ::= ‘0’ | … | ‘9’ ;
30-
paren ::= ‘(’ | ‘)’ | ‘[’ | ‘]’ | ‘{’ | ‘}’ | ‘'(’ | ‘'[’ | ‘'{’ ;
30+
paren ::= ‘(’ | ‘)’ | ‘[’ | ‘]’ | ‘{’ | ‘}’ | ‘'(’ ;
3131
delim ::= ‘`’ | ‘'’ | ‘"’ | ‘.’ | ‘;’ | ‘,’ ;
3232
opchar ::= ‘!’ | ‘#’ | ‘%’ | ‘&’ | ‘*’ | ‘+’ | ‘-’ | ‘/’ | ‘:’ |
3333
‘<’ | ‘=’ | ‘>’ | ‘?’ | ‘@’ | ‘\’ | ‘^’ | ‘|’ | ‘~’
@@ -45,6 +45,7 @@ id ::= plainid
4545
| ‘`’ { charNoBackQuoteOrNewline | UnicodeEscape | charEscapeSeq } ‘`’ ;
4646
idrest ::= {letter | digit} [‘_’ op] ;
4747
quoteId ::= ‘'’ alphaid ;
48+
spliceId ::= ‘'’ alphaid ;
4849
4950
integerLiteral ::= (decimalNumeral | hexNumeral) [‘L’ | ‘l’] ;
5051
decimalNumeral ::= ‘0’ | nonZeroDigit [{digit | ‘_’} digit] ;
@@ -183,8 +184,7 @@ SimpleType1 ::= id
183184
| Singleton ‘.’ ‘type’ SingletonTypeTree(p)
184185
| ‘(’ Types ‘)’ Tuple(ts)
185186
| Refinement RefinedTypeTree(EmptyTree, refinement)
186-
| ‘$’ ‘{’ Block ‘}’ -- unless inside quoted pattern
187-
| ‘$’ ‘{’ Pattern ‘}’ -- only inside quoted pattern
187+
| TypeSplice -- deprecated syntax
188188
| SimpleType1 TypeArgs AppliedTypeTree(t, args)
189189
| SimpleType1 ‘#’ id Select(t, name) ;
190190
Singleton ::= SimpleRef
@@ -243,8 +243,7 @@ SimpleExpr ::= SimpleRef
243243
| Literal
244244
| ‘_’
245245
| BlockExpr
246-
| ‘$’ ‘{’ Block ‘}’ -- unless inside quoted pattern
247-
| ‘$’ ‘{’ Pattern ‘}’ -- only inside quoted pattern
246+
| ExprSplice
248247
| Quoted
249248
| quoteId -- only inside splices
250249
| ‘new’ ConstrApp {‘with’ ConstrApp} [TemplateBody] New(constr | templ)
@@ -261,6 +260,12 @@ SimpleExpr ::= SimpleRef
261260
IndentedExpr ::= indent CaseClauses | Block outdent ;
262261
Quoted ::= ‘'’ ‘{’ Block ‘}’
263262
| ‘'’ ‘[’ Type ‘]’ ;
263+
ExprSplice ::= spliceId -- if inside quoted block
264+
| ‘$’ ‘{’ Block ‘}’ -- unless inside quoted pattern
265+
| ‘$’ ‘{’ Pattern ‘}’ -- when inside quoted pattern
266+
TypeSplice ::= spliceId -- if inside quoted type -- deprecated syntax
267+
| ‘$’ ‘{’ Block ‘}’ -- unless inside quoted type pattern -- deprecated syntax
268+
| ‘$’ ‘{’ Pattern ‘}’ -- when inside quoted type pattern -- deprecated syntax
264269
ExprsInParens ::= ExprInParens {‘,’ ExprInParens} ;
265270
ExprInParens ::= PostfixExpr ‘:’ Type -- normal Expr allows only RefinedType here ;
266271
| Expr

0 commit comments

Comments
 (0)