1
|
1 // lex.h -*- C++ -*- |
|
2 /* |
|
3 |
383
|
4 Copyright (C) 1992, 1993, 1994 John W. Eaton |
1
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
383
|
24 #if !defined (octave_lex_h) |
|
25 #define octave_lex_h 1 |
1
|
26 |
143
|
27 // Arrange to get input via readline. |
|
28 |
|
29 #ifdef YY_INPUT |
|
30 #undef YY_INPUT |
247
|
31 #endif |
143
|
32 #define YY_INPUT(buf,result,max_size) \ |
|
33 if ((result = octave_read (buf, max_size)) < 0) \ |
|
34 YY_FATAL_ERROR ("octave_read () in flex scanner failed"); |
|
35 |
|
36 // Try to avoid crashing out completely on fatal scanner errors. |
|
37 |
|
38 #ifdef YY_FATAL_ERROR |
|
39 #undef YY_FATAL_ERROR |
247
|
40 #endif |
143
|
41 #define YY_FATAL_ERROR(msg) \ |
|
42 do \ |
|
43 { \ |
|
44 error (msg); \ |
|
45 jump_to_top_level (); \ |
|
46 } \ |
|
47 while (0) |
|
48 |
|
49 #define TOK_RETURN(tok) \ |
|
50 do \ |
|
51 { \ |
|
52 current_input_column += yyleng; \ |
|
53 quote_is_transpose = 0; \ |
|
54 cant_be_identifier = 0; \ |
|
55 convert_spaces_to_comma = 1; \ |
|
56 return (tok); \ |
|
57 } \ |
|
58 while (0) |
|
59 |
|
60 #define BIN_OP_RETURN(tok,convert) \ |
|
61 do \ |
|
62 { \ |
|
63 yylval.tok_val = new token (input_line_number, current_input_column); \ |
|
64 token_stack.push (yylval.tok_val); \ |
|
65 current_input_column += yyleng; \ |
|
66 quote_is_transpose = 0; \ |
|
67 cant_be_identifier = 0; \ |
|
68 convert_spaces_to_comma = convert; \ |
|
69 return (tok); \ |
|
70 } \ |
|
71 while (0) |
|
72 |
1
|
73 typedef struct yy_buffer_state *YY_BUFFER_STATE; |
|
74 |
|
75 // Associate a buffer with a new file to read. |
|
76 extern YY_BUFFER_STATE create_buffer (FILE *f); |
|
77 |
|
78 // Report the current buffer. |
|
79 extern YY_BUFFER_STATE current_buffer (void); |
|
80 |
|
81 // Connect to new buffer buffer. |
|
82 extern void switch_to_buffer (YY_BUFFER_STATE buf); |
|
83 |
|
84 // Delete a buffer. |
|
85 extern void delete_buffer (YY_BUFFER_STATE buf); |
|
86 |
|
87 // Restore a buffer (for unwind-prot). |
|
88 extern void restore_input_buffer (void *buf); |
|
89 |
|
90 // Delete a buffer (for unwind-prot). |
|
91 extern void delete_input_buffer (void *buf); |
|
92 |
|
93 // See if a function file has extra garbage after the end statement. |
|
94 extern void check_for_garbage_after_fcn_def (void); |
|
95 |
240
|
96 // Return transpose or start a string? |
|
97 extern int quote_is_transpose; |
|
98 |
440
|
99 // Nonzero means we thing we are looking at the beginning of a |
|
100 // function definition. |
|
101 extern int beginning_of_function; |
|
102 |
1
|
103 #endif |
|
104 |
|
105 /* |
|
106 ;;; Local Variables: *** |
|
107 ;;; mode: C++ *** |
|
108 ;;; page-delimiter: "^/\\*" *** |
|
109 ;;; End: *** |
|
110 */ |