Permalink
Browse files

fix single quote literal

```
Welcome to Scala 2.12.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_172).
Type in expressions for evaluation. Or try :help.

scala> '''
<console>:12: warning: deprecated syntax for character literal (use '\'' for single quote)
       '''
       ^
res0: Char = '
```
  • Loading branch information...
xuwei-k committed May 9, 2018
1 parent 1c91977 commit 876bd9f99da2d53417382b21b57f37de522b8c8d
@@ -46,9 +46,9 @@ trait SourceUtils {
def currentCharsAreMultilineCommentCommentStart = current2CharsAre('/', '*')
def currentCharsAreMultilineCommentCommentEnd = current2CharsAre('*', '/')
def currentCharIsRegularQuote = currentCharIs('"')
def currentCharsAreSingleQuotedSingleQuote = current3CharsAre(''', ''', ''')
def currentCharsAreEscapedSingleQuote = current2CharsAre('\\', ''')
def currentCharIsSingleQuote = currentCharIs(''')
def currentCharsAreSingleQuotedSingleQuote = current3CharsAre('\'', '\'', '\'')
def currentCharsAreEscapedSingleQuote = current2CharsAre('\\', '\'')
def currentCharIsSingleQuote = currentCharIs('\'')
def currentCharsAreEscapedRegularQuote = current2CharsAre('\\', '"')
def currentCharIsNewline = currentCharIs('\n')
def currentCharIsBackTick = currentCharIs('`')
@@ -605,7 +605,7 @@ object SourceWithMarker {
}
val delimiter = charOfClass { c =>
c == '`' || c == ''' || c == '"' || c == '.' || c == ';' || c == ','
c == '`' || c == '\'' || c == '"' || c == '.' || c == ';' || c == ','
}
val opChar = charOfClass { c =>
@@ -620,10 +620,10 @@ object SourceWithMarker {
}
val characterLiteral = {
val charEscape = character('b') | 't' | 'n' | 'f' | 'r' | '"' | ''' | '\\'
val charEscape = character('b') | 't' | 'n' | 'f' | 'r' | '"' | '\'' | '\\'
val octEscape = octalDigit ~ octalDigit.atMostNtimes(2)
''' ~ ((any.butNot('\\') | ('\\' ~ (charEscape | octEscape)))) ~ '''
'\'' ~ ((any.butNot('\\') | ('\\' ~ (charEscape | octEscape)))) ~ '\''
}
val stringLiteral = {
@@ -680,7 +680,7 @@ object SourceWithMarker {
val plainid = (upper ~ idrest) | varid | op
val symbolLiteral = ''' ~ plainid
val symbolLiteral = '\'' ~ plainid
val literalIdentifier = '`' ~ any.butNot('`').atLeastOnce ~ '`'

0 comments on commit 876bd9f

Please sign in to comment.