Introduce a syntax for comments.
Chris Pressey
1 year, 10 months ago
65 | 65 |
|
66 | 66 |
### Syntax
|
67 | 67 |
|
68 | |
* A syntax for comments.
|
69 | 68 |
* A syntax for terminals so that `"` can be given as a terminal.
|
70 | 69 |
Probably any unicode code point by its hex.
|
71 | 70 |
|
9 | 9 |
-------------------
|
10 | 10 |
|
11 | 11 |
This grammar is written in EBNF. Any amount of whitespace may occur
|
12 | |
between tokens (and for this purpose, comments count as whitespace).
|
|
12 |
between tokens (and for this purpose, comments, which are introduced
|
|
13 |
by `//` and extend until the end of the line, count as whitespace).
|
13 | 14 |
Some whitespace must appear between tokens if the tokens would otherwise
|
14 | 15 |
be interpreted as a single token. The bottommost productions in the
|
15 | 16 |
grammar describe the concrete structure of tokens.
|
19 | 19 |
Goal ::= "f" "o" "o";
|
20 | 20 |
===> Grammar [("Goal",[],Alt [Seq [Terminal 'f',Terminal 'o',Terminal 'o']])]
|
21 | 21 |
|
22 | |
Multi-character terminal.
|
|
22 |
Multi-character terminal and whitespace and comments.
|
23 | 23 |
|
24 | |
Goal ::= "foo";
|
|
24 |
// This is my grammar.
|
|
25 |
|
|
26 |
Goal ::= "foo"; // You see
|
|
27 |
// how it is
|
25 | 28 |
===> Grammar [("Goal",[],Alt [Seq [Seq [Terminal 'f',Terminal 'o',Terminal 'o']]])]
|
26 | 29 |
|
27 | 30 |
Alternation and recursion.
|