26 #if ! defined (octave_parse_h)
27 #define octave_parse_h 1
29 #include "octave-config.h"
52 class tree_anon_fcn_handle;
53 class tree_argument_list;
54 class tree_array_list;
57 class tree_classdef_attribute_list;
58 class tree_classdef_body;
59 class tree_classdef_enum_block;
60 class tree_classdef_enum_list;
61 class tree_classdef_events_block;
62 class tree_classdef_events_list;
63 class tree_classdef_methods_block;
64 class tree_classdef_methods_list;
65 class tree_classdef_properties_block;
66 class tree_classdef_property_list;
67 class tree_classdef_superclass_list;
68 class tree_colon_expression;
71 class tree_decl_command;
72 class tree_decl_init_list;
73 class tree_expression;
74 class tree_fcn_handle;
75 class tree_function_def;
76 class tree_identifier;
78 class tree_if_command;
79 class tree_if_command_list;
80 class tree_index_expression;
83 class tree_parameter_list;
85 class tree_statement_list;
86 class tree_statement_listtree_statement;
87 class tree_switch_case;
88 class tree_switch_case_list;
89 class tree_switch_command;
129 size_t size (
void)
const;
465 template <
typename T>
488 const std::string& file,
const std::string& dir_name,
489 const std::string& dispatch_type,
490 const std::string& package_name,
bool require_file,
491 bool force_script,
bool autoload,
bool relative_lookup);
499 virtual int run (
void) = 0;
589 const std::string& file,
const std::string& dir_name,
590 const std::string& dispatch_type,
591 const std::string& package_name,
bool require_file,
592 bool force_script,
bool autoload,
bool relative_lookup);
663 int run (
const std::string&
input,
bool eof);
672 extern OCTINTERP_API std::string
676 extern OCTINTERP_API std::string
681 const std::string& dir_name =
"",
682 const std::string& dispatch_type =
"",
683 const std::string& package_name =
"",
684 const std::string& fcn_name =
"",
685 bool autoload =
false);
687 extern OCTINTERP_API
void
689 const std::string&
context =
"",
690 bool verbose =
false,
bool require_file =
true);
715 OCTAVE_DEPRECATED (5,
"use 'octave::interpreter::eval_string' instead")
717 eval_string (const std::
string&,
bool silent,
int& parse_status,
int nargout);
721 eval_string (const std::
string&,
bool silent,
int& parse_status);
723 extern OCTINTERP_API
void
bool name_current_scope(const std::string &name)
parent_scope_info(const parent_scope_info &)=delete
parent_scope_info(void)=delete
std::deque< value_type >::iterator iterator
symbol_scope parent_scope(void) const
bool name_ok(const std::string &name)
std::deque< value_type >::const_iterator const_iterator
std::deque< value_type >::reverse_iterator reverse_iterator
std::pair< symbol_scope, std::string > value_type
parent_scope_info & operator=(const parent_scope_info &)=delete
std::deque< value_type >::const_reverse_iterator const_reverse_iterator
std::set< std::string > m_all_names
void push(const value_type &elt)
std::string parent_name(void) const
~parent_scope_info(void)=default
std::deque< value_type > m_info
parent_scope_info(base_parser &parser)
tree_command * make_unwind_command(token *unwind_tok, tree_statement_list *body, tree_statement_list *cleanup, token *end_tok, comment_list *lc, comment_list *mc)
bool validate_array_list(tree_expression *e)
tree_decl_command * make_decl_command(int tok, token *tok_val, tree_decl_init_list *lst)
tree_expression * make_postfix_op(int op, tree_expression *op1, token *tok_val)
octave_user_function * start_function(tree_identifier *id, tree_parameter_list *param_list, tree_statement_list *body, tree_statement *end_function)
void disallow_command_syntax(void)
tree_expression * make_assign_op(int op, tree_argument_list *lhs, token *eq_tok, tree_expression *rhs)
tree_anon_fcn_handle * make_anon_fcn_handle(tree_parameter_list *param_list, tree_expression *expr, const filepos &at_pos)
tree_expression * make_binary_op(int op, tree_expression *op1, token *tok_val, tree_expression *op2)
tree_switch_case * make_switch_case(token *case_tok, tree_expression *expr, tree_statement_list *list, comment_list *lc)
void bison_error(const std::string &s)
tree_if_command_list * start_if_command(tree_expression *expr, tree_statement_list *list)
tree_classdef_properties_block * make_classdef_properties_block(token *tok_val, tree_classdef_attribute_list *a, tree_classdef_property_list *plist, token *end_tok, comment_list *lc, comment_list *tc)
tree_command * make_return_command(token *return_tok)
bool m_parsing_local_functions
octave_value m_primary_fcn
void recover_from_parsing_function(void)
friend octave_value parse_fcn_file(interpreter &interp, const std::string &full_file, const std::string &file, const std::string &dir_name, const std::string &dispatch_type, const std::string &package_name, bool require_file, bool force_script, bool autoload, bool relative_lookup)
tree_command * make_do_until_command(token *until_tok, tree_statement_list *body, tree_expression *expr, comment_list *lc)
tree_expression * make_prefix_op(int op, tree_expression *op1, token *tok_val)
tree_function_def * finish_classdef_external_method(octave_user_function *fcn, tree_parameter_list *ret_list, comment_list *cl)
void finish_classdef_file(tree_classdef *cls, tree_statement_list *local_fcns)
base_parser(const base_parser &)=delete
bool parsing_subfunctions(void) const
std::shared_ptr< tree_classdef > m_classdef_object
parent_scope_info m_function_scopes
base_lexer & get_lexer(void) const
int curr_fcn_depth(void) const
tree_statement_list * set_stmt_print_flag(tree_statement_list *, char, bool)
tree_classdef_events_block * make_classdef_events_block(token *tok_val, tree_classdef_attribute_list *a, tree_classdef_events_list *elist, token *end_tok, comment_list *lc, comment_list *tc)
tree_statement_list * append_statement_list(tree_statement_list *list, char sep, tree_statement *stmt, bool warn_missing_semi)
symbol_scope m_primary_fcn_scope
tree_statement * make_statement(T *arg)
tree_if_clause * make_elseif_clause(token *elseif_tok, tree_expression *expr, tree_statement_list *list, comment_list *lc)
tree_command * make_while_command(token *while_tok, tree_expression *expr, tree_statement_list *body, token *end_tok, comment_list *lc)
tree_command * make_break_command(token *break_tok)
void endfunction_found(bool flag)
tree_function_def * finish_function(tree_parameter_list *ret_list, octave_user_function *fcn, comment_list *lc, int l, int c)
tree_expression * make_colon_expression(tree_expression *base, tree_expression *limit, tree_expression *incr=nullptr)
bool at_end_of_input(void) const
bool endfunction_found(void) const
tree_classdef_enum_block * make_classdef_enum_block(token *tok_val, tree_classdef_attribute_list *a, tree_classdef_enum_list *elist, token *end_tok, comment_list *lc, comment_list *tc)
tree_command * make_try_command(token *try_tok, tree_statement_list *body, char catch_sep, tree_statement_list *cleanup, token *end_tok, comment_list *lc, comment_list *mc)
void maybe_warn_missing_semi(tree_statement_list *)
bool m_fcn_file_from_relative_lookup
std::string m_curr_class_name
tree_index_expression * make_indirect_ref(tree_expression *expr, const std::string &)
std::string m_curr_package_name
void parsing_local_functions(bool flag)
std::list< std::string > m_subfunction_names
void maybe_warn_variable_switch_label(tree_expression *expr)
std::shared_ptr< tree_classdef > classdef_object(void) const
tree_function_def * make_function(token *fcn_tok, tree_parameter_list *ret_list, tree_identifier *id, tree_parameter_list *param_list, tree_statement_list *body, tree_statement *end_fcn_stmt, comment_list *lc)
tree_constant * make_constant(int op, token *tok_val)
tree_command * make_continue_command(token *continue_tok)
tree_if_command * finish_if_command(token *if_tok, tree_if_command_list *list, token *end_tok, comment_list *lc)
void make_script(tree_statement_list *cmds, tree_statement *end_script)
void maybe_warn_assign_as_truth_value(tree_expression *expr)
tree_identifier * make_fcn_name(tree_identifier *id)
tree_statement * make_end(const std::string &type, bool eof, const filepos &beg_pos, const filepos &end_pos)
octave_user_function * start_classdef_external_method(tree_identifier *id, tree_parameter_list *pl)
bool push_fcn_symtab(void)
tree_expression * finish_matrix(tree_matrix *m, token *open_delim, token *close_delim)
tree_command * make_for_command(int tok_id, token *for_tok, tree_argument_list *lhs, tree_expression *expr, tree_expression *maxproc, tree_statement_list *body, token *end_tok, comment_list *lc)
tree_expression * make_boolean_op(int op, tree_expression *op1, token *tok_val, tree_expression *op2)
tree_index_expression * make_index_expression(tree_expression *expr, tree_argument_list *args, char type)
void classdef_object(const std::shared_ptr< tree_classdef > &obj)
octave_user_function * frob_function(tree_identifier *id, octave_user_function *fcn)
bool m_parsing_subfunctions
void end_token_error(token *tok, token::end_tok_type expected)
std::string m_parse_error_msg
tree_argument_list * validate_matrix_for_assignment(tree_expression *e)
std::shared_ptr< tree_statement_list > statement_list(void) const
tree_switch_command * finish_switch_command(token *switch_tok, tree_expression *expr, tree_switch_case_list *list, token *end_tok, comment_list *lc)
tree_expression * finish_array_list(tree_array_list *a, token *open_delim, token *close_delim)
base_parser & operator=(const base_parser &)=delete
bool parsing_local_functions(void) const
bool end_token_ok(token *tok, token::end_tok_type expected)
tree_classdef_methods_block * make_classdef_methods_block(token *tok_val, tree_classdef_attribute_list *a, tree_classdef_methods_list *mlist, token *end_tok, comment_list *lc, comment_list *tc)
bool validate_param_list(tree_parameter_list *lst, tree_parameter_list::in_or_out type)
tree_classdef * make_classdef(token *tok_val, tree_classdef_attribute_list *a, tree_identifier *id, tree_classdef_superclass_list *sc, tree_classdef_body *body, token *end_tok, comment_list *lc, comment_list *tc)
tree_statement_list * make_statement_list(tree_statement *stmt)
std::shared_ptr< tree_statement_list > m_stmt_list
tree_fcn_handle * make_fcn_handle(token *tok_val)
base_parser(base_lexer &lxr)
tree_expression * finish_cell(tree_cell *c, token *open_delim, token *close_delim)
void parsing_subfunctions(bool flag)
parser(FILE *file, interpreter &interp)
parser(const parser &)=delete
parser(const std::string &eval_string, interpreter &interp)
parser(interpreter &interp)
parser & operator=(const parser &)=delete
push_parser(const push_parser &)=delete
~push_parser(void)=default
push_parser(interpreter &interp)
push_parser(interpreter &interp, input_reader *reader)
std::shared_ptr< input_reader > m_reader
interpreter & m_interpreter
push_parser & operator=(const push_parser &)=delete
octave_value parse_fcn_file(interpreter &interp, const std::string &full_file, const std::string &file, const std::string &dir_name, const std::string &dispatch_type, const std::string &package_name, bool require_file, bool force_script, bool autoload, bool relative_lookup)
void cleanup_statement_list(tree_statement_list **lst)
octave_value load_fcn_from_file(const std::string &file_name, const std::string &dir_name, const std::string &dispatch_type, const std::string &package_name, const std::string &fcn_name, bool autoload)
octave_value_list eval_string(const std::string &eval_str, bool silent, int &parse_status, int nargout)
static llvm::LLVMContext & context
octave_value_list feval(const char *name, const octave_value_list &args, int nargout)
Evaluate an Octave function (built-in or interpreted) and return the list of result values.
void source_file(const std::string &file_name, const std::string &context, bool verbose, bool require_file)
std::string get_help_from_file(const std::string &nm, bool &symbol_found, std::string &full_file)
static int input(yyscan_t yyscanner)