GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
octave::base_lexer Class Referenceabstract

#include "lex.h"

Inheritance diagram for octave::base_lexer:
Collaboration diagram for octave::base_lexer:

Classes

class  comment_buffer
 
class  input_buffer
 

Public Member Functions

 base_lexer (const base_lexer &)=delete
 
 base_lexer (interpreter &interp)
 
virtual ~base_lexer (void)
 
bool at_end_of_buffer (void) const
 
bool at_end_of_file (void) const
 
void begin_string (int state)
 
void clear_start_state (void)
 
int count_token (int tok)
 
int count_token_internal (int tok)
 
tokencurrent_token (void)
 
bool debug_flag (void) const
 
void display_start_state (void) const
 
void display_token (int tok)
 
bool display_tokens (void) const
 
void fatal_error (const char *msg)
 
virtual int fill_flex_buffer (char *buf, unsigned int max_size)=0
 
int finish_command_arg (void)
 
void finish_comment (comment_elt::comment_type typ)
 
int flex_yyleng (void)
 
char * flex_yytext (void)
 
bool fq_identifier_contains_keyword (const std::string &s)
 
comment_listget_comment (void)
 
int handle_close_bracket (int bracket_type)
 
void handle_continuation (void)
 
int handle_end_of_input (void)
 
int handle_fq_identifier (void)
 
int handle_identifier (void)
 
int handle_meta_identifier (void)
 
void handle_number (void)
 
int handle_op (int tok, bool bos=false, bool compat=true)
 
int handle_superclass_identifier (void)
 
int handle_token (int tok, token *tok_val=nullptr)
 
void increment_token_count (void)
 
void init (void)
 
virtual bool input_from_eval_string (void) const
 
virtual bool input_from_file (void) const
 
virtual bool input_from_terminal (void) const
 
bool input_from_tmp_history_file (void)
 
virtual std::string input_source (void) const
 
bool inside_any_object_index (void)
 
virtual bool is_push_lexer (void) const
 
bool is_variable (const std::string &name, const symbol_scope &scope)
 
void lexer_debug (const char *pattern)
 
bool looking_at_space (void)
 
bool looks_like_command_arg (void)
 
int make_keyword_token (const std::string &s)
 
void mark_as_variable (const std::string &nm)
 
void mark_as_variables (const std::list< std::string > &lst)
 
void mark_previous_token_trailing_space (void)
 
void maybe_mark_previous_token_as_variable (void)
 
bool maybe_unput_comma_before_unary_op (int tok)
 
void maybe_warn_language_extension_comment (char c)
 
void maybe_warn_separator_insert (char sep)
 
base_lexeroperator= (const base_lexer &)=delete
 
size_t pending_token_count (void) const
 
void pop_start_state (void)
 
void prep_for_file (void)
 
bool previous_token_is_binop (void) const
 
bool previous_token_is_keyword (void) const
 
bool previous_token_may_be_command (void) const
 
int previous_token_value (void) const
 
bool previous_token_value_is (int tok_val) const
 
void push_start_state (int state)
 
void push_token (token *)
 
virtual void reset (void)
 
int show_token (int tok)
 
bool space_follows_previous_token (void) const
 
int start_state (void) const
 
int text_yyinput (void)
 
void update_token_positions (int tok_len)
 
void warn_language_extension (const std::string &msg)
 
void warn_language_extension_continuation (void)
 
void warn_language_extension_operator (const std::string &op)
 
void warn_single_quote_string (void)
 
bool whitespace_is_significant (void)
 
void xunput (char c)
 
void xunput (char c, char *buf)
 

Public Attributes

bool m_allow_command_syntax
 
bool m_at_beginning_of_statement
 
int m_block_comment_nesting_level
 
int m_braceflag
 
int m_bracketflag
 
bool m_buffer_function_text
 
int m_command_arg_paren_count
 
comment_buffer m_comment_buf
 
std::string m_comment_text
 
std::string m_current_input_line
 
int m_defining_func
 
std::string m_dir_name
 
bool m_end_of_input
 
std::string m_fcn_file_full_name
 
std::string m_fcn_file_name
 
filepos m_filepos
 
