Skip to content

Commit 00674e3

Browse files
committed
docs: clarify the start rule of a grammar
1 parent f7def17 commit 00674e3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

docs/section-3-creating-parsers.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,9 @@ Although languages have very different constructs, their constructs can often be
558558
}
559559
```
560560

561+
One important fact to know up front is that the start rule for the grammar is the first property in the `rules` object.
562+
In the example above, that would correspond to `source_file`, but it can be named anything.
563+
561564
Some of the details of this grammar will be explained in more depth later on, but if you focus on the `TODO` comments, you can see that the overall strategy is *breadth-first*. Notably, this initial skeleton does not need to directly match an exact subset of the context-free grammar in the language specification. It just needs to touch on the major groupings of rules in as simple and obvious a way as possible.
562565

563566
With this structure in place, you can now freely decide what part of the grammar to flesh out next. For example, you might decide to start with *types*. One-by-one, you could define the rules for writing basic types and composing them into more complex types:

0 commit comments

Comments
 (0)