@@ -20,51 +20,46 @@ productions map to AST nodes.
2020The following description of Scala tokens uses literal characters ` ‘c’ ` when
2121referring to the ASCII fragment ` \u0000 ` – ` \u007F ` .
2222
23- _ Unicode escapes_ are used to represent the [ Unicode character] ( https://www.w3.org/International/articles/definitions-characters/ ) with the given
24- hexadecimal code:
25-
26- ``` ebnf
27- UnicodeEscape ::= ‘\’ ‘u’ {‘u’} hexDigit hexDigit hexDigit hexDigit
28- hexDigit ::= ‘0’ | … | ‘9’ | ‘A’ | … | ‘F’ | ‘a’ | … | ‘f’
29- ```
30-
31- Informal descriptions are typeset as ` “some comment” ` .
32-
3323## Lexical Syntax
3424
35- The lexical syntax of Scala is given by the following grammar in EBNF
36- form.
25+ The lexical syntax of Scala is given by the following grammar in EBNF form:
3726
3827``` ebnf
3928whiteSpace ::= ‘\u0020’ | ‘\u0009’ | ‘\u000D’ | ‘\u000A’
40- upper ::= ‘A’ | … | ‘Z’ | ‘\$’ | ‘_’ “… and Unicode category Lu”
41- lower ::= ‘a’ | … | ‘z’ “… and Unicode category Ll”
42- letter ::= upper | lower “… and Unicode categories Lo, Lt, Lm, Nl”
43- digit ::= ‘0’ | … | ‘9’
29+ upper ::= ‘A’ | ... | ‘Z’ | ‘$’ and any character in Unicode categories Lu, Lt or Nl,
30+ and any character in Unicode categories Lo and Lm that doesn't have
31+ contributory property Other_Lowercase
32+ lower ::= ‘a’ | ... | ‘z’ | ‘_’ and any character in Unicode category Ll,
33+ and any character in Unicode categories Lo or Lm that has contributory
34+ property Other_Lowercase
35+ letter ::= upper | lower
36+ digit ::= ‘0’ | ... | ‘9’
4437paren ::= ‘(’ | ‘)’ | ‘[’ | ‘]’ | ‘{’ | ‘}’
4538delim ::= ‘`’ | ‘'’ | ‘"’ | ‘.’ | ‘;’ | ‘,’
4639opchar ::= ‘!’ | ‘#’ | ‘%’ | ‘&’ | ‘*’ | ‘+’ | ‘-’ | ‘/’ | ‘:’ |
4740 ‘<’ | ‘=’ | ‘>’ | ‘?’ | ‘@’ | ‘\’ | ‘^’ | ‘|’ | ‘~’
48- “… and Unicode categories Sm, So”
49- printableChar ::= “all characters in [\u0020, \u007E] inclusive”
41+ and any character in Unicode categories Sm or So
42+ printableChar ::= all characters in [\u0020, \u007E] inclusive
43+ UnicodeEscape ::= ‘\’ ‘u’ {‘u’} hexDigit hexDigit hexDigit hexDigit
44+ hexDigit ::= ‘0’ | ... | ‘9’ | ‘A’ | ... | ‘F’ | ‘a’ | ... | ‘f’
5045charEscapeSeq ::= ‘\’ (‘b’ | ‘t’ | ‘n’ | ‘f’ | ‘r’ | ‘"’ | ‘'’ | ‘\’)
46+ escapeSeq ::= UnicodeEscape | charEscapeSeq
5147
5248op ::= opchar {opchar}
5349varid ::= lower idrest
54- alphaid ::= upper idrest
55- | varid
50+ boundvarid ::= varid
51+ | ‘`’ varid ‘`’
5652plainid ::= alphaid
5753 | op
5854id ::= plainid
59- | ‘`’ { charNoBackQuoteOrNewline | UnicodeEscape | charEscapeSeq } ‘`’
55+ | ‘`’ { charNoBackQuoteOrNewline | escapeSeq } ‘`’
6056idrest ::= {letter | digit} [‘_’ op]
6157quoteId ::= ‘'’ alphaid
6258spliceId ::= ‘$’ alphaid ;
6359
6460integerLiteral ::= (decimalNumeral | hexNumeral) [‘L’ | ‘l’]
65- decimalNumeral ::= ‘0’ | nonZeroDigit [{digit | ‘_’} digit]
61+ decimalNumeral ::= ‘0’ | digit [{digit | ‘_’} digit]
6662hexNumeral ::= ‘0’ (‘x’ | ‘X’) hexDigit [{hexDigit | ‘_’} hexDigit]
67- nonZeroDigit ::= ‘1’ | … | ‘9’
6863
6964floatingPointLiteral
7065 ::= [decimalNumeral] ‘.’ digit [{digit | ‘_’} digit] [exponentPart] [floatType]
@@ -75,25 +70,25 @@ floatType ::= ‘F’ | ‘f’ | ‘D’ | ‘d’
7570
7671booleanLiteral ::= ‘true’ | ‘false’
7772
78- characterLiteral ::= ‘'’ (printableChar | charEscapeSeq ) ‘'’
73+ characterLiteral ::= ‘'’ (charNoQuoteOrNewline | escapeSeq ) ‘'’
7974
8075stringLiteral ::= ‘"’ {stringElement} ‘"’
8176 | ‘"""’ multiLineChars ‘"""’
82- stringElement ::= printableChar \ (‘"’ | ‘\’)
83- | UnicodeEscape
84- | charEscapeSeq
85- multiLineChars ::= {[‘"’] [‘"’] char \ ‘"’} {‘"’}
86- processedStringLiteral
87- ::= alphaid ‘"’ {[‘\’] processedStringPart | ‘\\’ | ‘\"’} ‘"’
88- | alphaid ‘"""’ {[‘"’] [‘"’] char \ (‘"’ | ‘$’) | escape} {‘"’} ‘"""’
89- processedStringPart
77+ stringElement ::= charNoDoubleQuoteOrNewline
78+ | escapeSeq
79+ multiLineChars ::= {[‘"’] [‘"’] charNoDoubleQuote} {‘"’}
80+
81+ interpolatedString
82+ ::= alphaid ‘"’ {[‘\’] interpolatedStringPart | ‘\\’ | ‘\"’} ‘"’
83+ | alphaid ‘"""’ {[‘"’] [‘"’] char \ (‘"’ | ‘\ $’) | escape} {‘"’} ‘"""’
84+ interpolatedStringPart
9085 ::= printableChar \ (‘"’ | ‘$’ | ‘\’) | escape
91- escape ::= ‘$ $’
92- | ‘$’ letter { letter | digit }
93- | ‘{’ Block [‘;’ whiteSpace stringFormat whiteSpace] ‘}’
94- stringFormat ::= {printableChar \ (‘"’ | ‘}’ | ‘ ’ | ‘\t’ | ‘\n’)}
95-
96- symbolLiteral ::= ‘'’ plainid // until 2.13
86+ escape ::= ‘\$\ $’
87+ | ‘\$"’
88+ | ‘\$’ alphaid
89+ | ‘\$’ BlockExpr
90+ alphaid ::= upper idrest
91+ | varid
9792
9893comment ::= ‘/*’ “any sequence of characters; nested comments are allowed” ‘*/’
9994 | ‘//’ “any sequence of characters up to end of line”
@@ -159,7 +154,7 @@ SimpleLiteral ::= [‘-’] integerLiteral
159154 | characterLiteral
160155 | stringLiteral
161156Literal ::= SimpleLiteral
162- | processedStringLiteral
157+ | interpolatedStringLiteral
163158 | symbolLiteral
164159 | ‘null’
165160
0 commit comments