cond method
Evaluates a condition expression, returns bool. Returns false on failure.
Implementation
bool cond(String expr) {
if (expr.isEmpty) return false;
lastError = ''; // clears the previous error before every evaluation
_p.expression = expr;
if (_p.analyzeExpression()) {
final v = _p.value;
if (v == null) return false;
if (v is bool) return v;
if (v is num) return v != 0;
if (v is String) {
final s = v.toLowerCase();
return s == 'true' || s == '1' || s == 'y';
}
return false;
}
lastError = '[ERROR] $expr # ${_p.error}';
return false;
}