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 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.
In addition to the C89 punctuators and preprocessing tokens, C++ increases
the number of legal tokens for a punctuator or preprocessing token to include
the C and C++ operators. A punctuator that specifies an operation to be
performed is known as an operator. C++ allows the following
tokens, which include preprocessing tokens that are converted by the
preprocessor into tokens for operators and punctuators:
. | -> | ++ | -- | .* | ->* |
& | + | - | ~ | ! | :: |
/ | % | << | >> | new | delete |
< | > | <= | >= | == | != |
^ | | | && | || | ? | |
*= | /= | %= | += | -= | |
<<= | >>= | &= | ^= | |= | ## |
<: | :> | <% | %> | %: | %:%: |
and | and_eq | bitand | bitor | comp | |
not | not_eq | or | or_eq | xor | xor_eq |
Related References
C and C++ provide alternative representations for some operators and
punctuators. The following table lists the operators and punctuators
and their alternative representation:
Operator or Punctuator | Alternative Representation |
---|---|
{ | <% |
} | %> |
[ | <: |
] | :> |
# | %: |
## | %:%: |
&& | and |
| | bitor |
|| | or |
^ | xor |
~ | compl |
& | bitand |
&= | and_eq |
|= | or_eq |
^= | xor_eq |
! | not |
!= | not_eq |
Related References
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.