op ::= opchar {opchar}
varid ::= lower idrest
boundvarid ::= varid
| ‘`’ varid ‘`’
plainid ::= upper idrest
| varid
| op
id ::= plainid
| ‘`’ { charNoBackQuoteOrNewline | UnicodeEscape | charEscapeSeq } ‘`’
idrest ::= {letter | digit} [‘_’ op]
_
以外字符的规则是要求用反引号引用标识符的规则:‘`’ { charNoBackQuoteOrNewline | UnicodeEscape | charEscapeSeq } ‘`’
然而,charNoBackQuoteOrNewline
明确不允许使用反引号,如果你试图通过 UnicodeEscape
来解决这个问题,那也不行:
scala> val `hello \u0060world` = "hello world"
<console>:1: error: unclosed quoted identifier
val `hello \u0060world` = "hello world"
^
val `hello 'world` = "hello world"
? - Dmytro MitinString Refined MatchesRegex[W.someRegexWithBackTick.T]
(我不得不删除 someRegexWithBackTick 周围的反引号,因为它会破坏格式)。 - Valy Dia