Home > Mobile >  Should I consider '\f', '\v' as newline characters in .c file?
Should I consider '\f', '\v' as newline characters in .c file?

Time:03-03

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.

CodePudding user response:

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.

  • Related