@@ -357,9 +357,6 @@ object Parsers {
357357 offset
358358 }
359359
360- def reportMissing (expected : Token ): Unit =
361- syntaxError(ExpectedTokenButFound (expected, in.token))
362-
363360 /** semi = nl {nl} | `;'
364361 * nl = `\n' // where allowed
365362 */
@@ -1825,7 +1822,7 @@ object Parsers {
18251822 * the initially parsed (...) region?
18261823 */
18271824 def toBeContinued (altToken : Token ): Boolean =
1828- if in.token == altToken || in. isNewLine || migrateTo3 then
1825+ if in.isNewLine || migrateTo3 then
18291826 false // a newline token means the expression is finished
18301827 else if ! in.canStartStatTokens.contains(in.token)
18311828 || in.isLeadingInfixOperator(inConditional = true )
@@ -1835,37 +1832,27 @@ object Parsers {
18351832 followedByToken(altToken) // scan ahead to see whether we find a `then` or `do`
18361833
18371834 def condExpr (altToken : Token ): Tree =
1838- if in.token == LPAREN then
1839- var t : Tree = atSpan(in.offset) { Parens (inParens(exprInParens())) }
1840- val enclosedInParens = ! toBeContinued(altToken)
1841- if ! enclosedInParens then
1842- t = inSepRegion(InCond ) {
1843- expr1Rest(postfixExprRest(simpleExprRest(t)), Location .ElseWhere )
1844- }
1845- if in.token == altToken then
1846- if rewriteToOldSyntax() then revertToParens(t)
1847- in.nextToken()
1835+ val t : Tree =
1836+ if in.token == LPAREN then
1837+ var t : Tree = atSpan(in.offset) { Parens (inParens(exprInParens())) }
1838+ if in.token != altToken then
1839+ if toBeContinued(altToken) then
1840+ t = inSepRegion(InCond ) {
1841+ expr1Rest(postfixExprRest(simpleExprRest(t)), Location .ElseWhere )
1842+ }
1843+ else
1844+ if rewriteToNewSyntax(t.span) then
1845+ dropParensOrBraces(t.span.start, s " ${tokenString(altToken)}" )
1846+ in.observeIndented()
1847+ return t
1848+ t
1849+ else if in.isNestedStart then
1850+ try expr() finally newLinesOpt()
18481851 else
1849- if (altToken == THEN || enclosedInParens) && in.isNewLine then
1850- in.observeIndented()
1851- if ! enclosedInParens && in.token != INDENT then reportMissing(altToken)
1852- if (rewriteToNewSyntax(t.span))
1853- dropParensOrBraces(t.span.start, s " ${tokenString(altToken)}" )
1854- t
1855- else
1856- val t =
1857- if in.isNestedStart then
1858- try expr() finally newLinesOpt()
1859- else
1860- inSepRegion(InCond )(expr())
1861- if rewriteToOldSyntax(t.span.startPos) then
1862- revertToParens(t)
1863- if altToken == THEN && in.isNewLine then
1864- // don't require a `then` at the end of a line
1865- in.observeIndented()
1866- if in.token != INDENT then accept(altToken)
1867- t
1868- end condExpr
1852+ inSepRegion(InCond )(expr())
1853+ if rewriteToOldSyntax(t.span.startPos) then revertToParens(t)
1854+ accept(altToken)
1855+ t
18691856
18701857 /** Expr ::= [`implicit'] FunParams (‘=>’ | ‘?=>’) Expr
18711858 * | Expr1
0 commit comments