In the reference manual of K&R2 (2) 
Author Message
 In the reference manual of K&R2 (2)

Hi...

I hope that these questions is the final questions about
the reference manual of K&R2. ^^

[1] A12.20 Predefined Names (p.233)

 "They (Predefined Names), and also the prepocessor expression operator
  'defined', may not be undefined or redefined."

 Here, I can't understand that 'defined' may not be undefined or
 redefined. 'defined' is the operator, is it natural not to be able
 to undefine or redefine that? Does it mean that I may not use
 'defined' as macro name? or what?

[2] A13. Grammer (p.234)

 "Besides adding whatever syntactic marking is used to indicate
  alternatives in productions, it is necessary to expand the "one of"
  constructions, and (depending on the rules of the parser-generator)
  to duplicate each production with an 'opt' symbol, once with the
  symbol and once without."

 Plz give me more explanation and practice.

[3] A13. Grammer (p.234)

 "It has only one conflict, generated by the if-else ambiguity."

 I have already known the if-else ambiguity, but I can't understand
 that the grammer produced in A13 has a conflict.

[4] A13. Grammer (p.238)

 "It includes the symbol 'text', which means ordinary program text,
  non-conditional preprocessor control lines, or complete preprocessor
  conditional constructions."

 What are the complete preprocessor conditional constructions?
 Does it mean that the 'text' could have the nested conditional
 constructions?

[5] 'conrol line' and 'preprocessor line'

 The reference manual of K&R uses the term "preprocessor line"
 and "control line". I think they have the same meaning.
 Is there the difference between them?

Thanks...

                                               Jun Woong



Thu, 22 Aug 2002 03:00:00 GMT  
 In the reference manual of K&R2 (2)


Quote:
> Hi...

> I hope that these questions is the final questions about
> the reference manual of K&R2. ^^

> [1] A12.20 Predefined Names (p.233)

>  "They (Predefined Names), and also the prepocessor expression operator
>   'defined', may not be undefined or redefined."

>  Here, I can't understand that 'defined' may not be undefined or
>  redefined. 'defined' is the operator, is it natural not to be able
>  to undefine or redefine that? Does it mean that I may not use
>  'defined' as macro name? or what?

No, that would not be natural, no more than being able to undefine or
redefine other preprocessor facilities such as #if.  It does mean that you
cannot use 'defined' as a macro name.

It's hard to imagine how you could usefully re-define 'defined' in such a
way that preprocessor directive that use it would still work.  Simple
example of very common usage of 'defined':

#if (defined(HITACHI) || defined(ARM)) /* platform-specific stuff follows */
[...]
#else /* some other platform */
[...]
#endif

I can't think of anything you could substitute for 'defined' in the above
code such that it would still be valid.



Thu, 22 Aug 2002 03:00:00 GMT  
 In the reference manual of K&R2 (2)

Quote:

>Hi...

>I hope that these questions is the final questions about
>the reference manual of K&R2. ^^

>[1] A12.20 Predefined Names (p.233)

> "They (Predefined Names), and also the prepocessor expression operator
>  'defined', may not be undefined or redefined."

> Here, I can't understand that 'defined' may not be undefined or
> redefined. 'defined' is the operator, is it natural not to be able
> to undefine or redefine that? Does it mean that I may not use
> 'defined' as macro name? or what?

It means that you can't do things like this:

#undef defined
#define defined(x) 1

Yes, it's natural that you shouldn't be able to undefine or redefine
"defined", and the language definition is just being explicit about
forbidding this.  The C90 ISO standard is perhaps a bit clearer about this.
It says [6.8.8] "None of these macro names, nor the identifier defined,
shall be the subject of a #define or a #undef preprocessing directive."
"These macro names" refers to the names __LINE__, __FILE__, __DATE__,
__TIME__, and __STDC__, meaning that you can't do things like

#undef __LINE__
#define __DATE__ "Feb 29 2000"
--



Fri, 23 Aug 2002 03:00:00 GMT  
 In the reference manual of K&R2 (2)


Quote:
> Hi...

> I hope that these questions is the final questions about
> the reference manual of K&R2. ^^

> [1] A12.20 Predefined Names (p.233)

>  "They (Predefined Names), and also the prepocessor expression operator
>   'defined', may not be undefined or redefined."

>  Here, I can't understand that 'defined' may not be undefined or
>  redefined. 'defined' is the operator, is it natural not to be able
>  to undefine or redefine that? Does it mean that I may not use
>  'defined' as macro name? or what?

'natural' isn't an option.

It means that `#define defined` and `#undef defined` are both illegal.

Quote:
> [2] A13. Grammer (p.234)

>  "Besides adding whatever syntactic marking is used to indicate
>   alternatives in productions, it is necessary to expand the "one of"
>   constructions, and (depending on the rules of the parser-generator)
>   to duplicate each production with an 'opt' symbol, once with the
>   symbol and once without."

>  Plz give me more explanation and practice.

If you want to feed their grammar to a parser-generator, then you will
have to expand the notations it likely doesn't understand.

Thus a rule that says

    spoo ::= one of a, b, c, d, e, f

will become one that says

    spoo ::= a | b | c | d | e | f

(or, if this is lexical rather than syntactic, may get moved to your
"tokens" section. If you don't understand what I'm talking about, you
probably don't need to know.)

Quote:
> [3] A13. Grammer (p.234)

>  "It has only one conflict, generated by the if-else ambiguity."

>  I have already known the if-else ambiguity, but I can't understand
>  that the grammer produced in A13 has a conflict.

There's a LALR shift-reduce conflict. If you don't know what that
means, then you probably don't *need* to know. (It's just the way
an LR parser-generator such as yacc notices the ambiguity.)

Quote:
> [4] A13. Grammer (p.238)

>  "It includes the symbol 'text', which means ordinary program text,
>   non-conditional preprocessor control lines, or complete preprocessor
>   conditional constructions."

>  What are the complete preprocessor conditional constructions?

#if ... #endif

Quote:
>  Does it mean that the 'text' could have the nested conditional
>  constructions?

yes.

--
Chris "electric hedgehog" Dollin
C FAQs at: http://www.faqs.org/faqs/by-newsgroup/comp/comp.lang.c.html



Sat, 24 Aug 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. In the reference manual of K&R2

2. K&R1 vs. K&R2

3. clcm: Looking for a better C reference manual

4. need good reference manual

5. ->C A Reference Manual

6. FS: C answer book, C reference manual, C standard library

7. Borland C 3.0/3.1 Library Reference Manual wanted

8. looking for nonANSI C reference manual

9. ANSI C Library reference manual online?

10. Best Online Reference Manual

11. About C (not C++) reference manuals

12. zipped Gnu C Library Reference manual

 

 
Powered by phpBB® Forum Software