PpWhitespace

Understands whitespacey things about source code character streams.

cpip.core.PpWhitespace.DEFINE_WHITESPACE = {'\t', '\n', ' '}

Whitespace characters that are significant in define statements ISO/IEC 14882:1998(E) 16-2 only ‘ ‘ and ‘t’ as ws

cpip.core.PpWhitespace.LEN_WHITESPACE_CHARACTER_SET = 5

Number of whitespace characters

cpip.core.PpWhitespace.LEX_NEWLINE = '\n'

Whitespace newline

cpip.core.PpWhitespace.LEX_WHITESPACE = {'\t', '\x0c', '\n', '\x0b', ' '}

Whitespace characters

class cpip.core.PpWhitespace.PpWhitespace

A class that does whitespacey type things in accordance with ISO/IEC 9899:1999(E) Section 6 and ISO/IEC 14882:1998(E).

hasLeadingWhitespace(theCharS)

Returns True if any leading whitespace, False if zero length or starts with non-whitespace.

isAllMacroWhitespace(theCharS)

“Return True if theCharS is zero length or only has allowable whitespace for preprocesing macros.

ISO/IEC 14882:1998(E) 16-2 only ‘ ‘ and ‘ ‘ as whitespace.

Parameters:theCharS (str) – The character string.
Returns:bool – True if empty or all DEFINE_WHITESPACE
isAllWhitespace(theCharS)

Returns True if the supplied string is all whitespace.

isBreakingWhitespace(theCharS)

Returns True if whitespace leads theChars and that whitespace contains a newline.

Parameters:theCharS (str) – The character string.
Returns:bool – True if there is a LEX_NEWLINE in the string.
preceedsNewline(theCharS)

Returns True if theChars ends with a newline. i.e. this immediately precedes a new line.

Parameters:theCharS (str) – String of characters.
Returns:bool – True if ends with a LEX_NEWLINE
sliceNonWhitespace(theBuf, theOfs=0)

Returns the length of non-whitespace characters that are in theBuf from position theOfs.

sliceWhitespace(theBuf, theOfs=0)

Returns the length of whitespace characters that are in theBuf from position theOfs.

Parameters:
  • theBuf (cpip.util.BufGen.BufGen, str) – Buffer or string.
  • theOfs (int) – Offset into the buffer.
Returns:

int – Number of whitespace characters.

Raises:

IndexError