Skip to content

Commit cdc4442

Browse files
committed
Fill in definitions from 2.12
1 parent bac774d commit cdc4442

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

docs/docs/internals/syntax.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,18 @@ The lexical syntax of Scala is given by the following grammar in EBNF
2121
form.
2222

2323
```ebnf
24+
whiteSpace ::= ‘\u0020’ | ‘\u0009’ | ‘\u000D’ | ‘\u000A’
2425
upper ::= ‘A’ | … | ‘Z’ | ‘\$’ | ‘_’ “… and Unicode category Lu”
2526
lower ::= ‘a’ | … | ‘z’ “… and Unicode category Ll”
2627
letter ::= upper | lower “… and Unicode categories Lo, Lt, Nl”
2728
digit ::= ‘0’ | … | ‘9’
29+
paren ::= ‘(’ | ‘)’ | ‘[’ | ‘]’ | ‘{’ | ‘}’
30+
delim ::= ‘`’ | ‘'’ | ‘"’ | ‘.’ | ‘;’ | ‘,’
2831
opchar ::= “printableChar not matched by (whiteSpace | upper | lower |
2932
letter | digit | paren | delim | opchar | Unicode_Sm |
3033
Unicode_So)”
34+
printableChar ::= “all characters in [\u0020, \u007F] inclusive”
35+
charEscapeSeq ::= ‘\’ (‘b’ | ‘t’ | ‘n’ | ‘f’ | ‘r’ | ‘"’ | ‘'’ | ‘\’)
3136
3237
op ::= opchar {opchar}
3338
varid ::= lower idrest
@@ -36,7 +41,7 @@ alphaid ::= upper idrest
3641
plainid ::= alphaid
3742
| op
3843
id ::= plainid
39-
| ‘\`’ stringLit ‘\`’
44+
| ‘`’ { charNoBackQuoteOrNewline | UnicodeEscape | charEscapeSeq } ‘`’
4045
| INT // interpolation id, only for quasi-quotes
4146
idrest ::= {letter | digit} [‘_’ op]
4247
@@ -51,28 +56,26 @@ floatingPointLiteral
5156
| ‘.’ digit {digit} [exponentPart] [floatType]
5257
| digit {digit} exponentPart [floatType]
5358
| digit {digit} [exponentPart] floatType
54-
5559
exponentPart ::= (‘E’ | ‘e’) [‘+’ | ‘-’] digit {digit}
5660
floatType ::= ‘F’ | ‘f’ | ‘D’ | ‘d’
61+
5762
booleanLiteral ::= ‘true’ | ‘false’
5863
59-
characterLiteral ::= ‘\'’ printableChar ‘\'’
60-
| ‘\'’ charEscapeSeq ‘\'’
64+
characterLiteral ::= ‘'’ (printableChar | charEscapeSeq) ‘'’
6165
6266
stringLiteral ::= ‘"’ {stringElement} ‘"’
63-
| ‘"""’ {[‘"’] [‘"’] char \ ‘"’} {‘"’} ‘"""’
67+
| ‘"""’ multiLineChars ‘"""’
6468
stringElement ::= printableChar \ (‘"’ | ‘\’)
69+
| UnicodeEscape
6570
| charEscapeSeq
66-
charEscapeSeq ::= ‘\b’ | ‘\n’ | ‘\t’ | ‘\f’ | ‘\r’ | ‘"’ | ‘'’ | ‘\\’
67-
71+
multiLineChars ::= {[‘"’] [‘"’] char \ ‘"’} {‘"’}
6872
processedStringLiteral
6973
::= alphaid ‘"’ {printableChar \ (‘"’ | ‘$’) | escape} ‘"’
7074
| alphaid ‘"""’ {[‘"’] [‘"’] char \ (‘"’ | ‘$’) | escape} {‘"’} ‘"""’
7175
escape ::= ‘$$’ \comment{$}
7276
| ‘$’ letter { letter | digit }
7377
| ‘{’ Block [‘;’ whiteSpace stringFormat whiteSpace] ‘}’
7478
stringFormat ::= {printableChar \ (‘"’ | ‘}’ | ‘ ’ | ‘\t’ | ‘\n’)}
75-
whiteSpace ::= {‘ ’ | ‘\t’}
7679
7780
symbolLiteral ::= ‘'’ plainid
7881

0 commit comments

Comments
 (0)