@@ -21,13 +21,18 @@ The lexical syntax of Scala is given by the following grammar in EBNF
21
21
form.
22
22
23
23
``` ebnf
24
+ whiteSpace ::= ‘\u0020’ | ‘\u0009’ | ‘\u000D’ | ‘\u000A’
24
25
upper ::= ‘A’ | … | ‘Z’ | ‘\$’ | ‘_’ “… and Unicode category Lu”
25
26
lower ::= ‘a’ | … | ‘z’ “… and Unicode category Ll”
26
27
letter ::= upper | lower “… and Unicode categories Lo, Lt, Nl”
27
28
digit ::= ‘0’ | … | ‘9’
29
+ paren ::= ‘(’ | ‘)’ | ‘[’ | ‘]’ | ‘{’ | ‘}’
30
+ delim ::= ‘`’ | ‘'’ | ‘"’ | ‘.’ | ‘;’ | ‘,’
28
31
opchar ::= “printableChar not matched by (whiteSpace | upper | lower |
29
32
letter | digit | paren | delim | opchar | Unicode_Sm |
30
33
Unicode_So)”
34
+ printableChar ::= “all characters in [\u0020, \u007F] inclusive”
35
+ charEscapeSeq ::= ‘\’ (‘b’ | ‘t’ | ‘n’ | ‘f’ | ‘r’ | ‘"’ | ‘'’ | ‘\’)
31
36
32
37
op ::= opchar {opchar}
33
38
varid ::= lower idrest
@@ -36,7 +41,7 @@ alphaid ::= upper idrest
36
41
plainid ::= alphaid
37
42
| op
38
43
id ::= plainid
39
- | ‘\ `’ stringLit ‘\ `’
44
+ | ‘`’ { charNoBackQuoteOrNewline | UnicodeEscape | charEscapeSeq } ‘ `’
40
45
| INT // interpolation id, only for quasi-quotes
41
46
idrest ::= {letter | digit} [‘_’ op]
42
47
@@ -51,28 +56,26 @@ floatingPointLiteral
51
56
| ‘.’ digit {digit} [exponentPart] [floatType]
52
57
| digit {digit} exponentPart [floatType]
53
58
| digit {digit} [exponentPart] floatType
54
-
55
59
exponentPart ::= (‘E’ | ‘e’) [‘+’ | ‘-’] digit {digit}
56
60
floatType ::= ‘F’ | ‘f’ | ‘D’ | ‘d’
61
+
57
62
booleanLiteral ::= ‘true’ | ‘false’
58
63
59
- characterLiteral ::= ‘\'’ printableChar ‘\'’
60
- | ‘\'’ charEscapeSeq ‘\'’
64
+ characterLiteral ::= ‘'’ (printableChar | charEscapeSeq) ‘'’
61
65
62
66
stringLiteral ::= ‘"’ {stringElement} ‘"’
63
- | ‘"""’ {[‘"’] [‘"’] char \ ‘"’} {‘"’} ‘"""’
67
+ | ‘"""’ multiLineChars ‘"""’
64
68
stringElement ::= printableChar \ (‘"’ | ‘\’)
69
+ | UnicodeEscape
65
70
| charEscapeSeq
66
- charEscapeSeq ::= ‘\b’ | ‘\n’ | ‘\t’ | ‘\f’ | ‘\r’ | ‘"’ | ‘'’ | ‘\\’
67
-
71
+ multiLineChars ::= {[‘"’] [‘"’] char \ ‘"’} {‘"’}
68
72
processedStringLiteral
69
73
::= alphaid ‘"’ {printableChar \ (‘"’ | ‘$’) | escape} ‘"’
70
74
| alphaid ‘"""’ {[‘"’] [‘"’] char \ (‘"’ | ‘$’) | escape} {‘"’} ‘"""’
71
75
escape ::= ‘$$’ \comment{$}
72
76
| ‘$’ letter { letter | digit }
73
77
| ‘{’ Block [‘;’ whiteSpace stringFormat whiteSpace] ‘}’
74
78
stringFormat ::= {printableChar \ (‘"’ | ‘}’ | ‘ ’ | ‘\t’ | ‘\n’)}
75
- whiteSpace ::= {‘ ’ | ‘\t’}
76
79
77
80
symbolLiteral ::= ‘'’ plainid
78
81
0 commit comments