-
Notifications
You must be signed in to change notification settings - Fork 552
Expand file tree
/
Copy pathdebugtool.cpp
More file actions
35 lines (30 loc) · 1.05 KB
/
debugtool.cpp
File metadata and controls
35 lines (30 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//-----------------------------------------------------------------------------
// Our entry point for exposing various internal mechanisms.
//
// Copyright 2017 whitequark
//-----------------------------------------------------------------------------
#include "expr.h"
#include "platform/platform.h"
using namespace SolveSpace;
int main(int argc, char **argv) {
std::vector<std::string> args = Platform::InitCli(argc, argv);
if(args.size() == 3 && args[1] == "expr") {
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());
}
Platform::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;
}