comparison tty-main.cpp @ 6:1b575145197e

interpreter is now a class instead of a namespace with functions
author John W. Eaton <jwe@octave.org>
date Thu, 23 May 2019 07:41:18 -0400
parents 0e154787183d
children 822a2fe5bb51
comparison
equal deleted inserted replaced
5:54edd85237ab 6:1b575145197e
21 << "Example Calculator.\n" 21 << "Example Calculator.\n"
22 << "Available operations: + - * / ^ ()\n" 22 << "Available operations: + - * / ^ ()\n"
23 << "Semicolon terminates statement.\n" 23 << "Semicolon terminates statement.\n"
24 << "GNU Readline available for history editing.\n" << std::endl; 24 << "GNU Readline available for history editing.\n" << std::endl;
25 25
26 interpreter::init (); 26 calc::interpreter interp;
27 27
28 for (;;) 28 for (;;)
29 { 29 {
30 char *tmp = readline (parser::beg_of_stmt ? ">> " : ""); 30 char *tmp = readline (parser::beg_of_stmt ? ">> " : "");
31 31
40 40
41 std::string line = tmp; 41 std::string line = tmp;
42 42
43 free (tmp); 43 free (tmp);
44 44
45 int status = interpreter::parse_and_execute (line); 45 int status = interp.parse_and_execute (line);
46 46
47 if (status < 0) 47 if (status < 0)
48 break; 48 break;
49 } 49 }
50
51 interpreter::fini ();
52 50
53 return 0; 51 return 0;
54 } 52 }
55 53
56 void emit_result (double value) 54 void emit_result (double value)