Bash++
Bash++ compiler internal documentation
BashppListener.h
Go to the documentation of this file.
1
7#pragma once
8
9#include <iostream>
10#include <vector>
11#include <set>
12#include <list>
13#include <memory>
14#include <stack>
15#include <optional>
16#include <fstream>
17#include <unordered_map>
18
20
21class BashppListener;
22
29
30#include <bpp_include/bpp.h>
31#include <include/BashVersion.h>
33
34#include <error/detail.h>
35#include <error/SyntaxError.h>
36#include <error/InternalError.h>
37
58class BashppListener : public AST::BaseListener<BashppListener>, std::enable_shared_from_this<BashppListener> {
59 private:
64 std::string source_file;
65
66 bool included = false;
67
72 std::shared_ptr<std::vector<std::string>> include_paths = nullptr;
73
74 bool suppress_warnings = false;
75
80 std::shared_ptr<std::set<std::string>> included_files = std::make_shared<std::set<std::string>>();
82
87 std::vector<std::string> include_stack;
88
93 std::shared_ptr<std::ostream> code_buffer;
94 std::shared_ptr<std::ostream> output_stream;
95 std::string output_file;
96 bool run_on_exit = false;
97
103
108 std::vector<char*> arguments = {};
109
110 std::shared_ptr<bpp::bpp_program> program = std::make_shared<bpp::bpp_program>();
111
112 bool in_method = false;
113
114 bool in_class = false;
115 bool in_supershell = false;
116 std::stack<std::monostate> bash_function_stack;
117 bool should_declare_local() const;
118
119 // Diagnostic information (not used for compilation):
120 std::stack<std::monostate> dynamic_cast_stack; // Used to track whether we're inside a dynamic_cast statement
121 std::stack<std::monostate> typeof_stack; // Used to track whether we're inside a typeof expression
122
124
136 std::stack<std::shared_ptr<bpp::bpp_entity>> entity_stack;
137
145 std::unordered_map<std::string, std::string> replacement_file_contents;
146
147 std::shared_ptr<bpp::bpp_class> primitive;
148
149 bool lsp_mode = false; // Whether this listener is just running as part of the language server (i.e., not really compiling anything)
150
151 #define show_warning(token, msg) \
152 if (!suppress_warnings) { \
153 bpp::ErrorHandling::Warning _msg(this, token, msg); \
154 _msg.print(); \
155 }
156
157 public:
158
159 void set_source_file(std::string source_file);
160 void set_include_paths(std::shared_ptr<std::vector<std::string>> include_paths);
161 void set_included(bool included);
163 void set_included_files(std::shared_ptr<std::set<std::string>> included_files);
164 void set_code_buffer(std::shared_ptr<std::ostream> code_buffer);
165 void set_output_stream(std::shared_ptr<std::ostream> output_stream);
166 void set_output_file(std::string output_file);
167 void set_run_on_exit(bool run_on_exit);
170 void set_arguments(std::vector<char*> arguments);
171 void set_lsp_mode(bool lsp_mode);
172
173 void set_replacement_file_contents(const std::string& file_path, const std::string& contents);
174
175 std::shared_ptr<bpp::bpp_program> get_program();
176 std::shared_ptr<std::set<std::string>> get_included_files();
177 const std::vector<std::string>& get_include_stack();
178 std::string get_source_file();
179 bool get_lsp_mode();
180
181 std::shared_ptr<bpp::bpp_code_entity> latest_code_entity();
182
183 void enterProgram(std::shared_ptr<AST::Program> node);
184 void exitProgram(std::shared_ptr<AST::Program> node);
185 void enterArrayAssignment(std::shared_ptr<AST::ArrayAssignment> node);
186 void exitArrayAssignment(std::shared_ptr<AST::ArrayAssignment> node);
187 void enterArrayIndex(std::shared_ptr<AST::ArrayIndex> node);
188 void exitArrayIndex(std::shared_ptr<AST::ArrayIndex> node);
189 void enterBash53NativeSupershell(std::shared_ptr<AST::Bash53NativeSupershell> node);
190 void exitBash53NativeSupershell(std::shared_ptr<AST::Bash53NativeSupershell> node);
191 void enterBashArithmeticForCondition(std::shared_ptr<AST::BashArithmeticForCondition> node);
192 void exitBashArithmeticForCondition(std::shared_ptr<AST::BashArithmeticForCondition> node);
193 void enterBashArithmeticForStatement(std::shared_ptr<AST::BashArithmeticForStatement> node);
194 void exitBashArithmeticForStatement(std::shared_ptr<AST::BashArithmeticForStatement> node);
195 void enterBashArithmeticSubstitution(std::shared_ptr<AST::BashArithmeticSubstitution> node);
196 void exitBashArithmeticSubstitution(std::shared_ptr<AST::BashArithmeticSubstitution> node);
197 void enterBashCasePattern(std::shared_ptr<AST::BashCasePattern> node);
198 void exitBashCasePattern(std::shared_ptr<AST::BashCasePattern> node);
199 void enterBashCasePatternHeader(std::shared_ptr<AST::BashCasePatternHeader> node);
200 void exitBashCasePatternHeader(std::shared_ptr<AST::BashCasePatternHeader> node);
201 void enterBashCaseStatement(std::shared_ptr<AST::BashCaseStatement> node);
202 void exitBashCaseStatement(std::shared_ptr<AST::BashCaseStatement> node);
203 //void enterBashCommand(std::shared_ptr<AST::BashCommand> node);
204 //void exitBashCommand(std::shared_ptr<AST::BashCommand> node);
205 void enterBashCommandSequence(std::shared_ptr<AST::BashCommandSequence> node);
206 void exitBashCommandSequence(std::shared_ptr<AST::BashCommandSequence> node);
207 void enterBashForStatement(std::shared_ptr<AST::BashForStatement> node);
208 void exitBashForStatement(std::shared_ptr<AST::BashForStatement> node);
209 void enterBashIfCondition(std::shared_ptr<AST::BashIfCondition> node);
210 void exitBashIfCondition(std::shared_ptr<AST::BashIfCondition> node);
211 void enterBashIfElseBranch(std::shared_ptr<AST::BashIfElseBranch> node);
212 void exitBashIfElseBranch(std::shared_ptr<AST::BashIfElseBranch> node);
213 void enterBashIfRootBranch(std::shared_ptr<AST::BashIfRootBranch> node);
214 void exitBashIfRootBranch(std::shared_ptr<AST::BashIfRootBranch> node);
215 void enterBashIfStatement(std::shared_ptr<AST::BashIfStatement> node);
216 void exitBashIfStatement(std::shared_ptr<AST::BashIfStatement> node);
217 void enterBashInCondition(std::shared_ptr<AST::BashInCondition> node);
218 void exitBashInCondition(std::shared_ptr<AST::BashInCondition> node);
219 void enterBashPipeline(std::shared_ptr<AST::BashPipeline> node);
220 void exitBashPipeline(std::shared_ptr<AST::BashPipeline> node);
221 void enterBashRedirection(std::shared_ptr<AST::BashRedirection> node);
222 void exitBashRedirection(std::shared_ptr<AST::BashRedirection> node);
223 void enterBashSelectStatement(std::shared_ptr<AST::BashSelectStatement> node);
224 void exitBashSelectStatement(std::shared_ptr<AST::BashSelectStatement> node);
225 void enterBashTestConditionCommand(std::shared_ptr<AST::BashTestConditionCommand> node);
226 void exitBashTestConditionCommand(std::shared_ptr<AST::BashTestConditionCommand> node);
227 void enterBashUntilStatement(std::shared_ptr<AST::BashUntilStatement> node);
228 void exitBashUntilStatement(std::shared_ptr<AST::BashUntilStatement> node);
229 void enterBashVariable(std::shared_ptr<AST::BashVariable> node);
230 void exitBashVariable(std::shared_ptr<AST::BashVariable> node);
231 void enterBashWhileOrUntilCondition(std::shared_ptr<AST::BashWhileOrUntilCondition> node);
232 void exitBashWhileOrUntilCondition(std::shared_ptr<AST::BashWhileOrUntilCondition> node);
233 void enterBashWhileStatement(std::shared_ptr<AST::BashWhileStatement> node);
234 void exitBashWhileStatement(std::shared_ptr<AST::BashWhileStatement> node);
235 void enterBashFunction(std::shared_ptr<AST::BashFunction> node);
236 void exitBashFunction(std::shared_ptr<AST::BashFunction> node);
237 void enterBlock(std::shared_ptr<AST::Block> node);
238 void exitBlock(std::shared_ptr<AST::Block> node);
239 void enterClassDefinition(std::shared_ptr<AST::ClassDefinition> node);
240 void exitClassDefinition(std::shared_ptr<AST::ClassDefinition> node);
241 void enterConnective(std::shared_ptr<AST::Connective> node);
242 void exitConnective(std::shared_ptr<AST::Connective> node);
243 void enterConstructorDefinition(std::shared_ptr<AST::ConstructorDefinition> node);
244 void exitConstructorDefinition(std::shared_ptr<AST::ConstructorDefinition> node);
245 void enterDatamemberDeclaration(std::shared_ptr<AST::DatamemberDeclaration> node);
246 void exitDatamemberDeclaration(std::shared_ptr<AST::DatamemberDeclaration> node);
247 void enterDeleteStatement(std::shared_ptr<AST::DeleteStatement> node);
248 void exitDeleteStatement(std::shared_ptr<AST::DeleteStatement> node);
249 void enterDestructorDefinition(std::shared_ptr<AST::DestructorDefinition> node);
250 void exitDestructorDefinition(std::shared_ptr<AST::DestructorDefinition> node);
251 void enterDoublequotedString(std::shared_ptr<AST::DoublequotedString> node);
252 void exitDoublequotedString(std::shared_ptr<AST::DoublequotedString> node);
253 void enterDynamicCast(std::shared_ptr<AST::DynamicCast> node);
254 void exitDynamicCast(std::shared_ptr<AST::DynamicCast> node);
255 void enterDynamicCastTarget(std::shared_ptr<AST::DynamicCastTarget> node);
256 void exitDynamicCastTarget(std::shared_ptr<AST::DynamicCastTarget> node);
257 void enterHeredocBody(std::shared_ptr<AST::HeredocBody> node);
258 void exitHeredocBody(std::shared_ptr<AST::HeredocBody> node);
259 void enterHereString(std::shared_ptr<AST::HereString> node);
260 void exitHereString(std::shared_ptr<AST::HereString> node);
261 void enterIncludeStatement(std::shared_ptr<AST::IncludeStatement> node);
262 void exitIncludeStatement(std::shared_ptr<AST::IncludeStatement> node);
263 void enterMethodDefinition(std::shared_ptr<AST::MethodDefinition> node);
264 void exitMethodDefinition(std::shared_ptr<AST::MethodDefinition> node);
265 void enterNewStatement(std::shared_ptr<AST::NewStatement> node);
266 void exitNewStatement(std::shared_ptr<AST::NewStatement> node);
267 void enterObjectAssignment(std::shared_ptr<AST::ObjectAssignment> node);
268 void exitObjectAssignment(std::shared_ptr<AST::ObjectAssignment> node);
269 void enterObjectInstantiation(std::shared_ptr<AST::ObjectInstantiation> node);
270 void exitObjectInstantiation(std::shared_ptr<AST::ObjectInstantiation> node);
271 void enterObjectReference(std::shared_ptr<AST::ObjectReference> node);
272 void exitObjectReference(std::shared_ptr<AST::ObjectReference> node);
273 void enterParameterExpansion(std::shared_ptr<AST::ParameterExpansion> node);
274 void exitParameterExpansion(std::shared_ptr<AST::ParameterExpansion> node);
275 void enterPointerDeclaration(std::shared_ptr<AST::PointerDeclaration> node);
276 void exitPointerDeclaration(std::shared_ptr<AST::PointerDeclaration> node);
277 void enterPrimitiveAssignment(std::shared_ptr<AST::PrimitiveAssignment> node);
278 void exitPrimitiveAssignment(std::shared_ptr<AST::PrimitiveAssignment> node);
279 void enterProcessSubstitution(std::shared_ptr<AST::ProcessSubstitution> node);
280 void exitProcessSubstitution(std::shared_ptr<AST::ProcessSubstitution> node);
281 void enterRawSubshell(std::shared_ptr<AST::RawSubshell> node);
282 void exitRawSubshell(std::shared_ptr<AST::RawSubshell> node);
283 void enterRawText(std::shared_ptr<AST::RawText> node);
284 void exitRawText(std::shared_ptr<AST::RawText> node);
285 //void enterRvalue(std::shared_ptr<AST::Rvalue> node);
286 //void exitRvalue(std::shared_ptr<AST::Rvalue> node);
287 void enterSubshellSubstitution(std::shared_ptr<AST::SubshellSubstitution> node);
288 void exitSubshellSubstitution(std::shared_ptr<AST::SubshellSubstitution> node);
289 void enterSupershell(std::shared_ptr<AST::Supershell> node);
290 void exitSupershell(std::shared_ptr<AST::Supershell> node);
291 void enterTypeofExpression(std::shared_ptr<AST::TypeofExpression> node);
292 void exitTypeofExpression(std::shared_ptr<AST::TypeofExpression> node);
293 void enterValueAssignment(std::shared_ptr<AST::ValueAssignment> node);
294 void exitValueAssignment(std::shared_ptr<AST::ValueAssignment> node);
295
296};
CRTP base class for AST listeners. CRTP is a kind of language hack that makes static polymorphism pos...
Definition BaseListener.h:112
The main listener class for the Bash++ compiler.
Definition BashppListener.h:58
void enterDoublequotedString(std::shared_ptr< AST::DoublequotedString > node)
Definition DoublequotedString.cpp:9
void exitArrayAssignment(std::shared_ptr< AST::ArrayAssignment > node)
Definition ArrayAssignment.cpp:31
void exitBashFunction(std::shared_ptr< AST::BashFunction > node)
Definition BashFunction.cpp:50
bool in_class
Definition BashppListener.h:114
bool in_method
Definition BashppListener.h:112
void enterDestructorDefinition(std::shared_ptr< AST::DestructorDefinition > node)
Definition DestructorDefinition.cpp:9
void enterClassDefinition(std::shared_ptr< AST::ClassDefinition > node)
Definition ClassDefinition.cpp:9
void enterBashCasePattern(std::shared_ptr< AST::BashCasePattern > node)
Definition BashCaseStatement.cpp:64
void enterDynamicCastTarget(std::shared_ptr< AST::DynamicCastTarget > node)
Definition DynamicCastTarget.cpp:9
void exitBashTestConditionCommand(std::shared_ptr< AST::BashTestConditionCommand > node)
Definition BashTestConditionCommand.cpp:31
void exitBashIfElseBranch(std::shared_ptr< AST::BashIfElseBranch > node)
Definition BashIfStatement.cpp:193
void exitBashSelectStatement(std::shared_ptr< AST::BashSelectStatement > node)
Definition BashForOrSelectStatement.cpp:91
void enterBashInCondition(std::shared_ptr< AST::BashInCondition > node)
Definition BashForOrSelectStatement.cpp:122
void enterDeleteStatement(std::shared_ptr< AST::DeleteStatement > node)
Definition DeleteStatement.cpp:9
void exitDoublequotedString(std::shared_ptr< AST::DoublequotedString > node)
Definition DoublequotedString.cpp:30
void exitProcessSubstitution(std::shared_ptr< AST::ProcessSubstitution > node)
Definition ProcessSubstitution.cpp:19
bool run_on_exit
Definition BashppListener.h:96
std::vector< std::string > include_stack
A chain of included files, from the main file to the current file (used for error reporting)
Definition BashppListener.h:87
std::unordered_map< std::string, std::string > replacement_file_contents
A map of file paths to replacement contents for those files This is used by the language server to pr...
Definition BashppListener.h:145
void set_output_file(std::string output_file)
Definition BashppListener.cpp:45
void exitPointerDeclaration(std::shared_ptr< AST::PointerDeclaration > node)
Definition PointerDeclaration.cpp:81
void set_target_bash_version(BashVersion target_bash_version)
Definition BashppListener.cpp:57
void enterDynamicCast(std::shared_ptr< AST::DynamicCast > node)
Definition DynamicCast.cpp:9
void enterBashArithmeticSubstitution(std::shared_ptr< AST::BashArithmeticSubstitution > node)
Definition BashArithmeticSubstitution.cpp:9
void enterBashPipeline(std::shared_ptr< AST::BashPipeline > node)
Definition BashPipeline.cpp:9
void exitDynamicCast(std::shared_ptr< AST::DynamicCast > node)
Definition DynamicCast.cpp:40
void set_run_on_exit(bool run_on_exit)
Definition BashppListener.cpp:49
void exitBash53NativeSupershell(std::shared_ptr< AST::Bash53NativeSupershell > node)
Definition Bash53NativeSupershell.cpp:42
void exitBashPipeline(std::shared_ptr< AST::BashPipeline > node)
Definition BashPipeline.cpp:21
std::shared_ptr< std::ostream > code_buffer
Definition BashppListener.h:93
void exitConnective(std::shared_ptr< AST::Connective > node)
Definition Connective.cpp:19
bool in_supershell
Definition BashppListener.h:115
BashVersion target_bash_version
The target Bash version to compile for (default is 5.2)
Definition BashppListener.h:102
void enterBashTestConditionCommand(std::shared_ptr< AST::BashTestConditionCommand > node)
Definition BashTestConditionCommand.cpp:9
std::vector< char * > arguments
Command-line arguments to pass to the compiled program if run_on_exit is true.
Definition BashppListener.h:108
void enterBashCommandSequence(std::shared_ptr< AST::BashCommandSequence > node)
Definition BashCommandSequence.cpp:9
void enterHereString(std::shared_ptr< AST::HereString > node)
Definition HereString.cpp:9
void set_include_paths(std::shared_ptr< std::vector< std::string > > include_paths)
Definition BashppListener.cpp:13
void enterBashCaseStatement(std::shared_ptr< AST::BashCaseStatement > node)
Definition BashCaseStatement.cpp:16
void exitDeleteStatement(std::shared_ptr< AST::DeleteStatement > node)
Definition DeleteStatement.cpp:30
void enterObjectInstantiation(std::shared_ptr< AST::ObjectInstantiation > node)
Definition ObjectInstantiation.cpp:9
void enterIncludeStatement(std::shared_ptr< AST::IncludeStatement > node)
Handles.
Definition IncludeStatement.cpp:29
void exitBashCasePattern(std::shared_ptr< AST::BashCasePattern > node)
Definition BashCaseStatement.cpp:86
bool get_lsp_mode()
Definition BashppListener.cpp:85
void set_included_files(std::shared_ptr< std::set< std::string > > included_files)
Sets the included_files pointer to the given set of included files.
Definition BashppListener.cpp:33
void enterBashIfCondition(std::shared_ptr< AST::BashIfCondition > node)
Definition BashIfStatement.cpp:220
void exitConstructorDefinition(std::shared_ptr< AST::ConstructorDefinition > node)
Definition ConstructorDefinition.cpp:52
void exitBashVariable(std::shared_ptr< AST::BashVariable > node)
Definition BashVariable.cpp:21
void set_source_file(std::string source_file)
Definition BashppListener.cpp:9
void exitBashIfStatement(std::shared_ptr< AST::BashIfStatement > node)
Definition BashIfStatement.cpp:89
void exitBashArithmeticSubstitution(std::shared_ptr< AST::BashArithmeticSubstitution > node)
Definition BashArithmeticSubstitution.cpp:34
std::string get_source_file()
Definition BashppListener.cpp:81
void set_output_stream(std::shared_ptr< std::ostream > output_stream)
Definition BashppListener.cpp:41
void enterBash53NativeSupershell(std::shared_ptr< AST::Bash53NativeSupershell > node)
Definition Bash53NativeSupershell.cpp:9
void enterConnective(std::shared_ptr< AST::Connective > node)
Definition Connective.cpp:9
void enterArrayIndex(std::shared_ptr< AST::ArrayIndex > node)
Definition ArrayIndex.cpp:9
void enterBashIfRootBranch(std::shared_ptr< AST::BashIfRootBranch > node)
Definition BashIfStatement.cpp:113
void enterBashArithmeticForCondition(std::shared_ptr< AST::BashArithmeticForCondition > node)
Definition BashArithmeticForStatement.cpp:49
void enterBashIfElseBranch(std::shared_ptr< AST::BashIfElseBranch > node)
Definition BashIfStatement.cpp:164
void exitRawText(std::shared_ptr< AST::RawText > node)
Definition RawText.cpp:21
const std::vector< std::string > & get_include_stack()
Definition BashppListener.cpp:77
void set_included(bool included)
Definition BashppListener.cpp:17
void exitBlock(std::shared_ptr< AST::Block > node)
Definition Block.cpp:39
std::shared_ptr< std::ostream > output_stream
Pointer to the output stream to write the compiled code to.
Definition BashppListener.h:94
void set_included_from(BashppListener *included_from)
Sets the included_from pointer to the given listener.
Definition BashppListener.cpp:24
std::string output_file
Definition BashppListener.h:95
void exitSupershell(std::shared_ptr< AST::Supershell > node)
Definition Supershell.cpp:37
void enterBashArithmeticForStatement(std::shared_ptr< AST::BashArithmeticForStatement > node)
Definition BashArithmeticForStatement.cpp:9
void exitBashCommandSequence(std::shared_ptr< AST::BashCommandSequence > node)
Definition BashCommandSequence.cpp:22
void exitClassDefinition(std::shared_ptr< AST::ClassDefinition > node)
Definition ClassDefinition.cpp:69
void exitObjectReference(std::shared_ptr< AST::ObjectReference > node)
Definition ObjectReference.cpp:41
void exitValueAssignment(std::shared_ptr< AST::ValueAssignment > node)
Definition ValueAssignment.cpp:40
void set_lsp_mode(bool lsp_mode)
Definition BashppListener.cpp:65
void enterValueAssignment(std::shared_ptr< AST::ValueAssignment > node)
Definition ValueAssignment.cpp:9
bool included
Definition BashppListener.h:66
void exitRawSubshell(std::shared_ptr< AST::RawSubshell > node)
Definition Subshell.cpp:84
void exitBashWhileOrUntilCondition(std::shared_ptr< AST::BashWhileOrUntilCondition > node)
Definition BashWhileOrUntilStatement.cpp:132
std::stack< std::monostate > bash_function_stack
Definition BashppListener.h:116
bool suppress_warnings
Definition BashppListener.h:74
void enterBashUntilStatement(std::shared_ptr< AST::BashUntilStatement > node)
Definition BashWhileOrUntilStatement.cpp:66
void set_arguments(std::vector< char * > arguments)
Definition BashppListener.cpp:61
void enterBashIfStatement(std::shared_ptr< AST::BashIfStatement > node)
Definition BashIfStatement.cpp:17
void enterBashVariable(std::shared_ptr< AST::BashVariable > node)
Definition BashVariable.cpp:9
void exitTypeofExpression(std::shared_ptr< AST::TypeofExpression > node)
Definition TypeofExpression.cpp:29
void enterBashWhileOrUntilCondition(std::shared_ptr< AST::BashWhileOrUntilCondition > node)
Definition BashWhileOrUntilStatement.cpp:117
void exitSubshellSubstitution(std::shared_ptr< AST::SubshellSubstitution > node)
Definition Subshell.cpp:36
std::stack< std::shared_ptr< bpp::bpp_entity > > entity_stack
A stack to keep track of the current entity being processed.
Definition BashppListener.h:136
void set_code_buffer(std::shared_ptr< std::ostream > code_buffer)
Definition BashppListener.cpp:37
std::shared_ptr< std::set< std::string > > included_files
A set of (unique) included files (used for '@include_once' directives)
Definition BashppListener.h:80
void enterProcessSubstitution(std::shared_ptr< AST::ProcessSubstitution > node)
Definition ProcessSubstitution.cpp:9
void enterProgram(std::shared_ptr< AST::Program > node)
Definition Program.cpp:14
void exitIncludeStatement(std::shared_ptr< AST::IncludeStatement > node)
Definition IncludeStatement.cpp:189
void exitMethodDefinition(std::shared_ptr< AST::MethodDefinition > node)
Definition MethodDefinition.cpp:128
void exitArrayIndex(std::shared_ptr< AST::ArrayIndex > node)
Definition ArrayIndex.cpp:34
void enterBashWhileStatement(std::shared_ptr< AST::BashWhileStatement > node)
Definition BashWhileOrUntilStatement.cpp:17
void enterTypeofExpression(std::shared_ptr< AST::TypeofExpression > node)
Definition TypeofExpression.cpp:9
void exitBashIfCondition(std::shared_ptr< AST::BashIfCondition > node)
Definition BashIfStatement.cpp:236
void enterBlock(std::shared_ptr< AST::Block > node)
Definition Block.cpp:9
std::stack< std::monostate > dynamic_cast_stack
Definition BashppListener.h:120
void enterObjectAssignment(std::shared_ptr< AST::ObjectAssignment > node)
Definition ObjectAssignment.cpp:9
void exitBashWhileStatement(std::shared_ptr< AST::BashWhileStatement > node)
Definition BashWhileOrUntilStatement.cpp:36
void exitBashInCondition(std::shared_ptr< AST::BashInCondition > node)
Definition BashForOrSelectStatement.cpp:134
void exitDatamemberDeclaration(std::shared_ptr< AST::DatamemberDeclaration > node)
Definition DatamemberDeclaration.cpp:67
BashppListener * included_from
Definition BashppListener.h:81
void exitBashCasePatternHeader(std::shared_ptr< AST::BashCasePatternHeader > node)
Definition BashCaseStatement.cpp:131
void enterBashSelectStatement(std::shared_ptr< AST::BashSelectStatement > node)
Definition BashForOrSelectStatement.cpp:69
std::shared_ptr< bpp::bpp_code_entity > latest_code_entity()
Definition BashppListener.cpp:93
std::shared_ptr< std::vector< std::string > > include_paths
A list of paths to search for included files.
Definition BashppListener.h:72
void exitBashArithmeticForStatement(std::shared_ptr< AST::BashArithmeticForStatement > node)
Definition BashArithmeticForStatement.cpp:21
void enterBashFunction(std::shared_ptr< AST::BashFunction > node)
Definition BashFunction.cpp:9
void enterRawText(std::shared_ptr< AST::RawText > node)
Definition RawText.cpp:9
void enterObjectReference(std::shared_ptr< AST::ObjectReference > node)
Definition ObjectReference.cpp:9
void set_suppress_warnings(bool suppress_warnings)
Definition BashppListener.cpp:53
void exitObjectInstantiation(std::shared_ptr< AST::ObjectInstantiation > node)
Definition ObjectInstantiation.cpp:86
void enterBashCasePatternHeader(std::shared_ptr< AST::BashCasePatternHeader > node)
Definition BashCaseStatement.cpp:117
void exitDestructorDefinition(std::shared_ptr< AST::DestructorDefinition > node)
Definition DestructorDefinition.cpp:37
void enterBashForStatement(std::shared_ptr< AST::BashForStatement > node)
Definition BashForOrSelectStatement.cpp:16
void exitBashRedirection(std::shared_ptr< AST::BashRedirection > node)
Definition BashRedirection.cpp:19
void enterArrayAssignment(std::shared_ptr< AST::ArrayAssignment > node)
Definition ArrayAssignment.cpp:9
void exitParameterExpansion(std::shared_ptr< AST::ParameterExpansion > node)
Definition ParameterExpansion.cpp:20
std::shared_ptr< bpp::bpp_class > primitive
Definition BashppListener.h:147
std::stack< std::monostate > typeof_stack
Definition BashppListener.h:121
void exitPrimitiveAssignment(std::shared_ptr< AST::PrimitiveAssignment > node)
Definition PrimitiveAssignment.cpp:21
void enterRawSubshell(std::shared_ptr< AST::RawSubshell > node)
Definition Subshell.cpp:61
void enterPrimitiveAssignment(std::shared_ptr< AST::PrimitiveAssignment > node)
Definition PrimitiveAssignment.cpp:9
void exitObjectAssignment(std::shared_ptr< AST::ObjectAssignment > node)
Definition ObjectAssignment.cpp:17
bool should_declare_local() const
Definition BashppListener.cpp:89
void enterPointerDeclaration(std::shared_ptr< AST::PointerDeclaration > node)
Definition PointerDeclaration.cpp:9
void enterSubshellSubstitution(std::shared_ptr< AST::SubshellSubstitution > node)
Definition Subshell.cpp:9
void enterNewStatement(std::shared_ptr< AST::NewStatement > node)
Definition NewStatement.cpp:9
std::shared_ptr< std::set< std::string > > get_included_files()
Definition BashppListener.cpp:73
bool lsp_mode
Definition BashppListener.h:149
std::shared_ptr< bpp::bpp_program > program
Definition BashppListener.h:110
void enterParameterExpansion(std::shared_ptr< AST::ParameterExpansion > node)
Definition ParameterExpansion.cpp:9
std::string source_file
Path to the source file being compiled (used for error reporting)
Definition BashppListener.h:64
void exitBashForStatement(std::shared_ptr< AST::BashForStatement > node)
Definition BashForOrSelectStatement.cpp:38
void enterMethodDefinition(std::shared_ptr< AST::MethodDefinition > node)
Definition MethodDefinition.cpp:9
void exitBashArithmeticForCondition(std::shared_ptr< AST::BashArithmeticForCondition > node)
Definition BashArithmeticForStatement.cpp:61
void exitBashCaseStatement(std::shared_ptr< AST::BashCaseStatement > node)
Definition BashCaseStatement.cpp:40
void enterSupershell(std::shared_ptr< AST::Supershell > node)
Definition Supershell.cpp:9
void exitBashUntilStatement(std::shared_ptr< AST::BashUntilStatement > node)
Definition BashWhileOrUntilStatement.cpp:85
std::shared_ptr< bpp::bpp_program > get_program()
Definition BashppListener.cpp:69
void enterConstructorDefinition(std::shared_ptr< AST::ConstructorDefinition > node)
Definition ConstructorDefinition.cpp:9
void exitDynamicCastTarget(std::shared_ptr< AST::DynamicCastTarget > node)
Definition DynamicCastTarget.cpp:27
void enterDatamemberDeclaration(std::shared_ptr< AST::DatamemberDeclaration > node)
Definition DatamemberDeclaration.cpp:9
void set_replacement_file_contents(const std::string &file_path, const std::string &contents)
Definition BashppListener.cpp:116
void exitBashIfRootBranch(std::shared_ptr< AST::BashIfRootBranch > node)
Definition BashIfStatement.cpp:136
void exitHereString(std::shared_ptr< AST::HereString > node)
Definition HereString.cpp:22
void enterHeredocBody(std::shared_ptr< AST::HeredocBody > node)
Definition HeredocBody.cpp:9
void enterBashRedirection(std::shared_ptr< AST::BashRedirection > node)
Definition BashRedirection.cpp:9
void exitProgram(std::shared_ptr< AST::Program > node)
Definition Program.cpp:49
ExpectationsStack context_expectations_stack
Definition BashppListener.h:123
void exitHeredocBody(std::shared_ptr< AST::HeredocBody > node)
Definition HeredocBody.cpp:22
void exitNewStatement(std::shared_ptr< AST::NewStatement > node)
Definition NewStatement.cpp:64
A stack to manage ContextExpectations during AST traversal.
Definition ContextExpectations.h:52
code_segment generate_supershell_code(const std::string &code_to_run, std::shared_ptr< bpp::bpp_program > program)
Generates a supershell code segment for executing a bash command.
Definition bpp_codegen.cpp:28
code_segment generate_dynamic_cast_code(const std::string &reference_code, const std::string &class_name, std::shared_ptr< bpp::bpp_program > program)
Generates a code segment for performing a dynamic cast.
Definition bpp_codegen.cpp:236
code_segment generate_delete_code(std::shared_ptr< bpp::bpp_object > object, const std::string &object_ref, std::shared_ptr< bpp::bpp_program > program)
Generates a code segment for deleting an object.
Definition bpp_codegen.cpp:84
code_segment generate_method_call_code(const std::string &reference_code, const std::string &method_name, std::shared_ptr< bpp::bpp_class > assumed_class, bool force_static_reference, std::shared_ptr< bpp::bpp_program > program)
Generates a code segment for calling a method.
Definition bpp_codegen.cpp:134
Represents a Bash version to target for code generation.
Definition BashVersion.h:21
A struct to hold (compiled) code segments.
Definition bpp_codegen.h:39