Skip to content

Commit

Permalink
Move ast to dryad
Browse files Browse the repository at this point in the history
  • Loading branch information
Spartan322 committed Nov 30, 2023
1 parent 9a10a81 commit 2054a29
Show file tree
Hide file tree
Showing 33 changed files with 1,218 additions and 1,492 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ jobs:
platform: windows
arch: x86_64
- identifier: macos-debug
os: macos-latest
os: macos-13
name: 🍎 macOS (universal) Debug
target: template_debug
platform: macos
arch: universal
- identifier: macos-release
os: macos-latest
os: macos-13
name: 🍎 macOS (universal) Release
target: template_release
platform: macos
Expand Down Expand Up @@ -82,6 +82,15 @@ jobs:
python -m pip install scons
scons --version
- name: macOS dependencies
if: ${{ matrix.platform == 'macos' }}
run: |
echo "$(brew --prefix llvm@15)/bin" >> $GITHUB_PATH
xcode-select --switch /Applications/Xcode_15.0.1.app
- if: ${{ matrix.platform == 'macos' }}
run: clang++ --version

- name: Linux dependencies
if: ${{ matrix.platform == 'linux' }}
run: |
Expand Down
31 changes: 19 additions & 12 deletions include/openvic-dataloader/AbstractSyntaxTree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,25 @@ namespace ovdl {
};

template<typename T>
concept IsAst = std::derived_from<T, AbstractSyntaxTree> && requires(T t, const typename T::node_type* node, NodeLocation loc) {
requires IsFile<typename T::file_type>;
typename T::root_node_type;
typename T::node_type;
requires std::derived_from<typename T::root_node_type, typename T::node_type>;
{ t.set_location(node, loc) } -> std::same_as<void>;
{ t.location_of(node) } -> std::same_as<NodeLocation>;
{ t.root() } -> std::same_as<typename T::root_node_type*>;
{ const_cast<const T&>(t).root() } -> std::same_as<const typename T::root_node_type*>;
{ t.file() } -> std::same_as<typename T::file_type&>;
{ const_cast<const T&>(t).file() } -> std::same_as<const typename T::file_type&>;
};
concept IsAst =
std::derived_from<T, AbstractSyntaxTree> &&
requires(
T t,
const T ct,
const typename T::node_type* node,
NodeLocation loc //
) {
requires IsFile<typename T::file_type>;
typename T::root_node_type;
typename T::node_type;
requires std::derived_from<typename T::root_node_type, typename T::node_type>;
{ t.set_location(node, loc) } -> std::same_as<void>;
{ t.location_of(node) } -> std::same_as<NodeLocation>;
{ t.root() } -> std::same_as<typename T::root_node_type*>;
{ ct.root() } -> std::same_as<const typename T::root_node_type*>;
{ t.file() } -> std::same_as<typename T::file_type&>;
{ ct.file() } -> std::same_as<const typename T::file_type&>;
};

