我们可以使用 GCC 来处理 C 项目的翻译阶段 1..5

Can we use GCC to process translation phases 1..5 for C project

我正在尝试使用 ANSI C Lex and Yacc 语法来解析我的 C 项目。 在该语法的描述中,它需要

It is assumed that translation phases 1..5 have already been completed, including preprocessing and _Pragma processing. The Lex rule for string literals will perform concatenation (translation phase 6). Transliteration of universal character names (\uHHHH or \UHHHHHHHH) must have been done by either the preprocessor or a replacement for the input() macro used by Lex (or the YY_INPUT function used by Flex) to read characters.

如何使用 GCC 处理翻译阶段 1..5?

How can I use GCC to process translation phases 1..5?

最接近的 GCC 提供的是它的 -E 选项,这会导致它停止 "after the preprocessing stage" 并将结果发送到标准输出。

GCC 的预处理阶段至少与 C 的抽象翻译模型中的翻译阶段 4 大致一致,但我无法证明 gcc -E 的输出是否 完全匹配 什么人们应该期待第 1-4 阶段的结果。如果是这样,那么只有当源字符集不同于执行字符集 and 源包含至少一个这些集合映射不同的字符。