Punctuators

A punctuator is a token that has syntactic and semantic meaning to the compiler, but the exact significance depends on the context. A punctuator can also be a token that is used in the syntax of the preprocessor. At the C89 language level, a punctuator does not cause an action. For example, a comma is a punctuator in an argument list or in an initializer list, but is an operator when used within a parenthesized expression.

At the C89 language level, a punctuator can be a character that separates tokens, such as:

[     ]
(     )
{     }
, : ;

or any of the following:

* = ... #    

C89 restricts the use of the number sign # to preprocessor directives only.

At the C99 language level, the number of legal tokens for a punctuator or preprocessing token increases to include the C operators. A punctuator that specifies an operation to be performed is known as an operator. This distinction between a punctuator and operator is also used by C++. In addition to the C89 punctuators, C99 defines the following tokens as punctuators, operators, or preprocessing tokens:

. -> ++ -- ##  
& + - ~ !  
/ % << >> !=  
< > <= >= ==  
^ | && || ?  
*= /= %= += -=  
<<= >>= &= ^= |=  
<: :> <% %> %: %:%:

C++ In addition to the C99 preprocessing tokens, operators, and punctuators, C++ allows the following tokens as punctuators:

:: .* ->* new delete  
and and_eq bitand bitor comp  
not not_eq or or_eq xor xor_eq

Related References

IBM Copyright 2003