2017-02-12 14:21:58 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Our entry point for exposing various internal mechanisms.
|
|
|
|
//
|
|
|
|
// Copyright 2017 whitequark
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
#include "solvespace.h"
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
std::vector<std::string> args = InitPlatform(argc, argv);
|
|
|
|
|
|
|
|
if(args.size() == 3 && args[1] == "expr") {
|
2017-02-17 02:50:00 +00:00
|
|
|
std::string expr = args[2], err;
|
|
|
|
Expr *e = Expr::Parse(expr.c_str(), &err);
|
|
|
|
if(e == NULL) {
|
|
|
|
fprintf(stderr, "cannot parse: %s\n", err.c_str());
|
|
|
|
} else {
|
|
|
|
fprintf(stderr, "%g\n", e->Eval());
|
|
|
|
}
|
2017-02-12 14:21:58 +00:00
|
|
|
FreeAllTemporary();
|
|
|
|
} else {
|
|
|
|
fprintf(stderr, "Usage: %s <command> <options>\n", args[0].c_str());
|
|
|
|
//-----------------------------------------------------------------------------> 80 col */
|
|
|
|
fprintf(stderr, R"(
|
|
|
|
Commands:
|
|
|
|
expr [expr]
|
|
|
|
Evaluate an expression.
|
|
|
|
)");
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|