ConstantExpression

Handles the Python interpretation of a constant-expression. See ISO/IEC 14882:1998(E)

class cpip.core.ConstantExpression.ConstantExpression(theTokTypeS)

Class that interpret a stream of pre-processing tokens (cpip.core.PpToken.PpToken objects) and evaluate it as a constant expression.

__init__(theTokTypeS)

Constructor takes a list pf PpToken.

Parameters:theTokTypeS (list([cpip.core.PpToken.PpToken])) – List of tokens.
Returns:NoneType
__weakref__

list of weak references to the object (if defined)

_evaluateConditionalExpression(theMatch)

Evaluates a conditional expression e.g. expr ? t : f Which we convert with a regular expression to:

if exp:
    t
else:
    f
_evaluateExpression(theStr)

Evaluates a conditional expression e.g. 1 < 2

Parameters:theStr (str) – The string to evaluate in the Pythoin environment.
Returns:int – Result of eval(), 0 is success.
Raises:ExceptionEvaluateExpression on failure.
evaluate()

Evaluates the constant expression and returns 0 or 1.

Returns:int – Result of eval(), 0 is success.
Raises:ExceptionEvaluateExpression on failure.
translateTokensToString()

Returns a string to be evaluated as a constant-expression.

ISO/IEC ISO/IEC 14882:1998(E) 16.1 Conditional inclusion sub-section 4 i.e. 16.1-4

All remaining identifiers and keywords 137) , except for true and false, are replaced with the pp-number 0

Returns:str – Result.
exception cpip.core.ConstantExpression.ExceptionConditionalExpression

Exception when conditional expression e.g. ... ? ... : ... fails to evaluate.

exception cpip.core.ConstantExpression.ExceptionConditionalExpressionInit

Exception when initialising a ConstantExpression class.

exception cpip.core.ConstantExpression.ExceptionConstantExpression

Simple specialisation of an exception class for the ConstantExpression classes.

exception cpip.core.ConstantExpression.ExceptionEvaluateExpression

Exception when conditional expression e.g. 1 < 2 fails to evaluate.