PpTokenCount

Keeps a count of Preprocessing tokens.

exception cpip.core.PpTokenCount.ExceptionPpTokenCount

Exception when handling PpTokenCount object.

exception cpip.core.PpTokenCount.ExceptionPpTokenCountStack

Exception when handling PpTokenCountStack object.

class cpip.core.PpTokenCount.PpTokenCount

Maps of {token_type : integer_count, ...} self._cntrTokAll is all tokens.

__iadd__(other)

In-place add of the contents of another PpTokenCount object.

__weakref__

list of weak references to the object (if defined)

inc(tok, isUnCond, num=1)

Increment the count. tok is a PpToken, isUnCond is a boolean that is True if this is not conditionally compiled. num is the number of tokens to increment.

tokenCount(theType, isAll)

Returns the token count of a particular type. If isAll is true then the count of all tokens is returned, if False the count of unconditional tokens is returned.

tokenCountNonWs(isAll)

Returns the token count of a particular type. If isAll is true then the count of all tokens is returned, if False the count of unconditional tokens is returned.

tokenTypesAndCounts(isAll, allPossibleTypes=True)

Generator the yields (type, count) in PpToken.LEX_PPTOKEN_TYPES order where type is a string and count an integer.

If isAll is true then the count of all tokens is returned, if False the count of unconditional tokens is returned.

If allPossibleTypes is True the counts of all token types are yielded even if zero, if False then only token types encountered will be yielded i.e. all counts will be non-zero.

totalAll

The total token count.

totalAllConditional

The token count of conditional tokens.

totalAllUnconditional

The token count of unconditional tokens.

class cpip.core.PpTokenCount.PpTokenCountStack

This simply holds a stack of PpTokenCount objects that can be created and popped of the stack.

__init__()

ctor with empty stack.

__weakref__

list of weak references to the object (if defined)

close()

Finalisation, will raise a ExceptionPpTokenCountStack if there is anything on the stack.

counter()

Returns a reference to the current PpTokenCount object.

pop()

Pops the current PpTokenCount object off the stack and returns it.

push()

Add a new counter object to the stack.

Previous topic

PpToken

Next topic

PpTokeniser

This Page