英文:
Are identifiers separate tokens only in select cases?
问题
> 1. 词法陷阱:
>
> 举个例子,考虑以下语句:
if (x < big) big = x; 
> 这个语句中的每个非空白字符都是一个单独的标记,
> 除了 if 关键字和标识符 big 的两个实例之外。
>
> 实际上,C程序会被分为两次标记...
— 来自《C陷阱与技巧》(C Traps and Pitfalls, Andrew Koenig)。
英文:
> 1. Lexical Pitfalls:
>
> For another example, consider this statement:
if (x < big) big = x; 
>Each non-blank character in this statement is a separate token,
> except for the if keyword and the two instances of the identifier big.
>
> In fact, C programs are broken into tokens twice....
— From C Traps and Pitfalls, Andrew Koenig.
My question is: Why is the if keyword and the two instances of the identifier big not separate tokens? What are they?
答案1
得分: 2
这段文字的意思是:“这个表达式中的每个字符都是一个标记,除了用于形成 if 和 big 的字符。” 对于 if,if 是一个标记,但分别不包括字符 i 和 f。
也就是说,这个表达式由以下标记组成:if、(、x、<、big、)、big、=、x、;。
英文:
The text means to say "every character in this expression is a token, except the characters used to form if and big". In case of if then if is a token, but not the characters i and f respectively.
That is, this expression consists of the tokens if, (, x, <, big, ), big, =, x, ;.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论