Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/grammar.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Grammar summary

The following is a summary of the grammar production rules.
The following is a summary of the grammar production rules. For details on the syntax of this grammar, see *[notation.grammar.syntax]*.

{{ grammar-summary }}
13 changes: 13 additions & 0 deletions src/input-format.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
r[input]
# Input format

r[input.syntax]
```grammar,lexer
@root CHAR -> <a Unicode scalar value>

NUL -> U+0000

TAB -> U+0009

LF -> U+000A

CR -> U+000D
```
Comment on lines +4 to +15
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels a bit odd to reference this as the input syntax (and put it here. I would have expected input.syntax to be something like

@root INPUT -> SHEBANG? (BLANK_LINES FRONTMATTER)? TOKEN*

BLANK_LINES might refer to part of this but not all of it.


r[input.intro]
This chapter describes how a source file is interpreted as a sequence of tokens.

Expand Down
30 changes: 9 additions & 21 deletions src/notation.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
r[notation]
# Notation

r[notation.grammar]
## Grammar

r[notation.grammar.syntax]

The following notations are used by the *Lexer* and *Syntax* grammar snippets:

| Notation | Examples | Meaning |
Expand All @@ -26,7 +30,8 @@ The following notations are used by the *Lexer* and *Syntax* grammar snippets:

Sequences have a higher precedence than `|` alternation.

## String table productions
r[notation.grammar.string-tables]
### String table productions

Some rules in the grammar &mdash; notably [unary operators], [binary
operators], and [keywords] &mdash; are given in a simplified form: as a listing
Expand All @@ -40,30 +45,13 @@ When such a string in `monospace` font occurs inside the grammar,
it is an implicit reference to a single member of such a string table
production. See [tokens] for more information.

## Grammar visualizations
r[notation.grammar.visualizations]
### Grammar visualizations

Below each grammar block is a button to toggle the display of a [syntax diagram]. A square element is a non-terminal rule, and a rounded rectangle is a terminal.

[syntax diagram]: https://en.wikipedia.org/wiki/Syntax_diagram

## Common productions

The following are common definitions used in the grammar.

r[input.syntax]
```grammar,lexer
@root CHAR -> <a Unicode scalar value>

NUL -> U+0000

TAB -> U+0009

LF -> U+000A

CR -> U+000D
```

[binary operators]: expressions/operator-expr.md#arithmetic-and-logical-binary-operators
[keywords]: keywords.md
[syntax diagram]: https://en.wikipedia.org/wiki/Syntax_diagram
[tokens]: tokens.md
[unary operators]: expressions/operator-expr.md#borrow-operators