How to write a Parser in C++

Concepts

Common Actions/Operations

C++ Elements

Skipping White Space

Manipulator std::ws extracts as many whitespace characters as possible from the current position in the input sequence. The extraction stops as soon as a non-whitespace character is found. These extracted whitespace characters are discarded.

Note: basic_istream objects have the skipws flag set by default: This applies a similar effect before the formatted extraction operations


Alternatively,

ios_base& skipws (ios_base& str);

sets the skipws format flag for the str stream.

When the skipws format flag is set, as many whitespace characters as necessary are read and discarded from the stream until a non-whitespace character is found before. This applies to every formatted input operation performed with operator>> on the stream.

Tab spaces, carriage returns and blank spaces are all considered whitespaces.

This flag can be unset with the noskipws manipulator, forcing extraction operations to consider leading whitepaces as part of the content to be extracted.

For standard streams, the skipws flag is set on initialization.