diff --git a/src/grammar.md b/src/grammar.md index fa7ca7819..e27d73936 100644 --- a/src/grammar.md +++ b/src/grammar.md @@ -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 }} diff --git a/src/input-format.md b/src/input-format.md index afdf8ac37..5d2a69275 100644 --- a/src/input-format.md +++ b/src/input-format.md @@ -1,6 +1,19 @@ r[input] # Input format +r[input.syntax] +```grammar,lexer +@root CHAR -> + +NUL -> U+0000 + +TAB -> U+0009 + +LF -> U+000A + +CR -> U+000D +``` + r[input.intro] This chapter describes how a source file is interpreted as a sequence of tokens. diff --git a/src/notation.md b/src/notation.md index de262423c..b4954d42c 100644 --- a/src/notation.md +++ b/src/notation.md @@ -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 | @@ -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 — notably [unary operators], [binary operators], and [keywords] — are given in a simplified form: as a listing @@ -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 -> - -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