template<IsFile FileT, std::derived_from<typename FileT::node_type> RootNodeT>
struct BasicAbstractSyntaxTree : AbstractSyntaxTree {
Expand Down
4 changes: 2 additions & 2 deletions include/openvic-dataloader/NodeLocation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ namespace ovdl {
};

struct FilePosition {
std::uint32_t start_line = -1, end_line = -1, start_column = -1, end_column = -1;
std::uint32_t start_line = std::uint32_t(-1), end_line = std::uint32_t(-1), start_column = std::uint32_t(-1), end_column = std::uint32_t(-1);

inline constexpr bool is_empty() { return start_line == -1 && end_line == -1 && start_column == -1 && end_column == -1; }
inline constexpr bool is_empty() { return start_line == std::uint32_t(-1) && end_line == std::uint32_t(-1) && start_column == std::uint32_t(-1) && end_column == std::uint32_t(-1); }
};
}
14 changes: 8 additions & 6 deletions include/openvic-dataloader/ParseState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace ovdl {
template<typename T>
concept IsParseState = requires(
T t,
const T ct,
typename T::ast_type::file_type&& file,
std::ostream& error_stream,
lexy::buffer<typename T::ast_type::file_type::encoding_type>&& buffer,
Expand All @@ -23,9 +24,9 @@ namespace ovdl {
{ T { std::move(buffer), error_stream } } -> std::same_as<T>;
{ T { path, std::move(buffer), error_stream } } -> std::same_as<T>;
{ t.ast() } -> std::same_as<typename T::ast_type&>;
{ const_cast<const T&>(t).ast() } -> std::same_as<const typename T::ast_type&>;
{ ct.ast() } -> std::same_as<const typename T::ast_type&>;
{ t.logger() } -> std::same_as<typename T::diagnostic_logger_type&>;
{ const_cast<const T&>(t).logger() } -> std::same_as<const typename T::diagnostic_logger_type&>;
{ ct.logger() } -> std::same_as<const typename T::diagnostic_logger_type&>;
};

template<IsAst AstT>
Expand Down Expand Up @@ -67,6 +68,7 @@ namespace ovdl {
template<typename T>
concept IsFileParseState = requires(
T t,
const T ct,
typename T::file_type&& file,
std::ostream& error_stream,
lexy::buffer<typename T::file_type::encoding_type>&& buffer,
Expand All @@ -78,9 +80,9 @@ namespace ovdl {
{ T { std::move(buffer), error_stream } } -> std::same_as<T>;
{ T { path, std::move(buffer), error_stream } } -> std::same_as<T>;
{ t.file() } -> std::same_as<typename T::file_type&>;
{ const_cast<const T&>(t).file() } -> std::same_as<const typename T::file_type&>;
{ ct.file() } -> std::same_as<const typename T::file_type&>;
{ t.logger() } -> std::same_as<typename T::diagnostic_logger_type&>;
{ const_cast<const T&>(t).logger() } -> std::same_as<const typename T::diagnostic_logger_type&>;
{ ct.logger() } -> std::same_as<const typename T::diagnostic_logger_type&>;
};

template<IsFile FileT>
Expand All @@ -89,8 +91,8 @@ namespace ovdl {
using diagnostic_logger_type = BasicDiagnosticLogger<file_type>;

FileParseState(file_type&& file, std::ostream& error_stream)
: _file { file },
_logger { file(), error_stream } {}
: _file { std::move(file) },
_logger { file, error_stream } {}

FileParseState(lexy::buffer<typename file_type::encoding_type>&& buffer, std::ostream& error_stream)
: FileParseState(file_type { std::move(buffer) }, error_stream) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@

#include <openvic-dataloader/ParseError.hpp>
#include <openvic-dataloader/ParseWarning.hpp>
#include <openvic-dataloader/detail/utility/Concepts.hpp>

namespace ovdl::detail {
class BasicParser {
public:
struct BasicParser {
BasicParser();

void set_error_log_to_null();
Expand Down
9 changes: 4 additions & 5 deletions include/openvic-dataloader/csv/Parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

#include <filesystem>

#include <openvic-dataloader/Parser.hpp>
#include <openvic-dataloader/csv/LineObject.hpp>
#include <openvic-dataloader/detail/utility/Concepts.hpp>

#include "openvic-dataloader/detail/BasicParser.hpp"

namespace ovdl::csv {
enum class EncodingType {
Windows1252,
Expand Down Expand Up @@ -44,12 +43,12 @@ namespace ovdl::csv {
~Parser();

private:
class BufferHandler;
std::unique_ptr<BufferHandler> _buffer_handler;
class ParseHandler;
std::unique_ptr<ParseHandler> _buffer_handler;
std::vector<csv::LineObject> _lines;

template<typename... Args>
constexpr void _run_load_func(detail::LoadCallback<BufferHandler, Args...> auto func, Args... args);
constexpr void _run_load_func(detail::LoadCallback<ParseHandler, Args...> auto func, Args... args);
};

using Windows1252Parser = Parser<EncodingType::Windows1252>;
Expand Down
9 changes: 0 additions & 9 deletions include/openvic-dataloader/detail/OptionalConstexpr.hpp

This file was deleted.

9 changes: 0 additions & 9 deletions include/openvic-dataloader/detail/VectorConstexpr.hpp

This file was deleted.

8 changes: 3 additions & 5 deletions include/openvic-dataloader/detail/utility/Concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
#include <concepts>
#include <cstdint>
#include <functional>
#include <optional>
#include <utility>
#include "openvic-dataloader/ParseError.hpp"

namespace ovdl {
struct NodeLocation;
Expand All @@ -26,14 +24,14 @@ namespace ovdl::detail {
};

template<typename T>
concept HasPath = requires(const T* t) {
{ t->path() } -> std::convertible_to<const char*>;
concept HasPath = requires(T& t) {
{ t.path() } -> std::same_as<const char*>;
};

template<typename T, typename Self, typename... Args>
concept LoadCallback =
requires(T&& t, Self&& self, Args&&... args) {
{ std::invoke(std::forward<T>(t), std::forward<Self>(self), std::forward<Args>(args)...) } -> std::same_as<std::optional<ParseError>>;
{ std::invoke(std::forward<T>(t), std::forward<Self>(self), std::forward<Args>(args)...) } -> std::same_as<ovdl::detail::buffer_error>;
};

template<typename T>
Expand Down
Loading

0 comments on commit 2054a29

Please sign in to comment.