annotate parser.yy @ 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 // Infix notation calculator.
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3 %{
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 #define YYSTYPE double
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 #include <iostream>
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
8 #include <string>
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 #include <cctype>
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11 #include <cmath>
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 #include <cstdio>
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
14 #include "interpreter.h"
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 #include "main.h"
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16 #include "gui-main.h"
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 #include "tty-main.h"
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
18 #include "parser.h"
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
20 namespace parser
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 {
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22 FILE *outfile = 0;
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 size_t bufptr = 0;
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 size_t chunk_size = 0;
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
1
08df60a01bc1 debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents: 0
diff changeset
26 const char *buf;
08df60a01bc1 debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents: 0
diff changeset
27 bool beg_of_stmt = true;
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 static int yylex (void);
1
08df60a01bc1 debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents: 0
diff changeset
30
08df60a01bc1 debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents: 0
diff changeset
31 static void debug_trace (const char *);
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 static void yyerror (char const *);
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35
6
1b575145197e interpreter is now a class instead of a namespace with functions
John W. Eaton <jwe@octave.org>
parents: 4
diff changeset
36 static void emit_error (const char *msg);
1b575145197e interpreter is now a class instead of a namespace with functions
John W. Eaton <jwe@octave.org>
parents: 4
diff changeset
37 static void emit_result (double value);
1b575145197e interpreter is now a class instead of a namespace with functions
John W. Eaton <jwe@octave.org>
parents: 4
diff changeset
38
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 %}
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 %define api.push-pull push
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 // Bison declarations.
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 %token NUM
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 %left '-' '+'
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 %left '*' '/'
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 %left NEG // negation--unary minus
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 %right '^' // exponentiation
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 %%
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 input : // empty
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 { }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 | input line
1
08df60a01bc1 debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents: 0
diff changeset
55 | error
08df60a01bc1 debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents: 0
diff changeset
56 {
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
57 parser::debug_trace ("ABORT");
1
08df60a01bc1 debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents: 0
diff changeset
58 YYABORT;
08df60a01bc1 debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents: 0
diff changeset
59 }
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 ;
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62 line : ';'
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63 { }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 | exp ';'
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 {
6
1b575145197e interpreter is now a class instead of a namespace with functions
John W. Eaton <jwe@octave.org>
parents: 4
diff changeset
66 emit_result ($1);
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
67 parser::beg_of_stmt = true;
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68 }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69 ;
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 exp : NUM
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 {
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
73 parser::debug_trace ("NUM");
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74 $$ = $1;
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
75 parser::beg_of_stmt = false;
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77 | exp '+' exp
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78 {
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
79 parser::debug_trace ("ADD");
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80 $$ = $1 + $3;
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
81 parser::beg_of_stmt = false;
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83 | exp '-' exp
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84 {
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
85 parser::debug_trace ("SUB");
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86 $$ = $1 - $3;
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
87 parser::beg_of_stmt = false;
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88 }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89 | exp '*' exp
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90 {
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
91 parser::debug_trace ("MUL");
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92 $$ = $1 * $3;
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
93 parser::beg_of_stmt = false;
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94 }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95 | exp '/' exp
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96 {
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
97 parser::debug_trace ("DIV");
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
98 $$ = $1 / $3;
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
99 parser::beg_of_stmt = false;
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
100 }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
101 | '-' exp %prec NEG
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
102 {
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
103 parser::debug_trace ("NEG");
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
104 $$ = -$2;
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
105 parser::beg_of_stmt = false;
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
106 }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
107 | exp '^' exp
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
108 {
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
109 parser::debug_trace ("EXP");
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
110 $$ = std::pow ($1, $3);
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
111 parser::beg_of_stmt = false;
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
112 }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
113 | '(' exp ')'
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
114 {
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
115 parser::debug_trace ("PAREN");
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
116 $$ = $2;
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
117 parser::beg_of_stmt = false;
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
118 }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
119 ;
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
120
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
121 %%
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
122
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
123 namespace parser
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
124 {
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
125 // The lexical analyzer returns a double floating point number on the
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
126 // stack and the token NUM, or the numeric code of the character read
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
127 // if not a number. It skips all blanks and tabs, and returns -1 for
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
128 // end-of-input.
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
129
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
130 static int yylex (void)
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
131 {
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
132 int c;
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
133
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
134 if (bufptr >= chunk_size)
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
135 return -1;
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
136
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
137 // Skip white space.
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
138 while ((c = buf[bufptr++]) == ' ' || c == '\t' || c == '\n')
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
139 ;
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
140
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
141 // Process numbers.
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
142 if (c == '.' || isdigit (c))
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
143 {
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
144 int chars_read = 0;
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
145 bufptr--;
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
146 sscanf (&buf[bufptr], "%lf%n", &yylval, &chars_read);
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
147 bufptr += chars_read;
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
148 return NUM;
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
149 }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
150
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
151 // Return a single char.
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
152 return c;
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
153 }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
154
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
155 static yypstate *ps = 0;
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
156
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
157 void init (void)
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
158 {
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
159 fini ();
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
160
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
161 ps = yypstate_new ();
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
162 }
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
163
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
164 void fini (void)
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
165 {
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
166 if (ps)
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
167 yypstate_delete (ps);
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
168
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
169 ps = 0;
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
170 }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
171
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
172 int parse_and_execute (const std::string& line)
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
173 {
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
174 bufptr = 0;
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
175 chunk_size = line.length ();
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
176 buf = line.c_str ();
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
177
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
178 int status;
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
179
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
180 do
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
181 {
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
182 ::yychar = yylex ();
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
183
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
184 if (::yychar < 0)
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
185 return -1;
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
186
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
187 status = yypush_parse (ps);
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
188 }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
189 while (status == YYPUSH_MORE);
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
190
1
08df60a01bc1 debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents: 0
diff changeset
191 return -2;
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
192 }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
193
1
08df60a01bc1 debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents: 0
diff changeset
194 void debug_trace (const char *msg)
08df60a01bc1 debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents: 0
diff changeset
195 {
08df60a01bc1 debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents: 0
diff changeset
196 if (calc::debug_mode)
08df60a01bc1 debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents: 0
diff changeset
197 std::cerr << msg << std::endl;
08df60a01bc1 debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents: 0
diff changeset
198 }
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
199 }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
200
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
201 static void yyerror (char const *msg)
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
202 {
6
1b575145197e interpreter is now a class instead of a namespace with functions
John W. Eaton <jwe@octave.org>
parents: 4
diff changeset
203 emit_error (msg);
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
204 }
6
1b575145197e interpreter is now a class instead of a namespace with functions
John W. Eaton <jwe@octave.org>
parents: 4
diff changeset
205
1b575145197e interpreter is now a class instead of a namespace with functions
John W. Eaton <jwe@octave.org>
parents: 4
diff changeset
206 static void emit_error (const char *msg)
1b575145197e interpreter is now a class instead of a namespace with functions
John W. Eaton <jwe@octave.org>
parents: 4
diff changeset
207 {
1b575145197e interpreter is now a class instead of a namespace with functions
John W. Eaton <jwe@octave.org>
parents: 4
diff changeset
208 calc::interpreter::the_interpreter->emit_error (msg);
1b575145197e interpreter is now a class instead of a namespace with functions
John W. Eaton <jwe@octave.org>
parents: 4
diff changeset
209 }
1b575145197e interpreter is now a class instead of a namespace with functions
John W. Eaton <jwe@octave.org>
parents: 4
diff changeset
210
1b575145197e interpreter is now a class instead of a namespace with functions
John W. Eaton <jwe@octave.org>
parents: 4
diff changeset
211 static void emit_result (double value)
1b575145197e interpreter is now a class instead of a namespace with functions
John W. Eaton <jwe@octave.org>
parents: 4
diff changeset
212 {
1b575145197e interpreter is now a class instead of a namespace with functions
John W. Eaton <jwe@octave.org>
parents: 4
diff changeset
213 calc::interpreter::the_interpreter->emit_result (value);
1b575145197e interpreter is now a class instead of a namespace with functions
John W. Eaton <jwe@octave.org>
parents: 4
diff changeset
214 }