Skip to content

Commit 4ec1ae0

Browse files
committed
Mock up a representative subset of the grammar.
1 parent dd3dd27 commit 4ec1ae0

File tree

1 file changed

+23
-32
lines changed

1 file changed

+23
-32
lines changed

Sources/TSPL/TSPL.docc/ReferenceManual/AboutTheLanguageReference.md

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,13 @@ follows a few conventions:
2828
- In a few cases, regular font text is used to describe the right-hand side
2929
of a grammar production rule.
3030
- Optional syntactic categories and literals are marked by a trailing
31-
subscript, *opt*.
31+
question mark, *?*.
3232

3333
As an example, the grammar of a getter-setter block is defined as follows:
3434

3535
> Grammar of a getter-setter block:
3636
>
37-
> getter-setter-block → `{` getter-clause setter-clause? `}` | `{` setter-clause getter-clause `}`
38-
>
39-
> getter-setter-block → `{` getter-clause setter-clause-OPT `}` | `{` setter-clause getter-clause `}`
40-
>
41-
> getter-setter-block → `{` getter-clause setter-clause OPT `}` | `{` setter-clause getter-clause `}`
42-
>
43-
> getter-setter-block → `{` getter-clause setter-clause (opt) `}` | `{` setter-clause getter-clause `}`
44-
37+
> *getter-setter-block***`{`** *getter-clause* *setter-clause* _?_ **`}`** | **`{`** *setter-clause* *getter-clause* **`}`**
4538
4639
This definition indicates that a getter-setter block can consist of a getter clause
4740
followed by an optional setter clause, enclosed in braces,
@@ -52,44 +45,42 @@ where the alternatives are spelled out explicitly:
5245
> Grammar of a getter-setter block:
5346
>
5447
>
55-
> getter-setter-block → `{` getter-clause setter-clause? `}`
48+
> *getter-setter-block***`{`** *getter-clause* *setter-clause?* **`}`**
5649
>
57-
> getter-setter-block → `{` getter-clause setter-clause-OPT `}`
58-
>
59-
> getter-setter-block → `{` getter-clause setter-clause OPT `}`
60-
>
61-
> getter-setter-block → `{` getter-clause setter-clause (opt) `}`
62-
>
63-
> getter-setter-block → `{` setter-clause getter-clause `}`
50+
> *getter-setter-block***`{`** setter-clause getter-clause **`}`**
6451
6552
> Grammar of a literal:
6653
>
67-
> literal → numeric-literal | string-literal | regular-expression-literal | boolean-literal | nil-literal
54+
> *literal**numeric-literal* | *string-literal* | *regular-expression-literal* | *boolean-literal* | *nil-literal*
55+
>
6856
>
57+
> *numeric-literal***`-`**_?_ *integer-literal* | **`-`**_?_ *floating-point-literal*
6958
>
70-
> numeric-literal → `-`? integer-literal | `-`? floating-point-literal
59+
> *boolean-literal***`true`** | **`false`**
7160
>
72-
> numeric-literal → `-`OPT integer-literal | `-`OPT floating-point-literal
61+
> *nil-literal***`nil`**
62+
63+
> Grammar of an identifier (partial):
7364
>
74-
> numeric-literal`-` OPT integer-literal | `-` OPT floating-point-literal
65+
> *identifier-head*Upper- or lowercase letter A through Z
7566
>
76-
> numeric-literal`-` (opt) integer-literal | `-` (opt) floating-point-literal
67+
> *identifier-head***`_`**
7768
>
78-
> boolean-literal`true` | `false`
69+
> *identifier-head*U+00A8, U+00AA, U+00AD, U+00AF, U+00B2--U+00B5, or U+00B7--U+00BA
7970
>
80-
> nil-literal`nil`
71+
> *identifier-head*U+00BC--U+00BE, U+00C0--U+00D6, U+00D8--U+00F6, or U+00F8--U+00FF
8172
73+
@Comment {
74+
`_`** Fixes runaway syntax highlight from above
75+
}
8276

83-
> Grammar of a literal:
77+
> Grammar of an optional type:
8478
>
85-
> literal → numeric-literal | string-literal | regular-expression-literal | boolean-literal | nil-literal
86-
>
87-
>
88-
> numeric-literal → `-`opt integer-literal | `-`OPT floating-point-literal
89-
>
90-
> boolean-literal → `true` | `false`
79+
> *optional-type**type* **`?`**
80+
81+
> Grammar of a conditional operator:
9182
>
92-
> nil-literal`nil`
83+
> *conditional-operator***`?`** *expression* **`:`**
9384
9485

9586
@Comment {

0 commit comments

Comments
 (0)