Files
cppdraft_translate/cppdraft/syntax.md
2025-10-25 03:02:53 +03:00

56 lines
2.1 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[syntax]
# 4 General principles [[intro]](./#intro)
## 4.3 Syntax notation [syntax]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/intro.tex#L1073)
In the syntax notation used in this document, syntactic
categories are indicated by *italic, sans-serif* type, and literal words
and characters in constant width type[.](#1.sentence-1)
Alternatives are
listed on separate lines except in a few cases where a long set of
alternatives is marked by the phrase “one of”[.](#1.sentence-2)
If the text of an alternative is too long to fit on a line, the text is continued on subsequent lines indented from the first one[.](#1.sentence-3)
An optional terminal or non-terminal symbol is indicated by the subscript
“opt”, so
{ [*expression*](expr.comma#nt:expression "7.6.20Comma operator[expr.comma]")opt }
indicates an optional expression enclosed in braces[.](#1.sentence-4)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/intro.tex#L1087)
Names for syntactic categories have generally been chosen according to
the following rules:
- [(2.1)](#2.1)
*X-name* is a use of an identifier in a context that
determines its meaning (e.g., [*class-name*](class.pre#nt:class-name "11.1Preamble[class.pre]"),[*typedef-name*](dcl.typedef#nt:typedef-name "9.2.4The typedef specifier[dcl.typedef]"))[.](#2.1.sentence-1)
- [(2.2)](#2.2)
*X-id* is an identifier with no context-dependent meaning
(e.g., [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3Qualified names[expr.prim.id.qual]"))[.](#2.2.sentence-1)
- [(2.3)](#2.3)
*X-seq* is one or more *X*'s without intervening
delimiters (e.g., [*declaration-seq*](dcl.pre#nt:declaration-seq "9.1Preamble[dcl.pre]") is a sequence of
declarations)[.](#2.3.sentence-1)
- [(2.4)](#2.4)
*X-list* is one or more *X*'s separated by
intervening commas (e.g., [*identifier-list*](cpp.pre#nt:identifier-list "15.1Preamble[cpp.pre]") is a sequence of
identifiers separated by commas)[.](#2.4.sentence-1)