我应该考虑'\f', '\v'吗?作为 .c 文件中的换行符?

发布于 2025-01-11 05:35:04 字数 341 浏览 2 评论 0 原文

我正在尝试使用 flex 制作一个 C 程序词法分析器。

我读了 https://en.cppreference.com/w/c/language/translation_phases< /a> 并被告知垂直制表符 \v 和换页符 \f 在行组合和分解阶段之前保留。

我是否应该将它们视为换行符,就像 \n 一样?

期待任何答复,谢谢。

I am trying to make a C program lexical analyzer using flex.

I read https://en.cppreference.com/w/c/language/translation_phases and was told that vertical tab \v and form feed \f is kept before the line-combining and the decomposing phases.

Should I consider them as newlines characters just like \n?

looking forward to any reply, thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

琉璃梦幻 2025-01-18 05:35:04

C 标准在第 5.1.1.2 章“翻译阶段”中对第 3 阶段说:

  • 源文件被分解为预处理标记和空白字符序列(包括注释)。 [...] 是否保留除换行符之外的每个非空空白字符序列或将其替换为一个空格字符是实现定义的。
  • 由于 \v\f 是空白字符,因此您可以自行决定是否将它们替换为单个空格。但您不应该用换行符替换它们。

    The C standard says in chapter 5.1.1.2 "Translation phases" for phase 3:

    1. The source file is decomposed into preprocessing tokens and sequences of white-space characters (including comments). [...] Whether each nonempty sequence of white-space characters other than new-line is retained or replaced by one space character is implementation-defined.

    Since \v and \f are white-space characters, it is up to you to replace them with a single space or not. But you should not replace them with new-lines.

    ~没有更多了~
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文