bool m_force_script
 
std::string m_function_text
 
std::string m_help_text
 
input_buffer m_input_buf
 
interpreterm_interpreter
 
bool m_looking_at_anon_fcn_args
 
bool m_looking_at_decl_list
 
int m_looking_at_function_handle
 
bool m_looking_at_indirect_ref
 
bool m_looking_at_initializer_expression
 
bool m_looking_at_matrix_or_assign_lhs
 
std::list< bool > m_looking_at_object_index
 
bool m_looking_at_parameter_list
 
bool m_looking_at_return_list
 
bool m_looking_for_object_index
 
int m_looping
 
bool m_maybe_classdef_get_set_method
 
bbp_nesting_level m_nesting_level
 
std::string m_package_name
 
std::stack< bool > m_parsed_function_name
 
bool m_parsing_anon_fcn_body
 
bool m_parsing_class_method
 
bool m_parsing_classdef
 
bool m_parsing_classdef_decl
 
bool m_parsing_classdef_get_method
 
bool m_parsing_classdef_set_method
 
bool m_parsing_classdef_superclass
 
std::set< std::string > m_pending_local_variables
 
bool m_quote_is_transpose
 
bool m_reading_classdef_file
 
bool m_reading_fcn_file
 
bool m_reading_script_file
 
void * m_scanner
 
std::string m_string_text
 
symbol_table_context m_symtab_context
 
filepos m_tok_beg
 
filepos m_tok_end
 
size_t m_token_count
 
token_cache m_tokens
 

Protected Attributes

std::stack< int > start_state_stack
 

Detailed Description

Definition at line 533 of file lex.h.

Constructor & Destructor Documentation

◆ base_lexer() [1/2]

octave::base_lexer::base_lexer ( interpreter interp)
inline

Definition at line 607 of file lex.h.

◆ base_lexer() [2/2]

octave::base_lexer::base_lexer ( const base_lexer )
delete

◆ ~base_lexer()

octave::base_lexer::~base_lexer ( void  )
virtual

Definition at line 5307 of file lex.cc.

References m_scanner, and yylex_destroy.

Member Function Documentation

◆ at_end_of_buffer()

bool octave::base_lexer::at_end_of_buffer ( void  ) const
inline

Definition at line 634 of file lex.h.

Referenced by octave::push_parser::run().

◆ at_end_of_file()

bool octave::base_lexer::at_end_of_file ( void  ) const
inline

Definition at line 636 of file lex.h.

◆ begin_string()

void octave::base_lexer::begin_string ( int  state)

◆ clear_start_state()

void octave::base_lexer::clear_start_state ( void  )

Definition at line 6461 of file lex.cc.

References INITIAL, push_start_state(), and start_state_stack.

Referenced by init(), and reset().

◆ count_token()

int octave::base_lexer::count_token ( int  tok)

◆ count_token_internal()

int octave::base_lexer::count_token_internal ( int  tok)

◆ current_token()

token * octave::base_lexer::current_token ( void  )

Definition at line 6248 of file lex.cc.

References m_scanner, yyget_lval, and YYSTYPE.

Referenced by display_token().

◆ debug_flag()

bool octave::base_lexer::debug_flag ( void  ) const

◆ display_start_state()

void octave::base_lexer::display_start_state ( void  ) const

◆ display_token()

◆ display_tokens()

bool octave::base_lexer::display_tokens ( void  ) const

◆ fatal_error()

void octave::base_lexer::fatal_error ( const char *  msg)

Definition at line 6390 of file lex.cc.

References error().

◆ fill_flex_buffer()

virtual int octave::base_lexer::fill_flex_buffer ( char *  buf,
unsigned int  max_size 
)
pure virtual

Implemented in octave::push_lexer, and octave::lexer.

◆ finish_command_arg()

◆ finish_comment()

◆ flex_yyleng()

int octave::base_lexer::flex_yyleng ( void  )

◆ flex_yytext()

char * octave::base_lexer::flex_yytext ( void  )

◆ fq_identifier_contains_keyword()

bool octave::base_lexer::fq_identifier_contains_keyword ( const std::string &  s)

◆ get_comment()

