Next: Introducing Ternary Operators, Previous: Ternary Operator Definition, Up: Ternary Operators [Index]
A ternary operator named ‘$’‘~’ and evaluating as OPERAND1 * OPERAND2 ^ OPERAND3 for its real operands will be introduced by its leading binary operator definition:
See Binary Operator Definition Example.
const struct x1f4_operator_type def1lead { "$", NULL, 0224, 0, real2, X1f4_E4_E2ND_LINK, 1, NULL, &def1lead_ext };
See struct x1f4_operator_type.
The flags
field says the second extension is to be observed.
The function
and type
fields are not interpreted for ternaries
leading operator definition.
See Operator Flags.
The operator definition second extension introduced by its extension2
is:
const struct x1f4_2ndscope_type def1lead_ext = { X1f4_E4_RAIL_MARK | X1f4_E4_RAIL_ONLY, NULL, NULL, NULL, &def1trail };
See struct x1f4_2ndscope_type.
The flags
field says the operator is a ternary
(X1f4_E4_RAIL_MARK
) only (X1f4_E4_RAIL_ONLY
) one.
See Operator Second Extension Scope Flags.
Its rail
field introduces the trailing operator definition:
const struct x1f4_operator_type def1trail = { "~", NULL, 0224, X1f4_E4_REAL, real2, X1f4_E4_E2ND_LINK, 1, NULL, &def1trail_ext };
The flags
field says the second extension is to be observed.
No function is introduced by the operator, as one is to be introduced by the definition second extension:
const struct x1f4_2ndscope_type def1trail_ext = { 0, &def1line, NULL, NULL, NULL };
The line
field introduces the evaluating function, in the struct
x1f4_linetext_type
definition:
const struct x1f4_linetext_type def1line = { { "def1", def1function, X1f4_E4_REAL, real3, 3, 0, 4 }, NULL };
See struct x1f4_linetext_type.
The name
and length
fields are not interpreted when parsing or
evaluating expressions, but may be when printing them.
The function
field introduces the actual evaluating function:
int def1function(void *output, void **input) { X1f4_E4_REAL a, b, c, *out; a = *(X1f4_E4_REAL *) input[0]; b = *(X1f4_E4_REAL *) input[1]; out = output; *out = a * pow(b, c); return 0; }
The args
fields in the above definitions are:
int real2[] = { X1f4_E4_REAL, X1f4_E4_REAL };
and:
int real3[] = { X1f4_E4_REAL, X1f4_E4_REAL, X1f4_E4_REAL };
Next: Introducing Ternary Operators, Previous: Ternary Operator Definition, Up: Ternary Operators [Index]