1
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
1
|
21 |
|
22 */ |
|
23 |
383
|
24 #if !defined (octave_lex_h) |
|
25 #define octave_lex_h 1 |
1
|
26 |
5775
|
27 // FIXME -- these input buffer things should be members of a |
1826
|
28 // parser input stream class. |
|
29 |
1
|
30 typedef struct yy_buffer_state *YY_BUFFER_STATE; |
|
31 |
|
32 // Associate a buffer with a new file to read. |
|
33 extern YY_BUFFER_STATE create_buffer (FILE *f); |
|
34 |
|
35 // Report the current buffer. |
|
36 extern YY_BUFFER_STATE current_buffer (void); |
|
37 |
|
38 // Connect to new buffer buffer. |
|
39 extern void switch_to_buffer (YY_BUFFER_STATE buf); |
|
40 |
|
41 // Delete a buffer. |
|
42 extern void delete_buffer (YY_BUFFER_STATE buf); |
|
43 |
|
44 // Restore a buffer (for unwind-prot). |
|
45 extern void restore_input_buffer (void *buf); |
|
46 |
|
47 // Delete a buffer (for unwind-prot). |
|
48 extern void delete_input_buffer (void *buf); |
|
49 |
4867
|
50 // Is the given string a keyword? |
|
51 extern bool is_keyword (const std::string& s); |
|
52 |
1826
|
53 // For communication between the lexer and parser. |
|
54 |
3585
|
55 class |
|
56 lexical_feedback |
1826
|
57 { |
|
58 public: |
|
59 |
|
60 lexical_feedback (void) { init (); } |
|
61 |
|
62 ~lexical_feedback (void) { } |
|
63 |
|
64 void init (void); |
|
65 |
3351
|
66 // Square bracket level count. |
|
67 int bracketflag; |
1826
|
68 |
4613
|
69 // Curly brace level count. |
|
70 int braceflag; |
|
71 |
2877
|
72 // TRUE means we're in the middle of defining a loop. |
1826
|
73 int looping; |
|
74 |
2877
|
75 // TRUE means we think we are looking at the beginning of a |
2857
|
76 // function definition. |
|
77 bool beginning_of_function; |
|
78 |
2877
|
79 // TRUE means that we should convert spaces to a comma inside a |
2857
|
80 // matrix definition. |
|
81 bool convert_spaces_to_comma; |
|
82 |
2877
|
83 // TRUE means we're in the middle of defining a function. |
2857
|
84 bool defining_func; |
|
85 |
4930
|
86 // Nonzero means we are parsing a function handle. |
|
87 int looking_at_function_handle; |
|
88 |
2877
|
89 // TRUE means we're parsing the return list for a function. |
2857
|
90 bool looking_at_return_list; |
|
91 |
2877
|
92 // TRUE means we're parsing the parameter list for a function. |
2857
|
93 bool looking_at_parameter_list; |
|
94 |
3189
|
95 // TRUE means we're parsing a matrix or the left hand side of |
|
96 // multi-value assignment statement. |
|
97 bool looking_at_matrix_or_assign_lhs; |
|
98 |
4237
|
99 // Nonzero means we're parsing an indexing operation for an object. |
|
100 int looking_at_object_index; |
4234
|
101 |
2857
|
102 // GAG. Stupid kludge so that [[1,2][3,4]] will work. |
|
103 bool do_comma_insert; |
|
104 |
5102
|
105 // TRUE means we're doing a raw input command. |
|
106 bool doing_rawcommand; |
|
107 |
2877
|
108 // TRUE means we're looking at an indirect reference to a |
2857
|
109 // structure element. |
|
110 bool looking_at_indirect_ref; |
|
111 |
2877
|
112 // TRUE means that we've already seen the name of this function. |
|
113 // Should only matter if defining_func is also TRUE. |
|
114 bool parsed_function_name; |
|
115 |
4240
|
116 // Are we parsing a nested function? |
|
117 // 1 ==> Yes. |
|
118 // 0 ==> No. |
|
119 // -1 ==> Yes, but it is the last one because we have seen EOF. |
|
120 int parsing_nested_function; |
4238
|
121 |
1826
|
122 // Return transpose or start a string? |
2857
|
123 bool quote_is_transpose; |
1826
|
124 |
|
125 private: |
|
126 |
|
127 lexical_feedback (const lexical_feedback&); |
|
128 |
|
129 lexical_feedback& operator = (const lexical_feedback&); |
|
130 }; |
|
131 |
3883
|
132 // TRUE means that we have encountered EOF on the input stream. |
|
133 extern bool parser_end_of_input; |
|
134 |
1826
|
135 // Flags that need to be shared between the lexer and parser. |
|
136 extern lexical_feedback lexer_flags; |
440
|
137 |
1
|
138 #endif |
|
139 |
|
140 /* |
|
141 ;;; Local Variables: *** |
|
142 ;;; mode: C++ *** |
|
143 ;;; End: *** |
|
144 */ |