Bash++
Bash++ compiler internal documentation
BashppListener.h
Go to the documentation of this file.
1 
6 #ifndef SRC_LISTENER_BASHPPLISTENER_H_
7 #define SRC_LISTENER_BASHPPLISTENER_H_
8 
9 #include <iostream>
10 #include <vector>
11 #include <set>
12 #include <list>
13 #include <memory>
14 #include <stack>
15 #include <antlr4-runtime.h>
16 
17 #include "../antlr/BashppParserBaseListener.h"
18 
19 class BashppListener;
20 
21 #include "../bpp_include/bpp_entity.cpp"
22 #include "../bpp_include/bpp_code_entity.cpp"
23 #include "../bpp_include/bpp_string.cpp"
24 #include "../bpp_include/bash_while_loop.cpp"
25 #include "../bpp_include/bash_while_condition.cpp"
26 #include "../bpp_include/bash_if.cpp"
27 #include "../bpp_include/bash_if_branch.cpp"
28 #include "../bpp_include/bash_case.cpp"
29 #include "../bpp_include/bash_case_pattern.cpp"
30 #include "../bpp_include/bash_for.cpp"
31 #include "../bpp_include/bpp_delete_statement.cpp"
32 #include "../bpp_include/bpp_dynamic_cast_statement.cpp"
33 #include "../bpp_include/bpp_value_assignment.cpp"
34 #include "../bpp_include/bpp_object_reference.cpp"
35 #include "../bpp_include/bpp_object_assignment.cpp"
36 #include "../bpp_include/bpp_pointer_dereference.cpp"
37 #include "../bpp_include/bpp_program.cpp"
38 #include "../bpp_include/bpp_class.cpp"
39 #include "../bpp_include/bpp_constructor.cpp"
40 #include "../bpp_include/bpp_destructor.cpp"
41 #include "../bpp_include/bpp_datamember.cpp"
42 #include "../bpp_include/bpp_method.cpp"
43 #include "../bpp_include/bpp_method_parameter.cpp"
44 #include "../bpp_include/bpp_object.cpp"
45 
46 #include "../syntax_error.cpp"
47 #include "../internal_error.cpp"
48 
49 #define skip_singlequote_string if (in_singlequote_string) return;
50 #define skip_syntax_errors if (error_thrown) { \
51  if (error_context == ctx) { \
52  error_thrown = false; \
53  error_context = nullptr; \
54  } \
55  return; \
56  }
57 
78 class BashppListener : public BashppParserBaseListener, std::enable_shared_from_this<BashppListener> {
79  private:
84  std::string source_file;
85 
86  bool included = false;
87 
92  std::shared_ptr<std::vector<std::string>> include_paths = nullptr;
93 
94  bool dynamic_linking = false;
95  bool suppress_warnings = false;
96 
101  std::set<std::string> included_files = {};
103 
108  std::stack<std::string> include_stack;
109 
114  std::shared_ptr<std::ostream> output_stream;
115  std::string output_file;
116  bool run_on_exit = false;
117 
122  std::vector<char*> arguments = {};
123 
124  std::shared_ptr<bpp::bpp_program> program = std::make_shared<bpp::bpp_program>();
125 
126  bool in_comment = false;
127  bool in_singlequote_string = false;
128  bool in_while_condition = false;
129  std::shared_ptr<bpp::bash_while_condition> current_while_condition = nullptr;
130 
142  std::stack<std::shared_ptr<bpp::bpp_entity>> entity_stack;
143 
144  static constexpr const char* protected_keywords[] = {
145  "class", "constructor", "delete", "destructor",
146  "dynamic_cast", "include", "include_once", "method",
147  "new", "nullptr", "primitive", "private",
148  "protected", "public", "this", "virtual"
149  };
150 
151  inline bool is_protected_keyword(const std::string& keyword) {
152  for (const char* protected_keyword : protected_keywords) {
153  if (keyword == protected_keyword) {
154  return true;
155  }
156  }
157  return false;
158  }
159 
160  std::shared_ptr<bpp::bpp_class> primitive;
161 
162  bool error_thrown = false;
163  antlr4::ParserRuleContext* error_context = nullptr;
164 
165  bool program_has_errors = false;
166 
167  #define set_error_context error_thrown = true; error_context = ctx;
168 
169  #define output_syntax_error(symbol, msg) \
170  int line = symbol->getLine(); \
171  int column = symbol->getCharPositionInLine(); \
172  std::string text = symbol->getText(); \
173  print_syntax_error_or_warning(source_file, line, column, text, msg, get_include_stack()); \
174  program_has_errors = true;
175 
176  #define throw_syntax_error_sym(symbol, msg) \
177  output_syntax_error(symbol, msg) \
178  set_error_context \
179  return;
180 
181  #define throw_syntax_error(token, msg) antlr4::Token* symbol = token->getSymbol(); \
182  throw_syntax_error_sym(symbol, msg) \
183  set_error_context \
184  return;
185 
186  #define throw_syntax_error_from_exitRule(token, msg) antlr4::Token* symbol = token->getSymbol(); \
187  output_syntax_error(symbol, msg) \
188  return;
189 
190  #define show_warning_sym(symbol, msg) \
191  if (!suppress_warnings) { \
192  int line = symbol->getLine(); \
193  int column = symbol->getCharPositionInLine(); \
194  std::string text = symbol->getText(); \
195  print_syntax_error_or_warning(source_file, line, column, text, msg, get_include_stack(), true); \
196  }
197 
198  #define show_warning(token, msg) antlr4::Token* symbol = token->getSymbol(); \
199  show_warning_sym(symbol, msg)
200 
201  public:
202 
203  void set_source_file(std::string source_file);
204  void set_include_paths(std::shared_ptr<std::vector<std::string>> include_paths);
206  void set_included(bool included);
208  void set_errors();
209  void set_output_stream(std::shared_ptr<std::ostream> output_stream);
210  void set_output_file(std::string output_file);
211  void set_run_on_exit(bool run_on_exit);
213  void set_arguments(std::vector<char*> arguments);
214 
215  std::shared_ptr<bpp::bpp_program> get_program();
216  std::set<std::string> get_included_files();
217  std::stack<std::string> get_include_stack();
218 
232  struct code_segment {
233  std::string pre_code = "";
234  std::string code = "";
235  std::string post_code = "";
236  };
237 
238  code_segment generate_supershell_code(const std::string& code_to_run_in_supershell);
239  code_segment generate_delete_code(std::shared_ptr<bpp::bpp_object> object, const std::string& object_reference_string, bool force_pointer = false);
240  code_segment generate_method_call_code(const std::string& reference_code, const std::string& method_name, std::shared_ptr<bpp::bpp_class> assumed_class);
241  code_segment generate_dynamic_cast_code(const std::string& reference_code, const std::string& class_name);
242 
243  void enterProgram(BashppParser::ProgramContext *ctx) override;
244  void exitProgram(BashppParser::ProgramContext *ctx) override;
245 
246  void enterInclude_statement(BashppParser::Include_statementContext *ctx) override;
247  void exitInclude_statement(BashppParser::Include_statementContext *ctx) override;
248 
249  void enterClass_definition(BashppParser::Class_definitionContext *ctx) override;
250  void exitClass_definition(BashppParser::Class_definitionContext *ctx) override;
251 
252  void enterMember_declaration(BashppParser::Member_declarationContext *ctx) override;
253  void exitMember_declaration(BashppParser::Member_declarationContext *ctx) override;
254 
255  void enterObject_instantiation(BashppParser::Object_instantiationContext *ctx) override;
256  void exitObject_instantiation(BashppParser::Object_instantiationContext *ctx) override;
257 
258  void enterPointer_declaration(BashppParser::Pointer_declarationContext *ctx) override;
259  void exitPointer_declaration(BashppParser::Pointer_declarationContext *ctx) override;
260 
261  void enterValue_assignment(BashppParser::Value_assignmentContext *ctx) override;
262  void exitValue_assignment(BashppParser::Value_assignmentContext *ctx) override;
263 
264  void enterMethod_definition(BashppParser::Method_definitionContext *ctx) override;
265  void exitMethod_definition(BashppParser::Method_definitionContext *ctx) override;
266 
267  void enterConstructor_definition(BashppParser::Constructor_definitionContext *ctx) override;
268  void exitConstructor_definition(BashppParser::Constructor_definitionContext *ctx) override;
269 
270  void enterDestructor_definition(BashppParser::Destructor_definitionContext *ctx) override;
271  void exitDestructor_definition(BashppParser::Destructor_definitionContext *ctx) override;
272 
273  void enterSelf_reference(BashppParser::Self_referenceContext *ctx) override;
274  void exitSelf_reference(BashppParser::Self_referenceContext *ctx) override;
275 
276  void enterSelf_reference_as_lvalue(BashppParser::Self_reference_as_lvalueContext *ctx) override;
277  void exitSelf_reference_as_lvalue(BashppParser::Self_reference_as_lvalueContext *ctx) override;
278 
279  void enterStatement(BashppParser::StatementContext *ctx) override;
280  void exitStatement(BashppParser::StatementContext *ctx) override;
281 
282  void enterClass_body_statement(BashppParser::Class_body_statementContext *ctx) override;
283  void exitClass_body_statement(BashppParser::Class_body_statementContext *ctx) override;
284 
285  void enterGeneral_statement(BashppParser::General_statementContext *ctx) override;
286  void exitGeneral_statement(BashppParser::General_statementContext *ctx) override;
287 
288  void enterObject_assignment(BashppParser::Object_assignmentContext *ctx) override;
289 
290  void exitObject_assignment(BashppParser::Object_assignmentContext *ctx) override;
291 
292  void enterPointer_dereference(BashppParser::Pointer_dereferenceContext *ctx) override;
293  void exitPointer_dereference(BashppParser::Pointer_dereferenceContext *ctx) override;
294 
295  void enterObject_address(BashppParser::Object_addressContext *ctx) override;
296  void exitObject_address(BashppParser::Object_addressContext *ctx) override;
297 
298  void enterObject_reference(BashppParser::Object_referenceContext *ctx) override;
299  void exitObject_reference(BashppParser::Object_referenceContext *ctx) override;
300 
301  void enterObject_reference_as_lvalue(BashppParser::Object_reference_as_lvalueContext *ctx) override;
302  void exitObject_reference_as_lvalue(BashppParser::Object_reference_as_lvalueContext *ctx) override;
303 
304  void enterNullptr_ref(BashppParser::Nullptr_refContext *ctx) override;
305  void exitNullptr_ref(BashppParser::Nullptr_refContext *ctx) override;
306 
307  void enterNew_statement(BashppParser::New_statementContext *ctx) override;
308  void exitNew_statement(BashppParser::New_statementContext *ctx) override;
309 
310  void enterDelete_statement(BashppParser::Delete_statementContext *ctx) override;
311  void exitDelete_statement(BashppParser::Delete_statementContext *ctx) override;
312 
313  void enterDynamic_cast_statement(BashppParser::Dynamic_cast_statementContext *ctx) override;
314  void exitDynamic_cast_statement(BashppParser::Dynamic_cast_statementContext *ctx) override;
315 
316  void enterSupershell(BashppParser::SupershellContext *ctx) override;
317  void exitSupershell(BashppParser::SupershellContext *ctx) override;
318 
319  void enterSubshell(BashppParser::SubshellContext *ctx) override;
320  void exitSubshell(BashppParser::SubshellContext *ctx) override;
321 
322  void enterDeprecated_subshell(BashppParser::Deprecated_subshellContext *ctx) override;
323  void exitDeprecated_subshell(BashppParser::Deprecated_subshellContext *ctx) override;
324 
325  void enterBash_arithmetic(BashppParser::Bash_arithmeticContext *ctx) override;
326  void exitBash_arithmetic(BashppParser::Bash_arithmeticContext *ctx) override;
327 
328  void enterString(BashppParser::StringContext *ctx) override;
329  void exitString(BashppParser::StringContext *ctx) override;
330 
331  void enterSinglequote_string(BashppParser::Singlequote_stringContext *ctx) override;
332  void exitSinglequote_string(BashppParser::Singlequote_stringContext *ctx) override;
333 
334  void enterParameter(BashppParser::ParameterContext *ctx) override;
335  void exitParameter(BashppParser::ParameterContext *ctx) override;
336 
337  void enterOther_statement(BashppParser::Other_statementContext *ctx) override;
338  void exitOther_statement(BashppParser::Other_statementContext *ctx) override;
339 
340  void enterRaw_rvalue(BashppParser::Raw_rvalueContext *ctx) override;
341  void exitRaw_rvalue(BashppParser::Raw_rvalueContext *ctx) override;
342 
343  void enterArray_value(BashppParser::Array_valueContext *ctx) override;
344  void exitArray_value(BashppParser::Array_valueContext *ctx) override;
345 
346  void enterArray_index(BashppParser::Array_indexContext *ctx) override;
347  void exitArray_index(BashppParser::Array_indexContext *ctx) override;
348 
349  void enterBash_if_statement(BashppParser::Bash_if_statementContext *ctx) override;
350  void exitBash_if_statement(BashppParser::Bash_if_statementContext *ctx) override;
351 
352  void enterBash_if_root_branch(BashppParser::Bash_if_root_branchContext *ctx) override;
353  void exitBash_if_root_branch(BashppParser::Bash_if_root_branchContext *ctx) override;
354 
355  void enterBash_if_else_branch(BashppParser::Bash_if_else_branchContext *ctx) override;
356  void exitBash_if_else_branch(BashppParser::Bash_if_else_branchContext *ctx) override;
357 
358  void enterBash_if_condition(BashppParser::Bash_if_conditionContext *ctx) override;
359  void exitBash_if_condition(BashppParser::Bash_if_conditionContext *ctx) override;
360 
361  void enterBash_case_statement(BashppParser::Bash_case_statementContext *ctx) override;
362  void exitBash_case_statement(BashppParser::Bash_case_statementContext *ctx) override;
363 
364  void enterBash_case_pattern(BashppParser::Bash_case_patternContext *ctx) override;
365  void exitBash_case_pattern(BashppParser::Bash_case_patternContext *ctx) override;
366 
367  void enterBash_case_pattern_header(BashppParser::Bash_case_pattern_headerContext *ctx) override;
368  void exitBash_case_pattern_header(BashppParser::Bash_case_pattern_headerContext *ctx) override;
369 
370  void enterBash_while_loop(BashppParser::Bash_while_loopContext *ctx) override;
371  void exitBash_while_loop(BashppParser::Bash_while_loopContext *ctx) override;
372 
373  void enterBash_while_condition(BashppParser::Bash_while_conditionContext *ctx) override;
374  void exitBash_while_condition(BashppParser::Bash_while_conditionContext *ctx) override;
375 
376  void enterBash_for_loop(BashppParser::Bash_for_loopContext *ctx) override;
377  void exitBash_for_loop(BashppParser::Bash_for_loopContext *ctx) override;
378 
379  void enterBash_for_header(BashppParser::Bash_for_headerContext *ctx) override;
380  void exitBash_for_header(BashppParser::Bash_for_headerContext *ctx) override;
381 
382  void enterHeredoc(BashppParser::HeredocContext *ctx) override;
383  void exitHeredoc(BashppParser::HeredocContext *ctx) override;
384 
385  void enterHeredoc_header(BashppParser::Heredoc_headerContext *ctx) override;
386  void exitHeredoc_header(BashppParser::Heredoc_headerContext *ctx) override;
387 
388  void enterExtra_statement(BashppParser::Extra_statementContext *ctx) override;
389  void exitExtra_statement(BashppParser::Extra_statementContext *ctx) override;
390 
391  void enterTerminal_token(BashppParser::Terminal_tokenContext *ctx) override;
392  void exitTerminal_token(BashppParser::Terminal_tokenContext *ctx) override;
393 
394 };
395 
396 #endif // SRC_LISTENER_BASHPPLISTENER_H_
The main listener class for the Bash++ compiler.
Definition: BashppListener.h:78
void enterValue_assignment(BashppParser::Value_assignmentContext *ctx) override
Definition: value_assignment.cpp:11
code_segment generate_method_call_code(const std::string &reference_code, const std::string &method_name, std::shared_ptr< bpp::bpp_class > assumed_class)
Generates a code segment for calling a method.
Definition: BashppListener.cpp:104
void enterBash_while_loop(BashppParser::Bash_while_loopContext *ctx) override
Definition: bash_while_loop.cpp:17
void enterArray_index(BashppParser::Array_indexContext *ctx) override
Definition: array_index.cpp:11
void exitBash_for_header(BashppParser::Bash_for_headerContext *ctx) override
Definition: bash_for_loop.cpp:72
std::shared_ptr< bpp::bash_while_condition > current_while_condition
Definition: BashppListener.h:129
void exitObject_assignment(BashppParser::Object_assignmentContext *ctx) override
Definition: object_assignment.cpp:26
void exitBash_if_root_branch(BashppParser::Bash_if_root_branchContext *ctx) override
Definition: bash_if_statement.cpp:145
void exitDelete_statement(BashppParser::Delete_statementContext *ctx) override
Definition: delete_statement.cpp:38
void enterBash_case_statement(BashppParser::Bash_case_statementContext *ctx) override
Definition: bash_case_statement.cpp:18
void enterBash_if_root_branch(BashppParser::Bash_if_root_branchContext *ctx) override
Definition: bash_if_statement.cpp:124
void enterMember_declaration(BashppParser::Member_declarationContext *ctx) override
Definition: member_declaration.cpp:11
bool run_on_exit
Definition: BashppListener.h:116
void exitArray_value(BashppParser::Array_valueContext *ctx) override
Definition: array_value.cpp:38
std::stack< std::string > include_stack
A chain of included files, from the main file to the current file (used for error reporting)
Definition: BashppListener.h:108
bool error_thrown
Definition: BashppListener.h:162
void set_include_paths(std::shared_ptr< std::vector< std::string >> include_paths)
Definition: BashppListener.cpp:161
void set_output_file(std::string output_file)
Definition: BashppListener.cpp:195
void exitRaw_rvalue(BashppParser::Raw_rvalueContext *ctx) override
Definition: raw_rvalue.cpp:22
bool program_has_errors
Definition: BashppListener.h:165
void exitBash_case_statement(BashppParser::Bash_case_statementContext *ctx) override
Definition: bash_case_statement.cpp:51
void exitSelf_reference(BashppParser::Self_referenceContext *ctx) override
Definition: self_reference.cpp:43
code_segment generate_dynamic_cast_code(const std::string &reference_code, const std::string &class_name)
Generates a code segment for performing a dynamic cast.
Definition: BashppListener.cpp:145
void enterHeredoc_header(BashppParser::Heredoc_headerContext *ctx) override
Definition: heredoc.cpp:54
void enterBash_while_condition(BashppParser::Bash_while_conditionContext *ctx) override
Definition: bash_while_loop.cpp:68
void set_run_on_exit(bool run_on_exit)
Definition: BashppListener.cpp:199
void enterInclude_statement(BashppParser::Include_statementContext *ctx) override
Definition: include_statement.cpp:11
void enterSubshell(BashppParser::SubshellContext *ctx) override
Definition: subshell.cpp:11
void exitSinglequote_string(BashppParser::Singlequote_stringContext *ctx) override
Definition: singlequote_string.cpp:24
void exitTerminal_token(BashppParser::Terminal_tokenContext *ctx) override
Definition: terminal_token.cpp:23
void enterPointer_dereference(BashppParser::Pointer_dereferenceContext *ctx) override
Definition: pointer_dereference.cpp:11
std::vector< char * > arguments
Command-line arguments to pass to the compiled program if run_on_exit is true.
Definition: BashppListener.h:122
bool in_singlequote_string
Definition: BashppListener.h:127
void enterClass_definition(BashppParser::Class_definitionContext *ctx) override
Definition: class_definition.cpp:11
void enterArray_value(BashppParser::Array_valueContext *ctx) override
Definition: array_value.cpp:11
void exitNullptr_ref(BashppParser::Nullptr_refContext *ctx) override
Definition: nullptr_ref.cpp:30
void enterSelf_reference(BashppParser::Self_referenceContext *ctx) override
Definition: self_reference.cpp:11
void exitClass_definition(BashppParser::Class_definitionContext *ctx) override
Definition: class_definition.cpp:51
code_segment generate_supershell_code(const std::string &code_to_run_in_supershell)
Generates a supershell code segment for executing a bash command.
Definition: BashppListener.cpp:28
void exitConstructor_definition(BashppParser::Constructor_definitionContext *ctx) override
Definition: constructor_definition.cpp:38
void set_source_file(std::string source_file)
Definition: BashppListener.cpp:157
void set_output_stream(std::shared_ptr< std::ostream > output_stream)
Definition: BashppListener.cpp:191
bool in_comment
Definition: BashppListener.h:126
void exitObject_reference_as_lvalue(BashppParser::Object_reference_as_lvalueContext *ctx) override
Definition: object_reference_as_lvalue.cpp:274
void exitBash_if_statement(BashppParser::Bash_if_statementContext *ctx) override
Definition: bash_if_statement.cpp:94
void enterSelf_reference_as_lvalue(BashppParser::Self_reference_as_lvalueContext *ctx) override
Definition: self_reference_as_lvalue.cpp:11
void set_errors()
Sets the program_has_errors flag to true.
Definition: BashppListener.cpp:187
bool in_while_condition
Definition: BashppListener.h:128
void enterDelete_statement(BashppParser::Delete_statementContext *ctx) override
Definition: delete_statement.cpp:11
void enterBash_for_loop(BashppParser::Bash_for_loopContext *ctx) override
Definition: bash_for_loop.cpp:17
void enterOther_statement(BashppParser::Other_statementContext *ctx) override
Definition: other_statement.cpp:11
void set_included(bool included)
Definition: BashppListener.cpp:169
std::shared_ptr< std::ostream > output_stream
Pointer to the output stream to write the compiled code to.
Definition: BashppListener.h:114
std::set< std::string > get_included_files()
Definition: BashppListener.cpp:215
void exitBash_arithmetic(BashppParser::Bash_arithmeticContext *ctx) override
Definition: bash_arithmetic.cpp:38
void set_included_from(BashppListener *included_from)
Sets the included_from pointer to the given listener.
Definition: BashppListener.cpp:176
void enterMethod_definition(BashppParser::Method_definitionContext *ctx) override
Definition: method_definition.cpp:11
void exitHeredoc_header(BashppParser::Heredoc_headerContext *ctx) override
Definition: heredoc.cpp:70
std::string output_file
Definition: BashppListener.h:115
void exitDynamic_cast_statement(BashppParser::Dynamic_cast_statementContext *ctx) override
Definition: dynamic_cast.cpp:46
void enterExtra_statement(BashppParser::Extra_statementContext *ctx) override
Definition: extra_statement.cpp:11
void enterStatement(BashppParser::StatementContext *ctx) override
Definition: statement.cpp:11
void exitBash_for_loop(BashppParser::Bash_for_loopContext *ctx) override
Definition: bash_for_loop.cpp:33
void enterObject_instantiation(BashppParser::Object_instantiationContext *ctx) override
Definition: object_instantiation.cpp:11
void exitObject_address(BashppParser::Object_addressContext *ctx) override
Definition: object_address.cpp:35
void exitMember_declaration(BashppParser::Member_declarationContext *ctx) override
Definition: member_declaration.cpp:64
bool included
Definition: BashppListener.h:86
code_segment generate_delete_code(std::shared_ptr< bpp::bpp_object > object, const std::string &object_reference_string, bool force_pointer=false)
Generates a code segment for deleting an object.
Definition: BashppListener.cpp:72
void exitExtra_statement(BashppParser::Extra_statementContext *ctx) override
Definition: extra_statement.cpp:23
void exitParameter(BashppParser::ParameterContext *ctx) override
Definition: parameter.cpp:51
bool suppress_warnings
Definition: BashppListener.h:95
void set_arguments(std::vector< char * > arguments)
Definition: BashppListener.cpp:207
antlr4::ParserRuleContext * error_context
Definition: BashppListener.h:163
void enterSinglequote_string(BashppParser::Singlequote_stringContext *ctx) override
Definition: singlequote_string.cpp:11
void enterParameter(BashppParser::ParameterContext *ctx) override
Definition: parameter.cpp:11
void enterObject_reference(BashppParser::Object_referenceContext *ctx) override
Definition: object_reference.cpp:11
std::stack< std::shared_ptr< bpp::bpp_entity > > entity_stack
A stack to keep track of the current entity being processed.
Definition: BashppListener.h:142
std::set< std::string > included_files
A set of (unique) included files (used for '@include_once' directives)
Definition: BashppListener.h:101
void enterNullptr_ref(BashppParser::Nullptr_refContext *ctx) override
Definition: nullptr_ref.cpp:11
void exitBash_case_pattern(BashppParser::Bash_case_patternContext *ctx) override
Definition: bash_case_statement.cpp:93
void enterNew_statement(BashppParser::New_statementContext *ctx) override
Definition: new_statement.cpp:11
void enterBash_if_condition(BashppParser::Bash_if_conditionContext *ctx) override
Definition: bash_if_statement.cpp:213
void enterBash_if_else_branch(BashppParser::Bash_if_else_branchContext *ctx) override
Definition: bash_if_statement.cpp:166
void exitObject_instantiation(BashppParser::Object_instantiationContext *ctx) override
Definition: object_instantiation.cpp:82
void enterBash_if_statement(BashppParser::Bash_if_statementContext *ctx) override
Definition: bash_if_statement.cpp:19
void exitHeredoc(BashppParser::HeredocContext *ctx) override
Definition: heredoc.cpp:33
bool is_protected_keyword(const std::string &keyword)
Definition: BashppListener.h:151
void enterTerminal_token(BashppParser::Terminal_tokenContext *ctx) override
Definition: terminal_token.cpp:11
void enterObject_assignment(BashppParser::Object_assignmentContext *ctx) override
Definition: object_assignment.cpp:11
BashppListener * included_from
Definition: BashppListener.h:102
void enterBash_arithmetic(BashppParser::Bash_arithmeticContext *ctx) override
Definition: bash_arithmetic.cpp:11
void enterHeredoc(BashppParser::HeredocContext *ctx) override
Definition: heredoc.cpp:17
std::shared_ptr< std::vector< std::string > > include_paths
A list of paths to search for included files.
Definition: BashppListener.h:92
void exitBash_while_loop(BashppParser::Bash_while_loopContext *ctx) override
Definition: bash_while_loop.cpp:33
void enterDestructor_definition(BashppParser::Destructor_definitionContext *ctx) override
Definition: destructor_definition.cpp:11
void set_suppress_warnings(bool suppress_warnings)
Definition: BashppListener.cpp:203
void enterBash_case_pattern(BashppParser::Bash_case_patternContext *ctx) override
Definition: bash_case_statement.cpp:74
void enterGeneral_statement(BashppParser::General_statementContext *ctx) override
Definition: general_statement.cpp:11
void enterString(BashppParser::StringContext *ctx) override
Definition: string.cpp:11
void enterDynamic_cast_statement(BashppParser::Dynamic_cast_statementContext *ctx) override
Definition: dynamic_cast.cpp:11
void exitSupershell(BashppParser::SupershellContext *ctx) override
Definition: supershell.cpp:34
void exitOther_statement(BashppParser::Other_statementContext *ctx) override
Definition: other_statement.cpp:30
void exitNew_statement(BashppParser::New_statementContext *ctx) override
Definition: new_statement.cpp:46
void enterSupershell(BashppParser::SupershellContext *ctx) override
Definition: supershell.cpp:11
std::shared_ptr< bpp::bpp_class > primitive
Definition: BashppListener.h:160
void enterBash_case_pattern_header(BashppParser::Bash_case_pattern_headerContext *ctx) override
Definition: bash_case_statement.cpp:118
void exitBash_while_condition(BashppParser::Bash_while_conditionContext *ctx) override
Definition: bash_while_loop.cpp:89
void exitGeneral_statement(BashppParser::General_statementContext *ctx) override
Definition: general_statement.cpp:24
void exitPointer_dereference(BashppParser::Pointer_dereferenceContext *ctx) override
Definition: pointer_dereference.cpp:48
void exitProgram(BashppParser::ProgramContext *ctx) override
Definition: program.cpp:31
void exitSubshell(BashppParser::SubshellContext *ctx) override
Definition: subshell.cpp:31
void enterPointer_declaration(BashppParser::Pointer_declarationContext *ctx) override
Definition: pointer_declaration.cpp:11
void exitArray_index(BashppParser::Array_indexContext *ctx) override
Definition: array_index.cpp:39
void exitBash_case_pattern_header(BashppParser::Bash_case_pattern_headerContext *ctx) override
Definition: bash_case_statement.cpp:135
void exitClass_body_statement(BashppParser::Class_body_statementContext *ctx) override
Definition: class_body_statement.cpp:44
void exitString(BashppParser::StringContext *ctx) override
Definition: string.cpp:35
void enterRaw_rvalue(BashppParser::Raw_rvalueContext *ctx) override
Definition: raw_rvalue.cpp:11
void enterProgram(BashppParser::ProgramContext *ctx) override
Definition: program.cpp:14
void exitDestructor_definition(BashppParser::Destructor_definitionContext *ctx) override
Definition: destructor_definition.cpp:38
void enterDeprecated_subshell(BashppParser::Deprecated_subshellContext *ctx) override
Definition: deprecated_subshell.cpp:11
void exitObject_reference(BashppParser::Object_referenceContext *ctx) override
Definition: object_reference.cpp:40
void exitInclude_statement(BashppParser::Include_statementContext *ctx) override
Definition: include_statement.cpp:172
std::shared_ptr< bpp::bpp_program > program
Definition: BashppListener.h:124
void enterObject_reference_as_lvalue(BashppParser::Object_reference_as_lvalueContext *ctx) override
Definition: object_reference_as_lvalue.cpp:11
std::string source_file
Path to the source file being compiled (used for error reporting)
Definition: BashppListener.h:84
void enterConstructor_definition(BashppParser::Constructor_definitionContext *ctx) override
Definition: constructor_definition.cpp:11
void enterClass_body_statement(BashppParser::Class_body_statementContext *ctx) override
Definition: class_body_statement.cpp:11
std::shared_ptr< bpp::bpp_program > get_program()
Definition: BashppListener.cpp:211
void exitValue_assignment(BashppParser::Value_assignmentContext *ctx) override
Definition: value_assignment.cpp:35
void enterBash_for_header(BashppParser::Bash_for_headerContext *ctx) override
Definition: bash_for_loop.cpp:56
void exitStatement(BashppParser::StatementContext *ctx) override
Definition: statement.cpp:16
void exitBash_if_else_branch(BashppParser::Bash_if_else_branchContext *ctx) override
Definition: bash_if_statement.cpp:192
void exitPointer_declaration(BashppParser::Pointer_declarationContext *ctx) override
Definition: pointer_declaration.cpp:92
void exitSelf_reference_as_lvalue(BashppParser::Self_reference_as_lvalueContext *ctx) override
Definition: self_reference_as_lvalue.cpp:212
void set_dynamic_linking(bool dynamic_linking)
Definition: BashppListener.cpp:165
void enterObject_address(BashppParser::Object_addressContext *ctx) override
Definition: object_address.cpp:11
static constexpr const char * protected_keywords[]
Definition: BashppListener.h:144
void exitBash_if_condition(BashppParser::Bash_if_conditionContext *ctx) override
Definition: bash_if_statement.cpp:232
bool dynamic_linking
Definition: BashppListener.h:94
std::stack< std::string > get_include_stack()
Definition: BashppListener.cpp:219
void exitMethod_definition(BashppParser::Method_definitionContext *ctx) override
Definition: method_definition.cpp:49
void exitDeprecated_subshell(BashppParser::Deprecated_subshellContext *ctx) override
Definition: deprecated_subshell.cpp:31
A struct to hold (compiled) code segments.
Definition: BashppListener.h:232
std::string post_code
Definition: BashppListener.h:235
std::string code
Definition: BashppListener.h:234
std::string pre_code
Definition: BashppListener.h:233