No Clock  1.0.2

Get properties of an expression. More...

Functions

bool expression_get_boolean (const expression *e)
 Get an expression's boolean. More...
 
const char * expression_get_identifier (const expression *e)
 Get an expression's identifier. More...
 
expression * expression_get_left (const expression *e)
 Get an expression's left operand. More...
 
long int expression_get_number (const expression *e)
 Get an expression's number. More...
 
expression * expression_get_right (const expression *e)
 Get an expression's right operand. More...
 
expression_type expression_get_type (const expression *e)
 Get an expression's type. More...
 
bool expression_is_boolean (const expression *e)
 Determine whether an expression is a boolean expression. More...
 
bool expression_is_false (const expression *e)
 Determine whether an expression is false. More...
 
bool expression_is_identifier (const expression *e)
 Determine whether an expression is an identifier. More...
 
bool expression_is_number (const expression *e)
 Determine whether an expression is a number expression. More...
 
bool expression_is_one (const expression *e)
 Determine whether an expression is 1. More...
 
bool expression_is_true (const expression *e)
 Determine whether an expression is true. More...
 
bool expression_is_zero (const expression *e)
 Determine whether an expression is 0. More...
 

Detailed Description

Get properties of an expression.

Since
version 1.0.0

Expression type inspection

The type of an expression can and should be inspected using expression_get_type().

Constant expressions have dedicated inspection functions:

Number expressions

If an expression is a number, it is possible to:

Boolean expressions

If an expression is a boolean value, it is possible to:

Other expressions

For identifier expressions, the identifier can be obtained with expression_get_identifier().

The left and right operands of a binary operation can be obtained with expression_get_left() and expression_get_right().

Warning
Please note that it is only safe to use the appropriate getter(s) on an expression:
Expression type Appropriate getter(s)
EXPR_NUMBER expression_get_number()
EXPR_TRUE expression_get_boolean()
EXPR_FALSE expression_get_boolean()
EXPR_ID expression_get_identifier()
EXPR_NOT expression_get_left()
EXPR_NEG expression_get_left()
other types != EXPR_UNKNOWN expression_get_left(), expression_get_right()

Function Documentation

bool expression_get_boolean ( const expression *  e)
related

Get an expression's boolean.

Since
version 1.0.0
Parameters
eExpression of interest.
Returns
Boolean.
const char * expression_get_identifier ( const expression *  e)
related

Get an expression's identifier.

Since
version 1.0.0
Parameters
eExpression of interest.
Returns
Identifier.
expression * expression_get_left ( const expression *  e)
related

Get an expression's left operand.

Since
version 1.0.0
Parameters
eExpression of interest.
Returns
Left operand.
long int expression_get_number ( const expression *  e)
related

Get an expression's number.

Since
version 1.0.0
Parameters
eExpression of interest.
Returns
Number.
expression * expression_get_right ( const expression *  e)
related

Get an expression's right operand.

Since
version 1.0.0
Parameters
eExpression of interest.
Returns
Right operand.
expression_type expression_get_type ( const expression *  e)
related

Get an expression's type.

Since
version 1.0.0
Parameters
eExpression of interest.
Returns
The expression's type.
bool expression_is_boolean ( const expression *  e)
related

Determine whether an expression is a boolean expression.

Since
version 1.0.0
Parameters
eExpression of interest.
Return values
trueif the expression is a boolean.
falseotherwise.
bool expression_is_false ( const expression *  e)
related

Determine whether an expression is false.

Since
version 1.0.0
Parameters
eExpression of interest.
Return values
trueif the expression is true.
otherwise.
bool expression_is_identifier ( const expression *  e)
related

Determine whether an expression is an identifier.

Since
version 1.0.0
Parameters
eExpression of interest.
Return values
trueif the expression is an identifier.
falseotherwise.
bool expression_is_number ( const expression *  e)
related

Determine whether an expression is a number expression.

Since
version 1.0.0
Parameters
eExpression of interest.
Return values
trueif the expression is a number.
falseotherwise.
bool expression_is_one ( const expression *  e)
related

Determine whether an expression is 1.

Since
version 1.0.0
Parameters
eExpression of interest.
Return values
trueif the expression is 1.
otherwise.
bool expression_is_true ( const expression *  e)
related

Determine whether an expression is true.

Since
version 1.0.0
Parameters
eExpression of interest.
Return values
trueif the expression is true.
otherwise.
bool expression_is_zero ( const expression *  e)
related

Determine whether an expression is 0.

Since
version 1.0.0
Parameters
eExpression of interest.
Return values
trueif the expression is 0.
otherwise.