Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined (octave_lex_h)
00024 #define octave_lex_h 1
00025
00026 #include <list>
00027 #include <stack>
00028
00029
00030
00031
00032 typedef struct yy_buffer_state *YY_BUFFER_STATE;
00033
00034
00035 extern OCTINTERP_API YY_BUFFER_STATE create_buffer (FILE *f);
00036
00037
00038 extern OCTINTERP_API YY_BUFFER_STATE current_buffer (void);
00039
00040
00041 extern OCTINTERP_API void switch_to_buffer (YY_BUFFER_STATE buf);
00042
00043
00044 extern OCTINTERP_API void delete_buffer (YY_BUFFER_STATE buf);
00045
00046 extern OCTINTERP_API void clear_all_buffers (void);
00047
00048 extern OCTINTERP_API void cleanup_parser (void);
00049
00050
00051 extern bool is_keyword (const std::string& s);
00052
00053 extern void prep_lexer_for_script_file (void);
00054 extern void prep_lexer_for_function_file (void);
00055
00056
00057
00058 class
00059 lexical_feedback
00060 {
00061 public:
00062
00063 lexical_feedback (void)
00064
00065 : bracketflag (0), braceflag (0), looping (0),
00066 convert_spaces_to_comma (true), at_beginning_of_statement (true),
00067 defining_func (0), looking_at_function_handle (0),
00068 looking_at_anon_fcn_args (true),
00069 looking_at_return_list (false), looking_at_parameter_list (false),
00070 looking_at_decl_list (false), looking_at_initializer_expression (false),
00071 looking_at_matrix_or_assign_lhs (false), looking_at_object_index (),
00072 looking_for_object_index (false), do_comma_insert (false),
00073 looking_at_indirect_ref (false), parsed_function_name (),
00074 parsing_class_method (false), maybe_classdef_get_set_method (false),
00075 parsing_classdef (false), quote_is_transpose (false),
00076 pending_local_variables ()
00077
00078 {
00079 init ();
00080 }
00081
00082 ~lexical_feedback (void) { }
00083
00084 void init (void);
00085
00086
00087 int bracketflag;
00088
00089
00090 int braceflag;
00091
00092
00093 int looping;
00094
00095
00096
00097 bool convert_spaces_to_comma;
00098
00099
00100
00101 bool at_beginning_of_statement;
00102
00103
00104 int defining_func;
00105
00106
00107 int looking_at_function_handle;
00108
00109
00110 bool looking_at_anon_fcn_args;
00111
00112
00113 bool looking_at_return_list;
00114
00115
00116 bool looking_at_parameter_list;
00117
00118
00119
00120 bool looking_at_decl_list;
00121
00122
00123
00124 bool looking_at_initializer_expression;
00125
00126
00127
00128 bool looking_at_matrix_or_assign_lhs;
00129
00130
00131
00132 std::list<bool> looking_at_object_index;
00133
00134
00135 bool looking_for_object_index;
00136
00137
00138 bool do_comma_insert;
00139
00140
00141
00142 bool looking_at_indirect_ref;
00143
00144
00145
00146
00147 std::stack<bool> parsed_function_name;
00148
00149
00150 bool parsing_class_method;
00151
00152
00153
00154
00155 bool maybe_classdef_get_set_method;
00156
00157
00158 bool parsing_classdef;
00159
00160
00161 bool quote_is_transpose;
00162
00163
00164 std::set<std::string> pending_local_variables;
00165
00166 private:
00167
00168 lexical_feedback (const lexical_feedback&);
00169
00170 lexical_feedback& operator = (const lexical_feedback&);
00171 };
00172
00173 class
00174 stream_reader
00175 {
00176 public:
00177 virtual int getc (void) = 0;
00178 virtual int ungetc (int c) = 0;
00179
00180 protected:
00181 stream_reader (void) { }
00182 ~stream_reader (void) { }
00183
00184 private:
00185
00186
00187 stream_reader (const stream_reader&);
00188 stream_reader& operator = (const stream_reader&);
00189 };
00190
00191 extern std::string
00192 grab_comment_block (stream_reader& reader, bool at_bol, bool& eof);
00193
00194
00195 extern bool parser_end_of_input;
00196
00197
00198 extern lexical_feedback lexer_flags;
00199
00200 #endif