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