@@ -1732,9 +1732,6 @@ object Parsers {
17321732 })
17331733 else t
17341734
1735- /** The block in a quote or splice */
1736- def stagedBlock () = inBraces(block(simplify = true ))
1737-
17381735 /** TypeBlock ::= {TypeBlockStat semi} Type
17391736 */
17401737 def typeBlock (): Tree =
@@ -1747,7 +1744,7 @@ object Parsers {
17471744 while in.token == TYPE do tdefs += typeBlockStat()
17481745 tdefs.toList
17491746
1750- /** TypeBlockStat ::= ‘type’ {nl} TypeDcl
1747+ /** TypeBlockStat ::= ‘type’ {nl} TypeDcl
17511748 */
17521749 def typeBlockStat (): Tree =
17531750 val mods = defAnnotsMods(BitSet ())
@@ -1756,6 +1753,20 @@ object Parsers {
17561753 if in.isNewLine then in.nextToken()
17571754 tdef
17581755
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+
17591770 /** ExprSplice ::= ‘$’ spliceId -- if inside quoted block
17601771 * | ‘$’ ‘{’ Block ‘}’ -- unless inside quoted pattern
17611772 * | ‘$’ ‘{’ Pattern ‘}’ -- when inside quoted pattern
@@ -1770,7 +1781,7 @@ object Parsers {
17701781 if (in.name.length == 1 ) {
17711782 in.nextToken()
17721783 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 ) ))
17741785 }
17751786 else atSpan(in.offset + 1 ) {
17761787 val id = Ident (in.name.drop(1 ))
@@ -2514,14 +2525,7 @@ object Parsers {
25142525 canApply = false
25152526 blockExpr()
25162527 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)
25252529 case NEW =>
25262530 canApply = false
25272531 newExpr()
0 commit comments