1
|
1 // lex.h -*- C++ -*- |
|
2 /* |
|
3 |
1009
|
4 Copyright (C) 1992, 1993, 1994, 1995 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 |
1315
|
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1
|
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 |
1060
|
60 #define TOK_PUSH_AND_RETURN(name,tok) \ |
|
61 do \ |
|
62 { \ |
1061
|
63 yylval.tok_val = new token (name, input_line_number, \ |
|
64 current_input_column); \ |
1060
|
65 token_stack.push (yylval.tok_val); \ |
|
66 TOK_RETURN (tok); \ |
|
67 } \ |
|
68 while (0) |
|
69 |
143
|
70 #define BIN_OP_RETURN(tok,convert) \ |
|
71 do \ |
|
72 { \ |
|
73 yylval.tok_val = new token (input_line_number, current_input_column); \ |
|
74 token_stack.push (yylval.tok_val); \ |
|
75 current_input_column += yyleng; \ |
|
76 quote_is_transpose = 0; \ |
|
77 cant_be_identifier = 0; \ |
|
78 convert_spaces_to_comma = convert; \ |
|
79 return (tok); \ |
|
80 } \ |
|
81 while (0) |
|
82 |
1
|
83 typedef struct yy_buffer_state *YY_BUFFER_STATE; |
|
84 |
|
85 // Associate a buffer with a new file to read. |
|
86 extern YY_BUFFER_STATE create_buffer (FILE *f); |
|
87 |
|
88 // Report the current buffer. |
|
89 extern YY_BUFFER_STATE current_buffer (void); |
|
90 |
|
91 // Connect to new buffer buffer. |
|
92 extern void switch_to_buffer (YY_BUFFER_STATE buf); |
|
93 |
|
94 // Delete a buffer. |
|
95 extern void delete_buffer (YY_BUFFER_STATE buf); |
|
96 |
|
97 // Restore a buffer (for unwind-prot). |
|
98 extern void restore_input_buffer (void *buf); |
|
99 |
|
100 // Delete a buffer (for unwind-prot). |
|
101 extern void delete_input_buffer (void *buf); |
|
102 |
|
103 // See if a function file has extra garbage after the end statement. |
|
104 extern void check_for_garbage_after_fcn_def (void); |
|
105 |
240
|
106 // Return transpose or start a string? |
|
107 extern int quote_is_transpose; |
|
108 |
440
|
109 // Nonzero means we thing we are looking at the beginning of a |
|
110 // function definition. |
|
111 extern int beginning_of_function; |
|
112 |
1
|
113 #endif |
|
114 |
|
115 /* |
|
116 ;;; Local Variables: *** |
|
117 ;;; mode: C++ *** |
|
118 ;;; page-delimiter: "^/\\*" *** |
|
119 ;;; End: *** |
|
120 */ |