comment_list* octave::base_lexer::get_comment ( void  )
inline

Definition at line 670 of file lex.h.

Referenced by octave::base_parser::make_statement().

◆ handle_close_bracket()

◆ handle_continuation()

◆ handle_end_of_input()

◆ handle_fq_identifier()

◆ handle_identifier()

◆ handle_meta_identifier()

◆ handle_number()

◆ handle_op()

◆ handle_superclass_identifier()

◆ handle_token()

int octave::base_lexer::handle_token ( int  tok,
token tok_val = nullptr 
)

◆ increment_token_count()

void octave::base_lexer::increment_token_count ( void  )

◆ init()

void octave::base_lexer::init ( void  )

Definition at line 5313 of file lex.cc.

References clear_start_state(), m_scanner, yylex_init, and yyset_extra.

◆ input_from_eval_string()

virtual bool octave::base_lexer::input_from_eval_string ( void  ) const
inlinevirtual

Reimplemented in octave::lexer.

Definition at line 729 of file lex.h.

Referenced by octave::base_parser::make_anon_fcn_handle(), and reset().

◆ input_from_file()

virtual bool octave::base_lexer::input_from_file ( void  ) const
inlinevirtual

Reimplemented in octave::lexer.

Definition at line 727 of file lex.h.

Referenced by make_keyword_token().

◆ input_from_terminal()

virtual bool octave::base_lexer::input_from_terminal ( void  ) const
inlinevirtual

Reimplemented in octave::lexer.

Definition at line 725 of file lex.h.

Referenced by octave::base_parser::make_anon_fcn_handle().

◆ input_from_tmp_history_file()

bool octave::base_lexer::input_from_tmp_history_file ( void  )

◆ input_source()

virtual std::string octave::base_lexer::input_source ( void  ) const
inlinevirtual

Reimplemented in octave::push_lexer, and octave::lexer.

Definition at line 723 of file lex.h.

◆ inside_any_object_index()

bool octave::base_lexer::inside_any_object_index ( void  )

Definition at line 5489 of file lex.cc.

References octave::lexical_feedback::m_looking_at_object_index, and retval.

Referenced by make_keyword_token().

◆ is_push_lexer()

virtual bool octave::base_lexer::is_push_lexer ( void  ) const
inlinevirtual

Reimplemented in octave::push_lexer.

Definition at line 624 of file lex.h.

◆ is_variable()

bool octave::base_lexer::is_variable ( const std::string &  name,
const symbol_scope scope 
)

◆ lexer_debug()

void octave::base_lexer::lexer_debug ( const char *  pattern)

Definition at line 6419 of file lex.cc.

References debug_flag(), display_start_state(), and flex_yytext().

Referenced by handle_end_of_input().

◆ looking_at_space()

bool octave::base_lexer::looking_at_space ( void  )

Definition at line 5481 of file lex.cc.

References is_space_or_tab(), text_yyinput(), and xunput().

Referenced by looks_like_command_arg().

◆ looks_like_command_arg()

◆ make_keyword_token()

int octave::base_lexer::make_keyword_token ( const std::string &  s)

Definition at line 5516 of file lex.cc.

