"lovecreatesbeauty" <lo***************@gmail.com> writes:
Both `K&R C, 2nd' and `C: A reference manual, 5th' introduce the
"hello, world" thing using the name "string-constant". But `ISO/IEC
9899:TC2' does not include this kind of thing in section `A.1.5
Constants'.
You'll find it in the following section, "String literals".
In the C99 grammar, we have:
token:
keyword
identifier
constant
string-literal
punctuator
constant:
integer-constant
floating-constant
enumeration-constant
character-constant
primary-expression:
identifier
constant
string-literal
( expression )
"primary-expression" and "token" are the only productions that refers
to "constant".
Making a "string-literal" a separate kind of token, rather than
another kind of "constant", was an arbitrary choice. The following
would describe exactly the same language:
token:
keyword
identifier
constant
/* remove string-literal */
punctuator
constant:
integer-constant
floating-constant
enumeration-constant
character-constant
string-literal /* add this */
primary-expression:
identifier
constant
/* remove string-literal */
( expression )
The wording in K&R2 and H&S5 is just a slightly different way of
describing exactly the same thing.
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.