annotate parser.yy @ 14:1e5a1e15fa56

clean up header files, more small readline changes
author John W. Eaton <jwe@octave.org>
date Thu, 23 May 2019 18:41:04 -0400
parents d179b0bb85e4
children
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
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
7 #include <string>
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 #include <cctype>
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 #include <cmath>
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11 #include <cstdio>
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12
4
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
13 #include "interpreter.h"
0e154787183d new interpreter and qt_interpreter objects
John W. Eaton <jwe@octave.org>
parents: 1
diff changeset
14 #include "parser.h"
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15
12
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
16 namespace calc
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 {
12
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
18 static void *create_parser_state (void);
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
19 static void delete_parser_state (void *);
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
20
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
21 parser::parser (interpreter& interp)
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
22 : m_interpreter (interp),
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
23 m_parser_state (create_parser_state ()),
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
24 m_beg_of_stmt (true)
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
25 { }
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
26
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
27 parser::~parser (void)
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
28 {
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
29 delete_parser_state (m_parser_state);
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
30 }
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
31
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
32 void parser::emit_error (const char *msg) const
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
33 {
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
34 m_interpreter.emit_error (msg);
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
35 }
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
36
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
37 void parser::emit_result (double value) const
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
38 {
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
39 m_interpreter.emit_result (value);
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
40 }
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42
12
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
43 static void yyerror (calc::parser&, char const *);
6
1b575145197e interpreter is now a class instead of a namespace with functions
John W. Eaton <jwe@octave.org>
parents: 4
diff changeset
44
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 %}
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46
12
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
47 %define api.pure full
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 %define api.push-pull push
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49
12
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
50 %parse-param {calc::parser& parser}
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
51
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 // Bison declarations.
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 %token NUM
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 %left '-' '+'
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 %left '*' '/'
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 %left NEG // negation--unary minus
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 %right '^' // exponentiation
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59 %%
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 input : // empty
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62 { }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63 | input line
1
08df60a01bc1 debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents: 0
diff changeset
64 | error
08df60a01bc1 debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents: 0
diff changeset
65 {
08df60a01bc1 debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents: 0
diff changeset
66 YYABORT;
08df60a01bc1 debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents: 0
diff changeset
67 }
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 line : ';'
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 { }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 | exp ';'
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73 {
12
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
74 parser.emit_result ($1);
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
75 parser.beg_of_stmt (true);
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 }
12
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
77 ;
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79 exp : NUM
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80 {
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81 $$ = $1;
12
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
82 parser.beg_of_stmt (false);
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83 }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84 | exp '+' exp
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85 {
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86 $$ = $1 + $3;
12
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
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 {
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91 $$ = $1 - $3;
12
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
92 parser.beg_of_stmt (false);
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93 }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94 | exp '*' exp
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95 {
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96 $$ = $1 * $3;
12
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
97 parser.beg_of_stmt (false);
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
98 }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
99 | exp '/' exp
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 $$ = $1 / $3;
12
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
102 parser.beg_of_stmt (false);
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
103 }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
104 | '-' exp %prec NEG
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
105 {
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
106 $$ = -$2;
12
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
107 parser.beg_of_stmt (false);
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
108 }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
109 | exp '^' exp
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
110 {
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
111 $$ = std::pow ($1, $3);
12
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
112 parser.beg_of_stmt (false);
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
113 }
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
114 | '(' exp ')'
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
115 {
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
116 $$ = $2;
12
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
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
12
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
123 namespace calc
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
13
d179b0bb85e4 make lexer a member function in parser class and eliminate some more global variables
John W. Eaton <jwe@octave.org>
parents: 12
diff changeset
130 int parser::lexer (double& token_value)
0
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
13
d179b0bb85e4 make lexer a member function in parser class and eliminate some more global variables
John W. Eaton <jwe@octave.org>
parents: 12
diff changeset
134 if (m_bufptr >= m_chunk_size)
0
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.
13
d179b0bb85e4 make lexer a member function in parser class and eliminate some more global variables
John W. Eaton <jwe@octave.org>
parents: 12
diff changeset
138 while ((c = m_buf[m_bufptr++]) == ' ' || c == '\t' || c == '\n')
0
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;
13
d179b0bb85e4 make lexer a member function in parser class and eliminate some more global variables
John W. Eaton <jwe@octave.org>
parents: 12
diff changeset
145 m_bufptr--;
d179b0bb85e4 make lexer a member function in parser class and eliminate some more global variables
John W. Eaton <jwe@octave.org>
parents: 12
diff changeset
146 sscanf (&m_buf[m_bufptr], "%lf%n", &token_value, &chars_read);
d179b0bb85e4 make lexer a member function in parser class and eliminate some more global variables
John W. Eaton <jwe@octave.org>
parents: 12
diff changeset
147 m_bufptr += chars_read;
0
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
12
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
155 int parser::parse_and_execute (const std::string& line)
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
156 {
13
d179b0bb85e4 make lexer a member function in parser class and eliminate some more global variables
John W. Eaton <jwe@octave.org>
parents: 12
diff changeset
157 m_bufptr = 0;
d179b0bb85e4 make lexer a member function in parser class and eliminate some more global variables
John W. Eaton <jwe@octave.org>
parents: 12
diff changeset
158 m_chunk_size = line.length ();
d179b0bb85e4 make lexer a member function in parser class and eliminate some more global variables
John W. Eaton <jwe@octave.org>
parents: 12
diff changeset
159 m_buf = line.c_str ();
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
160
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
161 int status;
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
162
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
163 do
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
164 {
13
d179b0bb85e4 make lexer a member function in parser class and eliminate some more global variables
John W. Eaton <jwe@octave.org>
parents: 12
diff changeset
165 double token_value;
d179b0bb85e4 make lexer a member function in parser class and eliminate some more global variables
John W. Eaton <jwe@octave.org>
parents: 12
diff changeset
166 int input_char = lexer (token_value);
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
167
12
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
168 if (input_char < 0)
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
169 return -1;
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
170
12
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
171 status = yypush_parse (static_cast<yypstate *> (m_parser_state),
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
172 input_char, &token_value, *this);
0
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 while (status == YYPUSH_MORE);
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
175
1
08df60a01bc1 debug flag, handle input with signal
John W. Eaton <jwe@octave.org>
parents: 0
diff changeset
176 return -2;
0
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
12
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
179 static void *create_parser_state (void)
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
180 {
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
181 return yypstate_new ();
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
182 }
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
183
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
184 static void delete_parser_state (void *parser_state)
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
185 {
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
186 return yypstate_delete (static_cast<yypstate *> (parser_state));
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
187 }
0
dff751fb985c initial revision
John W. Eaton <jwe@octave.org>
parents:
diff changeset
188 }
6
1b575145197e interpreter is now a class instead of a namespace with functions
John W. Eaton <jwe@octave.org>
parents: 4
diff changeset
189
12
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
190 static void yyerror (calc::parser& parser, char const *msg)
6
1b575145197e interpreter is now a class instead of a namespace with functions
John W. Eaton <jwe@octave.org>
parents: 4
diff changeset
191 {
12
894be158b32d define parser as a class and eliminate some global variables
John W. Eaton <jwe@octave.org>
parents: 11
diff changeset
192 parser.emit_error (msg);
6
1b575145197e interpreter is now a class instead of a namespace with functions
John W. Eaton <jwe@octave.org>
parents: 4
diff changeset
193 }