23 #if ! defined (octave_lex_h) 24 #define octave_lex_h 1 26 #include "octave-config.h" 60 : m_frame_stack () { }
66 bool empty (
void)
const {
return m_frame_stack.empty (); }
68 size_t size (
void)
const {
return m_frame_stack.size (); }
74 m_frame_stack.push_front (scope);
104 : m_context (nl.m_context)
119 while (! m_context.empty ())
123 void bracket (
void) { m_context.push (BRACKET); }
127 return ! m_context.empty () && m_context.top () == BRACKET;
130 void brace (
void) { m_context.push (BRACE); }
134 return ! m_context.empty () && m_context.top () == BRACE;
137 void paren (
void) { m_context.push (PAREN); }
141 return ! m_context.empty () && m_context.top () == PAREN;
148 return ! m_context.empty () && m_context.top () == ANON_FCN_BODY;
153 return (! m_context.empty ()
154 && (m_context.top () == BRACKET || m_context.top () == BRACE));
157 bool none (
void) {
return m_context.empty (); }
161 if (! m_context.empty ())
167 while (! m_context.empty ())
204 m_buffer.push_front (tok);
211 delete m_buffer.back ();
212 m_buffer.pop_back ();
219 return empty () ? nullptr : m_buffer.at (n);
224 return empty () ? nullptr : m_buffer.at (n);
230 return empty () ? nullptr : m_buffer.front ();
235 return empty () ? nullptr : m_buffer.front ();
240 return empty () ? nullptr : m_buffer.back ();
245 return empty () ? nullptr : m_buffer.back ();
249 size_t size (
void)
const {
return m_buffer.size (); }
251 bool empty (
void)
const {
return m_buffer.empty (); }
265 : m_end_of_input (
false),
266 m_at_beginning_of_statement (true),
267 m_looking_at_anon_fcn_args (
false),
268 m_looking_at_return_list (
false),
269 m_looking_at_parameter_list (
false),
270 m_looking_at_decl_list (
false),
271 m_looking_at_initializer_expression (
false),
272 m_looking_at_matrix_or_assign_lhs (
false),
273 m_looking_for_object_index (
false),
274 m_looking_at_indirect_ref (
false),
275 m_parsing_class_method (
false),
276 m_parsing_classdef (
false),
277 m_maybe_classdef_get_set_method (
false),
278 m_parsing_classdef_get_method (
false),
279 m_parsing_classdef_set_method (
false),
280 m_quote_is_transpose (
false),
281 m_force_script (
false),
282 m_reading_fcn_file (
false),
283 m_reading_script_file (
false),
284 m_reading_classdef_file (
false),
285 m_buffer_function_text (
false),
286 m_input_line_number (1),
287 m_current_input_column (1),
292 m_looking_at_function_handle (0),
293 m_block_comment_nesting_level (0),
294 m_command_arg_paren_count (0),
296 m_current_input_line (),
304 m_fcn_file_full_name (),
307 m_looking_at_object_index (),
308 m_parsed_function_name (),
309 m_pending_local_variables (),
329 int previous_token_value (
void)
const;
331 bool previous_token_value_is (
int tok_val)
const;
333 void mark_previous_token_trailing_space (
void);
335 bool space_follows_previous_token (
void)
const;
337 bool previous_token_is_binop (
void)
const;
339 bool previous_token_is_keyword (
void)
const;
341 bool previous_token_may_be_command (
void)
const;
343 void maybe_mark_previous_token_as_variable (
void);
346 void mark_as_variables (
const std::list<std::string>& lst);
522 : m_buffer (), m_pos (nullptr), m_chars_left (0), m_eof (
false)
528 int copy_chunk (
char *buf,
size_t max_size);
530 bool empty (
void)
const {
return m_chars_left == 0; }
532 bool at_eof (
void)
const {
return m_eof; }
555 if (! m_comment_list)
558 m_comment_list->append (
s,
t);
567 m_comment_list =
nullptr;
574 delete m_comment_list;
576 m_comment_list =
nullptr;
586 m_comment_buf (), m_interpreter (interp)
603 virtual void reset (
void);
605 void prep_for_file (
void);
607 void begin_string (
int state);
609 virtual int fill_flex_buffer (
char *buf,
unsigned int max_size) = 0;
615 int handle_end_of_input (
void);
617 char * flex_yytext (
void);
619 int flex_yyleng (
void);
621 int text_yyinput (
void);
623 void xunput (
char c,
char *buf);
625 void xunput (
char c);
627 bool looking_at_space (
void);
629 bool inside_any_object_index (
void);
635 bool fq_identifier_contains_keyword (
const std::string&
s);
637 bool whitespace_is_significant (
void);
639 void handle_number (
void);
641 void handle_continuation (
void);
647 int handle_close_bracket (
int bracket_type);
649 bool looks_like_command_arg (
void);
651 int handle_superclass_identifier (
void);
653 int handle_meta_identifier (
void);
655 int handle_fq_identifier (
void);
657 int handle_identifier (
void);
659 void maybe_warn_separator_insert (
char sep);
661 void warn_single_quote_string (
void);
663 void warn_language_extension (
const std::string& msg);
665 void maybe_warn_language_extension_comment (
char c);
667 void warn_language_extension_continuation (
void);
669 void warn_language_extension_operator (
const std::string& op);
671 void push_token (
token *);
673 token * current_token (
void);
675 void display_token (
int tok);
677 void fatal_error (
const char *msg);
679 void lexer_debug (
const char *
pattern);
693 virtual void increment_promptflag (
void) = 0;
695 virtual void decrement_promptflag (
void) = 0;
697 virtual int promptflag (
void)
const = 0;
699 virtual int promptflag (
int) = 0;
709 void push_start_state (
int state);
711 void pop_start_state (
void);
713 void clear_start_state (
void);
717 void display_start_state (
void)
const;
719 int handle_op (
const char *
pattern,
int tok,
bool bos =
false);
721 int handle_language_extension_op (
const char *
pattern,
int tok,
724 bool maybe_unput_comma_before_unary_op (
int tok);
726 int handle_unary_op (
int tok,
bool bos =
false);
728 int handle_language_extension_unary_op (
int tok,
bool bos =
false);
730 int handle_assign_op (
const char *
pattern,
int tok);
732 int handle_language_extension_assign_op (
const char *
pattern,
int tok);
734 int handle_op_internal (
int tok,
bool bos,
bool compat);
738 int handle_token (
int tok,
token *tok_val =
nullptr);
740 int count_token (
int tok);
742 int count_token_internal (
int tok);
744 int show_token (
int tok);
746 void enable_fq_identifier (
void);
787 int promptflag (
void)
const {
return m_reader.promptflag (); }
793 return m_reader.input_source ();
798 return m_reader.input_from_terminal ();
803 return m_reader.input_from_file ();
808 return m_reader.input_from_eval_string ();
811 int fill_flex_buffer (
char *buf,
unsigned int max_size);
824 append_input (
"",
false);
830 append_input (
input,
false);
836 append_input (
"", eof);
843 append_input (
input, eof);
878 int fill_flex_buffer (
char *buf,
unsigned int max_size);
For example cd octave end example noindent changes the current working directory to file
std::string m_comment_text
void decrement_promptflag(void)
int m_command_arg_paren_count
bool is_anon_fcn_body(void)
push_lexer(const std::string &input, bool eof, interpreter *interp=nullptr)
bool m_looking_at_initializer_expression
bool input_from_terminal(void) const
bool m_buffer_function_text
void push(const symbol_scope &scope)
bbp_nesting_level m_nesting_level
bool m_looking_at_anon_fcn_args
bool m_at_beginning_of_statement
push_lexer(bool eof, interpreter *interp=nullptr)
base_lexer(interpreter *interp=nullptr)
int m_block_comment_nesting_level
lexer(const std::string &eval_string, interpreter *interp=nullptr)
virtual bool input_from_file(void) const
comment_list * get_comment(void)
int m_looking_at_function_handle
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
bool m_parsing_classdef_set_method
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
symbol_table_context(void)
bool is_push_lexer(void) const
virtual bool input_from_eval_string(void) const
std::stack< int > m_context
std::string input_source(void) const
int promptflag(void) const
create a structure array and initialize its values The dimensions of each cell array of values must match Singleton cells and non cell values are repeated so that they fill the entire array If the cells are empty
nd deftypefn *std::string name
std::set< std::string > m_pending_local_variables
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
bool is_bracket_or_brace(void)
OCTINTERP_API octave_value_list eval_string(const std::string &, bool silent, int &parse_status, int nargout)
comment_buffer m_comment_buf
const token * front(void) const
std::string m_current_input_line
static bool is_variable(octave::symbol_table &symtab, const std::string &name)
void increment_promptflag(void)
std::deque< symbol_scope > m_frame_stack
bbp_nesting_level(const bbp_nesting_level &nl)
const token * back(void) const
std::string m_function_text
returns the type of the matrix and caches it for future use Called with more than one the function will not attempt to guess the type if it is still unknown This is useful for debugging purposes The possible matrix types depend on whether the matrix is full or and can be one of the following able sis tem and mark type as unknown tem as the structure of the matrix explicitly gives this(Sparse matrices only) tem code
push_lexer(const std::string &input, interpreter *interp=nullptr)
int start_state(void) const
bool is_keyword(const std::string &s)
OCTAVE_EXPORT octave_value_list or cell arrays Arguments are concatenated vertically The returned values are padded with blanks as needed to make each row of the string array have the same length Empty input strings are significant and will concatenated in the output For numerical input
bool input_from_eval_string(void) const
is longer than or if then or only for unique occurrences of the complete pattern(false). The default is true. If a cell array of strings ar
std::stack< bool > m_parsed_function_name
push_lexer(interpreter *interp=nullptr)
bool m_looking_at_return_list
symbol_table_context m_symtab_context
static uint32_t state[624]
bool m_reading_script_file
bool m_parsing_class_method
void increment_promptflag(void)
bool at_end_of_file(void) const
bool at_end_of_buffer(void) const
virtual std::string input_source(void) const
void decrement_promptflag(void)
virtual bool is_push_lexer(void) const
bool m_looking_at_parameter_list
interpreter * m_interpreter
std::string input_source(void) const
bool m_looking_at_decl_list
bool m_reading_classdef_file
bool m_looking_at_indirect_ref
~symbol_table_context(void)
bool m_parsing_classdef_get_method
virtual bool input_from_terminal(void) const
bool m_looking_at_matrix_or_assign_lhs
std::stack< int > start_state_stack
lexer(FILE *file, interpreter *interp=nullptr)
lexer(interpreter *interp=nullptr)
bool m_quote_is_transpose
std::string m_string_text
std::deque< token * > m_buffer
bool input_from_file(void) const
std::list< bool > m_looking_at_object_index
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
int promptflag(void) const
const token * at(size_t n) const
std::string m_fcn_file_full_name
std::string m_package_name
bool m_looking_for_object_index
bool m_maybe_classdef_get_set_method
std::string m_fcn_file_name
int m_current_input_column