2022-09-19 07:34:19 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "utils/message.hh"
|
|
|
|
#include "utils/location.hh"
|
|
|
|
|
|
|
|
namespace ppc::lang {
|
2022-10-04 13:00:18 +00:00
|
|
|
template <class T>
|
|
|
|
struct located_t : T {
|
|
|
|
location_t location;
|
|
|
|
|
2022-10-04 20:45:08 +00:00
|
|
|
located_t(location_t loc, const T &val): T(val), location(loc) { }
|
|
|
|
located_t(const T &val): T(val), location(location_t::NONE) { }
|
|
|
|
located_t() { }
|
2022-10-04 13:00:18 +00:00
|
|
|
};
|
|
|
|
|
2022-10-04 17:03:46 +00:00
|
|
|
struct namespace_name_t : public std::vector<std::string> {
|
|
|
|
using base = std::vector<std::string>;
|
2022-10-04 13:00:18 +00:00
|
|
|
|
|
|
|
bool operator ==(const namespace_name_t &other) const;
|
2022-10-04 17:03:46 +00:00
|
|
|
bool operator !=(const namespace_name_t &other) const;
|
2022-10-04 13:00:18 +00:00
|
|
|
|
|
|
|
std::string to_string() const;
|
|
|
|
|
|
|
|
namespace_name_t() { }
|
2022-10-04 17:03:46 +00:00
|
|
|
namespace_name_t(std::initializer_list<std::string> segments): base(segments.begin(), segments.end()) { }
|
2022-09-19 07:34:19 +00:00
|
|
|
};
|
|
|
|
|
2022-09-21 06:37:50 +00:00
|
|
|
bool is_identifier_valid(messages::msg_stack_t &msg_stack, ppc::location_t location, const std::string &name);
|
|
|
|
inline bool is_identifier_valid(const std::string &name) {
|
2022-09-19 07:34:19 +00:00
|
|
|
messages::msg_stack_t ms { };
|
|
|
|
return is_identifier_valid(ms, { }, name);
|
|
|
|
}
|
|
|
|
}
|