#pragma once #include "utils/message.hh" #include "utils/location.hh" namespace ppc::lang { template struct located_t : T { location_t location; 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() { } }; struct namespace_name_t : public std::vector { using base = std::vector; bool operator ==(const namespace_name_t &other) const; bool operator !=(const namespace_name_t &other) const; operator std::string() const { return to_string(); } std::string to_string() const; namespace_name_t() { } namespace_name_t(std::initializer_list segments): base(segments.begin(), segments.end()) { } }; struct loc_namespace_name_t : public std::vector> { using base = std::vector>; bool operator ==(const loc_namespace_name_t &other) const; bool operator !=(const loc_namespace_name_t &other) const; namespace_name_t strip_location(); operator std::string() const { return to_string(); } std::string to_string() const; loc_namespace_name_t() { } loc_namespace_name_t(std::initializer_list> segments): base(segments.begin(), segments.end()) { } }; 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) { messages::msg_stack_t ms; return is_identifier_valid(ms, { }, name); } }