mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-14 19:15:05 -05:00
Merge branch 'main' of https://github.com/geode-sdk/geode into main
This commit is contained in:
commit
afd9258995
764 changed files with 584 additions and 114223 deletions
6
.gitmodules
vendored
6
.gitmodules
vendored
|
@ -1,6 +0,0 @@
|
|||
[submodule "loader/md4c"]
|
||||
path = loader/md4c
|
||||
url = https://github.com/mity/md4c
|
||||
[submodule "loader/minhook"]
|
||||
path = loader/minhook
|
||||
url = https://github.com/TsudaKageyu/minhook
|
|
@ -19,9 +19,6 @@ message(STATUS "Version: ${GEODE_VERSION}, tag: ${GEODE_VERSION_TAG}")
|
|||
|
||||
project(geode-sdk VERSION ${GEODE_VERSION} LANGUAGES CXX C)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
add_library(${PROJECT_NAME} INTERFACE)
|
||||
|
||||
if (NOT DEFINED GEODE_DEBUG AND (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo))
|
||||
|
@ -44,6 +41,7 @@ set(GEODE_LOADER_PATH ${CMAKE_CURRENT_SOURCE_DIR}/loader)
|
|||
|
||||
include(cmake/GeodeFile.cmake)
|
||||
include(cmake/Platform.cmake)
|
||||
include(cmake/CPM.cmake)
|
||||
|
||||
target_sources(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/entry.cpp)
|
||||
|
||||
|
@ -94,10 +92,10 @@ target_link_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/lo
|
|||
|
||||
add_definitions(-DFMT_CONSTEVAL=)
|
||||
|
||||
add_subdirectory(loader/include/Geode/external/filesystem)
|
||||
add_subdirectory(loader/include/Geode/external/fmt)
|
||||
CPMAddPackage("gh:fmtlib/fmt#9.1.0")
|
||||
CPMAddPackage("gh:gulrak/filesystem#3e5b930")
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} INTERFACE filesystem fmt)
|
||||
target_link_libraries(${PROJECT_NAME} INTERFACE ghc_filesystem fmt)
|
||||
|
||||
|
||||
if (NOT EXISTS ${GEODE_BIN_PATH})
|
||||
|
@ -123,6 +121,7 @@ elseif(EXISTS ${GEODE_PLATFORM_BIN_PATH})
|
|||
target_precompile_headers(${PROJECT_NAME} INTERFACE
|
||||
"${GEODE_LOADER_PATH}/include/Geode/DefaultInclude.hpp"
|
||||
"${GEODE_LOADER_PATH}/include/Geode/Loader.hpp"
|
||||
# please stop adding modify here its not here because it makes windows compilation take longer than geode 1.0 release date
|
||||
"${GEODE_LOADER_PATH}/include/Geode/UI.hpp"
|
||||
"${GEODE_LOADER_PATH}/include/Geode/cocos/include/cocos2d.h"
|
||||
"${GEODE_LOADER_PATH}/include/Geode/cocos/extensions/cocos-ext.h"
|
||||
|
|
|
@ -3864,6 +3864,7 @@ class CustomSongLayerDelegate {
|
|||
|
||||
class LevelSettingsLayer : FLAlertLayer, ColorSelectDelegate, SelectArtDelegate, FLAlertLayerProtocol, CustomSongLayerDelegate {
|
||||
static LevelSettingsLayer* create(LevelSettingsObject* levelSettings, LevelEditorLayer* editor) = win 0x170d90;
|
||||
bool init(LevelSettingsObject* levelSettings, LevelEditorLayer* editor) = mac 0xa7e00, win 0x170e50;
|
||||
PAD = mac 0x50;
|
||||
LevelSettingsObject* m_settingsObject;
|
||||
}
|
||||
|
|
21
cmake/CPM.cmake
Normal file
21
cmake/CPM.cmake
Normal file
|
@ -0,0 +1,21 @@
|
|||
set(CPM_DOWNLOAD_VERSION 0.36.0)
|
||||
|
||||
if(CPM_SOURCE_CACHE)
|
||||
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
|
||||
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||
else()
|
||||
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||
endif()
|
||||
|
||||
# Expand relative path. This is important if the provided path contains a tilde (~)
|
||||
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
|
||||
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
|
||||
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
|
||||
file(DOWNLOAD
|
||||
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
|
||||
${CPM_DOWNLOAD_LOCATION}
|
||||
)
|
||||
endif()
|
||||
|
||||
include(${CPM_DOWNLOAD_LOCATION})
|
|
@ -1,303 +0,0 @@
|
|||
# When configuring CMake with a toolchain file against a top-level CMakeLists.txt,
|
||||
# it will actually run CMake many times, once for each small test program used to
|
||||
# determine what features a compiler supports. Unfortunately, none of these
|
||||
# invocations share a CMakeCache.txt with the top-level invocation, meaning they
|
||||
# won't see the value of any arguments the user passed via -D. Since these are
|
||||
# necessary to properly configure MSVC in both the top-level configuration as well as
|
||||
# all feature-test invocations, we set environment variables with the values so that
|
||||
# these environments get inherited by child invocations.
|
||||
function(init_user_prop prop)
|
||||
if(${prop})
|
||||
set(ENV{_${prop}} "${${prop}}")
|
||||
else()
|
||||
set(${prop} "$ENV{_${prop}}" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
macro(cmake_getconf VAR)
|
||||
if(NOT ${VAR})
|
||||
set(${VAR} "$ENV{${VAR}}")
|
||||
if(${VAR})
|
||||
set(${VAR} "${${VAR}}" CACHE STRING "${VAR}")
|
||||
message(STATUS "Found ${VAR}: ${${VAR}}")
|
||||
else()
|
||||
message(FATAL_ERROR "Cannot determine \"${VAR}\"")
|
||||
endif()
|
||||
else()
|
||||
set(ENV{${VAR}} "${${VAR}}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
function(generate_winsdk_vfs_overlay winsdk_include_dir output_path)
|
||||
set(include_dirs)
|
||||
file(GLOB_RECURSE entries LIST_DIRECTORIES true "${winsdk_include_dir}/*")
|
||||
foreach(entry ${entries})
|
||||
if(IS_DIRECTORY "${entry}")
|
||||
list(APPEND include_dirs "${entry}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
file(WRITE "${output_path}" "version: 0\n")
|
||||
file(APPEND "${output_path}" "case-sensitive: false\n")
|
||||
file(APPEND "${output_path}" "roots:\n")
|
||||
|
||||
foreach(dir ${include_dirs})
|
||||
file(GLOB headers RELATIVE "${dir}" "${dir}/*.h")
|
||||
if(NOT headers)
|
||||
continue()
|
||||
endif()
|
||||
|
||||
file(APPEND "${output_path}" " - name: \"${dir}\"\n")
|
||||
file(APPEND "${output_path}" " type: directory\n")
|
||||
file(APPEND "${output_path}" " contents:\n")
|
||||
|
||||
foreach(header ${headers})
|
||||
file(APPEND "${output_path}" " - name: \"${header}\"\n")
|
||||
file(APPEND "${output_path}" " type: file\n")
|
||||
file(APPEND "${output_path}" " external-contents: \"${dir}/${header}\"\n")
|
||||
endforeach()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(generate_winsdk_lib_symlinks winsdk_um_lib_dir output_dir)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${output_dir}")
|
||||
file(GLOB libraries RELATIVE "${winsdk_um_lib_dir}" "${winsdk_um_lib_dir}/*")
|
||||
foreach(library ${libraries})
|
||||
string(TOLOWER "${library}" symlink_name)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}"
|
||||
-E create_symlink
|
||||
"${winsdk_um_lib_dir}/${library}"
|
||||
"${output_dir}/${symlink_name}")
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
set(CMAKE_SYSTEM_VERSION 10.0)
|
||||
set(CMAKE_SYSTEM_PROCESSOR AMD64)
|
||||
|
||||
cmake_getconf(HOST_ARCH)
|
||||
cmake_getconf(MSVC_BASE)
|
||||
cmake_getconf(WINSDK_BASE)
|
||||
cmake_getconf(WINSDK_VER)
|
||||
cmake_getconf(LLVM_VER)
|
||||
cmake_getconf(CLANG_VER)
|
||||
cmake_getconf(LLVM_PATH)
|
||||
|
||||
if(LLVM_VER STREQUAL "")
|
||||
set(LLVM_VER 11)
|
||||
message(STATUS "LLVM_VER not set assuming version ${LLVM_VER}")
|
||||
endif()
|
||||
|
||||
if(CLANG_VER STREQUAL "")
|
||||
set(CLANG_VER 11)
|
||||
message(STATUS "CLANG_VER not set assuming version ${CLANG_VER}")
|
||||
endif()
|
||||
|
||||
if(NOT HOST_ARCH)
|
||||
set(HOST_ARCH x86_64)
|
||||
endif()
|
||||
if(HOST_ARCH STREQUAL "aarch64" OR HOST_ARCH STREQUAL "arm64")
|
||||
set(TRIPLE_ARCH "aarch64")
|
||||
set(WINSDK_ARCH "arm64")
|
||||
elseif(HOST_ARCH STREQUAL "armv7" OR HOST_ARCH STREQUAL "arm")
|
||||
set(TRIPLE_ARCH "armv7")
|
||||
set(WINSDK_ARCH "arm")
|
||||
elseif(HOST_ARCH STREQUAL "i686" OR HOST_ARCH STREQUAL "x86")
|
||||
set(TRIPLE_ARCH "i686")
|
||||
set(WINSDK_ARCH "x86")
|
||||
elseif(HOST_ARCH STREQUAL "x86_64" OR HOST_ARCH STREQUAL "x64")
|
||||
set(TRIPLE_ARCH "x86_64")
|
||||
set(WINSDK_ARCH "x64")
|
||||
else()
|
||||
message(SEND_ERROR "Unknown host architecture ${HOST_ARCH}. Must be aarch64 (or arm64), armv7 (or arm), i686 (or x86), or x86_64 (or x64).")
|
||||
endif()
|
||||
|
||||
set(MSVC_INCLUDE "${MSVC_BASE}/include")
|
||||
set(MSVC_LIB "${MSVC_BASE}/lib")
|
||||
set(WINSDK_INCLUDE "${WINSDK_BASE}/Include/${WINSDK_VER}")
|
||||
set(WINSDK_LIB "${WINSDK_BASE}/Lib/${WINSDK_VER}")
|
||||
|
||||
if(NOT EXISTS "${MSVC_BASE}" OR
|
||||
NOT EXISTS "${MSVC_INCLUDE}" OR
|
||||
NOT EXISTS "${MSVC_LIB}")
|
||||
message(SEND_ERROR
|
||||
"CMake variable MSVC_BASE must point to a folder containing MSVC "
|
||||
"system headers and libraries")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${WINSDK_BASE}" OR
|
||||
NOT EXISTS "${WINSDK_INCLUDE}" OR
|
||||
NOT EXISTS "${WINSDK_LIB}")
|
||||
message(SEND_ERROR
|
||||
"CMake variable WINSDK_BASE and WINSDK_VER must resolve to a valid "
|
||||
"Windows SDK installation")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${WINSDK_INCLUDE}/um/Windows.h")
|
||||
message(SEND_ERROR "Cannot find Windows.h")
|
||||
endif()
|
||||
if(NOT EXISTS "${WINSDK_INCLUDE}/um/WINDOWS.H")
|
||||
set(case_sensitive_filesystem TRUE)
|
||||
endif()
|
||||
|
||||
# Attempt to find the clang-cl binary
|
||||
find_program(CLANG_CL_PATH NAMES clang-cl-${CLANG_VER} clang-cl PATHS ${LLVM_PATH})
|
||||
if(${CLANG_CL_PATH} STREQUAL "CLANG_CL_PATH-NOTFOUND")
|
||||
message(SEND_ERROR "Unable to find clang-cl-${CLANG_VER}")
|
||||
endif()
|
||||
|
||||
# Attempt to find the llvm-link binary
|
||||
find_program(LLD_LINK_PATH NAMES lld-link-${LLVM_VER} lld-link PATHS ${LLVM_PATH})
|
||||
if(${LLD_LINK_PATH} STREQUAL "LLD_LINK_PATH-NOTFOUND")
|
||||
message(SEND_ERROR "Unable to find lld-link-${LLVM_VER}")
|
||||
endif()
|
||||
|
||||
# Attempt to find the lld-lib binary
|
||||
find_program(LLVM_LIB_PATH NAMES llvm-lib-${LLVM_VER} llvm-lib PATHS ${LLVM_PATH})
|
||||
if(${LLVM_LIB_PATH} STREQUAL "LLVM_LIB_PATH-NOTFOUND")
|
||||
message(SEND_ERROR "Unable to find llvm-lib-${LLVM_VER}")
|
||||
endif()
|
||||
|
||||
# Attempt to find the llvm-nm binary
|
||||
find_program(LLVM_NM_PATH NAMES llvm-nm-${LLVM_VER} llvm-nm PATHS ${LLVM_PATH})
|
||||
if(${LLVM_NM_PATH} STREQUAL "LLVM_NM_PATH-NOTFOUND")
|
||||
message(SEND_ERROR "Unable to find llvm-nm-${LLVM_VER}")
|
||||
endif()
|
||||
|
||||
# Attempt to find the llvm-mt binary
|
||||
find_program(LLVM_MT_PATH NAMES llvm-mt-${LLVM_VER} llvm-mt PATHS ${LLVM_PATH})
|
||||
#set(LLVM_MT_PATH "${CMAKE_CURRENT_LIST_DIR}/llvm-mt-wrapper")
|
||||
if(${LLVM_MT_PATH} STREQUAL "LLVM_MT_PATH-NOTFOUND")
|
||||
message(SEND_ERROR "Unable to find llvm-mt-${LLVM_VER}")
|
||||
endif()
|
||||
|
||||
# Attempt to find the native clang binary
|
||||
find_program(CLANG_C_PATH NAMES clang-${CLANG_VER} clang PATHS ${LLVM_PATH})
|
||||
if(${CLANG_C_PATH} STREQUAL "CLANG_C_PATH-NOTFOUND")
|
||||
message(SEND_ERROR "Unable to find clang-${CLANG_VER}")
|
||||
endif()
|
||||
|
||||
# Attempt to find the native clang++ binary
|
||||
find_program(CLANG_CXX_PATH NAMES clang++-${CLANG_VER} clang++ PATHS ${LLVM_PATH})
|
||||
if(${CLANG_CXX_PATH} STREQUAL "CLANG_CXX_PATH-NOTFOUND")
|
||||
message(SEND_ERROR "Unable to find clang++-${CLANG_VER}")
|
||||
endif()
|
||||
|
||||
# Attempt to find the llvm-rc binary
|
||||
find_program(LLVM_RC_PATH NAMES llvm-rc-${LLVM_VER} llvm-rc PATHS ${LLVM_PATH})
|
||||
if(${LLVM_RC_PATH} STREQUAL "LLVM_RC_PATH-NOTFOUND")
|
||||
message(SEND_ERROR "Unable to find rc")
|
||||
endif()
|
||||
|
||||
|
||||
set(CMAKE_C_COMPILER "${CLANG_CL_PATH}" CACHE FILEPATH "")
|
||||
set(CMAKE_CXX_COMPILER "${CLANG_CL_PATH}" CACHE FILEPATH "")
|
||||
set(CMAKE_RC_COMPILER "${LLVM_RC_PATH}" CACHE FILEPATH "")
|
||||
set(CMAKE_LINKER "${LLD_LINK_PATH}" CACHE FILEPATH "")
|
||||
set(CMAKE_AR "${LLVM_LIB_PATH}" CACHE FILEPATH "")
|
||||
set(CMAKE_NM "${LLVM_NM_PATH}" CACHE FILEPATH "")
|
||||
set(CMAKE_MT "${LLVM_MT_PATH}" CACHE FILEPATH "")
|
||||
|
||||
# Even though we're cross-compiling, we need some native tools (e.g. llvm-tblgen), and those
|
||||
# native tools have to be built before we can start doing the cross-build. LLVM supports
|
||||
# a CROSS_TOOLCHAIN_FLAGS_NATIVE argument which consists of a list of flags to pass to CMake
|
||||
# when configuring the NATIVE portion of the cross-build. By default we construct this so
|
||||
# that it points to the tools in the same location as the native clang-cl that we're using.
|
||||
list(APPEND _CTF_NATIVE_DEFAULT "-DCMAKE_ASM_COMPILER=${CLANG_C_PATH}")
|
||||
list(APPEND _CTF_NATIVE_DEFAULT "-DCMAKE_C_COMPILER=${CLANG_C_PATH}")
|
||||
list(APPEND _CTF_NATIVE_DEFAULT "-DCMAKE_CXX_COMPILER=${CLANG_CXX_PATH}")
|
||||
|
||||
set(CROSS_TOOLCHAIN_FLAGS_NATIVE "${_CTF_NATIVE_DEFAULT}" CACHE STRING "")
|
||||
|
||||
set(COMPILE_FLAGS
|
||||
-Xclang -fexceptions -Xclang -fcxx-exceptions -Xclang
|
||||
-D_CRT_SECURE_NO_WARNINGS
|
||||
--target=${TRIPLE_ARCH}-windows-msvc
|
||||
-fms-compatibility-version=19.11
|
||||
-Wno-unused-command-line-argument # Needed to accept projects pushing both -Werror and /MP
|
||||
-imsvc "${MSVC_INCLUDE}"
|
||||
-imsvc "${WINSDK_INCLUDE}/ucrt"
|
||||
-imsvc "${WINSDK_INCLUDE}/shared"
|
||||
-imsvc "${WINSDK_INCLUDE}/um"
|
||||
-imsvc "${WINSDK_INCLUDE}/winrt")
|
||||
|
||||
link_libraries(user32 kernel32 shell32 ole32)
|
||||
|
||||
if(case_sensitive_filesystem)
|
||||
# Ensure all sub-configures use the top-level VFS overlay instead of generating their own.
|
||||
init_user_prop(winsdk_vfs_overlay_path)
|
||||
if(NOT winsdk_vfs_overlay_path)
|
||||
set(winsdk_vfs_overlay_path "${CMAKE_BINARY_DIR}/winsdk_vfs_overlay.yaml")
|
||||
generate_winsdk_vfs_overlay("${WINSDK_BASE}/Include/${WINSDK_VER}" "${winsdk_vfs_overlay_path}")
|
||||
init_user_prop(winsdk_vfs_overlay_path)
|
||||
endif()
|
||||
list(APPEND COMPILE_FLAGS
|
||||
-Xclang -ivfsoverlay -Xclang "${winsdk_vfs_overlay_path}")
|
||||
|
||||
set(CMAKE_CLANG_VFS_OVERLAY "${winsdk_vfs_overlay_path}")
|
||||
endif()
|
||||
|
||||
string(REPLACE ";" " " COMPILE_FLAGS "${COMPILE_FLAGS}")
|
||||
|
||||
# We need to preserve any flags that were passed in by the user. However, we
|
||||
# can't append to CMAKE_C_FLAGS and friends directly, because toolchain files
|
||||
# will be re-invoked on each reconfigure and therefore need to be idempotent.
|
||||
# The assignments to the _INITIAL cache variables don't use FORCE, so they'll
|
||||
# only be populated on the initial configure, and their values won't change
|
||||
# afterward.
|
||||
set(_CMAKE_RC_FLAGS_INITIAL -I "${MSVC_INCLUDE}"
|
||||
-I "${WINSDK_INCLUDE}/ucrt"
|
||||
-I "${WINSDK_INCLUDE}/shared"
|
||||
-I "${WINSDK_INCLUDE}/um"
|
||||
-I "${WINSDK_INCLUDE}/winrt")
|
||||
string(REPLACE ";" " " _CMAKE_RC_FLAGS_INITIAL "${_CMAKE_RC_FLAGS_INITIAL}")
|
||||
set(CMAKE_RC_FLAGS "${_CMAKE_RC_FLAGS_INITIAL}" CACHE STRING "" FORCE)
|
||||
|
||||
set(_CMAKE_C_FLAGS_INITIAL "${CMAKE_C_FLAGS}" CACHE STRING "")
|
||||
set(CMAKE_C_FLAGS "${_CMAKE_C_FLAGS_INITIAL} ${COMPILE_FLAGS}" CACHE STRING "" FORCE)
|
||||
|
||||
set(_CMAKE_CXX_FLAGS_INITIAL "${CMAKE_CXX_FLAGS}" CACHE STRING "")
|
||||
set(CMAKE_CXX_FLAGS "${_CMAKE_CXX_FLAGS_INITIAL} ${COMPILE_FLAGS}" CACHE STRING "" FORCE)
|
||||
|
||||
set(LINK_FLAGS
|
||||
# Prevent CMake from attempting to invoke mt.exe. It only recognizes the slashed form and not the dashed form.
|
||||
#/manifest:no
|
||||
|
||||
-libpath:"${MSVC_LIB}/${WINSDK_ARCH}"
|
||||
-libpath:"${WINSDK_LIB}/ucrt/${WINSDK_ARCH}"
|
||||
-libpath:"${WINSDK_LIB}/um/${WINSDK_ARCH}")
|
||||
|
||||
if(case_sensitive_filesystem)
|
||||
# Ensure all sub-configures use the top-level symlinks dir instead of generating their own.
|
||||
init_user_prop(winsdk_lib_symlinks_dir)
|
||||
if(NOT winsdk_lib_symlinks_dir)
|
||||
set(winsdk_lib_symlinks_dir "${CMAKE_BINARY_DIR}/winsdk_lib_symlinks")
|
||||
generate_winsdk_lib_symlinks("${WINSDK_BASE}/Lib/${WINSDK_VER}/um/${WINSDK_ARCH}" "${winsdk_lib_symlinks_dir}")
|
||||
init_user_prop(winsdk_lib_symlinks_dir)
|
||||
endif()
|
||||
list(APPEND LINK_FLAGS
|
||||
-libpath:"${winsdk_lib_symlinks_dir}")
|
||||
endif()
|
||||
|
||||
string(REPLACE ";" " " LINK_FLAGS "${LINK_FLAGS}")
|
||||
|
||||
# See explanation for compiler flags above for the _INITIAL variables.
|
||||
set(_CMAKE_EXE_LINKER_FLAGS_INITIAL "${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${_CMAKE_EXE_LINKER_FLAGS_INITIAL} ${LINK_FLAGS}" CACHE STRING "" FORCE)
|
||||
|
||||
set(_CMAKE_MODULE_LINKER_FLAGS_INITIAL "${CMAKE_MODULE_LINKER_FLAGS}" CACHE STRING "")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${_CMAKE_MODULE_LINKER_FLAGS_INITIAL} ${LINK_FLAGS}" CACHE STRING "" FORCE)
|
||||
|
||||
set(_CMAKE_SHARED_LINKER_FLAGS_INITIAL "${CMAKE_SHARED_LINKER_FLAGS}" CACHE STRING "")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${_CMAKE_SHARED_LINKER_FLAGS_INITIAL} ${LINK_FLAGS}" CACHE STRING "" FORCE)
|
||||
|
||||
# CMake populates these with a bunch of unnecessary libraries, which requires
|
||||
# extra case-correcting symlinks and what not. Instead, let projects explicitly
|
||||
# control which libraries they require.
|
||||
set(CMAKE_C_STANDARD_LIBRARIES "" CACHE STRING "" FORCE)
|
||||
set(CMAKE_CXX_STANDARD_LIBRARIES "" CACHE STRING "" FORCE)
|
||||
|
||||
if(NOT $ENV{VCPKG_TOOLCHAIN} STREQUAL "")
|
||||
message(STATUS "Included VCPKG: $ENV{VCPKG_TOOLCHAIN}")
|
||||
include($ENV{VCPKG_TOOLCHAIN})
|
||||
endif()
|
|
@ -58,7 +58,7 @@ elseif (GEODE_TARGET_PLATFORM STREQUAL "Win32")
|
|||
${GEODE_LOADER_PATH}/include/Geode/cocos/cocos2dx/platform/third_party/win32/OGLES
|
||||
)
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME} INTERFACE -DCC_TARGET_OS_WIN32)
|
||||
target_compile_definitions(${PROJECT_NAME} INTERFACE -DCC_TARGET_OS_WIN32 NOMINMAX)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} INTERFACE
|
||||
${GEODE_LOADER_PATH}/include/link/libcocos2d.lib
|
||||
|
|
|
@ -7,6 +7,6 @@ target_compile_features(Broma PRIVATE cxx_std_17)
|
|||
|
||||
target_include_directories(Broma PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
|
||||
add_subdirectory(PEGTL-3.2.7)
|
||||
target_compile_definitions(Broma PUBLIC TAO_PEGTL_GHC_FILESYSTEM=1)
|
||||
|
||||
target_link_libraries(Broma taocpp::pegtl)
|
||||
target_link_libraries(Broma taocpp::pegtl ghc_filesystem)
|
|
@ -1,84 +0,0 @@
|
|||
# the official .clang-format style for https://github.com/taocpp
|
||||
#
|
||||
# clang-format -i -style=file $(find . -name '[^.]*.[hc]pp')
|
||||
|
||||
Language: Cpp
|
||||
Standard: Latest
|
||||
|
||||
AccessModifierOffset: -3
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlinesLeft: false
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: Empty
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
BraceWrapping:
|
||||
AfterClass: true
|
||||
AfterControlStatement: false
|
||||
AfterEnum : true
|
||||
AfterFunction : true
|
||||
AfterNamespace : true
|
||||
AfterStruct : true
|
||||
AfterUnion : true
|
||||
AfterExternBlock: true
|
||||
BeforeCatch : true
|
||||
BeforeElse : true
|
||||
IndentBraces : false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: false
|
||||
SplitEmptyNamespace: false
|
||||
BreakBeforeBinaryOperators: All
|
||||
BreakBeforeBraces: Custom
|
||||
BreakBeforeTernaryOperators: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakStringLiterals: false
|
||||
ColumnLimit: 0
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth: 3
|
||||
ContinuationIndentWidth: 3
|
||||
Cpp11BracedListStyle: false
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true
|
||||
IncludeBlocks: Preserve
|
||||
IndentCaseLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: 3
|
||||
IndentWrappedFunctionNames: false
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: All
|
||||
PointerAlignment: Left
|
||||
ReflowComments: false
|
||||
SortIncludes: true
|
||||
SortUsingDeclarations: false
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: Never
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 2
|
||||
SpacesInAngles: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: true
|
||||
SpacesInSquareBrackets: true
|
||||
TabWidth: 8
|
||||
UseTab: Never
|
|
@ -1,34 +0,0 @@
|
|||
Checks: >-
|
||||
bugprone-*,
|
||||
cppcoreguidelines-slicing,
|
||||
cppcoreguidelines-special-member-functions,
|
||||
google-build-explicit-make-pair,
|
||||
google-build-namespaces,
|
||||
google-default-arguments,
|
||||
google-global-names-in-headers,
|
||||
google-readability-casting,
|
||||
llvm-*,
|
||||
-llvm-namespace-comment,
|
||||
misc-*,
|
||||
-misc-no-recursion,
|
||||
-misc-non-private-member-variables-in-classes,
|
||||
-misc-unused-alias-decls,
|
||||
modernize-*,
|
||||
-modernize-avoid-c-arrays,
|
||||
-modernize-concat-nested-namespaces,
|
||||
-modernize-raw-string-literal,
|
||||
-modernize-use-trailing-return-type,
|
||||
performance-*,
|
||||
readability-*,
|
||||
-readability-avoid-const-params-in-decls,
|
||||
-readability-magic-numbers,
|
||||
-readability-static-accessed-through-instance,
|
||||
|
||||
CheckOptions:
|
||||
- { key: readability-identifier-naming.ClassCase, value: lower_case }
|
||||
- { key: readability-identifier-naming.FunctionCase, value: lower_case }
|
||||
- { key: readability-identifier-naming.ParameterCase, value: lower_case }
|
||||
- { key: readability-identifier-naming.StructCase, value: aNy_CasE } # PEGTL rules
|
||||
- { key: readability-identifier-naming.VariableCase, value: lower_case }
|
||||
|
||||
WarningsAsErrors: '*'
|
|
@ -1,4 +0,0 @@
|
|||
# When a dependency is added with add_subdirectory, but searched with find_package
|
||||
|
||||
# Redirect to the directory added with add_subdirectory
|
||||
add_subdirectory("@PROJECT_SOURCE_DIR@" "@PROJECT_BINARY_DIR@")
|
|
@ -1,22 +0,0 @@
|
|||
// This is a dummy program that just needs to compile and link to tell us if
|
||||
// the C++17 std::filesystem API is available. Use CMake's configure_file
|
||||
// command to replace the FILESYSTEM_HEADER and FILESYSTEM_NAMESPACE tokens
|
||||
// for each combination of headers and namespaces which we want to pass to the
|
||||
// CMake try_compile command.
|
||||
|
||||
#include <@FILESYSTEM_HEADER@>
|
||||
|
||||
// clang-format off
|
||||
int main()
|
||||
{
|
||||
#if defined( __cpp_exceptions )
|
||||
try {
|
||||
throw @FILESYSTEM_NAMESPACE@::filesystem_error( "instantiate one to make sure it links", std::make_error_code( std::errc::function_not_supported ) );
|
||||
}
|
||||
catch( const @FILESYSTEM_NAMESPACE@::filesystem_error& error ) {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return !@FILESYSTEM_NAMESPACE@::temp_directory_path().is_absolute();
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
ignore:
|
||||
- src/example/**/*
|
|
@ -1,39 +0,0 @@
|
|||
name: Android
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'doc/**'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'doc/**'
|
||||
|
||||
jobs:
|
||||
android:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
image:
|
||||
- r22
|
||||
platform:
|
||||
- android-27
|
||||
- android-29
|
||||
abi:
|
||||
- armeabi-v7a
|
||||
- arm64-v8a
|
||||
build_type: [Debug, Release]
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
container:
|
||||
image: bojoe/cpp-android-ndk-build-env-ubuntu:${{ matrix.image }}
|
||||
options: --user root
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- run: cmake -H$GITHUB_WORKSPACE -B/home/developer/build -GNinja -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake -DANDROID_ABI=${{ matrix.abi }} -DANDROID_PLATFORM=${{ matrix.platform }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
|
||||
|
||||
- run: cmake --build /home/developer/build
|
|
@ -1,30 +0,0 @@
|
|||
name: clang-analyze
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'doc/**'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'doc/**'
|
||||
|
||||
jobs:
|
||||
clang-analyze:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- run: sudo apt-get update -yq
|
||||
|
||||
- run: sudo apt-get install -yq clang-tools
|
||||
|
||||
- run: scan-build cmake -E make_directory build
|
||||
|
||||
- working-directory: build/
|
||||
run: scan-build cmake $GITHUB_WORKSPACE
|
||||
|
||||
- working-directory: build/
|
||||
run: scan-build cmake --build .
|
|
@ -1,22 +0,0 @@
|
|||
name: clang-format
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'doc/**'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'doc/**'
|
||||
|
||||
jobs:
|
||||
clang-format:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: DoozyX/clang-format-lint-action@v0.13
|
||||
with:
|
||||
extensions: 'hpp,cpp'
|
||||
clangFormatVersion: 13
|
|
@ -1,26 +0,0 @@
|
|||
name: clang-tidy
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'doc/**'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'doc/**'
|
||||
|
||||
jobs:
|
||||
clang-tidy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- run: sudo apt-get update -yq
|
||||
|
||||
- run: sudo apt-get install -yq clang-tidy
|
||||
|
||||
- run: find include/ -name '*.hpp' | grep -vF file_mapper_win32.hpp | grep -vF endian_win.hpp | xargs -I '{}' clang-tidy --quiet '{}' -- --std=c++17 -Iinclude
|
||||
|
||||
- run: find src/ -name '*.cpp' | xargs -I '{}' clang-tidy --quiet '{}' -- --std=c++17 -Iinclude
|
|
@ -1,32 +0,0 @@
|
|||
name: Code Coverage
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'doc/**'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'doc/**'
|
||||
|
||||
jobs:
|
||||
code-coverage:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- run: cmake -E make_directory build
|
||||
|
||||
- working-directory: build/
|
||||
run: cmake $GITHUB_WORKSPACE -DPEGTL_BUILD_EXAMPLES=OFF -DCMAKE_CXX_FLAGS="-coverage"
|
||||
|
||||
- working-directory: build/
|
||||
run: cmake --build .
|
||||
|
||||
- working-directory: build/
|
||||
run: ctest --output-on-failure
|
||||
|
||||
- working-directory: build/
|
||||
run: bash <(curl -s https://codecov.io/bash)
|
|
@ -1,73 +0,0 @@
|
|||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, 3.x ]
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'doc/**'
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ main, 3.x ]
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'doc/**'
|
||||
schedule:
|
||||
- cron: '31 6 * * 0'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'cpp' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
||||
# Learn more:
|
||||
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
|
@ -1,157 +0,0 @@
|
|||
name: Linux
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'doc/**'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'doc/**'
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
compiler:
|
||||
- g++-9
|
||||
- g++-10
|
||||
- clang++-10
|
||||
- clang++-11
|
||||
- clang++-12
|
||||
build_type: [Debug, Release]
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
CXX: ${{ matrix.compiler }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- run: cmake -E make_directory build
|
||||
|
||||
- working-directory: build/
|
||||
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
|
||||
|
||||
- working-directory: build/
|
||||
run: cmake --build .
|
||||
|
||||
- working-directory: build/
|
||||
run: ctest --output-on-failure
|
||||
|
||||
linux-new:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
compiler:
|
||||
- g++-11
|
||||
- clang++-13
|
||||
- clang++-14
|
||||
build_type: [Debug, Release]
|
||||
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
env:
|
||||
CXX: ${{ matrix.compiler }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- run: cmake -E make_directory build
|
||||
|
||||
- working-directory: build/
|
||||
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
|
||||
|
||||
- working-directory: build/
|
||||
run: cmake --build .
|
||||
|
||||
- working-directory: build/
|
||||
run: ctest --output-on-failure
|
||||
|
||||
linux-old:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
compiler:
|
||||
- g++-7
|
||||
- g++-8
|
||||
- clang++-6.0
|
||||
- clang++-7
|
||||
- clang++-8
|
||||
- clang++-9
|
||||
build_type: [Debug, Release]
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
CXX: ${{ matrix.compiler }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- run: sudo apt-get update -yq
|
||||
|
||||
- run: sudo apt-get install -yq ${{ matrix.compiler }}
|
||||
|
||||
- run: cmake -E make_directory build
|
||||
|
||||
- working-directory: build/
|
||||
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
|
||||
|
||||
- working-directory: build/
|
||||
run: cmake --build .
|
||||
|
||||
- working-directory: build/
|
||||
run: ctest --output-on-failure
|
||||
|
||||
linux-gcc-extra:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
flags: ["-fno-rtti"]
|
||||
build_type: [Debug, Release]
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- run: cmake -E make_directory build
|
||||
|
||||
- working-directory: build/
|
||||
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_FLAGS="${{ matrix.flags }}"
|
||||
|
||||
- working-directory: build/
|
||||
run: cmake --build .
|
||||
|
||||
- working-directory: build/
|
||||
run: ctest --output-on-failure
|
||||
|
||||
linux-clang-extra:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
flags: ["-fno-rtti", "-fms-extensions"]
|
||||
build_type: [Debug, Release]
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
CXX: clang++
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- run: cmake -E make_directory build
|
||||
|
||||
- working-directory: build/
|
||||
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_FLAGS="${{ matrix.flags }}"
|
||||
|
||||
- working-directory: build/
|
||||
run: cmake --build .
|
||||
|
||||
- working-directory: build/
|
||||
run: ctest --output-on-failure
|
|
@ -1,39 +0,0 @@
|
|||
name: macOS
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'doc/**'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'doc/**'
|
||||
|
||||
jobs:
|
||||
xcode:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
xcode: ['11', '12', '13']
|
||||
build_type: [Debug, Release]
|
||||
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- uses: maxim-lobanov/setup-xcode@v1
|
||||
with:
|
||||
xcode-version: ${{ matrix.xcode }}
|
||||
|
||||
- run: cmake -E make_directory build
|
||||
|
||||
- working-directory: build/
|
||||
run: cmake $GITHUB_WORKSPACE
|
||||
|
||||
- working-directory: build/
|
||||
run: cmake --build . --config ${{ matrix.build_type }}
|
||||
|
||||
- working-directory: build/
|
||||
run: ctest --config ${{ matrix.build_type }} --output-on-failure
|
|
@ -1,38 +0,0 @@
|
|||
name: No-Exceptions
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'doc/**'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'doc/**'
|
||||
|
||||
jobs:
|
||||
no-exceptions:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
compiler: [g++, clang++]
|
||||
build_type: [Debug, Release]
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
CXX: ${{ matrix.compiler }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- run: cmake -E make_directory build
|
||||
|
||||
- working-directory: build/
|
||||
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_FLAGS="-fno-exceptions"
|
||||
|
||||
- working-directory: build/
|
||||
run: cmake --build .
|
||||
|
||||
- working-directory: build/
|
||||
run: ctest --output-on-failure
|
|
@ -1,38 +0,0 @@
|
|||
name: Sanitizer
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'doc/**'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'doc/**'
|
||||
|
||||
jobs:
|
||||
sanitizer:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
cxx: [g++, clang++]
|
||||
sanitizer: [address, undefined]
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
CXX: ${{ matrix.cxx }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- run: cmake -E make_directory build
|
||||
|
||||
- working-directory: build/
|
||||
run: cmake $GITHUB_WORKSPACE -DPEGTL_BUILD_EXAMPLES=OFF -DCMAKE_CXX_FLAGS="-fsanitize=${{ matrix.sanitizer }}"
|
||||
|
||||
- working-directory: build/
|
||||
run: cmake --build .
|
||||
|
||||
- working-directory: build/
|
||||
run: ctest --output-on-failure
|
|
@ -1,104 +0,0 @@
|
|||
name: Windows
|
||||
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'doc/**'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- 'README.md'
|
||||
- 'doc/**'
|
||||
|
||||
jobs:
|
||||
vs2022:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
build_type: [Debug, Release]
|
||||
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- run: cmake -E make_directory build
|
||||
|
||||
- shell: bash
|
||||
working-directory: build/
|
||||
run: cmake $GITHUB_WORKSPACE -G "Visual Studio 17 2022"
|
||||
|
||||
- working-directory: build/
|
||||
run: cmake --build . --config ${{ matrix.build_type }}
|
||||
|
||||
- working-directory: build/
|
||||
run: ctest -C ${{ matrix.build_type }} --output-on-failure
|
||||
|
||||
vs2022-clang:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
build_type: [Debug, Release]
|
||||
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- run: cmake -E make_directory build
|
||||
|
||||
- shell: bash
|
||||
working-directory: build/
|
||||
run: cmake $GITHUB_WORKSPACE -G "Visual Studio 17 2022" -T ClangCL
|
||||
|
||||
- working-directory: build/
|
||||
run: cmake --build . --config ${{ matrix.build_type }}
|
||||
|
||||
- working-directory: build/
|
||||
run: ctest -C ${{ matrix.build_type }} --output-on-failure
|
||||
|
||||
vs2019:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
build_type: [Debug, Release]
|
||||
|
||||
runs-on: windows-2019
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- run: cmake -E make_directory build
|
||||
|
||||
- shell: bash
|
||||
working-directory: build/
|
||||
run: cmake $GITHUB_WORKSPACE -G "Visual Studio 16 2019"
|
||||
|
||||
- working-directory: build/
|
||||
run: cmake --build . --config ${{ matrix.build_type }}
|
||||
|
||||
- working-directory: build/
|
||||
run: ctest -C ${{ matrix.build_type }} --output-on-failure
|
||||
|
||||
vs2019-clang:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
build_type: [Debug, Release]
|
||||
|
||||
runs-on: windows-2019
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- run: cmake -E make_directory build
|
||||
|
||||
- shell: bash
|
||||
working-directory: build/
|
||||
run: cmake $GITHUB_WORKSPACE -G "Visual Studio 16 2019" -T ClangCL
|
||||
|
||||
- working-directory: build/
|
||||
run: cmake --build . --config ${{ matrix.build_type }}
|
||||
|
||||
- working-directory: build/
|
||||
run: ctest -C ${{ matrix.build_type }} --output-on-failure
|
5
codegen/Broma/PEGTL-3.2.7/.gitignore
vendored
5
codegen/Broma/PEGTL-3.2.7/.gitignore
vendored
|
@ -1,5 +0,0 @@
|
|||
*~
|
||||
build
|
||||
private
|
||||
/.vs
|
||||
/.vscode
|
|
@ -1,110 +0,0 @@
|
|||
cmake_minimum_required(VERSION 3.8...3.19)
|
||||
|
||||
# Read version from version.hpp
|
||||
file(READ "${CMAKE_CURRENT_LIST_DIR}/include/tao/pegtl/version.hpp" version_hpp_data)
|
||||
string(REGEX MATCH "#define TAO_PEGTL_VERSION \"([^\"]+)\"" _ ${version_hpp_data})
|
||||
set(PEGTL_VERSION "${CMAKE_MATCH_1}")
|
||||
|
||||
project(pegtl VERSION ${PEGTL_VERSION} LANGUAGES CXX)
|
||||
|
||||
set(PEGTL_IS_MAIN_PROJECT OFF)
|
||||
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||
set(PEGTL_IS_MAIN_PROJECT ON)
|
||||
endif()
|
||||
|
||||
if(PEGTL_HAS_PARENT)
|
||||
# Multiple versions of PEGTL can't co-exist
|
||||
if(NOT ${PROJECT_NAME}_VERSION STREQUAL ${PROJECT_VERSION})
|
||||
message(FATAL_ERROR "Multiple mismatched PEGTL versions")
|
||||
endif()
|
||||
|
||||
# Only include if this is the first include
|
||||
if(NOT ${PROJECT_NAME}_DIR STREQUAL "${PROJECT_BINARY_DIR}")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Keep track of pegtl version
|
||||
set(${PROJECT_NAME}_FOUND TRUE CACHE BOOL "" FORCE)
|
||||
set(${PROJECT_NAME}_VERSION "${PROJECT_VERSION}" CACHE STRING "" FORCE)
|
||||
set(${PROJECT_NAME}_DIR "${PROJECT_BINARY_DIR}" CACHE PATH "" FORCE)
|
||||
|
||||
mark_as_advanced(${PROJECT_NAME}_FOUND)
|
||||
mark_as_advanced(${PROJECT_NAME}_VERSION)
|
||||
mark_as_advanced(${PROJECT_NAME}_DIR)
|
||||
|
||||
# installation directories
|
||||
set(PEGTL_INSTALL_INCLUDE_DIR "include" CACHE STRING "The installation include directory")
|
||||
set(PEGTL_INSTALL_DOC_DIR "share/doc/tao/pegtl" CACHE STRING "The installation doc directory")
|
||||
set(PEGTL_INSTALL_CMAKE_DIR "share/pegtl/cmake" CACHE STRING "The installation cmake directory")
|
||||
|
||||
# define a header-only library
|
||||
add_library(pegtl INTERFACE)
|
||||
add_library(taocpp::pegtl ALIAS pegtl)
|
||||
target_include_directories(pegtl INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:${PEGTL_INSTALL_INCLUDE_DIR}>
|
||||
)
|
||||
|
||||
target_link_libraries(pegtl INTERFACE filesystem)
|
||||
|
||||
# require C++17
|
||||
target_compile_features(pegtl INTERFACE cxx_std_17)
|
||||
|
||||
option(PEGTL_USE_BOOST_FILESYSTEM "Override the auto-detection of std::filesystem and use Boost.Filesystem" OFF)
|
||||
|
||||
# Try compiling a test program with std::filesystem or one of its alternatives
|
||||
function(check_filesystem_impl FILESYSTEM_HEADER FILESYSTEM_NAMESPACE OPTIONAL_LIBS OUT_RESULT)
|
||||
set(TEST_FILE "test_${OUT_RESULT}.cpp")
|
||||
configure_file(.cmake/test_filesystem.cpp.in ${TEST_FILE} @ONLY)
|
||||
|
||||
try_compile(TEST_RESULT
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${TEST_FILE}
|
||||
CXX_STANDARD 17)
|
||||
|
||||
if(NOT TEST_RESULT)
|
||||
# Retry with each of the optional libraries
|
||||
foreach(OPTIONAL_LIB IN LISTS OPTIONAL_LIBS)
|
||||
try_compile(TEST_RESULT
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/${TEST_FILE}
|
||||
LINK_LIBRARIES ${OPTIONAL_LIB}
|
||||
CXX_STANDARD 17)
|
||||
|
||||
if(TEST_RESULT)
|
||||
# Looks like the optional library was required, go ahead and add it to the link options.
|
||||
message(STATUS "Adding ${OPTIONAL_LIB} to the PEGTL to build with ${FILESYSTEM_NAMESPACE}.")
|
||||
target_link_libraries(${PROJECT_NAME} INTERFACE ${OPTIONAL_LIB})
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
set(${OUT_RESULT} ${TEST_RESULT} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# testing
|
||||
option(PEGTL_BUILD_TESTS "Build test programs" ${PEGTL_IS_MAIN_PROJECT})
|
||||
if(PEGTL_BUILD_TESTS)
|
||||
enable_testing()
|
||||
add_subdirectory(src/test/pegtl)
|
||||
endif()
|
||||
|
||||
# examples
|
||||
option(PEGTL_BUILD_EXAMPLES "Build example programs" ${PEGTL_IS_MAIN_PROJECT})
|
||||
if(PEGTL_BUILD_EXAMPLES)
|
||||
add_subdirectory(src/example/pegtl)
|
||||
endif()
|
||||
|
||||
# Make package findable
|
||||
configure_file(.cmake/pegtl-config.cmake.in pegtl-config.cmake @ONLY)
|
||||
|
||||
# Ignore pointer width differences since this is a header-only library
|
||||
unset(CMAKE_SIZEOF_VOID_P)
|
||||
|
||||
# Enable version checks in find_package
|
||||
include(CMakePackageConfigHelpers)
|
||||
write_basic_package_version_file(pegtl-config-version.cmake COMPATIBILITY SameMajorVersion)
|
||||
|
||||
# install and export target
|
|
@ -1,21 +0,0 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2007-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -1,91 +0,0 @@
|
|||
# The Art of C++
|
||||
# Copyright (c) 2014-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
# Please see LICENSE for license or visit https://github.com/taocpp/PEGTL
|
||||
|
||||
.SUFFIXES:
|
||||
.SECONDARY:
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
UNAME_S := $(OS)
|
||||
ifeq ($(shell gcc -dumpmachine),mingw32)
|
||||
MINGW_CXXFLAGS = -U__STRICT_ANSI__
|
||||
endif
|
||||
else
|
||||
UNAME_S := $(shell uname -s)
|
||||
endif
|
||||
|
||||
# For Darwin (Mac OS X / macOS) we assume that the default compiler
|
||||
# clang++ is used; when $(CXX) is some version of g++, then
|
||||
# $(CXXSTD) has to be set to -std=c++17 (or newer) so
|
||||
# that -stdlib=libc++ is not automatically added.
|
||||
|
||||
ifeq ($(CXXSTD),)
|
||||
CXXSTD := -std=c++17
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
CXXSTD += -stdlib=libc++
|
||||
endif
|
||||
endif
|
||||
|
||||
# Ensure strict standard compliance and no warnings, can be
|
||||
# changed if desired.
|
||||
|
||||
CPPFLAGS ?= -pedantic
|
||||
CXXFLAGS ?= -Wall -Wextra -Wshadow -Werror -O3 $(MINGW_CXXFLAGS)
|
||||
|
||||
HEADERS := $(shell find include -name '*.hpp')
|
||||
SOURCES := $(shell find src -name '*.cpp')
|
||||
DEPENDS := $(SOURCES:%.cpp=build/%.d)
|
||||
BINARIES := $(SOURCES:%.cpp=build/%)
|
||||
|
||||
UNIT_TESTS := $(filter build/src/test/%,$(BINARIES))
|
||||
|
||||
.PHONY: all
|
||||
all: compile check
|
||||
|
||||
.PHONY: compile
|
||||
compile: $(BINARIES)
|
||||
|
||||
.PHONY: check
|
||||
check: $(UNIT_TESTS)
|
||||
@set -e; for T in $(UNIT_TESTS); do echo $$T; $$T > /dev/null; done
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@rm -rf build/*
|
||||
@find . -name '*~' -delete
|
||||
|
||||
build/%.d: %.cpp Makefile
|
||||
@mkdir -p $(@D)
|
||||
$(CXX) $(CXXSTD) -Iinclude $(CPPFLAGS) -MM -MQ $@ $< -o $@
|
||||
|
||||
build/%: %.cpp build/%.d
|
||||
$(CXX) $(CXXSTD) -Iinclude $(CPPFLAGS) $(CXXFLAGS) $< $(LDFLAGS) -o $@
|
||||
|
||||
.PHONY: amalgamate
|
||||
amalgamate: build/amalgamated/pegtl.hpp
|
||||
|
||||
build/amalgamated/pegtl.hpp: $(HEADERS)
|
||||
@mkdir -p $(@D)
|
||||
@rm -rf build/include
|
||||
@cp -a include build/
|
||||
@rm -rf build/include/tao/pegtl/contrib/icu
|
||||
@sed -i -e 's%^#%//#%g' $$(find build/include -name '*.hpp')
|
||||
@sed -i -e 's%^//#include "%#include "%g' $$(find build/include -name '*.hpp')
|
||||
@for i in $$(find build/include -name '*.hpp'); do echo "#pragma once" >tmp.out; echo "#line 1" >>tmp.out; cat $$i >>tmp.out; mv tmp.out $$i; done
|
||||
@echo '#include "tao/pegtl.hpp"' >build/include/amalgamated.hpp
|
||||
@( cd build/include ; for i in tao/pegtl/contrib/*.hpp; do echo "#include \"$$i\""; done ) >>build/include/amalgamated.hpp
|
||||
@echo -e "/*\n\nWelcome to the Parsing Expression Grammar Template Library (PEGTL)." >$@
|
||||
@echo -e "See https://github.com/taocpp/PEGTL/ for more information, documentation, etc.\n" >>$@
|
||||
@echo -e "The library is licensed as follows:\n" >>$@
|
||||
@cat LICENSE >>$@
|
||||
@echo -e "\n*/\n" >>$@
|
||||
@( cd build/include ; g++ -E -C -nostdinc amalgamated.hpp ) >>$@
|
||||
@sed -i -e 's%^//#%#%g' $@
|
||||
@sed -i -e 's%^# \([0-9]* "[^"]*"\).*%#line \1%g' $@
|
||||
@sed -i -e 's%^// Copyright.*%%g' $@
|
||||
@sed -i -e 's%^// Please.*%%g' $@
|
||||
@echo "Generated/updated $@ successfully."
|
||||
|
||||
ifeq ($(findstring $(MAKECMDGOALS),clean),)
|
||||
-include $(DEPENDS)
|
||||
endif
|
|
@ -1,151 +0,0 @@
|
|||
# Welcome to the PEGTL
|
||||
|
||||
[![Windows](https://github.com/taocpp/PEGTL/actions/workflows/windows.yml/badge.svg?branch=3.x)](https://github.com/taocpp/PEGTL/actions/workflows/windows.yml)
|
||||
[![macOS](https://github.com/taocpp/PEGTL/actions/workflows/macos.yml/badge.svg?branch=3.x)](https://github.com/taocpp/PEGTL/actions/workflows/macos.yml)
|
||||
[![Linux](https://github.com/taocpp/PEGTL/actions/workflows/linux.yml/badge.svg?branch=3.x)](https://github.com/taocpp/PEGTL/actions/workflows/linux.yml)
|
||||
[![Android](https://github.com/taocpp/PEGTL/actions/workflows/android.yml/badge.svg?branch=3.x)](https://github.com/taocpp/PEGTL/actions/workflows/android.yml)
|
||||
<br>
|
||||
[![clang-analyze](https://github.com/taocpp/PEGTL/actions/workflows/clang-analyze.yml/badge.svg?branch=3.x)](https://github.com/taocpp/PEGTL/actions/workflows/clang-analyze.yml)
|
||||
[![clang-tidy](https://github.com/taocpp/PEGTL/actions/workflows/clang-tidy.yml/badge.svg?branch=3.x)](https://github.com/taocpp/PEGTL/actions/workflows/clang-tidy.yml)
|
||||
[![Sanitizer](https://github.com/taocpp/PEGTL/actions/workflows/sanitizer.yml/badge.svg?branch=3.x)](https://github.com/taocpp/PEGTL/actions/workflows/sanitizer.yml)
|
||||
[![CodeQL](https://github.com/taocpp/PEGTL/actions/workflows/codeql-analysis.yml/badge.svg?branch=3.x)](https://github.com/taocpp/PEGTL/actions/workflows/codeql-analysis.yml)
|
||||
[![Codecov](https://codecov.io/gh/taocpp/PEGTL/branch/3.x/graph/badge.svg?token=ykWa8RRdyk)](https://codecov.io/gh/taocpp/PEGTL)
|
||||
|
||||
The Parsing Expression Grammar Template Library (PEGTL) is a zero-dependency C++ header-only parser combinator library for creating parsers according to a [Parsing Expression Grammar](http://en.wikipedia.org/wiki/Parsing_expression_grammar) (PEG).
|
||||
|
||||
## Documentation
|
||||
|
||||
* [Changelog](doc/Changelog.md)
|
||||
* [Version 3.x](doc/README.md) (requires C++17)
|
||||
* [Version 2.x](https://github.com/taocpp/PEGTL/blob/2.x/doc/README.md) (requires C++11)
|
||||
* [Version 1.x](https://github.com/taocpp/PEGTL/blob/1.x/doc/README.md) (requires C++11)
|
||||
|
||||
## Contact
|
||||
|
||||
<a href="https://discord.gg/VQYkppcgqN"><img align="right" src="https://discordapp.com/api/guilds/790164930083028993/embed.png?style=banner2" alt="Join us on Discord"></a>
|
||||
|
||||
For questions and suggestions regarding the PEGTL, success or failure stories, and any other kind of feedback, please feel free to join our [Discord](https://discord.gg/VQYkppcgqN) server, open a [discussion](https://github.com/taocpp/PEGTL/discussions), an [issue](https://github.com/taocpp/PEGTL/issues) or a [pull request](https://github.com/taocpp/PEGTL/pulls) on GitHub or contact the authors at `taocpp(at)icemx.net`.
|
||||
|
||||
## Introduction
|
||||
|
||||
Grammars are written as regular C++ code, created with template programming (not template meta programming), i.e. nested template instantiations that naturally correspond to the inductive definition of PEGs (and other parser-combinator approaches).
|
||||
|
||||
A comprehensive set of [parser rules](doc/Rule-Reference.md) that can be combined and extended by the user is included, as are mechanisms for debugging grammars, and for attaching user-defined [actions](doc/Actions-and-States.md) to grammar rules.
|
||||
Here is an example of how a PEG grammar rule is implemented as C++ class with the PEGTL.
|
||||
|
||||
```c++
|
||||
// PEG rule for integers consisting of a non-empty
|
||||
// sequence of digits with an optional sign:
|
||||
|
||||
// sign ::= '+' / '-'
|
||||
// integer ::= sign? digit+
|
||||
|
||||
// The same parsing rule implemented with the PEGTL:
|
||||
|
||||
using namespace tao::pegtl;
|
||||
|
||||
struct sign : one< '+', '-' > {};
|
||||
struct integer : seq< opt< sign >, plus< digit > > {};
|
||||
```
|
||||
|
||||
PEGs are superficially similar to Context-Free Grammars (CFGs), however the more deterministic nature of PEGs gives rise to some very important differences.
|
||||
The included [grammar analysis](doc/Grammar-Analysis.md) finds several typical errors in PEGs, including left recursion.
|
||||
|
||||
## Design
|
||||
|
||||
The PEGTL is designed to be "lean and mean", the core library consists of approximately 6000 lines of code.
|
||||
Emphasis is on simplicity and efficiency, preferring a well-tuned simple approach over complicated optimisations.
|
||||
|
||||
The PEGTL is mostly concerned with parsing combinators and grammar rules, and with giving the user of the library (the possibility of) full control over all other aspects of a parsing run.
|
||||
Whether/which actions are taken, and whether/which data structures are created during a parsing run, is entirely up to the user.
|
||||
|
||||
Included are some [examples](doc/Contrib-and-Examples.md#examples) for typical situation like unescaping escape sequences in strings, building a generic [JSON](http://www.json.org/) data structure, and on-the-fly evaluation of arithmetic expressions.
|
||||
|
||||
Through the use of template programming and template specialisations it is possible to write a grammar once, and use it in multiple ways with different (semantic) actions in different (or the same) parsing runs.
|
||||
|
||||
With the PEG formalism, the separation into lexer and parser stages is usually dropped -- everything is done in a single grammar.
|
||||
The rules are expressed in C++ as template instantiations, and it is the compiler's task to optimise PEGTL grammars.
|
||||
|
||||
## Status
|
||||
|
||||
Each commit is automatically tested with multiple architectures, operating systems, compilers, and versions thereof.
|
||||
|
||||
Each commit is checked with GCC's and Clang's [sanitizers](https://github.com/google/sanitizers), Clang's [Static Analyzer](https://clang-analyzer.llvm.org/), and [`clang-tidy`](http://clang.llvm.org/extra/clang-tidy/).
|
||||
Additionally, we use [CodeQL](https://securitylab.github.com/tools/codeql) to scan for (security) issues.
|
||||
|
||||
Code coverage is automatically measured and the unit tests cover 100% of the core library code (for releases).
|
||||
|
||||
[Releases](https://github.com/taocpp/PEGTL/releases) are done in accordance with [Semantic Versioning](http://semver.org/).
|
||||
Incompatible API changes are *only* allowed to occur between major versions.
|
||||
|
||||
## Thank You
|
||||
|
||||
In appreciation of all contributions here are the people that have [directly contributed](https://github.com/taocpp/PEGTL/graphs/contributors) to the PEGTL and/or its development.
|
||||
|
||||
[<img alt="amphaal" src="https://avatars.githubusercontent.com/u/13903151" width="120">](https://github.com/amphaal)
|
||||
[<img alt="anand-bala" src="https://avatars.githubusercontent.com/u/7420072" width="120">](https://github.com/anand-bala)
|
||||
[<img alt="andoma" src="https://avatars.githubusercontent.com/u/216384" width="120">](https://github.com/andoma)
|
||||
[<img alt="barbieri" src="https://avatars.githubusercontent.com/u/1838" width="120">](https://github.com/barbieri)
|
||||
[<img alt="bjoe" src="https://avatars.githubusercontent.com/u/727911" width="120">](https://github.com/bjoe)
|
||||
[<img alt="bwagner" src="https://avatars.githubusercontent.com/u/447049" width="120">](https://github.com/bwagner)
|
||||
[<img alt="cdiggins" src="https://avatars.githubusercontent.com/u/1759994" width="120">](https://github.com/cdiggins)
|
||||
[<img alt="clausklein" src="https://avatars.githubusercontent.com/u/1833050" width="120">](https://github.com/clausklein)
|
||||
[<img alt="delpinux" src="https://avatars.githubusercontent.com/u/35096584" width="120">](https://github.com/delpinux)
|
||||
[<img alt="dkopecek" src="https://avatars.githubusercontent.com/u/1353140" width="120">](https://github.com/dkopecek)
|
||||
[<img alt="gene-hightower" src="https://avatars.githubusercontent.com/u/3957811" width="120">](https://github.com/gene-hightower)
|
||||
[<img alt="irrequietus" src="https://avatars.githubusercontent.com/u/231192" width="120">](https://github.com/irrequietus)
|
||||
[<img alt="jedelbo" src="https://avatars.githubusercontent.com/u/572755" width="120">](https://github.com/jedelbo)
|
||||
[<img alt="joelfrederico" src="https://avatars.githubusercontent.com/u/458871" width="120">](https://github.com/joelfrederico)
|
||||
[<img alt="johelegp" src="https://avatars.githubusercontent.com/u/21071787" width="120">](https://github.com/johelegp)
|
||||
[<img alt="jovermann" src="https://avatars.githubusercontent.com/u/6087443" width="120">](https://github.com/jovermann)
|
||||
[<img alt="jubnzv" src="https://avatars.githubusercontent.com/u/12023585" width="120">](https://github.com/jubnzv)
|
||||
[<img alt="kelvinhammond" src="https://avatars.githubusercontent.com/u/1824682" width="120">](https://github.com/kelvinhammond)
|
||||
[<img alt="kneth" src="https://avatars.githubusercontent.com/u/1225363" width="120">](https://github.com/kneth)
|
||||
[<img alt="kuzmas" src="https://avatars.githubusercontent.com/u/1858553" width="120">](https://github.com/kuzmas)
|
||||
[<img alt="lambdafu" src="https://avatars.githubusercontent.com/u/1138455" width="120">](https://github.com/lambdafu)
|
||||
[<img alt="lichray" src="https://avatars.githubusercontent.com/u/433009" width="120">](https://github.com/lichray)
|
||||
[<img alt="michael-brade" src="https://avatars.githubusercontent.com/u/8768950" width="120">](https://github.com/michael-brade)
|
||||
[<img alt="mkrupcale" src="https://avatars.githubusercontent.com/u/13936020" width="120">](https://github.com/mkrupcale)
|
||||
[<img alt="newproggie" src="https://avatars.githubusercontent.com/u/162319" width="120">](https://github.com/newproggie)
|
||||
[<img alt="obiwahn" src="https://avatars.githubusercontent.com/u/741109" width="120">](https://github.com/obiwahn)
|
||||
[<img alt="ohanar" src="https://avatars.githubusercontent.com/u/1442822" width="120">](https://github.com/ohanar)
|
||||
[<img alt="pauloscustodio" src="https://avatars.githubusercontent.com/u/70773" width="120">](https://github.com/pauloscustodio)
|
||||
[<img alt="pleroux0" src="https://avatars.githubusercontent.com/u/39619854" width="120">](https://github.com/pleroux0)
|
||||
[<img alt="quadfault" src="https://avatars.githubusercontent.com/u/30195320" width="120">](https://github.com/quadfault)
|
||||
[<img alt="quarticcat" src="https://avatars.githubusercontent.com/u/70888415" width="120">](https://github.com/quarticcat)
|
||||
[<img alt="ras0219" src="https://avatars.githubusercontent.com/u/533828" width="120">](https://github.com/ras0219)
|
||||
[<img alt="redmercury" src="https://avatars.githubusercontent.com/u/4424222" width="120">](https://github.com/redmercury)
|
||||
[<img alt="robertcampion" src="https://avatars.githubusercontent.com/u/4220569" width="120">](https://github.com/robertcampion)
|
||||
[<img alt="samhocevar" src="https://avatars.githubusercontent.com/u/245089" width="120">](https://github.com/samhocevar)
|
||||
[<img alt="sanssecours" src="https://avatars.githubusercontent.com/u/691989" width="120">](https://github.com/sanssecours)
|
||||
[<img alt="sgbeal" src="https://avatars.githubusercontent.com/u/235303" width="120">](https://github.com/sgbeal)
|
||||
[<img alt="skyrich62" src="https://avatars.githubusercontent.com/u/23705081" width="120">](https://github.com/skyrich62)
|
||||
[<img alt="studoot" src="https://avatars.githubusercontent.com/u/799344" width="120">](https://github.com/studoot)
|
||||
[<img alt="svenjo" src="https://avatars.githubusercontent.com/u/1538181" width="120">](https://github.com/svenjo)
|
||||
[<img alt="wickedmic" src="https://avatars.githubusercontent.com/u/12001183" width="120">](https://github.com/wickedmic)
|
||||
[<img alt="wravery" src="https://avatars.githubusercontent.com/u/6502881" width="120">](https://github.com/wravery)
|
||||
[<img alt="zhihaoy" src="https://avatars.githubusercontent.com/u/43971430" width="120">](https://github.com/zhihaoy)
|
||||
|
||||
## The Art of C++
|
||||
|
||||
The PEGTL is part of [The Art of C++](https://taocpp.github.io/).
|
||||
|
||||
[<img alt="colinh" src="https://avatars.githubusercontent.com/u/113184" width="120">](https://github.com/colinh)
|
||||
[<img alt="d-frey" src="https://avatars.githubusercontent.com/u/3956325" width="120">](https://github.com/d-frey)
|
||||
[<img alt="uilianries" src="https://avatars.githubusercontent.com/u/4870173" width="120">](https://github.com/uilianries)
|
||||
|
||||
## License
|
||||
|
||||
<a href="https://opensource.org/licenses/MIT"><img align="right" src="https://opensource.org/files/OSIApproved.png" width="150" hspace="20" alt="Open Source Initiative"></a>
|
||||
|
||||
The PEGTL is certified [Open Source](http://www.opensource.org/docs/definition.html) software.
|
||||
It may be used for any purpose, including commercial purposes, at absolutely no cost.
|
||||
It is distributed under the terms of the [MIT license](http://www.opensource.org/licenses/mit-license.html) reproduced here.
|
||||
|
||||
> Copyright (c) 2007-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
>
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,48 +0,0 @@
|
|||
// Copyright (c) 2014-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_HPP
|
||||
#define TAO_PEGTL_HPP
|
||||
|
||||
#include "pegtl/config.hpp"
|
||||
#include "pegtl/demangle.hpp"
|
||||
#include "pegtl/parse.hpp"
|
||||
#include "pegtl/version.hpp"
|
||||
|
||||
#include "pegtl/ascii.hpp"
|
||||
#include "pegtl/rules.hpp"
|
||||
#include "pegtl/utf8.hpp"
|
||||
|
||||
#include "pegtl/argv_input.hpp"
|
||||
#include "pegtl/buffer_input.hpp"
|
||||
#include "pegtl/cstream_input.hpp"
|
||||
#include "pegtl/istream_input.hpp"
|
||||
#include "pegtl/memory_input.hpp"
|
||||
#include "pegtl/read_input.hpp"
|
||||
#include "pegtl/string_input.hpp"
|
||||
|
||||
// This has to be included *after* the above inputs,
|
||||
// otherwise the amalgamated header will not work!
|
||||
#include "pegtl/file_input.hpp"
|
||||
|
||||
#include "pegtl/change_action.hpp"
|
||||
#include "pegtl/change_action_and_state.hpp"
|
||||
#include "pegtl/change_action_and_states.hpp"
|
||||
#include "pegtl/change_control.hpp"
|
||||
#include "pegtl/change_state.hpp"
|
||||
#include "pegtl/change_states.hpp"
|
||||
|
||||
#include "pegtl/disable_action.hpp"
|
||||
#include "pegtl/enable_action.hpp"
|
||||
|
||||
#include "pegtl/discard_input.hpp"
|
||||
#include "pegtl/discard_input_on_failure.hpp"
|
||||
#include "pegtl/discard_input_on_success.hpp"
|
||||
|
||||
#include "pegtl/visit.hpp"
|
||||
|
||||
#if defined( __cpp_exceptions )
|
||||
#include "pegtl/must_if.hpp"
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,19 +0,0 @@
|
|||
// Copyright (c) 2014-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_APPLY_MODE_HPP
|
||||
#define TAO_PEGTL_APPLY_MODE_HPP
|
||||
|
||||
#include "config.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
enum class apply_mode : bool
|
||||
{
|
||||
action = true,
|
||||
nothing = false
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,49 +0,0 @@
|
|||
// Copyright (c) 2017-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_ARGV_INPUT_HPP
|
||||
#define TAO_PEGTL_ARGV_INPUT_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "config.hpp"
|
||||
#include "eol.hpp"
|
||||
#include "memory_input.hpp"
|
||||
#include "tracking_mode.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
[[nodiscard]] inline std::string make_argv_source( const std::size_t argn )
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << "argv[" << argn << ']';
|
||||
return std::move( oss ).str();
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf >
|
||||
struct argv_input
|
||||
: memory_input< P, Eol >
|
||||
{
|
||||
template< typename T >
|
||||
argv_input( char** argv, const std::size_t argn, T&& in_source )
|
||||
: memory_input< P, Eol >( static_cast< const char* >( argv[ argn ] ), std::forward< T >( in_source ) )
|
||||
{}
|
||||
|
||||
argv_input( char** argv, const std::size_t argn )
|
||||
: argv_input( argv, argn, internal::make_argv_source( argn ) )
|
||||
{}
|
||||
};
|
||||
|
||||
template< typename... Ts >
|
||||
argv_input( Ts&&... ) -> argv_input<>;
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,54 +0,0 @@
|
|||
// Copyright (c) 2014-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_ASCII_HPP
|
||||
#define TAO_PEGTL_ASCII_HPP
|
||||
|
||||
#include "config.hpp"
|
||||
|
||||
#include "internal/result_on_found.hpp"
|
||||
#include "internal/rules.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
inline namespace ascii
|
||||
{
|
||||
// clang-format off
|
||||
struct alnum : internal::ranges< internal::peek_char, 'a', 'z', 'A', 'Z', '0', '9' > {};
|
||||
struct alpha : internal::ranges< internal::peek_char, 'a', 'z', 'A', 'Z' > {};
|
||||
struct any : internal::any< internal::peek_char > {};
|
||||
struct blank : internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\t' > {};
|
||||
struct digit : internal::range< internal::result_on_found::success, internal::peek_char, '0', '9' > {};
|
||||
struct ellipsis : internal::string< '.', '.', '.' > {};
|
||||
template< char... Cs > struct forty_two : internal::rep< 42, internal::one< internal::result_on_found::success, internal::peek_char, Cs... > > {};
|
||||
struct identifier_first : internal::identifier_first {};
|
||||
struct identifier_other : internal::identifier_other {};
|
||||
struct identifier : internal::identifier {};
|
||||
template< char... Cs > struct istring : internal::istring< Cs... > {};
|
||||
template< char... Cs > struct keyword : internal::seq< internal::string< Cs... >, internal::not_at< internal::identifier_other > > { static_assert( sizeof...( Cs ) > 0 ); };
|
||||
struct lower : internal::range< internal::result_on_found::success, internal::peek_char, 'a', 'z' > {};
|
||||
template< char... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_char, Cs... > {};
|
||||
template< char Lo, char Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_char, Lo, Hi > {};
|
||||
struct nul : internal::one< internal::result_on_found::success, internal::peek_char, char( 0 ) > {};
|
||||
struct odigit : internal::range< internal::result_on_found::success, internal::peek_char, '0', '7' > {};
|
||||
template< char... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_char, Cs... > {};
|
||||
struct print : internal::range< internal::result_on_found::success, internal::peek_char, char( 32 ), char( 126 ) > {};
|
||||
template< char Lo, char Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_char, Lo, Hi > {};
|
||||
template< char... Cs > struct ranges : internal::ranges< internal::peek_char, Cs... > {};
|
||||
struct seven : internal::range< internal::result_on_found::success, internal::peek_char, char( 0 ), char( 127 ) > {};
|
||||
struct shebang : internal::seq< internal::string< '#', '!' >, internal::until< internal::eolf > > {};
|
||||
struct space : internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\n', '\r', '\t', '\v', '\f' > {};
|
||||
template< char... Cs > struct string : internal::string< Cs... > {};
|
||||
template< char C > struct three : internal::string< C, C, C > {};
|
||||
template< char C > struct two : internal::string< C, C > {};
|
||||
struct upper : internal::range< internal::result_on_found::success, internal::peek_char, 'A', 'Z' > {};
|
||||
struct xdigit : internal::ranges< internal::peek_char, '0', '9', 'a', 'f', 'A', 'F' > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace ascii
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#include "internal/pegtl_string.hpp"
|
||||
|
||||
#endif
|
|
@ -1,226 +0,0 @@
|
|||
// Copyright (c) 2016-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_BUFFER_INPUT_HPP
|
||||
#define TAO_PEGTL_BUFFER_INPUT_HPP
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#if defined( __cpp_exceptions )
|
||||
#include <stdexcept>
|
||||
#else
|
||||
#include <cstdio>
|
||||
#include <exception>
|
||||
#endif
|
||||
|
||||
#include "config.hpp"
|
||||
#include "eol.hpp"
|
||||
#include "memory_input.hpp"
|
||||
#include "position.hpp"
|
||||
#include "tracking_mode.hpp"
|
||||
|
||||
#include "internal/action_input.hpp"
|
||||
#include "internal/bump.hpp"
|
||||
#include "internal/iterator.hpp"
|
||||
#include "internal/marker.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
template< typename Reader, typename Eol = eol::lf_crlf, typename Source = std::string, std::size_t Chunk = 64 >
|
||||
class buffer_input
|
||||
{
|
||||
public:
|
||||
using reader_t = Reader;
|
||||
|
||||
using eol_t = Eol;
|
||||
using source_t = Source;
|
||||
|
||||
using iterator_t = internal::iterator;
|
||||
|
||||
using action_t = internal::action_input< buffer_input >;
|
||||
|
||||
static constexpr std::size_t chunk_size = Chunk;
|
||||
static constexpr tracking_mode tracking_mode_v = tracking_mode::eager;
|
||||
|
||||
template< typename T, typename... As >
|
||||
buffer_input( T&& in_source, const std::size_t maximum, As&&... as )
|
||||
: m_reader( std::forward< As >( as )... ),
|
||||
m_maximum( maximum + Chunk ),
|
||||
m_buffer( new char[ maximum + Chunk ] ),
|
||||
m_current( m_buffer.get() ),
|
||||
m_end( m_buffer.get() ),
|
||||
m_source( std::forward< T >( in_source ) )
|
||||
{
|
||||
static_assert( Chunk != 0, "zero chunk size not implemented" );
|
||||
assert( m_maximum > maximum ); // Catches overflow; change to >= when zero chunk size is implemented.
|
||||
}
|
||||
|
||||
buffer_input( const buffer_input& ) = delete;
|
||||
buffer_input( buffer_input&& ) = delete;
|
||||
|
||||
~buffer_input() = default;
|
||||
|
||||
buffer_input& operator=( const buffer_input& ) = delete;
|
||||
buffer_input& operator=( buffer_input&& ) = delete;
|
||||
|
||||
[[nodiscard]] bool empty()
|
||||
{
|
||||
require( 1 );
|
||||
return m_current.data == m_end;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::size_t size( const std::size_t amount )
|
||||
{
|
||||
require( amount );
|
||||
return buffer_occupied();
|
||||
}
|
||||
|
||||
[[nodiscard]] const char* current() const noexcept
|
||||
{
|
||||
return m_current.data;
|
||||
}
|
||||
|
||||
[[nodiscard]] const char* end( const std::size_t amount )
|
||||
{
|
||||
require( amount );
|
||||
return m_end;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::size_t byte() const noexcept
|
||||
{
|
||||
return m_current.byte;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::size_t line() const noexcept
|
||||
{
|
||||
return m_current.line;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::size_t column() const noexcept
|
||||
{
|
||||
return m_current.column;
|
||||
}
|
||||
|
||||
[[nodiscard]] const Source& source() const noexcept
|
||||
{
|
||||
return m_source;
|
||||
}
|
||||
|
||||
[[nodiscard]] char peek_char( const std::size_t offset = 0 ) const noexcept
|
||||
{
|
||||
return m_current.data[ offset ];
|
||||
}
|
||||
|
||||
[[nodiscard]] std::uint8_t peek_uint8( const std::size_t offset = 0 ) const noexcept
|
||||
{
|
||||
return static_cast< std::uint8_t >( peek_char( offset ) );
|
||||
}
|
||||
|
||||
void bump( const std::size_t in_count = 1 ) noexcept
|
||||
{
|
||||
internal::bump( m_current, in_count, Eol::ch );
|
||||
}
|
||||
|
||||
void bump_in_this_line( const std::size_t in_count = 1 ) noexcept
|
||||
{
|
||||
internal::bump_in_this_line( m_current, in_count );
|
||||
}
|
||||
|
||||
void bump_to_next_line( const std::size_t in_count = 1 ) noexcept
|
||||
{
|
||||
internal::bump_to_next_line( m_current, in_count );
|
||||
}
|
||||
|
||||
void discard() noexcept
|
||||
{
|
||||
if( m_current.data > m_buffer.get() + Chunk ) {
|
||||
const auto s = m_end - m_current.data;
|
||||
std::memmove( m_buffer.get(), m_current.data, s );
|
||||
m_current.data = m_buffer.get();
|
||||
m_end = m_buffer.get() + s;
|
||||
}
|
||||
}
|
||||
|
||||
void require( const std::size_t amount )
|
||||
{
|
||||
if( m_current.data + amount <= m_end ) {
|
||||
return;
|
||||
}
|
||||
if( m_current.data + amount > m_buffer.get() + m_maximum ) {
|
||||
#if defined( __cpp_exceptions )
|
||||
throw std::overflow_error( "require() beyond end of buffer" );
|
||||
#else
|
||||
std::fputs( "overflow error: require() beyond end of buffer\n", stderr );
|
||||
std::terminate();
|
||||
#endif
|
||||
}
|
||||
if( const auto r = m_reader( m_end, ( std::min )( buffer_free_after_end(), ( std::max )( amount - buffer_occupied(), Chunk ) ) ) ) {
|
||||
m_end += r;
|
||||
}
|
||||
}
|
||||
|
||||
template< rewind_mode M >
|
||||
[[nodiscard]] internal::marker< iterator_t, M > mark() noexcept
|
||||
{
|
||||
return internal::marker< iterator_t, M >( m_current );
|
||||
}
|
||||
|
||||
[[nodiscard]] TAO_PEGTL_NAMESPACE::position position( const iterator_t& it ) const
|
||||
{
|
||||
return TAO_PEGTL_NAMESPACE::position( it, m_source );
|
||||
}
|
||||
|
||||
[[nodiscard]] TAO_PEGTL_NAMESPACE::position position() const
|
||||
{
|
||||
return position( m_current );
|
||||
}
|
||||
|
||||
[[nodiscard]] const iterator_t& iterator() const noexcept
|
||||
{
|
||||
return m_current;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::size_t buffer_capacity() const noexcept
|
||||
{
|
||||
return m_maximum;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::size_t buffer_occupied() const noexcept
|
||||
{
|
||||
assert( m_end >= m_current.data );
|
||||
return std::size_t( m_end - m_current.data );
|
||||
}
|
||||
|
||||
[[nodiscard]] std::size_t buffer_free_before_current() const noexcept
|
||||
{
|
||||
assert( m_current.data >= m_buffer.get() );
|
||||
return std::size_t( m_current.data - m_buffer.get() );
|
||||
}
|
||||
|
||||
[[nodiscard]] std::size_t buffer_free_after_end() const noexcept
|
||||
{
|
||||
assert( m_buffer.get() + m_maximum >= m_end );
|
||||
return std::size_t( m_buffer.get() + m_maximum - m_end );
|
||||
}
|
||||
|
||||
private:
|
||||
Reader m_reader;
|
||||
std::size_t m_maximum;
|
||||
std::unique_ptr< char[] > m_buffer;
|
||||
iterator_t m_current;
|
||||
char* m_end;
|
||||
const Source m_source;
|
||||
|
||||
public:
|
||||
std::size_t private_depth = 0;
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,38 +0,0 @@
|
|||
// Copyright (c) 2019-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CHANGE_ACTION_HPP
|
||||
#define TAO_PEGTL_CHANGE_ACTION_HPP
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "apply_mode.hpp"
|
||||
#include "config.hpp"
|
||||
#include "nothing.hpp"
|
||||
#include "rewind_mode.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
template< template< typename... > class NewAction >
|
||||
struct change_action
|
||||
: maybe_nothing
|
||||
{
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
static_assert( !std::is_same_v< Action< void >, NewAction< void > >, "old and new action class templates are identical" );
|
||||
return Control< Rule >::template match< A, M, NewAction, Control >( in, st... );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,71 +0,0 @@
|
|||
// Copyright (c) 2019-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CHANGE_ACTION_AND_STATE_HPP
|
||||
#define TAO_PEGTL_CHANGE_ACTION_AND_STATE_HPP
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "apply_mode.hpp"
|
||||
#include "config.hpp"
|
||||
#include "match.hpp"
|
||||
#include "nothing.hpp"
|
||||
#include "rewind_mode.hpp"
|
||||
|
||||
#include "internal/dependent_false.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
template< template< typename... > class NewAction, typename NewState >
|
||||
struct change_action_and_state
|
||||
: maybe_nothing
|
||||
{
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
static_assert( !std::is_same_v< Action< void >, NewAction< void > >, "old and new action class templates are identical" );
|
||||
|
||||
if constexpr( std::is_constructible_v< NewState, const ParseInput&, States... > ) {
|
||||
NewState s( static_cast< const ParseInput& >( in ), st... );
|
||||
if( Control< Rule >::template match< A, M, NewAction, Control >( in, s ) ) {
|
||||
if constexpr( A == apply_mode::action ) {
|
||||
Action< Rule >::success( static_cast< const ParseInput& >( in ), s, st... );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if constexpr( std::is_default_constructible_v< NewState > ) {
|
||||
NewState s;
|
||||
if( Control< Rule >::template match< A, M, NewAction, Control >( in, s ) ) {
|
||||
if constexpr( A == apply_mode::action ) {
|
||||
Action< Rule >::success( static_cast< const ParseInput& >( in ), s, st... );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
static_assert( internal::dependent_false< NewState >, "unable to instantiate new state" );
|
||||
}
|
||||
}
|
||||
|
||||
template< typename ParseInput,
|
||||
typename... States >
|
||||
static void success( const ParseInput& in, NewState& s, States&&... st ) noexcept( noexcept( s.success( in, st... ) ) )
|
||||
{
|
||||
s.success( in, st... );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,62 +0,0 @@
|
|||
// Copyright (c) 2019-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CHANGE_ACTION_AND_STATES_HPP
|
||||
#define TAO_PEGTL_CHANGE_ACTION_AND_STATES_HPP
|
||||
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
#include "apply_mode.hpp"
|
||||
#include "config.hpp"
|
||||
#include "match.hpp"
|
||||
#include "nothing.hpp"
|
||||
#include "rewind_mode.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
template< template< typename... > class NewAction, typename... NewStates >
|
||||
struct change_action_and_states
|
||||
: maybe_nothing
|
||||
{
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
std::size_t... Ns,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( std::index_sequence< Ns... > /*unused*/, ParseInput& in, States&&... st )
|
||||
{
|
||||
auto t = std::tie( st... );
|
||||
if( Control< Rule >::template match< A, M, NewAction, Control >( in, std::get< Ns >( t )... ) ) {
|
||||
if constexpr( A == apply_mode::action ) {
|
||||
Action< Rule >::success( static_cast< const ParseInput& >( in ), st... );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
static_assert( !std::is_same_v< Action< void >, NewAction< void > >, "old and new action class templates are identical" );
|
||||
return match< Rule, A, M, Action, Control >( std::index_sequence_for< NewStates... >(), in, NewStates()..., st... );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,36 +0,0 @@
|
|||
// Copyright (c) 2019-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CHANGE_CONTROL_HPP
|
||||
#define TAO_PEGTL_CHANGE_CONTROL_HPP
|
||||
|
||||
#include "apply_mode.hpp"
|
||||
#include "config.hpp"
|
||||
#include "match.hpp"
|
||||
#include "nothing.hpp"
|
||||
#include "rewind_mode.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
template< template< typename... > class NewControl >
|
||||
struct change_control
|
||||
: maybe_nothing
|
||||
{
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
return TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, NewControl >( in, st... );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,69 +0,0 @@
|
|||
// Copyright (c) 2019-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CHANGE_STATE_HPP
|
||||
#define TAO_PEGTL_CHANGE_STATE_HPP
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "apply_mode.hpp"
|
||||
#include "config.hpp"
|
||||
#include "match.hpp"
|
||||
#include "nothing.hpp"
|
||||
#include "rewind_mode.hpp"
|
||||
|
||||
#include "internal/dependent_false.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
template< typename NewState >
|
||||
struct change_state
|
||||
: maybe_nothing
|
||||
{
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
if constexpr( std::is_constructible_v< NewState, const ParseInput&, States... > ) {
|
||||
NewState s( static_cast< const ParseInput& >( in ), st... );
|
||||
if( TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, s ) ) {
|
||||
if constexpr( A == apply_mode::action ) {
|
||||
Action< Rule >::success( static_cast< const ParseInput& >( in ), s, st... );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if constexpr( std::is_default_constructible_v< NewState > ) {
|
||||
NewState s;
|
||||
if( TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, s ) ) {
|
||||
if constexpr( A == apply_mode::action ) {
|
||||
Action< Rule >::success( static_cast< const ParseInput& >( in ), s, st... );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
static_assert( internal::dependent_false< NewState >, "unable to instantiate new state" );
|
||||
}
|
||||
}
|
||||
|
||||
template< typename ParseInput,
|
||||
typename... States >
|
||||
static void success( const ParseInput& in, NewState& s, States&&... st ) noexcept( noexcept( s.success( in, st... ) ) )
|
||||
{
|
||||
s.success( in, st... );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,61 +0,0 @@
|
|||
// Copyright (c) 2019-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CHANGE_STATES_HPP
|
||||
#define TAO_PEGTL_CHANGE_STATES_HPP
|
||||
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
#include "apply_mode.hpp"
|
||||
#include "config.hpp"
|
||||
#include "match.hpp"
|
||||
#include "nothing.hpp"
|
||||
#include "rewind_mode.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
template< typename... NewStates >
|
||||
struct change_states
|
||||
: maybe_nothing
|
||||
{
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
std::size_t... Ns,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( std::index_sequence< Ns... > /*unused*/, ParseInput& in, States&&... st )
|
||||
{
|
||||
auto t = std::tie( st... );
|
||||
if( TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, std::get< Ns >( t )... ) ) {
|
||||
if constexpr( A == apply_mode::action ) {
|
||||
Action< Rule >::success( static_cast< const ParseInput& >( in ), st... );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
return match< Rule, A, M, Action, Control >( std::index_sequence_for< NewStates... >(), in, NewStates()..., st... );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,11 +0,0 @@
|
|||
// Copyright (c) 2017-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONFIG_HPP
|
||||
#define TAO_PEGTL_CONFIG_HPP
|
||||
|
||||
#if !defined( TAO_PEGTL_NAMESPACE )
|
||||
#define TAO_PEGTL_NAMESPACE tao::pegtl
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -1,35 +0,0 @@
|
|||
// Copyright (c) 2014-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_ABNF_HPP
|
||||
#define TAO_PEGTL_CONTRIB_ABNF_HPP
|
||||
|
||||
#include "../config.hpp"
|
||||
#include "../internal/rules.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::abnf
|
||||
{
|
||||
// Core ABNF rules according to RFC 5234, Appendix B
|
||||
|
||||
// clang-format off
|
||||
struct ALPHA : internal::ranges< internal::peek_char, 'a', 'z', 'A', 'Z' > {};
|
||||
struct BIT : internal::one< internal::result_on_found::success, internal::peek_char, '0', '1' > {};
|
||||
struct CHAR : internal::range< internal::result_on_found::success, internal::peek_char, char( 1 ), char( 127 ) > {};
|
||||
struct CR : internal::one< internal::result_on_found::success, internal::peek_char, '\r' > {};
|
||||
struct CRLF : internal::string< '\r', '\n' > {};
|
||||
struct CTL : internal::ranges< internal::peek_char, char( 0 ), char( 31 ), char( 127 ) > {};
|
||||
struct DIGIT : internal::range< internal::result_on_found::success, internal::peek_char, '0', '9' > {};
|
||||
struct DQUOTE : internal::one< internal::result_on_found::success, internal::peek_char, '"' > {};
|
||||
struct HEXDIG : internal::ranges< internal::peek_char, '0', '9', 'a', 'f', 'A', 'F' > {};
|
||||
struct HTAB : internal::one< internal::result_on_found::success, internal::peek_char, '\t' > {};
|
||||
struct LF : internal::one< internal::result_on_found::success, internal::peek_char, '\n' > {};
|
||||
struct LWSP : internal::star< internal::sor< internal::string< '\r', '\n' >, internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\t' > >, internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\t' > > {};
|
||||
struct OCTET : internal::any< internal::peek_char > {};
|
||||
struct SP : internal::one< internal::result_on_found::success, internal::peek_char, ' ' > {};
|
||||
struct VCHAR : internal::range< internal::result_on_found::success, internal::peek_char, char( 33 ), char( 126 ) > {};
|
||||
struct WSP : internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\t' > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::abnf
|
||||
|
||||
#endif
|
|
@ -1,69 +0,0 @@
|
|||
// Copyright (c) 2021-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_ADD_STATE_HPP
|
||||
#define TAO_PEGTL_CONTRIB_ADD_STATE_HPP
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "../apply_mode.hpp"
|
||||
#include "../config.hpp"
|
||||
#include "../match.hpp"
|
||||
#include "../nothing.hpp"
|
||||
#include "../rewind_mode.hpp"
|
||||
|
||||
#include "../internal/dependent_false.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
template< typename AddState >
|
||||
struct add_state
|
||||
: maybe_nothing
|
||||
{
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
if constexpr( std::is_constructible_v< AddState, const ParseInput&, States... > ) {
|
||||
AddState s( static_cast< const ParseInput& >( in ), st... );
|
||||
if( TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, s, st... ) ) {
|
||||
if constexpr( A == apply_mode::action ) {
|
||||
Action< Rule >::success( static_cast< const ParseInput& >( in ), s, st... );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if constexpr( std::is_default_constructible_v< AddState > ) {
|
||||
AddState s;
|
||||
if( TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, s, st... ) ) {
|
||||
if constexpr( A == apply_mode::action ) {
|
||||
Action< Rule >::success( static_cast< const ParseInput& >( in ), s, st... );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
static_assert( internal::dependent_false< AddState >, "unable to instantiate new state" );
|
||||
}
|
||||
}
|
||||
|
||||
template< typename ParseInput,
|
||||
typename... States >
|
||||
static void success( const ParseInput& in, AddState& s, States&&... st ) noexcept( noexcept( s.success( in, st... ) ) )
|
||||
{
|
||||
s.success( in, st... );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,67 +0,0 @@
|
|||
// Copyright (c) 2015-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_ALPHABET_HPP
|
||||
#define TAO_PEGTL_CONTRIB_ALPHABET_HPP
|
||||
|
||||
#include "../config.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::alphabet
|
||||
{
|
||||
static const char a = 'a';
|
||||
static const char b = 'b';
|
||||
static const char c = 'c';
|
||||
static const char d = 'd';
|
||||
static const char e = 'e';
|
||||
static const char f = 'f';
|
||||
static const char g = 'g';
|
||||
static const char h = 'h';
|
||||
static const char i = 'i';
|
||||
static const char j = 'j';
|
||||
static const char k = 'k';
|
||||
static const char l = 'l';
|
||||
static const char m = 'm';
|
||||
static const char n = 'n';
|
||||
static const char o = 'o';
|
||||
static const char p = 'p';
|
||||
static const char q = 'q';
|
||||
static const char r = 'r';
|
||||
static const char s = 's';
|
||||
static const char t = 't';
|
||||
static const char u = 'u';
|
||||
static const char v = 'v';
|
||||
static const char w = 'w';
|
||||
static const char x = 'x';
|
||||
static const char y = 'y';
|
||||
static const char z = 'z';
|
||||
|
||||
static const char A = 'A'; // NOLINT(readability-identifier-naming)
|
||||
static const char B = 'B'; // NOLINT(readability-identifier-naming)
|
||||
static const char C = 'C'; // NOLINT(readability-identifier-naming)
|
||||
static const char D = 'D'; // NOLINT(readability-identifier-naming)
|
||||
static const char E = 'E'; // NOLINT(readability-identifier-naming)
|
||||
static const char F = 'F'; // NOLINT(readability-identifier-naming)
|
||||
static const char G = 'G'; // NOLINT(readability-identifier-naming)
|
||||
static const char H = 'H'; // NOLINT(readability-identifier-naming)
|
||||
static const char I = 'I'; // NOLINT(readability-identifier-naming)
|
||||
static const char J = 'J'; // NOLINT(readability-identifier-naming)
|
||||
static const char K = 'K'; // NOLINT(readability-identifier-naming)
|
||||
static const char L = 'L'; // NOLINT(readability-identifier-naming)
|
||||
static const char M = 'M'; // NOLINT(readability-identifier-naming)
|
||||
static const char N = 'N'; // NOLINT(readability-identifier-naming)
|
||||
static const char O = 'O'; // NOLINT(readability-identifier-naming)
|
||||
static const char P = 'P'; // NOLINT(readability-identifier-naming)
|
||||
static const char Q = 'Q'; // NOLINT(readability-identifier-naming)
|
||||
static const char R = 'R'; // NOLINT(readability-identifier-naming)
|
||||
static const char S = 'S'; // NOLINT(readability-identifier-naming)
|
||||
static const char T = 'T'; // NOLINT(readability-identifier-naming)
|
||||
static const char U = 'U'; // NOLINT(readability-identifier-naming)
|
||||
static const char V = 'V'; // NOLINT(readability-identifier-naming)
|
||||
static const char W = 'W'; // NOLINT(readability-identifier-naming)
|
||||
static const char X = 'X'; // NOLINT(readability-identifier-naming)
|
||||
static const char Y = 'Y'; // NOLINT(readability-identifier-naming)
|
||||
static const char Z = 'Z'; // NOLINT(readability-identifier-naming)
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::alphabet
|
||||
|
||||
#endif
|
|
@ -1,189 +0,0 @@
|
|||
// Copyright (c) 2020-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_ANALYZE_HPP
|
||||
#define TAO_PEGTL_CONTRIB_ANALYZE_HPP
|
||||
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "../config.hpp"
|
||||
#include "../demangle.hpp"
|
||||
|
||||
#include "analyze_traits.hpp"
|
||||
|
||||
#include "internal/set_stack_guard.hpp"
|
||||
#include "internal/vector_stack_guard.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
struct analyze_entry
|
||||
{
|
||||
explicit analyze_entry( const analyze_type in_type ) noexcept
|
||||
: type( in_type )
|
||||
{}
|
||||
|
||||
const analyze_type type;
|
||||
std::vector< std::string_view > subs;
|
||||
};
|
||||
|
||||
class analyze_cycles_impl
|
||||
{
|
||||
public:
|
||||
analyze_cycles_impl( analyze_cycles_impl&& ) = delete;
|
||||
analyze_cycles_impl( const analyze_cycles_impl& ) = delete;
|
||||
|
||||
~analyze_cycles_impl() = default;
|
||||
|
||||
analyze_cycles_impl& operator=( analyze_cycles_impl&& ) = delete;
|
||||
analyze_cycles_impl& operator=( const analyze_cycles_impl& ) = delete;
|
||||
|
||||
[[nodiscard]] std::size_t problems()
|
||||
{
|
||||
for( auto& i : m_entries ) {
|
||||
assert( m_trace.empty() );
|
||||
assert( m_stack.empty() );
|
||||
m_results[ i.first ] = work( i, false );
|
||||
}
|
||||
// The number of problems returned is not very informative as some problems will be found multiple times.
|
||||
return m_problems;
|
||||
}
|
||||
|
||||
template< typename Rule >
|
||||
[[nodiscard]] bool consumes() const
|
||||
{
|
||||
// The name "consumes" is a shortcut for "the analyze cycles algorithm could prove that this rule always consumes when it succeeds".
|
||||
return m_results.at( demangle< Rule >() );
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit analyze_cycles_impl( const int verbose ) noexcept
|
||||
: m_verbose( verbose ),
|
||||
m_problems( 0 )
|
||||
{}
|
||||
|
||||
[[nodiscard]] const std::pair< const std::string_view, analyze_entry >& find( const std::string_view name ) const noexcept
|
||||
{
|
||||
const auto iter = m_entries.find( name );
|
||||
assert( iter != m_entries.end() );
|
||||
return *iter;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool work( const std::pair< const std::string_view, analyze_entry >& entry, const bool accum )
|
||||
{
|
||||
if( const auto g = set_stack_guard( m_stack, entry.first ) ) {
|
||||
const auto v = vector_stack_guard( m_trace, entry.first );
|
||||
switch( entry.second.type ) {
|
||||
case analyze_type::any: {
|
||||
bool a = false;
|
||||
for( const auto& r : entry.second.subs ) {
|
||||
a = a || work( find( r ), accum || a );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case analyze_type::opt: {
|
||||
bool a = false;
|
||||
for( const auto& r : entry.second.subs ) {
|
||||
a = a || work( find( r ), accum || a );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case analyze_type::seq: {
|
||||
bool a = false;
|
||||
for( const auto& r : entry.second.subs ) {
|
||||
a = a || work( find( r ), accum || a );
|
||||
}
|
||||
return a;
|
||||
}
|
||||
case analyze_type::sor: {
|
||||
bool a = true;
|
||||
for( const auto& r : entry.second.subs ) {
|
||||
a = a && work( find( r ), accum );
|
||||
}
|
||||
return a;
|
||||
}
|
||||
}
|
||||
assert( false ); // LCOV_EXCL_LINE
|
||||
}
|
||||
assert( !m_trace.empty() );
|
||||
|
||||
if( !accum ) {
|
||||
++m_problems;
|
||||
// LCOV_EXCL_START
|
||||
if( ( m_verbose >= 0 ) && ( m_trace.front() == entry.first ) ) {
|
||||
for( const auto& r : m_trace ) {
|
||||
if( r < entry.first ) {
|
||||
return accum;
|
||||
}
|
||||
}
|
||||
std::cerr << "WARNING: Possible cycle without progress at rule " << entry.first << std::endl;
|
||||
if( m_verbose > 0 ) {
|
||||
for( const auto& r : m_trace ) {
|
||||
std::cerr << "- involved (transformed) rule: " << r << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
return accum;
|
||||
}
|
||||
|
||||
const int m_verbose;
|
||||
|
||||
std::size_t m_problems;
|
||||
|
||||
std::set< std::string_view > m_stack;
|
||||
std::vector< std::string_view > m_trace;
|
||||
std::map< std::string_view, bool > m_results;
|
||||
std::map< std::string_view, analyze_entry > m_entries;
|
||||
};
|
||||
|
||||
template< typename Name >
|
||||
std::string_view analyze_insert( std::map< std::string_view, analyze_entry >& entry )
|
||||
{
|
||||
using Traits = analyze_traits< Name, typename Name::rule_t >;
|
||||
|
||||
const auto [ i, b ] = entry.try_emplace( demangle< Name >(), Traits::type_v );
|
||||
if( b ) {
|
||||
analyze_insert_impl( typename Traits::subs_t(), i->second.subs, entry );
|
||||
}
|
||||
return i->first;
|
||||
}
|
||||
|
||||
template< typename... Subs >
|
||||
void analyze_insert_impl( type_list< Subs... > /*unused*/, std::vector< std::string_view >& subs, std::map< std::string_view, analyze_entry >& entry )
|
||||
{
|
||||
( subs.emplace_back( analyze_insert< Subs >( entry ) ), ... );
|
||||
}
|
||||
|
||||
template< typename Grammar >
|
||||
struct analyze_cycles
|
||||
: analyze_cycles_impl
|
||||
{
|
||||
explicit analyze_cycles( const int verbose )
|
||||
: analyze_cycles_impl( verbose )
|
||||
{
|
||||
analyze_insert< Grammar >( m_entries );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template< typename Grammar >
|
||||
[[nodiscard]] std::size_t analyze( const int verbose = 1 )
|
||||
{
|
||||
return internal::analyze_cycles< Grammar >( verbose ).problems();
|
||||
}
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,277 +0,0 @@
|
|||
// Copyright (c) 2020-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_ANALYZE_TRAITS_HPP
|
||||
#define TAO_PEGTL_CONTRIB_ANALYZE_TRAITS_HPP
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "../ascii.hpp"
|
||||
#include "../config.hpp"
|
||||
#include "../rules.hpp"
|
||||
#include "../type_list.hpp"
|
||||
|
||||
#include "forward.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
enum class analyze_type
|
||||
{
|
||||
any, // Consumption-on-success is always true; assumes bounded repetition of conjunction of sub-rules.
|
||||
opt, // Consumption-on-success not necessarily true; assumes bounded repetition of conjunction of sub-rules.
|
||||
seq, // Consumption-on-success depends on consumption of (non-zero bounded repetition of) conjunction of sub-rules.
|
||||
sor // Consumption-on-success depends on consumption of (non-zero bounded repetition of) disjunction of sub-rules.
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template< typename... Rules >
|
||||
struct analyze_any_traits
|
||||
{
|
||||
static constexpr internal::analyze_type type_v = internal::analyze_type::any;
|
||||
using subs_t = type_list< Rules... >;
|
||||
};
|
||||
|
||||
template< typename... Rules >
|
||||
struct analyze_opt_traits
|
||||
{
|
||||
static constexpr internal::analyze_type type_v = internal::analyze_type::opt;
|
||||
using subs_t = type_list< Rules... >;
|
||||
};
|
||||
|
||||
template< typename... Rules >
|
||||
struct analyze_seq_traits
|
||||
{
|
||||
static constexpr internal::analyze_type type_v = internal::analyze_type::seq;
|
||||
using subs_t = type_list< Rules... >;
|
||||
};
|
||||
|
||||
template< typename... Rules >
|
||||
struct analyze_sor_traits
|
||||
{
|
||||
static constexpr internal::analyze_type type_v = internal::analyze_type::sor;
|
||||
using subs_t = type_list< Rules... >;
|
||||
};
|
||||
|
||||
template< typename Name, template< typename... > class Action, typename... Rules >
|
||||
struct analyze_traits< Name, internal::action< Action, Rules... > >
|
||||
: analyze_traits< Name, typename seq< Rules... >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, typename Peek >
|
||||
struct analyze_traits< Name, internal::any< Peek > >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename... Actions >
|
||||
struct analyze_traits< Name, internal::apply< Actions... > >
|
||||
: analyze_opt_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename... Actions >
|
||||
struct analyze_traits< Name, internal::apply0< Actions... > >
|
||||
: analyze_opt_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename... Rules >
|
||||
struct analyze_traits< Name, internal::at< Rules... > >
|
||||
: analyze_traits< Name, typename opt< Rules... >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name >
|
||||
struct analyze_traits< Name, internal::bof >
|
||||
: analyze_opt_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name >
|
||||
struct analyze_traits< Name, internal::bol >
|
||||
: analyze_opt_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, unsigned Cnt >
|
||||
struct analyze_traits< Name, internal::bytes< Cnt > >
|
||||
: std::conditional_t< ( Cnt != 0 ), analyze_any_traits<>, analyze_opt_traits<> >
|
||||
{};
|
||||
|
||||
template< typename Name, template< typename... > class Control, typename... Rules >
|
||||
struct analyze_traits< Name, internal::control< Control, Rules... > >
|
||||
: analyze_traits< Name, typename seq< Rules... >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, typename... Rules >
|
||||
struct analyze_traits< Name, internal::disable< Rules... > >
|
||||
: analyze_traits< Name, typename seq< Rules... >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name >
|
||||
struct analyze_traits< Name, internal::discard >
|
||||
: analyze_opt_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename... Rules >
|
||||
struct analyze_traits< Name, internal::enable< Rules... > >
|
||||
: analyze_traits< Name, typename seq< Rules... >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name >
|
||||
struct analyze_traits< Name, internal::eof >
|
||||
: analyze_opt_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name >
|
||||
struct analyze_traits< Name, internal::eol >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name >
|
||||
struct analyze_traits< Name, internal::eolf >
|
||||
: analyze_opt_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name >
|
||||
struct analyze_traits< Name, internal::failure >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename Rule, typename... Actions >
|
||||
struct analyze_traits< Name, internal::if_apply< Rule, Actions... > >
|
||||
: analyze_traits< Name, typename Rule::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, typename Cond, typename Then, typename Else >
|
||||
struct analyze_traits< Name, internal::if_then_else< Cond, Then, Else > >
|
||||
: analyze_traits< Name, typename sor< seq< Cond, Then >, Else >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, char... Cs >
|
||||
struct analyze_traits< Name, internal::istring< Cs... > >
|
||||
: std::conditional_t< ( sizeof...( Cs ) != 0 ), analyze_any_traits<>, analyze_opt_traits<> >
|
||||
{};
|
||||
|
||||
template< typename Name, typename... Rules >
|
||||
struct analyze_traits< Name, internal::not_at< Rules... > >
|
||||
: analyze_traits< Name, typename opt< Rules... >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, internal::result_on_found R, typename Peek, typename Peek::data_t... Cs >
|
||||
struct analyze_traits< Name, internal::one< R, Peek, Cs... > >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename Rule, typename... Rules >
|
||||
struct analyze_traits< Name, internal::opt< Rule, Rules... > >
|
||||
: analyze_opt_traits< Rule, Rules... >
|
||||
{};
|
||||
|
||||
template< typename Name, typename... Rules >
|
||||
struct analyze_traits< Name, internal::plus< Rules... > >
|
||||
: analyze_traits< Name, typename seq< Rules..., opt< Name > >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, internal::result_on_found R, typename Peek, typename Peek::data_t Lo, typename Peek::data_t Hi >
|
||||
struct analyze_traits< Name, internal::range< R, Peek, Lo, Hi > >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename Peek, typename Peek::data_t... Cs >
|
||||
struct analyze_traits< Name, internal::ranges< Peek, Cs... > >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename Head, typename... Rules >
|
||||
struct analyze_traits< Name, internal::rematch< Head, Rules... > >
|
||||
: analyze_traits< Name, typename sor< Head, sor< seq< Rules, any >... > >::rule_t > // TODO: Correct (enough)?
|
||||
{};
|
||||
|
||||
template< typename Name, unsigned Cnt, typename... Rules >
|
||||
struct analyze_traits< Name, internal::rep< Cnt, Rules... > >
|
||||
: analyze_traits< Name, std::conditional_t< ( Cnt != 0 ), typename seq< Rules... >::rule_t, typename opt< Rules... >::rule_t > >
|
||||
{};
|
||||
|
||||
template< typename Name, unsigned Min, unsigned Max, typename... Rules >
|
||||
struct analyze_traits< Name, internal::rep_min_max< Min, Max, Rules... > >
|
||||
: analyze_traits< Name, std::conditional_t< ( Min != 0 ), typename seq< Rules... >::rule_t, typename opt< Rules... >::rule_t > >
|
||||
{};
|
||||
|
||||
template< typename Name, unsigned Max, typename... Rules >
|
||||
struct analyze_traits< Name, internal::rep_opt< Max, Rules... > >
|
||||
: analyze_traits< Name, typename opt< Rules... >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, unsigned Amount >
|
||||
struct analyze_traits< Name, internal::require< Amount > >
|
||||
: analyze_opt_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename Rule, typename... Rules >
|
||||
struct analyze_traits< Name, internal::seq< Rule, Rules... > >
|
||||
: analyze_seq_traits< Rule, Rules... >
|
||||
{};
|
||||
|
||||
template< typename Name, typename Rule, typename... Rules >
|
||||
struct analyze_traits< Name, internal::sor< Rule, Rules... > >
|
||||
: analyze_sor_traits< Rule, Rules... >
|
||||
{};
|
||||
|
||||
template< typename Name, typename... Rules >
|
||||
struct analyze_traits< Name, internal::star< Rules... > >
|
||||
: analyze_traits< Name, typename opt< Rules..., Name >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, typename State, typename... Rules >
|
||||
struct analyze_traits< Name, internal::state< State, Rules... > >
|
||||
: analyze_traits< Name, typename seq< Rules... >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, char... Cs >
|
||||
struct analyze_traits< Name, internal::string< Cs... > >
|
||||
: std::conditional_t< ( sizeof...( Cs ) != 0 ), analyze_any_traits<>, analyze_opt_traits<> >
|
||||
{};
|
||||
|
||||
template< typename Name >
|
||||
struct analyze_traits< Name, internal::success >
|
||||
: analyze_opt_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename Cond >
|
||||
struct analyze_traits< Name, internal::until< Cond > >
|
||||
: analyze_traits< Name, typename Cond::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, typename Cond, typename... Rules >
|
||||
struct analyze_traits< Name, internal::until< Cond, Rules... > >
|
||||
: analyze_traits< Name, typename seq< star< Rules... >, Cond >::rule_t >
|
||||
{};
|
||||
|
||||
#if defined( __cpp_exceptions )
|
||||
template< typename Name, typename Cond, typename... Rules >
|
||||
struct analyze_traits< Name, internal::if_must< true, Cond, Rules... > >
|
||||
: analyze_traits< Name, typename opt< Cond, Rules... >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, typename Cond, typename... Rules >
|
||||
struct analyze_traits< Name, internal::if_must< false, Cond, Rules... > >
|
||||
: analyze_traits< Name, typename seq< Cond, Rules... >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, typename... Rules >
|
||||
struct analyze_traits< Name, internal::must< Rules... > >
|
||||
: analyze_traits< Name, typename seq< Rules... >::rule_t >
|
||||
{};
|
||||
|
||||
template< typename Name, typename T >
|
||||
struct analyze_traits< Name, internal::raise< T > >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename Exception, typename... Rules >
|
||||
struct analyze_traits< Name, internal::try_catch_type< Exception, Rules... > >
|
||||
: analyze_traits< Name, typename seq< Rules... >::rule_t >
|
||||
{};
|
||||
#endif
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,55 +0,0 @@
|
|||
// Copyright (c) 2021-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_CHECK_BYTES_HPP
|
||||
#define TAO_PEGTL_CONTRIB_CHECK_BYTES_HPP
|
||||
|
||||
#include "../apply_mode.hpp"
|
||||
#include "../config.hpp"
|
||||
#include "../match.hpp"
|
||||
#include "../nothing.hpp"
|
||||
#include "../rewind_mode.hpp"
|
||||
|
||||
#if defined( __cpp_exceptions )
|
||||
#include "../parse_error.hpp"
|
||||
#else
|
||||
#include <cstdio>
|
||||
#include <exception>
|
||||
#endif
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
template< std::size_t Maximum >
|
||||
struct check_bytes
|
||||
: maybe_nothing
|
||||
{
|
||||
template< typename Rule,
|
||||
pegtl::apply_mode A,
|
||||
pegtl::rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
const auto* start = in.current();
|
||||
if( TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, st... ) ) {
|
||||
if( std::size_t( in.current() - start ) > Maximum ) {
|
||||
#if defined( __cpp_exceptions )
|
||||
throw TAO_PEGTL_NAMESPACE::parse_error( "maximum allowed rule consumption exceeded", in );
|
||||
#else
|
||||
std::fputs( "maximum allowed rule consumption exceeded\n", stderr );
|
||||
std::terminate();
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,93 +0,0 @@
|
|||
// Copyright (c) 2020-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_CONTROL_ACTION_HPP
|
||||
#define TAO_PEGTL_CONTRIB_CONTROL_ACTION_HPP
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "../config.hpp"
|
||||
#include "../match.hpp"
|
||||
#include "../nothing.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
template< typename, typename Rule, template< typename... > class Action, typename ParseInput, typename... States >
|
||||
inline constexpr bool action_has_unwind = false;
|
||||
|
||||
template< typename Rule, template< typename... > class Action, typename ParseInput, typename... States >
|
||||
inline constexpr bool action_has_unwind< decltype( (void)Action< Rule >::unwind( std::declval< const ParseInput& >(), std::declval< States&& >()... ) ), Rule, Action, ParseInput, States... > = true;
|
||||
|
||||
} // namespace internal
|
||||
|
||||
struct control_action
|
||||
: maybe_nothing
|
||||
{
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
#if defined( __cpp_exceptions )
|
||||
if constexpr( internal::action_has_unwind< void, Rule, Action, ParseInput, States... > ) {
|
||||
try {
|
||||
return control_action::match_impl< Rule, A, M, Action, Control >( in, st... );
|
||||
}
|
||||
catch( ... ) {
|
||||
Action< Rule >::unwind( const_cast< const ParseInput& >( in ), st... );
|
||||
throw;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return control_action::match_impl< Rule, A, M, Action, Control >( in, st... );
|
||||
}
|
||||
#else
|
||||
return control_action::match_impl< Rule, A, M, Action, Control >( in, st... );
|
||||
#endif
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename... States >
|
||||
static void start( const ParseInput& /*unused*/, States&&... /*unused*/ ) noexcept
|
||||
{}
|
||||
|
||||
template< typename ParseInput, typename... States >
|
||||
static void success( const ParseInput& /*unused*/, States&&... /*unused*/ ) noexcept
|
||||
{}
|
||||
|
||||
template< typename ParseInput, typename... States >
|
||||
static void failure( const ParseInput& /*unused*/, States&&... /*unused*/ ) noexcept
|
||||
{}
|
||||
|
||||
private:
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match_impl( ParseInput& in, States&&... st )
|
||||
{
|
||||
Action< Rule >::start( const_cast< const ParseInput& >( in ), st... );
|
||||
if( TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, st... ) ) {
|
||||
Action< Rule >::success( const_cast< const ParseInput& >( in ), st... );
|
||||
return true;
|
||||
}
|
||||
Action< Rule >::failure( const_cast< const ParseInput& >( in ), st... );
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,151 +0,0 @@
|
|||
// Copyright (c) 2020-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_COVERAGE_HPP
|
||||
#define TAO_PEGTL_CONTRIB_COVERAGE_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <map>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "state_control.hpp"
|
||||
|
||||
#include "../apply_mode.hpp"
|
||||
#include "../config.hpp"
|
||||
#include "../demangle.hpp"
|
||||
#include "../normal.hpp"
|
||||
#include "../nothing.hpp"
|
||||
#include "../parse.hpp"
|
||||
#include "../rewind_mode.hpp"
|
||||
#include "../type_list.hpp"
|
||||
#include "../visit.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
struct coverage_info
|
||||
{
|
||||
std::size_t start = 0;
|
||||
std::size_t success = 0;
|
||||
std::size_t failure = 0;
|
||||
std::size_t unwind = 0;
|
||||
std::size_t raise = 0;
|
||||
};
|
||||
|
||||
struct coverage_entry
|
||||
: coverage_info
|
||||
{
|
||||
std::map< std::string_view, coverage_info > branches;
|
||||
};
|
||||
|
||||
using coverage_result = std::map< std::string_view, coverage_entry >;
|
||||
|
||||
namespace internal
|
||||
{
|
||||
template< typename Rule >
|
||||
struct coverage_insert
|
||||
{
|
||||
static void visit( std::map< std::string_view, coverage_entry >& map )
|
||||
{
|
||||
visit_branches( map.try_emplace( demangle< Rule >() ).first->second.branches, typename Rule::subs_t() );
|
||||
}
|
||||
|
||||
template< typename... Ts >
|
||||
static void visit_branches( std::map< std::string_view, coverage_info >& branches, type_list< Ts... > /*unused*/ )
|
||||
{
|
||||
( branches.try_emplace( demangle< Ts >() ), ... );
|
||||
}
|
||||
};
|
||||
|
||||
struct coverage_state
|
||||
{
|
||||
template< typename Rule >
|
||||
static constexpr bool enable = true;
|
||||
|
||||
explicit coverage_state( coverage_result& in_result )
|
||||
: result( in_result )
|
||||
{}
|
||||
|
||||
coverage_result& result;
|
||||
std::vector< std::string_view > stack;
|
||||
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void start( const ParseInput& /*unused*/, States&&... /*unused*/ )
|
||||
{
|
||||
const auto name = demangle< Rule >();
|
||||
++result.at( name ).start;
|
||||
if( !stack.empty() ) {
|
||||
++result.at( stack.back() ).branches.at( name ).start;
|
||||
}
|
||||
stack.push_back( name );
|
||||
}
|
||||
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void success( const ParseInput& /*unused*/, States&&... /*unused*/ )
|
||||
{
|
||||
stack.pop_back();
|
||||
const auto name = demangle< Rule >();
|
||||
++result.at( name ).success;
|
||||
if( !stack.empty() ) {
|
||||
++result.at( stack.back() ).branches.at( name ).success;
|
||||
}
|
||||
}
|
||||
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void failure( const ParseInput& /*unused*/, States&&... /*unused*/ )
|
||||
{
|
||||
stack.pop_back();
|
||||
const auto name = demangle< Rule >();
|
||||
++result.at( name ).failure;
|
||||
if( !stack.empty() ) {
|
||||
++result.at( stack.back() ).branches.at( name ).failure;
|
||||
}
|
||||
}
|
||||
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void raise( const ParseInput& /*unused*/, States&&... /*unused*/ )
|
||||
{
|
||||
const auto name = demangle< Rule >();
|
||||
++result.at( name ).raise;
|
||||
if( !stack.empty() ) {
|
||||
++result.at( stack.back() ).branches.at( name ).raise;
|
||||
}
|
||||
}
|
||||
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void unwind( const ParseInput& /*unused*/, States&&... /*unused*/ )
|
||||
{
|
||||
stack.pop_back();
|
||||
const auto name = demangle< Rule >();
|
||||
++result.at( name ).unwind;
|
||||
if( !stack.empty() ) {
|
||||
++result.at( stack.back() ).branches.at( name ).unwind;
|
||||
}
|
||||
}
|
||||
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void apply( const ParseInput& /*unused*/, States&&... /*unused*/ ) noexcept
|
||||
{}
|
||||
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void apply0( const ParseInput& /*unused*/, States&&... /*unused*/ ) noexcept
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template< typename Rule,
|
||||
template< typename... > class Action = nothing,
|
||||
template< typename... > class Control = normal,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
bool coverage( ParseInput&& in, coverage_result& result, States&&... st )
|
||||
{
|
||||
internal::coverage_state state( result );
|
||||
visit< Rule, internal::coverage_insert >( state.result ); // Fill map with all sub-rules of the grammar.
|
||||
return parse< Rule, Action, state_control< Control >::template type >( in, st..., state );
|
||||
}
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,16 +0,0 @@
|
|||
// Copyright (c) 2020-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_FORWARD_HPP
|
||||
#define TAO_PEGTL_CONTRIB_FORWARD_HPP
|
||||
|
||||
#include "../config.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
template< typename Name, typename Rule, typename = void >
|
||||
struct analyze_traits;
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,52 +0,0 @@
|
|||
// Copyright (c) 2020-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_FUNCTION_HPP
|
||||
#define TAO_PEGTL_CONTRIB_FUNCTION_HPP
|
||||
|
||||
#include "../config.hpp"
|
||||
|
||||
#include "../apply_mode.hpp"
|
||||
#include "../rewind_mode.hpp"
|
||||
#include "../type_list.hpp"
|
||||
|
||||
#include "../internal/enable_control.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
template< typename F, F U >
|
||||
struct function;
|
||||
|
||||
template< typename ParseInput, typename... States, bool ( *U )( ParseInput&, States... ) >
|
||||
struct function< bool ( * )( ParseInput&, States... ), U >
|
||||
{
|
||||
using rule_t = function;
|
||||
using subs_t = empty_list;
|
||||
|
||||
template< apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control >
|
||||
[[nodiscard]] static bool match( ParseInput& in, States... st ) noexcept( noexcept( U( in, st... ) ) )
|
||||
{
|
||||
return U( in, st... );
|
||||
}
|
||||
};
|
||||
|
||||
template< typename F, F U >
|
||||
inline constexpr bool enable_control< function< F, U > > = false;
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template< auto F >
|
||||
struct function
|
||||
: internal::function< decltype( F ), F >
|
||||
{};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,277 +0,0 @@
|
|||
// Copyright (c) 2014-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_HTTP_HPP
|
||||
#define TAO_PEGTL_CONTRIB_HTTP_HPP
|
||||
|
||||
#if !defined( __cpp_exceptions )
|
||||
#error "Exception support required for tao/pegtl/contrib/http.hpp"
|
||||
#else
|
||||
|
||||
#include "../ascii.hpp"
|
||||
#include "../config.hpp"
|
||||
#include "../nothing.hpp"
|
||||
#include "../rules.hpp"
|
||||
#include "../utf8.hpp"
|
||||
|
||||
#include "abnf.hpp"
|
||||
#include "forward.hpp"
|
||||
#include "remove_first_state.hpp"
|
||||
#include "uri.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::http
|
||||
{
|
||||
// HTTP 1.1 grammar according to RFC 7230.
|
||||
|
||||
// This grammar is a direct PEG translation of the original HTTP grammar.
|
||||
// It should be considered experimental -- in case of any issues, in particular
|
||||
// missing rules for attached actions, please contact the developers.
|
||||
|
||||
using OWS = star< abnf::WSP >; // optional whitespace
|
||||
using RWS = plus< abnf::WSP >; // required whitespace
|
||||
using BWS = OWS; // "bad" whitespace
|
||||
|
||||
using obs_text = not_range< 0x00, 0x7F >;
|
||||
using obs_fold = seq< abnf::CRLF, plus< abnf::WSP > >;
|
||||
|
||||
// clang-format off
|
||||
struct tchar : sor< abnf::ALPHA, abnf::DIGIT, one< '!', '#', '$', '%', '&', '\'', '*', '+', '-', '.', '^', '_', '`', '|', '~' > > {};
|
||||
struct token : plus< tchar > {};
|
||||
|
||||
struct field_name : token {};
|
||||
|
||||
struct field_vchar : sor< abnf::VCHAR, obs_text > {};
|
||||
struct field_content : list< field_vchar, plus< abnf::WSP > > {};
|
||||
struct field_value : star< sor< field_content, obs_fold > > {};
|
||||
|
||||
struct header_field : seq< field_name, one< ':' >, OWS, field_value, OWS > {};
|
||||
|
||||
struct method : token {};
|
||||
|
||||
struct absolute_path : plus< one< '/' >, uri::segment > {};
|
||||
|
||||
struct origin_form : seq< absolute_path, uri::opt_query > {};
|
||||
struct absolute_form : uri::absolute_URI {};
|
||||
struct authority_form : uri::authority {};
|
||||
struct asterisk_form : one< '*' > {};
|
||||
|
||||
struct request_target : sor< origin_form, absolute_form, authority_form, asterisk_form > {};
|
||||
|
||||
struct status_code : rep< 3, abnf::DIGIT > {};
|
||||
struct reason_phrase : star< sor< abnf::VCHAR, obs_text, abnf::WSP > > {};
|
||||
|
||||
struct HTTP_version : if_must< string< 'H', 'T', 'T', 'P', '/' >, abnf::DIGIT, one< '.' >, abnf::DIGIT > {};
|
||||
|
||||
struct request_line : if_must< method, abnf::SP, request_target, abnf::SP, HTTP_version, abnf::CRLF > {};
|
||||
struct status_line : if_must< HTTP_version, abnf::SP, status_code, abnf::SP, reason_phrase, abnf::CRLF > {};
|
||||
struct start_line : sor< status_line, request_line > {};
|
||||
|
||||
struct message_body : star< abnf::OCTET > {};
|
||||
struct HTTP_message : seq< start_line, star< header_field, abnf::CRLF >, abnf::CRLF, opt< message_body > > {};
|
||||
|
||||
struct Content_Length : plus< abnf::DIGIT > {};
|
||||
|
||||
struct uri_host : uri::host {};
|
||||
struct port : uri::port {};
|
||||
|
||||
struct Host : seq< uri_host, opt< one< ':' >, port > > {};
|
||||
|
||||
// PEG are different from CFGs! (this replaces ctext and qdtext)
|
||||
using text = sor< abnf::HTAB, range< 0x20, 0x7E >, obs_text >;
|
||||
|
||||
struct quoted_pair : if_must< one< '\\' >, sor< abnf::VCHAR, obs_text, abnf::WSP > > {};
|
||||
struct quoted_string : if_must< abnf::DQUOTE, until< abnf::DQUOTE, sor< quoted_pair, text > > > {};
|
||||
|
||||
struct transfer_parameter : seq< token, BWS, one< '=' >, BWS, sor< token, quoted_string > > {};
|
||||
struct transfer_extension : seq< token, star< OWS, one< ';' >, OWS, transfer_parameter > > {};
|
||||
struct transfer_coding : sor< istring< 'c', 'h', 'u', 'n', 'k', 'e', 'd' >,
|
||||
istring< 'c', 'o', 'm', 'p', 'r', 'e', 's', 's' >,
|
||||
istring< 'd', 'e', 'f', 'l', 'a', 't', 'e' >,
|
||||
istring< 'g', 'z', 'i', 'p' >,
|
||||
transfer_extension > {};
|
||||
|
||||
struct rank : sor< seq< one< '0' >, opt< one< '.' >, rep_opt< 3, abnf::DIGIT > > >,
|
||||
seq< one< '1' >, opt< one< '.' >, rep_opt< 3, one< '0' > > > > > {};
|
||||
|
||||
struct t_ranking : seq< OWS, one< ';' >, OWS, one< 'q', 'Q' >, one< '=' >, rank > {};
|
||||
struct t_codings : sor< istring< 't', 'r', 'a', 'i', 'l', 'e', 'r', 's' >, seq< transfer_coding, opt< t_ranking > > > {};
|
||||
|
||||
struct TE : opt< sor< one< ',' >, t_codings >, star< OWS, one< ',' >, opt< OWS, t_codings > > > {};
|
||||
|
||||
template< typename T >
|
||||
using make_comma_list = seq< star< one< ',' >, OWS >, T, star< OWS, one< ',' >, opt< OWS, T > > >;
|
||||
|
||||
struct connection_option : token {};
|
||||
struct Connection : make_comma_list< connection_option > {};
|
||||
|
||||
struct Trailer : make_comma_list< field_name > {};
|
||||
|
||||
struct Transfer_Encoding : make_comma_list< transfer_coding > {};
|
||||
|
||||
struct protocol_name : token {};
|
||||
struct protocol_version : token {};
|
||||
struct protocol : seq< protocol_name, opt< one< '/' >, protocol_version > > {};
|
||||
struct Upgrade : make_comma_list< protocol > {};
|
||||
|
||||
struct pseudonym : token {};
|
||||
|
||||
struct received_protocol : seq< opt< protocol_name, one< '/' > >, protocol_version > {};
|
||||
struct received_by : sor< seq< uri_host, opt< one< ':' >, port > >, pseudonym > {};
|
||||
|
||||
struct comment : if_must< one< '(' >, until< one< ')' >, sor< comment, quoted_pair, text > > > {};
|
||||
|
||||
struct Via : make_comma_list< seq< received_protocol, RWS, received_by, opt< RWS, comment > > > {};
|
||||
|
||||
struct http_URI : if_must< istring< 'h', 't', 't', 'p', ':', '/', '/' >, uri::authority, uri::path_abempty, uri::opt_query, uri::opt_fragment > {};
|
||||
struct https_URI : if_must< istring< 'h', 't', 't', 'p', 's', ':', '/', '/' >, uri::authority, uri::path_abempty, uri::opt_query, uri::opt_fragment > {};
|
||||
|
||||
struct partial_URI : seq< uri::relative_part, uri::opt_query > {};
|
||||
// clang-format on
|
||||
|
||||
struct chunk_size
|
||||
{
|
||||
using rule_t = plus< abnf::HEXDIG >::rule_t;
|
||||
|
||||
template< apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, std::size_t& size, States&&... /*unused*/ )
|
||||
{
|
||||
size = 0;
|
||||
std::size_t i = 0;
|
||||
while( in.size( i + 1 ) >= i + 1 ) {
|
||||
const auto c = in.peek_char( i );
|
||||
if( ( '0' <= c ) && ( c <= '9' ) ) {
|
||||
size <<= 4;
|
||||
size |= std::size_t( c - '0' );
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
if( ( 'a' <= c ) && ( c <= 'f' ) ) {
|
||||
size <<= 4;
|
||||
size |= std::size_t( c - 'a' + 10 );
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
if( ( 'A' <= c ) && ( c <= 'F' ) ) {
|
||||
size <<= 4;
|
||||
size |= std::size_t( c - 'A' + 10 );
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
in.bump_in_this_line( i );
|
||||
return i > 0;
|
||||
}
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
struct chunk_ext_name : token {};
|
||||
struct chunk_ext_val : sor< quoted_string, token > {};
|
||||
struct chunk_ext : star_must< one< ';' >, chunk_ext_name, if_must< one< '=' >, chunk_ext_val > > {};
|
||||
// clang-format on
|
||||
|
||||
struct chunk_data
|
||||
{
|
||||
using rule_t = star< abnf::OCTET >::rule_t;
|
||||
|
||||
template< apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, const std::size_t size, States&&... /*unused*/ )
|
||||
{
|
||||
if( in.size( size ) >= size ) {
|
||||
in.bump( size );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
namespace internal::chunk_helper
|
||||
{
|
||||
template< typename Base >
|
||||
struct control;
|
||||
|
||||
template< template< typename... > class Control, typename Rule >
|
||||
struct control< Control< Rule > >
|
||||
: Control< Rule >
|
||||
{
|
||||
template< apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class,
|
||||
typename ParseInput,
|
||||
typename State,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, State&& /*unused*/, States&&... st )
|
||||
{
|
||||
return Control< Rule >::template match< A, M, Action, Control >( in, st... );
|
||||
}
|
||||
};
|
||||
|
||||
template< template< typename... > class Control >
|
||||
struct control< Control< chunk_size > >
|
||||
: remove_first_state< Control< chunk_size > >
|
||||
{};
|
||||
|
||||
template< template< typename... > class Control >
|
||||
struct control< Control< chunk_data > >
|
||||
: remove_first_state< Control< chunk_data > >
|
||||
{};
|
||||
|
||||
template< template< typename... > class Control >
|
||||
struct bind
|
||||
{
|
||||
template< typename Rule >
|
||||
using type = control< Control< Rule > >;
|
||||
};
|
||||
|
||||
} // namespace internal::chunk_helper
|
||||
|
||||
struct chunk
|
||||
{
|
||||
using impl = seq< chunk_size, chunk_ext, abnf::CRLF, chunk_data, abnf::CRLF >;
|
||||
|
||||
using rule_t = impl::rule_t;
|
||||
|
||||
template< apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
std::size_t size{};
|
||||
return impl::template match< A, M, Action, internal::chunk_helper::bind< Control >::template type >( in, size, st... );
|
||||
}
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
struct last_chunk : seq< plus< one< '0' > >, not_at< digit >, chunk_ext, abnf::CRLF > {};
|
||||
|
||||
struct trailer_part : star< header_field, abnf::CRLF > {};
|
||||
|
||||
struct chunked_body : seq< until< last_chunk, chunk >, trailer_part, abnf::CRLF > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::http
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -1,98 +0,0 @@
|
|||
// Copyright (c) 2018-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_ICU_INTERNAL_HPP
|
||||
#define TAO_PEGTL_CONTRIB_ICU_INTERNAL_HPP
|
||||
|
||||
#include <unicode/uchar.h>
|
||||
|
||||
#include "../analyze_traits.hpp"
|
||||
|
||||
#include "../../config.hpp"
|
||||
#include "../../type_list.hpp"
|
||||
|
||||
#include "../../internal/enable_control.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
namespace icu
|
||||
{
|
||||
template< typename Peek, UProperty P, bool V = true >
|
||||
struct binary_property
|
||||
{
|
||||
using peek_t = Peek;
|
||||
using data_t = typename Peek::data_t;
|
||||
|
||||
using rule_t = binary_property;
|
||||
using subs_t = empty_list;
|
||||
|
||||
[[nodiscard]] static bool test( const data_t c ) noexcept
|
||||
{
|
||||
return u_hasBinaryProperty( c, P ) == V;
|
||||
}
|
||||
|
||||
template< typename ParseInput >
|
||||
[[nodiscard]] static bool match( ParseInput& in ) noexcept( noexcept( Peek::peek( in ) ) )
|
||||
{
|
||||
if( const auto t = Peek::peek( in ) ) {
|
||||
if( test( t.data ) ) {
|
||||
in.bump( t.size );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template< typename Peek, UProperty P, int V >
|
||||
struct property_value
|
||||
{
|
||||
using peek_t = Peek;
|
||||
using data_t = typename Peek::data_t;
|
||||
|
||||
using rule_t = property_value;
|
||||
using subs_t = empty_list;
|
||||
|
||||
[[nodiscard]] static bool test( const data_t c ) noexcept
|
||||
{
|
||||
return u_getIntPropertyValue( c, P ) == V;
|
||||
}
|
||||
|
||||
template< typename ParseInput >
|
||||
[[nodiscard]] static bool match( ParseInput& in ) noexcept( noexcept( Peek::peek( in ) ) )
|
||||
{
|
||||
if( const auto t = Peek::peek( in ) ) {
|
||||
if( test( t.data ) ) {
|
||||
in.bump( t.size );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace icu
|
||||
|
||||
template< typename Peek, UProperty P, bool V >
|
||||
inline constexpr bool enable_control< icu::binary_property< Peek, P, V > > = false;
|
||||
|
||||
template< typename Peek, UProperty P, int V >
|
||||
inline constexpr bool enable_control< icu::property_value< Peek, P, V > > = false;
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template< typename Name, typename Peek, UProperty P, bool V >
|
||||
struct analyze_traits< Name, internal::icu::binary_property< Peek, P, V > >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename Peek, UProperty P, int V >
|
||||
struct analyze_traits< Name, internal::icu::property_value< Peek, P, V > >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,196 +0,0 @@
|
|||
// Copyright (c) 2018-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_ICU_UTF16_HPP
|
||||
#define TAO_PEGTL_CONTRIB_ICU_UTF16_HPP
|
||||
|
||||
#include "internal.hpp"
|
||||
|
||||
#include "../../config.hpp"
|
||||
#include "../utf16.hpp"
|
||||
|
||||
#include "../internal/peek_utf16.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace utf16_be::icu
|
||||
{
|
||||
template< UProperty P, bool V = true >
|
||||
struct binary_property
|
||||
: internal::icu::binary_property< internal::peek_utf16_be, P, V >
|
||||
{};
|
||||
|
||||
template< UProperty P, int V >
|
||||
struct property_value
|
||||
: internal::icu::property_value< internal::peek_utf16_be, P, V >
|
||||
{};
|
||||
|
||||
// clang-format off
|
||||
struct alphabetic : binary_property< UCHAR_ALPHABETIC > {};
|
||||
struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {};
|
||||
struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {};
|
||||
struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {};
|
||||
struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {};
|
||||
struct dash : binary_property< UCHAR_DASH > {};
|
||||
struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {};
|
||||
struct deprecated : binary_property< UCHAR_DEPRECATED > {};
|
||||
struct diacritic : binary_property< UCHAR_DIACRITIC > {};
|
||||
struct extender : binary_property< UCHAR_EXTENDER > {};
|
||||
struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {};
|
||||
struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {};
|
||||
struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {};
|
||||
struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {};
|
||||
struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {};
|
||||
struct hyphen : binary_property< UCHAR_HYPHEN > {};
|
||||
struct id_continue : binary_property< UCHAR_ID_CONTINUE > {};
|
||||
struct id_start : binary_property< UCHAR_ID_START > {};
|
||||
struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {};
|
||||
struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {};
|
||||
struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {};
|
||||
struct join_control : binary_property< UCHAR_JOIN_CONTROL > {};
|
||||
struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {};
|
||||
struct lowercase : binary_property< UCHAR_LOWERCASE > {};
|
||||
struct math : binary_property< UCHAR_MATH > {};
|
||||
struct nfc_inert : binary_property< UCHAR_NFC_INERT > {};
|
||||
struct nfd_inert : binary_property< UCHAR_NFD_INERT > {};
|
||||
struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {};
|
||||
struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {};
|
||||
struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {};
|
||||
struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {};
|
||||
struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {};
|
||||
struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {};
|
||||
struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {};
|
||||
struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {};
|
||||
struct posix_print : binary_property< UCHAR_POSIX_PRINT > {};
|
||||
struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {};
|
||||
struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {};
|
||||
struct radical : binary_property< UCHAR_RADICAL > {};
|
||||
struct s_term : binary_property< UCHAR_S_TERM > {};
|
||||
struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {};
|
||||
struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {};
|
||||
struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {};
|
||||
struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {};
|
||||
struct uppercase : binary_property< UCHAR_UPPERCASE > {};
|
||||
struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {};
|
||||
struct white_space : binary_property< UCHAR_WHITE_SPACE > {};
|
||||
struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {};
|
||||
struct xid_start : binary_property< UCHAR_XID_START > {};
|
||||
|
||||
template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {};
|
||||
template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {};
|
||||
template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {};
|
||||
template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {};
|
||||
template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {};
|
||||
template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {};
|
||||
template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {};
|
||||
template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {};
|
||||
template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {};
|
||||
template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {};
|
||||
// UNormalizationCheckResult requires an additional header <unicode/unorm2.h>:
|
||||
// template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {};
|
||||
// template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {};
|
||||
// template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {};
|
||||
// template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {};
|
||||
template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {};
|
||||
template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {};
|
||||
template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {};
|
||||
|
||||
template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {};
|
||||
template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {};
|
||||
template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace utf16_be::icu
|
||||
|
||||
namespace utf16_le::icu
|
||||
{
|
||||
template< UProperty P, bool V = true >
|
||||
struct binary_property
|
||||
: internal::icu::binary_property< internal::peek_utf16_le, P, V >
|
||||
{};
|
||||
|
||||
template< UProperty P, int V >
|
||||
struct property_value
|
||||
: internal::icu::property_value< internal::peek_utf16_le, P, V >
|
||||
{};
|
||||
|
||||
// clang-format off
|
||||
struct alphabetic : binary_property< UCHAR_ALPHABETIC > {};
|
||||
struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {};
|
||||
struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {};
|
||||
struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {};
|
||||
struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {};
|
||||
struct dash : binary_property< UCHAR_DASH > {};
|
||||
struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {};
|
||||
struct deprecated : binary_property< UCHAR_DEPRECATED > {};
|
||||
struct diacritic : binary_property< UCHAR_DIACRITIC > {};
|
||||
struct extender : binary_property< UCHAR_EXTENDER > {};
|
||||
struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {};
|
||||
struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {};
|
||||
struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {};
|
||||
struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {};
|
||||
struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {};
|
||||
struct hyphen : binary_property< UCHAR_HYPHEN > {};
|
||||
struct id_continue : binary_property< UCHAR_ID_CONTINUE > {};
|
||||
struct id_start : binary_property< UCHAR_ID_START > {};
|
||||
struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {};
|
||||
struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {};
|
||||
struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {};
|
||||
struct join_control : binary_property< UCHAR_JOIN_CONTROL > {};
|
||||
struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {};
|
||||
struct lowercase : binary_property< UCHAR_LOWERCASE > {};
|
||||
struct math : binary_property< UCHAR_MATH > {};
|
||||
struct nfc_inert : binary_property< UCHAR_NFC_INERT > {};
|
||||
struct nfd_inert : binary_property< UCHAR_NFD_INERT > {};
|
||||
struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {};
|
||||
struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {};
|
||||
struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {};
|
||||
struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {};
|
||||
struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {};
|
||||
struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {};
|
||||
struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {};
|
||||
struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {};
|
||||
struct posix_print : binary_property< UCHAR_POSIX_PRINT > {};
|
||||
struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {};
|
||||
struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {};
|
||||
struct radical : binary_property< UCHAR_RADICAL > {};
|
||||
struct s_term : binary_property< UCHAR_S_TERM > {};
|
||||
struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {};
|
||||
struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {};
|
||||
struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {};
|
||||
struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {};
|
||||
struct uppercase : binary_property< UCHAR_UPPERCASE > {};
|
||||
struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {};
|
||||
struct white_space : binary_property< UCHAR_WHITE_SPACE > {};
|
||||
struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {};
|
||||
struct xid_start : binary_property< UCHAR_XID_START > {};
|
||||
|
||||
template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {};
|
||||
template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {};
|
||||
template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {};
|
||||
template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {};
|
||||
template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {};
|
||||
template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {};
|
||||
template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {};
|
||||
template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {};
|
||||
template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {};
|
||||
template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {};
|
||||
// UNormalizationCheckResult requires an additional header <unicode/unorm2.h>:
|
||||
// template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {};
|
||||
// template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {};
|
||||
// template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {};
|
||||
// template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {};
|
||||
template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {};
|
||||
template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {};
|
||||
template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {};
|
||||
|
||||
template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {};
|
||||
template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {};
|
||||
template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace utf16_le::icu
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,196 +0,0 @@
|
|||
// Copyright (c) 2018-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_ICU_UTF32_HPP
|
||||
#define TAO_PEGTL_CONTRIB_ICU_UTF32_HPP
|
||||
|
||||
#include "internal.hpp"
|
||||
|
||||
#include "../../config.hpp"
|
||||
#include "../utf32.hpp"
|
||||
|
||||
#include "../internal/peek_utf32.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace utf32_be::icu
|
||||
{
|
||||
template< UProperty P, bool V = true >
|
||||
struct binary_property
|
||||
: internal::icu::binary_property< internal::peek_utf32_be, P, V >
|
||||
{};
|
||||
|
||||
template< UProperty P, int V >
|
||||
struct property_value
|
||||
: internal::icu::property_value< internal::peek_utf32_be, P, V >
|
||||
{};
|
||||
|
||||
// clang-format off
|
||||
struct alphabetic : binary_property< UCHAR_ALPHABETIC > {};
|
||||
struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {};
|
||||
struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {};
|
||||
struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {};
|
||||
struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {};
|
||||
struct dash : binary_property< UCHAR_DASH > {};
|
||||
struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {};
|
||||
struct deprecated : binary_property< UCHAR_DEPRECATED > {};
|
||||
struct diacritic : binary_property< UCHAR_DIACRITIC > {};
|
||||
struct extender : binary_property< UCHAR_EXTENDER > {};
|
||||
struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {};
|
||||
struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {};
|
||||
struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {};
|
||||
struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {};
|
||||
struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {};
|
||||
struct hyphen : binary_property< UCHAR_HYPHEN > {};
|
||||
struct id_continue : binary_property< UCHAR_ID_CONTINUE > {};
|
||||
struct id_start : binary_property< UCHAR_ID_START > {};
|
||||
struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {};
|
||||
struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {};
|
||||
struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {};
|
||||
struct join_control : binary_property< UCHAR_JOIN_CONTROL > {};
|
||||
struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {};
|
||||
struct lowercase : binary_property< UCHAR_LOWERCASE > {};
|
||||
struct math : binary_property< UCHAR_MATH > {};
|
||||
struct nfc_inert : binary_property< UCHAR_NFC_INERT > {};
|
||||
struct nfd_inert : binary_property< UCHAR_NFD_INERT > {};
|
||||
struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {};
|
||||
struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {};
|
||||
struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {};
|
||||
struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {};
|
||||
struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {};
|
||||
struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {};
|
||||
struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {};
|
||||
struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {};
|
||||
struct posix_print : binary_property< UCHAR_POSIX_PRINT > {};
|
||||
struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {};
|
||||
struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {};
|
||||
struct radical : binary_property< UCHAR_RADICAL > {};
|
||||
struct s_term : binary_property< UCHAR_S_TERM > {};
|
||||
struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {};
|
||||
struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {};
|
||||
struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {};
|
||||
struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {};
|
||||
struct uppercase : binary_property< UCHAR_UPPERCASE > {};
|
||||
struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {};
|
||||
struct white_space : binary_property< UCHAR_WHITE_SPACE > {};
|
||||
struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {};
|
||||
struct xid_start : binary_property< UCHAR_XID_START > {};
|
||||
|
||||
template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {};
|
||||
template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {};
|
||||
template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {};
|
||||
template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {};
|
||||
template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {};
|
||||
template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {};
|
||||
template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {};
|
||||
template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {};
|
||||
template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {};
|
||||
template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {};
|
||||
// UNormalizationCheckResult requires an additional header <unicode/unorm2.h>:
|
||||
// template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {};
|
||||
// template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {};
|
||||
// template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {};
|
||||
// template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {};
|
||||
template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {};
|
||||
template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {};
|
||||
template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {};
|
||||
|
||||
template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {};
|
||||
template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {};
|
||||
template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace utf32_be::icu
|
||||
|
||||
namespace utf32_le::icu
|
||||
{
|
||||
template< UProperty P, bool V = true >
|
||||
struct binary_property
|
||||
: internal::icu::binary_property< internal::peek_utf32_le, P, V >
|
||||
{};
|
||||
|
||||
template< UProperty P, int V >
|
||||
struct property_value
|
||||
: internal::icu::property_value< internal::peek_utf32_le, P, V >
|
||||
{};
|
||||
|
||||
// clang-format off
|
||||
struct alphabetic : binary_property< UCHAR_ALPHABETIC > {};
|
||||
struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {};
|
||||
struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {};
|
||||
struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {};
|
||||
struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {};
|
||||
struct dash : binary_property< UCHAR_DASH > {};
|
||||
struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {};
|
||||
struct deprecated : binary_property< UCHAR_DEPRECATED > {};
|
||||
struct diacritic : binary_property< UCHAR_DIACRITIC > {};
|
||||
struct extender : binary_property< UCHAR_EXTENDER > {};
|
||||
struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {};
|
||||
struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {};
|
||||
struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {};
|
||||
struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {};
|
||||
struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {};
|
||||
struct hyphen : binary_property< UCHAR_HYPHEN > {};
|
||||
struct id_continue : binary_property< UCHAR_ID_CONTINUE > {};
|
||||
struct id_start : binary_property< UCHAR_ID_START > {};
|
||||
struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {};
|
||||
struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {};
|
||||
struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {};
|
||||
struct join_control : binary_property< UCHAR_JOIN_CONTROL > {};
|
||||
struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {};
|
||||
struct lowercase : binary_property< UCHAR_LOWERCASE > {};
|
||||
struct math : binary_property< UCHAR_MATH > {};
|
||||
struct nfc_inert : binary_property< UCHAR_NFC_INERT > {};
|
||||
struct nfd_inert : binary_property< UCHAR_NFD_INERT > {};
|
||||
struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {};
|
||||
struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {};
|
||||
struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {};
|
||||
struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {};
|
||||
struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {};
|
||||
struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {};
|
||||
struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {};
|
||||
struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {};
|
||||
struct posix_print : binary_property< UCHAR_POSIX_PRINT > {};
|
||||
struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {};
|
||||
struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {};
|
||||
struct radical : binary_property< UCHAR_RADICAL > {};
|
||||
struct s_term : binary_property< UCHAR_S_TERM > {};
|
||||
struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {};
|
||||
struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {};
|
||||
struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {};
|
||||
struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {};
|
||||
struct uppercase : binary_property< UCHAR_UPPERCASE > {};
|
||||
struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {};
|
||||
struct white_space : binary_property< UCHAR_WHITE_SPACE > {};
|
||||
struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {};
|
||||
struct xid_start : binary_property< UCHAR_XID_START > {};
|
||||
|
||||
template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {};
|
||||
template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {};
|
||||
template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {};
|
||||
template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {};
|
||||
template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {};
|
||||
template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {};
|
||||
template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {};
|
||||
template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {};
|
||||
template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {};
|
||||
template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {};
|
||||
// UNormalizationCheckResult requires an additional header <unicode/unorm2.h>:
|
||||
// template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {};
|
||||
// template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {};
|
||||
// template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {};
|
||||
// template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {};
|
||||
template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {};
|
||||
template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {};
|
||||
template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {};
|
||||
|
||||
template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {};
|
||||
template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {};
|
||||
template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace utf32_le::icu
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,103 +0,0 @@
|
|||
// Copyright (c) 2018-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_ICU_UTF8_HPP
|
||||
#define TAO_PEGTL_CONTRIB_ICU_UTF8_HPP
|
||||
|
||||
#include "internal.hpp"
|
||||
|
||||
#include "../../config.hpp"
|
||||
#include "../../utf8.hpp"
|
||||
|
||||
#include "../../internal/peek_utf8.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::utf8::icu
|
||||
{
|
||||
template< UProperty P, bool V = true >
|
||||
struct binary_property
|
||||
: internal::icu::binary_property< internal::peek_utf8, P, V >
|
||||
{};
|
||||
|
||||
template< UProperty P, int V >
|
||||
struct property_value
|
||||
: internal::icu::property_value< internal::peek_utf8, P, V >
|
||||
{};
|
||||
|
||||
// clang-format off
|
||||
struct alphabetic : binary_property< UCHAR_ALPHABETIC > {};
|
||||
struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {};
|
||||
struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {};
|
||||
struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {};
|
||||
struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {};
|
||||
struct dash : binary_property< UCHAR_DASH > {};
|
||||
struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {};
|
||||
struct deprecated : binary_property< UCHAR_DEPRECATED > {};
|
||||
struct diacritic : binary_property< UCHAR_DIACRITIC > {};
|
||||
struct extender : binary_property< UCHAR_EXTENDER > {};
|
||||
struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {};
|
||||
struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {};
|
||||
struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {};
|
||||
struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {};
|
||||
struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {};
|
||||
struct hyphen : binary_property< UCHAR_HYPHEN > {};
|
||||
struct id_continue : binary_property< UCHAR_ID_CONTINUE > {};
|
||||
struct id_start : binary_property< UCHAR_ID_START > {};
|
||||
struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {};
|
||||
struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {};
|
||||
struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {};
|
||||
struct join_control : binary_property< UCHAR_JOIN_CONTROL > {};
|
||||
struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {};
|
||||
struct lowercase : binary_property< UCHAR_LOWERCASE > {};
|
||||
struct math : binary_property< UCHAR_MATH > {};
|
||||
struct nfc_inert : binary_property< UCHAR_NFC_INERT > {};
|
||||
struct nfd_inert : binary_property< UCHAR_NFD_INERT > {};
|
||||
struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {};
|
||||
struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {};
|
||||
struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {};
|
||||
struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {};
|
||||
struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {};
|
||||
struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {};
|
||||
struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {};
|
||||
struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {};
|
||||
struct posix_print : binary_property< UCHAR_POSIX_PRINT > {};
|
||||
struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {};
|
||||
struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {};
|
||||
struct radical : binary_property< UCHAR_RADICAL > {};
|
||||
struct s_term : binary_property< UCHAR_S_TERM > {};
|
||||
struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {};
|
||||
struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {};
|
||||
struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {};
|
||||
struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {};
|
||||
struct uppercase : binary_property< UCHAR_UPPERCASE > {};
|
||||
struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {};
|
||||
struct white_space : binary_property< UCHAR_WHITE_SPACE > {};
|
||||
struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {};
|
||||
struct xid_start : binary_property< UCHAR_XID_START > {};
|
||||
|
||||
template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {};
|
||||
template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {};
|
||||
template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {};
|
||||
template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {};
|
||||
template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {};
|
||||
template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {};
|
||||
template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {};
|
||||
template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {};
|
||||
template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {};
|
||||
template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {};
|
||||
// UNormalizationCheckResult requires an additional header <unicode/unorm2.h>:
|
||||
// template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {};
|
||||
// template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {};
|
||||
// template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {};
|
||||
// template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {};
|
||||
template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {};
|
||||
template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {};
|
||||
template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {};
|
||||
|
||||
template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {};
|
||||
template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {};
|
||||
template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::utf8::icu
|
||||
|
||||
#endif
|
|
@ -1,56 +0,0 @@
|
|||
// Copyright (c) 2018-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_IF_THEN_HPP
|
||||
#define TAO_PEGTL_CONTRIB_IF_THEN_HPP
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "../config.hpp"
|
||||
|
||||
#include "../internal/enable_control.hpp"
|
||||
#include "../internal/failure.hpp"
|
||||
#include "../internal/if_then_else.hpp"
|
||||
#include "../internal/seq.hpp"
|
||||
#include "../internal/success.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
template< typename Cond, typename Then >
|
||||
struct if_pair
|
||||
{};
|
||||
|
||||
template< typename... Pairs >
|
||||
struct if_then;
|
||||
|
||||
template< typename Cond, typename Then, typename... Pairs >
|
||||
struct if_then< if_pair< Cond, Then >, Pairs... >
|
||||
: if_then_else< Cond, Then, if_then< Pairs... > >
|
||||
{
|
||||
template< typename ElseCond, typename... Thens >
|
||||
using else_if_then = if_then< if_pair< Cond, Then >, Pairs..., if_pair< ElseCond, seq< Thens... > > >;
|
||||
|
||||
template< typename... Thens >
|
||||
using else_then = if_then_else< Cond, Then, if_then< Pairs..., if_pair< success, seq< Thens... > > > >;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct if_then<>
|
||||
: failure
|
||||
{};
|
||||
|
||||
template< typename... Pairs >
|
||||
inline constexpr bool enable_control< if_then< Pairs... > > = false;
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template< typename Cond, typename... Thens >
|
||||
struct if_then
|
||||
: internal::if_then< internal::if_pair< Cond, internal::seq< Thens... > > >
|
||||
{};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,38 +0,0 @@
|
|||
// Copyright (c) 2020-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_INSTANTIATE_HPP
|
||||
#define TAO_PEGTL_CONTRIB_INSTANTIATE_HPP
|
||||
|
||||
#include "../config.hpp"
|
||||
|
||||
#include "../apply_mode.hpp"
|
||||
#include "../match.hpp"
|
||||
#include "../nothing.hpp"
|
||||
#include "../rewind_mode.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
template< typename T >
|
||||
struct instantiate
|
||||
: maybe_nothing
|
||||
{
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
const T t( static_cast< const ParseInput& >( in ), st... );
|
||||
return TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, st... );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,468 +0,0 @@
|
|||
// Copyright (c) 2019-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_INTEGER_HPP
|
||||
#define TAO_PEGTL_CONTRIB_INTEGER_HPP
|
||||
|
||||
#if !defined( __cpp_exceptions )
|
||||
#error "Exception support required for tao/pegtl/contrib/integer.hpp"
|
||||
#else
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <limits>
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
|
||||
#include "../ascii.hpp"
|
||||
#include "../parse.hpp"
|
||||
#include "../parse_error.hpp"
|
||||
#include "../rules.hpp"
|
||||
|
||||
#include "analyze_traits.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
struct unsigned_rule_old
|
||||
: plus< digit >
|
||||
{
|
||||
// Pre-3.0 version of this rule.
|
||||
};
|
||||
|
||||
struct unsigned_rule_new
|
||||
: if_then_else< one< '0' >, not_at< digit >, plus< digit > >
|
||||
{
|
||||
// New version that does not allow leading zeros.
|
||||
};
|
||||
|
||||
struct signed_rule_old
|
||||
: seq< opt< one< '-', '+' > >, plus< digit > >
|
||||
{
|
||||
// Pre-3.0 version of this rule.
|
||||
};
|
||||
|
||||
struct signed_rule_new
|
||||
: seq< opt< one< '-', '+' > >, if_then_else< one< '0' >, not_at< digit >, plus< digit > > >
|
||||
{
|
||||
// New version that does not allow leading zeros.
|
||||
};
|
||||
|
||||
struct signed_rule_bis
|
||||
: seq< opt< one< '-' > >, if_then_else< one< '0' >, not_at< digit >, plus< digit > > >
|
||||
{};
|
||||
|
||||
struct signed_rule_ter
|
||||
: seq< one< '-', '+' >, if_then_else< one< '0' >, not_at< digit >, plus< digit > > >
|
||||
{};
|
||||
|
||||
namespace internal
|
||||
{
|
||||
[[nodiscard]] constexpr bool is_digit( const char c ) noexcept
|
||||
{
|
||||
// We don't use std::isdigit() because it might
|
||||
// return true for other values on MS platforms.
|
||||
|
||||
return ( '0' <= c ) && ( c <= '9' );
|
||||
}
|
||||
|
||||
template< typename Integer, Integer Maximum = ( std::numeric_limits< Integer >::max )() >
|
||||
[[nodiscard]] constexpr bool accumulate_digit( Integer& result, const char digit ) noexcept
|
||||
{
|
||||
// Assumes that digit is a digit as per is_digit(); returns false on overflow.
|
||||
|
||||
static_assert( std::is_integral_v< Integer > );
|
||||
|
||||
constexpr Integer cutoff = Maximum / 10;
|
||||
constexpr Integer cutlim = Maximum % 10;
|
||||
|
||||
const Integer c = digit - '0';
|
||||
|
||||
if( ( result > cutoff ) || ( ( result == cutoff ) && ( c > cutlim ) ) ) {
|
||||
return false;
|
||||
}
|
||||
result *= 10;
|
||||
result += c;
|
||||
return true;
|
||||
}
|
||||
|
||||
template< typename Integer, Integer Maximum = ( std::numeric_limits< Integer >::max )() >
|
||||
[[nodiscard]] constexpr bool accumulate_digits( Integer& result, const std::string_view input ) noexcept
|
||||
{
|
||||
// Assumes input is a non-empty sequence of digits; returns false on overflow.
|
||||
|
||||
for( char c : input ) {
|
||||
if( !accumulate_digit< Integer, Maximum >( result, c ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template< typename Integer, Integer Maximum = ( std::numeric_limits< Integer >::max )() >
|
||||
[[nodiscard]] constexpr bool convert_positive( Integer& result, const std::string_view input ) noexcept
|
||||
{
|
||||
// Assumes result == 0 and that input is a non-empty sequence of digits; returns false on overflow.
|
||||
|
||||
static_assert( std::is_integral_v< Integer > );
|
||||
return accumulate_digits< Integer, Maximum >( result, input );
|
||||
}
|
||||
|
||||
template< typename Signed >
|
||||
[[nodiscard]] constexpr bool convert_negative( Signed& result, const std::string_view input ) noexcept
|
||||
{
|
||||
// Assumes result == 0 and that input is a non-empty sequence of digits; returns false on overflow.
|
||||
|
||||
static_assert( std::is_signed_v< Signed > );
|
||||
using Unsigned = std::make_unsigned_t< Signed >;
|
||||
constexpr Unsigned maximum = static_cast< Unsigned >( ( std::numeric_limits< Signed >::max )() ) + 1;
|
||||
Unsigned temporary = 0;
|
||||
if( accumulate_digits< Unsigned, maximum >( temporary, input ) ) {
|
||||
result = static_cast< Signed >( ~temporary ) + 1;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template< typename Unsigned, Unsigned Maximum = ( std::numeric_limits< Unsigned >::max )() >
|
||||
[[nodiscard]] constexpr bool convert_unsigned( Unsigned& result, const std::string_view input ) noexcept
|
||||
{
|
||||
// Assumes result == 0 and that input is a non-empty sequence of digits; returns false on overflow.
|
||||
|
||||
static_assert( std::is_unsigned_v< Unsigned > );
|
||||
return accumulate_digits< Unsigned, Maximum >( result, input );
|
||||
}
|
||||
|
||||
template< typename Signed >
|
||||
[[nodiscard]] constexpr bool convert_signed( Signed& result, const std::string_view input ) noexcept
|
||||
{
|
||||
// Assumes result == 0 and that input is an optional sign followed by a non-empty sequence of digits; returns false on overflow.
|
||||
|
||||
static_assert( std::is_signed_v< Signed > );
|
||||
if( input[ 0 ] == '-' ) {
|
||||
return convert_negative< Signed >( result, std::string_view( input.data() + 1, input.size() - 1 ) );
|
||||
}
|
||||
const auto offset = unsigned( input[ 0 ] == '+' );
|
||||
return convert_positive< Signed >( result, std::string_view( input.data() + offset, input.size() - offset ) );
|
||||
}
|
||||
|
||||
template< typename ParseInput >
|
||||
[[nodiscard]] bool match_unsigned( ParseInput& in ) noexcept( noexcept( in.empty() ) )
|
||||
{
|
||||
if( !in.empty() ) {
|
||||
const char c = in.peek_char();
|
||||
if( is_digit( c ) ) {
|
||||
in.bump_in_this_line();
|
||||
if( c == '0' ) {
|
||||
return in.empty() || ( !is_digit( in.peek_char() ) );
|
||||
}
|
||||
while( ( !in.empty() ) && is_digit( in.peek_char() ) ) {
|
||||
in.bump_in_this_line();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template< typename ParseInput,
|
||||
typename Unsigned,
|
||||
Unsigned Maximum = ( std::numeric_limits< Unsigned >::max )() >
|
||||
[[nodiscard]] bool match_and_convert_unsigned_with_maximum_throws( ParseInput& in, Unsigned& st )
|
||||
{
|
||||
// Assumes st == 0.
|
||||
|
||||
if( !in.empty() ) {
|
||||
char c = in.peek_char();
|
||||
if( is_digit( c ) ) {
|
||||
if( c == '0' ) {
|
||||
in.bump_in_this_line();
|
||||
return in.empty() || ( !is_digit( in.peek_char() ) );
|
||||
}
|
||||
do {
|
||||
if( !accumulate_digit< Unsigned, Maximum >( st, c ) ) {
|
||||
throw TAO_PEGTL_NAMESPACE::parse_error( "integer overflow", in );
|
||||
}
|
||||
in.bump_in_this_line();
|
||||
} while( ( !in.empty() ) && is_digit( c = in.peek_char() ) );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template< typename ParseInput,
|
||||
typename Unsigned,
|
||||
Unsigned Maximum = ( std::numeric_limits< Unsigned >::max )() >
|
||||
[[nodiscard]] bool match_and_convert_unsigned_with_maximum_nothrow( ParseInput& in, Unsigned& st )
|
||||
{
|
||||
// Assumes st == 0.
|
||||
|
||||
if( !in.empty() ) {
|
||||
char c = in.peek_char();
|
||||
if( c == '0' ) {
|
||||
if( ( in.size( 2 ) < 2 ) || ( !is_digit( in.peek_char( 1 ) ) ) ) {
|
||||
in.bump_in_this_line();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if( is_digit( c ) ) {
|
||||
unsigned b = 0;
|
||||
|
||||
do {
|
||||
if( !accumulate_digit< Unsigned, Maximum >( st, c ) ) {
|
||||
return false;
|
||||
}
|
||||
++b;
|
||||
} while( ( !in.empty() ) && is_digit( c = in.peek_char( b ) ) );
|
||||
in.bump_in_this_line( b );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
struct unsigned_action
|
||||
{
|
||||
// Assumes that 'in' contains a non-empty sequence of ASCII digits.
|
||||
|
||||
template< typename ActionInput, typename Unsigned >
|
||||
static void apply( const ActionInput& in, Unsigned& st )
|
||||
{
|
||||
// This function "only" offers basic exception safety.
|
||||
st = 0;
|
||||
if( !internal::convert_unsigned( st, in.string_view() ) ) {
|
||||
throw parse_error( "unsigned integer overflow", in );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct unsigned_rule
|
||||
{
|
||||
using rule_t = unsigned_rule;
|
||||
using subs_t = empty_list;
|
||||
|
||||
template< typename ParseInput >
|
||||
[[nodiscard]] static bool match( ParseInput& in ) noexcept( noexcept( in.empty() ) )
|
||||
{
|
||||
return internal::match_unsigned( in ); // Does not check for any overflow.
|
||||
}
|
||||
};
|
||||
|
||||
struct unsigned_rule_with_action
|
||||
{
|
||||
using rule_t = unsigned_rule_with_action;
|
||||
using subs_t = empty_list;
|
||||
|
||||
template< apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static auto match( ParseInput& in, States&&... /*unused*/ ) noexcept( noexcept( in.empty() ) ) -> std::enable_if_t< A == apply_mode::nothing, bool >
|
||||
{
|
||||
return internal::match_unsigned( in ); // Does not check for any overflow.
|
||||
}
|
||||
|
||||
template< apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename Unsigned >
|
||||
[[nodiscard]] static auto match( ParseInput& in, Unsigned& st ) -> std::enable_if_t< ( A == apply_mode::action ) && std::is_unsigned_v< Unsigned >, bool >
|
||||
{
|
||||
// This function "only" offers basic exception safety.
|
||||
st = 0;
|
||||
return internal::match_and_convert_unsigned_with_maximum_throws( in, st ); // Throws on overflow.
|
||||
}
|
||||
};
|
||||
|
||||
template< typename Unsigned, Unsigned Maximum >
|
||||
struct maximum_action
|
||||
{
|
||||
// Assumes that 'in' contains a non-empty sequence of ASCII digits.
|
||||
|
||||
static_assert( std::is_unsigned_v< Unsigned > );
|
||||
|
||||
template< typename ActionInput, typename Unsigned2 >
|
||||
static void apply( const ActionInput& in, Unsigned2& st )
|
||||
{
|
||||
// This function "only" offers basic exception safety.
|
||||
st = 0;
|
||||
if( !internal::convert_unsigned< Unsigned, Maximum >( st, in.string_view() ) ) {
|
||||
throw parse_error( "unsigned integer overflow", in );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template< typename Unsigned, Unsigned Maximum = ( std::numeric_limits< Unsigned >::max )() >
|
||||
struct maximum_rule
|
||||
{
|
||||
using rule_t = maximum_rule;
|
||||
using subs_t = empty_list;
|
||||
|
||||
static_assert( std::is_unsigned_v< Unsigned > );
|
||||
|
||||
template< typename ParseInput >
|
||||
[[nodiscard]] static bool match( ParseInput& in )
|
||||
{
|
||||
Unsigned st = 0;
|
||||
return internal::match_and_convert_unsigned_with_maximum_nothrow< ParseInput, Unsigned, Maximum >( in, st );
|
||||
}
|
||||
};
|
||||
|
||||
template< typename Unsigned, Unsigned Maximum = ( std::numeric_limits< Unsigned >::max )() >
|
||||
struct maximum_rule_with_action
|
||||
{
|
||||
using rule_t = maximum_rule_with_action;
|
||||
using subs_t = empty_list;
|
||||
|
||||
static_assert( std::is_unsigned_v< Unsigned > );
|
||||
|
||||
template< apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static auto match( ParseInput& in, States&&... /*unused*/ ) -> std::enable_if_t< A == apply_mode::nothing, bool >
|
||||
{
|
||||
Unsigned st = 0;
|
||||
return internal::match_and_convert_unsigned_with_maximum_throws< ParseInput, Unsigned, Maximum >( in, st );
|
||||
}
|
||||
|
||||
template< apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename Unsigned2 >
|
||||
[[nodiscard]] static auto match( ParseInput& in, Unsigned2& st ) -> std::enable_if_t< ( A == apply_mode::action ) && std::is_same_v< Unsigned, Unsigned2 >, bool >
|
||||
{
|
||||
// This function "only" offers basic exception safety.
|
||||
st = 0;
|
||||
return internal::match_and_convert_unsigned_with_maximum_throws< ParseInput, Unsigned, Maximum >( in, st );
|
||||
}
|
||||
};
|
||||
|
||||
struct signed_action
|
||||
{
|
||||
// Assumes that 'in' contains a non-empty sequence of ASCII digits,
|
||||
// with optional leading sign; with sign, in.size() must be >= 2.
|
||||
|
||||
template< typename ActionInput, typename Signed >
|
||||
static void apply( const ActionInput& in, Signed& st )
|
||||
{
|
||||
// This function "only" offers basic exception safety.
|
||||
st = 0;
|
||||
if( !internal::convert_signed( st, in.string_view() ) ) {
|
||||
throw parse_error( "signed integer overflow", in );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct signed_rule
|
||||
{
|
||||
using rule_t = signed_rule;
|
||||
using subs_t = empty_list;
|
||||
|
||||
template< typename ParseInput >
|
||||
[[nodiscard]] static bool match( ParseInput& in ) noexcept( noexcept( in.empty() ) )
|
||||
{
|
||||
return TAO_PEGTL_NAMESPACE::parse< signed_rule_new >( in ); // Does not check for any overflow.
|
||||
}
|
||||
};
|
||||
|
||||
namespace internal
|
||||
{
|
||||
template< typename Rule >
|
||||
struct signed_action_action
|
||||
: nothing< Rule >
|
||||
{};
|
||||
|
||||
template<>
|
||||
struct signed_action_action< signed_rule_new >
|
||||
: signed_action
|
||||
{};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
struct signed_rule_with_action
|
||||
{
|
||||
using rule_t = signed_rule_with_action;
|
||||
using subs_t = empty_list;
|
||||
|
||||
template< apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static auto match( ParseInput& in, States&&... /*unused*/ ) noexcept( noexcept( in.empty() ) ) -> std::enable_if_t< A == apply_mode::nothing, bool >
|
||||
{
|
||||
return TAO_PEGTL_NAMESPACE::parse< signed_rule_new >( in ); // Does not check for any overflow.
|
||||
}
|
||||
|
||||
template< apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename Signed >
|
||||
[[nodiscard]] static auto match( ParseInput& in, Signed& st ) -> std::enable_if_t< ( A == apply_mode::action ) && std::is_signed_v< Signed >, bool >
|
||||
{
|
||||
return TAO_PEGTL_NAMESPACE::parse< signed_rule_new, internal::signed_action_action >( in, st ); // Throws on overflow.
|
||||
}
|
||||
};
|
||||
|
||||
template< typename Name >
|
||||
struct analyze_traits< Name, unsigned_rule >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name >
|
||||
struct analyze_traits< Name, unsigned_rule_with_action >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename Integer, Integer Maximum >
|
||||
struct analyze_traits< Name, maximum_rule< Integer, Maximum > >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, typename Integer, Integer Maximum >
|
||||
struct analyze_traits< Name, maximum_rule_with_action< Integer, Maximum > >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name >
|
||||
struct analyze_traits< Name, signed_rule >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name >
|
||||
struct analyze_traits< Name, signed_rule_with_action >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -1,77 +0,0 @@
|
|||
// Copyright (c) 2017-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_INTERNAL_ENDIAN_HPP
|
||||
#define TAO_PEGTL_CONTRIB_INTERNAL_ENDIAN_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
#include "../../config.hpp"
|
||||
|
||||
#if defined( _WIN32 ) && !defined( __MINGW32__ ) && !defined( __CYGWIN__ )
|
||||
#include "endian_win.hpp"
|
||||
#else
|
||||
#include "endian_gcc.hpp"
|
||||
#endif
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::internal
|
||||
{
|
||||
enum class endian
|
||||
{
|
||||
#if defined( _WIN32 )
|
||||
little = 0,
|
||||
big = 1,
|
||||
native = little
|
||||
#elif defined( __BYTE_ORDER__ )
|
||||
little = __ORDER_LITTLE_ENDIAN__,
|
||||
big = __ORDER_BIG_ENDIAN__,
|
||||
native = __BYTE_ORDER__
|
||||
#else
|
||||
#error Unknown endianness.
|
||||
#endif
|
||||
};
|
||||
|
||||
template< typename N >
|
||||
[[nodiscard]] N h_to_be( const N n ) noexcept
|
||||
{
|
||||
return N( to_and_from_be< sizeof( N ) >::convert( n ) );
|
||||
}
|
||||
|
||||
template< typename N >
|
||||
[[nodiscard]] N be_to_h( const N n ) noexcept
|
||||
{
|
||||
return h_to_be( n );
|
||||
}
|
||||
|
||||
template< typename N >
|
||||
[[nodiscard]] N be_to_h( const void* p ) noexcept
|
||||
{
|
||||
N n;
|
||||
std::memcpy( &n, p, sizeof( n ) );
|
||||
return internal::be_to_h( n );
|
||||
}
|
||||
|
||||
template< typename N >
|
||||
[[nodiscard]] N h_to_le( const N n ) noexcept
|
||||
{
|
||||
return N( to_and_from_le< sizeof( N ) >::convert( n ) );
|
||||
}
|
||||
|
||||
template< typename N >
|
||||
[[nodiscard]] N le_to_h( const N n ) noexcept
|
||||
{
|
||||
return h_to_le( n );
|
||||
}
|
||||
|
||||
template< typename N >
|
||||
[[nodiscard]] N le_to_h( const void* p ) noexcept
|
||||
{
|
||||
N n;
|
||||
std::memcpy( &n, p, sizeof( n ) );
|
||||
return internal::le_to_h( n );
|
||||
}
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::internal
|
||||
|
||||
#endif
|
|
@ -1,198 +0,0 @@
|
|||
// Copyright (c) 2017-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_INTERNAL_ENDIAN_GCC_HPP
|
||||
#define TAO_PEGTL_CONTRIB_INTERNAL_ENDIAN_GCC_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::internal
|
||||
{
|
||||
#if !defined( __BYTE_ORDER__ )
|
||||
#error No byte order defined!
|
||||
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
|
||||
template< std::size_t S >
|
||||
struct to_and_from_be
|
||||
{
|
||||
template< typename T >
|
||||
[[nodiscard]] static T convert( const T n ) noexcept
|
||||
{
|
||||
return n;
|
||||
}
|
||||
};
|
||||
|
||||
template< std::size_t S >
|
||||
struct to_and_from_le;
|
||||
|
||||
template<>
|
||||
struct to_and_from_le< 1 >
|
||||
{
|
||||
[[nodiscard]] static std::uint8_t convert( const std::uint8_t n ) noexcept
|
||||
{
|
||||
return n;
|
||||
}
|
||||
|
||||
[[nodiscard]] static std::int8_t convert( const std::int8_t n ) noexcept
|
||||
{
|
||||
return n;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct to_and_from_le< 2 >
|
||||
{
|
||||
[[nodiscard]] static std::int16_t convert( const std::int16_t n ) noexcept
|
||||
{
|
||||
return static_cast< std::int16_t >( __builtin_bswap16( static_cast< std::uint16_t >( n ) ) );
|
||||
}
|
||||
|
||||
[[nodiscard]] static std::uint16_t convert( const std::uint16_t n ) noexcept
|
||||
{
|
||||
return __builtin_bswap16( n );
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct to_and_from_le< 4 >
|
||||
{
|
||||
[[nodiscard]] static float convert( float n ) noexcept
|
||||
{
|
||||
std::uint32_t u;
|
||||
std::memcpy( &u, &n, 4 );
|
||||
u = convert( u );
|
||||
std::memcpy( &n, &u, 4 );
|
||||
return n;
|
||||
}
|
||||
|
||||
[[nodiscard]] static std::int32_t convert( const std::int32_t n ) noexcept
|
||||
{
|
||||
return static_cast< std::int32_t >( __builtin_bswap32( static_cast< std::uint32_t >( n ) ) );
|
||||
}
|
||||
|
||||
[[nodiscard]] static std::uint32_t convert( const std::uint32_t n ) noexcept
|
||||
{
|
||||
return __builtin_bswap32( n );
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct to_and_from_le< 8 >
|
||||
{
|
||||
[[nodiscard]] static double convert( double n ) noexcept
|
||||
{
|
||||
std::uint64_t u;
|
||||
std::memcpy( &u, &n, 8 );
|
||||
u = convert( u );
|
||||
std::memcpy( &n, &u, 8 );
|
||||
return n;
|
||||
}
|
||||
|
||||
[[nodiscard]] static std::int64_t convert( const std::int64_t n ) noexcept
|
||||
{
|
||||
return static_cast< std::int64_t >( __builtin_bswap64( static_cast< std::uint64_t >( n ) ) );
|
||||
}
|
||||
|
||||
[[nodiscard]] static std::uint64_t convert( const std::uint64_t n ) noexcept
|
||||
{
|
||||
return __builtin_bswap64( n );
|
||||
}
|
||||
};
|
||||
|
||||
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
|
||||
template< std::size_t S >
|
||||
struct to_and_from_le
|
||||
{
|
||||
template< typename T >
|
||||
[[nodiscard]] static T convert( const T n ) noexcept
|
||||
{
|
||||
return n;
|
||||
}
|
||||
};
|
||||
|
||||
template< std::size_t S >
|
||||
struct to_and_from_be;
|
||||
|
||||
template<>
|
||||
struct to_and_from_be< 1 >
|
||||
{
|
||||
[[nodiscard]] static std::int8_t convert( const std::int8_t n ) noexcept
|
||||
{
|
||||
return n;
|
||||
}
|
||||
|
||||
[[nodiscard]] static std::uint8_t convert( const std::uint8_t n ) noexcept
|
||||
{
|
||||
return n;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct to_and_from_be< 2 >
|
||||
{
|
||||
[[nodiscard]] static std::int16_t convert( const std::int16_t n ) noexcept
|
||||
{
|
||||
return static_cast< std::int16_t >( __builtin_bswap16( static_cast< std::uint16_t >( n ) ) );
|
||||
}
|
||||
|
||||
[[nodiscard]] static std::uint16_t convert( const std::uint16_t n ) noexcept
|
||||
{
|
||||
return __builtin_bswap16( n );
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct to_and_from_be< 4 >
|
||||
{
|
||||
[[nodiscard]] static float convert( float n ) noexcept
|
||||
{
|
||||
std::uint32_t u;
|
||||
std::memcpy( &u, &n, 4 );
|
||||
u = convert( u );
|
||||
std::memcpy( &n, &u, 4 );
|
||||
return n;
|
||||
}
|
||||
|
||||
[[nodiscard]] static std::int32_t convert( const std::int32_t n ) noexcept
|
||||
{
|
||||
return static_cast< std::int32_t >( __builtin_bswap32( static_cast< std::uint32_t >( n ) ) );
|
||||
}
|
||||
|
||||
[[nodiscard]] static std::uint32_t convert( const std::uint32_t n ) noexcept
|
||||
{
|
||||
return __builtin_bswap32( n );
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct to_and_from_be< 8 >
|
||||
{
|
||||
[[nodiscard]] static double convert( double n ) noexcept
|
||||
{
|
||||
std::uint64_t u;
|
||||
std::memcpy( &u, &n, 8 );
|
||||
u = convert( u );
|
||||
std::memcpy( &n, &u, 8 );
|
||||
return n;
|
||||
}
|
||||
|
||||
[[nodiscard]] static std::int64_t convert( const std::int64_t n ) noexcept
|
||||
{
|
||||
return static_cast< std::int64_t >( __builtin_bswap64( static_cast< std::uint64_t >( n ) ) );
|
||||
}
|
||||
|
||||
[[nodiscard]] static std::uint64_t convert( const std::uint64_t n ) noexcept
|
||||
{
|
||||
return __builtin_bswap64( n );
|
||||
}
|
||||
};
|
||||
|
||||
#else
|
||||
#error Unknown host byte order!
|
||||
#endif
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::internal
|
||||
|
||||
#endif
|
|
@ -1,102 +0,0 @@
|
|||
// Copyright (c) 2017-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_INTERNAL_ENDIAN_WIN_HPP
|
||||
#define TAO_PEGTL_CONTRIB_INTERNAL_ENDIAN_WIN_HPP
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::internal
|
||||
{
|
||||
template< std::size_t S >
|
||||
struct to_and_from_le
|
||||
{
|
||||
template< typename T >
|
||||
[[nodiscard]] static T convert( const T t ) noexcept
|
||||
{
|
||||
return t;
|
||||
}
|
||||
};
|
||||
|
||||
template< std::size_t S >
|
||||
struct to_and_from_be;
|
||||
|
||||
template<>
|
||||
struct to_and_from_be< 1 >
|
||||
{
|
||||
[[nodiscard]] static std::int8_t convert( const std::int8_t n ) noexcept
|
||||
{
|
||||
return n;
|
||||
}
|
||||
|
||||
[[nodiscard]] static std::uint8_t convert( const std::uint8_t n ) noexcept
|
||||
{
|
||||
return n;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct to_and_from_be< 2 >
|
||||
{
|
||||
[[nodiscard]] static std::int16_t convert( const std::int16_t n ) noexcept
|
||||
{
|
||||
return std::int16_t( _byteswap_ushort( std::uint16_t( n ) ) );
|
||||
}
|
||||
|
||||
[[nodiscard]] static std::uint16_t convert( const std::uint16_t n ) noexcept
|
||||
{
|
||||
return _byteswap_ushort( n );
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct to_and_from_be< 4 >
|
||||
{
|
||||
[[nodiscard]] static float convert( float n ) noexcept
|
||||
{
|
||||
std::uint32_t u;
|
||||
std::memcpy( &u, &n, 4 );
|
||||
u = convert( u );
|
||||
std::memcpy( &n, &u, 4 );
|
||||
return n;
|
||||
}
|
||||
|
||||
[[nodiscard]] static std::int32_t convert( const std::int32_t n ) noexcept
|
||||
{
|
||||
return std::int32_t( _byteswap_ulong( std::uint32_t( n ) ) );
|
||||
}
|
||||
|
||||
[[nodiscard]] static std::uint32_t convert( const std::uint32_t n ) noexcept
|
||||
{
|
||||
return _byteswap_ulong( n );
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct to_and_from_be< 8 >
|
||||
{
|
||||
[[nodiscard]] static double convert( double n ) noexcept
|
||||
{
|
||||
std::uint64_t u;
|
||||
std::memcpy( &u, &n, 8 );
|
||||
u = convert( u );
|
||||
std::memcpy( &n, &u, 8 );
|
||||
return n;
|
||||
}
|
||||
|
||||
[[nodiscard]] static std::int64_t convert( const std::int64_t n ) noexcept
|
||||
{
|
||||
return std::int64_t( _byteswap_uint64( std::uint64_t( n ) ) );
|
||||
}
|
||||
|
||||
[[nodiscard]] static std::uint64_t convert( const std::uint64_t n ) noexcept
|
||||
{
|
||||
return _byteswap_uint64( n );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::internal
|
||||
|
||||
#endif
|
|
@ -1,54 +0,0 @@
|
|||
// Copyright (c) 2018-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_INTERNAL_PEEK_MASK_UINT_HPP
|
||||
#define TAO_PEGTL_CONTRIB_INTERNAL_PEEK_MASK_UINT_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "../../config.hpp"
|
||||
#include "../../internal/input_pair.hpp"
|
||||
|
||||
#include "read_uint.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::internal
|
||||
{
|
||||
template< typename R, typename R::type M >
|
||||
struct peek_mask_uint_impl
|
||||
{
|
||||
using data_t = typename R::type;
|
||||
using pair_t = input_pair< data_t >;
|
||||
|
||||
template< typename ParseInput >
|
||||
[[nodiscard]] static pair_t peek( ParseInput& in ) noexcept( noexcept( in.size( sizeof( data_t ) ) ) )
|
||||
{
|
||||
if( in.size( sizeof( data_t ) ) < sizeof( data_t ) ) {
|
||||
return { 0, 0 };
|
||||
}
|
||||
const data_t data = R::read( in.current() ) & M;
|
||||
return { data, sizeof( data_t ) };
|
||||
}
|
||||
};
|
||||
|
||||
template< std::uint16_t M >
|
||||
using peek_mask_uint16_be = peek_mask_uint_impl< read_uint16_be, M >;
|
||||
|
||||
template< std::uint16_t M >
|
||||
using peek_mask_uint16_le = peek_mask_uint_impl< read_uint16_le, M >;
|
||||
|
||||
template< std::uint32_t M >
|
||||
using peek_mask_uint32_be = peek_mask_uint_impl< read_uint32_be, M >;
|
||||
|
||||
template< std::uint32_t M >
|
||||
using peek_mask_uint32_le = peek_mask_uint_impl< read_uint32_le, M >;
|
||||
|
||||
template< std::uint64_t M >
|
||||
using peek_mask_uint64_be = peek_mask_uint_impl< read_uint64_be, M >;
|
||||
|
||||
template< std::uint64_t M >
|
||||
using peek_mask_uint64_le = peek_mask_uint_impl< read_uint64_le, M >;
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::internal
|
||||
|
||||
#endif
|
|
@ -1,33 +0,0 @@
|
|||
// Copyright (c) 2018-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_INTERNAL_PEEK_MASK_UINT8_HPP
|
||||
#define TAO_PEGTL_CONTRIB_INTERNAL_PEEK_MASK_UINT8_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "../../config.hpp"
|
||||
#include "../../internal/input_pair.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::internal
|
||||
{
|
||||
template< std::uint8_t M >
|
||||
struct peek_mask_uint8
|
||||
{
|
||||
using data_t = std::uint8_t;
|
||||
using pair_t = input_pair< std::uint8_t >;
|
||||
|
||||
template< typename ParseInput >
|
||||
[[nodiscard]] static pair_t peek( ParseInput& in ) noexcept( noexcept( in.empty() ) )
|
||||
{
|
||||
if( in.empty() ) {
|
||||
return { 0, 0 };
|
||||
}
|
||||
return { std::uint8_t( in.peek_uint8() & M ), 1 };
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::internal
|
||||
|
||||
#endif
|
|
@ -1,45 +0,0 @@
|
|||
// Copyright (c) 2018-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_INTERNAL_PEEK_UINT_HPP
|
||||
#define TAO_PEGTL_CONTRIB_INTERNAL_PEEK_UINT_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "../../config.hpp"
|
||||
#include "../../internal/input_pair.hpp"
|
||||
|
||||
#include "read_uint.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::internal
|
||||
{
|
||||
template< typename R >
|
||||
struct peek_uint_impl
|
||||
{
|
||||
using data_t = typename R::type;
|
||||
using pair_t = input_pair< data_t >;
|
||||
|
||||
template< typename ParseInput >
|
||||
[[nodiscard]] static pair_t peek( ParseInput& in ) noexcept( noexcept( in.size( sizeof( data_t ) ) ) )
|
||||
{
|
||||
if( in.size( sizeof( data_t ) ) < sizeof( data_t ) ) {
|
||||
return { 0, 0 };
|
||||
}
|
||||
const data_t data = R::read( in.current() );
|
||||
return { data, sizeof( data_t ) };
|
||||
}
|
||||
};
|
||||
|
||||
using peek_uint16_be = peek_uint_impl< read_uint16_be >;
|
||||
using peek_uint16_le = peek_uint_impl< read_uint16_le >;
|
||||
|
||||
using peek_uint32_be = peek_uint_impl< read_uint32_be >;
|
||||
using peek_uint32_le = peek_uint_impl< read_uint32_le >;
|
||||
|
||||
using peek_uint64_be = peek_uint_impl< read_uint64_be >;
|
||||
using peek_uint64_le = peek_uint_impl< read_uint64_le >;
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::internal
|
||||
|
||||
#endif
|
|
@ -1,32 +0,0 @@
|
|||
// Copyright (c) 2018-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_INTERNAL_PEEK_UINT8_HPP
|
||||
#define TAO_PEGTL_CONTRIB_INTERNAL_PEEK_UINT8_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "../../config.hpp"
|
||||
#include "../../internal/input_pair.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::internal
|
||||
{
|
||||
struct peek_uint8
|
||||
{
|
||||
using data_t = std::uint8_t;
|
||||
using pair_t = input_pair< std::uint8_t >;
|
||||
|
||||
template< typename ParseInput >
|
||||
[[nodiscard]] static pair_t peek( ParseInput& in ) noexcept( noexcept( in.empty() ) )
|
||||
{
|
||||
if( in.empty() ) {
|
||||
return { 0, 0 };
|
||||
}
|
||||
return { in.peek_uint8(), 1 };
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::internal
|
||||
|
||||
#endif
|
|
@ -1,54 +0,0 @@
|
|||
// Copyright (c) 2014-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_INTERNAL_PEEK_UTF16_HPP
|
||||
#define TAO_PEGTL_CONTRIB_INTERNAL_PEEK_UTF16_HPP
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "../../config.hpp"
|
||||
#include "../../internal/input_pair.hpp"
|
||||
|
||||
#include "read_uint.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::internal
|
||||
{
|
||||
template< typename R >
|
||||
struct peek_utf16_impl
|
||||
{
|
||||
using data_t = char32_t;
|
||||
using pair_t = input_pair< char32_t >;
|
||||
|
||||
using short_t = std::make_unsigned< char16_t >::type;
|
||||
|
||||
static_assert( sizeof( short_t ) == 2 );
|
||||
static_assert( sizeof( char16_t ) == 2 );
|
||||
|
||||
template< typename ParseInput >
|
||||
[[nodiscard]] static pair_t peek( ParseInput& in ) noexcept( noexcept( in.size( 4 ) ) )
|
||||
{
|
||||
if( in.size( 2 ) < 2 ) {
|
||||
return { 0, 0 };
|
||||
}
|
||||
const char32_t t = R::read( in.current() );
|
||||
if( ( t < 0xd800 ) || ( t > 0xdfff ) ) {
|
||||
return { t, 2 };
|
||||
}
|
||||
if( ( t >= 0xdc00 ) || ( in.size( 4 ) < 4 ) ) {
|
||||
return { 0, 0 };
|
||||
}
|
||||
const char32_t u = R::read( in.current() + 2 );
|
||||
if( ( u >= 0xdc00 ) && ( u <= 0xdfff ) ) {
|
||||
const auto cp = ( ( ( t & 0x03ff ) << 10 ) | ( u & 0x03ff ) ) + 0x10000;
|
||||
return { cp, 4 };
|
||||
}
|
||||
return { 0, 0 };
|
||||
}
|
||||
};
|
||||
|
||||
using peek_utf16_be = peek_utf16_impl< read_uint16_be >;
|
||||
using peek_utf16_le = peek_utf16_impl< read_uint16_le >;
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::internal
|
||||
|
||||
#endif
|
|
@ -1,43 +0,0 @@
|
|||
// Copyright (c) 2014-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_INTERNAL_PEEK_UTF32_HPP
|
||||
#define TAO_PEGTL_CONTRIB_INTERNAL_PEEK_UTF32_HPP
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "../../config.hpp"
|
||||
#include "../../internal/input_pair.hpp"
|
||||
|
||||
#include "read_uint.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::internal
|
||||
{
|
||||
template< typename R >
|
||||
struct peek_utf32_impl
|
||||
{
|
||||
using data_t = char32_t;
|
||||
using pair_t = input_pair< char32_t >;
|
||||
|
||||
static_assert( sizeof( char32_t ) == 4 );
|
||||
|
||||
template< typename ParseInput >
|
||||
[[nodiscard]] static pair_t peek( ParseInput& in ) noexcept( noexcept( in.size( 4 ) ) )
|
||||
{
|
||||
if( in.size( 4 ) < 4 ) {
|
||||
return { 0, 0 };
|
||||
}
|
||||
const char32_t t = R::read( in.current() );
|
||||
if( ( t <= 0x10ffff ) && !( t >= 0xd800 && t <= 0xdfff ) ) {
|
||||
return { t, 4 };
|
||||
}
|
||||
return { 0, 0 };
|
||||
}
|
||||
};
|
||||
|
||||
using peek_utf32_be = peek_utf32_impl< read_uint32_be >;
|
||||
using peek_utf32_le = peek_utf32_impl< read_uint32_le >;
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::internal
|
||||
|
||||
#endif
|
|
@ -1,77 +0,0 @@
|
|||
// Copyright (c) 2018-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_INTERNAL_READ_UINT_HPP
|
||||
#define TAO_PEGTL_CONTRIB_INTERNAL_READ_UINT_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "../../config.hpp"
|
||||
|
||||
#include "endian.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::internal
|
||||
{
|
||||
struct read_uint16_be
|
||||
{
|
||||
using type = std::uint16_t;
|
||||
|
||||
[[nodiscard]] static std::uint16_t read( const void* d ) noexcept
|
||||
{
|
||||
return be_to_h< std::uint16_t >( d );
|
||||
}
|
||||
};
|
||||
|
||||
struct read_uint16_le
|
||||
{
|
||||
using type = std::uint16_t;
|
||||
|
||||
[[nodiscard]] static std::uint16_t read( const void* d ) noexcept
|
||||
{
|
||||
return le_to_h< std::uint16_t >( d );
|
||||
}
|
||||
};
|
||||
|
||||
struct read_uint32_be
|
||||
{
|
||||
using type = std::uint32_t;
|
||||
|
||||
[[nodiscard]] static std::uint32_t read( const void* d ) noexcept
|
||||
{
|
||||
return be_to_h< std::uint32_t >( d );
|
||||
}
|
||||
};
|
||||
|
||||
struct read_uint32_le
|
||||
{
|
||||
using type = std::uint32_t;
|
||||
|
||||
[[nodiscard]] static std::uint32_t read( const void* d ) noexcept
|
||||
{
|
||||
return le_to_h< std::uint32_t >( d );
|
||||
}
|
||||
};
|
||||
|
||||
struct read_uint64_be
|
||||
{
|
||||
using type = std::uint64_t;
|
||||
|
||||
[[nodiscard]] static std::uint64_t read( const void* d ) noexcept
|
||||
{
|
||||
return be_to_h< std::uint64_t >( d );
|
||||
}
|
||||
};
|
||||
|
||||
struct read_uint64_le
|
||||
{
|
||||
using type = std::uint64_t;
|
||||
|
||||
[[nodiscard]] static std::uint64_t read( const void* d ) noexcept
|
||||
{
|
||||
return le_to_h< std::uint64_t >( d );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::internal
|
||||
|
||||
#endif
|
|
@ -1,52 +0,0 @@
|
|||
// Copyright (c) 2020-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_INTERNAL_SET_STACK_GUARD_HPP
|
||||
#define TAO_PEGTL_CONTRIB_INTERNAL_SET_STACK_GUARD_HPP
|
||||
|
||||
#include <set>
|
||||
#include <utility>
|
||||
|
||||
#include "../../config.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::internal
|
||||
{
|
||||
template< typename... Cs >
|
||||
class [[nodiscard]] set_stack_guard
|
||||
{
|
||||
public:
|
||||
template< typename... Ts >
|
||||
set_stack_guard( std::set< Cs... >& set, Ts&&... ts )
|
||||
: m_i( set.emplace( std::forward< Ts >( ts )... ) ),
|
||||
m_s( set )
|
||||
{}
|
||||
|
||||
set_stack_guard( set_stack_guard&& ) = delete;
|
||||
set_stack_guard( const set_stack_guard& ) = delete;
|
||||
|
||||
set_stack_guard& operator=( set_stack_guard&& ) = delete;
|
||||
set_stack_guard& operator=( const set_stack_guard& ) = delete;
|
||||
|
||||
~set_stack_guard()
|
||||
{
|
||||
if( m_i.second ) {
|
||||
m_s.erase( m_i.first );
|
||||
}
|
||||
}
|
||||
|
||||
explicit operator bool() const noexcept
|
||||
{
|
||||
return m_i.second;
|
||||
}
|
||||
|
||||
private:
|
||||
const std::pair< typename std::set< Cs... >::iterator, bool > m_i;
|
||||
std::set< Cs... >& m_s;
|
||||
};
|
||||
|
||||
template< typename... Cs >
|
||||
set_stack_guard( std::set< Cs... >&, const typename std::set< Cs... >::value_type& ) -> set_stack_guard< Cs... >;
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::internal
|
||||
|
||||
#endif
|
|
@ -1,45 +0,0 @@
|
|||
// Copyright (c) 2020-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_INTERNAL_VECTOR_STACK_GUARD_HPP
|
||||
#define TAO_PEGTL_CONTRIB_INTERNAL_VECTOR_STACK_GUARD_HPP
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "../../config.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::internal
|
||||
{
|
||||
template< typename... Cs >
|
||||
class [[nodiscard]] vector_stack_guard
|
||||
{
|
||||
public:
|
||||
template< typename... Ts >
|
||||
vector_stack_guard( std::vector< Cs... >& vector, Ts&&... ts )
|
||||
: m_s( vector )
|
||||
{
|
||||
m_s.emplace_back( std::forward< Ts >( ts )... );
|
||||
}
|
||||
|
||||
vector_stack_guard( vector_stack_guard&& ) = delete;
|
||||
vector_stack_guard( const vector_stack_guard& ) = delete;
|
||||
|
||||
vector_stack_guard& operator=( vector_stack_guard&& ) = delete;
|
||||
vector_stack_guard& operator=( const vector_stack_guard& ) = delete;
|
||||
|
||||
~vector_stack_guard()
|
||||
{
|
||||
m_s.pop_back();
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector< Cs... >& m_s;
|
||||
};
|
||||
|
||||
template< typename... Cs >
|
||||
vector_stack_guard( std::vector< Cs... >&, const typename std::vector< Cs... >::value_type& ) -> vector_stack_guard< Cs... >;
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::internal
|
||||
|
||||
#endif
|
|
@ -1,106 +0,0 @@
|
|||
// Copyright (c) 2021 Kelvin Hammond
|
||||
// Copyright (c) 2021-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_IRI_HPP
|
||||
#define TAO_PEGTL_CONTRIB_IRI_HPP
|
||||
|
||||
#if !defined( __cpp_exceptions )
|
||||
#error "Exception support required for tao/pegtl/contrib/iri.hpp"
|
||||
#else
|
||||
|
||||
#include "../config.hpp"
|
||||
#include "../rules.hpp"
|
||||
#include "../utf8.hpp"
|
||||
|
||||
#include "abnf.hpp"
|
||||
#include "uri.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::iri
|
||||
{
|
||||
// IRI grammar according to RFC 3987.
|
||||
|
||||
// This grammar is a direct PEG translation of the original URI grammar.
|
||||
// It should be considered experimental -- in case of any issues, in particular
|
||||
// missing rules for attached actions, please contact the developers.
|
||||
|
||||
// Note that this grammar has multiple top-level rules.
|
||||
|
||||
using uri::scheme;
|
||||
using uri::port;
|
||||
using uri::dslash;
|
||||
using uri::IP_literal;
|
||||
using uri::IPv4address;
|
||||
using uri::pct_encoded;
|
||||
using uri::sub_delims;
|
||||
using uri::colon;
|
||||
|
||||
// clang-format off
|
||||
struct ucschar : utf8::ranges<
|
||||
0xA0, 0xD7FF,
|
||||
0xF900, 0xFDCF,
|
||||
0xFDF0, 0xFFEF,
|
||||
0x10000, 0x1FFFD,
|
||||
0x20000, 0x2FFFD,
|
||||
0x30000, 0x3FFFD,
|
||||
0x40000, 0x4FFFD,
|
||||
0x50000, 0x5FFFD,
|
||||
0x60000, 0x6FFFD,
|
||||
0x70000, 0x7FFFD,
|
||||
0x80000, 0x8FFFD,
|
||||
0x90000, 0x9FFFD,
|
||||
0xA0000, 0xAFFFD,
|
||||
0xB0000, 0xBFFFD,
|
||||
0xC0000, 0xCFFFD,
|
||||
0xD0000, 0xDFFFD,
|
||||
0xE1000, 0xEFFFD > {};
|
||||
|
||||
struct iprivate : utf8::ranges< 0xE000, 0xF8FF, 0xF0000, 0xFFFFD, 0x100000, 0x10FFFD > {};
|
||||
|
||||
struct iunreserved : sor< abnf::ALPHA, abnf::DIGIT, one< '-', '.', '_', '~' >, ucschar > {};
|
||||
|
||||
struct ipchar : sor< iunreserved, pct_encoded, sub_delims, one< ':', '@' > > {};
|
||||
|
||||
struct isegment : star< ipchar > {};
|
||||
struct isegment_nz : plus< ipchar > {};
|
||||
// non-zero-length segment without any colon ":"
|
||||
struct isegment_nz_nc : plus< sor< iunreserved, pct_encoded, sub_delims, one< '@' > > > {};
|
||||
|
||||
struct ipath_abempty : star< one< '/' >, isegment > {};
|
||||
struct ipath_absolute : seq< one< '/' >, opt< isegment_nz, star< one< '/' >, isegment > > > {};
|
||||
struct ipath_noscheme : seq< isegment_nz_nc, star< one< '/' >, isegment > > {};
|
||||
struct ipath_rootless : seq< isegment_nz, star< one< '/' >, isegment > > {};
|
||||
struct ipath_empty : success {};
|
||||
|
||||
struct ipath : sor< ipath_noscheme, // begins with a non-colon segment
|
||||
ipath_rootless, // begins with a segment
|
||||
ipath_absolute, // begins with "/" but not "//"
|
||||
ipath_abempty > // begins with "/" or is empty
|
||||
{};
|
||||
|
||||
struct ireg_name : star< sor< iunreserved, pct_encoded, sub_delims > > {};
|
||||
|
||||
struct ihost : sor< IP_literal, IPv4address, ireg_name > {};
|
||||
struct iuserinfo : star< sor< iunreserved, pct_encoded, sub_delims, colon > > {};
|
||||
struct opt_iuserinfo : opt< iuserinfo, one< '@' > > {};
|
||||
struct iauthority : seq< opt_iuserinfo, ihost, opt< colon, port > > {};
|
||||
|
||||
struct iquery : star< sor< ipchar, iprivate, one< '/', '?' > > > {};
|
||||
struct ifragment : star< sor< ipchar, one< '/', '?' > > > {};
|
||||
|
||||
struct opt_iquery : opt_must< one< '?' >, iquery > {};
|
||||
struct opt_ifragment : opt_must< one< '#' >, ifragment > {};
|
||||
|
||||
struct ihier_part : sor< if_must< dslash, iauthority, ipath_abempty >, ipath_rootless, ipath_absolute, ipath_empty > {};
|
||||
struct irelative_part : sor< if_must< dslash, iauthority, ipath_abempty >, ipath_noscheme, ipath_absolute, ipath_empty > {};
|
||||
struct irelative_ref : seq< irelative_part, opt_iquery, opt_ifragment > {};
|
||||
|
||||
struct IRI : seq< scheme, one< ':' >, ihier_part, opt_iquery, opt_ifragment > {};
|
||||
struct IRI_reference : sor< IRI, irelative_ref > {};
|
||||
struct absolute_IRI : seq< scheme, one< ':' >, ihier_part, opt_iquery > {};
|
||||
// clang-format off
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::iri
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -1,91 +0,0 @@
|
|||
// Copyright (c) 2014-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_JSON_HPP
|
||||
#define TAO_PEGTL_CONTRIB_JSON_HPP
|
||||
|
||||
#include "../ascii.hpp"
|
||||
#include "../config.hpp"
|
||||
#include "../rules.hpp"
|
||||
#include "../utf8.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::json
|
||||
{
|
||||
// JSON grammar according to RFC 8259
|
||||
|
||||
// clang-format off
|
||||
struct ws : one< ' ', '\t', '\n', '\r' > {};
|
||||
|
||||
template< typename R, typename P = ws >
|
||||
struct padr : seq< R, star< P > > {};
|
||||
|
||||
struct begin_array : padr< one< '[' > > {};
|
||||
struct begin_object : padr< one< '{' > > {};
|
||||
struct end_array : one< ']' > {};
|
||||
struct end_object : one< '}' > {};
|
||||
struct name_separator : pad< one< ':' >, ws > {};
|
||||
struct value_separator : padr< one< ',' > > {};
|
||||
|
||||
struct false_ : string< 'f', 'a', 'l', 's', 'e' > {}; // NOLINT(readability-identifier-naming)
|
||||
struct null : string< 'n', 'u', 'l', 'l' > {};
|
||||
struct true_ : string< 't', 'r', 'u', 'e' > {}; // NOLINT(readability-identifier-naming)
|
||||
|
||||
struct digits : plus< digit > {};
|
||||
struct exp : seq< one< 'e', 'E' >, opt< one< '-', '+'> >, digits > {};
|
||||
struct frac : seq< one< '.' >, digits > {};
|
||||
struct int_ : sor< one< '0' >, plus< digit > > {}; // NOLINT(readability-identifier-naming)
|
||||
struct number : seq< opt< one< '-' > >, int_, opt< frac >, opt< exp > > {};
|
||||
|
||||
struct xdigit : pegtl::xdigit {};
|
||||
struct unicode : list< seq< one< 'u' >, rep< 4, xdigit > >, one< '\\' > > {};
|
||||
struct escaped_char : one< '"', '\\', '/', 'b', 'f', 'n', 'r', 't' > {};
|
||||
struct escaped : sor< escaped_char, unicode > {};
|
||||
struct unescaped : utf8::range< 0x20, 0x10FFFF > {};
|
||||
struct char_ : if_then_else< one< '\\' >, escaped, unescaped > {}; // NOLINT(readability-identifier-naming)
|
||||
|
||||
struct string_content : until< at< one< '"' > >, char_ > {};
|
||||
struct string : seq< one< '"' >, string_content, any >
|
||||
{
|
||||
using content = string_content;
|
||||
};
|
||||
|
||||
struct key_content : until< at< one< '"' > >, char_ > {};
|
||||
struct key : seq< one< '"' >, key_content, any >
|
||||
{
|
||||
using content = key_content;
|
||||
};
|
||||
|
||||
struct value;
|
||||
|
||||
struct array_element;
|
||||
struct next_array_element : seq< array_element > {};
|
||||
struct array_content : opt< array_element, star< value_separator, next_array_element > > {};
|
||||
struct array : seq< begin_array, array_content, end_array >
|
||||
{
|
||||
using begin = begin_array;
|
||||
using end = end_array;
|
||||
using element = array_element;
|
||||
using content = array_content;
|
||||
};
|
||||
|
||||
struct member_value : padr< value > {};
|
||||
struct member : seq< key, name_separator, member_value > {};
|
||||
struct next_member : seq< member > {};
|
||||
struct object_content : opt< member, star< value_separator, next_member > > {};
|
||||
struct object : seq< begin_object, object_content, end_object >
|
||||
{
|
||||
using begin = begin_object;
|
||||
using end = end_object;
|
||||
using element = member;
|
||||
using content = object_content;
|
||||
};
|
||||
|
||||
struct value : sor< string, number, object, array, false_, true_, null > {};
|
||||
struct array_element : padr< value > {};
|
||||
|
||||
struct text : pad< value, ws > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::json
|
||||
|
||||
#endif
|
|
@ -1,33 +0,0 @@
|
|||
// Copyright (c) 2019-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_JSON_POINTER_HPP
|
||||
#define TAO_PEGTL_CONTRIB_JSON_POINTER_HPP
|
||||
|
||||
#include "../ascii.hpp"
|
||||
#include "../config.hpp"
|
||||
#include "../rules.hpp"
|
||||
#include "../utf8.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::json_pointer
|
||||
{
|
||||
// JSON pointer grammar according to RFC 6901
|
||||
|
||||
// clang-format off
|
||||
struct unescaped : utf8::ranges< 0x0, 0x2E, 0x30, 0x7D, 0x7F, 0x10FFFF > {};
|
||||
struct escaped : seq< one< '~' >, one< '0', '1' > > {};
|
||||
|
||||
struct reference_token : star< sor< unescaped, escaped > > {};
|
||||
struct json_pointer : star< one< '/' >, reference_token > {};
|
||||
// clang-format on
|
||||
|
||||
// relative JSON pointer, see ...
|
||||
|
||||
// clang-format off
|
||||
struct non_negative_integer : sor< one< '0' >, plus< digit > > {};
|
||||
struct relative_json_pointer : seq< non_negative_integer, sor< one< '#' >, json_pointer > > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::json_pointer
|
||||
|
||||
#endif
|
|
@ -1,88 +0,0 @@
|
|||
// Copyright (c) 2021-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_LIMIT_BYTES_HPP
|
||||
#define TAO_PEGTL_CONTRIB_LIMIT_BYTES_HPP
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "../apply_mode.hpp"
|
||||
#include "../config.hpp"
|
||||
#include "../match.hpp"
|
||||
#include "../nothing.hpp"
|
||||
#include "../rewind_mode.hpp"
|
||||
|
||||
#if defined( __cpp_exceptions )
|
||||
#include "../parse_error.hpp"
|
||||
#else
|
||||
#include <cstdio>
|
||||
#include <exception>
|
||||
#endif
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
template< std::size_t Maximum, typename MemoryInput >
|
||||
struct [[nodiscard]] bytes_guard
|
||||
{
|
||||
MemoryInput& m_in;
|
||||
const char* m_end;
|
||||
|
||||
explicit bytes_guard( MemoryInput& in_in ) noexcept
|
||||
: m_in( in_in ),
|
||||
m_end( in_in.end() )
|
||||
{
|
||||
m_in.private_set_end( m_in.begin() + std::min( m_in.size(), Maximum ) );
|
||||
}
|
||||
|
||||
bytes_guard( bytes_guard&& ) = delete;
|
||||
bytes_guard( const bytes_guard& ) = delete;
|
||||
|
||||
~bytes_guard()
|
||||
{
|
||||
m_in.private_set_end( m_end );
|
||||
}
|
||||
|
||||
bytes_guard& operator=( bytes_guard&& ) = delete;
|
||||
bytes_guard& operator=( const bytes_guard& ) = delete;
|
||||
};
|
||||
|
||||
// C++17 does not allow for partial deduction guides.
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template< std::size_t Maximum >
|
||||
struct limit_bytes
|
||||
: maybe_nothing
|
||||
{
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
internal::bytes_guard< Maximum, ParseInput > bg( in );
|
||||
if( TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, st... ) ) {
|
||||
if( in.empty() && ( bg.m_end != in.current() ) ) {
|
||||
#if defined( __cpp_exceptions )
|
||||
throw TAO_PEGTL_NAMESPACE::parse_error( "maximum allowed rule consumption reached", in );
|
||||
#else
|
||||
std::fputs( "maximum allowed rule consumption reached\n", stderr );
|
||||
std::terminate();
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,83 +0,0 @@
|
|||
// Copyright (c) 2021-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_LIMIT_DEPTH_HPP
|
||||
#define TAO_PEGTL_CONTRIB_LIMIT_DEPTH_HPP
|
||||
|
||||
#include "../apply_mode.hpp"
|
||||
#include "../config.hpp"
|
||||
#include "../match.hpp"
|
||||
#include "../nothing.hpp"
|
||||
#include "../rewind_mode.hpp"
|
||||
|
||||
#if defined( __cpp_exceptions )
|
||||
#include "../parse_error.hpp"
|
||||
#else
|
||||
#include <cstdio>
|
||||
#include <exception>
|
||||
#endif
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
struct [[nodiscard]] depth_guard
|
||||
{
|
||||
std::size_t& m_depth;
|
||||
|
||||
explicit depth_guard( std::size_t& depth ) noexcept
|
||||
: m_depth( depth )
|
||||
{
|
||||
++m_depth;
|
||||
}
|
||||
|
||||
depth_guard( depth_guard&& ) = delete;
|
||||
depth_guard( const depth_guard& ) = delete;
|
||||
|
||||
~depth_guard()
|
||||
{
|
||||
--m_depth;
|
||||
}
|
||||
|
||||
depth_guard& operator=( depth_guard&& ) = delete;
|
||||
depth_guard& operator=( const depth_guard& ) = delete;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template< std::size_t Maximum >
|
||||
struct limit_depth
|
||||
: maybe_nothing
|
||||
{
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
if constexpr( Control< Rule >::enable ) {
|
||||
const internal::depth_guard dg( in.private_depth );
|
||||
if( in.private_depth > Maximum ) {
|
||||
#if defined( __cpp_exceptions )
|
||||
throw TAO_PEGTL_NAMESPACE::parse_error( "maximum parser rule nesting depth exceeded", in );
|
||||
#else
|
||||
std::fputs( "maximum parser rule nesting depth exceeded\n", stderr );
|
||||
std::terminate();
|
||||
#endif
|
||||
}
|
||||
return TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, st... );
|
||||
}
|
||||
else {
|
||||
return TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, st... );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,456 +0,0 @@
|
|||
// Copyright (c) 2017-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_PARSE_TREE_HPP
|
||||
#define TAO_PEGTL_CONTRIB_PARSE_TREE_HPP
|
||||
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <typeindex>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "remove_first_state.hpp"
|
||||
#include "shuffle_states.hpp"
|
||||
|
||||
#include "../apply_mode.hpp"
|
||||
#include "../config.hpp"
|
||||
#include "../demangle.hpp"
|
||||
#include "../memory_input.hpp"
|
||||
#include "../normal.hpp"
|
||||
#include "../nothing.hpp"
|
||||
#include "../parse.hpp"
|
||||
#include "../rewind_mode.hpp"
|
||||
|
||||
#include "../internal/enable_control.hpp"
|
||||
#include "../internal/has_unwind.hpp"
|
||||
#include "../internal/iterator.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::parse_tree
|
||||
{
|
||||
template< typename T, typename Source = std::string_view >
|
||||
struct basic_node
|
||||
{
|
||||
using node_t = T;
|
||||
using children_t = std::vector< std::unique_ptr< node_t > >;
|
||||
children_t children;
|
||||
|
||||
std::string_view type;
|
||||
Source source;
|
||||
|
||||
TAO_PEGTL_NAMESPACE::internal::iterator m_begin;
|
||||
TAO_PEGTL_NAMESPACE::internal::iterator m_end;
|
||||
|
||||
// each node will be default constructed
|
||||
basic_node() = default;
|
||||
|
||||
// no copy/move is necessary
|
||||
// (nodes are always owned/handled by a std::unique_ptr)
|
||||
basic_node( const basic_node& ) = delete;
|
||||
basic_node( basic_node&& ) = delete;
|
||||
|
||||
~basic_node() = default;
|
||||
|
||||
// no assignment either
|
||||
basic_node& operator=( const basic_node& ) = delete;
|
||||
basic_node& operator=( basic_node&& ) = delete;
|
||||
|
||||
[[nodiscard]] bool is_root() const noexcept
|
||||
{
|
||||
return type.empty();
|
||||
}
|
||||
|
||||
template< typename U >
|
||||
[[nodiscard]] bool is_type() const noexcept
|
||||
{
|
||||
const auto u = demangle< U >();
|
||||
return ( ( type.data() == u.data() ) && ( type.size() == u.size() ) ) || ( type == u );
|
||||
}
|
||||
|
||||
template< typename U >
|
||||
void set_type() noexcept
|
||||
{
|
||||
type = demangle< U >();
|
||||
}
|
||||
|
||||
[[nodiscard]] position begin() const
|
||||
{
|
||||
return position( m_begin, source );
|
||||
}
|
||||
|
||||
[[nodiscard]] position end() const
|
||||
{
|
||||
return position( m_end, source );
|
||||
}
|
||||
|
||||
[[nodiscard]] bool has_content() const noexcept
|
||||
{
|
||||
return m_end.data != nullptr;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string_view string_view() const noexcept
|
||||
{
|
||||
assert( has_content() );
|
||||
return std::string_view( m_begin.data, m_end.data - m_begin.data );
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string string() const
|
||||
{
|
||||
assert( has_content() );
|
||||
return std::string( m_begin.data, m_end.data );
|
||||
}
|
||||
|
||||
template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf >
|
||||
[[nodiscard]] memory_input< P, Eol > as_memory_input() const
|
||||
{
|
||||
assert( has_content() );
|
||||
return { m_begin.data, m_end.data, source, m_begin.byte, m_begin.line, m_begin.column };
|
||||
}
|
||||
|
||||
template< typename... States >
|
||||
void remove_content( States&&... /*unused*/ ) noexcept
|
||||
{
|
||||
m_end = TAO_PEGTL_NAMESPACE::internal::iterator();
|
||||
}
|
||||
|
||||
// all non-root nodes are initialized by calling this method
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void start( const ParseInput& in, States&&... /*unused*/ )
|
||||
{
|
||||
set_type< Rule >();
|
||||
source = in.source();
|
||||
m_begin = TAO_PEGTL_NAMESPACE::internal::iterator( in.iterator() );
|
||||
}
|
||||
|
||||
// if parsing of the rule succeeded, this method is called
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void success( const ParseInput& in, States&&... /*unused*/ ) noexcept
|
||||
{
|
||||
m_end = TAO_PEGTL_NAMESPACE::internal::iterator( in.iterator() );
|
||||
}
|
||||
|
||||
// if parsing of the rule failed, this method is called
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void failure( const ParseInput& /*unused*/, States&&... /*unused*/ ) noexcept
|
||||
{}
|
||||
|
||||
// if parsing succeeded and the (optional) transform call
|
||||
// did not discard the node, it is appended to its parent.
|
||||
// note that "child" is the node whose Rule just succeeded
|
||||
// and "*this" is the parent where the node should be appended.
|
||||
template< typename... States >
|
||||
void emplace_back( std::unique_ptr< node_t >&& child, States&&... /*unused*/ )
|
||||
{
|
||||
assert( child );
|
||||
children.emplace_back( std::move( child ) );
|
||||
}
|
||||
};
|
||||
|
||||
struct node
|
||||
: basic_node< node >
|
||||
{};
|
||||
|
||||
namespace internal
|
||||
{
|
||||
template< typename Node >
|
||||
struct state
|
||||
{
|
||||
std::vector< std::unique_ptr< Node > > stack;
|
||||
|
||||
state()
|
||||
{
|
||||
emplace_back();
|
||||
}
|
||||
|
||||
void emplace_back()
|
||||
{
|
||||
stack.emplace_back( std::make_unique< Node >() );
|
||||
}
|
||||
|
||||
[[nodiscard]] std::unique_ptr< Node >& back() noexcept
|
||||
{
|
||||
assert( !stack.empty() );
|
||||
return stack.back();
|
||||
}
|
||||
|
||||
void pop_back() noexcept
|
||||
{
|
||||
assert( !stack.empty() );
|
||||
return stack.pop_back();
|
||||
}
|
||||
};
|
||||
|
||||
template< typename Selector, typename... Parameters >
|
||||
void transform( Parameters&&... /*unused*/ ) noexcept
|
||||
{}
|
||||
|
||||
template< typename Selector, typename ParseInput, typename Node, typename... States >
|
||||
auto transform( const ParseInput& in, std::unique_ptr< Node >& n, States&&... st ) noexcept( noexcept( Selector::transform( in, n, st... ) ) )
|
||||
-> decltype( (void)Selector::transform( in, n, st... ) )
|
||||
{
|
||||
Selector::transform( in, n, st... );
|
||||
}
|
||||
|
||||
template< typename Selector, typename ParseInput, typename Node, typename... States >
|
||||
auto transform( const ParseInput& /*unused*/, std::unique_ptr< Node >& n, States&&... st ) noexcept( noexcept( Selector::transform( n, st... ) ) )
|
||||
-> decltype( (void)Selector::transform( n, st... ) )
|
||||
{
|
||||
Selector::transform( n, st... );
|
||||
}
|
||||
|
||||
template< typename Rule, template< typename... > class Selector >
|
||||
inline constexpr bool is_selected_node = ( TAO_PEGTL_NAMESPACE::internal::enable_control< Rule > && Selector< Rule >::value );
|
||||
|
||||
template< unsigned Level, typename Subs, template< typename... > class Selector >
|
||||
inline constexpr bool is_leaf{};
|
||||
|
||||
template< typename... Rules, template< typename... > class Selector >
|
||||
inline constexpr bool is_leaf< 0, type_list< Rules... >, Selector > = ( sizeof...( Rules ) == 0 );
|
||||
|
||||
template< unsigned Level, typename Rule, template< typename... > class Selector >
|
||||
inline constexpr bool is_unselected_branch = ( !is_selected_node< Rule, Selector > && is_leaf< Level, typename Rule::subs_t, Selector > );
|
||||
|
||||
template< unsigned Level, typename... Rules, template< typename... > class Selector >
|
||||
inline constexpr bool is_leaf< Level, type_list< Rules... >, Selector > = ( is_unselected_branch< Level - 1, Rules, Selector > && ... );
|
||||
|
||||
template< typename Node, template< typename... > class Selector, template< typename... > class Control >
|
||||
struct make_control
|
||||
{
|
||||
template< typename Rule, bool, bool >
|
||||
struct state_handler;
|
||||
|
||||
template< typename Rule >
|
||||
using type = rotate_states_right< state_handler< Rule, is_selected_node< Rule, Selector >, is_leaf< 8, typename Rule::subs_t, Selector > > >;
|
||||
};
|
||||
|
||||
template< typename, typename, typename... >
|
||||
inline constexpr bool node_has_unwind = false;
|
||||
|
||||
template< typename Node, typename Rule, typename... States >
|
||||
inline constexpr bool node_has_unwind< Node,
|
||||
Rule,
|
||||
decltype( std::declval< Node >().template unwind< Rule >( std::declval< States >()... ) ),
|
||||
States... > = true;
|
||||
|
||||
template< typename Control, typename... States >
|
||||
inline constexpr bool control_has_unwind = TAO_PEGTL_NAMESPACE::internal::has_unwind< Control, void, States... >;
|
||||
|
||||
template< typename Node, template< typename... > class Selector, template< typename... > class Control >
|
||||
template< typename Rule >
|
||||
struct make_control< Node, Selector, Control >::state_handler< Rule, false, true >
|
||||
: remove_first_state< Control< Rule > >
|
||||
{};
|
||||
|
||||
template< typename Node, template< typename... > class Selector, template< typename... > class Control >
|
||||
template< typename Rule >
|
||||
struct make_control< Node, Selector, Control >::state_handler< Rule, false, false >
|
||||
: remove_first_state< Control< Rule > >
|
||||
{
|
||||
static constexpr bool enable = true;
|
||||
|
||||
template< typename ParseInput, typename... States >
|
||||
static void start( const ParseInput& /*unused*/, state< Node >& state, States&&... /*unused*/ )
|
||||
{
|
||||
state.emplace_back();
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename... States >
|
||||
static void success( const ParseInput& /*unused*/, state< Node >& state, States&&... /*unused*/ )
|
||||
{
|
||||
auto n = std::move( state.back() );
|
||||
state.pop_back();
|
||||
for( auto& c : n->children ) {
|
||||
state.back()->children.emplace_back( std::move( c ) );
|
||||
}
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename... States >
|
||||
static void failure( const ParseInput& /*unused*/, state< Node >& state, States&&... /*unused*/ )
|
||||
{
|
||||
state.pop_back();
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename... States >
|
||||
static void unwind( const ParseInput& /*unused*/, state< Node >& state, States&&... /*unused*/ )
|
||||
{
|
||||
state.pop_back();
|
||||
}
|
||||
};
|
||||
|
||||
template< typename Node, template< typename... > class Selector, template< typename... > class Control >
|
||||
template< typename Rule, bool B >
|
||||
struct make_control< Node, Selector, Control >::state_handler< Rule, true, B >
|
||||
: remove_first_state< Control< Rule > >
|
||||
{
|
||||
template< typename ParseInput, typename... States >
|
||||
static void start( const ParseInput& in, state< Node >& state, States&&... st )
|
||||
{
|
||||
Control< Rule >::start( in, st... );
|
||||
state.emplace_back();
|
||||
state.back()->template start< Rule >( in, st... );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename... States >
|
||||
static void success( const ParseInput& in, state< Node >& state, States&&... st )
|
||||
{
|
||||
auto n = std::move( state.back() );
|
||||
state.pop_back();
|
||||
n->template success< Rule >( in, st... );
|
||||
transform< Selector< Rule > >( in, n, st... );
|
||||
if( n ) {
|
||||
state.back()->emplace_back( std::move( n ), st... );
|
||||
}
|
||||
Control< Rule >::success( in, st... );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename... States >
|
||||
static void failure( const ParseInput& in, state< Node >& state, States&&... st )
|
||||
{
|
||||
state.back()->template failure< Rule >( in, st... );
|
||||
state.pop_back();
|
||||
Control< Rule >::failure( in, st... );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename... States >
|
||||
static void unwind( [[maybe_unused]] const ParseInput& in, [[maybe_unused]] state< Node >& state, States&&... st )
|
||||
{
|
||||
if constexpr( node_has_unwind< Node, Rule, void, const ParseInput&, States... > ) {
|
||||
state.back()->template unwind< Rule >( in, st... );
|
||||
}
|
||||
state.pop_back();
|
||||
if constexpr( control_has_unwind< Control< Rule >, const ParseInput&, States... > ) {
|
||||
Control< Rule >::unwind( in, st... );
|
||||
}
|
||||
#if defined( _MSC_VER )
|
||||
( (void)st,
|
||||
... );
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
template< typename >
|
||||
using store_all = std::true_type;
|
||||
|
||||
template< typename >
|
||||
struct selector;
|
||||
|
||||
template< typename T >
|
||||
struct selector< std::tuple< T > >
|
||||
{
|
||||
using type = typename T::type;
|
||||
};
|
||||
|
||||
template< typename... Ts >
|
||||
struct selector< std::tuple< Ts... > >
|
||||
{
|
||||
static_assert( sizeof...( Ts ) == 0, "multiple matches found" );
|
||||
using type = std::false_type;
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
using selector_t = typename selector< T >::type;
|
||||
|
||||
template< typename Rule, typename Collection >
|
||||
using select_tuple = std::conditional_t< Collection::template contains< Rule >, std::tuple< Collection >, std::tuple<> >;
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template< typename Rule, typename... Collections >
|
||||
using selector = internal::selector_t< decltype( std::tuple_cat( std::declval< internal::select_tuple< Rule, Collections > >()... ) ) >;
|
||||
|
||||
template< typename Base >
|
||||
struct apply
|
||||
: std::true_type
|
||||
{
|
||||
template< typename... Rules >
|
||||
struct on
|
||||
{
|
||||
using type = Base;
|
||||
|
||||
template< typename Rule >
|
||||
static constexpr bool contains = ( std::is_same_v< Rule, Rules > || ... );
|
||||
};
|
||||
};
|
||||
|
||||
struct store_content
|
||||
: apply< store_content >
|
||||
{};
|
||||
|
||||
// some nodes don't need to store their content
|
||||
struct remove_content
|
||||
: apply< remove_content >
|
||||
{
|
||||
template< typename Node, typename... States >
|
||||
static void transform( std::unique_ptr< Node >& n, States&&... st ) noexcept( noexcept( n->Node::remove_content( st... ) ) )
|
||||
{
|
||||
n->remove_content( st... );
|
||||
}
|
||||
};
|
||||
|
||||
// if a node has only one child, replace the node with its child, otherwise remove content
|
||||
struct fold_one
|
||||
: apply< fold_one >
|
||||
{
|
||||
template< typename Node, typename... States >
|
||||
static void transform( std::unique_ptr< Node >& n, States&&... st ) noexcept( noexcept( n->children.size(), n->Node::remove_content( st... ) ) )
|
||||
{
|
||||
if( n->children.size() == 1 ) {
|
||||
n = std::move( n->children.front() );
|
||||
}
|
||||
else {
|
||||
n->remove_content( st... );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// if a node has no children, discard the node, otherwise remove content
|
||||
struct discard_empty
|
||||
: apply< discard_empty >
|
||||
{
|
||||
template< typename Node, typename... States >
|
||||
static void transform( std::unique_ptr< Node >& n, States&&... st ) noexcept( noexcept( (void)n->children.empty(), n->Node::remove_content( st... ) ) )
|
||||
{
|
||||
if( n->children.empty() ) {
|
||||
n.reset();
|
||||
}
|
||||
else {
|
||||
n->remove_content( st... );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template< typename Rule,
|
||||
typename Node,
|
||||
template< typename... > class Selector = internal::store_all,
|
||||
template< typename... > class Action = nothing,
|
||||
template< typename... > class Control = normal,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] std::unique_ptr< Node > parse( ParseInput&& in, States&&... st )
|
||||
{
|
||||
internal::state< Node > state;
|
||||
if( !TAO_PEGTL_NAMESPACE::parse< Rule, Action, internal::make_control< Node, Selector, Control >::template type >( in, st..., state ) ) {
|
||||
return nullptr;
|
||||
}
|
||||
assert( state.stack.size() == 1 );
|
||||
return std::move( state.back() );
|
||||
}
|
||||
|
||||
template< typename Rule,
|
||||
template< typename... > class Selector = internal::store_all,
|
||||
template< typename... > class Action = nothing,
|
||||
template< typename... > class Control = normal,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] std::unique_ptr< node > parse( ParseInput&& in, States&&... st )
|
||||
{
|
||||
return parse< Rule, node, Selector, Action, Control >( in, st... );
|
||||
}
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::parse_tree
|
||||
|
||||
#endif
|
|
@ -1,111 +0,0 @@
|
|||
// Copyright (c) 2019-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_PARSE_TREE_TO_DOT_HPP
|
||||
#define TAO_PEGTL_CONTRIB_PARSE_TREE_TO_DOT_HPP
|
||||
|
||||
#include <cassert>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
#include "parse_tree.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::parse_tree
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
inline void escape( std::ostream& os, const std::string_view s )
|
||||
{
|
||||
static const char* h = "0123456789abcdef";
|
||||
|
||||
const char* p = s.data();
|
||||
const char* l = p;
|
||||
const char* const e = s.data() + s.size();
|
||||
while( p != e ) {
|
||||
const unsigned char c = *p;
|
||||
if( c == '\\' ) {
|
||||
os.write( l, p - l );
|
||||
l = ++p;
|
||||
os << "\\\\\\\\";
|
||||
}
|
||||
else if( c == '"' ) {
|
||||
os.write( l, p - l );
|
||||
l = ++p;
|
||||
os << "\\\\\\\"";
|
||||
}
|
||||
else if( c < 32 ) {
|
||||
os.write( l, p - l );
|
||||
l = ++p;
|
||||
switch( c ) {
|
||||
case '\a':
|
||||
os << "\\\\a";
|
||||
break;
|
||||
case '\b':
|
||||
os << "\\\\b";
|
||||
break;
|
||||
case '\f':
|
||||
os << "\\\\f";
|
||||
break;
|
||||
case '\n':
|
||||
os << "\\\\n";
|
||||
break;
|
||||
case '\r':
|
||||
os << "\\\\r";
|
||||
break;
|
||||
case '\t':
|
||||
os << "\\\\t";
|
||||
break;
|
||||
case '\v':
|
||||
os << "\\\\v";
|
||||
break;
|
||||
default:
|
||||
os << "\\\\u00" << h[ ( c & 0xf0 ) >> 4 ] << h[ c & 0x0f ];
|
||||
}
|
||||
}
|
||||
else if( c == 127 ) {
|
||||
os.write( l, p - l );
|
||||
l = ++p;
|
||||
os << "\\\\u007f";
|
||||
}
|
||||
else {
|
||||
++p;
|
||||
}
|
||||
}
|
||||
os.write( l, p - l );
|
||||
}
|
||||
|
||||
template< typename Node >
|
||||
void print_dot_node( std::ostream& os, const Node& n, const std::string_view s )
|
||||
{
|
||||
os << " x" << &n << " [ label=\"";
|
||||
escape( os, s );
|
||||
if( n.has_content() ) {
|
||||
os << "\\n\\\"";
|
||||
escape( os, n.string_view() );
|
||||
os << "\\\"";
|
||||
}
|
||||
os << "\" ]\n";
|
||||
if( !n.children.empty() ) {
|
||||
os << " x" << &n << " -> { ";
|
||||
for( auto& up : n.children ) {
|
||||
os << "x" << up.get() << ( ( up == n.children.back() ) ? " }\n" : ", " );
|
||||
}
|
||||
for( auto& up : n.children ) {
|
||||
print_dot_node( os, *up, up->type );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template< typename Node >
|
||||
void print_dot( std::ostream& os, const Node& n )
|
||||
{
|
||||
os << "digraph parse_tree\n{\n";
|
||||
internal::print_dot_node( os, n, n.is_root() ? "ROOT" : n.type );
|
||||
os << "}\n";
|
||||
}
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::parse_tree
|
||||
|
||||
#endif
|
|
@ -1,121 +0,0 @@
|
|||
// Copyright (c) 2021 Daniel Deptford
|
||||
// Copyright (c) 2021-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_PEG_HPP
|
||||
#define TAO_PEGTL_CONTRIB_PEG_HPP
|
||||
|
||||
#include <tao/pegtl.hpp>
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::peg
|
||||
{
|
||||
// PEG grammar from https://pdos.csail.mit.edu/~baford/packrat/popl04/peg-popl04.pdf
|
||||
namespace grammar
|
||||
{
|
||||
// clang-format off
|
||||
struct AND;
|
||||
struct Char;
|
||||
struct Class;
|
||||
struct CLOSE;
|
||||
struct Comment;
|
||||
struct Definition;
|
||||
struct DOT;
|
||||
struct EndOfFile;
|
||||
struct EndOfLine;
|
||||
struct Expression;
|
||||
struct QUESTION;
|
||||
struct IdentCont;
|
||||
struct Identifier;
|
||||
struct IdentStart;
|
||||
struct LEFTARROW;
|
||||
struct Literal;
|
||||
struct NOT;
|
||||
struct OPEN;
|
||||
struct PLUS;
|
||||
struct Prefix;
|
||||
struct Primary;
|
||||
struct Range;
|
||||
struct Sequence;
|
||||
struct SLASH;
|
||||
struct Space;
|
||||
struct Spacing;
|
||||
struct STAR;
|
||||
struct Suffix;
|
||||
|
||||
struct Grammar : seq< Spacing, plus< Definition >, EndOfFile > {};
|
||||
|
||||
struct Definition : seq< Identifier, LEFTARROW, Expression > {};
|
||||
struct Expression : list< Sequence, SLASH > {};
|
||||
struct Sequence : star< Prefix > {};
|
||||
|
||||
struct Prefix : seq< opt< sor< AND, NOT > >, Suffix > {};
|
||||
struct Suffix : seq< Primary, opt< sor< QUESTION, STAR, PLUS > > > {};
|
||||
|
||||
struct Primary : sor<
|
||||
seq< Identifier, not_at< LEFTARROW > >,
|
||||
seq< OPEN, Expression, CLOSE >,
|
||||
Literal,
|
||||
Class,
|
||||
DOT
|
||||
> {};
|
||||
|
||||
struct Identifier : seq< IdentStart, star< IdentCont >, Spacing > {};
|
||||
|
||||
struct IdentStart : identifier_first {};
|
||||
|
||||
struct IdentCont : identifier_other {};
|
||||
|
||||
struct Literal : sor<
|
||||
seq< one< '\'' >, until< one< '\'' >, Char >, Spacing >,
|
||||
seq< one< '"' >, until< one< '"' >, Char >, Spacing >
|
||||
> {};
|
||||
|
||||
struct Class : seq< one< '[' >, until< one< ']' >, Range >, Spacing > {};
|
||||
|
||||
struct Range : sor<
|
||||
seq< Char, one< '-' >, Char >,
|
||||
Char
|
||||
> {};
|
||||
|
||||
struct Char : sor<
|
||||
seq<
|
||||
one< '\\' >,
|
||||
one< 'n', 'r', 't', '\'', '"', '[', ']', '\\' > >,
|
||||
seq<
|
||||
one< '\\' >,
|
||||
range< '0', '2' >,
|
||||
range< '0', '7' >,
|
||||
range< '0', '7' > >,
|
||||
seq<
|
||||
one< '\\' >,
|
||||
range< '0','7' >,
|
||||
opt< range< '0','7' > > >,
|
||||
seq<
|
||||
not_at< one< '\\' > >,
|
||||
any >
|
||||
> {};
|
||||
|
||||
struct LEFTARROW : seq< string< '<','-' >, Spacing > {};
|
||||
struct SLASH : seq< one< '/' >, Spacing > {};
|
||||
struct AND : seq< one< '&' >, Spacing > {};
|
||||
struct NOT : seq< one< '!' >, Spacing > {};
|
||||
struct QUESTION : seq< one< '?' >, Spacing > {};
|
||||
struct STAR : seq< one< '*' >, Spacing > {};
|
||||
struct PLUS : seq< one< '+' >, Spacing > {};
|
||||
struct OPEN : seq< one< '(' >, Spacing > {};
|
||||
struct CLOSE : seq< one< ')' >, Spacing > {};
|
||||
struct DOT : seq< one< '.' >, Spacing > {};
|
||||
|
||||
struct Spacing : star< sor< Space, Comment > > {};
|
||||
struct Comment : seq< one< '#' >, until< EndOfLine > > {};
|
||||
|
||||
struct Space : sor< one< ' ', '\t' >, EndOfLine > {};
|
||||
struct EndOfLine : sor< string< '\r', '\n' >, one< '\n' >, one< '\r' > > {};
|
||||
struct EndOfFile : eof {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace grammar
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::peg
|
||||
|
||||
#endif // TAO_PEGTL_CONTRIB_PEG_HPP
|
|
@ -1,126 +0,0 @@
|
|||
// Copyright (c) 2020-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_PREDICATES_HPP
|
||||
#define TAO_PEGTL_CONTRIB_PREDICATES_HPP
|
||||
|
||||
#include "../config.hpp"
|
||||
#include "../type_list.hpp"
|
||||
|
||||
#include "../internal/bump_help.hpp"
|
||||
#include "../internal/dependent_false.hpp"
|
||||
#include "../internal/enable_control.hpp"
|
||||
#include "../internal/failure.hpp"
|
||||
#include "../internal/peek_char.hpp"
|
||||
#include "../internal/peek_utf8.hpp"
|
||||
|
||||
#include "analyze_traits.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
template< typename Peek, typename... Ps >
|
||||
struct predicates_and_test
|
||||
{
|
||||
using peek_t = Peek;
|
||||
using data_t = typename Peek::data_t;
|
||||
|
||||
[[nodiscard]] static constexpr bool test( const data_t c ) noexcept
|
||||
{
|
||||
return ( Ps::test( c ) && ... ); // TODO: Static assert that Ps::peek_t is the same as peek_t?!
|
||||
}
|
||||
};
|
||||
|
||||
template< typename Peek, typename P >
|
||||
struct predicate_not_test
|
||||
{
|
||||
using peek_t = Peek;
|
||||
using data_t = typename Peek::data_t;
|
||||
|
||||
[[nodiscard]] static constexpr bool test( const data_t c ) noexcept
|
||||
{
|
||||
return !P::test( c ); // TODO: Static assert that P::peek_t is the same as peek_t?!
|
||||
}
|
||||
};
|
||||
|
||||
template< typename Peek, typename... Ps >
|
||||
struct predicates_or_test
|
||||
{
|
||||
using peek_t = Peek;
|
||||
using data_t = typename Peek::data_t;
|
||||
|
||||
[[nodiscard]] static constexpr bool test( const data_t c ) noexcept
|
||||
{
|
||||
return ( Ps::test( c ) || ... ); // TODO: Static assert that Ps::peek_t is the same as peek_t?!
|
||||
}
|
||||
};
|
||||
|
||||
template< template< typename, typename... > class Test, typename Peek, typename... Ps >
|
||||
struct predicates
|
||||
: private Test< Peek, Ps... >
|
||||
{
|
||||
using peek_t = Peek;
|
||||
using data_t = typename Peek::data_t;
|
||||
|
||||
using rule_t = predicates;
|
||||
using subs_t = empty_list;
|
||||
|
||||
using base_t = Test< Peek, Ps... >;
|
||||
using base_t::test;
|
||||
|
||||
template< int Eol >
|
||||
static constexpr bool can_match_eol = test( Eol );
|
||||
|
||||
template< typename ParseInput >
|
||||
[[nodiscard]] static bool match( ParseInput& in ) noexcept( noexcept( Peek::peek( in ) ) )
|
||||
{
|
||||
if( const auto t = Peek::peek( in ) ) {
|
||||
if( test( t.data ) ) {
|
||||
bump_help< predicates >( in, t.size );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template< template< typename, typename... > class Test, typename Peek >
|
||||
struct predicates< Test, Peek >
|
||||
{
|
||||
static_assert( dependent_false< Peek >, "Empty predicate list is not allowed!" );
|
||||
};
|
||||
|
||||
template< template< typename, typename... > class Test, typename Peek, typename... Ps >
|
||||
inline constexpr bool enable_control< predicates< Test, Peek, Ps... > > = false;
|
||||
|
||||
} // namespace internal
|
||||
|
||||
inline namespace ascii
|
||||
{
|
||||
// clang-format off
|
||||
template< typename... Ps > struct predicates_and : internal::predicates< internal::predicates_and_test, internal::peek_char, Ps... > {};
|
||||
template< typename P > struct predicate_not : internal::predicates< internal::predicate_not_test, internal::peek_char, P > {};
|
||||
template< typename... Ps > struct predicates_or : internal::predicates< internal::predicates_or_test, internal::peek_char, Ps... > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace ascii
|
||||
|
||||
namespace utf8
|
||||
{
|
||||
// clang-format off
|
||||
template< typename... Ps > struct predicates_and : internal::predicates< internal::predicates_and_test, internal::peek_utf8, Ps... > {};
|
||||
template< typename P > struct predicate_not : internal::predicates< internal::predicate_not_test, internal::peek_utf8, P > {};
|
||||
template< typename... Ps > struct predicates_or : internal::predicates< internal::predicates_or_test, internal::peek_utf8, Ps... > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace utf8
|
||||
|
||||
template< typename Name, template< typename, typename... > class Test, typename Peek, typename... Ps >
|
||||
struct analyze_traits< Name, internal::predicates< Test, Peek, Ps... > >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,75 +0,0 @@
|
|||
// Copyright (c) 2020-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_PRINT_HPP
|
||||
#define TAO_PEGTL_CONTRIB_PRINT_HPP
|
||||
|
||||
#include <ostream>
|
||||
|
||||
#include "../config.hpp"
|
||||
#include "../demangle.hpp"
|
||||
#include "../type_list.hpp"
|
||||
#include "../visit.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
template< typename Name >
|
||||
struct print_names
|
||||
{
|
||||
static void visit( std::ostream& os )
|
||||
{
|
||||
os << demangle< Name >() << '\n';
|
||||
}
|
||||
};
|
||||
|
||||
template< typename Name >
|
||||
struct print_debug
|
||||
{
|
||||
static void visit( std::ostream& os )
|
||||
{
|
||||
const auto first = demangle< Name >();
|
||||
os << first << '\n';
|
||||
|
||||
const auto second = demangle< typename Name::rule_t >();
|
||||
if( first != second ) {
|
||||
os << " (aka) " << second << '\n';
|
||||
}
|
||||
|
||||
print_subs( os, typename Name::subs_t() );
|
||||
|
||||
os << '\n';
|
||||
}
|
||||
|
||||
private:
|
||||
template< typename... Rules >
|
||||
static void print_subs( std::ostream& os, type_list< Rules... > /*unused*/ )
|
||||
{
|
||||
( print_sub< Rules >( os ), ... );
|
||||
}
|
||||
|
||||
template< typename Rule >
|
||||
static void print_sub( std::ostream& os )
|
||||
{
|
||||
os << " (sub) " << demangle< Rule >() << '\n';
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template< typename Grammar >
|
||||
void print_names( std::ostream& os )
|
||||
{
|
||||
visit< Grammar, internal::print_names >( os );
|
||||
}
|
||||
|
||||
template< typename Grammar >
|
||||
void print_debug( std::ostream& os )
|
||||
{
|
||||
visit< Grammar, internal::print_debug >( os );
|
||||
}
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,53 +0,0 @@
|
|||
// Copyright (c) 2020-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_PRINT_COVERAGE_HPP
|
||||
#define TAO_PEGTL_CONTRIB_PRINT_COVERAGE_HPP
|
||||
|
||||
#include <ostream>
|
||||
|
||||
#include "coverage.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
inline std::ostream& operator<<( std::ostream& os, const coverage_result& result )
|
||||
{
|
||||
os << "[\n";
|
||||
bool f = true;
|
||||
for( const auto& [ k, v ] : result ) {
|
||||
if( f ) {
|
||||
f = false;
|
||||
}
|
||||
else {
|
||||
os << ",\n";
|
||||
}
|
||||
os << " {\n"
|
||||
<< " \"rule\": \"" << k << "\",\n"
|
||||
<< " \"start\": " << v.start << ", \"success\": " << v.success << ", \"failure\": " << v.failure << ", \"unwind\": " << v.unwind << ", \"raise\": " << v.raise << ",\n";
|
||||
if( v.branches.empty() ) {
|
||||
os << " \"branches\": []\n";
|
||||
}
|
||||
else {
|
||||
os << " \"branches\": [\n";
|
||||
bool f2 = true;
|
||||
for( const auto& [ k2, v2 ] : v.branches ) {
|
||||
if( f2 ) {
|
||||
f2 = false;
|
||||
}
|
||||
else {
|
||||
os << ",\n";
|
||||
}
|
||||
os << " { \"branch\": \"" << k2 << "\", \"start\": " << v2.start << ", \"success\": " << v2.success << ", \"failure\": " << v2.failure << ", \"unwind\": " << v2.unwind << ", \"raise\": " << v2.raise << " }";
|
||||
}
|
||||
os << "\n ]\n";
|
||||
}
|
||||
os << " }";
|
||||
}
|
||||
os << "\n";
|
||||
os << "]\n";
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,142 +0,0 @@
|
|||
// Copyright (c) 2021-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_PROTO3_HPP
|
||||
#define TAO_PEGTL_CONTRIB_PROTO3_HPP
|
||||
|
||||
#include "../ascii.hpp"
|
||||
#include "../config.hpp"
|
||||
#include "../rules.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::proto3
|
||||
{
|
||||
// protocol buffer v3
|
||||
// https://developers.google.com/protocol-buffers/docs/reference/proto3-spec
|
||||
|
||||
// clang-format off
|
||||
struct comment_sl : seq< two< '/' >, until< eolf > > {};
|
||||
struct comment_ml : if_must< string< '/', '*' >, until< string< '*', '/' > > > {};
|
||||
struct sp : sor< space, comment_sl, comment_ml > {};
|
||||
struct sps : star< sp > {};
|
||||
|
||||
struct comma : one< ',' > {};
|
||||
struct dot : one< '.' > {};
|
||||
struct equ : one< '=' > {};
|
||||
struct semi : one< ';' > {};
|
||||
|
||||
struct option;
|
||||
struct message;
|
||||
struct extend;
|
||||
|
||||
struct ident_first : ranges< 'a', 'z', 'A', 'Z' > {}; // NOTE: Yes, no '_'.
|
||||
struct ident_other : ranges< 'a', 'z', 'A', 'Z', '0', '9', '_' > {};
|
||||
struct ident : seq< ident_first, star< ident_other > > {};
|
||||
struct full_ident : list_must< ident, dot > {};
|
||||
|
||||
struct hex_lit : seq< one< '0' >, one< 'x', 'X' >, plus< xdigit > > {};
|
||||
struct oct_lit : seq< one< '0' >, plus< odigit > > {};
|
||||
struct dec_lit : seq< range< '1', '9' >, star< digit > > {};
|
||||
struct int_lit : sor< hex_lit, oct_lit, dec_lit > {};
|
||||
|
||||
struct sign : one< '+', '-' > {};
|
||||
struct exp : seq< one< 'E', 'e' >, opt< sign >, plus< digit > > {};
|
||||
struct float_lit : sor<
|
||||
seq< plus< digit >, dot, exp >,
|
||||
seq< plus< digit >, dot, star< digit >, opt< exp > >,
|
||||
seq< dot, plus< digit >, opt< exp > >,
|
||||
keyword< 'i', 'n', 'f' >,
|
||||
keyword< 'n', 'a', 'n' > > {};
|
||||
|
||||
struct bool_lit : sor< keyword< 't', 'r', 'u', 'e' >,
|
||||
keyword< 'f', 'a', 'l', 's', 'e' > > {};
|
||||
|
||||
struct hex_escape : if_must< one< 'x', 'X' >, xdigit, xdigit > {};
|
||||
struct oct_escape : if_must< odigit, odigit, odigit > {};
|
||||
struct char_escape : one< 'a', 'b', 'f', 'n', 'r', 't', 'v', '\\', '\'', '"' > {};
|
||||
struct escape : if_must< one< '\\' >, hex_escape, oct_escape, char_escape > {};
|
||||
struct char_value : sor< escape, not_one< '\n', '\0' > > {}; // NOTE: No need to exclude '\' from not_one<>, see escape rule.
|
||||
template< char Q >
|
||||
struct str_impl : if_must< one< Q >, until< one< Q >, char_value > > {};
|
||||
struct str_lit : sor< str_impl< '\'' >, str_impl< '"' > > {};
|
||||
|
||||
struct constant : sor< bool_lit, seq< opt< sign >, float_lit >, seq< opt< sign >, int_lit >, str_lit, full_ident > {};
|
||||
|
||||
struct option_name : seq< sor< ident, if_must< one< '(' >, full_ident, one< ')' > > >, star_must< dot, ident > > {};
|
||||
struct option : if_must< keyword< 'o', 'p', 't', 'i', 'o', 'n' >, sps, option_name, sps, equ, sps, constant, sps, semi > {};
|
||||
|
||||
struct bool_type : keyword< 'b', 'o', 'o', 'l' > {};
|
||||
struct bytes_type : keyword< 'b', 'y', 't', 'e', 's' > {};
|
||||
struct double_type : keyword< 'd', 'o', 'u', 'b', 'l', 'e' > {};
|
||||
struct float_type : keyword< 'f', 'l', 'o', 'a', 't' > {};
|
||||
struct string_type : keyword< 's', 't', 'r', 'i', 'n', 'g' > {};
|
||||
|
||||
struct int32_type : keyword< 'i', 'n', 't', '3', '2' > {};
|
||||
struct int64_type : keyword< 'i', 'n', 't', '6', '4' > {};
|
||||
struct sint32_type : keyword< 's', 'i', 'n', 't', '3', '2' > {};
|
||||
struct sint64_type : keyword< 's', 'i', 'n', 't', '6', '4' > {};
|
||||
struct uint32_type : keyword< 'u', 'i', 'n', 't', '3', '2' > {};
|
||||
struct uint64_type : keyword< 'u', 'i', 'n', 't', '6', '4' > {};
|
||||
struct fixed32_type : keyword< 'f', 'i', 'x', 'e', 'd', '3', '2' > {};
|
||||
struct fixed64_type : keyword< 'f', 'i', 'x', 'e', 'd', '6', '4' > {};
|
||||
struct sfixed32_type : keyword< 's', 'f', 'i', 'x', 'e', 'd', '3', '2' > {};
|
||||
struct sfixed64_type : keyword< 's', 'f', 'i', 'x', 'e', 'd', '6', '4' > {};
|
||||
|
||||
struct builtin_type : sor< bool_type, bytes_type, double_type, float_type, string_type, int32_type, int64_type, sint32_type, sint64_type, uint32_type, uint64_type, fixed32_type, fixed64_type, sfixed32_type, sfixed64_type > {};
|
||||
|
||||
struct defined_type : seq< opt< dot >, full_ident > {}; // NOTE: This replaces both message_type and enum_type -- they have the same syntax.
|
||||
|
||||
struct type : sor< builtin_type, defined_type > {};
|
||||
|
||||
struct field_option : if_must< option_name, sps, equ, sps, constant > {};
|
||||
struct field_options : if_must< one< '[' >, sps, list< field_option, comma, sp >, sps, one< ']' > > {};
|
||||
struct field_name : ident {};
|
||||
struct field_number : int_lit {};
|
||||
struct field : seq< opt< sor< keyword< 'o', 'p', 't', 'i', 'o', 'n', 'a', 'l' >, keyword< 'r', 'e', 'p', 'e', 'a', 't', 'e', 'd' > >, sps >, type, sps, field_name, sps, equ, sps, field_number, sps, opt< field_options, sps >, semi > {};
|
||||
|
||||
struct oneof_name : ident {};
|
||||
struct oneof_field : if_must< type, sps, field_name, sps, equ, sps, field_number, sps, opt< field_options, sps >, semi > {};
|
||||
struct oneof_body : sor< oneof_field, semi > {};
|
||||
struct oneof : if_must< keyword< 'o', 'n', 'e', 'o', 'f' >, sps, oneof_name, sps, one< '{' >, sps, until< one< '}' >, oneof_body, sps >, sps > {};
|
||||
|
||||
struct key_type : seq< sor< bool_type, string_type, int32_type, int64_type, sint32_type, sint64_type, uint32_type, uint64_type, fixed32_type, fixed64_type, sfixed32_type, sfixed64_type >, not_at< ident_other > > {};
|
||||
struct map_name : ident {};
|
||||
struct map_field : if_must< keyword< 'm', 'a', 'p' >, sps, one< '<' >, sps, key_type, sps, comma, sps, type, sps, one< '>' >, sps, map_name, sps, equ, sps, field_number, sps, opt< field_options, sps >, semi > {};
|
||||
|
||||
struct range : if_must< int_lit, sps, keyword< 't', 'o' >, sps, sor< int_lit, keyword< 'm', 'a', 'x' > > > {};
|
||||
struct ranges : list_must< range, comma, sp > {};
|
||||
struct field_names : list_must< field_name, comma, sp > {};
|
||||
struct reserved : if_must< keyword< 'r', 'e', 's', 'e', 'r', 'v', 'e', 'd' >, sps, sor< ranges, field_names >, sps, semi > {};
|
||||
|
||||
struct enum_name : ident {};
|
||||
struct enum_value_option : seq< option_name, sps, equ, sps, constant > {};
|
||||
struct enum_field : seq< ident, sps, equ, sps, int_lit, sps, opt_must< one< '[' >, sps, list_must< enum_value_option, comma, sp >, sps, one< ']' >, sps >, semi > {};
|
||||
struct enum_body : if_must< one< '{' >, sps, star< sor< option, enum_field, semi >, sps >, one< '}' > > {};
|
||||
struct enum_def : if_must< keyword< 'e', 'n', 'u', 'm' >, sps, enum_name, sps, enum_body > {};
|
||||
|
||||
struct message_thing : sor< field, enum_def, message, option, oneof, map_field, reserved, extend, semi > {};
|
||||
struct message_body : seq< one<'{'>, sps, star< message_thing, sps >, one<'}'> > {};
|
||||
struct message : if_must< keyword< 'm', 'e', 's', 's', 'a', 'g', 'e' >, sps, defined_type, sps, message_body > {};
|
||||
struct extend : if_must< keyword< 'e', 'x', 't', 'e', 'n', 'd' >, sps, defined_type, sps, message_body > {};
|
||||
|
||||
struct package : if_must< keyword< 'p', 'a', 'c', 'k', 'a', 'g', 'e' >, sps, full_ident, sps, semi > {};
|
||||
|
||||
struct import_option : opt< sor< keyword< 'w', 'e', 'a', 'k' >, keyword< 'p', 'u', 'b', 'l', 'i', 'c' > > > {};
|
||||
struct import : if_must< keyword< 'i', 'm', 'p', 'o', 'r', 't' >, sps, import_option, sps, str_lit, sps, semi > {};
|
||||
|
||||
struct rpc_name : ident {};
|
||||
struct rpc_type : if_must< one< '(' >, sps, opt< keyword< 's', 't', 'r', 'e', 'a', 'm' >, sps >, defined_type, sps, one< ')' > > {};
|
||||
struct rpc_options : if_must< one< '{' >, sps, star< sor< option, semi >, sps >, one< '}' > > {};
|
||||
struct rpc : if_must< keyword< 'r', 'p', 'c' >, sps, rpc_name, sps, rpc_type, sps, keyword< 'r', 'e', 't', 'u', 'r', 'n', 's' >, sps, rpc_type, sps, sor< semi, rpc_options > > {};
|
||||
struct service_name : ident {};
|
||||
struct service : if_must< keyword< 's', 'e', 'r', 'v', 'i', 'c', 'e' >, sps, service_name, sps, one< '{' >, sps, star< sor< option, rpc, semi >, sps >, one< '}' > > {};
|
||||
|
||||
struct body : sor< import, package, option, message, enum_def, service, extend, semi > {};
|
||||
|
||||
struct quote : one< '\'', '"' > {};
|
||||
struct head : if_must< keyword< 's', 'y', 'n', 't', 'a', 'x' >, sps, equ, sps, quote, string< 'p', 'r', 'o', 't', 'o', '3' >, quote, sps, semi > {};
|
||||
struct proto : must< sps, head, sps, star< body, sps >, eof > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::proto3
|
||||
|
||||
#endif
|
|
@ -1,232 +0,0 @@
|
|||
// Copyright (c) 2014-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_RAW_STRING_HPP
|
||||
#define TAO_PEGTL_CONTRIB_RAW_STRING_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
#include "../apply_mode.hpp"
|
||||
#include "../ascii.hpp"
|
||||
#include "../config.hpp"
|
||||
#include "../rewind_mode.hpp"
|
||||
#include "../rules.hpp"
|
||||
|
||||
#include "analyze_traits.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
template< char Open, char Marker >
|
||||
struct raw_string_open
|
||||
{
|
||||
using rule_t = raw_string_open;
|
||||
using subs_t = empty_list;
|
||||
|
||||
template< apply_mode A,
|
||||
rewind_mode,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput >
|
||||
[[nodiscard]] static bool match( ParseInput& in, std::size_t& marker_size ) noexcept( noexcept( in.size( 0 ) ) )
|
||||
{
|
||||
if( in.empty() || ( in.peek_char( 0 ) != Open ) ) {
|
||||
return false;
|
||||
}
|
||||
for( std::size_t i = 1; i < in.size( i + 1 ); ++i ) {
|
||||
switch( const auto c = in.peek_char( i ) ) {
|
||||
case Open:
|
||||
marker_size = i + 1;
|
||||
in.bump_in_this_line( marker_size );
|
||||
(void)eol::match( in );
|
||||
return true;
|
||||
case Marker:
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template< char Open, char Marker >
|
||||
inline constexpr bool enable_control< raw_string_open< Open, Marker > > = false;
|
||||
|
||||
template< char Marker, char Close >
|
||||
struct at_raw_string_close
|
||||
{
|
||||
using rule_t = at_raw_string_close;
|
||||
using subs_t = empty_list;
|
||||
|
||||
template< apply_mode A,
|
||||
rewind_mode,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput >
|
||||
[[nodiscard]] static bool match( ParseInput& in, const std::size_t& marker_size ) noexcept( noexcept( in.size( 0 ) ) )
|
||||
{
|
||||
if( in.size( marker_size ) < marker_size ) {
|
||||
return false;
|
||||
}
|
||||
if( in.peek_char( 0 ) != Close ) {
|
||||
return false;
|
||||
}
|
||||
if( in.peek_char( marker_size - 1 ) != Close ) {
|
||||
return false;
|
||||
}
|
||||
for( std::size_t i = 0; i < ( marker_size - 2 ); ++i ) {
|
||||
if( in.peek_char( i + 1 ) != Marker ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
template< char Marker, char Close >
|
||||
inline constexpr bool enable_control< at_raw_string_close< Marker, Close > > = false;
|
||||
|
||||
template< typename Cond, typename... Rules >
|
||||
struct raw_string_until
|
||||
: raw_string_until< Cond, seq< Rules... > >
|
||||
{};
|
||||
|
||||
template< typename Cond >
|
||||
struct raw_string_until< Cond >
|
||||
{
|
||||
using rule_t = raw_string_until;
|
||||
using subs_t = type_list< Cond >;
|
||||
|
||||
template< apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, const std::size_t& marker_size, States&&... /*unused*/ )
|
||||
{
|
||||
auto m = in.template mark< M >();
|
||||
|
||||
while( !Control< Cond >::template match< A, rewind_mode::required, Action, Control >( in, marker_size ) ) {
|
||||
if( in.empty() ) {
|
||||
return false;
|
||||
}
|
||||
in.bump();
|
||||
}
|
||||
return m( true );
|
||||
}
|
||||
};
|
||||
|
||||
template< typename Cond, typename Rule >
|
||||
struct raw_string_until< Cond, Rule >
|
||||
{
|
||||
using rule_t = raw_string_until;
|
||||
using subs_t = type_list< Cond, Rule >;
|
||||
|
||||
template< apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, const std::size_t& marker_size, States&&... st )
|
||||
{
|
||||
auto m = in.template mark< M >();
|
||||
using m_t = decltype( m );
|
||||
|
||||
while( !Control< Cond >::template match< A, rewind_mode::required, Action, Control >( in, marker_size ) ) {
|
||||
if( !Control< Rule >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return m( true );
|
||||
}
|
||||
};
|
||||
|
||||
template< typename Cond, typename... Rules >
|
||||
inline constexpr bool enable_control< raw_string_until< Cond, Rules... > > = false;
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// raw_string matches Lua-style long literals.
|
||||
//
|
||||
// The following description was taken from the Lua documentation
|
||||
// (see http://www.lua.org/docs.html):
|
||||
//
|
||||
// - An "opening long bracket of level n" is defined as an opening square
|
||||
// bracket followed by n equal signs followed by another opening square
|
||||
// bracket. So, an opening long bracket of level 0 is written as `[[`,
|
||||
// an opening long bracket of level 1 is written as `[=[`, and so on.
|
||||
// - A "closing long bracket" is defined similarly; for instance, a closing
|
||||
// long bracket of level 4 is written as `]====]`.
|
||||
// - A "long literal" starts with an opening long bracket of any level and
|
||||
// ends at the first closing long bracket of the same level. It can
|
||||
// contain any text except a closing bracket of the same level.
|
||||
// - Literals in this bracketed form can run for several lines, do not
|
||||
// interpret any escape sequences, and ignore long brackets of any other
|
||||
// level.
|
||||
// - For convenience, when the opening long bracket is eagerly followed
|
||||
// by a newline, the newline is not included in the string.
|
||||
//
|
||||
// Note that unlike Lua's long literal, a raw_string is customizable to use
|
||||
// other characters than `[`, `=` and `]` for matching. Also note that Lua
|
||||
// introduced newline-specific replacements in Lua 5.2, which we do not
|
||||
// support on the grammar level.
|
||||
|
||||
template< char Open, char Marker, char Close, typename... Contents >
|
||||
struct raw_string
|
||||
{
|
||||
// This is used for binding the apply()-method and for error-reporting
|
||||
// when a raw string is not closed properly or has invalid content.
|
||||
struct content
|
||||
: internal::raw_string_until< internal::at_raw_string_close< Marker, Close >, Contents... >
|
||||
{};
|
||||
|
||||
using rule_t = raw_string;
|
||||
using subs_t = empty_list; // type_list< internal::raw_string_open< Open, Marker >, content >;
|
||||
|
||||
template< apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
std::size_t marker_size;
|
||||
if( Control< internal::raw_string_open< Open, Marker > >::template match< A, M, Action, Control >( in, marker_size ) ) {
|
||||
if( Control< content >::template match< A, M, Action, Control >( in, marker_size, st... ) ) {
|
||||
in.bump_in_this_line( marker_size );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template< typename Name, char Open, char Marker, char Close >
|
||||
struct analyze_traits< Name, raw_string< Open, Marker, Close > >
|
||||
: analyze_any_traits<>
|
||||
{};
|
||||
|
||||
template< typename Name, char Open, char Marker, char Close, typename... Contents >
|
||||
struct analyze_traits< Name, raw_string< Open, Marker, Close, Contents... > >
|
||||
: analyze_traits< Name, typename seq< any, star< Contents... >, any >::rule_t >
|
||||
{};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,72 +0,0 @@
|
|||
// Copyright (c) 2019-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_REMOVE_FIRST_STATE_HPP
|
||||
#define TAO_PEGTL_CONTRIB_REMOVE_FIRST_STATE_HPP
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "../config.hpp"
|
||||
|
||||
#include "../internal/has_unwind.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
// The first state is removed for most of the control functions forwarded to Base,
|
||||
// start(), success(), failure(), unwind(), raise(), apply(), and apply0(). The call
|
||||
// to match() is unchanged because it can call other grammar rules that require all
|
||||
// states when starting their match to keep an even playing field.
|
||||
|
||||
template< typename Base >
|
||||
struct remove_first_state
|
||||
: Base
|
||||
{
|
||||
template< typename ParseInput, typename State, typename... States >
|
||||
static void start( const ParseInput& in, State&& /*unused*/, States&&... st ) noexcept( noexcept( Base::start( in, st... ) ) )
|
||||
{
|
||||
Base::start( in, st... );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename State, typename... States >
|
||||
static void success( const ParseInput& in, State&& /*unused*/, States&&... st ) noexcept( noexcept( Base::success( in, st... ) ) )
|
||||
{
|
||||
Base::success( in, st... );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename State, typename... States >
|
||||
static void failure( const ParseInput& in, State&& /*unused*/, States&&... st ) noexcept( noexcept( Base::failure( in, st... ) ) )
|
||||
{
|
||||
Base::failure( in, st... );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename State, typename... States >
|
||||
[[noreturn]] static void raise( const ParseInput& in, State&& /*unused*/, States&&... st )
|
||||
{
|
||||
Base::raise( in, st... );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename State, typename... States >
|
||||
static auto unwind( const ParseInput& in, State&& /*unused*/, States&&... st )
|
||||
-> std::enable_if_t< internal::has_unwind< Base, void, const ParseInput&, States... > >
|
||||
{
|
||||
Base::unwind( in, st... );
|
||||
}
|
||||
|
||||
template< template< typename... > class Action, typename Iterator, typename ParseInput, typename State, typename... States >
|
||||
static auto apply( const Iterator& begin, const ParseInput& in, State&& /*unused*/, States&&... st ) noexcept( noexcept( Base::template apply< Action >( begin, in, st... ) ) )
|
||||
-> decltype( Base::template apply< Action >( begin, in, st... ) )
|
||||
{
|
||||
return Base::template apply< Action >( begin, in, st... );
|
||||
}
|
||||
|
||||
template< template< typename... > class Action, typename ParseInput, typename State, typename... States >
|
||||
static auto apply0( const ParseInput& in, State&& /*unused*/, States&&... st ) noexcept( noexcept( Base::template apply0< Action >( in, st... ) ) )
|
||||
-> decltype( Base::template apply0< Action >( in, st... ) )
|
||||
{
|
||||
return Base::template apply0< Action >( in, st... );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,121 +0,0 @@
|
|||
// Copyright (c) 2020-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_REMOVE_LAST_STATES_HPP
|
||||
#define TAO_PEGTL_CONTRIB_REMOVE_LAST_STATES_HPP
|
||||
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
#include "../config.hpp"
|
||||
|
||||
#include "../internal/has_unwind.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
// The last N states are removed for most of the control functions forwarded to Base,
|
||||
// start(), success(), failure(), unwind(), raise(), apply(), and apply0(). The call
|
||||
// to match() is unchanged because it can call other grammar rules that require all
|
||||
// states when starting their match to keep an even playing field.
|
||||
|
||||
template< typename Base, std::size_t N >
|
||||
struct remove_last_states
|
||||
: Base
|
||||
{
|
||||
template< typename ParseInput, typename Tuple, std::size_t... Is >
|
||||
static void start_impl( const ParseInput& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::start( in, std::get< Is >( t )... ) ) )
|
||||
{
|
||||
Base::start( in, std::get< Is >( t )... );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename... States >
|
||||
static void start( const ParseInput& in, States&&... st ) noexcept( noexcept( start_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - N >() ) ) )
|
||||
{
|
||||
start_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - N >() );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename Tuple, std::size_t... Is >
|
||||
static void success_impl( const ParseInput& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::success( in, std::get< Is >( t )... ) ) )
|
||||
{
|
||||
Base::success( in, std::get< Is >( t )... );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename... States >
|
||||
static void success( const ParseInput& in, States&&... st ) noexcept( noexcept( success_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - N >() ) ) )
|
||||
{
|
||||
success_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - N >() );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename Tuple, std::size_t... Is >
|
||||
static void failure_impl( const ParseInput& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::failure( in, std::get< Is >( t )... ) ) )
|
||||
{
|
||||
Base::failure( in, std::get< Is >( t )... );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename... States >
|
||||
static void failure( const ParseInput& in, States&&... st ) noexcept( noexcept( failure_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - N >() ) ) )
|
||||
{
|
||||
failure_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - N >() );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename Tuple, std::size_t... Is >
|
||||
[[noreturn]] static void raise_impl( const ParseInput& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ )
|
||||
{
|
||||
Base::raise( in, std::get< Is >( t )... );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename... States >
|
||||
[[noreturn]] static void raise( const ParseInput& in, States&&... st )
|
||||
{
|
||||
raise_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - N >() );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename Tuple, std::size_t... Is >
|
||||
static auto unwind_impl( const ParseInput& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ )
|
||||
-> std::enable_if_t< internal::has_unwind< Base, void, const ParseInput&, std::tuple_element_t< Is, Tuple >... > >
|
||||
{
|
||||
Base::unwind( in, std::get< Is >( t )... );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename... States >
|
||||
static auto unwind( const ParseInput& in, States&&... st )
|
||||
-> decltype( unwind_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - N >() ) )
|
||||
{
|
||||
unwind_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - N >() );
|
||||
}
|
||||
|
||||
template< template< typename... > class Action, typename Iterator, typename ParseInput, typename Tuple, std::size_t... Is >
|
||||
static auto apply_impl( const Iterator& begin, const ParseInput& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::template apply< Action >( begin, in, std::get< Is >( t )... ) ) )
|
||||
-> decltype( Base::template apply< Action >( begin, in, std::get< Is >( t )... ) )
|
||||
{
|
||||
return Base::template apply< Action >( begin, in, std::get< Is >( t )... );
|
||||
}
|
||||
|
||||
template< template< typename... > class Action, typename Iterator, typename ParseInput, typename... States >
|
||||
static auto apply( const Iterator& begin, const ParseInput& in, States&&... st ) noexcept( noexcept( apply_impl< Action >( begin, in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - N >() ) ) )
|
||||
-> decltype( apply_impl< Action >( begin, in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - N >() ) )
|
||||
{
|
||||
return apply_impl< Action >( begin, in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - N >() );
|
||||
}
|
||||
|
||||
template< template< typename... > class Action, typename ParseInput, typename Tuple, std::size_t... Is >
|
||||
static auto apply0_impl( const ParseInput& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::template apply0< Action >( in, std::get< Is >( t )... ) ) )
|
||||
-> decltype( Base::template apply0< Action >( in, std::get< Is >( t )... ) )
|
||||
{
|
||||
return Base::template apply0< Action >( in, std::get< Is >( t )... );
|
||||
}
|
||||
|
||||
template< template< typename... > class Action, typename ParseInput, typename... States >
|
||||
static auto apply0( const ParseInput& in, States&&... st ) noexcept( noexcept( apply0_impl< Action >( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - N >() ) ) )
|
||||
-> decltype( apply0_impl< Action >( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - N >() ) )
|
||||
{
|
||||
return apply0_impl< Action >( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - N >() );
|
||||
}
|
||||
};
|
||||
|
||||
template< typename Base >
|
||||
using remove_last_state = remove_last_states< Base, 1 >;
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,100 +0,0 @@
|
|||
// Copyright (c) 2017-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_REP_ONE_MIN_MAX_HPP
|
||||
#define TAO_PEGTL_CONTRIB_REP_ONE_MIN_MAX_HPP
|
||||
|
||||
#include <algorithm>
|
||||
#include <type_traits>
|
||||
|
||||
#include "../config.hpp"
|
||||
#include "../type_list.hpp"
|
||||
|
||||
#include "../internal/bump_help.hpp"
|
||||
#include "../internal/bytes.hpp"
|
||||
#include "../internal/enable_control.hpp"
|
||||
#include "../internal/opt.hpp"
|
||||
|
||||
#include "analyze_traits.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
template< unsigned Min, unsigned Max, char C >
|
||||
struct rep_one_min_max
|
||||
{
|
||||
using rule_t = rep_one_min_max;
|
||||
using subs_t = empty_list;
|
||||
|
||||
static_assert( Min <= Max );
|
||||
|
||||
template< int Eol >
|
||||
static constexpr bool can_match_eol = ( C == Eol );
|
||||
|
||||
template< typename ParseInput >
|
||||
[[nodiscard]] static bool match( ParseInput& in )
|
||||
{
|
||||
const auto size = in.size( Max + 1 );
|
||||
if( size < Min ) {
|
||||
return false;
|
||||
}
|
||||
std::size_t i = 0;
|
||||
while( ( i < size ) && ( in.peek_char( i ) == C ) ) {
|
||||
++i;
|
||||
}
|
||||
if( ( Min <= i ) && ( i <= Max ) ) {
|
||||
bump_help< rep_one_min_max >( in, i );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template< unsigned Max, char C >
|
||||
struct rep_one_min_max< 0, Max, C >
|
||||
{
|
||||
using rule_t = rep_one_min_max;
|
||||
using subs_t = empty_list;
|
||||
|
||||
template< int Eol >
|
||||
static constexpr bool can_match_eol = ( C == Eol );
|
||||
|
||||
template< typename ParseInput >
|
||||
[[nodiscard]] static bool match( ParseInput& in )
|
||||
{
|
||||
const auto size = in.size( Max + 1 );
|
||||
std::size_t i = 0;
|
||||
while( ( i < size ) && ( in.peek_char( i ) == C ) ) {
|
||||
++i;
|
||||
}
|
||||
if( i <= Max ) {
|
||||
bump_help< rep_one_min_max >( in, i );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template< unsigned Min, unsigned Max, char C >
|
||||
inline constexpr bool enable_control< rep_one_min_max< Min, Max, C > > = false;
|
||||
|
||||
} // namespace internal
|
||||
|
||||
inline namespace ascii
|
||||
{
|
||||
template< unsigned Min, unsigned Max, char C >
|
||||
struct rep_one_min_max
|
||||
: internal::rep_one_min_max< Min, Max, C >
|
||||
{};
|
||||
|
||||
} // namespace ascii
|
||||
|
||||
template< typename Name, unsigned Min, unsigned Max, char C >
|
||||
struct analyze_traits< Name, internal::rep_one_min_max< Min, Max, C > >
|
||||
: std::conditional_t< ( Min != 0 ), analyze_any_traits<>, analyze_opt_traits<> >
|
||||
{};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,43 +0,0 @@
|
|||
// Copyright (c) 2019-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_REP_STRING_HPP
|
||||
#define TAO_PEGTL_CONTRIB_REP_STRING_HPP
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "../config.hpp"
|
||||
#include "../internal/string.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
template< std::size_t, typename, char... >
|
||||
struct make_rep_string;
|
||||
|
||||
template< char... Ss, char... Cs >
|
||||
struct make_rep_string< 0, string< Ss... >, Cs... >
|
||||
{
|
||||
using type = string< Ss... >;
|
||||
};
|
||||
|
||||
template< std::size_t N, char... Ss, char... Cs >
|
||||
struct make_rep_string< N, string< Ss... >, Cs... >
|
||||
: make_rep_string< N - 1, string< Ss..., Cs... >, Cs... >
|
||||
{};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
inline namespace ascii
|
||||
{
|
||||
template< std::size_t N, char... Cs >
|
||||
struct rep_string
|
||||
: internal::make_rep_string< N, internal::string<>, Cs... >::type
|
||||
{};
|
||||
|
||||
} // namespace ascii
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,45 +0,0 @@
|
|||
// Copyright (c) 2021-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_SEPARATED_SEQ_HPP
|
||||
#define TAO_PEGTL_CONTRIB_SEPARATED_SEQ_HPP
|
||||
|
||||
#include "../config.hpp"
|
||||
|
||||
#include "../internal/seq.hpp"
|
||||
#include "../type_list.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
template< typename... >
|
||||
struct sep;
|
||||
|
||||
template< typename... Ts, typename S, typename Rule, typename... Rules >
|
||||
struct sep< type_list< Ts... >, S, Rule, Rules... >
|
||||
: sep< type_list< Ts..., Rule, S >, S, Rules... >
|
||||
{};
|
||||
|
||||
template< typename... Ts, typename S, typename Rule >
|
||||
struct sep< type_list< Ts... >, S, Rule >
|
||||
{
|
||||
using type = seq< Ts..., Rule >;
|
||||
};
|
||||
|
||||
template< typename S >
|
||||
struct sep< type_list<>, S >
|
||||
{
|
||||
using type = seq<>;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template< typename S, typename... Rules >
|
||||
struct separated_seq
|
||||
: internal::sep< type_list<>, S, Rules... >::type
|
||||
{};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,193 +0,0 @@
|
|||
// Copyright (c) 2020-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_SHUFFLE_STATES_HPP
|
||||
#define TAO_PEGTL_CONTRIB_SHUFFLE_STATES_HPP
|
||||
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include "../config.hpp"
|
||||
|
||||
#include "../internal/has_unwind.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
template< std::size_t N >
|
||||
struct rotate_left
|
||||
{
|
||||
template< std::size_t I, std::size_t S >
|
||||
static constexpr std::size_t value = ( I + N ) % S;
|
||||
};
|
||||
|
||||
template< std::size_t N >
|
||||
struct rotate_right
|
||||
{
|
||||
template< std::size_t I, std::size_t S >
|
||||
static constexpr std::size_t value = ( I + S - N ) % S;
|
||||
};
|
||||
|
||||
struct reverse
|
||||
{
|
||||
template< std::size_t I, std::size_t S >
|
||||
static constexpr std::size_t value = ( S - 1 ) - I;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// Applies 'Shuffle' to the states of start(), success(), failure(), raise(), apply(), and apply0()
|
||||
template< typename Base, typename Shuffle >
|
||||
struct shuffle_states
|
||||
: Base
|
||||
{
|
||||
template< typename ParseInput, typename Tuple, std::size_t... Is >
|
||||
static void start_impl( const ParseInput& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::start( in, std::get< Shuffle::template value< Is, sizeof...( Is ) > >( t )... ) ) )
|
||||
{
|
||||
Base::start( in, std::get< Shuffle::template value< Is, sizeof...( Is ) > >( t )... );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename... States >
|
||||
static void start( const ParseInput& in, States&&... st ) noexcept( noexcept( start_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) >() ) ) )
|
||||
{
|
||||
start_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) >() );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename State >
|
||||
static void start( const ParseInput& in, State&& st ) noexcept( noexcept( Base::start( in, st ) ) )
|
||||
{
|
||||
Base::start( in, st );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename Tuple, std::size_t... Is >
|
||||
static void success_impl( const ParseInput& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::success( in, std::get< Shuffle::template value< Is, sizeof...( Is ) > >( t )... ) ) )
|
||||
{
|
||||
Base::success( in, std::get< Shuffle::template value< Is, sizeof...( Is ) > >( t )... );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename... States >
|
||||
static void success( const ParseInput& in, States&&... st ) noexcept( noexcept( success_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) >() ) ) )
|
||||
{
|
||||
success_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) >() );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename State >
|
||||
static void success( const ParseInput& in, State&& st ) noexcept( noexcept( Base::success( in, st ) ) )
|
||||
{
|
||||
Base::success( in, st );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename Tuple, std::size_t... Is >
|
||||
static void failure_impl( const ParseInput& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::failure( in, std::get< Shuffle::template value< Is, sizeof...( Is ) > >( t )... ) ) )
|
||||
{
|
||||
Base::failure( in, std::get< Shuffle::template value< Is, sizeof...( Is ) > >( t )... );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename... States >
|
||||
static void failure( const ParseInput& in, States&&... st ) noexcept( noexcept( failure_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) >() ) ) )
|
||||
{
|
||||
failure_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) >() );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename State >
|
||||
static void failure( const ParseInput& in, State&& st ) noexcept( noexcept( Base::failure( in, st ) ) )
|
||||
{
|
||||
Base::failure( in, st );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename Tuple, std::size_t... Is >
|
||||
[[noreturn]] static void raise_impl( const ParseInput& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ )
|
||||
{
|
||||
Base::raise( in, std::get< Shuffle::template value< Is, sizeof...( Is ) > >( t )... );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename... States >
|
||||
[[noreturn]] static void raise( const ParseInput& in, States&&... st )
|
||||
{
|
||||
raise_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) >() );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename State >
|
||||
[[noreturn]] static void raise( const ParseInput& in, State&& st )
|
||||
{
|
||||
Base::raise( in, st );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename Tuple, std::size_t... Is >
|
||||
static auto unwind_impl( const ParseInput& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ )
|
||||
-> std::enable_if_t< internal::has_unwind< Base, void, const ParseInput&, std::tuple_element_t< Shuffle::template value< Is, sizeof...( Is ) >, Tuple >... > >
|
||||
{
|
||||
Base::unwind( in, std::get< Shuffle::template value< Is, sizeof...( Is ) > >( t )... );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename... States >
|
||||
static auto unwind( const ParseInput& in, States&&... st )
|
||||
-> decltype( unwind_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) >() ) )
|
||||
{
|
||||
unwind_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) >() );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename State >
|
||||
static auto unwind( const ParseInput& in, State&& st )
|
||||
-> std::enable_if_t< internal::has_unwind< Base, void, const ParseInput&, State > >
|
||||
{
|
||||
Base::unwind( in, st );
|
||||
}
|
||||
|
||||
template< template< typename... > class Action, typename Iterator, typename ParseInput, typename Tuple, std::size_t... Is >
|
||||
static auto apply_impl( const Iterator& begin, const ParseInput& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::template apply< Action >( begin, in, std::get< Shuffle::template value< Is, sizeof...( Is ) > >( t )... ) ) )
|
||||
-> decltype( Base::template apply< Action >( begin, in, std::get< Shuffle::template value< Is, sizeof...( Is ) > >( t )... ) )
|
||||
{
|
||||
return Base::template apply< Action >( begin, in, std::get< Shuffle::template value< Is, sizeof...( Is ) > >( t )... );
|
||||
}
|
||||
|
||||
template< template< typename... > class Action, typename Iterator, typename ParseInput, typename... States >
|
||||
static auto apply( const Iterator& begin, const ParseInput& in, States&&... st ) noexcept( noexcept( apply_impl< Action >( begin, in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) >() ) ) )
|
||||
-> decltype( apply_impl< Action >( begin, in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) >() ) )
|
||||
{
|
||||
return apply_impl< Action >( begin, in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) >() );
|
||||
}
|
||||
|
||||
template< template< typename... > class Action, typename Iterator, typename ParseInput, typename State >
|
||||
static auto apply( const Iterator& begin, const ParseInput& in, State&& st ) noexcept( noexcept( Base::template apply< Action >( begin, in, st ) ) )
|
||||
-> decltype( Base::template apply< Action >( begin, in, st ) )
|
||||
{
|
||||
return Base::template apply< Action >( begin, in, st );
|
||||
}
|
||||
|
||||
template< template< typename... > class Action, typename ParseInput, typename Tuple, std::size_t... Is >
|
||||
static auto apply0_impl( const ParseInput& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( Base::template apply0< Action >( in, std::get< Shuffle::template value< Is, sizeof...( Is ) > >( t )... ) ) )
|
||||
-> decltype( Base::template apply0< Action >( in, std::get< Shuffle::template value< Is, sizeof...( Is ) > >( t )... ) )
|
||||
{
|
||||
return Base::template apply0< Action >( in, std::get< Shuffle::template value< Is, sizeof...( Is ) > >( t )... );
|
||||
}
|
||||
|
||||
template< template< typename... > class Action, typename ParseInput, typename... States >
|
||||
static auto apply0( const ParseInput& in, States&&... st ) noexcept( noexcept( apply0_impl< Action >( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) >() ) ) )
|
||||
-> decltype( apply0_impl< Action >( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) >() ) )
|
||||
{
|
||||
return apply0_impl< Action >( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) >() );
|
||||
}
|
||||
|
||||
template< template< typename... > class Action, typename ParseInput, typename State >
|
||||
static auto apply0( const ParseInput& in, State&& st ) noexcept( noexcept( Base::template apply0< Action >( in, st ) ) )
|
||||
-> decltype( Base::template apply0< Action >( in, st ) )
|
||||
{
|
||||
return Base::template apply0< Action >( in, st );
|
||||
}
|
||||
};
|
||||
|
||||
template< typename Base, std::size_t N = 1 >
|
||||
using rotate_states_left = shuffle_states< Base, internal::rotate_left< N > >;
|
||||
|
||||
template< typename Base, std::size_t N = 1 >
|
||||
using rotate_states_right = shuffle_states< Base, internal::rotate_right< N > >;
|
||||
|
||||
template< typename Base >
|
||||
using reverse_states = shuffle_states< Base, internal::reverse >;
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,122 +0,0 @@
|
|||
// Copyright (c) 2020-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_STATE_CONTROL_HPP
|
||||
#define TAO_PEGTL_CONTRIB_STATE_CONTROL_HPP
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "shuffle_states.hpp"
|
||||
|
||||
#include "../config.hpp"
|
||||
#include "../internal/has_unwind.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
template< template< typename... > class Control >
|
||||
struct state_control
|
||||
{
|
||||
template< typename Rule >
|
||||
struct control
|
||||
: Control< Rule >
|
||||
{
|
||||
static constexpr bool enable = true;
|
||||
|
||||
template< typename ParseInput, typename State, typename... States >
|
||||
static void start( [[maybe_unused]] const ParseInput& in, [[maybe_unused]] State& state, [[maybe_unused]] States&&... st )
|
||||
{
|
||||
if constexpr( Control< Rule >::enable ) {
|
||||
Control< Rule >::start( in, st... );
|
||||
}
|
||||
if constexpr( State::template enable< Rule > ) {
|
||||
state.template start< Rule >( in, st... );
|
||||
}
|
||||
#if defined( _MSC_VER )
|
||||
( (void)st,
|
||||
... );
|
||||
#endif
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename State, typename... States >
|
||||
static void success( [[maybe_unused]] const ParseInput& in, [[maybe_unused]] State& state, [[maybe_unused]] States&&... st )
|
||||
{
|
||||
if constexpr( State::template enable< Rule > ) {
|
||||
state.template success< Rule >( in, st... );
|
||||
}
|
||||
if constexpr( Control< Rule >::enable ) {
|
||||
Control< Rule >::success( in, st... );
|
||||
}
|
||||
#if defined( _MSC_VER )
|
||||
( (void)st,
|
||||
... );
|
||||
#endif
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename State, typename... States >
|
||||
static void failure( [[maybe_unused]] const ParseInput& in, [[maybe_unused]] State& state, [[maybe_unused]] States&&... st )
|
||||
{
|
||||
if constexpr( State::template enable< Rule > ) {
|
||||
state.template failure< Rule >( in, st... );
|
||||
}
|
||||
if constexpr( Control< Rule >::enable ) {
|
||||
Control< Rule >::failure( in, st... );
|
||||
}
|
||||
#if defined( _MSC_VER )
|
||||
( (void)st,
|
||||
... );
|
||||
#endif
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename State, typename... States >
|
||||
[[noreturn]] static void raise( const ParseInput& in, [[maybe_unused]] State& state, States&&... st )
|
||||
{
|
||||
if constexpr( State::template enable< Rule > ) {
|
||||
state.template raise< Rule >( in, st... );
|
||||
}
|
||||
Control< Rule >::raise( in, st... );
|
||||
}
|
||||
|
||||
template< typename ParseInput, typename State, typename... States >
|
||||
static auto unwind( [[maybe_unused]] const ParseInput& in, [[maybe_unused]] State& state, [[maybe_unused]] States&&... st )
|
||||
-> std::enable_if_t< State::template enable< Rule > || ( Control< Rule >::enable && internal::has_unwind< Control< Rule >, void, const ParseInput&, States... > ) >
|
||||
{
|
||||
if constexpr( State::template enable< Rule > ) {
|
||||
state.template unwind< Rule >( in, st... );
|
||||
}
|
||||
if constexpr( Control< Rule >::enable && internal::has_unwind< Control< Rule >, void, const ParseInput&, States... > ) {
|
||||
Control< Rule >::unwind( in, st... );
|
||||
}
|
||||
#if defined( _MSC_VER )
|
||||
( (void)st,
|
||||
... );
|
||||
#endif
|
||||
}
|
||||
|
||||
template< template< typename... > class Action, typename Iterator, typename ParseInput, typename State, typename... States >
|
||||
static auto apply( const Iterator& begin, const ParseInput& in, [[maybe_unused]] State& state, States&&... st )
|
||||
-> decltype( Control< Rule >::template apply< Action >( begin, in, st... ) )
|
||||
{
|
||||
if constexpr( State::template enable< Rule > ) {
|
||||
state.template apply< Rule >( in, st... );
|
||||
}
|
||||
return Control< Rule >::template apply< Action >( begin, in, st... );
|
||||
}
|
||||
|
||||
template< template< typename... > class Action, typename ParseInput, typename State, typename... States >
|
||||
static auto apply0( const ParseInput& in, [[maybe_unused]] State& state, States&&... st )
|
||||
-> decltype( Control< Rule >::template apply0< Action >( in, st... ) )
|
||||
{
|
||||
if constexpr( State::template enable< Rule > ) {
|
||||
state.template apply0< Rule >( in, st... );
|
||||
}
|
||||
return Control< Rule >::template apply0< Action >( in, st... );
|
||||
}
|
||||
};
|
||||
|
||||
template< typename Rule >
|
||||
using type = rotate_states_right< control< Rule > >;
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,38 +0,0 @@
|
|||
// Copyright (c) 2017-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_TO_STRING_HPP
|
||||
#define TAO_PEGTL_CONTRIB_TO_STRING_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "../config.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace internal
|
||||
{
|
||||
template< typename >
|
||||
struct to_string;
|
||||
|
||||
template< template< char... > class X, char... Cs >
|
||||
struct to_string< X< Cs... > >
|
||||
{
|
||||
[[nodiscard]] static std::string get()
|
||||
{
|
||||
const char s[] = { Cs..., 0 };
|
||||
return std::string( s, sizeof...( Cs ) );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
template< typename T >
|
||||
[[nodiscard]] std::string to_string()
|
||||
{
|
||||
return internal::to_string< T >::get();
|
||||
}
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,227 +0,0 @@
|
|||
// Copyright (c) 2020-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_TRACE_HPP
|
||||
#define TAO_PEGTL_CONTRIB_TRACE_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <string_view>
|
||||
#include <tuple>
|
||||
|
||||
#include "state_control.hpp"
|
||||
|
||||
#include "../apply_mode.hpp"
|
||||
#include "../config.hpp"
|
||||
#include "../demangle.hpp"
|
||||
#include "../normal.hpp"
|
||||
#include "../nothing.hpp"
|
||||
#include "../parse.hpp"
|
||||
#include "../rewind_mode.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
template< bool HideInternal = false, bool UseColor = true, std::size_t IndentIncrement = 2, std::size_t InitialIndent = 8 >
|
||||
struct tracer_traits
|
||||
{
|
||||
template< typename Rule >
|
||||
static constexpr bool enable = ( HideInternal ? normal< Rule >::enable : true );
|
||||
|
||||
static constexpr std::size_t initial_indent = InitialIndent;
|
||||
static constexpr std::size_t indent_increment = IndentIncrement;
|
||||
|
||||
static constexpr std::string_view ansi_reset = UseColor ? "\033[m" : "";
|
||||
static constexpr std::string_view ansi_rule = UseColor ? "\033[36m" : "";
|
||||
static constexpr std::string_view ansi_hide = UseColor ? "\033[37m" : "";
|
||||
|
||||
static constexpr std::string_view ansi_position = UseColor ? "\033[1;34m" : "";
|
||||
static constexpr std::string_view ansi_success = UseColor ? "\033[32m" : "";
|
||||
static constexpr std::string_view ansi_failure = UseColor ? "\033[31m" : "";
|
||||
static constexpr std::string_view ansi_raise = UseColor ? "\033[1;31m" : "";
|
||||
static constexpr std::string_view ansi_unwind = UseColor ? "\033[31m" : "";
|
||||
static constexpr std::string_view ansi_apply = UseColor ? "\033[1;36m" : "";
|
||||
};
|
||||
|
||||
using standard_tracer_traits = tracer_traits< true >;
|
||||
using complete_tracer_traits = tracer_traits< false >;
|
||||
|
||||
template< typename TracerTraits >
|
||||
struct tracer
|
||||
{
|
||||
const std::ios_base::fmtflags m_flags;
|
||||
std::size_t m_count = 0;
|
||||
std::vector< std::size_t > m_stack;
|
||||
position m_position;
|
||||
|
||||
template< typename Rule >
|
||||
static constexpr bool enable = TracerTraits::template enable< Rule >;
|
||||
|
||||
template< typename ParseInput >
|
||||
explicit tracer( const ParseInput& in )
|
||||
: m_flags( std::cerr.flags() ),
|
||||
m_position( in.position() )
|
||||
{
|
||||
std::cerr << std::left;
|
||||
print_position();
|
||||
}
|
||||
|
||||
tracer( const tracer& ) = delete;
|
||||
tracer( tracer&& ) = delete;
|
||||
|
||||
~tracer()
|
||||
{
|
||||
std::cerr.flags( m_flags );
|
||||
}
|
||||
|
||||
tracer& operator=( const tracer& ) = delete;
|
||||
tracer& operator=( tracer&& ) = delete;
|
||||
|
||||
[[nodiscard]] std::size_t indent() const noexcept
|
||||
{
|
||||
return TracerTraits::initial_indent + TracerTraits::indent_increment * m_stack.size();
|
||||
}
|
||||
|
||||
void print_position() const
|
||||
{
|
||||
std::cerr << std::setw( indent() ) << ' ' << TracerTraits::ansi_position << "position" << TracerTraits::ansi_reset << ' ' << m_position << '\n';
|
||||
}
|
||||
|
||||
void update_position( const position& p )
|
||||
{
|
||||
if( m_position != p ) {
|
||||
m_position = p;
|
||||
print_position();
|
||||
}
|
||||
}
|
||||
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void start( const ParseInput& /*unused*/, States&&... /*unused*/ )
|
||||
{
|
||||
std::cerr << '#' << std::setw( indent() - 1 ) << ++m_count << TracerTraits::ansi_rule << demangle< Rule >() << TracerTraits::ansi_reset << '\n';
|
||||
m_stack.push_back( m_count );
|
||||
}
|
||||
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void success( const ParseInput& in, States&&... /*unused*/ )
|
||||
{
|
||||
const auto prev = m_stack.back();
|
||||
m_stack.pop_back();
|
||||
std::cerr << std::setw( indent() ) << ' ' << TracerTraits::ansi_success << "success" << TracerTraits::ansi_reset;
|
||||
if( m_count != prev ) {
|
||||
std::cerr << " #" << prev << ' ' << TracerTraits::ansi_hide << demangle< Rule >() << TracerTraits::ansi_reset;
|
||||
}
|
||||
std::cerr << '\n';
|
||||
update_position( in.position() );
|
||||
}
|
||||
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void failure( const ParseInput& in, States&&... /*unused*/ )
|
||||
{
|
||||
const auto prev = m_stack.back();
|
||||
m_stack.pop_back();
|
||||
std::cerr << std::setw( indent() ) << ' ' << TracerTraits::ansi_failure << "failure" << TracerTraits::ansi_reset;
|
||||
if( m_count != prev ) {
|
||||
std::cerr << " #" << prev << ' ' << TracerTraits::ansi_hide << demangle< Rule >() << TracerTraits::ansi_reset;
|
||||
}
|
||||
std::cerr << '\n';
|
||||
update_position( in.position() );
|
||||
}
|
||||
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void raise( const ParseInput& /*unused*/, States&&... /*unused*/ )
|
||||
{
|
||||
std::cerr << std::setw( indent() ) << ' ' << TracerTraits::ansi_raise << "raise" << TracerTraits::ansi_reset << ' ' << TracerTraits::ansi_rule << demangle< Rule >() << TracerTraits::ansi_reset << '\n';
|
||||
}
|
||||
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void unwind( const ParseInput& in, States&&... /*unused*/ )
|
||||
{
|
||||
const auto prev = m_stack.back();
|
||||
m_stack.pop_back();
|
||||
std::cerr << std::setw( indent() ) << ' ' << TracerTraits::ansi_unwind << "unwind" << TracerTraits::ansi_reset;
|
||||
if( m_count != prev ) {
|
||||
std::cerr << " #" << prev << ' ' << TracerTraits::ansi_hide << demangle< Rule >() << TracerTraits::ansi_reset;
|
||||
}
|
||||
std::cerr << '\n';
|
||||
update_position( in.position() );
|
||||
}
|
||||
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void apply( const ParseInput& /*unused*/, States&&... /*unused*/ )
|
||||
{
|
||||
std::cerr << std::setw( static_cast< int >( indent() - TracerTraits::indent_increment ) ) << ' ' << TracerTraits::ansi_apply << "apply" << TracerTraits::ansi_reset << '\n';
|
||||
}
|
||||
|
||||
template< typename Rule, typename ParseInput, typename... States >
|
||||
void apply0( const ParseInput& /*unused*/, States&&... /*unused*/ )
|
||||
{
|
||||
std::cerr << std::setw( static_cast< int >( indent() - TracerTraits::indent_increment ) ) << ' ' << TracerTraits::ansi_apply << "apply0" << TracerTraits::ansi_reset << '\n';
|
||||
}
|
||||
|
||||
template< typename Rule,
|
||||
template< typename... > class Action = nothing,
|
||||
template< typename... > class Control = normal,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
bool parse( ParseInput&& in, States&&... st )
|
||||
{
|
||||
return TAO_PEGTL_NAMESPACE::parse< Rule, Action, state_control< Control >::template type >( in, st..., *this );
|
||||
}
|
||||
};
|
||||
|
||||
template< typename Rule,
|
||||
template< typename... > class Action = nothing,
|
||||
template< typename... > class Control = normal,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
bool standard_trace( ParseInput&& in, States&&... st )
|
||||
{
|
||||
tracer< standard_tracer_traits > tr( in );
|
||||
return tr.parse< Rule, Action, Control >( in, st... );
|
||||
}
|
||||
|
||||
template< typename Rule,
|
||||
template< typename... > class Action = nothing,
|
||||
template< typename... > class Control = normal,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
bool complete_trace( ParseInput&& in, States&&... st )
|
||||
{
|
||||
tracer< complete_tracer_traits > tr( in );
|
||||
return tr.parse< Rule, Action, Control >( in, st... );
|
||||
}
|
||||
|
||||
template< typename Tracer >
|
||||
struct trace
|
||||
: maybe_nothing
|
||||
{
|
||||
template< typename Rule,
|
||||
apply_mode A,
|
||||
rewind_mode M,
|
||||
template< typename... >
|
||||
class Action,
|
||||
template< typename... >
|
||||
class Control,
|
||||
typename ParseInput,
|
||||
typename... States >
|
||||
[[nodiscard]] static bool match( ParseInput& in, States&&... st )
|
||||
{
|
||||
if constexpr( sizeof...( st ) == 0 ) {
|
||||
return TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, state_control< Control >::template type >( in, st..., Tracer( in ) );
|
||||
}
|
||||
else if constexpr( !std::is_same_v< std::tuple_element_t< sizeof...( st ) - 1, std::tuple< States... > >, Tracer& > ) {
|
||||
return TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, state_control< Control >::template type >( in, st..., Tracer( in ) );
|
||||
}
|
||||
else {
|
||||
return TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, st... );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
using trace_standard = trace< tracer< standard_tracer_traits > >;
|
||||
using trace_complete = trace< tracer< complete_tracer_traits > >;
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,62 +0,0 @@
|
|||
// Copyright (c) 2018-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_UINT16_HPP
|
||||
#define TAO_PEGTL_CONTRIB_UINT16_HPP
|
||||
|
||||
#include "../config.hpp"
|
||||
#include "../internal/result_on_found.hpp"
|
||||
#include "../internal/rules.hpp"
|
||||
|
||||
#include "internal/peek_mask_uint.hpp"
|
||||
#include "internal/peek_uint.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace uint16_be
|
||||
{
|
||||
// clang-format off
|
||||
struct any : internal::any< internal::peek_uint16_be > {};
|
||||
|
||||
template< std::uint16_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint16_be, Cs... > {};
|
||||
template< std::uint16_t Lo, std::uint16_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint16_be, Lo, Hi > {};
|
||||
template< std::uint16_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint16_be, Cs... > {};
|
||||
template< std::uint16_t Lo, std::uint16_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint16_be, Lo, Hi > {};
|
||||
template< std::uint16_t... Cs > struct ranges : internal::ranges< internal::peek_uint16_be, Cs... > {};
|
||||
template< std::uint16_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint16_be, Cs >... > {};
|
||||
|
||||
template< std::uint16_t M, std::uint16_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint16_be< M >, Cs... > {};
|
||||
template< std::uint16_t M, std::uint16_t Lo, std::uint16_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint16_be< M >, Lo, Hi > {};
|
||||
template< std::uint16_t M, std::uint16_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint16_be< M >, Cs... > {};
|
||||
template< std::uint16_t M, std::uint16_t Lo, std::uint16_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint16_be< M >, Lo, Hi > {};
|
||||
template< std::uint16_t M, std::uint16_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint16_be< M >, Cs... > {};
|
||||
template< std::uint16_t M, std::uint16_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint16_be< M >, Cs >... > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace uint16_be
|
||||
|
||||
namespace uint16_le
|
||||
{
|
||||
// clang-format off
|
||||
struct any : internal::any< internal::peek_uint16_le > {};
|
||||
|
||||
template< std::uint16_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint16_le, Cs... > {};
|
||||
template< std::uint16_t Lo, std::uint16_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint16_le, Lo, Hi > {};
|
||||
template< std::uint16_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint16_le, Cs... > {};
|
||||
template< std::uint16_t Lo, std::uint16_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint16_le, Lo, Hi > {};
|
||||
template< std::uint16_t... Cs > struct ranges : internal::ranges< internal::peek_uint16_le, Cs... > {};
|
||||
template< std::uint16_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint16_le, Cs >... > {};
|
||||
|
||||
template< std::uint16_t M, std::uint16_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint16_le< M >, Cs... > {};
|
||||
template< std::uint16_t M, std::uint16_t Lo, std::uint16_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint16_le< M >, Lo, Hi > {};
|
||||
template< std::uint16_t M, std::uint16_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint16_le< M >, Cs... > {};
|
||||
template< std::uint16_t M, std::uint16_t Lo, std::uint16_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint16_le< M >, Lo, Hi > {};
|
||||
template< std::uint16_t M, std::uint16_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint16_le< M >, Cs... > {};
|
||||
template< std::uint16_t M, std::uint16_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint16_le< M >, Cs >... > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace uint16_le
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,62 +0,0 @@
|
|||
// Copyright (c) 2018-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_UINT32_HPP
|
||||
#define TAO_PEGTL_CONTRIB_UINT32_HPP
|
||||
|
||||
#include "../config.hpp"
|
||||
#include "../internal/result_on_found.hpp"
|
||||
#include "../internal/rules.hpp"
|
||||
|
||||
#include "internal/peek_mask_uint.hpp"
|
||||
#include "internal/peek_uint.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace uint32_be
|
||||
{
|
||||
// clang-format off
|
||||
struct any : internal::any< internal::peek_uint32_be > {};
|
||||
|
||||
template< std::uint32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint32_be, Cs... > {};
|
||||
template< std::uint32_t Lo, std::uint32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint32_be, Lo, Hi > {};
|
||||
template< std::uint32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint32_be, Cs... > {};
|
||||
template< std::uint32_t Lo, std::uint32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint32_be, Lo, Hi > {};
|
||||
template< std::uint32_t... Cs > struct ranges : internal::ranges< internal::peek_uint32_be, Cs... > {};
|
||||
template< std::uint32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint32_be, Cs >... > {};
|
||||
|
||||
template< std::uint32_t M, std::uint32_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint32_be< M >, Cs... > {};
|
||||
template< std::uint32_t M, std::uint32_t Lo, std::uint32_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint32_be< M >, Lo, Hi > {};
|
||||
template< std::uint32_t M, std::uint32_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint32_be< M >, Cs... > {};
|
||||
template< std::uint32_t M, std::uint32_t Lo, std::uint32_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint32_be< M >, Lo, Hi > {};
|
||||
template< std::uint32_t M, std::uint32_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint32_be< M >, Cs... > {};
|
||||
template< std::uint32_t M, std::uint32_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint32_be< M >, Cs >... > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace uint32_be
|
||||
|
||||
namespace uint32_le
|
||||
{
|
||||
// clang-format off
|
||||
struct any : internal::any< internal::peek_uint32_le > {};
|
||||
|
||||
template< std::uint32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint32_le, Cs... > {};
|
||||
template< std::uint32_t Lo, std::uint32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint32_le, Lo, Hi > {};
|
||||
template< std::uint32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint32_le, Cs... > {};
|
||||
template< std::uint32_t Lo, std::uint32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint32_le, Lo, Hi > {};
|
||||
template< std::uint32_t... Cs > struct ranges : internal::ranges< internal::peek_uint32_le, Cs... > {};
|
||||
template< std::uint32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint32_le, Cs >... > {};
|
||||
|
||||
template< std::uint32_t M, std::uint32_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint32_le< M >, Cs... > {};
|
||||
template< std::uint32_t M, std::uint32_t Lo, std::uint32_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint32_le< M >, Lo, Hi > {};
|
||||
template< std::uint32_t M, std::uint32_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint32_le< M >, Cs... > {};
|
||||
template< std::uint32_t M, std::uint32_t Lo, std::uint32_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint32_le< M >, Lo, Hi > {};
|
||||
template< std::uint32_t M, std::uint32_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint32_le< M >, Cs... > {};
|
||||
template< std::uint32_t M, std::uint32_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint32_le< M >, Cs >... > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace uint32_le
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,63 +0,0 @@
|
|||
// Copyright (c) 2018-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_UINT64_HPP
|
||||
#define TAO_PEGTL_CONTRIB_UINT64_HPP
|
||||
|
||||
#include "../config.hpp"
|
||||
#include "../internal/result_on_found.hpp"
|
||||
#include "../internal/rules.hpp"
|
||||
|
||||
#include "internal/peek_mask_uint.hpp"
|
||||
#include "internal/peek_uint.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace uint64_be
|
||||
{
|
||||
// clang-format off
|
||||
struct any : internal::any< internal::peek_uint64_be > {};
|
||||
|
||||
template< std::uint64_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint64_be, Cs... > {};
|
||||
template< std::uint64_t Lo, std::uint64_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint64_be, Lo, Hi > {};
|
||||
template< std::uint64_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint64_be, Cs... > {};
|
||||
template< std::uint64_t Lo, std::uint64_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint64_be, Lo, Hi > {};
|
||||
template< std::uint64_t... Cs > struct ranges : internal::ranges< internal::peek_uint64_be, Cs... > {};
|
||||
template< std::uint64_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint64_be, Cs >... > {};
|
||||
|
||||
|
||||
template< std::uint64_t M, std::uint64_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint64_be< M >, Cs... > {};
|
||||
template< std::uint64_t M, std::uint64_t Lo, std::uint64_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint64_be< M >, Lo, Hi > {};
|
||||
template< std::uint64_t M, std::uint64_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint64_be< M >, Cs... > {};
|
||||
template< std::uint64_t M, std::uint64_t Lo, std::uint64_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint64_be< M >, Lo, Hi > {};
|
||||
template< std::uint64_t M, std::uint64_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint64_be< M >, Cs... > {};
|
||||
template< std::uint64_t M, std::uint64_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint64_be< M >, Cs >... > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace uint64_be
|
||||
|
||||
namespace uint64_le
|
||||
{
|
||||
// clang-format off
|
||||
struct any : internal::any< internal::peek_uint64_le > {};
|
||||
|
||||
template< std::uint64_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint64_le, Cs... > {};
|
||||
template< std::uint64_t Lo, std::uint64_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint64_le, Lo, Hi > {};
|
||||
template< std::uint64_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint64_le, Cs... > {};
|
||||
template< std::uint64_t Lo, std::uint64_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint64_le, Lo, Hi > {};
|
||||
template< std::uint64_t... Cs > struct ranges : internal::ranges< internal::peek_uint64_le, Cs... > {};
|
||||
template< std::uint64_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint64_le, Cs >... > {};
|
||||
|
||||
template< std::uint64_t M, std::uint64_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint64_le< M >, Cs... > {};
|
||||
template< std::uint64_t M, std::uint64_t Lo, std::uint64_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint64_le< M >, Lo, Hi > {};
|
||||
template< std::uint64_t M, std::uint64_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint64_le< M >, Cs... > {};
|
||||
template< std::uint64_t M, std::uint64_t Lo, std::uint64_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint64_le< M >, Lo, Hi > {};
|
||||
template< std::uint64_t M, std::uint64_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint64_le< M >, Cs... > {};
|
||||
template< std::uint64_t M, std::uint64_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint64_le< M >, Cs >... > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace uint64_le
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,36 +0,0 @@
|
|||
// Copyright (c) 2018-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_UINT8_HPP
|
||||
#define TAO_PEGTL_CONTRIB_UINT8_HPP
|
||||
|
||||
#include "../config.hpp"
|
||||
#include "../internal/result_on_found.hpp"
|
||||
#include "../internal/rules.hpp"
|
||||
|
||||
#include "internal/peek_mask_uint8.hpp"
|
||||
#include "internal/peek_uint8.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::uint8
|
||||
{
|
||||
// clang-format off
|
||||
struct any : internal::any< internal::peek_uint8 > {};
|
||||
|
||||
template< std::uint8_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint8, Cs... > {};
|
||||
template< std::uint8_t Lo, std::uint8_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint8, Lo, Hi > {};
|
||||
template< std::uint8_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint8, Cs... > {};
|
||||
template< std::uint8_t Lo, std::uint8_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint8, Lo, Hi > {};
|
||||
template< std::uint8_t... Cs > struct ranges : internal::ranges< internal::peek_uint8, Cs... > {};
|
||||
template< std::uint8_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint8, Cs >... > {};
|
||||
|
||||
template< std::uint8_t M, std::uint8_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint8< M >, Cs... > {};
|
||||
template< std::uint8_t M, std::uint8_t Lo, std::uint8_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint8< M >, Lo, Hi > {};
|
||||
template< std::uint8_t M, std::uint8_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint8< M >, Cs... > {};
|
||||
template< std::uint8_t M, std::uint8_t Lo, std::uint8_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint8< M >, Lo, Hi > {};
|
||||
template< std::uint8_t M, std::uint8_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint8< M >, Cs... > {};
|
||||
template< std::uint8_t M, std::uint8_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint8< M >, Cs >... > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::uint8
|
||||
|
||||
#endif
|
|
@ -1,214 +0,0 @@
|
|||
// Copyright (c) 2014-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_UNESCAPE_HPP
|
||||
#define TAO_PEGTL_CONTRIB_UNESCAPE_HPP
|
||||
|
||||
#include <cassert>
|
||||
#include <exception>
|
||||
#include <string>
|
||||
|
||||
#include "../ascii.hpp"
|
||||
#include "../config.hpp"
|
||||
#include "../parse_error.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::unescape
|
||||
{
|
||||
// Utility functions for the unescape actions.
|
||||
|
||||
[[nodiscard]] inline bool utf8_append_utf32( std::string& string, const unsigned utf32 )
|
||||
{
|
||||
if( utf32 <= 0x7f ) {
|
||||
string += char( utf32 & 0xff );
|
||||
return true;
|
||||
}
|
||||
if( utf32 <= 0x7ff ) {
|
||||
char tmp[] = { char( ( ( utf32 & 0x7c0 ) >> 6 ) | 0xc0 ),
|
||||
char( ( ( utf32 & 0x03f ) ) | 0x80 ) };
|
||||
string.append( tmp, sizeof( tmp ) );
|
||||
return true;
|
||||
}
|
||||
if( utf32 <= 0xffff ) {
|
||||
if( utf32 >= 0xd800 && utf32 <= 0xdfff ) {
|
||||
// nope, this is a UTF-16 surrogate
|
||||
return false;
|
||||
}
|
||||
char tmp[] = { char( ( ( utf32 & 0xf000 ) >> 12 ) | 0xe0 ),
|
||||
char( ( ( utf32 & 0x0fc0 ) >> 6 ) | 0x80 ),
|
||||
char( ( ( utf32 & 0x003f ) ) | 0x80 ) };
|
||||
string.append( tmp, sizeof( tmp ) );
|
||||
return true;
|
||||
}
|
||||
if( utf32 <= 0x10ffff ) {
|
||||
char tmp[] = { char( ( ( utf32 & 0x1c0000 ) >> 18 ) | 0xf0 ),
|
||||
char( ( ( utf32 & 0x03f000 ) >> 12 ) | 0x80 ),
|
||||
char( ( ( utf32 & 0x000fc0 ) >> 6 ) | 0x80 ),
|
||||
char( ( ( utf32 & 0x00003f ) ) | 0x80 ) };
|
||||
string.append( tmp, sizeof( tmp ) );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// This function MUST only be called for characters matching TAO_PEGTL_NAMESPACE::ascii::xdigit!
|
||||
template< typename I >
|
||||
[[nodiscard]] I unhex_char( const char c )
|
||||
{
|
||||
switch( c ) {
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
return I( c - '0' );
|
||||
case 'a':
|
||||
case 'b':
|
||||
case 'c':
|
||||
case 'd':
|
||||
case 'e':
|
||||
case 'f':
|
||||
return I( c - 'a' + 10 );
|
||||
case 'A':
|
||||
case 'B':
|
||||
case 'C':
|
||||
case 'D':
|
||||
case 'E':
|
||||
case 'F':
|
||||
return I( c - 'A' + 10 );
|
||||
default: // LCOV_EXCL_LINE
|
||||
std::terminate(); // LCOV_EXCL_LINE
|
||||
}
|
||||
}
|
||||
|
||||
template< typename I >
|
||||
[[nodiscard]] I unhex_string( const char* begin, const char* end )
|
||||
{
|
||||
I r = 0;
|
||||
while( begin != end ) {
|
||||
r <<= 4;
|
||||
r += unhex_char< I >( *begin++ );
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
// Actions for common unescape situations.
|
||||
|
||||
struct append_all
|
||||
{
|
||||
template< typename ActionInput >
|
||||
static void apply( const ActionInput& in, std::string& s )
|
||||
{
|
||||
s.append( in.begin(), in.size() );
|
||||
}
|
||||
};
|
||||
|
||||
// This action MUST be called for a character matching T which MUST be TAO_PEGTL_NAMESPACE::one< ... >.
|
||||
template< typename T, char... Rs >
|
||||
struct unescape_c
|
||||
{
|
||||
template< typename ActionInput >
|
||||
static void apply( const ActionInput& in, std::string& s )
|
||||
{
|
||||
assert( in.size() == 1 );
|
||||
s += apply_one( in, static_cast< const T* >( nullptr ) );
|
||||
}
|
||||
|
||||
template< typename ActionInput, char... Qs >
|
||||
[[nodiscard]] static char apply_one( const ActionInput& in, const one< Qs... >* /*unused*/ )
|
||||
{
|
||||
static_assert( sizeof...( Qs ) == sizeof...( Rs ), "size mismatch between escaped characters and their mappings" );
|
||||
return apply_two( in, { Qs... }, { Rs... } );
|
||||
}
|
||||
|
||||
template< typename ActionInput >
|
||||
[[nodiscard]] static char apply_two( const ActionInput& in, const std::initializer_list< char >& q, const std::initializer_list< char >& r )
|
||||
{
|
||||
const char c = *in.begin();
|
||||
for( std::size_t i = 0; i < q.size(); ++i ) {
|
||||
if( *( q.begin() + i ) == c ) {
|
||||
return *( r.begin() + i );
|
||||
}
|
||||
}
|
||||
std::terminate(); // LCOV_EXCL_LINE
|
||||
}
|
||||
};
|
||||
|
||||
// See src/example/pegtl/unescape.cpp for why the following two actions
|
||||
// skip the first input character. They also MUST be called
|
||||
// with non-empty matched inputs!
|
||||
|
||||
struct unescape_u
|
||||
{
|
||||
#if defined( __cpp_exceptions )
|
||||
template< typename ActionInput >
|
||||
static void apply( const ActionInput& in, std::string& s )
|
||||
{
|
||||
assert( !in.empty() ); // First character MUST be present, usually 'u' or 'U'.
|
||||
if( !utf8_append_utf32( s, unhex_string< unsigned >( in.begin() + 1, in.end() ) ) ) {
|
||||
throw parse_error( "invalid escaped unicode code point", in );
|
||||
}
|
||||
}
|
||||
#else
|
||||
template< typename ActionInput >
|
||||
static bool apply( const ActionInput& in, std::string& s )
|
||||
{
|
||||
assert( !in.empty() ); // First character MUST be present, usually 'u' or 'U'.
|
||||
return utf8_append_utf32( s, unhex_string< unsigned >( in.begin() + 1, in.end() ) );
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct unescape_x
|
||||
{
|
||||
template< typename ActionInput >
|
||||
static void apply( const ActionInput& in, std::string& s )
|
||||
{
|
||||
assert( !in.empty() ); // First character MUST be present, usually 'x'.
|
||||
s += unhex_string< char >( in.begin() + 1, in.end() );
|
||||
}
|
||||
};
|
||||
|
||||
// The unescape_j action is similar to unescape_u, however unlike
|
||||
// unescape_u it
|
||||
// (a) assumes exactly 4 hexdigits per escape sequence,
|
||||
// (b) accepts multiple consecutive escaped 16-bit values.
|
||||
// When applied to more than one escape sequence, unescape_j
|
||||
// translates UTF-16 surrogate pairs in the input into a single
|
||||
// UTF-8 sequence in s, as required for JSON by RFC 8259.
|
||||
|
||||
struct unescape_j
|
||||
{
|
||||
template< typename ActionInput >
|
||||
static bool apply( const ActionInput& in, std::string& s )
|
||||
{
|
||||
assert( ( ( in.size() + 1 ) % 6 ) == 0 ); // Expects multiple "\\u1234", starting with the first "u".
|
||||
for( const char* b = in.begin() + 1; b < in.end(); b += 6 ) {
|
||||
const auto c = unhex_string< unsigned >( b, b + 4 );
|
||||
if( ( 0xd800 <= c ) && ( c <= 0xdbff ) && ( b + 6 < in.end() ) ) {
|
||||
const auto d = unhex_string< unsigned >( b + 6, b + 10 );
|
||||
if( ( 0xdc00 <= d ) && ( d <= 0xdfff ) ) {
|
||||
b += 6;
|
||||
(void)utf8_append_utf32( s, ( ( ( c & 0x03ff ) << 10 ) | ( d & 0x03ff ) ) + 0x10000 );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if( !utf8_append_utf32( s, c ) ) {
|
||||
#if defined( __cpp_exceptions )
|
||||
throw parse_error( "invalid escaped unicode code point", in );
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::unescape
|
||||
|
||||
#endif
|
|
@ -1,111 +0,0 @@
|
|||
// Copyright (c) 2014-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_URI_HPP
|
||||
#define TAO_PEGTL_CONTRIB_URI_HPP
|
||||
|
||||
#if !defined( __cpp_exceptions )
|
||||
#error "Exception support required for tao/pegtl/contrib/uri.hpp"
|
||||
#else
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "../ascii.hpp"
|
||||
#include "../config.hpp"
|
||||
#include "../rules.hpp"
|
||||
#include "../utf8.hpp"
|
||||
|
||||
#include "abnf.hpp"
|
||||
#include "integer.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE::uri
|
||||
{
|
||||
// URI grammar according to RFC 3986.
|
||||
|
||||
// This grammar is a direct PEG translation of the original URI grammar.
|
||||
// It should be considered experimental -- in case of any issues, in particular
|
||||
// missing rules for attached actions, please contact the developers.
|
||||
|
||||
// Note that this grammar has multiple top-level rules.
|
||||
|
||||
using dot = one< '.' >;
|
||||
using colon = one< ':' >;
|
||||
|
||||
// clang-format off
|
||||
struct dec_octet : maximum_rule< std::uint8_t > {};
|
||||
|
||||
struct IPv4address : seq< dec_octet, dot, dec_octet, dot, dec_octet, dot, dec_octet > {};
|
||||
|
||||
struct h16 : rep_min_max< 1, 4, abnf::HEXDIG > {};
|
||||
struct ls32 : sor< seq< h16, colon, h16 >, IPv4address > {};
|
||||
|
||||
struct dcolon : two< ':' > {};
|
||||
|
||||
struct IPv6address : sor< seq< rep< 6, h16, colon >, ls32 >,
|
||||
seq< dcolon, rep< 5, h16, colon >, ls32 >,
|
||||
seq< opt< h16 >, dcolon, rep< 4, h16, colon >, ls32 >,
|
||||
seq< opt< h16, opt< colon, h16 > >, dcolon, rep< 3, h16, colon >, ls32 >,
|
||||
seq< opt< h16, rep_opt< 2, colon, h16 > >, dcolon, rep< 2, h16, colon >, ls32 >,
|
||||
seq< opt< h16, rep_opt< 3, colon, h16 > >, dcolon, h16, colon, ls32 >,
|
||||
seq< opt< h16, rep_opt< 4, colon, h16 > >, dcolon, ls32 >,
|
||||
seq< opt< h16, rep_opt< 5, colon, h16 > >, dcolon, h16 >,
|
||||
seq< opt< h16, rep_opt< 6, colon, h16 > >, dcolon > > {};
|
||||
|
||||
struct gen_delims : one< ':', '/', '?', '#', '[', ']', '@' > {};
|
||||
struct sub_delims : one< '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=' > {};
|
||||
|
||||
struct unreserved : sor< abnf::ALPHA, abnf::DIGIT, one< '-', '.', '_', '~' > > {};
|
||||
struct reserved : sor< gen_delims, sub_delims > {};
|
||||
|
||||
struct IPvFuture : if_must< one< 'v', 'V' >, plus< abnf::HEXDIG >, dot, plus< sor< unreserved, sub_delims, colon > > > {};
|
||||
|
||||
struct IP_literal : if_must< one< '[' >, sor< IPvFuture, IPv6address >, one< ']' > > {};
|
||||
|
||||
struct pct_encoded : if_must< one< '%' >, abnf::HEXDIG, abnf::HEXDIG > {};
|
||||
struct pchar : sor< unreserved, pct_encoded, sub_delims, one< ':', '@' > > {};
|
||||
|
||||
struct query : star< sor< pchar, one< '/', '?' > > > {};
|
||||
struct fragment : star< sor< pchar, one< '/', '?' > > > {};
|
||||
|
||||
struct segment : star< pchar > {};
|
||||
struct segment_nz : plus< pchar > {};
|
||||
struct segment_nz_nc : plus< sor< unreserved, pct_encoded, sub_delims, one< '@' > > > {}; // non-zero-length segment without any colon ":"
|
||||
|
||||
struct path_abempty : star< one< '/' >, segment > {};
|
||||
struct path_absolute : seq< one< '/' >, opt< segment_nz, star< one< '/' >, segment > > > {};
|
||||
struct path_noscheme : seq< segment_nz_nc, star< one< '/' >, segment > > {};
|
||||
struct path_rootless : seq< segment_nz, star< one< '/' >, segment > > {};
|
||||
struct path_empty : success {};
|
||||
|
||||
struct path : sor< path_noscheme, // begins with a non-colon segment
|
||||
path_rootless, // begins with a segment
|
||||
path_absolute, // begins with "/" but not "//"
|
||||
path_abempty > {}; // begins with "/" or is empty
|
||||
|
||||
struct reg_name : star< sor< unreserved, pct_encoded, sub_delims > > {};
|
||||
|
||||
struct port : star< abnf::DIGIT > {};
|
||||
struct host : sor< IP_literal, IPv4address, reg_name > {};
|
||||
struct userinfo : star< sor< unreserved, pct_encoded, sub_delims, colon > > {};
|
||||
struct opt_userinfo : opt< userinfo, one< '@' > > {};
|
||||
struct authority : seq< opt_userinfo, host, opt< colon, port > > {};
|
||||
|
||||
struct scheme : seq< abnf::ALPHA, star< sor< abnf::ALPHA, abnf::DIGIT, one< '+', '-', '.' > > > > {};
|
||||
|
||||
using dslash = two< '/' >;
|
||||
using opt_query = opt_must< one< '?' >, query >;
|
||||
using opt_fragment = opt_must< one< '#' >, fragment >;
|
||||
|
||||
struct hier_part : sor< if_must< dslash, authority, path_abempty >, path_rootless, path_absolute, path_empty > {};
|
||||
struct relative_part : sor< if_must< dslash, authority, path_abempty >, path_noscheme, path_absolute, path_empty > {};
|
||||
struct relative_ref : seq< relative_part, opt_query, opt_fragment > {};
|
||||
|
||||
struct URI : seq< scheme, one< ':' >, hier_part, opt_query, opt_fragment > {};
|
||||
struct URI_reference : sor< URI, relative_ref > {};
|
||||
struct absolute_URI : seq< scheme, one< ':' >, hier_part, opt_query > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE::uri
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -1,57 +0,0 @@
|
|||
// Copyright (c) 2015-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_UTF16_HPP
|
||||
#define TAO_PEGTL_CONTRIB_UTF16_HPP
|
||||
|
||||
#include "../config.hpp"
|
||||
#include "../internal/result_on_found.hpp"
|
||||
#include "../internal/rules.hpp"
|
||||
|
||||
#include "internal/peek_utf16.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace utf16_be
|
||||
{
|
||||
// clang-format off
|
||||
struct any : internal::any< internal::peek_utf16_be > {};
|
||||
struct bom : internal::one< internal::result_on_found::success, internal::peek_utf16_be, 0xfeff > {};
|
||||
template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_utf16_be, Cs... > {};
|
||||
template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_utf16_be, Lo, Hi > {};
|
||||
template< char32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_utf16_be, Cs... > {};
|
||||
template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_utf16_be, Lo, Hi > {};
|
||||
template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf16_be, Cs... > {};
|
||||
template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_utf16_be, Cs >... > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace utf16_be
|
||||
|
||||
namespace utf16_le
|
||||
{
|
||||
// clang-format off
|
||||
struct any : internal::any< internal::peek_utf16_le > {};
|
||||
struct bom : internal::one< internal::result_on_found::success, internal::peek_utf16_le, 0xfeff > {};
|
||||
template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_utf16_le, Cs... > {};
|
||||
template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_utf16_le, Lo, Hi > {};
|
||||
template< char32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_utf16_le, Cs... > {};
|
||||
template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_utf16_le, Lo, Hi > {};
|
||||
template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf16_le, Cs... > {};
|
||||
template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_utf16_le, Cs >... > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace utf16_le
|
||||
|
||||
#if defined( _WIN32 ) && !defined( __MINGW32__ ) && !defined( __CYGWIN__ )
|
||||
namespace utf16 = utf16_le;
|
||||
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
namespace utf16 = utf16_le;
|
||||
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
namespace utf16 = utf16_be;
|
||||
#else
|
||||
#error Unknown endianness.
|
||||
#endif
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
|
@ -1,57 +0,0 @@
|
|||
// Copyright (c) 2014-2022 Dr. Colin Hirsch and Daniel Frey
|
||||
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
|
||||
|
||||
#ifndef TAO_PEGTL_CONTRIB_UTF32_HPP
|
||||
#define TAO_PEGTL_CONTRIB_UTF32_HPP
|
||||
|
||||
#include "../config.hpp"
|
||||
#include "../internal/result_on_found.hpp"
|
||||
#include "../internal/rules.hpp"
|
||||
|
||||
#include "internal/peek_utf32.hpp"
|
||||
|
||||
namespace TAO_PEGTL_NAMESPACE
|
||||
{
|
||||
namespace utf32_be
|
||||
{
|
||||
// clang-format off
|
||||
struct any : internal::any< internal::peek_utf32_be > {};
|
||||
struct bom : internal::one< internal::result_on_found::success, internal::peek_utf32_be, 0xfeff > {};
|
||||
template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_utf32_be, Cs... > {};
|
||||
template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_utf32_be, Lo, Hi > {};
|
||||
template< char32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_utf32_be, Cs... > {};
|
||||
template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_utf32_be, Lo, Hi > {};
|
||||
template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf32_be, Cs... > {};
|
||||
template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_utf32_be, Cs >... > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace utf32_be
|
||||
|
||||
namespace utf32_le
|
||||
{
|
||||
// clang-format off
|
||||
struct any : internal::any< internal::peek_utf32_le > {};
|
||||
struct bom : internal::one< internal::result_on_found::success, internal::peek_utf32_le, 0xfeff > {};
|
||||
template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_utf32_le, Cs... > {};
|
||||
template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_utf32_le, Lo, Hi > {};
|
||||
template< char32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_utf32_le, Cs... > {};
|
||||
template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_utf32_le, Lo, Hi > {};
|
||||
template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf32_le, Cs... > {};
|
||||
template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_utf32_le, Cs >... > {};
|
||||
// clang-format on
|
||||
|
||||
} // namespace utf32_le
|
||||
|
||||
#if defined( _WIN32 ) && !defined( __MINGW32__ ) && !defined( __CYGWIN__ )
|
||||
namespace utf32 = utf32_le;
|
||||
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
namespace utf32 = utf32_le;
|
||||
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
namespace utf32 = utf32_be;
|
||||
#else
|
||||
#error Unknown endianness.
|
||||
#endif
|
||||
|
||||
} // namespace TAO_PEGTL_NAMESPACE
|
||||
|
||||
#endif
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue