@@ -1732,9 +1732,6 @@ object Parsers {
1732
1732
})
1733
1733
else t
1734
1734
1735
- /** The block in a quote or splice */
1736
- def stagedBlock () = inBraces(block(simplify = true ))
1737
-
1738
1735
/** TypeBlock ::= {TypeBlockStat semi} Type
1739
1736
*/
1740
1737
def typeBlock (): Tree =
@@ -1747,7 +1744,7 @@ object Parsers {
1747
1744
while in.token == TYPE do tdefs += typeBlockStat()
1748
1745
tdefs.toList
1749
1746
1750
- /** TypeBlockStat ::= ‘type’ {nl} TypeDcl
1747
+ /** TypeBlockStat ::= ‘type’ {nl} TypeDcl
1751
1748
*/
1752
1749
def typeBlockStat (): Tree =
1753
1750
val mods = defAnnotsMods(BitSet ())
@@ -1756,6 +1753,20 @@ object Parsers {
1756
1753
if in.isNewLine then in.nextToken()
1757
1754
tdef
1758
1755
1756
+ /** Quoted ::= ‘'’ ‘{’ Block ‘}’
1757
+ * | ‘'’ ‘[’ Type ‘]’
1758
+ * | ‘'’ ‘[’ TypeBlock ‘]’
1759
+ */
1760
+ def quote (inPattern : Boolean ): Tree =
1761
+ atSpan(in.skipToken()) {
1762
+ withinStaged(StageKind .Quoted | (if (inPattern) StageKind .QuotedPattern else 0 )) {
1763
+ val body =
1764
+ if (in.token == LBRACKET ) inBrackets(typeBlock())
1765
+ else inBraces(block(simplify = true ))
1766
+ Quote (body)
1767
+ }
1768
+ }
1769
+
1759
1770
/** ExprSplice ::= ‘$’ spliceId -- if inside quoted block
1760
1771
* | ‘$’ ‘{’ Block ‘}’ -- unless inside quoted pattern
1761
1772
* | ‘$’ ‘{’ Pattern ‘}’ -- when inside quoted pattern
@@ -1770,7 +1781,7 @@ object Parsers {
1770
1781
if (in.name.length == 1 ) {
1771
1782
in.nextToken()
1772
1783
val inPattern = (staged & StageKind .QuotedPattern ) != 0
1773
- withinStaged(StageKind .Spliced )(if (inPattern) inBraces( pattern()) else stagedBlock( ))
1784
+ withinStaged(StageKind .Spliced )(inBraces( if (inPattern) pattern() else block(simplify = true ) ))
1774
1785
}
1775
1786
else atSpan(in.offset + 1 ) {
1776
1787
val id = Ident (in.name.drop(1 ))
@@ -2514,14 +2525,7 @@ object Parsers {
2514
2525
canApply = false
2515
2526
blockExpr()
2516
2527
case QUOTE =>
2517
- atSpan(in.skipToken()) {
2518
- withinStaged(StageKind .Quoted | (if (location.inPattern) StageKind .QuotedPattern else 0 )) {
2519
- val body =
2520
- if (in.token == LBRACKET ) inBrackets(typeBlock())
2521
- else stagedBlock()
2522
- Quote (body)
2523
- }
2524
- }
2528
+ quote(location.inPattern)
2525
2529
case NEW =>
2526
2530
canApply = false
2527
2531
newExpr()
0 commit comments