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 <memory>
13#include <stack>
14#include <unordered_map>
15
17
18class BashppListener;
19
21
22#include <bpp_include/bpp.h>
23#include <include/BashVersion.h>
25
26#include <error/detail.h>
27#include <error/SyntaxError.h>
28#include <error/InternalError.h>
29
50class BashppListener : public AST::BaseListener<BashppListener>, std::enable_shared_from_this<BashppListener> {
51 private:
57 int exit_code = 0;
58
63 std::string source_file;
64
65 bool included = false;
66
71 std::shared_ptr<std::vector<std::string>> include_paths = nullptr;
72
73 bool suppress_warnings = false;
74
79 std::shared_ptr<std::set<std::string>> included_files = std::make_shared<std::set<std::string>>();
81
86 std::vector<std::string> include_stack;
87
92 std::shared_ptr<std::ostream> code_buffer;
93 std::shared_ptr<std::ostream> output_stream;
94 std::string output_file;
95 bool run_on_exit = false;
96
102
107 std::vector<char*> arguments;
108
109 std::shared_ptr<bpp::bpp_program> program = std::make_shared<bpp::bpp_program>();
110
111 bool in_method = false;
112
113 bool in_class = false;
114 std::stack<std::monostate> supershell_stack;
115 std::stack<std::monostate> bash_function_stack;
116
125 bool should_declare_local() const;
126
146
147 // Diagnostic information (not used for compilation):
148 std::stack<std::monostate> dynamic_cast_stack; // Used to track whether we're inside a dynamic_cast statement
149 std::stack<std::monostate> typeof_stack; // Used to track whether we're inside a typeof expression
150
152
164 std::stack<std::shared_ptr<bpp::bpp_entity>> entity_stack;
165
173 std::unordered_map<std::string, std::string> replacement_file_contents;
174
175 bool lsp_mode = false; // Whether this listener is just running as part of the language server (i.e., not really compiling anything)
176 bool utf16_mode = false; // If we're in a language server, whether the client has demanded UTF-16 position encoding
177
178 #define show_warning(token, msg) \
179 if (!suppress_warnings) { \
180 bpp::ErrorHandling::Warning _msg(this, token, msg); \
181 _msg.print(); \
182 }
183
184 public:
185 void set_source_file(std::string source_file);
186 void set_include_paths(std::shared_ptr<std::vector<std::string>> include_paths);
187 void set_included(bool included);
189 void set_included_files(std::shared_ptr<std::set<std::string>> included_files);
190 void set_code_buffer(std::shared_ptr<std::ostream> code_buffer);
191 void set_output_stream(std::shared_ptr<std::ostream> output_stream);
192 void set_output_file(std::string output_file);
193 void set_run_on_exit(bool run_on_exit);
196 void set_arguments(std::vector<char*> arguments);
197 void set_lsp_mode(bool lsp_mode);
198 void set_utf16_mode(bool utf16_mode);
199
200 void set_replacement_file_contents(const std::string& file_path, const std::string& contents);
201
202 std::shared_ptr<bpp::bpp_program> get_program() const;
203 std::shared_ptr<std::set<std::string>> get_included_files() const;
204 const std::vector<std::string>& get_include_stack() const;
205 std::string get_source_file() const;
206 bool get_lsp_mode() const;
207 bool get_utf16_mode() const;
208
209 int get_exit_code() const;
210
211 std::shared_ptr<bpp::bpp_code_entity> latest_code_entity();
212
213 void enterProgram(std::shared_ptr<AST::Program> node);
214 void exitProgram(std::shared_ptr<AST::Program> node);
215 void enterArrayAssignment(std::shared_ptr<AST::ArrayAssignment> node);
216 void exitArrayAssignment(std::shared_ptr<AST::ArrayAssignment> node);
217 void enterArrayIndex(std::shared_ptr<AST::ArrayIndex> node);
218 void exitArrayIndex(std::shared_ptr<AST::ArrayIndex> node);
219 void enterBash53NativeSupershell(std::shared_ptr<AST::Bash53NativeSupershell> node);
220 void exitBash53NativeSupershell(std::shared_ptr<AST::Bash53NativeSupershell> node);
221 void enterBashArithmeticForCondition(std::shared_ptr<AST::BashArithmeticForCondition> node);
222 void exitBashArithmeticForCondition(std::shared_ptr<AST::BashArithmeticForCondition> node);
223 void enterBashArithmeticForStatement(std::shared_ptr<AST::BashArithmeticForStatement> node);
224 void exitBashArithmeticForStatement(std::shared_ptr<AST::BashArithmeticForStatement> node);
225 void enterBashArithmeticSubstitution(std::shared_ptr<AST::BashArithmeticSubstitution> node);
226 void exitBashArithmeticSubstitution(std::shared_ptr<AST::BashArithmeticSubstitution> node);
227 void enterBashCasePattern(std::shared_ptr<AST::BashCasePattern> node);
228 void exitBashCasePattern(std::shared_ptr<AST::BashCasePattern> node);
229 void enterBashCasePatternHeader(std::shared_ptr<AST::BashCasePatternHeader> node);
230 void exitBashCasePatternHeader(std::shared_ptr<AST::BashCasePatternHeader> node);
231 void enterBashCaseStatement(std::shared_ptr<AST::BashCaseStatement> node);
232 void exitBashCaseStatement(std::shared_ptr<AST::BashCaseStatement> node);
233 //void enterBashCommand(std::shared_ptr<AST::BashCommand> node);
234 //void exitBashCommand(std::shared_ptr<AST::BashCommand> node);
235 void enterBashCommandSequence(std::shared_ptr<AST::BashCommandSequence> node);
236 void exitBashCommandSequence(std::shared_ptr<AST::BashCommandSequence> node);
237 void enterBashForStatement(std::shared_ptr<AST::BashForStatement> node);
238 void exitBashForStatement(std::shared_ptr<AST::BashForStatement> node);
239 void enterBashIfCondition(std::shared_ptr<AST::BashIfCondition> node);
240 void exitBashIfCondition(std::shared_ptr<AST::BashIfCondition> node);
241 void enterBashIfElseBranch(std::shared_ptr<AST::BashIfElseBranch> node);
242 void exitBashIfElseBranch(std::shared_ptr<AST::BashIfElseBranch> node);
243 void enterBashIfRootBranch(std::shared_ptr<AST::BashIfRootBranch> node);
244 void exitBashIfRootBranch(std::shared_ptr<AST::BashIfRootBranch> node);
245 void enterBashIfStatement(std::shared_ptr<AST::BashIfStatement> node);
246 void exitBashIfStatement(std::shared_ptr<AST::BashIfStatement> node);
247 void enterBashInCondition(std::shared_ptr<AST::BashInCondition> node);
248 void exitBashInCondition(std::shared_ptr<AST::BashInCondition> node);
249 void enterBashPipeline(std::shared_ptr<AST::BashPipeline> node);
250 void exitBashPipeline(std::shared_ptr<AST::BashPipeline> node);
251 void enterBashRedirection(std::shared_ptr<AST::BashRedirection> node);
252 void exitBashRedirection(std::shared_ptr<AST::BashRedirection> node);
253 void enterBashSelectStatement(std::shared_ptr<AST::BashSelectStatement> node);
254 void exitBashSelectStatement(std::shared_ptr<AST::BashSelectStatement> node);
255 void enterBashTestConditionCommand(std::shared_ptr<AST::BashTestConditionCommand> node);
256 void exitBashTestConditionCommand(std::shared_ptr<AST::BashTestConditionCommand> node);
257 void enterBashUntilStatement(std::shared_ptr<AST::BashUntilStatement> node);
258 void exitBashUntilStatement(std::shared_ptr<AST::BashUntilStatement> node);
259 void enterBashVariable(std::shared_ptr<AST::BashVariable> node);
260 void exitBashVariable(std::shared_ptr<AST::BashVariable> node);
261 void enterBashWhileOrUntilCondition(std::shared_ptr<AST::BashWhileOrUntilCondition> node);
262 void exitBashWhileOrUntilCondition(std::shared_ptr<AST::BashWhileOrUntilCondition> node);
263 void enterBashWhileStatement(std::shared_ptr<AST::BashWhileStatement> node);
264 void exitBashWhileStatement(std::shared_ptr<AST::BashWhileStatement> node);
265 void enterBashFunction(std::shared_ptr<AST::BashFunction> node);
266 void exitBashFunction(std::shared_ptr<AST::BashFunction> node);
267 void enterBlock(std::shared_ptr<AST::Block> node);
268 void exitBlock(std::shared_ptr<AST::Block> node);
269 void enterClassDefinition(std::shared_ptr<AST::ClassDefinition> node);
270 void exitClassDefinition(std::shared_ptr<AST::ClassDefinition> node);
271 void enterConnective(std::shared_ptr<AST::Connective> node);
272 void exitConnective(std::shared_ptr<AST::Connective> node);
273 void enterConstructorDefinition(std::shared_ptr<AST::ConstructorDefinition> node);
274 void exitConstructorDefinition(std::shared_ptr<AST::ConstructorDefinition> node);
275 void enterDatamemberDeclaration(std::shared_ptr<AST::DatamemberDeclaration> node);
276 void exitDatamemberDeclaration(std::shared_ptr<AST::DatamemberDeclaration> node);
277 void enterDeleteStatement(std::shared_ptr<AST::DeleteStatement> node);
278 void exitDeleteStatement(std::shared_ptr<AST::DeleteStatement> node);
279 void enterDestructorDefinition(std::shared_ptr<AST::DestructorDefinition> node);
280 void exitDestructorDefinition(std::shared_ptr<AST::DestructorDefinition> node);
281 void enterDoublequotedString(std::shared_ptr<AST::DoublequotedString> node);
282 void exitDoublequotedString(std::shared_ptr<AST::DoublequotedString> node);
283 void enterDynamicCast(std::shared_ptr<AST::DynamicCast> node);
284 void exitDynamicCast(std::shared_ptr<AST::DynamicCast> node);
285 void enterDynamicCastTarget(std::shared_ptr<AST::DynamicCastTarget> node);
286 void exitDynamicCastTarget(std::shared_ptr<AST::DynamicCastTarget> node);
287 void enterHeredocBody(std::shared_ptr<AST::HeredocBody> node);
288 void exitHeredocBody(std::shared_ptr<AST::HeredocBody> node);
289 void enterHereString(std::shared_ptr<AST::HereString> node);
290 void exitHereString(std::shared_ptr<AST::HereString> node);
291 void enterIncludeStatement(std::shared_ptr<AST::IncludeStatement> node);
292 void exitIncludeStatement(std::shared_ptr<AST::IncludeStatement> node);
293 void enterMethodDefinition(std::shared_ptr<AST::MethodDefinition> node);
294 void exitMethodDefinition(std::shared_ptr<AST::MethodDefinition> node);
295 void enterNewStatement(std::shared_ptr<AST::NewStatement> node);
296 void exitNewStatement(std::shared_ptr<AST::NewStatement> node);
297 void enterObjectAssignment(std::shared_ptr<AST::ObjectAssignment> node);
298 void exitObjectAssignment(std::shared_ptr<AST::ObjectAssignment> node);
299 void enterObjectInstantiation(std::shared_ptr<AST::ObjectInstantiation> node);
300 void exitObjectInstantiation(std::shared_ptr<AST::ObjectInstantiation> node);
301 void enterObjectReference(std::shared_ptr<AST::ObjectReference> node);
302 void exitObjectReference(std::shared_ptr<AST::ObjectReference> node);
303 void enterParameterExpansion(std::shared_ptr<AST::ParameterExpansion> node);
304 void exitParameterExpansion(std::shared_ptr<AST::ParameterExpansion> node);
305 void enterPointerDeclaration(std::shared_ptr<AST::PointerDeclaration> node);
306 void exitPointerDeclaration(std::shared_ptr<AST::PointerDeclaration> node);
307 void enterPrimitiveAssignment(std::shared_ptr<AST::PrimitiveAssignment> node);
308 void exitPrimitiveAssignment(std::shared_ptr<AST::PrimitiveAssignment> node);
309 void enterProcessSubstitution(std::shared_ptr<AST::ProcessSubstitution> node);
310 void exitProcessSubstitution(std::shared_ptr<AST::ProcessSubstitution> node);
311 void enterRawSubshell(std::shared_ptr<AST::RawSubshell> node);
312 void exitRawSubshell(std::shared_ptr<AST::RawSubshell> node);
313 void enterRawText(std::shared_ptr<AST::RawText> node);
314 void exitRawText(std::shared_ptr<AST::RawText> node);
315 //void enterRvalue(std::shared_ptr<AST::Rvalue> node);
316 //void exitRvalue(std::shared_ptr<AST::Rvalue> node);
317 void enterSubshellSubstitution(std::shared_ptr<AST::SubshellSubstitution> node);
318 void exitSubshellSubstitution(std::shared_ptr<AST::SubshellSubstitution> node);
319 void enterSupershell(std::shared_ptr<AST::Supershell> node);
320 void exitSupershell(std::shared_ptr<AST::Supershell> node);
321 void enterTypeofExpression(std::shared_ptr<AST::TypeofExpression> node);
322 void exitTypeofExpression(std::shared_ptr<AST::TypeofExpression> node);
323 void enterValueAssignment(std::shared_ptr<AST::ValueAssignment> node);
324 void exitValueAssignment(std::shared_ptr<AST::ValueAssignment> node);
325};
CRTP base class for AST listeners. CRTP is a kind of language hack that makes static polymorphism pos...
Definition BaseListener.h:111
The main listener class for the Bash++ compiler.
Definition BashppListener.h:50
bool get_lsp_mode() const
Definition BashppListener.cpp:93
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:113
bool in_method
Definition BashppListener.h:111
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:196
void exitBashSelectStatement(std::shared_ptr< AST::BashSelectStatement > node)
Definition BashForOrSelectStatement.cpp:92
bool utf16_mode
Definition BashppListener.h:176
void enterBashInCondition(std::shared_ptr< AST::BashInCondition > node)
Definition BashForOrSelectStatement.cpp:125
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:30
bool run_on_exit
Definition BashppListener.h:95
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:86
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:173
void set_output_file(std::string output_file)
Definition BashppListener.cpp:49
void exitPointerDeclaration(std::shared_ptr< AST::PointerDeclaration > node)
Definition PointerDeclaration.cpp:82
void set_target_bash_version(BashVersion target_bash_version)
Definition BashppListener.cpp:61
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:53
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:92
void exitConnective(std::shared_ptr< AST::Connective > node)
Definition Connective.cpp:19
BashVersion target_bash_version
The target Bash version to compile for (default is 5.2)
Definition BashppListener.h:101
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:107
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:31
void exitBashCasePattern(std::shared_ptr< AST::BashCasePattern > node)
Definition BashCaseStatement.cpp:86
bool should_localize_object_instantiation() const
Whether an instantiated object should be made 'local' in the generated Bash code.
Definition BashppListener.cpp:109
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:37
void enterBashIfCondition(std::shared_ptr< AST::BashIfCondition > node)
Definition BashIfStatement.cpp:226
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
std::stack< std::monostate > supershell_stack
Definition BashppListener.h:114
void exitBashArithmeticSubstitution(std::shared_ptr< AST::BashArithmeticSubstitution > node)
Definition BashArithmeticSubstitution.cpp:34
void set_output_stream(std::shared_ptr< std::ostream > output_stream)
Definition BashppListener.cpp:45
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 set_utf16_mode(bool utf16_mode)
Definition BashppListener.cpp:73
void enterArrayIndex(std::shared_ptr< AST::ArrayIndex > node)
Definition ArrayIndex.cpp:9
void enterBashIfRootBranch(std::shared_ptr< AST::BashIfRootBranch > node)
Definition BashIfStatement.cpp:113
bool get_utf16_mode() const
Definition BashppListener.cpp:97
void enterBashArithmeticForCondition(std::shared_ptr< AST::BashArithmeticForCondition > node)
Definition BashArithmeticForStatement.cpp:49
void enterBashIfElseBranch(std::shared_ptr< AST::BashIfElseBranch > node)
Definition BashIfStatement.cpp:167
void exitRawText(std::shared_ptr< AST::RawText > node)
Definition RawText.cpp:21
void set_included(bool included)
Definition BashppListener.cpp:21
void exitBlock(std::shared_ptr< AST::Block > node)
Definition Block.cpp:51
std::shared_ptr< std::ostream > output_stream
Pointer to the output stream to write the compiled code to.
Definition BashppListener.h:93
void set_included_from(BashppListener *included_from)
Sets the included_from pointer to the given listener.
Definition BashppListener.cpp:28
std::string output_file
Definition BashppListener.h:94
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:69
void enterValueAssignment(std::shared_ptr< AST::ValueAssignment > node)
Definition ValueAssignment.cpp:9
bool included
Definition BashppListener.h:65
void exitRawSubshell(std::shared_ptr< AST::RawSubshell > node)
Definition Subshell.cpp:129
void exitBashWhileOrUntilCondition(std::shared_ptr< AST::BashWhileOrUntilCondition > node)
Definition BashWhileOrUntilStatement.cpp:138
std::stack< std::monostate > bash_function_stack
Definition BashppListener.h:115
std::string get_source_file() const
Definition BashppListener.cpp:89
bool suppress_warnings
Definition BashppListener.h:73
void enterBashUntilStatement(std::shared_ptr< AST::BashUntilStatement > node)
Definition BashWhileOrUntilStatement.cpp:69
void set_arguments(std::vector< char * > arguments)
Definition BashppListener.cpp:65
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:123
void exitSubshellSubstitution(std::shared_ptr< AST::SubshellSubstitution > node)
Definition Subshell.cpp:41
std::stack< std::shared_ptr< bpp::bpp_entity > > entity_stack
A stack to keep track of the current entity being processed.
Definition BashppListener.h:164
void set_code_buffer(std::shared_ptr< std::ostream > code_buffer)
Definition BashppListener.cpp:41
std::shared_ptr< std::set< std::string > > included_files
A set of (unique) included files (used for '@include_once' directives)
Definition BashppListener.h:79
void enterProcessSubstitution(std::shared_ptr< AST::ProcessSubstitution > node)
Definition ProcessSubstitution.cpp:9
void enterProgram(std::shared_ptr< AST::Program > node)
Definition Program.cpp:13
void exitIncludeStatement(std::shared_ptr< AST::IncludeStatement > node)
Definition IncludeStatement.cpp:192
void exitMethodDefinition(std::shared_ptr< AST::MethodDefinition > node)
Definition MethodDefinition.cpp:129
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:242
void enterBlock(std::shared_ptr< AST::Block > node)
Definition Block.cpp:9
std::stack< std::monostate > dynamic_cast_stack
Definition BashppListener.h:148
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:137
void exitDatamemberDeclaration(std::shared_ptr< AST::DatamemberDeclaration > node)
Definition DatamemberDeclaration.cpp:67
BashppListener * included_from
Definition BashppListener.h:80
void exitBashCasePatternHeader(std::shared_ptr< AST::BashCasePatternHeader > node)
Definition BashCaseStatement.cpp:134
void enterBashSelectStatement(std::shared_ptr< AST::BashSelectStatement > node)
Definition BashForOrSelectStatement.cpp:70
std::shared_ptr< bpp::bpp_code_entity > latest_code_entity()
Definition BashppListener.cpp:113
std::shared_ptr< std::vector< std::string > > include_paths
A list of paths to search for included files.
Definition BashppListener.h:71
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:57
void exitObjectInstantiation(std::shared_ptr< AST::ObjectInstantiation > node)
Definition ObjectInstantiation.cpp:87
void enterBashCasePatternHeader(std::shared_ptr< AST::BashCasePatternHeader > node)
Definition BashCaseStatement.cpp:120
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
int exit_code
The exit code to return when the compiler finishes (default is 0, which means success)
Definition BashppListener.h:57
std::stack< std::monostate > typeof_stack
Definition BashppListener.h:149
void exitPrimitiveAssignment(std::shared_ptr< AST::PrimitiveAssignment > node)
Definition PrimitiveAssignment.cpp:21
void enterRawSubshell(std::shared_ptr< AST::RawSubshell > node)
Definition Subshell.cpp:102
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
Whether the compiler should declare its temporary variables to be 'local' in the generated Bash code.
Definition BashppListener.cpp:105
int get_exit_code() const
Definition BashppListener.cpp:101
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< bpp::bpp_program > get_program() const
Definition BashppListener.cpp:77
bool lsp_mode
Definition BashppListener.h:175
std::shared_ptr< bpp::bpp_program > program
Definition BashppListener.h:109
std::shared_ptr< std::set< std::string > > get_included_files() const
Definition BashppListener.cpp:81
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:63
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:88
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:136
void exitBashIfRootBranch(std::shared_ptr< AST::BashIfRootBranch > node)
Definition BashIfStatement.cpp:136
const std::vector< std::string > & get_include_stack() const
Definition BashppListener.cpp:85
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:47
ExpectationsStack context_expectations_stack
Definition BashppListener.h:151
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
Represents a Bash version to target for code generation.
Definition BashVersion.h:22