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