11#include <unordered_map>
79class bpp_pointer_dereference;
83class bpp_object_address;
96 "class",
"constructor",
"delete",
"destructor",
97 "dynamic_cast",
"include",
"include_once",
"local",
98 "method",
"new",
"nullptr",
"private",
99 "protected",
"public",
"super",
"this",
123 if (identifier.contains(
"__"))
return false;
126 if (!isalpha(identifier[0]) && identifier[0] !=
'_') {
130 for (
char c : identifier) {
131 if (!isalnum(c) && c !=
'_') {
156 bool add(std::shared_ptr<T> entity) {
157 const std::string& name = entity->get_name();
164 std::shared_ptr<T>
find(
const std::string& name,
size_t max_visible_index = SIZE_MAX) {
167 size_t index = it->second;
168 if (index > max_visible_index)
return nullptr;
const std::vector< std::shared_ptr< T > > & get_entities() const
Definition bpp.h:176
std::shared_ptr< T > find(const std::string &name, size_t max_visible_index=SIZE_MAX)
Definition bpp.h:164
size_t size() const
Definition bpp.h:172
std::vector< std::shared_ptr< T > > entities
Definition bpp.h:153
bool add(std::shared_ptr< T > entity)
Definition bpp.h:156
std::unordered_map< std::string, size_t > name_to_index
Definition bpp.h:154
A pattern for a case statement in Bash++.
Definition bash_case.h:45
A case statement in Bash++.
Definition bash_case.h:27
A for loop or select statement in Bash++.
Definition bash_for_or_select.h:25
A normal Bash function.
Definition bash_function.h:23
A branch of an if statement in Bash++.
Definition bash_if.h:58
An if statement in Bash++.
Definition bash_if.h:38
The condition for a while/until loop in Bash++.
Definition bash_while_or_until_loop.h:51
A while/until loop in Bash++.
Definition bash_while_or_until_loop.h:32
A class in Bash++.
Definition bpp_class.h:23
An entity which can contain code.
Definition bpp_code_entity.h:35
A data member in a class.
Definition bpp_datamember.h:21
A delete statement in Bash++.
Definition bpp_delete_statement.h:27
A dynamic_cast statement in Bash++.
Definition bpp_dynamic_cast_statement.h:27
The base class for all entities in the Bash++ compiler.
Definition bpp_entity.h:25
A parameter in a method.
Definition bpp_method.h:55
A method in a class.
Definition bpp_method.h:23
An object assignment statement in Bash++.
Definition bpp_object_assignment.h:24
An object reference in Bash++.
Definition bpp_object_reference.h:23
An object in Bash++.
Definition bpp_object.h:22
The main program.
Definition bpp_program.h:28
The practical difference between bpp_code_entity and bpp_string is how we handle the code buffers.
Definition bpp_string.h:77
A value assignment statement in Bash++.
Definition bpp_value_assignment.h:23
Definition bash_case.cpp:9
bpp_scope
Definition bpp.h:20
static const char bpp_nullptr[]
The secret internal value of '@nullptr' in Bash++.
Definition bpp.h:89
bool is_valid_identifier(const std::string &identifier)
Check if a string is a valid identifier in Bash++.
Definition bpp.h:116
bool is_protected_keyword(const std::string &keyword)
Check if a string matches any of our protected keywords.
Definition bpp.h:107
constexpr std::array< std::string_view, 18 > protected_keywords
A list of keywords that are reserved and cannot be used as identifiers in Bash++.
Definition bpp.h:95
reference_type
Definition bpp.h:27
diagnostic_type
Definition bpp.h:33
std::string file
Definition bpp.h:141
uint64_t column
Definition bpp.h:143
SymbolPosition(const std::string &file, uint64_t line, uint64_t column)
Definition bpp.h:146
uint64_t line
Definition bpp.h:142
Represents a diagnostic message (error, warning, info, hint)
Definition bpp.h:47
uint32_t start_line
Definition bpp.h:50
uint32_t end_line
Definition bpp.h:52
diagnostic_type type
Definition bpp.h:48
std::string message
Definition bpp.h:49
uint32_t end_column
Definition bpp.h:53
uint32_t start_column
Definition bpp.h:51