Skip to content

Commit 67f7944

Browse files
committed
Rename rewrite options
pascal-style --> new-syntax c-style --> old-syntax
1 parent 60b2d74 commit 67f7944

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ class ScalaSettings extends Settings.SettingGroup {
4848
val silentWarnings: Setting[Boolean] = BooleanSetting("-nowarn", "Silence all warnings.") withAbbreviation "--no-warnings"
4949
val fromTasty: Setting[Boolean] = BooleanSetting("-from-tasty", "Compile classes from tasty in classpath. The arguments are used as class names.") withAbbreviation "--from-tasty"
5050

51-
val cStyle: Setting[Boolean] = BooleanSetting("-c-style", "when used with -rewrite, produces control expressions with parentheses")
52-
val pascalStyle: Setting[Boolean] = BooleanSetting("-pascal-style", "when used with -rewrite, produces control expressions without parentheses")
51+
val newSyntax: Setting[Boolean] = BooleanSetting("-new-syntax", "When used with -rewrite, produces control expressions without parentheses")
52+
val oldSyntax: Setting[Boolean] = BooleanSetting("-old-syntax", "when used with -rewrite, produces control expressions with parentheses")
5353

5454
/** Decompiler settings */
5555
val printTasty: Setting[Boolean] = BooleanSetting("-print-tasty", "Prints the raw tasty.") withAbbreviation "--print-tasty"

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,15 +1353,15 @@ object Parsers {
13531353
}
13541354
if (in.token == altToken) {
13551355
in.nextToken()
1356-
if (in.rewriteC) revertToParens(t)
1356+
if (in.rewriteOldSyntax) revertToParens(t)
13571357
}
1358-
else if (in.rewritePascal)
1358+
else if (in.rewriteNewSyntax)
13591359
dropParensOrBraces(t.span.start, s"${tokenString(altToken)}")
13601360
t
13611361
} else {
13621362
val t = inSepRegion(LPAREN, RPAREN)(expr())
13631363
accept(altToken)
1364-
if (in.rewriteC) revertToParens(t)
1364+
if (in.rewriteOldSyntax) revertToParens(t)
13651365
t
13661366
}
13671367
}
@@ -1994,7 +1994,7 @@ object Parsers {
19941994
val closingOnNewLine = in.isAfterLineEnd()
19951995
accept(leading + 1)
19961996
openParens.change(leading, -1)
1997-
if (in.rewritePascal && enumsOnNewLine == (leading == LBRACE)) { // Don't rewrite if that would change meaning of newlines
1997+
if (in.rewriteNewSyntax && enumsOnNewLine == (leading == LBRACE)) { // Don't rewrite if that would change meaning of newlines
19981998
newLinesOpt()
19991999
dropParensOrBraces(start, if (in.token == YIELD || in.token == DO) "" else "do")
20002000
}
@@ -2009,7 +2009,7 @@ object Parsers {
20092009
val ts = // If we use indent syntax, the distinction below should no longer be necessary
20102010
if (impliedBraces) enumerators()
20112011
else inSepRegion(LPAREN, RPAREN)(enumerators())
2012-
if (in.rewriteC && ts.nonEmpty) {
2012+
if (in.rewriteOldSyntax && ts.nonEmpty) {
20132013
if (impliedBraces) {
20142014
patch(source, Span(forEnd), " {")
20152015
patch(source, Span(in.offset), "} ")
@@ -2027,7 +2027,7 @@ object Parsers {
20272027
ForYield(enums, expr())
20282028
}
20292029
else if (in.token == DO) {
2030-
if (in.rewriteC) {
2030+
if (in.rewriteOldSyntax) {
20312031
var startOffset = in.offset
20322032
var endOffset = in.lastCharOffset
20332033
if (in.isAfterLineEnd()) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ object Scanners {
223223
private var allowLeadingInfixOperators = true
224224

225225
val rewrite = ctx.settings.rewrite.value.isDefined
226-
val rewritePascal = rewrite && ctx.settings.pascalStyle.value
227-
val rewriteC = rewrite && ctx.settings.cStyle.value
226+
val rewriteNewSyntax = rewrite && ctx.settings.newSyntax.value
227+
val rewriteOldSyntax = rewrite && ctx.settings.oldSyntax.value
228228

229229
/** All doc comments kept by their end position in a `Map` */
230230
private[this] var docstringMap: SortedMap[Int, Comment] = SortedMap.empty

tests/pos/syntaxRewrites.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Compile with -rewrite -pascal-style
2+
// Then compile again with -rewrite c-style
3+
// The resulting file is the same as the original one, except for some extra spaces
4+
// at line ends
15
object Test {
26

37
val xs = List(1, 2, 3)

0 commit comments

Comments
 (0)