Mercurial > hg > octave-lyh
comparison libinterp/parse-tree/lex.h @ 16113:7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
* lex.ll, lex.h oct-parse.yy (do_comma_insert_check, text_yyinput,
xunput, fixup_column_count, inside_any_object_index, is_keyword_token,
is_variable, grab_block_comment, grab_comment_block, process_comment,
next_token_is_sep_op, next_token_is_postfix_unary_op,
next_token_is_bin_op, scan_for_comments, eat_whitespace,
handle_number, have_continuation, have_ellipsis_continuation,
eat_continuation, handle_string, next_token_is_assign_op,
next_token_is_index_op, handle_close_bracket, maybe_unput_comma,
next_token_can_follow_bin_op, looks_like_command_arg,
handle_superclass_identifier, handle_meta_identifier,
handle_identifier, maybe_warn_separator_insert,
gripe_single_quote_string, gripe_matlab_incompatible,
maybe_gripe_matlab_incompatible_comment,
gripe_matlab_incompatible_continuation,
gripe_matlab_incompatible_operator): Declare as members of
lexical_feedback class. Change all callers.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 26 Feb 2013 02:40:32 -0500 |
parents | 3ec4f6488569 |
children | 4f6c37cfbdce |
comparison
equal
deleted
inserted
replaced
16112:ea5d92f574e0 | 16113:7c5e5e97a3bc |
---|---|
52 extern bool is_keyword (const std::string& s); | 52 extern bool is_keyword (const std::string& s); |
53 | 53 |
54 extern void prep_lexer_for_script_file (void); | 54 extern void prep_lexer_for_script_file (void); |
55 extern void prep_lexer_for_function_file (void); | 55 extern void prep_lexer_for_function_file (void); |
56 | 56 |
57 class | |
58 stream_reader | |
59 { | |
60 public: | |
61 virtual int getc (void) = 0; | |
62 virtual int ungetc (int c) = 0; | |
63 | |
64 protected: | |
65 stream_reader (void) { } | |
66 ~stream_reader (void) { } | |
67 | |
68 private: | |
69 | |
70 // No copying! | |
71 stream_reader (const stream_reader&); | |
72 stream_reader& operator = (const stream_reader&); | |
73 }; | |
57 | 74 |
58 // Forward decl for lexical_feedback::token_stack. | 75 // Forward decl for lexical_feedback::token_stack. |
59 class token; | 76 class token; |
60 | 77 |
61 // For communication between the lexer and parser. | 78 // For communication between the lexer and parser. |
186 // The closest paren, brace, or bracket nesting is not an object | 203 // The closest paren, brace, or bracket nesting is not an object |
187 // index. | 204 // index. |
188 looking_at_object_index.push_front (false); | 205 looking_at_object_index.push_front (false); |
189 } | 206 } |
190 | 207 |
208 void do_comma_insert_check (void); | |
209 | |
210 int text_yyinput (void); | |
211 | |
212 void xunput (char c, char *buf); | |
213 | |
214 void fixup_column_count (char *s); | |
215 | |
216 bool inside_any_object_index (void); | |
217 | |
218 int is_keyword_token (const std::string& s); | |
219 | |
220 bool is_variable (const std::string& name); | |
221 | |
222 std::string grab_block_comment (stream_reader& reader, bool& eof); | |
223 | |
224 std::string grab_comment_block (stream_reader& reader, bool at_bol, | |
225 bool& eof); | |
226 | |
227 int process_comment (bool start_in_block, bool& eof); | |
228 | |
229 bool next_token_is_sep_op (void); | |
230 | |
231 bool next_token_is_postfix_unary_op (bool spc_prev); | |
232 | |
233 bool next_token_is_bin_op (bool spc_prev); | |
234 | |
235 void scan_for_comments (const char *text); | |
236 | |
237 int eat_whitespace (void); | |
238 | |
239 void handle_number (void); | |
240 | |
241 bool have_continuation (bool trailing_comments_ok = true); | |
242 | |
243 bool have_ellipsis_continuation (bool trailing_comments_ok = true); | |
244 | |
245 int eat_continuation (void); | |
246 | |
247 int handle_string (char delim); | |
248 | |
249 bool next_token_is_assign_op (void); | |
250 | |
251 bool next_token_is_index_op (void); | |
252 | |
253 int handle_close_bracket (bool spc_gobbled, int bracket_type); | |
254 | |
255 void maybe_unput_comma (int spc_gobbled); | |
256 | |
257 bool next_token_can_follow_bin_op (void); | |
258 | |
259 bool looks_like_command_arg (void); | |
260 | |
261 int handle_superclass_identifier (void); | |
262 | |
263 int handle_meta_identifier (void); | |
264 | |
265 int handle_identifier (void); | |
266 | |
267 void maybe_warn_separator_insert (char sep); | |
268 | |
269 void gripe_single_quote_string (void); | |
270 | |
271 void gripe_matlab_incompatible (const std::string& msg); | |
272 | |
273 void maybe_gripe_matlab_incompatible_comment (char c); | |
274 | |
275 void gripe_matlab_incompatible_continuation (void); | |
276 | |
277 void gripe_matlab_incompatible_operator (const std::string& op); | |
278 | |
191 // TRUE means that we should convert spaces to a comma inside a | 279 // TRUE means that we should convert spaces to a comma inside a |
192 // matrix definition. | 280 // matrix definition. |
193 bool convert_spaces_to_comma; | 281 bool convert_spaces_to_comma; |
194 | 282 |
195 // GAG. Stupid kludge so that [[1,2][3,4]] will work. | 283 // GAG. Stupid kludge so that [[1,2][3,4]] will work. |
296 lexical_feedback (const lexical_feedback&); | 384 lexical_feedback (const lexical_feedback&); |
297 | 385 |
298 lexical_feedback& operator = (const lexical_feedback&); | 386 lexical_feedback& operator = (const lexical_feedback&); |
299 }; | 387 }; |
300 | 388 |
301 class | |
302 stream_reader | |
303 { | |
304 public: | |
305 virtual int getc (void) = 0; | |
306 virtual int ungetc (int c) = 0; | |
307 | |
308 protected: | |
309 stream_reader (void) { } | |
310 ~stream_reader (void) { } | |
311 | |
312 private: | |
313 | |
314 // No copying! | |
315 stream_reader (const stream_reader&); | |
316 stream_reader& operator = (const stream_reader&); | |
317 }; | |
318 | |
319 extern std::string | |
320 grab_comment_block (stream_reader& reader, bool at_bol, bool& eof); | |
321 | |
322 // The current state of the lexer. | 389 // The current state of the lexer. |
323 extern lexical_feedback *curr_lexer; | 390 extern lexical_feedback *curr_lexer; |
324 | 391 |
325 #endif | 392 #endif |