References break_kw, case_kw, catch_kw, octave::token::classdef_end, classdef_kw, continue_kw, do_kw, else_kw, elseif_kw, end_kw, end_try_catch_kw, end_unwind_protect_kw, endclassdef_kw, endenumeration_kw, endevents_kw, endfor_kw, endfunction_kw, endif_kw, endmethods_kw, endparfor_kw, endproperties_kw, endswitch_kw, endwhile_kw, octave::token::enumeration_end, enumeration_kw, octave::token::events_end, events_kw, octave::token::for_end, for_kw, octave::token::function_end, function_kw, get_kw, global_kw, octave::token::if_end, if_kw, octave_kw_hash::in_word_set(), input_from_file(), inside_any_object_index(), octave_kw::kw_id, octave::filepos::line(), octave::lexical_feedback::m_at_beginning_of_statement, octave::lexical_feedback::m_buffer_function_text, octave::lexical_feedback::m_current_input_line, octave::lexical_feedback::m_defining_func, octave::lexical_feedback::m_fcn_file_full_name, octave::lexical_feedback::m_filepos, octave::lexical_feedback::m_force_script, octave::lexical_feedback::m_function_text, octave::lexical_feedback::m_looking_at_decl_list, octave::lexical_feedback::m_looking_at_return_list, octave::lexical_feedback::m_looping, octave::lexical_feedback::m_maybe_classdef_get_set_method, octave::lexical_feedback::m_parsed_function_name, octave::lexical_feedback::m_parsing_classdef, octave::lexical_feedback::m_reading_classdef_file, octave::lexical_feedback::m_reading_fcn_file, octave::lexical_feedback::m_reading_script_file, octave::lexical_feedback::m_tok_beg, octave::lexical_feedback::m_tok_end, octave::lexical_feedback::m_token_count, magic_file_kw, magic_line_kw, octave::token::methods_end, methods_kw, otherwise_kw, panic_impossible, octave::token::parfor_end, parfor_kw, persistent_kw, octave::token::properties_end, properties_kw, push_token(), return_kw, set_kw, octave::token::simple_end, octave::token::switch_end, switch_kw, octave_kw::tok, octave::token::try_catch_end, try_kw, until_kw, unwind_protect_cleanup_kw, octave::token::unwind_protect_end, unwind_protect_kw, update_token_positions(), octave::token::while_end, and while_kw.

Referenced by handle_identifier().

◆ mark_as_variable()

void octave::lexical_feedback::mark_as_variable ( const std::string &  nm)
inherited

◆ mark_as_variables()

void octave::lexical_feedback::mark_as_variables ( const std::list< std::string > &  lst)
inherited

◆ mark_previous_token_trailing_space()

void octave::lexical_feedback::mark_previous_token_trailing_space ( void  )
inherited

◆ maybe_mark_previous_token_as_variable()

void octave::lexical_feedback::maybe_mark_previous_token_as_variable ( void  )
inherited

◆ maybe_unput_comma_before_unary_op()

◆ maybe_warn_language_extension_comment()

void octave::base_lexer::maybe_warn_language_extension_comment ( char  c)

Definition at line 6217 of file lex.cc.

References warn_language_extension().

◆ maybe_warn_separator_insert()

void octave::base_lexer::maybe_warn_separator_insert ( char  sep)

◆ operator=()

base_lexer& octave::base_lexer::operator= ( const base_lexer )
delete

◆ pending_token_count()

size_t octave::base_lexer::pending_token_count ( void  ) const

◆ pop_start_state()

void octave::base_lexer::pop_start_state ( void  )

Definition at line 6451 of file lex.cc.

References BEGIN, OCTAVE_YYG, start_state(), and start_state_stack.

Referenced by handle_close_bracket().

◆ prep_for_file()

void octave::base_lexer::prep_for_file ( void  )

◆ previous_token_is_binop()

bool octave::lexical_feedback::previous_token_is_binop ( void  ) const
inherited

◆ previous_token_is_keyword()

bool octave::lexical_feedback::previous_token_is_keyword ( void  ) const
inherited

◆ previous_token_may_be_command()

bool octave::lexical_feedback::previous_token_may_be_command ( void  ) const
inherited

◆ previous_token_value()

int octave::lexical_feedback::previous_token_value ( void  ) const
inherited

◆ previous_token_value_is()

bool octave::lexical_feedback::previous_token_value_is ( int  tok_val) const
inherited

◆ push_start_state()

void octave::base_lexer::push_start_state ( int  state)

◆ push_token()

◆ reset()

◆ show_token()

int octave::base_lexer::show_token ( int  tok)

Definition at line 6624 of file lex.cc.

References debug_flag(), display_token(), and display_tokens().

Referenced by count_token_internal().

◆ space_follows_previous_token()

bool octave::lexical_feedback::space_follows_previous_token ( void  ) const
inherited

◆ start_state()

int octave::base_lexer::start_state ( void  ) const
inline

Definition at line 739 of file lex.h.

Referenced by display_start_state(), pop_start_state(), and push_start_state().

◆ text_yyinput()

int octave::base_lexer::text_yyinput ( void  )

Definition at line 5410 of file lex.cc.

