Skip to content

Commit 18c8f91

Browse files
committed
[spec] Better align EBNF grammars in the lexical syntax chapter.
1 parent b4ce684 commit 18c8f91

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

Diff for: docs/_spec/01-lexical-syntax.md

+18-21
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ colon ::= ':' -- with side conditions explained above
4343
## Identifiers
4444

4545
```ebnf
46-
op ::= opchar {opchar}
47-
varid ::= lower idrest
48-
boundvarid ::= varid
49-
| ‘`’ varid ‘`’
50-
alphaid ::= upper idrest
51-
| varid
52-
plainid ::= alphaid
53-
| op
54-
id ::= plainid
55-
| ‘`’ { charNoBackQuoteOrNewline | escapeSeq } ‘`’
56-
idrest ::= {letter | digit} [‘_’ op]
46+
op ::= opchar {opchar}
47+
varid ::= lower idrest
48+
boundvarid ::= varid
49+
| ‘`’ varid ‘`’
50+
alphaid ::= upper idrest
51+
| varid
52+
plainid ::= alphaid
53+
| op
54+
id ::= plainid
55+
| ‘`’ { charNoBackQuoteOrNewline | escapeSeq } ‘`’
56+
idrest ::= {letter | digit} [‘_’ op]
5757
escapeSeq ::= UnicodeEscape | charEscapeSeq
5858
UnicodeEscape ::= ‘\’ ‘u’ {‘u’} hexDigit hexDigit hexDigit hexDigit
5959
hexDigit ::= ‘0’ | ... | ‘9’ | ‘A’ | ... | ‘F’ | ‘a’ | ... | ‘f’
@@ -177,9 +177,8 @@ _ ) ] }
177177
The tokens that can begin a statement are all Scala tokens _except_ the following delimiters and reserved words:
178178

179179
```
180-
catch else extends finally forSome match
181-
with yield , . ; : = => <- <: <%
182-
>: # [ ) ] }
180+
catch else extends finally forSome match with yield
181+
, . ; : = => <- <: <% >: # [ ) ] }
183182
```
184183

185184
A `case` token can begin a statement only if followed by a
@@ -334,8 +333,7 @@ Literal ::= [‘-’] integerLiteral
334333
### Integer Literals
335334

336335
```ebnf
337-
integerLiteral ::= (decimalNumeral | hexNumeral)
338-
[‘L’ | ‘l’]
336+
integerLiteral ::= (decimalNumeral | hexNumeral) [‘L’ | ‘l’]
339337
decimalNumeral ::= ‘0’ | digit [{digit | ‘_’} digit]
340338
hexNumeral ::= ‘0’ (‘x’ | ‘X’) hexDigit [{hexDigit | ‘_’} hexDigit]
341339
```
@@ -366,11 +364,10 @@ The digits of a numeric literal may be separated by arbitrarily many underscores
366364
### Floating Point Literals
367365
368366
```ebnf
369-
floatingPointLiteral
370-
::= [decimalNumeral] ‘.’ digit [{digit | ‘_’} digit] [exponentPart] [floatType]
371-
| decimalNumeral exponentPart [floatType]
372-
| decimalNumeral floatType
373-
exponentPart ::= (‘E| ‘e’) [‘+|-’] digit [{digit | ‘_’} digit]
367+
floatingPointLiteral ::= [decimalNumeral] ‘.’ digit [{digit | ‘_’} digit] [exponentPart] [floatType]
368+
| decimalNumeral exponentPart [floatType]
369+
| decimalNumeral floatType
370+
exponentPart ::= (‘E| ‘e’) [‘+|-’] digit [{digit | ‘_’} digit]
374371
```
375372
376373
Floating point literals are of type `Float` when followed by a floating point type suffix `F` or `f`, and are of type `Double` otherwise.

0 commit comments

Comments
 (0)