54 inline bool isWS(
const char *source,
int start,
int end)
56 for (
int i = start; i < end; ++i)
57 if (source[i] !=
'\n')
66 using Comments = std::vector<std::pair<int, int>>;
68 const std::string &s = expr.
getExpr();
71 for (
const auto &i : comments) {
73 return s.substr(i.first, i.second - i.first + 1);
82 , _val(dynamic_cast<const
ExprNumNode *>(node.child(0))->value())
86 if (comment.find(
'.') != std::string::npos || comment.find(
'e') != std::string::npos) {
109 std::stringstream ss;
128 , _val(
Vec3d(dynamic_cast<const
ExprNumNode *>(node.child(0)->child(0))->value(), dynamic_cast<const
ExprNumNode *>(node.child(0)->child(1))->value(), dynamic_cast<const
ExprNumNode *>(node.child(0)->child(2))->value()))
132 if (comment.find(
'.') != std::string::npos || comment.find(
'e') != std::string::npos) {
147 std::stringstream ss;
163 int num = cnode->numChildren();
164 for (
int i = 1; i < num - 2; i += 3) {
185 std::stringstream ss;
188 <<
"curve(" << _lookupText;
189 int num = _vec.size();
190 for (
int i = 0; i < num; ++i)
191 ss << _vec[i]._pos << _vec[i]._val << (
int)_vec[i]._interp;
207 ExprCcurveAssignSpec::
215 int num = cnode->numChildren();
216 for(
int i = 1; i < num - 2; i += 3)
217 if(
dynamic_cast<const ExprNumNode*
>(cnode->child(i+1)))
225 ExprCcurveAssignSpec::toString()
const
227 std::stringstream ss;
233 int num = _vec.size();
234 for(
int i = 0; i < num; ++i)
240 << (
int)_vec[i]._interp;
246 const ExprCcurveAssignSpec*
247 ExprCcurveAssignSpec::match(
const ExprNode* node)
250 return new ExprCcurveAssignSpec(*assign);
260 std::stringstream ss;
288 if (type ==
"string")
290 else if (type ==
"file")
292 else if (type ==
"directory")
Generic Expression control specification.
std::string _name
Name of control.
InterpType
Supported interpolation types.
Node that compute a local variable assignment.
const std::string & name() const
Curve assignment expression. Assignment of curve to a variable.
std::string toString() const override
Generates a replacement string based on changes to the spec.
static const ExprCurveAssignSpec * match(const ExprNode *node)
std::string _lookupText
Lookup subexpression text.
std::vector< typename Curve< T >::CV > _vec
Control points of curve spline.
ExprCurveAssignSpec(const ExprAssignNode &node)
Node that calls a function.
const Expression * expr() const
Access expression.
unsigned short int endPos() const
Access end position in input string.
const ExprNode * child(size_t i) const
Get 0 indexed child.
Node that stores a numeric constant.
Variable equals scalar control specification.
static const ExprScalarAssignSpec * match(const ExprNode *node)
ExprScalarAssignSpec(const ExprAssignNode &node)
double _min
Range of values.
std::string toString() const override
Generates a replacement string based on changes to the spec.
Node that stores a string.
static const ExprStrSpec * match(const ExprNode *node)
ExprStrSpec(const ExprStrNode &node, const char *name, Type type)
Takes name and type comments and takes ownership of them!
std::string toString() const override
Generates a replacement string based on changes to the spec.
Variable equals vector control specification.
std::string toString() const override
Generates a replacement string based on changes to the spec.
static const ExprVectorAssignSpec * match(const ExprNode *node)
double _min
Range of values.
const Vec3d & value() const
ExprVectorAssignSpec(const ExprAssignNode &node)
const std::vector< std::pair< int, int > > & getComments() const
const std::string & getExpr() const
Get the string that this expression is currently set to evaluate.
bool examine(const ExprNode *examinee) override
std::vector< const ControlSpec * >::const_iterator end() const
std::vector< const ControlSpec * > _specList
std::vector< const ControlSpec * >::const_iterator begin() const
bool parseRangeComment(const std::string &comment, double &from, double &to)
bool parseTypeNameComment(const std::string &comment, std::string &type, std::string &name)
bool isWS(const char *source, int start, int end)
Returns true if no newline separates comment and node.
const ExprAssignNode * isCurveAssign(const ExprNode *testee)
const ExprAssignNode * isVectorAssign(const ExprNode *testee)
const ExprAssignNode * isCcurveAssign(const ExprNode *testee)
const ExprStrNode * isString(const ExprNode *testee)
std::string findComment(const ExprNode &node)
Checks if there is whitespace in the range specified in the string.
const ExprAssignNode * isScalarAssign(const ExprNode *testee)