References debug_flag(), display_character(), m_scanner, and xunput().

Referenced by looking_at_space(), and maybe_unput_comma_before_unary_op().

◆ update_token_positions()

◆ warn_language_extension()

◆ warn_language_extension_continuation()

void octave::base_lexer::warn_language_extension_continuation ( void  )

Definition at line 6224 of file lex.cc.

References warn_language_extension().

Referenced by handle_continuation().

◆ warn_language_extension_operator()

void octave::base_lexer::warn_language_extension_operator ( const std::string &  op)

Definition at line 6230 of file lex.cc.

References n, and warn_language_extension().

Referenced by handle_op().

◆ warn_single_quote_string()

void octave::base_lexer::warn_single_quote_string ( void  )

◆ whitespace_is_significant()

◆ xunput() [1/2]

void octave::base_lexer::xunput ( char  c)

Definition at line 5461 of file lex.cc.

References flex_yytext(), and xunput().

◆ xunput() [2/2]

void octave::base_lexer::xunput ( char  c,
char *  buf 
)

Member Data Documentation

◆ m_allow_command_syntax

bool octave::lexical_feedback::m_allow_command_syntax
inherited

◆ m_at_beginning_of_statement

bool octave::lexical_feedback::m_at_beginning_of_statement
inherited

◆ m_block_comment_nesting_level

int octave::lexical_feedback::m_block_comment_nesting_level
inherited

Definition at line 459 of file lex.h.

Referenced by handle_end_of_input(), and octave::lexical_feedback::reset().

◆ m_braceflag

int octave::lexical_feedback::m_braceflag
inherited

Definition at line 447 of file lex.h.

Referenced by handle_close_bracket(), and octave::lexical_feedback::reset().

◆ m_bracketflag

int octave::lexical_feedback::m_bracketflag
inherited

Definition at line 444 of file lex.h.

Referenced by handle_close_bracket(), and octave::lexical_feedback::reset().

◆ m_buffer_function_text

bool octave::lexical_feedback::m_buffer_function_text
inherited

◆ m_command_arg_paren_count

int octave::lexical_feedback::m_command_arg_paren_count
inherited

Definition at line 462 of file lex.h.

Referenced by finish_command_arg(), and octave::lexical_feedback::reset().

◆ m_comment_buf

◆ m_comment_text

std::string octave::lexical_feedback::m_comment_text
inherited

Definition at line 485 of file lex.h.

Referenced by finish_comment(), handle_continuation(), and octave::lexical_feedback::reset().

◆ m_current_input_line

std::string octave::lexical_feedback::m_current_input_line
inherited

◆ m_defining_func

int octave::lexical_feedback::m_defining_func
inherited

◆ m_dir_name

std::string octave::lexical_feedback::m_dir_name
inherited

◆ m_end_of_input

bool octave::lexical_feedback::m_end_of_input
inherited

Definition at line 357 of file lex.h.

Referenced by octave::base_parser::at_end_of_input(), and octave::lexical_feedback::reset().

◆ m_fcn_file_full_name

◆ m_fcn_file_name

◆ m_filepos

◆ m_force_script

bool octave::lexical_feedback::m_force_script
inherited

◆ m_function_text

std::string octave::lexical_feedback::m_function_text
inherited

◆ m_help_text

std::string octave::lexical_feedback::m_help_text
inherited

◆ m_input_buf

input_buffer octave::base_lexer::m_input_buf

◆ m_interpreter

◆ m_looking_at_anon_fcn_args

bool octave::lexical_feedback::m_looking_at_anon_fcn_args
inherited

Definition at line 367 of file lex.h.

Referenced by octave::lexical_feedback::reset().

◆ m_looking_at_decl_list

bool octave::lexical_feedback::m_looking_at_decl_list
inherited

Definition at line 377 of file lex.h.

Referenced by make_keyword_token(), and octave::lexical_feedback::reset().

◆ m_looking_at_function_handle

int octave::lexical_feedback::m_looking_at_function_handle
inherited

Definition at line 456 of file lex.h.

Referenced by octave::lexical_feedback::reset().

◆ m_looking_at_indirect_ref

