Skip to content

Commit d62a649

Browse files
committed
Merge pull request scala#3664 from iainmcgin/lexicalfix
Minor typographical fixes for lexical syntax chapter
2 parents 63fb98d + 9cc0911 commit d62a649

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

spec/01-lexical-syntax.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ Scala programs are written using the Unicode Basic Multilingual Plane
1111
presently supported. This chapter defines the two modes of Scala's
1212
lexical syntax, the Scala mode and the _XML mode_. If not
1313
otherwise mentioned, the following descriptions of Scala tokens refer
14-
to _Scala mode_, and literal characters `‘c’` refer to the ASCII fragment `\u0000``\u007F`.
14+
to _Scala mode_, and literal characters ‘c’ refer to the ASCII fragment
15+
`\u0000``\u007F`.
1516

1617
In Scala mode, _Unicode escapes_ are replaced by the corresponding
1718
Unicode character with the given hexadecimal code.
1819

1920
```ebnf
20-
UnicodeEscape ::= ‘\ ‘u {‘u} hexDigit hexDigit hexDigit hexDigit
21+
UnicodeEscape ::= ‘\ ‘u {‘u} hexDigit hexDigit hexDigit hexDigit
2122
hexDigit ::= ‘0’ | … | ‘9’ | ‘A’ | … | ‘F’ | ‘a’ | … | ‘f’
2223
```
2324

@@ -40,8 +41,8 @@ classes (Unicode general category given in parentheses):
4041
1. Parentheses `‘(’ | ‘)’ | ‘[’ | ‘]’ | ‘{’ | ‘}’ `.
4142
1. Delimiter characters ``‘`’ | ‘'’ | ‘"’ | ‘.’ | ‘;’ | ‘,’ ``.
4243
1. Operator characters. These consist of all printable ASCII characters
43-
`\u0020 - \u007F` which are in none of the sets above, mathematical symbols (`Sm`)
44-
and other symbols (`So`).
44+
`\u0020` - `\u007F` which are in none of the sets above, mathematical
45+
symbols (`Sm`) and other symbols (`So`).
4546

4647
## Identifiers
4748

@@ -58,7 +59,7 @@ idrest ::= {letter | digit} [‘_’ op]
5859

5960
There are three ways to form an identifier. First, an identifier can
6061
start with a letter which can be followed by an arbitrary sequence of
61-
letters and digits. This may be followed by underscore `‘_’`
62+
letters and digits. This may be followed by underscore ‘_
6263
characters and another string composed of either letters and digits or
6364
of operator characters. Second, an identifier can start with an operator
6465
character followed by an arbitrary sequence of operator characters.
@@ -79,8 +80,8 @@ decomposes into the three identifiers `big_bob`, `++=`, and
7980
_variable identifiers_, which start with a lower case letter, and
8081
_constant identifiers_, which do not.
8182

82-
The `‘$’` character is reserved for compiler-synthesized identifiers.
83-
User programs should not define identifiers which contain `‘$’` characters.
83+
The \$ character is reserved for compiler-synthesized identifiers.
84+
User programs should not define identifiers which contain \$ characters.
8485

8586
The following names are reserved words instead of being members of the
8687
syntactic class `id` of lexical identifiers.
@@ -97,11 +98,11 @@ var while with yield
9798
_ : = => <- <: <% >: # @
9899
```
99100

100-
The Unicode operators `\u21D2 $\Rightarrow$` and `\u2190 $\leftarrow$`, which have the ASCII
101+
The Unicode operators `\u21D2`$\Rightarrow$ and `\u2190`$\leftarrow$, which have the ASCII
101102
equivalents `=>` and `<-`, are also reserved.
102103

103104
### Example
104-
105+
Here are examples of identifiers:
105106
```scala
106107
x Object maxIndex p2p empty_?
107108
+ `yield` αρετη _y dot_product_*
@@ -217,7 +218,7 @@ if (x > 0)
217218
x = x - 1
218219

219220
while (x > 0)
220-
x = x / 2
221+
x = x / 2
221222

222223
for (x <- 1 to 10)
223224
println(x)
@@ -338,9 +339,9 @@ octalDigit ::= ‘0’ | … | ‘7’
338339
Integer literals are usually of type `Int`, or of type
339340
`Long` when followed by a `L` or
340341
`l` suffix. Values of type `Int` are all integer
341-
numbers between $-2^{31}$ and $2^{31}-1$, inclusive. Values of
342-
type `Long` are all integer numbers between $-2^{63}$ and
343-
$2^{63}-1$, inclusive. A compile-time error occurs if an integer literal
342+
numbers between $-2\^{31}$ and $2\^{31}-1$, inclusive. Values of
343+
type `Long` are all integer numbers between $-2\^{63}$ and
344+
$2\^{63}-1$, inclusive. A compile-time error occurs if an integer literal
344345
denotes a number outside these ranges.
345346

346347
However, if the expected type [_pt_](06-expressions.html#expression-typing) of a literal
@@ -349,11 +350,11 @@ and the integer number fits in the numeric range defined by the type,
349350
then the number is converted to type _pt_ and the literal's type
350351
is _pt_. The numeric ranges given by these types are:
351352

352-
| | |
353-
|----------------|------------------------|
354-
|`Byte` | $-2^7$ to $2^7-1$ |
355-
|`Short` | $-2^{15}$ to $2^{15}-1$|
356-
|`Char` | $0$ to $2^{16}-1$ |
353+
| | |
354+
|----------------|--------------------------|
355+
|`Byte` | $-2\^7$ to $2\^7-1$ |
356+
|`Short` | $-2\^{15}$ to $2\^{15}-1$|
357+
|`Char` | $0$ to $2\^{16}-1$ |
357358

358359

359360
### Example
@@ -576,7 +577,7 @@ comment.
576577

577578
In order to allow literal inclusion of XML fragments, lexical analysis
578579
switches from Scala mode to XML mode when encountering an opening
579-
angle bracket '<' in the following circumstance: The '<' must be
580+
angle bracket ‘<’ in the following circumstance: The ‘<’ must be
580581
preceded either by whitespace, an opening parenthesis or an opening
581582
brace and immediately followed by a character starting an XML name.
582583

0 commit comments

Comments
 (0)