@@ -1737,9 +1737,6 @@ object Parsers {
1737
1737
})
1738
1738
else t
1739
1739
1740
- /** The block in a quote or splice */
1741
- def stagedBlock () = inBraces(block(simplify = true ))
1742
-
1743
1740
/** TypeBlock ::= {TypeBlockStat semi} Type
1744
1741
*/
1745
1742
def typeBlock (): Tree =
@@ -1752,7 +1749,7 @@ object Parsers {
1752
1749
while in.token == TYPE do tdefs += typeBlockStat()
1753
1750
tdefs.toList
1754
1751
1755
- /** TypeBlockStat ::= ‘type’ {nl} TypeDcl
1752
+ /** TypeBlockStat ::= ‘type’ {nl} TypeDcl
1756
1753
*/
1757
1754
def typeBlockStat (): Tree =
1758
1755
val mods = defAnnotsMods(BitSet ())
@@ -1761,6 +1758,20 @@ object Parsers {
1761
1758
if in.isNewLine then in.nextToken()
1762
1759
tdef
1763
1760
1761
+ /** Quoted ::= ‘'’ ‘{’ Block ‘}’
1762
+ * | ‘'’ ‘[’ Type ‘]’
1763
+ * | ‘'’ ‘[’ TypeBlock ‘]’
1764
+ */
1765
+ def quote (inPattern : Boolean ): Tree =
1766
+ atSpan(in.skipToken()) {
1767
+ withinStaged(StageKind .Quoted | (if (inPattern) StageKind .QuotedPattern else 0 )) {
1768
+ val body =
1769
+ if (in.token == LBRACKET ) inBrackets(typeBlock())
1770
+ else inBraces(block(simplify = true ))
1771
+ Quote (body, Nil )
1772
+ }
1773
+ }
1774
+
1764
1775
/** ExprSplice ::= ‘$’ spliceId -- if inside quoted block
1765
1776
* | ‘$’ ‘{’ Block ‘}’ -- unless inside quoted pattern
1766
1777
* | ‘$’ ‘{’ Pattern ‘}’ -- when inside quoted pattern
@@ -1775,7 +1786,7 @@ object Parsers {
1775
1786
if (in.name.length == 1 ) {
1776
1787
in.nextToken()
1777
1788
val inPattern = (staged & StageKind .QuotedPattern ) != 0
1778
- withinStaged(StageKind .Spliced )(if (inPattern) inBraces( pattern()) else stagedBlock( ))
1789
+ withinStaged(StageKind .Spliced )(inBraces( if (inPattern) pattern() else block(simplify = true ) ))
1779
1790
}
1780
1791
else atSpan(in.offset + 1 ) {
1781
1792
val id = Ident (in.name.drop(1 ))
@@ -2496,14 +2507,7 @@ object Parsers {
2496
2507
canApply = false
2497
2508
blockExpr()
2498
2509
case QUOTE =>
2499
- atSpan(in.skipToken()) {
2500
- withinStaged(StageKind .Quoted | (if (location.inPattern) StageKind .QuotedPattern else 0 )) {
2501
- val body =
2502
- if (in.token == LBRACKET ) inBrackets(typeBlock())
2503
- else stagedBlock()
2504
- Quote (body, Nil )
2505
- }
2506
- }
2510
+ quote(location.inPattern)
2507
2511
case NEW =>
2508
2512
canApply = false
2509
2513
newExpr()
0 commit comments