Skip to content

Commit eb124ba

Browse files
committed
lexy updated
1 parent 3e454b7 commit eb124ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1830
-735
lines changed

3rdparty/lexy/CMakeLists.txt

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,78 @@
22
# SPDX-License-Identifier: BSL-1.0
33

44
cmake_minimum_required(VERSION 3.8)
5-
project(lexy VERSION 2022.05.1 LANGUAGES CXX)
5+
project(lexy VERSION 2022.12.0 LANGUAGES CXX)
66

77
set(LEXY_USER_CONFIG_HEADER "" CACHE FILEPATH "The user config header for lexy.")
88
option(LEXY_FORCE_CPP17 "Whether or not lexy should use C++17 even if compiler supports C++20." OFF)
99

1010
add_subdirectory(src)
1111

12+
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
13+
cmake_minimum_required(VERSION 3.18)
14+
option(LEXY_BUILD_BENCHMARKS "whether or not benchmarks should be built" OFF)
15+
option(LEXY_BUILD_EXAMPLES "whether or not examples should be built" ON)
16+
option(LEXY_BUILD_TESTS "whether or not tests should be built" ON)
17+
option(LEXY_BUILD_DOCS "whether or not docs should be built" OFF)
18+
option(LEXY_BUILD_PACKAGE "whether or not the package should be built" ON)
19+
option(LEXY_ENABLE_INSTALL "whether or not to enable the install rule" ON)
20+
21+
if(LEXY_BUILD_PACKAGE)
22+
set(package_files include/ src/ cmake/ CMakeLists.txt LICENSE)
23+
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lexy-src.zip
24+
COMMAND ${CMAKE_COMMAND} -E tar c ${CMAKE_CURRENT_BINARY_DIR}/lexy-src.zip --format=zip -- ${package_files}
25+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
26+
DEPENDS ${package_files})
27+
add_custom_target(lexy_package DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/lexy-src.zip)
28+
endif()
29+
30+
if(LEXY_BUILD_EXAMPLES)
31+
add_subdirectory(examples)
32+
endif()
33+
if(LEXY_BUILD_BENCHMARKS)
34+
add_subdirectory(benchmarks)
35+
endif()
36+
if(LEXY_BUILD_TESTS)
37+
set(DOCTEST_NO_INSTALL ON)
38+
enable_testing()
39+
add_subdirectory(tests)
40+
endif()
41+
if(LEXY_BUILD_DOCS)
42+
add_subdirectory(docs EXCLUDE_FROM_ALL)
43+
endif()
44+
45+
if(LEXY_ENABLE_INSTALL)
46+
include(CMakePackageConfigHelpers)
47+
include(GNUInstallDirs)
48+
49+
install(TARGETS lexy_core lexy_file lexy_unicode lexy_ext _lexy_base lexy_dev
50+
EXPORT ${PROJECT_NAME}Targets
51+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
52+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
53+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
54+
55+
install(EXPORT ${PROJECT_NAME}Targets
56+
NAMESPACE foonathan::
57+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
58+
59+
configure_package_config_file(
60+
cmake/lexyConfig.cmake.in
61+
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
62+
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
63+
install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
64+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
65+
66+
# YYYY.MM.N1 is compatible with YYYY.MM.N2.
67+
write_basic_package_version_file(
68+
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
69+
COMPATIBILITY SameMinorVersion)
70+
71+
install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
72+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
73+
74+
install(DIRECTORY include/lexy include/lexy_ext
75+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
76+
FILES_MATCHING
77+
PATTERN "*.hpp")
78+
endif()
79+
endif()
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (C) 2020-2022 Jonathan Müller and lexy contributors
2+
# SPDX-License-Identifier: BSL-1.0
3+
4+
# lexy CMake configuration file.
5+
6+
@PACKAGE_INIT@
7+
8+
include ("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Copyright (C) 2020-2022 Jonathan Müller and lexy contributors
2+
// SPDX-License-Identifier: BSL-1.0
3+
4+
#ifndef LEXY_DETAIL_ANY_REF_HPP_INCLUDED
5+
#define LEXY_DETAIL_ANY_REF_HPP_INCLUDED
6+
7+
#include <lexy/_detail/config.hpp>
8+
9+
// Essentially a void*, but we can cast it in a constexpr context.
10+
// The cost is an extra layer of indirection.
11+
12+
namespace lexy::_detail
13+
{
14+
template <typename T>
15+
class any_holder;
16+
17+
// Store a pointer to this instead of a void*.
18+
class any_base
19+
{
20+
public:
21+
any_base(const any_base&) = delete;
22+
any_base& operator=(const any_base&) = delete;
23+
24+
template <typename T>
25+
constexpr T& get() noexcept
26+
{
27+
return static_cast<any_holder<T>*>(this)->get();
28+
}
29+
template <typename T>
30+
constexpr const T& get() const noexcept
31+
{
32+
return static_cast<const any_holder<T>*>(this)->get();
33+
}
34+
35+
private:
36+
constexpr any_base() = default;
37+
~any_base() = default;
38+
39+
template <typename T>
40+
friend class any_holder;
41+
};
42+
43+
using any_ref = any_base*;
44+
using any_cref = const any_base*;
45+
46+
// Need to store the object in here.
47+
template <typename T>
48+
class any_holder : public any_base
49+
{
50+
public:
51+
constexpr explicit any_holder(T&& obj) : _obj(LEXY_MOV(obj)) {}
52+
53+
constexpr T& get() noexcept
54+
{
55+
return _obj;
56+
}
57+
constexpr const T& get() const noexcept
58+
{
59+
return _obj;
60+
}
61+
62+
private:
63+
T _obj;
64+
};
65+
} // namespace lexy::_detail
66+
67+
#endif // LEXY_DETAIL_ANY_REF_HPP_INCLUDED
68+

3rdparty/lexy/include/lexy/_detail/code_point.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ constexpr cp_result<Reader> parse_code_point(Reader reader)
158158
else if constexpr (std::is_same_v<typename Reader::encoding, lexy::utf8_encoding> //
159159
|| std::is_same_v<typename Reader::encoding, lexy::utf8_char_encoding>)
160160
{
161+
using uchar_t = unsigned char;
161162
constexpr auto payload_lead1 = 0b0111'1111;
162163
constexpr auto payload_lead2 = 0b0001'1111;
163164
constexpr auto payload_lead3 = 0b0000'1111;
@@ -170,7 +171,7 @@ constexpr cp_result<Reader> parse_code_point(Reader reader)
170171
constexpr auto pattern_lead4 = 0b11110 << 3;
171172
constexpr auto pattern_cont = 0b10 << 6;
172173

173-
auto first = reader.peek();
174+
auto first = uchar_t(reader.peek());
174175
if ((first & ~payload_lead1) == pattern_lead1)
175176
{
176177
// ASCII character.
@@ -185,7 +186,7 @@ constexpr cp_result<Reader> parse_code_point(Reader reader)
185186
{
186187
reader.bump();
187188

188-
auto second = reader.peek();
189+
auto second = uchar_t(reader.peek());
189190
if ((second & ~payload_cont) != pattern_cont)
190191
return {{}, cp_error::missing_trailing, reader.position()};
191192
reader.bump();
@@ -204,12 +205,12 @@ constexpr cp_result<Reader> parse_code_point(Reader reader)
204205
{
205206
reader.bump();
206207

207-
auto second = reader.peek();
208+
auto second = uchar_t(reader.peek());
208209
if ((second & ~payload_cont) != pattern_cont)
209210
return {{}, cp_error::missing_trailing, reader.position()};
210211
reader.bump();
211212

212-
auto third = reader.peek();
213+
auto third = uchar_t(reader.peek());
213214
if ((third & ~payload_cont) != pattern_cont)
214215
return {{}, cp_error::missing_trailing, reader.position()};
215216
reader.bump();
@@ -232,17 +233,17 @@ constexpr cp_result<Reader> parse_code_point(Reader reader)
232233
{
233234
reader.bump();
234235

235-
auto second = reader.peek();
236+
auto second = uchar_t(reader.peek());
236237
if ((second & ~payload_cont) != pattern_cont)
237238
return {{}, cp_error::missing_trailing, reader.position()};
238239
reader.bump();
239240

240-
auto third = reader.peek();
241+
auto third = uchar_t(reader.peek());
241242
if ((third & ~payload_cont) != pattern_cont)
242243
return {{}, cp_error::missing_trailing, reader.position()};
243244
reader.bump();
244245

245-
auto fourth = reader.peek();
246+
auto fourth = uchar_t(reader.peek());
246247
if ((fourth & ~payload_cont) != pattern_cont)
247248
return {{}, cp_error::missing_trailing, reader.position()};
248249
reader.bump();

0 commit comments

Comments
 (0)