bool octave::lexical_feedback::m_looking_at_indirect_ref
inherited

◆ m_looking_at_initializer_expression

bool octave::lexical_feedback::m_looking_at_initializer_expression
inherited

Definition at line 381 of file lex.h.

Referenced by octave::lexical_feedback::reset().

◆ m_looking_at_matrix_or_assign_lhs

bool octave::lexical_feedback::m_looking_at_matrix_or_assign_lhs
inherited

Definition at line 385 of file lex.h.

Referenced by octave::lexical_feedback::reset().

◆ m_looking_at_object_index

std::list<bool> octave::lexical_feedback::m_looking_at_object_index
inherited

◆ m_looking_at_parameter_list

bool octave::lexical_feedback::m_looking_at_parameter_list
inherited

◆ m_looking_at_return_list

bool octave::lexical_feedback::m_looking_at_return_list
inherited

◆ m_looking_for_object_index

bool octave::lexical_feedback::m_looking_for_object_index
inherited

◆ m_looping

◆ m_maybe_classdef_get_set_method

bool octave::lexical_feedback::m_maybe_classdef_get_set_method
inherited

◆ m_nesting_level

bbp_nesting_level octave::lexical_feedback::m_nesting_level
inherited

◆ m_package_name

std::string octave::lexical_feedback::m_package_name
inherited

Definition at line 503 of file lex.h.

Referenced by octave::lexical_feedback::reset(), and octave::base_parser::start_function().

◆ m_parsed_function_name

std::stack<bool> octave::lexical_feedback::m_parsed_function_name
inherited

◆ m_parsing_anon_fcn_body

bool octave::lexical_feedback::m_parsing_anon_fcn_body
inherited

Definition at line 395 of file lex.h.

Referenced by handle_identifier(), and octave::lexical_feedback::reset().

◆ m_parsing_class_method

bool octave::lexical_feedback::m_parsing_class_method
inherited

Definition at line 398 of file lex.h.

Referenced by octave::lexical_feedback::reset(), and octave::base_parser::start_function().

◆ m_parsing_classdef

bool octave::lexical_feedback::m_parsing_classdef
inherited

◆ m_parsing_classdef_decl

bool octave::lexical_feedback::m_parsing_classdef_decl
inherited

Definition at line 406 of file lex.h.

Referenced by handle_op(), and octave::lexical_feedback::reset().

◆ m_parsing_classdef_get_method

bool octave::lexical_feedback::m_parsing_classdef_get_method
inherited

Definition at line 418 of file lex.h.

Referenced by octave::lexical_feedback::reset(), and octave::base_parser::start_function().

◆ m_parsing_classdef_set_method

bool octave::lexical_feedback::m_parsing_classdef_set_method
inherited

Definition at line 421 of file lex.h.

Referenced by octave::lexical_feedback::reset(), and octave::base_parser::start_function().

◆ m_parsing_classdef_superclass

bool octave::lexical_feedback::m_parsing_classdef_superclass
inherited

Definition at line 410 of file lex.h.

Referenced by handle_op(), and octave::lexical_feedback::reset().

◆ m_pending_local_variables

std::set<std::string> octave::lexical_feedback::m_pending_local_variables
inherited

◆ m_quote_is_transpose

bool octave::lexical_feedback::m_quote_is_transpose
inherited

Definition at line 424 of file lex.h.

Referenced by octave::lexical_feedback::reset().

◆ m_reading_classdef_file

◆ m_reading_fcn_file

◆ m_reading_script_file

◆ m_scanner

void* octave::base_lexer::m_scanner

◆ m_string_text

std::string octave::lexical_feedback::m_string_text
inherited

Definition at line 479 of file lex.h.

Referenced by finish_command_arg(), and octave::lexical_feedback::reset().

◆ m_symtab_context

◆ m_tok_beg

◆ m_tok_end

◆ m_token_count

size_t octave::lexical_feedback::m_token_count
inherited

◆ m_tokens

◆ start_state_stack

std::stack<int> octave::base_lexer::start_state_stack
protected

Definition at line 759 of file lex.h.

Referenced by clear_start_state(), pop_start_state(), and push_start_state().


The documentation for this class was generated from the following files: