我尝试搜索C99规范,但“:”匹配每一个页面,“冒号”没有找到每一个用法.同样的,通过玩具C parsers(我明白lex / yacc aren’t capable的解析C),我似乎只是找到部分结果.@H_403_3@
这些是我知道使用冒号的场景:@H_403_3@
解决方法
6.4.6 Punctuators
….@H_403_3@3 In all aspects of the language,the six tokens@H_403_3@
<:
:>
<%
%>
%:
%:%:
@H_403_3@behave,respectively,the same as the six tokens 79)@H_403_3@
[
]
{
}
#
##
@H_403_3@except for their spelling.80)@H_403_3@
79) These tokens are sometimes called ‘‘digraphs’’.@H_403_3@
80) Thus
[
and<:
behave differently when ‘‘stringized’’ (see 6.10.3.2),but can otherwise be freely interchanged.@H_403_3@
作为附注,C标准阐述了以下术语:@H_403_3@
The term “digraph” (token consisting of two characters) is not
perfectly descriptive,since one of the alternative preprocessing-tokens is%:%:
and of course several primary tokens contain two
characters. Nonetheless,those alternative tokens that aren’t lexical keywords are colloquially known as “digraphs”.@H_403_3@
根据Digraphs and trigraphs:@H_403_3@
In 1994 a normative amendment to the C standard,included in C99,supplied digraphs as more readable alternatives to five of the trigraphs. ….@H_403_3@
Unlike trigraphs,digraphs are handled during tokenization,and any digraph must always represent a full token by itself,or compose the token
%:%:
replacing the preprocessor concatenation token##
. If a digraph sequence occurs inside another token,for example a quoted string,or a character constant,it will not be replaced.@H_403_3@