gpt4 book ai didi

c++ - C++ 编译中有哪些不同的标记类型?

转载 作者:太空狗 更新时间:2023-10-29 20:29:07 24 4
gpt4 key购买 nike

Walter Bright 的 C++ Compilation 文章谈到了这两个词组

“转换为预处理标记。”
什么是初始 token ?预处理 token 是什么样的?

“预处理标记到 C++ 标记的转换”这个 C++ Token 是什么,为什么一开始不转换成它?

引用:http://www.drdobbs.com/blogs/cpp/228701711

最佳答案

预处理标记是预处理器语法的一个元素。来自 C++ 标准中的 [lex.pptoken]:

preprocessing-token:

  • header-name
  • identifier
  • pp-number
  • character-literal
  • user-defined-character-literal
  • string-literal
  • user-defined-string-literal
  • preprocessing-op-or-punc
  • each non-white-space character that cannot be one of the above

...

A preprocessing token is the minimal lexical element of the language in translation phases 3 through 6.

所以“转换为预处理标记”是对翻译单元进行词法分析和识别单个标记的过程。

C++ 标记(实际上只是“标记”)在 [lex.token] 中列出:

token:

  • identifier
  • keyword
  • literal
  • operator
  • punctuator

这些仅在所有其他翻译阶段(宏扩展等)发生后才存在。

有关整个过程的更多信息,我建议阅读 C++ 标准中的 [lex.phases]。

关于c++ - C++ 编译中有哪些不同的标记类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11074073/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com