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
00047 extern bool is_keyword (const std::string& s);
00048
00049 extern void prep_lexer_for_script_file (void);
00050 extern void prep_lexer_for_function_file (void);
00051
00052
00053
00054 class
00055 lexical_feedback
00056 {
00057 public:
00058
00059 lexical_feedback (void)
00060
00061 : bracketflag (0), braceflag (0), looping (0),
00062 convert_spaces_to_comma (true), at_beginning_of_statement (true),
00063 defining_func (0), looking_at_function_handle (false),
00064 looking_at_return_list (false), looking_at_parameter_list (false),
00065 looking_at_decl_list (false), looking_at_initializer_expression (false),
00066 looking_at_matrix_or_assign_lhs (false), looking_at_object_index (),
00067 looking_for_object_index (false), do_comma_insert (false),
00068 looking_at_indirect_ref (false), parsed_function_name (),
00069 parsing_class_method (false), maybe_classdef_get_set_method (false),
00070 parsing_classdef (false), quote_is_transpose (false),
00071 pending_local_variables ()
00072
00073 {
00074 init ();
00075 }
00076
00077 ~lexical_feedback (void) { }
00078
00079 void init (void);
00080
00081
00082 int bracketflag;
00083
00084
00085 int braceflag;
00086
00087
00088 int looping;
00089
00090
00091
00092 bool convert_spaces_to_comma;
00093
00094
00095
00096 bool at_beginning_of_statement;
00097
00098
00099 int defining_func;
00100
00101
00102 int looking_at_function_handle;
00103
00104
00105 bool looking_at_return_list;
00106
00107
00108 bool looking_at_parameter_list;
00109
00110
00111
00112 bool looking_at_decl_list;
00113
00114
00115
00116 bool looking_at_initializer_expression;
00117
00118
00119
00120 bool looking_at_matrix_or_assign_lhs;
00121
00122
00123
00124 std::list<bool> looking_at_object_index;
00125
00126
00127 bool looking_for_object_index;
00128
00129
00130 bool do_comma_insert;
00131
00132
00133
00134 bool looking_at_indirect_ref;
00135
00136
00137
00138
00139 std::stack<bool> parsed_function_name;
00140
00141
00142 bool parsing_class_method;
00143
00144
00145
00146
00147 bool maybe_classdef_get_set_method;
00148
00149
00150 bool parsing_classdef;
00151
00152
00153 bool quote_is_transpose;
00154
00155
00156 std::set<std::string> pending_local_variables;
00157
00158 private:
00159
00160 lexical_feedback (const lexical_feedback&);
00161
00162 lexical_feedback& operator = (const lexical_feedback&);
00163 };
00164
00165 class
00166 stream_reader
00167 {
00168 public:
00169 virtual int getc (void) = 0;
00170 virtual int ungetc (int c) = 0;
00171
00172 protected:
00173 stream_reader (void) { }
00174 ~stream_reader (void) { }
00175
00176 private:
00177
00178
00179 stream_reader (const stream_reader&);
00180 stream_reader& operator = (const stream_reader&);
00181 };
00182
00183 extern std::string
00184 grab_comment_block (stream_reader& reader, bool at_bol, bool& eof);
00185
00186
00187 extern bool parser_end_of_input;
00188
00189
00190 extern lexical_feedback lexer_flags;
00191
00192 #endif