File: r1.cpp

package info (click to toggle)
libmath%2B%2B 0.0.4-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 488 kB
  • ctags: 233
  • sloc: cpp: 1,311; makefile: 49; sh: 17
file content (30 lines) | stat: -rw-r--r-- 715 bytes parent folder | download | duplicates (4)
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

#include <math++/nodes.h>
#include <math++/reader.h>
#include <math++/printer.h>

#include <iostream>
#include <memory>

int main(int argc, char *argv[]) {
    std::cout << "Expression Reader example program (r1)" << std::endl;

    try {
        std::string exprStr(argc == 2 ? argv[1] : "2 + 3 * 4");

        std::auto_ptr<math::TNode<double> >expr(math::TReader<double>::parse(exprStr));

        std::cout << "reproduction: "
                  << math::TPrinter<double>::print(expr.get())
                  << std::endl;

    } catch (const math::EMath& e) {
        std::cout << "exception caught: " << e.reason() << std::endl;

        return 1;
    } catch (...) {
        return 1;
    }

    return 0;
}