Skip to content

Commit

Permalink
spec: use original terminology in metasyntax (cleanup)
Browse files Browse the repository at this point in the history
The metasyntax used in the spec is exactly the Wirth Syntax
Notation (WSN), which eventually influenced EBNF. Add a link
but keep mentioning EBNF which is likely more commonly known.

Use the original terms in the productions. Specifically, use
the words "Term" and "Factor" rather than "Alternative" and
"Term".

The terminology cleanup also resolves an inconsistency in the
subsequent prose which is referring to the correct "terms" now.

While at it, add a production for the entire Syntax itself,
matching the original WSN definition.

Also, replace the two uses of "grammar" with "syntax" for
consistency ("syntax" is the prevalent term used throughout
the spec).

Fixes #50074.

Change-Id: If770d5f32f56f509f85893782c1dafbb0eb29b2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/405814
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
  • Loading branch information
griesemer committed May 12, 2022
1 parent 1dfe994 commit f269d90
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions doc/go_spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,23 @@ <h2 id="Introduction">Introduction</h2>
</p>

<p>
The grammar is compact and simple to parse, allowing for easy analysis
The syntax is compact and simple to parse, allowing for easy analysis
by automatic tools such as integrated development environments.
</p>

<h2 id="Notation">Notation</h2>
<p>
The syntax is specified using Extended Backus-Naur Form (EBNF):
The syntax is specified using a
<a href="https://en.wikipedia.org/wiki/Wirth_syntax_notation">variant</a>
of Extended Backus-Naur Form (EBNF):
</p>

<pre class="grammar">
Syntax = { Production } .
Production = production_name "=" [ Expression ] "." .
Expression = Alternative { "|" Alternative } .
Alternative = Term { Term } .
Term = production_name | token [ "…" token ] | Group | Option | Repetition .
Expression = Term { "|" Term } .
Term = Factor { Factor } .
Factor = production_name | token [ "…" token ] | Group | Option | Repetition .
Group = "(" Expression ")" .
Option = "[" Expression "]" .
Repetition = "{" Expression "}" .
Expand All @@ -53,7 +56,7 @@ <h2 id="Notation">Notation</h2>
</pre>

<p>
Lowercase production names are used to identify lexical tokens.
Lowercase production names are used to identify lexical (terminal) tokens.
Non-terminals are in CamelCase. Lexical tokens are enclosed in
double quotes <code>""</code> or back quotes <code>``</code>.
</p>
Expand Down Expand Up @@ -170,7 +173,7 @@ <h3 id="Tokens">Tokens</h3>
<h3 id="Semicolons">Semicolons</h3>

<p>
The formal grammar uses semicolons <code>";"</code> as terminators in
The formal syntax uses semicolons <code>";"</code> as terminators in
a number of productions. Go programs may omit most of these semicolons
using the following two rules:
</p>
Expand Down Expand Up @@ -3038,7 +3041,7 @@ <h3 id="Composite_literals">Composite literals</h3>
<p>
The LiteralType's <a href="#Core_types">core type</a> <code>T</code>
must be a struct, array, slice, or map type
(the grammar enforces this constraint except when the type is given
(the syntax enforces this constraint except when the type is given
as a TypeName).
The types of the elements and keys must be <a href="#Assignability">assignable</a>
to the respective field, element, and key types of type <code>T</code>;
Expand Down

0 comments on commit f269d90

Please sign in to comment.