cplusplus / CWG

Core Working Group
23 stars 7 forks source link

[syntax] How do syntax notation and the literal wording establish a relationship is underspecified #429

Open xmh0511 opened 1 year ago

xmh0511 commented 1 year ago

Full name of submitter (unless configured in github; will be published with the issue): Jim X

[syntax] p1 says:

In the syntax notation used in this document, syntactic categories are indicated by italic type, and literal words and characters in constant width type.

This implies syntax and literal words are different things. However, in this document, we almost use literal wording in the phrasing rule to mention the associated syntax component. For example, [lex.pptoken] p1 says

Each preprocessing token that is converted to a token shall have the lexical form of a keyword, an identifier, a literal, or an operator or punctuator.

The literal wording preprocessing token wants to refer to the syntax stuff preprocessing-token. This concept is not clearly specified in [syntax]. Moreover, the literal wording sometimes is not simply identical(i.e. their spelling are similar) to the syntax notation, for example:

preprocessing numbers

The syntax notation the literal wording refers to should be

pp-number

which are not equivalent in their spelling.

Suggested Resolution

We should clarify how we map the literal wording and syntax notation

jensmaurer commented 1 year ago

The C standard equates syntax non-terminals with the English phrase with the same spelling. Not so in C++. However, due to the C heritage of C++, it is possible that some vestiges remain. In general, syntax non-terminals should be mapped to English phrases in English-language definitions, if we want to use the English phrase as a defined term.

xmh0511 commented 1 year ago

The C standard equates syntax non-terminals with the English phrase with the same spelling.

This is almost true in C++, however, as specified above, some syntax notations are not equivalent to the corresponding spelling of the English phrase.

In general, syntax non-terminals should be mapped to English phrases in English-language definitions, if we want to use the English phrase as a defined term.

We lack a formal rule to specify how the mapping works, i.e., which non-terminal syntax notation corresponds to an English phrase we are using in the rule.

jensmaurer commented 1 year ago

I'm not disagreeing.