diff --git a/packages/PEGTL/.clang-format b/packages/PEGTL/.clang-format index a3f254129f2326865c1ca172033c1b99f63f3a11..a111c83a236556e655e3e6c887f295e058cdd29b 100644 --- a/packages/PEGTL/.clang-format +++ b/packages/PEGTL/.clang-format @@ -1,10 +1,14 @@ # The Art of C++ -# https://github.com/PEGTL +# https://github.com/taocpp -# Copyright (c) 2016-2021 Daniel Frey +# Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) +# This is our official .clang-format style for https://github.com/taocpp +# +# clang-format -i -style=file $(find . -name '[^.]*.[hc]pp') + Language: Cpp Standard: Latest diff --git a/packages/PEGTL/.clang-tidy b/packages/PEGTL/.clang-tidy index b98e0d8b54747e3497f2e0376815d17fa55c98ac..d938e19e0f61b42ebc7d62874f0ea1a2dae2ee0b 100644 --- a/packages/PEGTL/.clang-tidy +++ b/packages/PEGTL/.clang-tidy @@ -1,12 +1,13 @@ # The Art of C++ -# https://github.com/PEGTL +# https://github.com/taocpp -# Copyright (c) 2016-2021 Daniel Frey +# Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) Checks: >- bugprone-*, + -bugprone-easily-swappable-parameters, cppcoreguidelines-slicing, cppcoreguidelines-special-member-functions, google-build-explicit-make-pair, @@ -28,6 +29,8 @@ Checks: >- performance-*, readability-*, -readability-avoid-const-params-in-decls, + -readability-function-cognitive-complexity, + -readability-identifier-length, -readability-magic-numbers, -readability-static-accessed-through-instance, diff --git a/packages/PEGTL/.github/workflows/android.yml b/packages/PEGTL/.github/workflows/android.yml index 44515ed7c67d1f4cfda8c7a4f35e5c735bc3d243..11b3c2e009426471a477a82bcdb8acb461d06746 100644 --- a/packages/PEGTL/.github/workflows/android.yml +++ b/packages/PEGTL/.github/workflows/android.yml @@ -32,7 +32,7 @@ jobs: options: --user root steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - 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 }} diff --git a/packages/PEGTL/.github/workflows/clang-analyze.yml b/packages/PEGTL/.github/workflows/clang-analyze.yml index 3919398d2e2a4c3402d4d95d86bbddbae4f4a410..344fc8b4f68397edd996903ef11e08a71a8ef024 100644 --- a/packages/PEGTL/.github/workflows/clang-analyze.yml +++ b/packages/PEGTL/.github/workflows/clang-analyze.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - run: sudo apt-get update -yq diff --git a/packages/PEGTL/.github/workflows/clang-format.yml b/packages/PEGTL/.github/workflows/clang-format.yml index a6aae1ae70f2a07d4c113f98034ece5124e5ec52..472ebafdbadf2f176f90bebd07cec074c98f1a02 100644 --- a/packages/PEGTL/.github/workflows/clang-format.yml +++ b/packages/PEGTL/.github/workflows/clang-format.yml @@ -15,8 +15,8 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: DoozyX/clang-format-lint-action@v0.12 + - uses: actions/checkout@v3 + - uses: DoozyX/clang-format-lint-action@v0.15 with: extensions: 'hpp,cpp' - clangFormatVersion: 12 + clangFormatVersion: 15 diff --git a/packages/PEGTL/.github/workflows/clang-tidy.yml b/packages/PEGTL/.github/workflows/clang-tidy.yml index 6f640820ac1e9ea0652c3f483b463346e27801d6..d095bce35f99d40a2b91129dcb78d9d4459bc01a 100644 --- a/packages/PEGTL/.github/workflows/clang-tidy.yml +++ b/packages/PEGTL/.github/workflows/clang-tidy.yml @@ -15,12 +15,12 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - 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 include/ -name '*.hpp' | grep -vF mmap_file_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 diff --git a/packages/PEGTL/.github/workflows/code-coverage.yml b/packages/PEGTL/.github/workflows/code-coverage.yml index 537752ad00839fed46cebed0281f35d6f09a6f5b..10b4c282e9e393caca5c9e001324bd4f6281c3c3 100644 --- a/packages/PEGTL/.github/workflows/code-coverage.yml +++ b/packages/PEGTL/.github/workflows/code-coverage.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - run: cmake -E make_directory build diff --git a/packages/PEGTL/.github/workflows/codeql-analysis.yml b/packages/PEGTL/.github/workflows/codeql-analysis.yml index d0f90dfac25b137fc821ff4e7b08d572c74c9741..5f688f37bf2b96bb004ae9216e7eabede83f2f4b 100644 --- a/packages/PEGTL/.github/workflows/codeql-analysis.yml +++ b/packages/PEGTL/.github/workflows/codeql-analysis.yml @@ -41,11 +41,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v2 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -56,7 +56,7 @@ jobs: # 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 + uses: github/codeql-action/autobuild@v2 # âšī¸ Command-line programs to run using the OS shell. # đ https://git.io/JvXDl @@ -70,4 +70,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v2 diff --git a/packages/PEGTL/.github/workflows/linux.yml b/packages/PEGTL/.github/workflows/linux.yml index d6f6d6ef76184ee0141ea1e8a74e612c958c2add..b3f95a4f23053aad8946d0fffca84e06397e2e7d 100644 --- a/packages/PEGTL/.github/workflows/linux.yml +++ b/packages/PEGTL/.github/workflows/linux.yml @@ -18,10 +18,11 @@ jobs: compiler: - g++-9 - g++-10 - #- g++-11 - - clang++-10 - - clang++-11 + - g++-11 + - g++-12 - clang++-12 + - clang++-13 + - clang++-14 build_type: [Debug, Release] runs-on: ubuntu-latest @@ -30,7 +31,7 @@ jobs: CXX: ${{ matrix.compiler }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - run: cmake -E make_directory build @@ -48,25 +49,26 @@ jobs: fail-fast: false matrix: compiler: - - g++-7 - g++-8 - clang++-6.0 - clang++-7 - clang++-8 - clang++-9 + - clang++-10 + - clang++-11 build_type: [Debug, Release] - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 env: CXX: ${{ matrix.compiler }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - run: sudo apt-get update -yq + - run: sudo apt-get update -y - - run: sudo apt-get install -yq ${{ matrix.compiler }} + - run: sudo apt-get install -y ${{ matrix.compiler }} - run: cmake -E make_directory build @@ -83,13 +85,13 @@ jobs: strategy: fail-fast: false matrix: - flags: ["-fno-rtti"] + flags: ["-fno-rtti", "-fno-exceptions"] build_type: [Debug, Release] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - run: cmake -E make_directory build @@ -106,7 +108,7 @@ jobs: strategy: fail-fast: false matrix: - flags: ["-fno-rtti", "-fms-extensions"] + flags: ["-fno-rtti", "-fno-exceptions", "-fms-extensions"] build_type: [Debug, Release] runs-on: ubuntu-latest @@ -115,7 +117,7 @@ jobs: CXX: clang++ steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - run: cmake -E make_directory build diff --git a/packages/PEGTL/.github/workflows/macos.yml b/packages/PEGTL/.github/workflows/macos.yml index a2dfade495df59b9173a2d79d7740606d127692e..842b1ab7cc9143d7421c75c50a1858a0408346f1 100644 --- a/packages/PEGTL/.github/workflows/macos.yml +++ b/packages/PEGTL/.github/workflows/macos.yml @@ -15,13 +15,35 @@ jobs: strategy: fail-fast: false matrix: - xcode: ['11', '12'] - build_type: [Debug, Release] - - runs-on: macos-latest + include: + - xcode: 11 + build_type: Debug + os: macos-11 + - xcode: 11 + build_type: Release + os: macos-11 + - xcode: 12 + build_type: Debug + os: macos-11 + - xcode: 12 + build_type: Release + os: macos-11 + - xcode: 13 + build_type: Debug + os: macos-12 + - xcode: 13 + build_type: Release + os: macos-12 + - xcode: 14 + build_type: Debug + os: macos-12 + - xcode: 14 + build_type: Release + os: macos-12 + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: maxim-lobanov/setup-xcode@v1 with: diff --git a/packages/PEGTL/.github/workflows/no-exceptions.yml b/packages/PEGTL/.github/workflows/no-exceptions.yml deleted file mode 100644 index 25c49e0c53fd8fc95742cffe4184c690f126323a..0000000000000000000000000000000000000000 --- a/packages/PEGTL/.github/workflows/no-exceptions.yml +++ /dev/null @@ -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 diff --git a/packages/PEGTL/.github/workflows/sanitizer.yml b/packages/PEGTL/.github/workflows/sanitizer.yml index 5bcb8a9b045adb1a0620e298817a503abacd7fe5..86e4debef9c08ffcb00cf2ab3db4babe924dc33c 100644 --- a/packages/PEGTL/.github/workflows/sanitizer.yml +++ b/packages/PEGTL/.github/workflows/sanitizer.yml @@ -24,7 +24,7 @@ jobs: CXX: ${{ matrix.cxx }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - run: cmake -E make_directory build diff --git a/packages/PEGTL/.github/workflows/windows.yml b/packages/PEGTL/.github/workflows/windows.yml index e474984856325ae1cd2f8e064bf804161d8755a5..42eacfd4ae61aa7c504d55d468c93451583a0898 100644 --- a/packages/PEGTL/.github/workflows/windows.yml +++ b/packages/PEGTL/.github/workflows/windows.yml @@ -11,7 +11,7 @@ on: - 'doc/**' jobs: - vs2019: + vs2022: strategy: fail-fast: false matrix: @@ -20,13 +20,13 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - run: cmake -E make_directory build - shell: bash working-directory: build/ - run: cmake $GITHUB_WORKSPACE -G "Visual Studio 16 2019" + run: cmake $GITHUB_WORKSPACE -G "Visual Studio 17 2022" - working-directory: build/ run: cmake --build . --config ${{ matrix.build_type }} @@ -34,7 +34,7 @@ jobs: - working-directory: build/ run: ctest -C ${{ matrix.build_type }} --output-on-failure - vs2019-clang: + vs2022-clang: strategy: fail-fast: false matrix: @@ -43,13 +43,13 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - run: cmake -E make_directory build - shell: bash working-directory: build/ - run: cmake $GITHUB_WORKSPACE -G "Visual Studio 16 2019" -T ClangCL + run: cmake $GITHUB_WORKSPACE -G "Visual Studio 17 2022" -T ClangCL - working-directory: build/ run: cmake --build . --config ${{ matrix.build_type }} @@ -57,25 +57,45 @@ jobs: - working-directory: build/ run: ctest -C ${{ matrix.build_type }} --output-on-failure - vs2017: + vs2019: strategy: fail-fast: false matrix: - visual_studio: - - 'Visual Studio 15 2017' - - 'Visual Studio 15 2017 Win64' build_type: [Debug, Release] - runs-on: windows-2016 + runs-on: windows-2019 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - run: cmake -E make_directory build - shell: bash working-directory: build/ - run: cmake $GITHUB_WORKSPACE -G "${{ matrix.visual_studio }}" + 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@v3 + + - 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 }} diff --git a/packages/PEGTL/.gitignore b/packages/PEGTL/.gitignore index da92b797d9a088c1565721bad71c5a4f22b94574..7ca4d8d6e46225865c34526961a2ac5d8251da27 100644 --- a/packages/PEGTL/.gitignore +++ b/packages/PEGTL/.gitignore @@ -3,3 +3,4 @@ build private /.vs /.vscode +.DS_Store diff --git a/packages/PEGTL/.gitrepo b/packages/PEGTL/.gitrepo index 279480bff62486421386892258910b04da453b3a..4ac43b7e4044c9880feadfc6c4cbcf5f5fdf40a2 100644 --- a/packages/PEGTL/.gitrepo +++ b/packages/PEGTL/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = git@github.com:taocpp/PEGTL.git branch = main - commit = bf4487c9793121e483291c4e516cec3e5c1c17b5 + commit = dc3d82928755046be3d66efb3015ed8b03f299ac parent = e00b72ebcd9d2add12cfe0e6fe4d114a7858dfa5 method = merge - cmdver = 0.4.3 + cmdver = 0.4.6 diff --git a/packages/PEGTL/Makefile b/packages/PEGTL/Makefile index 773c525bbc936e079e33e33084a45ed33d5e7469..ac94306836276e997943612ea9b8c894ba611668 100644 --- a/packages/PEGTL/Makefile +++ b/packages/PEGTL/Makefile @@ -1,7 +1,7 @@ # The Art of C++ # https://github.com/PEGTL -# Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +# Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/README.md b/packages/PEGTL/README.md index 399b2bb3a7c3e74c628a5df6a11fb7731f30e250..b4883158f56da430e597c132fb41389430cfb968 100644 --- a/packages/PEGTL/README.md +++ b/packages/PEGTL/README.md @@ -1,30 +1,31 @@ # Welcome to the PEGTL -[](https://github.com/taocpp/PEGTL/actions?query=workflow%3AWindows) -[](https://github.com/taocpp/PEGTL/actions?query=workflow%3AmacOS) -[](https://github.com/taocpp/PEGTL/actions?query=workflow%3ALinux) -[](https://github.com/taocpp/PEGTL/actions?query=workflow%3AAndroid) +[](https://github.com/taocpp/PEGTL/actions/workflows/windows.yml) +[](https://github.com/taocpp/PEGTL/actions/workflows/macos.yml) +[](https://github.com/taocpp/PEGTL/actions/workflows/linux.yml) +[](https://github.com/taocpp/PEGTL/actions/workflows/android.yml) <br> -[](https://github.com/taocpp/PEGTL/actions?query=workflow%3Aclang-analyze) -[](https://github.com/taocpp/PEGTL/actions?query=workflow%3Aclang-tidy) -[](https://github.com/taocpp/PEGTL/actions?query=workflow%3ASanitizer) -[](https://github.com/taocpp/PEGTL/actions?query=workflow%3ACodeQL) -[](https://codecov.io/gh/taocpp/PEGTL) +[](https://github.com/taocpp/PEGTL/actions/workflows/clang-analyze.yml) +[](https://github.com/taocpp/PEGTL/actions/workflows/clang-tidy.yml) +[](https://github.com/taocpp/PEGTL/actions/workflows/sanitizer.yml) +[](https://github.com/taocpp/PEGTL/actions/workflows/codeql-analysis.yml) +[](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). +**The main branch will go through phases of incompatible changes while parts of the evolution branch are back-ported. Please download [the latest release](https://github.com/taocpp/PEGTL/releases) rather than using unreleased changes from the main branch.** + ## Documentation * [Changelog](doc/Changelog.md) -* [Version 3.x](doc/README.md) (requires C++17) +* [Development](doc/README.md) (requires C++17) +* [Version 3.x](https://github.com/taocpp/PEGTL/blob/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`. +For questions and suggestions regarding the PEGTL, success or failure stories, and any other kind of feedback, please feel free to 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 @@ -136,9 +137,9 @@ The PEGTL is part of [The Art of C++](https://taocpp.github.io/). ## License -<a href="https://opensource.org/licenses/BSL-1.0"><img align="right" src="https://opensource.org/files/OSIApproved.png" width="150" hspace="20" alt="Open Source Initiative"></a> +<a href="https://opensource.org/licenses/BSL-1.0"><img align="right" src="https://opensource.org/wp-content/uploads/2009/06/OSIApproved.svg" width="150" hspace="20" alt="Open Source Initiative"></a> -Copyright (c) 2007-2021 Daniel Frey and Dr. Colin Hirsch +Copyright (c) 2007-2023 Daniel Frey and Dr. Colin Hirsch The PEGTL is certified [Open Source](http://www.opensource.org/docs/definition.html) software. It is [licensed](https://pdimov.github.io/blog/2020/09/06/why-use-the-boost-license/) under the terms of the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt) reproduced here. diff --git a/packages/PEGTL/doc/Actions-and-States.md b/packages/PEGTL/doc/Actions-and-States.md index 272b8ac460ccd0c15bd2225142a42542e90d0865..46c2fa5dbca93d2820f4ab7594cffbb2574d7513 100644 --- a/packages/PEGTL/doc/Actions-and-States.md +++ b/packages/PEGTL/doc/Actions-and-States.md @@ -300,7 +300,7 @@ struct foo Now an action class template can be specialised for `foo`, or for `tao::pegtl::alpha`, but *not* for `tao::pegtl::plus< tao::pegtl::alpha >`. -This because base classes are not taken into consideration by the C++ language when choosing a specialisation, which might be surprising when being used to pointer arguments to functions where conversions from pointer-to-derived to pointer-to-base are performed implicitly and silently. +This is because base classes are not taken into consideration by the C++ language when choosing a specialisation, which might be surprising when being used to pointer arguments to functions where conversions from pointer-to-derived to pointer-to-base are performed implicitly and silently. So although the function called by the library to match `foo` is the inherited `tao::pegtl::plus< tao::pegtl::alpha >::match()`, the rule class is `foo` and the function known as `foo::match()`, wherefore an action needs to be specialised for `foo` instead of `tao::pegtl::plus< tao::pegtl::alpha >`. @@ -608,6 +608,6 @@ See the [section on legacy-style action rules](Rule-Reference.md#action-rules). This document is part of the [PEGTL](https://github.com/taocpp/PEGTL). -Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey Distributed under the Boost Software License, Version 1.0<br> See accompanying file [LICENSE_1_0.txt](../LICENSE_1_0.txt) or copy at https://www.boost.org/LICENSE_1_0.txt diff --git a/packages/PEGTL/doc/Changelog.md b/packages/PEGTL/doc/Changelog.md index aca8f740a1f549f4f21702bfdd76862fdff29dc8..b05d176d3773a8134a13fab8e29d58066787f0aa 100644 --- a/packages/PEGTL/doc/Changelog.md +++ b/packages/PEGTL/doc/Changelog.md @@ -1,13 +1,54 @@ # Changelog -## 3.3.0 +## 4.0.0 **Not yet released** * Switched to Boost Software License, Version 1.0. +* Added new customization point for error messages. +* Added optional source line output for the tracer. +* Added new atomic rule `everything`. +* Added new convenience rule `partial`. +* Added new convenience rule `star_partial`. +* Added new convenience rule `strict`. +* Added new convenience rule `star_strict`. +* Moved depth counter to adapter class in contrib. +* Changed default top-level `rewind_mode` to `dontcare`. * Removed support for building an amalgamated header. -* Deprecated the `TAO_PEGTL_NAMESPACE` macro. - * Will be removed in version 4.0.0. +* Removed support for Visual Studio 2017. +* Removed support for GCC 7. + +## 3.2.7 + +Released 2022-07-14 + +* Removed superfluous deprecated include. + +## 3.2.6 + +Released 2022-06-29 + +* Made `unwind()` optional for parse tree nodes. +* Fixed `demangle()` for MSVC, again. +* Fixed `demangle()` for GCC 12. + +## 3.2.5 + +Released 2022-02-05 + +* Added missing include for fallback `demangle()` implementations. + +## 3.2.4 + +Released 2022-02-03 + +* Fixed `version.hpp`. + +## 3.2.3 + +Released 2022-02-03 + +* Fixed `static_assert` in `demangle()` with recent MSVC. ## 3.2.2 @@ -651,6 +692,6 @@ It is based on ideas from the YARD library by Christopher Diggins. This document is part of the [PEGTL](https://github.com/taocpp/PEGTL). -Copyright (c) 2007-2021 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2007-2023 Dr. Colin Hirsch and Daniel Frey Distributed under the Boost Software License, Version 1.0<br> See accompanying file [LICENSE_1_0.txt](../LICENSE_1_0.txt) or copy at https://www.boost.org/LICENSE_1_0.txt diff --git a/packages/PEGTL/doc/Contrib-and-Examples.md b/packages/PEGTL/doc/Contrib-and-Examples.md index 31f9035c161de1d791d8dc2b42eaf5662b11fcc1..a2c09f4fbe6c63250d408433eceb627c063e2e93 100644 --- a/packages/PEGTL/doc/Contrib-and-Examples.md +++ b/packages/PEGTL/doc/Contrib-and-Examples.md @@ -40,11 +40,12 @@ For all questions and remarks contact us at **taocpp(at)icemx.net**. * Grammars and actions for PEGTL-input-to-integer conversions. +###### `<tao/pegtl/contrib/input_with_depth.hpp>` ###### `<tao/pegtl/contrib/limit_depth.hpp>` -* Limits the nesting level of rules when parsing a grammar, prevents stack overflows. -* Can be applied selectively at specific rules to improve efficiency. -* See `src/test/pegtl/limit_depth.cpp`. +* Limit the nesting depth of rules when parsing a grammar to prevent stack overflows. +* Can be applied selectively at specific rules to reduce overhead. +* See `src/test/pegtl/contrib_limit_depth.cpp`. ###### `<tao/pegtl/contrib/json.hpp>` @@ -216,6 +217,6 @@ Invoked with one or more URIs as command line arguments will attempt to parse th This document is part of the [PEGTL](https://github.com/taocpp/PEGTL). -Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey Distributed under the Boost Software License, Version 1.0<br> See accompanying file [LICENSE_1_0.txt](../LICENSE_1_0.txt) or copy at https://www.boost.org/LICENSE_1_0.txt diff --git a/packages/PEGTL/doc/Control-and-Debug.md b/packages/PEGTL/doc/Control-and-Debug.md index 10fa8f80a931247c2a4be54e7bacbe954aaa1473..58b2143b6b26b3023a6157d6b44e6c671508bc06 100644 --- a/packages/PEGTL/doc/Control-and-Debug.md +++ b/packages/PEGTL/doc/Control-and-Debug.md @@ -148,6 +148,6 @@ Deriving the specialisation of the custom action for `my_rule` from `tao::pegtl: This document is part of the [PEGTL](https://github.com/taocpp/PEGTL). -Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey Distributed under the Boost Software License, Version 1.0<br> See accompanying file [LICENSE_1_0.txt](../LICENSE_1_0.txt) or copy at https://www.boost.org/LICENSE_1_0.txt diff --git a/packages/PEGTL/doc/Errors-and-Exceptions.md b/packages/PEGTL/doc/Errors-and-Exceptions.md index a0b16d24c7bfc74228c504c38624de3cd5df7468..d186d3ee49bde9f9bb5ba4498efccfac95b35bb7 100644 --- a/packages/PEGTL/doc/Errors-and-Exceptions.md +++ b/packages/PEGTL/doc/Errors-and-Exceptions.md @@ -81,12 +81,14 @@ Global failures can also be unconditionally provoked with the `raise<>` grammar It should be mentioned that `must< R >` is semantically equivalent to `sor< R, raise< R > >`, but more efficient. In any case, the task of actually throwing an exception is delegated to the [control class'](Control-and-Debug.md) `raise()`. +The control class' `raise()` method will generate a default message for the `parse_error` that will be thrown. +The default message can be overwritten by giving the rule `R` a static member variable that contains a different error message. Note that rules and actions can throw exceptions directly, meaning those are not generated from the [control class'](Control-and-Debug.md) `raise()`. ### Non-Intrusive Local to Global Failure -If a grammar does not contain any `must<>` rule(s) (or `raise<>`, `if_must<>`, ...), one can still convert a local failure for a rule into a global failure via `must_if<>`. +If a grammar does not contain any `must<>` rule(s) (or `raise<>`, `raise_message<>`, `if_must<>`, ...), one can still convert a local failure for a rule into a global failure via `must_if<>`. This helper allows one to create a [control class'](Control-and-Debug.md) and provide custom error messages for global failures. If an error message is provided for a rule that would normally return a local failure, it is automatically converted to a global failure. See [Custom Exception Messages](#custom-exception-messages) for more information. @@ -160,8 +162,11 @@ The same use of `if_must<>` can be applied to the `literal` rule assuming that i By default, when using any `must<>` error points, the exceptions generated by the PEGTL use the demangled name of the failed parsing rule as descriptive part of the error message. This is often insufficient and one would like to provide more meaningful error messages. -A practical technique to provide customised error messages for all `must<>` error points uses the `must_if<>` helper. +One option is to add a static member variable to the rule that provides a custom error message. +For your convenience, there is a `raise_message<>` rule and the corresponding `TAO_PEGTL_RAISE_MESSAGE()` macro to simplify this. +For an example of these customization points, see `src/example/pegtl/error_messages_2.hpp` and `src/example/pegtl/error_messages_3.hpp`. +If the above is not sufficient, you can provide a customised error messages for all `must<>` error points using the `must_if<>` helper. For an example of this method see `src/example/pegtl/json_errors.hpp`, where all errors that might occur in the supplied JSON grammar are customised like this: ```c++ @@ -218,6 +223,6 @@ This choice becoming particularly cumbersome and/or resulting in a large number This document is part of the [PEGTL](https://github.com/taocpp/PEGTL). -Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey Distributed under the Boost Software License, Version 1.0<br> See accompanying file [LICENSE_1_0.txt](../LICENSE_1_0.txt) or copy at https://www.boost.org/LICENSE_1_0.txt diff --git a/packages/PEGTL/doc/Example-Tables.md b/packages/PEGTL/doc/Example-Tables.md new file mode 100644 index 0000000000000000000000000000000000000000..2edc3e7696f18f5716d910b8d36ce88ebba63d89 --- /dev/null +++ b/packages/PEGTL/doc/Example-Tables.md @@ -0,0 +1,126 @@ +# Example Tables + +The following tables show how groups of related combinators differ by giving examples of their matching behaviour. + +We assume that the rule `x` is defined as `one< 'x' >` for all reasonable choices of `x` and that we are in namespace `tao::pegtl`. + +## Simple Combinators + +| Rule | Input | Result | Matched | +|------|-------|--------|---------| +| `seq< a, b, c >` | "" | false | | +| `opt< a, b, c >` | "" | **true** | "" | +| `strict< a, b, c >` | "" | **true** | "" | +| `partial< a, b, c >` | "" | **true** | "" | +| `if_must< a, b, c >` | "" | false | | +| `seq< a, b, c >` | "a" | false | | +| `opt< a, b, c >` | "a" | **true** | "" | +| `strict< a, b, c >` | "a" | false | | +| `partial< a, b, c >` | "a" | **true** | "a" | +| `if_must< a, b, c >` | "a" | error | | +| `seq< a, b, c >` | "ab" | false | | +| `opt< a, b, c >` | "ab" | **true** | "" | +| `strict< a, b, c >` | "ab" | false | | +| `partial< a, b, c >` | "ab" | **true** | "ab" | +| `if_must< a, b, c >` | "ab" | error | | +| `seq< a, b, c >` | "abc" | **true** | "abc" | +| `opt< a, b, c >` | "abc" | **true** | "abc" | +| `strict< a, b, c >` | "abc" | **true** | "abc" | +| `partial< a, b, c >` | "abc" | **true** | "abc" | +| `if_must< a, b, c >` | "abc" | **true** | "abc" | +| `seq< a, b, c >` | "abca" | **true** | "abc" | +| `opt< a, b, c >` | "abca" | **true** | "abc" | +| `strict< a, b, c >` | "abca" | **true** | "abc" | +| `partial< a, b, c >` | "abca" | **true** | "abc" | +| `if_must< a, b, c >` | "abca" | **true** | "abc" | +| `seq< a, b, c >` | "d" | false | | +| `opt< a, b, c >` | "d" | **true** | "" | +| `strict< a, b, c >` | "d" | **true** | "" | +| `partial< a, b, c >` | "d" | **true** | "" | +| `if_must< a, b, c >` | "d" | false | | +| `seq< a, b, c >` | "ad" | false | | +| `opt< a, b, c >` | "ad" | **true** | "" | +| `strict< a, b, c >` | "ad" | false | | +| `partial< a, b, c >` | "ad" | **true** | "a" | +| `if_must< a, b, c >` | "ad" | error | | +| `seq< a, b, c >` | "abd" | false | | +| `opt< a, b, c >` | "abd" | **true** | "" | +| `strict< a, b, c >` | "abd" | false | | +| `partial< a, b, c >` | "abd" | **true** | "ab" | +| `if_must< a, b, c >` | "abd" | error | | +| `seq< a, b, c >` | "abcd" | **true** | "abc" | +| `opt< a, b, c >` | "abcd" | **true** | "abc" | +| `strict< a, b, c >` | "abcd" | **true** | "abc" | +| `partial< a, b, c >` | "abcd" | **true** | "abc" | +| `if_must< a, b, c >` | "abcd" | **true** | "abc" | + +## Iterating Combinators + +| Rule | Input | Result | Matched | +|------|-------|--------|---------| +| `plus< a, b, c >` | "" | false | | +| `star< a, b, c >` | "" | **true** | "" | +| `star_strict< a, b, c >` | "" | **true** | "" | +| `star_partial< a, b, c >` | "" | **true** | "" | +| `star_must< a, b, c >` | "" | **true** | "" | +| `plus< a, b, c >` | "a" | false | | +| `star< a, b, c >` | "a" | **true** | "" | +| `star_strict< a, b, c >` | "a" | false | | +| `star_partial< a, b, c >` | "a" | **true** | "a" | +| `star_must< a, b, c >` | "a" | error | | +| `plus< a, b, c >` | "ab" | false | | +| `star< a, b, c >` | "ab" | **true** | "" | +| `star_strict< a, b, c >` | "ab" | false | | +| `star_partial< a, b, c >` | "ab" | **true** | "ab" | +| `star_must< a, b, c >` | "ab" | error | | +| `plus< a, b, c >` | "abc" | **true** | "abc" | +| `star< a, b, c >` | "abc" | **true** | "abc" | +| `star_strict< a, b, c >` | "abc" | **true** | "abc" | +| `star_partial< a, b, c >` | "abc" | **true** | "abc" | +| `star_must< a, b, c >` | "abc" | **true** | "abc" | +| `plus< a, b, c >` | "abca" | **true** | "abc" | +| `star< a, b, c >` | "abca" | **true** | "abc" | +| `star_strict< a, b, c >` | "abca" | false | | +| `star_partial< a, b, c >` | "abca" | **true** | "abca" | +| `star_must< a, b, c >` | "abca" | error | | +| `plus< a, b, c >` | "d" | false | | +| `star< a, b, c >` | "d" | **true** | "" | +| `star_strict< a, b, c >` | "d" | **true** | "" | +| `star_partial< a, b, c >` | "d" | **true** | "" | +| `star_must< a, b, c >` | "d" | **true** | "" | +| `plus< a, b, c >` | "ad" | false | | +| `star< a, b, c >` | "ad" | **true** | "" | +| `star_strict< a, b, c >` | "ad" | false | | +| `star_partial< a, b, c >` | "ad" | **true** | "a" | +| `star_must< a, b, c >` | "ad" | error | | +| `plus< a, b, c >` | "abd" | false | | +| `star< a, b, c >` | "abd" | **true** | "" | +| `star_strict< a, b, c >` | "abd" | false | | +| `star_partial< a, b, c >` | "abd" | **true** | "ab" | +| `star_must< a, b, c >` | "abd" | error | | +| `plus< a, b, c >` | "abcd" | **true** | "abc" | +| `star< a, b, c >` | "abcd" | **true** | "abc" | +| `star_strict< a, b, c >` | "abcd" | **true** | "abc" | +| `star_partial< a, b, c >` | "abcd" | **true** | "abc" | +| `star_must< a, b, c >` | "abcd" | **true** | "abc" | +| `plus< a, b, c >` | "abcabc" | **true** | "abcabc" | +| `star< a, b, c >` | "abcabc" | **true** | "abcabc" | +| `star_strict< a, b, c >` | "abcabc" | **true** | "abcabc" | +| `star_partial< a, b, c >` | "abcabc" | **true** | "abcabc" | +| `star_must< a, b, c >` | "abcabc" | **true** | "abcabc" | +| `plus< a, b, c >` | "abcabca" | **true** | "abcabc" | +| `star< a, b, c >` | "abcabca" | **true** | "abcabc" | +| `star_strict< a, b, c >` | "abcabca" | false | | +| `star_partial< a, b, c >` | "abcabca" | **true** | "abcabca" | +| `star_must< a, b, c >` | "abcabca" | error | | +| `plus< a, b, c >` | "abcabcb" | **true** | "abcabc" | +| `star< a, b, c >` | "abcabcb" | **true** | "abcabc" | +| `star_strict< a, b, c >` | "abcabcb" | **true** | "abcabc" | +| `star_partial< a, b, c >` | "abcabcb" | **true** | "abcabc" | +| `star_must< a, b, c >` | "abcabcb" | **true** | "abcabc" | + +This document is part of the [PEGTL](https://github.com/taocpp/PEGTL). + +Copyright (c) 2023 Dr. Colin Hirsch and Daniel Frey +Distributed under the Boost Software License, Version 1.0<br> +See accompanying file [LICENSE_1_0.txt](../LICENSE_1_0.txt) or copy at https://www.boost.org/LICENSE_1_0.txt diff --git a/packages/PEGTL/doc/Getting-Started.md b/packages/PEGTL/doc/Getting-Started.md index fbf71cbd304777526e661e0f50e0c2fb1b3eaf38..20c13d570d8077d25b8b13098f5a10087ff413e6 100644 --- a/packages/PEGTL/doc/Getting-Started.md +++ b/packages/PEGTL/doc/Getting-Started.md @@ -96,6 +96,9 @@ terminate called after throwing an instance of 'tao::pegtl::parse_error' Aborted (core dumped) ``` +Note that, by default, the PEGTL resides in `namespace tao::pegtl`, however this can be changed as explained in [Embedding in Library Interfaces](Installing-and-Using.md#embedding-in-library-interfaces). +The entire PEGTL documentation assumes that the default namespace applies. + The PEGTL provides multiple facilities that help to get started and develop your grammar. In the following paragraphs we will show several small programs to showcase the capabilities of the PEGTL. @@ -287,6 +290,6 @@ For more information see [Errors and Exceptions](Errors-and-Exceptions.md). This document is part of the [PEGTL](https://github.com/taocpp/PEGTL). -Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey Distributed under the Boost Software License, Version 1.0<br> See accompanying file [LICENSE_1_0.txt](../LICENSE_1_0.txt) or copy at https://www.boost.org/LICENSE_1_0.txt diff --git a/packages/PEGTL/doc/Grammar-Analysis.md b/packages/PEGTL/doc/Grammar-Analysis.md index 94bb40aef184878e3a5d7f1c17f520bdefbc1f8c..ec9812a6347d6539038e26e788d8f81e1dd32031 100644 --- a/packages/PEGTL/doc/Grammar-Analysis.md +++ b/packages/PEGTL/doc/Grammar-Analysis.md @@ -77,10 +77,8 @@ struct my_rule the analyze traits need to be set up as ```c++ -// In namespace TAO_PEGTL_NAMESPACE - template< typename Name > -struct analyze_traits< Name, my_rule > +struct tao::pegtl::analyze_traits< Name, my_rule > : analyze_any_traits<> {}; ``` @@ -128,6 +126,6 @@ False positives are a theoretical problem in that, while relatively easy to trig This document is part of the [PEGTL](https://github.com/taocpp/PEGTL). -Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey Distributed under the Boost Software License, Version 1.0<br> See accompanying file [LICENSE_1_0.txt](../LICENSE_1_0.txt) or copy at https://www.boost.org/LICENSE_1_0.txt diff --git a/packages/PEGTL/doc/Inputs-and-Parsing.md b/packages/PEGTL/doc/Inputs-and-Parsing.md index 96948728c3e62278d94feedb4083a9f764db382c..d661711426c3320766505ddceef4470547e386d9 100644 --- a/packages/PEGTL/doc/Inputs-and-Parsing.md +++ b/packages/PEGTL/doc/Inputs-and-Parsing.md @@ -283,8 +283,8 @@ The parse functions accept the following template parameters and arguments: Additionally, two enumeration values can be used to control the behaviour: -- The `apply_mode` which can also be set to `nothing` in order to disable action invocations, just like the `disable<>` rule does. -- The `rewind_mode` which can also be set to `dontcare` in order to not require rewinding of the input on local failure, a micro optimisation. +- The `apply_mode`, which can also be set to `nothing` in order to disable action invocations, just like the `disable<>` rule does. +- The `rewind_mode`, which can also be set to `required` when rewinding the input to its start is required for top-level parse failures. The result of a parsing run, i.e. an invocation of `tao::pegtl::parse()`, can be either @@ -298,7 +298,7 @@ template< typename Rule, template< typename... > class Action = nothing, template< typename... > class Control = normal, apply_mode A = apply_mode::action, - rewind_mode M = rewind_mode::required, + rewind_mode M = rewind_mode::dontcare, typename ParseInput, typename... States > bool parse( ParseInput& in, @@ -320,7 +320,7 @@ template< typename Rule, template< typename... > class Action = nothing, template< typename... > class Control = normal, apply_mode A = apply_mode::action, - rewind_mode M = rewind_mode::required, + rewind_mode M = rewind_mode::dontcare, typename OuterInput, typename ParseInput, typename... States > @@ -558,6 +558,6 @@ All input classes support [deduction guides](https://en.cppreference.com/w/cpp/l This document is part of the [PEGTL](https://github.com/taocpp/PEGTL). -Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey Distributed under the Boost Software License, Version 1.0<br> See accompanying file [LICENSE_1_0.txt](../LICENSE_1_0.txt) or copy at https://www.boost.org/LICENSE_1_0.txt diff --git a/packages/PEGTL/doc/Installing-and-Using.md b/packages/PEGTL/doc/Installing-and-Using.md index 007987116287d8674c22b571c27239ca6e76a0a1..8996a729560c4089c0ec85621266b0ff5dafb1e9 100644 --- a/packages/PEGTL/doc/Installing-and-Using.md +++ b/packages/PEGTL/doc/Installing-and-Using.md @@ -24,9 +24,9 @@ The PEGTL requires a C++17-capable compiler, e.g. one of -* GCC 7 -* Clang 5 -* Visual Studio 2017 +* GCC 8 +* Clang 6 +* Visual Studio 2019 on either @@ -37,6 +37,8 @@ on either It requires C++17, e.g. using the `--std=c++17` compiler switch. Using newer versions of the C++ standard is supported. +Due to the design of the PEGTL with many small functions and the reliance on the compiler for performance it is recommended to *always* compile with at least some optimisations enabled, in particular those that inline functions. + Larger projects will frequently require the `/bigobj` option when compiling with Visual Studio on Windows. It should also work with other C++17 compilers on other Unix systems (or any sufficiently compatible platform). @@ -236,7 +238,7 @@ for customising the build process. ## Embedding the PEGTL -When embedding the PEGTL into other projects, several problems may come up +When embedding the PEGTL in other projects, several problems might show up due to the nature of C++ header-only libraries. Depending on the scenario, there are various ways of working around these problems. @@ -293,16 +295,14 @@ $ sed -i 's/TAO_PEGTL_/MYLIB_PEGTL_/g' $(find -name '[^.]*.[hc]pp') The above command needs to run from the top-level directory of the embedded PEGTL. Additionally, `MYLIB_PEGTL_NAMESPACE` needs to be set as explained -above; alternatively `include/tao/pegtl/config.hpp` can be directly modified. - -A practical example of how the result looks like can be found in our own -header-only JSON library [taoJSON](https://github.com/taocpp/json/). +above; alternatively, since the PEGTL source is already being mnodified, +`include/tao/pegtl/config.hpp` can be changed to use the desired namespace. --- This document is part of the [PEGTL](https://github.com/taocpp/PEGTL). -Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey Distributed under the Boost Software License, Version 1.0<br> See accompanying file [LICENSE_1_0.txt](../LICENSE_1_0.txt) or copy at https://www.boost.org/LICENSE_1_0.txt diff --git a/packages/PEGTL/doc/Meta-Data-and-Visit.md b/packages/PEGTL/doc/Meta-Data-and-Visit.md index bed412efa030a9d8638dbee233b651a75276f7b9..8d0d52fc2fe9ada4af539391bae8ef777490997e 100644 --- a/packages/PEGTL/doc/Meta-Data-and-Visit.md +++ b/packages/PEGTL/doc/Meta-Data-and-Visit.md @@ -13,7 +13,7 @@ They are only required to support functions based on `visit()` and the [grammar ## Internals -While accessible in the namespace `TAO_PEGTL_NAMESPACE`, which defaults to `tao::pegtl`, the [rules and combinators](Rule-Reference.md) included with the PEGTL all have their actual implementation in the sub-namespace `internal`. +While accessible in the namespace `tao::pegtl`, the [rules and combinators](Rule-Reference.md) included with the PEGTL all have their actual implementation in the sub-namespace `internal`. For example the header `include/tao/pegtl/rules.hpp` shows how the user-facing rules are nothing more than forwarders to their `internal` implementation. The original motivation for this additional level of indirection was to prevent uninteded invocation of user-defined actions due to some PEGTL rules being built from exisiting rules instead of having a dedicated implementation. @@ -151,6 +151,6 @@ As usual, unless otherwise indicated, all functions and data structure are in th This document is part of the [PEGTL](https://github.com/taocpp/PEGTL). -Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey Distributed under the Boost Software License, Version 1.0<br> See accompanying file [LICENSE_1_0.txt](../LICENSE_1_0.txt) or copy at https://www.boost.org/LICENSE_1_0.txt diff --git a/packages/PEGTL/doc/Migration-Guide.md b/packages/PEGTL/doc/Migration-Guide.md index 19f543d970ad7274f79811b58c93c613850fe1f2..d037ab5c652a2db9617394d3fc3e94434cb47916 100644 --- a/packages/PEGTL/doc/Migration-Guide.md +++ b/packages/PEGTL/doc/Migration-Guide.md @@ -1,5 +1,9 @@ # Migration Guide +## Version 4.0.0 + + + ## Version 3.0.0 * The build system needs to be configured for C++17 or later. @@ -60,6 +64,6 @@ Please contact the authors at `taocpp(at)icemx.net` for any further questions wh This document is part of the [PEGTL](https://github.com/taocpp/PEGTL). -Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey Distributed under the Boost Software License, Version 1.0<br> See accompanying file [LICENSE_1_0.txt](../LICENSE_1_0.txt) or copy at https://www.boost.org/LICENSE_1_0.txt diff --git a/packages/PEGTL/doc/Parse-Tree.md b/packages/PEGTL/doc/Parse-Tree.md index e82f6cf7d49d932986bad8744bcbc7b386afc84b..4d1b02f7bc36f743a4c15714d0c73374bc4ebe47 100644 --- a/packages/PEGTL/doc/Parse-Tree.md +++ b/packages/PEGTL/doc/Parse-Tree.md @@ -57,8 +57,8 @@ template<> struct my_selector< my_rule_3 > : std::true_type {}; auto root = tao::pegtl::parse_tree::parse< my_grammar, my_selector >( in ); ``` -Note that the example uses a white-list style; the default is `std::false_type` and only rules listed with a specialisation deriving from `std::true_type` will generate nodes. -The opposite, a black-list style, is of course possible, too. +Note that the example uses an allow-list style; the default is `std::false_type` and only rules listed with a specialisation deriving from `std::true_type` will generate nodes. +The opposite, a block-list style, is of course possible, too. The PEGTL includes a selector class and additional utility classes to allow for a less verbose specification of a selector. The following definition of `my_selector` will behave just like the one above. @@ -244,6 +244,6 @@ The parse tree uses a rule's meta data supplied by [`subs_t`](Meta-Data-and-Visi This document is part of the [PEGTL](https://github.com/taocpp/PEGTL). -Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey Distributed under the Boost Software License, Version 1.0<br> See accompanying file [LICENSE_1_0.txt](../LICENSE_1_0.txt) or copy at https://www.boost.org/LICENSE_1_0.txt diff --git a/packages/PEGTL/doc/Performance-Notes.md b/packages/PEGTL/doc/Performance-Notes.md index bad3886260a3498bbb2663ab06f9195627195e7d..ca90a90940d465e8ec799ec96b4146dbd4f562c5 100644 --- a/packages/PEGTL/doc/Performance-Notes.md +++ b/packages/PEGTL/doc/Performance-Notes.md @@ -39,6 +39,7 @@ Instead of `one< ... >` advancing the input, and `at< one< ... > >` rewinding, t Put to the test, the optimised `at_one< '"' >` rule did not show any performance advantage over `at< one< '"' > >`, at least with `-O3`. Presumably the compiler was smart enough to perform the optimisation by itself. However with `-O0`, the optimised `at_one< '"' >` was faster by 5-10% in a [JSON library](https://github.com/taocpp/json) micro-benchmark. +As the PEGTL should only be used with optimizations enabled, we removed the `at_one<>` rule, as we try to reduce the number of rules that won't provide a clear benefit. We still need to test whether the compiler manages to perform the same optimisation in more complex cases. @@ -46,6 +47,6 @@ We still need to test whether the compiler manages to perform the same optimisat This document is part of the [PEGTL](https://github.com/taocpp/PEGTL). -Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey Distributed under the Boost Software License, Version 1.0<br> See accompanying file [LICENSE_1_0.txt](../LICENSE_1_0.txt) or copy at https://www.boost.org/LICENSE_1_0.txt diff --git a/packages/PEGTL/doc/README.md b/packages/PEGTL/doc/README.md index 88bedb59217372fbd3a69cfa2b022e2e52806f89..bde86a1e994764e08dfdfe710a3ef93942d21d17 100644 --- a/packages/PEGTL/doc/README.md +++ b/packages/PEGTL/doc/README.md @@ -71,6 +71,7 @@ * [ICU Rules for Value Properties](Rule-Reference.md#icu-rules-for-value-properties) * [Binary Rules](Rule-Reference.md#binary-rules) * [Full Index](Rule-Reference.md#full-index) + * [Example Tables](Example-Tables.md) * [Inputs and Parsing](Inputs-and-Parsing.md) * [Tracking Mode](Inputs-and-Parsing.md#tracking-mode) * [Line Ending](Inputs-and-Parsing.md#line-ending) @@ -162,6 +163,7 @@ * [`eof`](Rule-Reference.md#eof) <sup>[(atomic rules)](Rule-Reference.md#atomic-rules)</sup> * [`eol`](Rule-Reference.md#eol) <sup>[(atomic rules)](Rule-Reference.md#atomic-rules)</sup> * [`eolf`](Rule-Reference.md#eolf) <sup>[(atomic rules)](Rule-Reference.md#atomic-rules)</sup> +* [`everything`](Rule-Reference.md#everything) <sup>[(atomic rules)](Rule-Reference.md#atomic-rules)</sup> * [`extender`](Rule-Reference.md#extender) <sup>[(icu rules)](Rule-Reference.md#icu-rules-for-binary-properties)</sup> * [`failure`](Rule-Reference.md#failure) <sup>[(atomic rules)](Rule-Reference.md#atomic-rules)</sup> * [`forty_two< C... >`](Rule-Reference.md#forty_two-c-) <sup>[(ascii rules)](Rule-Reference.md#ascii-rules)</sup> @@ -234,6 +236,7 @@ * [`opt_must< R, S...>`](Rule-Reference.md#opt_must-r-s-) <sup>[(convenience)](Rule-Reference.md#convenience)</sup> * [`pad< R, S, T = S >`](Rule-Reference.md#pad-r-s-t--s-) <sup>[(convenience)](Rule-Reference.md#convenience)</sup> * [`pad_opt< R, P >`](Rule-Reference.md#pad_opt-r-p-) <sup>[(convenience)](Rule-Reference.md#convenience)</sup> +* [`partial< R... >`](Rule-Reference.md#partial-r-) <sup>[(convenience)](Rule-Reference.md#convenience)</sup> * [`pattern_syntax`](Rule-Reference.md#pattern_syntax) <sup>[(icu rules)](Rule-Reference.md#icu-rules-for-binary-properties)</sup> * [`pattern_white_space`](Rule-Reference.md#pattern_white_space) <sup>[(icu rules)](Rule-Reference.md#icu-rules-for-binary-properties)</sup> * [`plus< R... >`](Rule-Reference.md#plus-r-) <sup>[(combinators)](Rule-Reference.md#combinators)</sup> @@ -247,6 +250,7 @@ * [`quotation_mark`](Rule-Reference.md#quotation_mark) <sup>[(icu rules)](Rule-Reference.md#icu-rules-for-binary-properties)</sup> * [`radical`](Rule-Reference.md#radical) <sup>[(icu rules)](Rule-Reference.md#icu-rules-for-binary-properties)</sup> * [`raise< T >`](Rule-Reference.md#raise-t-) <sup>[(atomic rules)](Rule-Reference.md#atomic-rules)</sup> +* [`raise_message< C... >`](Rule-Reference.md#raise_message-c-) <sup>[(atomic rules)](Rule-Reference.md#atomic-rules)</sup> * [`range< C, D >`](Rule-Reference.md#range-c-d-) <sup>[(ascii rules)](Rule-Reference.md#ascii-rules)</sup> * [`range< C, D >`](Rule-Reference.md#range-c-d--1) <sup>[(unicode rules)](Rule-Reference.md#unicode-rules)</sup> * [`range< C, D >`](Rule-Reference.md#range-c-d--2) <sup>[(binary rules)](Rule-Reference.md#binary-rules)</sup> @@ -274,13 +278,17 @@ * [`space`](Rule-Reference.md#space) <sup>[(ascii rules)](Rule-Reference.md#ascii-rules)</sup> * [`star< R... >`](Rule-Reference.md#star-r-) <sup>[(combinators)](Rule-Reference.md#combinators)</sup> * [`star_must< R, S... >`](Rule-Reference.md#star_must-r-s-) <sup>[(convenience)](Rule-Reference.md#convenience)</sup> +* [`star_partial< R... >`](Rule-Reference.md#star_partial-r-) <sup>[(convenience)](Rule-Reference.md#convenience)</sup> +* [`star_strict< R... >`](Rule-Reference.md#star_strict-r-) <sup>[(convenience)](Rule-Reference.md#convenience)</sup> * [`state< S, R... >`](Rule-Reference.md#state-s-r-) <sup>[(meta rules)](Rule-Reference.md#meta-rules)</sup> +* [`strict< R... >`](Rule-Reference.md#strict-r-) <sup>[(convenience)](Rule-Reference.md#convenience)</sup> * [`string< C... >`](Rule-Reference.md#string-c-) <sup>[(ascii rules)](Rule-Reference.md#ascii-rules)</sup> * [`string< C... >`](Rule-Reference.md#string-c--1) <sup>[(unicode rules)](Rule-Reference.md#unicode-rules)</sup> * [`string< C... >`](Rule-Reference.md#string-c--2) <sup>[(binary rules)](Rule-Reference.md#binary-rules)</sup> * [`success`](Rule-Reference.md#success) <sup>[(atomic rules)](Rule-Reference.md#atomic-rules)</sup> * [`TAO_PEGTL_ISTRING( "..." )`](Rule-Reference.md#tao_pegtl_istring--) <sup>[(ascii rules)](Rule-Reference.md#ascii_rules)</sup> * [`TAO_PEGTL_KEYWORD( "..." )`](Rule-Reference.md#tao_pegtl_keyword--) <sup>[(ascii rules)](Rule-Reference.md#ascii_rules)</sup> +* [`TAO_PEGTL_RAISE_MESSAGE( "..." )`](Rule-Reference.md#tao_pegtl_raise_message--) <sup>[(atomic rules)](Rule-Reference.md#atomic_rules)</sup> * [`TAO_PEGTL_STRING( "..." )`](Rule-Reference.md#tao_pegtl_string--) <sup>[(ascii rules)](Rule-Reference.md#ascii_rules)</sup> * [`terminal_punctuation`](Rule-Reference.md#terminal_punctuation) <sup>[(icu rules)](Rule-Reference.md#icu-rules-for-binary-properties)</sup> * [`three< C >`](Rule-Reference.md#three-c-) <sup>[(ascii rules)](Rule-Reference.md#ascii-rules)</sup> @@ -304,6 +312,6 @@ This document is part of the [PEGTL](https://github.com/taocpp/PEGTL). -Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey Distributed under the Boost Software License, Version 1.0<br> See accompanying file [LICENSE_1_0.txt](../LICENSE_1_0.txt) or copy at https://www.boost.org/LICENSE_1_0.txt diff --git a/packages/PEGTL/doc/Rule-Reference.md b/packages/PEGTL/doc/Rule-Reference.md index b1a6757a68976bc2d9c091c150470707f64a54fa..9ea518b6beee7fec880dd347cb314404cd2f7cd0 100644 --- a/packages/PEGTL/doc/Rule-Reference.md +++ b/packages/PEGTL/doc/Rule-Reference.md @@ -90,7 +90,7 @@ These rules are in namespace `tao::pegtl`. * [Equivalent] to `success`, but: * Calls the input's `discard()` member function. * Must not be used where backtracking to before the `discard` might occur and/or nested within a rule for which an action with input can be called. -* See [Incremental Input](Inputs-and-Parsing.md#incremental-input) for details. +* See [Incremental Input] for details. * [Meta data] and [implementation] mapping: - `discard::rule_t` is `internal::discard` @@ -108,7 +108,7 @@ These rules are in namespace `tao::pegtl`. ###### `require< Num >` * Succeeds if at least `Num` further input bytes are available. -* With [Incremental Input](Inputs-and-Parsing.md#incremental-input) reads the bytes into the buffer. +* With [Incremental Input] reads the bytes into the buffer. * [Meta data] and [implementation] mapping: - `require< 0 >::rule_t` is `internal::success` - `require< N >::rule_t` is `internal::require< N >` @@ -297,17 +297,19 @@ Note that the `false` template parameter to `internal::if_must` corresponds to t * Matches a non-empty list of `R` separated by `S` with optional trailing `S`. * [Equivalent] to `seq< list< R, S >, opt< S > >`. +* [Equivalent] to `seq< R, star_partial< S, R > >`. * [Meta data] and [implementation] mapping: - - `list_tail< R, S >::rule_t` is `internal::seq< R, internal::star< S, R >, internal::opt< S > >` - - `list_tail< R, S >::subs_t` is `type_list< R, internal::star< S, R >, internal::opt< S > >` + - `list_tail< R, S >::rule_t` is `internal::seq< R, internal::star_partial< S, R > >` + - `list_tail< R, S >::subs_t` is `type_list< R, internal::star_partial< S, R > >` ###### `list_tail< R, S, P >` * Matches a non-empty list of `R` separated by `S` with optional trailing `S` and padding `P` inside the list. * [Equivalent] to `seq< list< R, S, P >, opt< star< P >, S > >`. +* [Equivalent] to `seq< R, star_partial< padl< S, P >, padl< R, P > > >`. * [Meta data] and [implementation] mapping: - - `list_tail< R, S, P >::rule_t` is `internal::seq< R, internal::star< internal::pad< S, P >, R >, internal::opt< internal::star< P >, S > >` - - `list_tail< R, S, P >::subs_t` is `type_list< R, internal::star< internal::pad< S, P >, R > >, internal::opt< internal::star< P >, S > >` + - `list_tail< R, S, P >::rule_t` is `internal::seq< R, internal::star_partial< internal::padl< S, P >, internal::padl< R, P > > >` + - `list_tail< R, S, P >::subs_t` is `type_list< R, internal::star_partial< internal::padl< S, P >, internal::padl< R, P > > >` ###### `minus< M, S >` @@ -360,6 +362,19 @@ Note that the `true` template parameter to `internal::if_must` corresponds to th - `pad_opt< R, P >::rule_t` is `internal::seq< internal::star< P >, internal::opt< R, internal::star< P > > >` - `pad_opt< R, P >::subs_t` is `type_list< internal::star< P >, internal::opt< R, internal::star< P > > >` +###### `partial< R... >` + +* Similar to `opt< R... >` with one important difference: +* Does *not* rewind the input after a partial match of `R...`. +* Attempts to match the given rules `R...` in the given order. +* Succeeds and stops matching when one of the given rules fails. +* Consumes everything that the successful rules of `R...` consumed. +* `R` must be a non-empty rule pack. +* [Equivalent] to `opt< R >` when `R...` is a single rule. +* [Meta data] and [implementation] mapping: + - `partial< R... >::rule_t` is `internal::partial< R... >` + - `partial< R... >::subs_t` is `type_list< R... >` + ###### `rematch< R, S... >` * Succeeds if `R` matches, and each `S` matches the input that `R` matched. @@ -440,6 +455,34 @@ Note that the `S` do *not* need to match *all* of the input matched by `R` (whic - `star_must< R, S... >::rule_t` is `internal::star< internal::if_must< false, R, S... > >` - `star_must< R, S... >::subs_t` is `type_list< internal::if_must< false, R, S... > >` +###### `star_partial< R... >` + +* Similar to `star< R... >` with one important difference: +* The final iteration does *not* rewind the input after a partial match of `R...`. +* `R` must be a non-empty rule pack. +* [Meta data] and [implementation] mapping: + - `star_partial< R... >::rule_t` is `internal::star_partial< R... >` + - `star_partial< R... >::subs_t` is `type_list< R... >` + +###### `star_strict< R... >` + +* Similar to `star< R... >` with one important difference: +* A partial match of `R...` lets `star_strict` fail locally. +* `R` must be a non-empty rule pack. +* [Meta data] and [implementation] mapping: + - `star_strict< R... >::rule_t` is `internal::star_strict< R... >` + - `star_strict< R... >::subs_t` is `type_list< R... >` + +###### `strict< R... >` + +* Similar to `opt< R... >` with one important difference: +* A partial match of `R...` lets `strict` fail locally. +* [Equivalent] to `sor< not_at< R1 >, seq< R... > >` if `R1` is the first rule of `R...`. +* `R` must be a non-empty rule pack. +* [Meta data] and [implementation] mapping: + - `strict< R... >::rule_t` is `internal::strict< R... >` + - `strict< R... >::subs_t` is `type_list< R... >` + ###### `try_catch< R... >` * [Equivalent] to `seq< R... >`, but: @@ -567,6 +610,14 @@ Atomic rules do not rely on other rules. * [Meta data] and [implementation] mapping: - `eolf::rule_t` is `internal::eolf` +###### `everything` + +* Matches and consumes the entire input in one go, but: +* Limited by the buffer size when using an [Incremental Input]. +* [Equivalent] to `until< eof, any >`. +* [Meta data] and [implementation] mapping: + - `everything::rule_t` is `internal::everything< std::size_t >` + ###### `failure` * Dummy rule that never succeeds. @@ -583,6 +634,14 @@ Atomic rules do not rely on other rules. * [Meta data] and [implementation] mapping: - `raise< T >::rule_t` is `internal::raise< T >` +###### `raise_message< C... >` + +* Generates a *global failure* with the message given by `C...`. +* Calls the control-class' `Control< raise_message< C... > >::raise()` static member function. +* Does not consume input. +* [Meta data] and [implementation] mapping: + - `raise_message< C... >::rule_t` is `internal::raise< raise_message< C... > >` + ###### `success` * Dummy rule that always succeeds. @@ -590,6 +649,12 @@ Atomic rules do not rely on other rules. * [Meta data] and [implementation] mapping: - `success::rule_t` is `internal::success` +###### `TAO_PEGTL_RAISE_MESSAGE( "..." )` + +* Macro where `TAO_PEGTL_RAISE_MESSAGE( "foo" )` yields `raise_message< 'f', 'o', 'o' >`. +* The argument must be a string literal. +* Works for strings up to 512 bytes of length (excluding trailing `'\0'`). + ## ASCII Rules These rules are in the inline namespace `tao::pegtl::ascii`. @@ -1412,6 +1477,7 @@ Binary rules do not rely on other rules. * [`eof`](#eof) <sup>[(atomic rules)](#atomic-rules)</sup> * [`eol`](#eol) <sup>[(atomic rules)](#atomic-rules)</sup> * [`eolf`](#eolf) <sup>[(atomic rules)](#atomic-rules)</sup> +* [`everything`](#everything) <sup>[(atomic rules)](#atomic-rules)</sup> * [`extender`](#extender) <sup>[(icu rules)](#icu-rules-for-binary-properties)</sup> * [`failure`](#failure) <sup>[(atomic rules)](#atomic-rules)</sup> * [`forty_two< C... >`](#forty_two-c-) <sup>[(ascii rules)](#ascii-rules)</sup> @@ -1483,6 +1549,7 @@ Binary rules do not rely on other rules. * [`opt_must< R, S...>`](#opt_must-r-s-) <sup>[(convenience)](#convenience)</sup> * [`pad< R, S, T = S >`](#pad-r-s-t--s-) <sup>[(convenience)](#convenience)</sup> * [`pad_opt< R, P >`](#pad_opt-r-p-) <sup>[(convenience)](#convenience)</sup> +* [`partial< R... >`](#partial-r-) <sup>[(convenience)](#convenience)</sup> * [`pattern_syntax`](#pattern_syntax) <sup>[(icu rules)](#icu-rules-for-binary-properties)</sup> * [`pattern_white_space`](#pattern_white_space) <sup>[(icu rules)](#icu-rules-for-binary-properties)</sup> * [`plus< R... >`](#plus-r-) <sup>[(combinators)](#combinators)</sup> @@ -1496,6 +1563,7 @@ Binary rules do not rely on other rules. * [`quotation_mark`](#quotation_mark) <sup>[(icu rules)](#icu-rules-for-binary-properties)</sup> * [`radical`](#radical) <sup>[(icu rules)](#icu-rules-for-binary-properties)</sup> * [`raise< T >`](#raise-t-) <sup>[(atomic rules)](#atomic-rules)</sup> +* [`raise_message< C... >`](#raise_message-c-) <sup>[(atomic rules)](#atomic-rules)</sup> * [`range< C, D >`](#range-c-d-) <sup>[(ascii rules)](#ascii-rules)</sup> * [`range< C, D >`](#range-c-d--1) <sup>[(unicode rules)](#unicode-rules)</sup> * [`range< C, D >`](#range-c-d--2) <sup>[(binary rules)](#binary-rules)</sup> @@ -1523,13 +1591,17 @@ Binary rules do not rely on other rules. * [`space`](#space) <sup>[(ascii rules)](#ascii-rules)</sup> * [`star< R... >`](#star-r-) <sup>[(combinators)](#combinators)</sup> * [`star_must< R, S... >`](#star_must-r-s-) <sup>[(convenience)](#convenience)</sup> +* [`star_partial< R... >`](#star_partial-r-) <sup>[(convenience)](#convenience)</sup> +* [`star_strict< R... >`](#star_strict-r-) <sup>[(convenience)](#convenience)</sup> * [`state< S, R... >`](#state-s-r-) <sup>[(meta rules)](#meta-rules)</sup> +* [`strict< R... >`](#strict-r-) <sup>[(convenience)](#convenience)</sup> * [`string< C... >`](#string-c-) <sup>[(ascii rules)](#ascii-rules)</sup> * [`string< C... >`](#string-c--1) <sup>[(unicode rules)](#unicode-rules)</sup> * [`string< C... >`](#string-c--2) <sup>[(binary rules)](#binary-rules)</sup> * [`success`](#success) <sup>[(atomic rules)](#atomic-rules)</sup> * [`TAO_PEGTL_ISTRING( "..." )`](#tao_pegtl_istring--) <sup>[(ascii rules)](#ascii_rules)</sup> * [`TAO_PEGTL_KEYWORD( "..." )`](#tao_pegtl_keyword--) <sup>[(ascii rules)](#ascii_rules)</sup> +* [`TAO_PEGTL_RAISE_MESSAGE( "..." )`](#tao_pegtl_raise_message--) <sup>[(atomic rules)](#atomic_rules)</sup> * [`TAO_PEGTL_STRING( "..." )`](#tao_pegtl_string--) <sup>[(ascii rules)](#ascii_rules)</sup> * [`terminal_punctuation`](#terminal_punctuation) <sup>[(icu rules)](#icu-rules-for-binary-properties)</sup> * [`three< C >`](#three-c-) <sup>[(ascii rules)](#ascii-rules)</sup> @@ -1553,10 +1625,11 @@ Binary rules do not rely on other rules. This document is part of the [PEGTL](https://github.com/taocpp/PEGTL). -Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey Distributed under the Boost Software License, Version 1.0<br> See accompanying file [LICENSE_1_0.txt](../LICENSE_1_0.txt) or copy at https://www.boost.org/LICENSE_1_0.txt [Equivalent]: #equivalence [implementation]: #implementation +[Incremental Input]: Inputs-and-Parsing.md#incremental-input [Meta data]: Meta-Data-and-Visit.md diff --git a/packages/PEGTL/doc/Rules-and-Grammars.md b/packages/PEGTL/doc/Rules-and-Grammars.md index f2242c0f4ab61786dc27b0300f4842adba1dccd9..a62a2dd4f3ea2a311d2ba71f6005a1d31f4a1cd3 100644 --- a/packages/PEGTL/doc/Rules-and-Grammars.md +++ b/packages/PEGTL/doc/Rules-and-Grammars.md @@ -155,7 +155,7 @@ Note how the return value reflects the result of the checks, and how input is on The remainder of the program checks that all characters of `argv[ 1 ]` are equal to 0 when divided by 3. ```c++ -using namespace TAO_PEGTL_NAMESPACE; +using namespace tao::pegtl; namespace modulus { @@ -402,6 +402,6 @@ long literal body was: "[foo[" This document is part of the [PEGTL](https://github.com/taocpp/PEGTL). -Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey Distributed under the Boost Software License, Version 1.0<br> See accompanying file [LICENSE_1_0.txt](../LICENSE_1_0.txt) or copy at https://www.boost.org/LICENSE_1_0.txt diff --git a/packages/PEGTL/include/tao/pegtl.hpp b/packages/PEGTL/include/tao/pegtl.hpp index 982d0759af5339d756f1af83776ca9e67118d353..4e7b9823fcbf83c873758d2185d6ecef79903202 100644 --- a/packages/PEGTL/include/tao/pegtl.hpp +++ b/packages/PEGTL/include/tao/pegtl.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -6,6 +6,7 @@ #define TAO_PEGTL_HPP #include "pegtl/config.hpp" + #include "pegtl/demangle.hpp" #include "pegtl/parse.hpp" #include "pegtl/version.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/apply_mode.hpp b/packages/PEGTL/include/tao/pegtl/apply_mode.hpp index e4517c6e8734be54d0c3939c590fe42aefd16ffe..8e61f254894857daa94b82ccc5a99bd27a099dbc 100644 --- a/packages/PEGTL/include/tao/pegtl/apply_mode.hpp +++ b/packages/PEGTL/include/tao/pegtl/apply_mode.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/argv_input.hpp b/packages/PEGTL/include/tao/pegtl/argv_input.hpp index 0518082ad067186846073f65845dfab233df883e..711a6b221cd39d77165a887115efecd9a5813d3b 100644 --- a/packages/PEGTL/include/tao/pegtl/argv_input.hpp +++ b/packages/PEGTL/include/tao/pegtl/argv_input.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/ascii.hpp b/packages/PEGTL/include/tao/pegtl/ascii.hpp index 73bb2cf5001697be0cfc2c4536a88cd0f2e1f6f5..b0b357adb71e29663ecc2e3dcfebf50b464722c9 100644 --- a/packages/PEGTL/include/tao/pegtl/ascii.hpp +++ b/packages/PEGTL/include/tao/pegtl/ascii.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -30,13 +30,13 @@ namespace TAO_PEGTL_NAMESPACE 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 nul : internal::one< internal::result_on_found::success, internal::peek_char, static_cast< 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 ) > {}; + struct print : internal::range< internal::result_on_found::success, internal::peek_char, static_cast< char >( 32 ), static_cast< 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 seven : internal::range< internal::result_on_found::success, internal::peek_char, static_cast< char >( 0 ), static_cast< 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... > {}; diff --git a/packages/PEGTL/include/tao/pegtl/buffer_input.hpp b/packages/PEGTL/include/tao/pegtl/buffer_input.hpp index 4ea21e7c6c4f91fd258ad2865dd1f75515e7e1a5..20e18a82f6cdeddd11135738dbc692f1b05d2d5d 100644 --- a/packages/PEGTL/include/tao/pegtl/buffer_input.hpp +++ b/packages/PEGTL/include/tao/pegtl/buffer_input.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -28,8 +28,8 @@ #include "internal/action_input.hpp" #include "internal/bump.hpp" -#include "internal/iterator.hpp" -#include "internal/marker.hpp" +#include "internal/frobnicator.hpp" +#include "internal/rewind_guard.hpp" namespace TAO_PEGTL_NAMESPACE { @@ -42,7 +42,7 @@ namespace TAO_PEGTL_NAMESPACE using eol_t = Eol; using source_t = Source; - using iterator_t = internal::iterator; + using frobnicator_t = internal::frobnicator; using action_t = internal::action_input< buffer_input >; @@ -58,7 +58,7 @@ namespace TAO_PEGTL_NAMESPACE m_end( m_buffer.get() ), m_source( std::forward< T >( in_source ) ) { - static_assert( Chunk, "zero chunk size not implemented" ); + static_assert( Chunk != 0, "zero chunk size not implemented" ); assert( m_maximum > maximum ); // Catches overflow; change to >= when zero chunk size is implemented. } @@ -161,18 +161,26 @@ namespace TAO_PEGTL_NAMESPACE 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; - } + m_end += m_reader( m_end, ( std::min )( buffer_free_after_end(), ( std::max )( amount - buffer_occupied(), Chunk ) ) ); } template< rewind_mode M > - [[nodiscard]] internal::marker< iterator_t, M > mark() noexcept + [[nodiscard]] internal::rewind_guard< M, buffer_input > auto_rewind() noexcept + { + return internal::rewind_guard< M, buffer_input >( this ); + } + + [[nodiscard]] const frobnicator_t& rewind_save() noexcept + { + return m_current; + } + + void rewind_restore( const frobnicator_t& data ) noexcept { - return internal::marker< iterator_t, M >( m_current ); + m_current = data; } - [[nodiscard]] TAO_PEGTL_NAMESPACE::position position( const iterator_t& it ) const + [[nodiscard]] TAO_PEGTL_NAMESPACE::position position( const frobnicator_t& it ) const { return TAO_PEGTL_NAMESPACE::position( it, m_source ); } @@ -182,7 +190,7 @@ namespace TAO_PEGTL_NAMESPACE return position( m_current ); } - [[nodiscard]] const iterator_t& iterator() const noexcept + [[nodiscard]] const frobnicator_t& frobnicator() const noexcept { return m_current; } @@ -195,26 +203,26 @@ namespace TAO_PEGTL_NAMESPACE [[nodiscard]] std::size_t buffer_occupied() const noexcept { assert( m_end >= m_current.data ); - return std::size_t( m_end - m_current.data ); + return static_cast< 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() ); + return static_cast< 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 ); + return static_cast< 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; + frobnicator_t m_current; char* m_end; const Source m_source; diff --git a/packages/PEGTL/include/tao/pegtl/change_action.hpp b/packages/PEGTL/include/tao/pegtl/change_action.hpp index 75496d45fe92dfa811cd6950cde436b2929450fd..dd3d273cedda92fcc81237d774748a2888be0947 100644 --- a/packages/PEGTL/include/tao/pegtl/change_action.hpp +++ b/packages/PEGTL/include/tao/pegtl/change_action.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/change_action_and_state.hpp b/packages/PEGTL/include/tao/pegtl/change_action_and_state.hpp index 248c6fedbeb9599dafd54b6a2d19b07d2bd7477a..e29ad167363fdb3e99d7896a44c22099f7e77ab0 100644 --- a/packages/PEGTL/include/tao/pegtl/change_action_and_state.hpp +++ b/packages/PEGTL/include/tao/pegtl/change_action_and_state.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/change_action_and_states.hpp b/packages/PEGTL/include/tao/pegtl/change_action_and_states.hpp index 9d0614f2f0620c10aeaf3ce67c049cb58ed7667f..51540b685cd372cdc479ee8c9ff068cdeb332d1c 100644 --- a/packages/PEGTL/include/tao/pegtl/change_action_and_states.hpp +++ b/packages/PEGTL/include/tao/pegtl/change_action_and_states.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/change_control.hpp b/packages/PEGTL/include/tao/pegtl/change_control.hpp index e825e235903cff1d30a2d7bd44d6018f96aa02d5..98717a24332a67418fe51d9a59558a66f4d5c04d 100644 --- a/packages/PEGTL/include/tao/pegtl/change_control.hpp +++ b/packages/PEGTL/include/tao/pegtl/change_control.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/change_state.hpp b/packages/PEGTL/include/tao/pegtl/change_state.hpp index 549ff4d7bc3c8f8cb3469f28af39103d4cca6e90..1679072be3bf078c0e470a9b070ff97e955a6955 100644 --- a/packages/PEGTL/include/tao/pegtl/change_state.hpp +++ b/packages/PEGTL/include/tao/pegtl/change_state.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/change_states.hpp b/packages/PEGTL/include/tao/pegtl/change_states.hpp index 59835c266d7911820e13d08e72ba11ba8cb484ed..ae8835cc39c657e5da44b08b6b20bd87e11c4400 100644 --- a/packages/PEGTL/include/tao/pegtl/change_states.hpp +++ b/packages/PEGTL/include/tao/pegtl/change_states.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/config.hpp b/packages/PEGTL/include/tao/pegtl/config.hpp index a58f22eb00cf1947d12ad17c9a9644e2aa9c6ff9..521623d26853772d266101fa1d9a5052d9dabf3e 100644 --- a/packages/PEGTL/include/tao/pegtl/config.hpp +++ b/packages/PEGTL/include/tao/pegtl/config.hpp @@ -1,13 +1,10 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) +// Copyright (c) 2017-2023 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 ) -#pragma message( "TAO_PEGTL_NAMESPACE is deprecated" ) -#else +#if !defined( TAO_PEGTL_NAMESPACE ) #define TAO_PEGTL_NAMESPACE tao::pegtl #endif diff --git a/packages/PEGTL/include/tao/pegtl/contrib/abnf.hpp b/packages/PEGTL/include/tao/pegtl/contrib/abnf.hpp index 6778f7a10f9b481ab7403aa2e0974e6e781815e4..2548e53be9f730bbda319ce0e6d66f851767ef3f 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/abnf.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/abnf.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -6,6 +6,7 @@ #define TAO_PEGTL_CONTRIB_ABNF_HPP #include "../config.hpp" + #include "../internal/rules.hpp" namespace TAO_PEGTL_NAMESPACE::abnf @@ -15,10 +16,10 @@ namespace TAO_PEGTL_NAMESPACE::abnf // 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 CHAR : internal::range< internal::result_on_found::success, internal::peek_char, static_cast< char >( 1 ), static_cast< 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 CTL : internal::ranges< internal::peek_char, static_cast< char >( 0 ), static_cast< char >( 31 ), static_cast< 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' > {}; @@ -27,7 +28,7 @@ namespace TAO_PEGTL_NAMESPACE::abnf 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 VCHAR : internal::range< internal::result_on_found::success, internal::peek_char, static_cast< char >( 33 ), static_cast< char >( 126 ) > {}; struct WSP : internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\t' > {}; // clang-format on diff --git a/packages/PEGTL/include/tao/pegtl/contrib/add_state.hpp b/packages/PEGTL/include/tao/pegtl/contrib/add_state.hpp index be91cd89cb1bf9e96112a8e4b1754410415e3686..f7e2c0635b5297020c087e69bd7ed6c9340d6d7b 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/add_state.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/add_state.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2021-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/contrib/alphabet.hpp b/packages/PEGTL/include/tao/pegtl/contrib/alphabet.hpp index 798530e05af4d18eb04407412051dd6d6376bf35..05acd5874ba5fcd1413a1290dfa37999f9bfa42a 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/alphabet.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/alphabet.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -44,7 +44,7 @@ namespace TAO_PEGTL_NAMESPACE::alphabet 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 I = 'I'; // NOLINT(readability-identifier-naming,misc-confusable-identifiers) 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) diff --git a/packages/PEGTL/include/tao/pegtl/contrib/analyze.hpp b/packages/PEGTL/include/tao/pegtl/contrib/analyze.hpp index 6b4b093b720cb5b2be239b7d1ddef9ee253506bb..3d4b7f1391796a5f6901f98b39410a40fbd3f8d0 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/analyze.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/analyze.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -68,8 +68,7 @@ namespace TAO_PEGTL_NAMESPACE protected: explicit analyze_cycles_impl( const int verbose ) noexcept - : m_verbose( verbose ), - m_problems( 0 ) + : m_verbose( verbose ) {} [[nodiscard]] const std::pair< const std::string_view, analyze_entry >& find( const std::string_view name ) const noexcept @@ -140,7 +139,7 @@ namespace TAO_PEGTL_NAMESPACE const int m_verbose; - std::size_t m_problems; + std::size_t m_problems = 0; std::set< std::string_view > m_stack; std::vector< std::string_view > m_trace; diff --git a/packages/PEGTL/include/tao/pegtl/contrib/analyze_traits.hpp b/packages/PEGTL/include/tao/pegtl/contrib/analyze_traits.hpp index b835098fbc5076cb2801aa8c2b825c6db0263a5f..33f47d4c3d968e185838b6237ce9ad21a131a0fc 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/analyze_traits.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/analyze_traits.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -131,6 +131,11 @@ namespace TAO_PEGTL_NAMESPACE : analyze_opt_traits<> {}; + template< typename Name, typename Size > + struct analyze_traits< Name, internal::everything< Size > > + : analyze_opt_traits<> + {}; + template< typename Name > struct analyze_traits< Name, internal::failure > : analyze_any_traits<> @@ -161,9 +166,14 @@ namespace TAO_PEGTL_NAMESPACE : 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::opt< Rules... > > + : analyze_opt_traits< Rules... > + {}; + + template< typename Name, typename... Rules > + struct analyze_traits< Name, internal::partial< Rules... > > + : analyze_opt_traits< Rules... > {}; template< typename Name, typename... Rules > @@ -221,6 +231,11 @@ namespace TAO_PEGTL_NAMESPACE : analyze_traits< Name, typename opt< Rules..., Name >::rule_t > {}; + template< typename Name, typename... Rules > + struct analyze_traits< Name, internal::star_partial< 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 > diff --git a/packages/PEGTL/include/tao/pegtl/contrib/check_bytes.hpp b/packages/PEGTL/include/tao/pegtl/contrib/check_bytes.hpp index cfd313db7d7c148e4a7f366a23a895a220bcdadc..25a14d06b56d66fd4410f6f4ee4b90d2767919b7 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/check_bytes.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/check_bytes.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2021-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -25,8 +25,8 @@ namespace TAO_PEGTL_NAMESPACE : maybe_nothing { template< typename Rule, - pegtl::apply_mode A, - pegtl::rewind_mode M, + apply_mode A, + rewind_mode M, template< typename... > class Action, template< typename... > diff --git a/packages/PEGTL/include/tao/pegtl/contrib/control_action.hpp b/packages/PEGTL/include/tao/pegtl/contrib/control_action.hpp index 239e6213bdabbb0d11bcc468dbc8cb27da574586..edff6bde5043efd93335c14fb1f0242f3dd7a779 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/control_action.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/control_action.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -55,6 +55,18 @@ namespace TAO_PEGTL_NAMESPACE #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, diff --git a/packages/PEGTL/include/tao/pegtl/contrib/coverage.hpp b/packages/PEGTL/include/tao/pegtl/contrib/coverage.hpp index bfa75424fbe26d170b58c69c5f84ddc25b73795c..001a9f87cf659a3ea48168f9d4bd36ffae7367b3 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/coverage.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/coverage.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/contrib/forward.hpp b/packages/PEGTL/include/tao/pegtl/contrib/forward.hpp index aa9f351e4e2956fc7f11eb719d695a117439c0ec..16905c654390b74b254e03e4db16e0d0a3dbd61d 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/forward.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/forward.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/contrib/function.hpp b/packages/PEGTL/include/tao/pegtl/contrib/function.hpp index 86d535896d4cef96d48e1b7b071060078032786d..91d1ef029f0d566baca8b3eb68be7af4033358a2 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/function.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/function.hpp @@ -1,13 +1,12 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_CONTRIB_FUNCTION_HPP #define TAO_PEGTL_CONTRIB_FUNCTION_HPP -#include "../config.hpp" - #include "../apply_mode.hpp" +#include "../config.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/contrib/http.hpp b/packages/PEGTL/include/tao/pegtl/contrib/http.hpp index e794a6dd739a803d4a323728d87daa77fbfe3426..22f439e1dc746180e1c63f220319a92ce2908202 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/http.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/http.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/contrib/icu/internal.hpp b/packages/PEGTL/include/tao/pegtl/contrib/icu/internal.hpp index 02976fd6d210a221d6f799aa72e8ef651bda4dd7..78b0323952367883769cf58bf1dd488f4da1fbdd 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/icu/internal.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/icu/internal.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -29,7 +29,7 @@ namespace TAO_PEGTL_NAMESPACE using rule_t = binary_property; using subs_t = empty_list; - [[nodiscard]] static bool test( const data_t c ) noexcept + [[nodiscard]] static bool test_one( const data_t c ) noexcept { return u_hasBinaryProperty( c, P ) == V; } @@ -38,7 +38,7 @@ namespace TAO_PEGTL_NAMESPACE [[nodiscard]] static bool match( ParseInput& in ) noexcept( noexcept( Peek::peek( in ) ) ) { if( const auto t = Peek::peek( in ) ) { - if( test( t.data ) ) { + if( test_one( t.data ) ) { in.bump( t.size ); return true; } @@ -56,7 +56,7 @@ namespace TAO_PEGTL_NAMESPACE using rule_t = property_value; using subs_t = empty_list; - [[nodiscard]] static bool test( const data_t c ) noexcept + [[nodiscard]] static bool test_one( const data_t c ) noexcept { return u_getIntPropertyValue( c, P ) == V; } @@ -65,7 +65,7 @@ namespace TAO_PEGTL_NAMESPACE [[nodiscard]] static bool match( ParseInput& in ) noexcept( noexcept( Peek::peek( in ) ) ) { if( const auto t = Peek::peek( in ) ) { - if( test( t.data ) ) { + if( test_one( t.data ) ) { in.bump( t.size ); return true; } diff --git a/packages/PEGTL/include/tao/pegtl/contrib/icu/utf16.hpp b/packages/PEGTL/include/tao/pegtl/contrib/icu/utf16.hpp index 1b04ad8b2ec60a361ce8d32395c85c4e1332dc21..418419df0c339a4681d89d70c21944a9fc0e7a8f 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/icu/utf16.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/icu/utf16.hpp @@ -1,13 +1,14 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_CONTRIB_ICU_UTF16_HPP #define TAO_PEGTL_CONTRIB_ICU_UTF16_HPP +#include "../../config.hpp" + #include "internal.hpp" -#include "../../config.hpp" #include "../utf16.hpp" #include "../internal/peek_utf16.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/contrib/icu/utf32.hpp b/packages/PEGTL/include/tao/pegtl/contrib/icu/utf32.hpp index 738b0e61f1dfe1f9c9d09c17e1e5e80911670908..a830cdd0cea85df796c1cf05ad1c8d8d0ae351f4 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/icu/utf32.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/icu/utf32.hpp @@ -1,13 +1,14 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_CONTRIB_ICU_UTF32_HPP #define TAO_PEGTL_CONTRIB_ICU_UTF32_HPP +#include "../../config.hpp" + #include "internal.hpp" -#include "../../config.hpp" #include "../utf32.hpp" #include "../internal/peek_utf32.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/contrib/icu/utf8.hpp b/packages/PEGTL/include/tao/pegtl/contrib/icu/utf8.hpp index 7a7ced60128523593bc951ec037f3dfdddf603d7..065837dc4537bb38dc6d1c8a836cf4d16e50a1fc 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/icu/utf8.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/icu/utf8.hpp @@ -1,13 +1,14 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_CONTRIB_ICU_UTF8_HPP #define TAO_PEGTL_CONTRIB_ICU_UTF8_HPP +#include "../../config.hpp" + #include "internal.hpp" -#include "../../config.hpp" #include "../../utf8.hpp" #include "../../internal/peek_utf8.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/contrib/if_then.hpp b/packages/PEGTL/include/tao/pegtl/contrib/if_then.hpp index 897f55c026d46394c3a63e0bbcb65083fd01bb0d..373b58ef4a6959975a21d80f9759b5e5cffde8aa 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/if_then.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/if_then.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/contrib/input_with_depth.hpp b/packages/PEGTL/include/tao/pegtl/contrib/input_with_depth.hpp new file mode 100644 index 0000000000000000000000000000000000000000..da2f6b5c683a3a1d31049b19fbbf1dc3d9dcab25 --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/contrib/input_with_depth.hpp @@ -0,0 +1,70 @@ +// Copyright (c) 2021-2023 Dr. Colin Hirsch and Daniel Frey +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) + +#ifndef TAO_PEGTL_CONTRIB_INPUT_WITH_DEPTH_HPP +#define TAO_PEGTL_CONTRIB_INPUT_WITH_DEPTH_HPP + +#include <cstddef> + +#include "../config.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + namespace internal + { + class [[nodiscard]] depth_guard + { + public: + 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; + + [[nodiscard]] std::size_t current_depth() const noexcept + { + return m_depth; + } + + private: + std::size_t& m_depth; + }; + + } // namespace internal + + template< typename Input > + class input_with_depth + : public Input + { + public: + using Input::Input; + + [[nodiscard]] internal::depth_guard make_depth_guard() noexcept + { + return internal::depth_guard( m_depth ); // NOLINT(google-readability-casting) + } + + [[nodiscard]] std::size_t current_depth() const noexcept + { + return m_depth; + } + + private: + std::size_t m_depth = 0; + }; + +} // namespace TAO_PEGTL_NAMESPACE + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/contrib/instantiate.hpp b/packages/PEGTL/include/tao/pegtl/contrib/instantiate.hpp index ce8bb4c293fe9ef45f85d1919d49fe4cdfd4b4d3..61ac3a6233617c0750e67958ecf29cb18828baad 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/instantiate.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/instantiate.hpp @@ -1,13 +1,12 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_CONTRIB_INSTANTIATE_HPP #define TAO_PEGTL_CONTRIB_INSTANTIATE_HPP -#include "../config.hpp" - #include "../apply_mode.hpp" +#include "../config.hpp" #include "../match.hpp" #include "../nothing.hpp" #include "../rewind_mode.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/contrib/integer.hpp b/packages/PEGTL/include/tao/pegtl/contrib/integer.hpp index 2fbc7285dcde90629456db3a5c334ffb5e93e94f..8556cd68bce9c59d2aedae1ba129ea6957dc2a26 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/integer.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/integer.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -17,6 +17,7 @@ #include <type_traits> #include "../ascii.hpp" +#include "../config.hpp" #include "../parse.hpp" #include "../parse_error.hpp" #include "../rules.hpp" @@ -143,7 +144,7 @@ namespace TAO_PEGTL_NAMESPACE if( input[ 0 ] == '-' ) { return convert_negative< Signed >( result, std::string_view( input.data() + 1, input.size() - 1 ) ); } - const auto offset = unsigned( input[ 0 ] == '+' ); + const auto offset = static_cast< unsigned >( input[ 0 ] == '+' ); return convert_positive< Signed >( result, std::string_view( input.data() + offset, input.size() - offset ) ); } @@ -383,7 +384,7 @@ namespace TAO_PEGTL_NAMESPACE 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. + return parse< signed_rule_new >( in ); // Does not check for any overflow. } }; @@ -416,7 +417,7 @@ namespace TAO_PEGTL_NAMESPACE 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. + return parse< signed_rule_new >( in ); // Does not check for any overflow. } template< apply_mode A, @@ -429,7 +430,7 @@ namespace TAO_PEGTL_NAMESPACE 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. + return parse< signed_rule_new, internal::signed_action_action >( in, st ); // Throws on overflow. } }; diff --git a/packages/PEGTL/include/tao/pegtl/contrib/internal/endian.hpp b/packages/PEGTL/include/tao/pegtl/contrib/internal/endian.hpp index fc997a311651a584583f72198ab325d158406cec..43d90b9d67fa5cf5ec88124a9f199ced8d6bbadf 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/internal/endian.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/internal/endian.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/contrib/internal/endian_gcc.hpp b/packages/PEGTL/include/tao/pegtl/contrib/internal/endian_gcc.hpp index d6a82315520517ef535f0a947284169376529dd3..c261be2b4ffec403c5a0d4fb40fb614d54a85fbf 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/internal/endian_gcc.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/internal/endian_gcc.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -8,6 +8,8 @@ #include <cstdint> #include <cstring> +#include "../../config.hpp" + namespace TAO_PEGTL_NAMESPACE::internal { #if !defined( __BYTE_ORDER__ ) diff --git a/packages/PEGTL/include/tao/pegtl/contrib/internal/endian_win.hpp b/packages/PEGTL/include/tao/pegtl/contrib/internal/endian_win.hpp index ac21c8bcc900a3a47b48ef5e9c6a029f61b45839..c0b1851ec509581a0dd8248c51b37de2b01e32c4 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/internal/endian_win.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/internal/endian_win.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -9,6 +9,8 @@ #include <cstdlib> #include <cstring> +#include "../../config.hpp" + namespace TAO_PEGTL_NAMESPACE::internal { template< std::size_t S > diff --git a/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_mask_uint.hpp b/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_mask_uint.hpp index f34baa4f708fd0e06424b8100b6d98aea5a6117c..6fafc911795a0bbf3030e5f4f4acbe73b757519c 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_mask_uint.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_mask_uint.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -8,8 +8,7 @@ #include <cstddef> #include <cstdint> -#include "../../config.hpp" -#include "../../internal/input_pair.hpp" +#include "../../internal/data_and_size.hpp" #include "read_uint.hpp" @@ -19,7 +18,7 @@ namespace TAO_PEGTL_NAMESPACE::internal struct peek_mask_uint_impl { using data_t = typename R::type; - using pair_t = input_pair< data_t >; + using pair_t = data_and_size< data_t >; template< typename ParseInput > [[nodiscard]] static pair_t peek( ParseInput& in ) noexcept( noexcept( in.size( sizeof( data_t ) ) ) ) diff --git a/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_mask_uint8.hpp b/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_mask_uint8.hpp index b57da1809cb774ed26c2f5339a8e04293bf36ebf..28c63ced2040231d77c72dc865579166fa4b94c8 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_mask_uint8.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_mask_uint8.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -8,8 +8,7 @@ #include <cstddef> #include <cstdint> -#include "../../config.hpp" -#include "../../internal/input_pair.hpp" +#include "../../internal/data_and_size.hpp" namespace TAO_PEGTL_NAMESPACE::internal { @@ -17,7 +16,7 @@ namespace TAO_PEGTL_NAMESPACE::internal struct peek_mask_uint8 { using data_t = std::uint8_t; - using pair_t = input_pair< std::uint8_t >; + using pair_t = data_and_size< std::uint8_t >; template< typename ParseInput > [[nodiscard]] static pair_t peek( ParseInput& in ) noexcept( noexcept( in.empty() ) ) diff --git a/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_uint.hpp b/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_uint.hpp index 62f7555b666c03a01384e9051cfcc1a99f1e8f12..8151f2a3f72a579f18c1a7009247ea868c111b4d 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_uint.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_uint.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -8,8 +8,7 @@ #include <cstddef> #include <cstdint> -#include "../../config.hpp" -#include "../../internal/input_pair.hpp" +#include "../../internal/data_and_size.hpp" #include "read_uint.hpp" @@ -19,7 +18,7 @@ namespace TAO_PEGTL_NAMESPACE::internal struct peek_uint_impl { using data_t = typename R::type; - using pair_t = input_pair< data_t >; + using pair_t = data_and_size< data_t >; template< typename ParseInput > [[nodiscard]] static pair_t peek( ParseInput& in ) noexcept( noexcept( in.size( sizeof( data_t ) ) ) ) diff --git a/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_uint8.hpp b/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_uint8.hpp index 9b437f4c650d827ca9b0e3c3681d1dd62db0093c..9e343eb2d0b35f6549815685441625dbe37fa6de 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_uint8.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_uint8.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -8,15 +8,14 @@ #include <cstddef> #include <cstdint> -#include "../../config.hpp" -#include "../../internal/input_pair.hpp" +#include "../../internal/data_and_size.hpp" namespace TAO_PEGTL_NAMESPACE::internal { struct peek_uint8 { using data_t = std::uint8_t; - using pair_t = input_pair< std::uint8_t >; + using pair_t = data_and_size< std::uint8_t >; template< typename ParseInput > [[nodiscard]] static pair_t peek( ParseInput& in ) noexcept( noexcept( in.empty() ) ) diff --git a/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_utf16.hpp b/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_utf16.hpp index 6a5006c216e847d993b5f56b06c9459cfc2dfb26..b4ab1091c2baabd4e0cd5335cb38f99704c752f8 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_utf16.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_utf16.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -7,8 +7,7 @@ #include <type_traits> -#include "../../config.hpp" -#include "../../internal/input_pair.hpp" +#include "../../internal/data_and_size.hpp" #include "read_uint.hpp" @@ -18,7 +17,7 @@ namespace TAO_PEGTL_NAMESPACE::internal struct peek_utf16_impl { using data_t = char32_t; - using pair_t = input_pair< char32_t >; + using pair_t = data_and_size< char32_t >; using short_t = std::make_unsigned< char16_t >::type; diff --git a/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_utf32.hpp b/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_utf32.hpp index 0d78db0dacf6cc8694a32e1d960362831f314ebe..a32170d94c1e271055dd9c6ef92ce52e75ab9ef4 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_utf32.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/internal/peek_utf32.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -7,8 +7,7 @@ #include <cstddef> -#include "../../config.hpp" -#include "../../internal/input_pair.hpp" +#include "../../internal/data_and_size.hpp" #include "read_uint.hpp" @@ -18,7 +17,7 @@ namespace TAO_PEGTL_NAMESPACE::internal struct peek_utf32_impl { using data_t = char32_t; - using pair_t = input_pair< char32_t >; + using pair_t = data_and_size< char32_t >; static_assert( sizeof( char32_t ) == 4 ); diff --git a/packages/PEGTL/include/tao/pegtl/contrib/internal/read_uint.hpp b/packages/PEGTL/include/tao/pegtl/contrib/internal/read_uint.hpp index 8f294726aa7b64d9b6f358ddd8148cc40d85c900..63f61c786ab85521bf497143600be94ea47a511a 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/internal/read_uint.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/internal/read_uint.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -7,8 +7,6 @@ #include <cstdint> -#include "../../config.hpp" - #include "endian.hpp" namespace TAO_PEGTL_NAMESPACE::internal diff --git a/packages/PEGTL/include/tao/pegtl/contrib/internal/set_stack_guard.hpp b/packages/PEGTL/include/tao/pegtl/contrib/internal/set_stack_guard.hpp index a7c89b5ec3c86fc76a55f228c667fb3f35960fff..4e4fb0dc0eb40b5ab70100e5832978b503132474 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/internal/set_stack_guard.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/internal/set_stack_guard.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -8,8 +8,6 @@ #include <set> #include <utility> -#include "../../config.hpp" - namespace TAO_PEGTL_NAMESPACE::internal { template< typename... Cs > @@ -35,7 +33,7 @@ namespace TAO_PEGTL_NAMESPACE::internal } } - explicit operator bool() const noexcept + [[nodiscard]] explicit operator bool() const noexcept { return m_i.second; } diff --git a/packages/PEGTL/include/tao/pegtl/contrib/internal/vector_stack_guard.hpp b/packages/PEGTL/include/tao/pegtl/contrib/internal/vector_stack_guard.hpp index b143457f4ff39776f9101b5284a16b5d53b22e29..1b7c69a8dfd9f1abd2f01bfe76c28179df3a528f 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/internal/vector_stack_guard.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/internal/vector_stack_guard.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -8,8 +8,6 @@ #include <utility> #include <vector> -#include "../../config.hpp" - namespace TAO_PEGTL_NAMESPACE::internal { template< typename... Cs > diff --git a/packages/PEGTL/include/tao/pegtl/contrib/iri.hpp b/packages/PEGTL/include/tao/pegtl/contrib/iri.hpp index defdc42fa0d72b1725e97c1c4bf497a8af64e84d..858432275a439041964fd38050404c34b40d0fef 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/iri.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/iri.hpp @@ -1,5 +1,5 @@ -// Copyright (c) 2021 Kelvin Hammond -// Copyright (c) 2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2021-2023 Kelvin Hammond +// Copyright (c) 2021-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/contrib/json.hpp b/packages/PEGTL/include/tao/pegtl/contrib/json.hpp index e47aaae4b5b01bb22bd1212781aa6fdd8c347559..0b9dcdaa3e2daa76f61a32e2dbf72ac63bdb059f 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/json.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/json.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -37,7 +37,7 @@ namespace TAO_PEGTL_NAMESPACE::json 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 xdigit : TAO_PEGTL_NAMESPACE::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 > {}; diff --git a/packages/PEGTL/include/tao/pegtl/contrib/json_pointer.hpp b/packages/PEGTL/include/tao/pegtl/contrib/json_pointer.hpp index 5e920d720b1e0d2b82dc77f4252f965eb67e4db2..29f77030ba7d990f8efd92db7547119414e4a249 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/json_pointer.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/json_pointer.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/contrib/limit_bytes.hpp b/packages/PEGTL/include/tao/pegtl/contrib/limit_bytes.hpp index 1447e1fd58fdd2a964bcdcc1263ed90696a27005..bbcc3ccb5c8c4592a9ca7bc348ec188cc065fffd 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/limit_bytes.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/limit_bytes.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2021-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -57,6 +57,8 @@ namespace TAO_PEGTL_NAMESPACE struct limit_bytes : maybe_nothing { + static constexpr const char* error_message = "maximum allowed rule consumption reached"; + template< typename Rule, apply_mode A, rewind_mode M, @@ -72,7 +74,7 @@ namespace TAO_PEGTL_NAMESPACE 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 ); + Control< limit_bytes >::raise( in ); #else std::fputs( "maximum allowed rule consumption reached\n", stderr ); std::terminate(); diff --git a/packages/PEGTL/include/tao/pegtl/contrib/limit_depth.hpp b/packages/PEGTL/include/tao/pegtl/contrib/limit_depth.hpp index a84e002eaed39f027d4c7f2b60a9c8ad27689cd3..3dbcf53b6e624e14281fec0c1b3e25da96a38663 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/limit_depth.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/limit_depth.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2021-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -20,36 +20,12 @@ 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 { + static constexpr const char* error_message = "maximum parser rule nesting depth exceeded"; + template< typename Rule, apply_mode A, rewind_mode M, @@ -62,10 +38,10 @@ namespace TAO_PEGTL_NAMESPACE [[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 ) { + const auto dg( in.make_depth_guard() ); + if( dg.current_depth() > Maximum ) { #if defined( __cpp_exceptions ) - throw TAO_PEGTL_NAMESPACE::parse_error( "maximum parser rule nesting depth exceeded", in ); + Control< limit_depth >::raise( in ); #else std::fputs( "maximum parser rule nesting depth exceeded\n", stderr ); std::terminate(); diff --git a/packages/PEGTL/include/tao/pegtl/contrib/parse_tree.hpp b/packages/PEGTL/include/tao/pegtl/contrib/parse_tree.hpp index 8de35b8cd13051ba046959e108933a6c160d484e..c442da75ebdb9eaea04e30212495c776f1fe05d0 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/parse_tree.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/parse_tree.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -28,8 +28,8 @@ #include "../rewind_mode.hpp" #include "../internal/enable_control.hpp" +#include "../internal/frobnicator.hpp" #include "../internal/has_unwind.hpp" -#include "../internal/iterator.hpp" namespace TAO_PEGTL_NAMESPACE::parse_tree { @@ -43,8 +43,8 @@ namespace TAO_PEGTL_NAMESPACE::parse_tree std::string_view type; Source source; - TAO_PEGTL_NAMESPACE::internal::iterator m_begin; - TAO_PEGTL_NAMESPACE::internal::iterator m_end; + TAO_PEGTL_NAMESPACE::internal::frobnicator m_begin; + TAO_PEGTL_NAMESPACE::internal::frobnicator m_end; // each node will be default constructed basic_node() = default; @@ -96,13 +96,13 @@ namespace TAO_PEGTL_NAMESPACE::parse_tree [[nodiscard]] std::string_view string_view() const noexcept { assert( has_content() ); - return std::string_view( m_begin.data, m_end.data - m_begin.data ); + return { m_begin.data, static_cast< std::size_t >( m_end.data - m_begin.data ) }; } [[nodiscard]] std::string string() const { assert( has_content() ); - return std::string( m_begin.data, m_end.data ); + return { m_begin.data, m_end.data }; } template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > @@ -115,7 +115,7 @@ namespace TAO_PEGTL_NAMESPACE::parse_tree template< typename... States > void remove_content( States&&... /*unused*/ ) noexcept { - m_end = TAO_PEGTL_NAMESPACE::internal::iterator(); + m_end = TAO_PEGTL_NAMESPACE::internal::frobnicator(); } // all non-root nodes are initialized by calling this method @@ -124,14 +124,14 @@ namespace TAO_PEGTL_NAMESPACE::parse_tree { set_type< Rule >(); source = in.source(); - m_begin = TAO_PEGTL_NAMESPACE::internal::iterator( in.iterator() ); + m_begin = TAO_PEGTL_NAMESPACE::internal::frobnicator( in.frobnicator() ); } // 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() ); + m_end = TAO_PEGTL_NAMESPACE::internal::frobnicator( in.frobnicator() ); } // if parsing of the rule failed, this method is called @@ -139,11 +139,6 @@ namespace TAO_PEGTL_NAMESPACE::parse_tree void failure( const ParseInput& /*unused*/, States&&... /*unused*/ ) noexcept {} - // if parsing of the rule failed with an exception, this method is called - template< typename Rule, typename ParseInput, typename... States > - void unwind( 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 @@ -233,6 +228,19 @@ namespace TAO_PEGTL_NAMESPACE::parse_tree 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 > @@ -310,13 +318,19 @@ namespace TAO_PEGTL_NAMESPACE::parse_tree } template< typename ParseInput, typename... States > - static void unwind( const ParseInput& in, state< Node >& state, States&&... st ) + static void unwind( [[maybe_unused]] const ParseInput& in, [[maybe_unused]] state< Node >& state, States&&... st ) { - state.back()->template unwind< Rule >( in, st... ); + if constexpr( node_has_unwind< Node, Rule, void, const ParseInput&, States... > ) { + state.back()->template unwind< Rule >( in, st... ); + } state.pop_back(); - if constexpr( TAO_PEGTL_NAMESPACE::internal::has_unwind< Control< Rule >, void, const ParseInput&, States... > ) { + if constexpr( control_has_unwind< Control< Rule >, const ParseInput&, States... > ) { Control< Rule >::unwind( in, st... ); } +#if defined( _MSC_VER ) + ( (void)st, + ... ); +#endif } }; diff --git a/packages/PEGTL/include/tao/pegtl/contrib/parse_tree_to_dot.hpp b/packages/PEGTL/include/tao/pegtl/contrib/parse_tree_to_dot.hpp index f186bf6ea0c559fb6d8e38c2fe1afb2d1c085b89..a713a26aa199241a439c869cb498b7a72c55e4bb 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/parse_tree_to_dot.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/parse_tree_to_dot.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -9,6 +9,8 @@ #include <ostream> #include <string> +#include "../config.hpp" + #include "parse_tree.hpp" namespace TAO_PEGTL_NAMESPACE::parse_tree diff --git a/packages/PEGTL/include/tao/pegtl/contrib/predicates.hpp b/packages/PEGTL/include/tao/pegtl/contrib/predicates.hpp index 4e37e29072324e5545ea1cf0dc67c70acdeba3dd..ad30169bc56304f51614f83ed359cedb645e5445 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/predicates.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/predicates.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -27,9 +27,9 @@ namespace TAO_PEGTL_NAMESPACE using peek_t = Peek; using data_t = typename Peek::data_t; - [[nodiscard]] static constexpr bool test( const data_t c ) noexcept + [[nodiscard]] static constexpr bool test_impl( const data_t c ) noexcept { - return ( Ps::test( c ) && ... ); // TODO: Static assert that Ps::peek_t is the same as peek_t?! + return ( Ps::test_one( c ) && ... ); // TODO: Static assert that Ps::peek_t is the same as peek_t?! } }; @@ -39,9 +39,9 @@ namespace TAO_PEGTL_NAMESPACE using peek_t = Peek; using data_t = typename Peek::data_t; - [[nodiscard]] static constexpr bool test( const data_t c ) noexcept + [[nodiscard]] static constexpr bool test_impl( const data_t c ) noexcept { - return !P::test( c ); // TODO: Static assert that P::peek_t is the same as peek_t?! + return !P::test_one( c ); // TODO: Static assert that P::peek_t is the same as peek_t?! } }; @@ -51,9 +51,9 @@ namespace TAO_PEGTL_NAMESPACE using peek_t = Peek; using data_t = typename Peek::data_t; - [[nodiscard]] static constexpr bool test( const data_t c ) noexcept + [[nodiscard]] static constexpr bool test_impl( const data_t c ) noexcept { - return ( Ps::test( c ) || ... ); // TODO: Static assert that Ps::peek_t is the same as peek_t?! + return ( Ps::test_one( c ) || ... ); // TODO: Static assert that Ps::peek_t is the same as peek_t?! } }; @@ -68,16 +68,22 @@ namespace TAO_PEGTL_NAMESPACE 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 ); + [[nodiscard]] static constexpr bool test_one( const data_t c ) noexcept + { + return Test< Peek, Ps... >::test_impl( c ); + } + + [[nodiscard]] static constexpr bool test_any( const data_t c ) noexcept + { + return Test< Peek, Ps... >::test_impl( c ); + } 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 ) ) { + if( test_one( t.data ) ) { bump_help< predicates >( in, t.size ); return true; } diff --git a/packages/PEGTL/include/tao/pegtl/contrib/print.hpp b/packages/PEGTL/include/tao/pegtl/contrib/print.hpp index 18d803021412de70c06aaac6bb698d959add68b1..6e079e9dd8a3feb5235d147ff718733b21c59dee 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/print.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/print.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/contrib/print_coverage.hpp b/packages/PEGTL/include/tao/pegtl/contrib/print_coverage.hpp index 9b0774f0467249aa09eb42716112845845aea6ae..ba20d365db51c0274edb64a19ef72983434b3ba1 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/print_coverage.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/print_coverage.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -7,6 +7,8 @@ #include <ostream> +#include "../config.hpp" + #include "coverage.hpp" namespace TAO_PEGTL_NAMESPACE diff --git a/packages/PEGTL/include/tao/pegtl/contrib/proto3.hpp b/packages/PEGTL/include/tao/pegtl/contrib/proto3.hpp index 535cfa1c327da830d203f2e526d5d10aea3e0dcb..7be928a145c314078befd3a141ca9968f5a33724 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/proto3.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/proto3.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2021-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -39,6 +39,9 @@ namespace TAO_PEGTL_NAMESPACE::proto3 struct dec_lit : seq< range< '1', '9' >, star< digit > > {}; struct int_lit : sor< hex_lit, oct_lit, dec_lit > {}; + struct enum_dec : plus< digit > {}; // NOTE: As of time of writing the original grammar has a bug -- it uses int_lit for enum_int, which uses dec_lit instead of enum_dec, thereby not allowing a plain 0 as enum value. + struct enum_int : sor< hex_lit, oct_lit, enum_dec > {}; + struct sign : one< '+', '-' > {}; struct exp : seq< one< 'E', 'e' >, opt< sign >, plus< digit > > {}; struct float_lit : sor< @@ -110,7 +113,7 @@ namespace TAO_PEGTL_NAMESPACE::proto3 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_field : seq< ident, sps, equ, sps, enum_int, 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 > {}; diff --git a/packages/PEGTL/include/tao/pegtl/contrib/raw_string.hpp b/packages/PEGTL/include/tao/pegtl/contrib/raw_string.hpp index e24c578bcbbe4e7cc49181af95a9b465986bd79a..e7c5a332864b7b76ffe33e1df1176f6ca8752719 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/raw_string.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/raw_string.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -115,7 +115,7 @@ namespace TAO_PEGTL_NAMESPACE typename... States > [[nodiscard]] static bool match( ParseInput& in, const std::size_t& marker_size, States&&... /*unused*/ ) { - auto m = in.template mark< M >(); + auto m = in.template auto_rewind< M >(); while( !Control< Cond >::template match< A, rewind_mode::required, Action, Control >( in, marker_size ) ) { if( in.empty() ) { @@ -143,7 +143,7 @@ namespace TAO_PEGTL_NAMESPACE typename... States > [[nodiscard]] static bool match( ParseInput& in, const std::size_t& marker_size, States&&... st ) { - auto m = in.template mark< M >(); + auto m = in.template auto_rewind< M >(); using m_t = decltype( m ); while( !Control< Cond >::template match< A, rewind_mode::required, Action, Control >( in, marker_size ) ) { diff --git a/packages/PEGTL/include/tao/pegtl/contrib/remove_first_state.hpp b/packages/PEGTL/include/tao/pegtl/contrib/remove_first_state.hpp index 74384c63973b752330946ad98703b79aeea821a0..993d0fca019afca7734c7e5603a9781557b2df8f 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/remove_first_state.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/remove_first_state.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -53,8 +53,8 @@ namespace TAO_PEGTL_NAMESPACE 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... ) ) ) + template< template< typename... > class Action, typename Frobnicator, typename ParseInput, typename State, typename... States > + static auto apply( const Frobnicator& 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... ); diff --git a/packages/PEGTL/include/tao/pegtl/contrib/remove_last_states.hpp b/packages/PEGTL/include/tao/pegtl/contrib/remove_last_states.hpp index 5a4d67ecc2bf9481cc3a81e27ce7fe8328826662..78a2fa68e06a603e9224bc5ce223e58bc6762780 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/remove_last_states.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/remove_last_states.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -85,15 +85,15 @@ namespace TAO_PEGTL_NAMESPACE 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 )... ) ) ) + template< template< typename... > class Action, typename Frobnicator, typename ParseInput, typename Tuple, std::size_t... Is > + static auto apply_impl( const Frobnicator& 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 >() ) ) ) + template< template< typename... > class Action, typename Frobnicator, typename ParseInput, typename... States > + static auto apply( const Frobnicator& 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 >() ); diff --git a/packages/PEGTL/include/tao/pegtl/contrib/rep_one_min_max.hpp b/packages/PEGTL/include/tao/pegtl/contrib/rep_one_min_max.hpp index 785e46f98004242ba1202424ce5d733b931e9055..bb9ed76cc34251bf0437e7999e5d505efb1273bc 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/rep_one_min_max.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/rep_one_min_max.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -30,8 +30,16 @@ namespace TAO_PEGTL_NAMESPACE static_assert( Min <= Max ); - template< int Eol > - static constexpr bool can_match_eol = ( C == Eol ); + [[nodiscard]] static constexpr bool test_one( const char c ) noexcept + { + static_assert( ( Min == 1 ) && ( Max == 1 ) ); + return C == c; + } + + [[nodiscard]] static constexpr bool test_any( const char c ) noexcept + { + return C == c; + } template< typename ParseInput > [[nodiscard]] static bool match( ParseInput& in ) @@ -58,8 +66,10 @@ namespace TAO_PEGTL_NAMESPACE using rule_t = rep_one_min_max; using subs_t = empty_list; - template< int Eol > - static constexpr bool can_match_eol = ( C == Eol ); + [[nodiscard]] static constexpr bool test_any( const char c ) noexcept + { + return C == c; + } template< typename ParseInput > [[nodiscard]] static bool match( ParseInput& in ) diff --git a/packages/PEGTL/include/tao/pegtl/contrib/rep_string.hpp b/packages/PEGTL/include/tao/pegtl/contrib/rep_string.hpp index b42061667f759180af7dba159877423a3f226421..5aa9e22d556a9a1cb065a54dd9f65c2bf6b8f6d2 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/rep_string.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/rep_string.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -8,6 +8,7 @@ #include <cstddef> #include "../config.hpp" + #include "../internal/string.hpp" namespace TAO_PEGTL_NAMESPACE diff --git a/packages/PEGTL/include/tao/pegtl/contrib/separated_seq.hpp b/packages/PEGTL/include/tao/pegtl/contrib/separated_seq.hpp index 26aac6ab4e5ca78977ce19ba8de23a5224a11451..f7f9dfd93cd1f9c397907bc49bde69acb95b84ee 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/separated_seq.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/separated_seq.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2021-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -6,7 +6,6 @@ #define TAO_PEGTL_CONTRIB_SEPARATED_SEQ_HPP #include "../config.hpp" - #include "../internal/seq.hpp" #include "../type_list.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/contrib/shuffle_states.hpp b/packages/PEGTL/include/tao/pegtl/contrib/shuffle_states.hpp index 8cc969048b756db43f1d7059ade41a8dd1303167..ad3d2fa7cb28f5bd90f3fd6a5691e63d04fbdf9d 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/shuffle_states.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/shuffle_states.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -137,22 +137,22 @@ namespace TAO_PEGTL_NAMESPACE 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 )... ) ) ) + template< template< typename... > class Action, typename Frobnicator, typename ParseInput, typename Tuple, std::size_t... Is > + static auto apply_impl( const Frobnicator& 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 ) >() ) ) ) + template< template< typename... > class Action, typename Frobnicator, typename ParseInput, typename... States > + static auto apply( const Frobnicator& 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 ) ) ) + template< template< typename... > class Action, typename Frobnicator, typename ParseInput, typename State > + static auto apply( const Frobnicator& 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 ); diff --git a/packages/PEGTL/include/tao/pegtl/contrib/state_control.hpp b/packages/PEGTL/include/tao/pegtl/contrib/state_control.hpp index a65a61b057b96a001777f60cd2c1227e922d7435..8041efdf81b97f6eefd9699c3369ddaa0765568c 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/state_control.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/state_control.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -7,11 +7,12 @@ #include <type_traits> -#include "shuffle_states.hpp" - #include "../config.hpp" + #include "../internal/has_unwind.hpp" +#include "shuffle_states.hpp" + namespace TAO_PEGTL_NAMESPACE { template< template< typename... > class Control > @@ -93,8 +94,8 @@ namespace TAO_PEGTL_NAMESPACE #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 ) + template< template< typename... > class Action, typename Frobnicator, typename ParseInput, typename State, typename... States > + static auto apply( const Frobnicator& 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 > ) { diff --git a/packages/PEGTL/include/tao/pegtl/contrib/to_string.hpp b/packages/PEGTL/include/tao/pegtl/contrib/to_string.hpp index 1075e897efe9512e53245ea9ace873e5fad48c31..7325dfc853bb744441abe87944acec002e213bed 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/to_string.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/to_string.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/contrib/trace.hpp b/packages/PEGTL/include/tao/pegtl/contrib/trace.hpp index 751ceb50a341b597bc8d2b266c014a505db82b19..67a8804248ae96075aacf5117bc52f2c8c5f8a3a 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/trace.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/trace.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -23,7 +23,11 @@ namespace TAO_PEGTL_NAMESPACE { - template< bool HideInternal = false, bool UseColor = true, std::size_t IndentIncrement = 2, std::size_t InitialIndent = 8 > + template< bool HideInternal = true, + bool UseColor = true, + bool PrintSourceLine = false, + std::size_t IndentIncrement = 2, + std::size_t InitialIndent = 8 > struct tracer_traits { template< typename Rule > @@ -32,6 +36,8 @@ namespace TAO_PEGTL_NAMESPACE static constexpr std::size_t initial_indent = InitialIndent; static constexpr std::size_t indent_increment = IndentIncrement; + static constexpr bool print_source_line = PrintSourceLine; + 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" : ""; @@ -64,7 +70,7 @@ namespace TAO_PEGTL_NAMESPACE m_position( in.position() ) { std::cerr << std::left; - print_position(); + print_position( in ); } tracer( const tracer& ) = delete; @@ -83,16 +89,23 @@ namespace TAO_PEGTL_NAMESPACE return TracerTraits::initial_indent + TracerTraits::indent_increment * m_stack.size(); } - void print_position() const + template< typename ParseInput > + void print_position( [[maybe_unused]] const ParseInput& in ) const { std::cerr << std::setw( indent() ) << ' ' << TracerTraits::ansi_position << "position" << TracerTraits::ansi_reset << ' ' << m_position << '\n'; + if constexpr( TracerTraits::print_source_line ) { + std::cerr << std::setw( indent() ) << ' ' << TracerTraits::ansi_position << "source" << TracerTraits::ansi_reset << ' ' << in.line_at( m_position ) << '\n'; + std::cerr << std::setw( indent() + 6 + m_position.column ) << ' ' << "^\n"; + } } - void update_position( const position& p ) + template< typename ParseInput > + void update_position( const ParseInput& in ) { + const auto p = in.position(); if( m_position != p ) { m_position = p; - print_position(); + print_position( in ); } } @@ -113,7 +126,7 @@ namespace TAO_PEGTL_NAMESPACE std::cerr << " #" << prev << ' ' << TracerTraits::ansi_hide << demangle< Rule >() << TracerTraits::ansi_reset; } std::cerr << '\n'; - update_position( in.position() ); + update_position( in ); } template< typename Rule, typename ParseInput, typename... States > @@ -126,7 +139,7 @@ namespace TAO_PEGTL_NAMESPACE std::cerr << " #" << prev << ' ' << TracerTraits::ansi_hide << demangle< Rule >() << TracerTraits::ansi_reset; } std::cerr << '\n'; - update_position( in.position() ); + update_position( in ); } template< typename Rule, typename ParseInput, typename... States > @@ -145,7 +158,7 @@ namespace TAO_PEGTL_NAMESPACE std::cerr << " #" << prev << ' ' << TracerTraits::ansi_hide << demangle< Rule >() << TracerTraits::ansi_reset; } std::cerr << '\n'; - update_position( in.position() ); + update_position( in ); } template< typename Rule, typename ParseInput, typename... States > diff --git a/packages/PEGTL/include/tao/pegtl/contrib/uint16.hpp b/packages/PEGTL/include/tao/pegtl/contrib/uint16.hpp index 1f7532861aa9c65b5a5e4570db86c0cc8f85f4a7..412686236b9de4a6aafba949d406aed47b4db0bc 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/uint16.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/uint16.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -6,6 +6,7 @@ #define TAO_PEGTL_CONTRIB_UINT16_HPP #include "../config.hpp" + #include "../internal/result_on_found.hpp" #include "../internal/rules.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/contrib/uint32.hpp b/packages/PEGTL/include/tao/pegtl/contrib/uint32.hpp index 8bd88045bfa85c69a3dab544ecfc562f5201819d..05dfa6f6c33205c8e4867956e346ee8ff8c9e6e4 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/uint32.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/uint32.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -6,6 +6,7 @@ #define TAO_PEGTL_CONTRIB_UINT32_HPP #include "../config.hpp" + #include "../internal/result_on_found.hpp" #include "../internal/rules.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/contrib/uint64.hpp b/packages/PEGTL/include/tao/pegtl/contrib/uint64.hpp index 366c9f4a6e95b7547f21d207495bdd19cb5c7a07..e1cdb864e59271daf22debf34754ba420cd343ad 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/uint64.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/uint64.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -6,6 +6,7 @@ #define TAO_PEGTL_CONTRIB_UINT64_HPP #include "../config.hpp" + #include "../internal/result_on_found.hpp" #include "../internal/rules.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/contrib/uint8.hpp b/packages/PEGTL/include/tao/pegtl/contrib/uint8.hpp index a5b325a298cea15ddac33de276364a14ae48c10b..1b0a7c5f58c84fec131210b9a46c9bddb0e4064e 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/uint8.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/uint8.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -6,6 +6,7 @@ #define TAO_PEGTL_CONTRIB_UINT8_HPP #include "../config.hpp" + #include "../internal/result_on_found.hpp" #include "../internal/rules.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/contrib/unescape.hpp b/packages/PEGTL/include/tao/pegtl/contrib/unescape.hpp index 7fb0c081ba054bce64d0d3fcd3ba3a7019f94b87..7ced90f6d81f6c4dd128d0d6e86a362fb818c84d 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/unescape.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/unescape.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -20,12 +20,12 @@ namespace TAO_PEGTL_NAMESPACE::unescape [[nodiscard]] inline bool utf8_append_utf32( std::string& string, const unsigned utf32 ) { if( utf32 <= 0x7f ) { - string += char( utf32 & 0xff ); + string += static_cast< char >( utf32 & 0xff ); return true; } if( utf32 <= 0x7ff ) { - char tmp[] = { char( ( ( utf32 & 0x7c0 ) >> 6 ) | 0xc0 ), - char( ( ( utf32 & 0x03f ) ) | 0x80 ) }; + char tmp[] = { static_cast< char >( ( ( utf32 & 0x7c0 ) >> 6 ) | 0xc0 ), + static_cast< char >( ( ( utf32 & 0x03f ) ) | 0x80 ) }; string.append( tmp, sizeof( tmp ) ); return true; } @@ -34,17 +34,17 @@ namespace TAO_PEGTL_NAMESPACE::unescape // 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 ) }; + char tmp[] = { static_cast< char >( ( ( utf32 & 0xf000 ) >> 12 ) | 0xe0 ), + static_cast< char >( ( ( utf32 & 0x0fc0 ) >> 6 ) | 0x80 ), + static_cast< 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 ) }; + char tmp[] = { static_cast< char >( ( ( utf32 & 0x1c0000 ) >> 18 ) | 0xf0 ), + static_cast< char >( ( ( utf32 & 0x03f000 ) >> 12 ) | 0x80 ), + static_cast< char >( ( ( utf32 & 0x000fc0 ) >> 6 ) | 0x80 ), + static_cast< char >( ( ( utf32 & 0x00003f ) ) | 0x80 ) }; string.append( tmp, sizeof( tmp ) ); return true; } diff --git a/packages/PEGTL/include/tao/pegtl/contrib/uri.hpp b/packages/PEGTL/include/tao/pegtl/contrib/uri.hpp index b019a7b36bb06e259cacf2016f2cddc8138a55e3..1306251507fd2691138c00277000c75feab5f5b3 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/uri.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/uri.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/contrib/utf16.hpp b/packages/PEGTL/include/tao/pegtl/contrib/utf16.hpp index 74915e16d44c3ca310e3717a894762dbe54d659b..dabac9f703adb2bfb3a2e83c19e7ed971e479400 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/utf16.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/utf16.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -6,6 +6,7 @@ #define TAO_PEGTL_CONTRIB_UTF16_HPP #include "../config.hpp" + #include "../internal/result_on_found.hpp" #include "../internal/rules.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/contrib/utf32.hpp b/packages/PEGTL/include/tao/pegtl/contrib/utf32.hpp index 1201fca885e907e8fd2011ef6d48e20248ad5662..84f3cb04bf15d0ecac736c89bdf6c0e6f8a4ab6f 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/utf32.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/utf32.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -6,6 +6,7 @@ #define TAO_PEGTL_CONTRIB_UTF32_HPP #include "../config.hpp" + #include "../internal/result_on_found.hpp" #include "../internal/rules.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/cstream_input.hpp b/packages/PEGTL/include/tao/pegtl/cstream_input.hpp index c589912261a99aeee6d9983c20be89f6a034b5d9..6e003ddb3233de7c1ae35ee92316da270022f80d 100644 --- a/packages/PEGTL/include/tao/pegtl/cstream_input.hpp +++ b/packages/PEGTL/include/tao/pegtl/cstream_input.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/demangle.hpp b/packages/PEGTL/include/tao/pegtl/demangle.hpp index 97b2606528390d15f53152cb235056ce2aa02c76..aa62100d0572a2048f858c5f71b36a6e26a20425 100644 --- a/packages/PEGTL/include/tao/pegtl/demangle.hpp +++ b/packages/PEGTL/include/tao/pegtl/demangle.hpp @@ -1,35 +1,42 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_DEMANGLE_HPP #define TAO_PEGTL_DEMANGLE_HPP -#include <ciso646> #include <string_view> #include "config.hpp" namespace TAO_PEGTL_NAMESPACE { + // ensure a consistent interface + template< typename T > + [[nodiscard]] constexpr std::string_view demangle() noexcept; + +} // namespace TAO_PEGTL_NAMESPACE + #if defined( __clang__ ) #if defined( _LIBCPP_VERSION ) - template< typename T > - [[nodiscard]] constexpr std::string_view demangle() noexcept - { - constexpr std::string_view sv = __PRETTY_FUNCTION__; - constexpr auto begin = sv.find( '=' ); - static_assert( begin != std::string_view::npos ); - return sv.substr( begin + 2, sv.size() - begin - 3 ); - } +template< typename T > +[[nodiscard]] constexpr std::string_view TAO_PEGTL_NAMESPACE::demangle() noexcept +{ + constexpr std::string_view sv = __PRETTY_FUNCTION__; + constexpr auto begin = sv.find( '=' ); + static_assert( begin != std::string_view::npos ); + return sv.substr( begin + 2, sv.size() - begin - 3 ); +} #else +namespace TAO_PEGTL_NAMESPACE::internal +{ // When using libstdc++ with clang, std::string_view::find is not constexpr :( template< char C > - constexpr const char* find( const char* p, std::size_t n ) noexcept + constexpr const char* string_view_find( const char* p, std::size_t n ) noexcept { while( n ) { if( *p == C ) { @@ -41,46 +48,44 @@ namespace TAO_PEGTL_NAMESPACE return nullptr; } - template< typename T > - [[nodiscard]] constexpr std::string_view demangle() noexcept - { - constexpr std::string_view sv = __PRETTY_FUNCTION__; - constexpr auto begin = find< '=' >( sv.data(), sv.size() ); - static_assert( begin != nullptr ); - return { begin + 2, sv.data() + sv.size() - begin - 3 }; - } +} // namespace TAO_PEGTL_NAMESPACE::internal + +template< typename T > +[[nodiscard]] constexpr std::string_view TAO_PEGTL_NAMESPACE::demangle() noexcept +{ + constexpr std::string_view sv = __PRETTY_FUNCTION__; + constexpr auto begin = internal::string_view_find< '=' >( sv.data(), sv.size() ); + static_assert( begin != nullptr ); + return { begin + 2, sv.data() + sv.size() - begin - 3 }; +} #endif #elif defined( __GNUC__ ) -#if( __GNUC__ == 7 ) +#if( __GNUC__ == 9 ) && ( __GNUC_MINOR__ < 3 ) - // GCC 7 wrongly sometimes disallows __PRETTY_FUNCTION__ in constexpr functions, - // therefore we drop the 'constexpr' and hope for the best. - template< typename T > - [[nodiscard]] std::string_view demangle() noexcept - { - const std::string_view sv = __PRETTY_FUNCTION__; - const auto begin = sv.find( '=' ); - const auto tmp = sv.substr( begin + 2 ); - const auto end = tmp.rfind( ';' ); - return tmp.substr( 0, end ); - } +#if !defined( __cpp_rtti ) +#error "RTTI support required for GCC 9.1/9.2" +#else -#elif( __GNUC__ == 9 ) && ( __GNUC_MINOR__ < 3 ) +#include <typeinfo> - // GCC 9.1 and 9.2 have a bug that leads to truncated __PRETTY_FUNCTION__ names, - // see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91155 - template< typename T > - [[nodiscard]] constexpr std::string_view demangle() noexcept - { - // fallback: requires RTTI, no demangling - return typeid( T ).name(); - } +// GCC 9.1 and 9.2 have a bug that leads to truncated __PRETTY_FUNCTION__ names, +// see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91155 +template< typename T > +[[nodiscard]] constexpr std::string_view TAO_PEGTL_NAMESPACE::demangle() noexcept +{ + // fallback: requires RTTI, no demangling + return typeid( T ).name(); +} + +#endif #else +namespace TAO_PEGTL_NAMESPACE::special +{ template< typename T > [[nodiscard]] constexpr std::string_view demangle() noexcept { @@ -93,49 +98,47 @@ namespace TAO_PEGTL_NAMESPACE return tmp.substr( 0, end ); } +} // namespace TAO_PEGTL_NAMESPACE::special + +template< typename T > +[[nodiscard]] constexpr std::string_view TAO_PEGTL_NAMESPACE::demangle() noexcept +{ + return TAO_PEGTL_NAMESPACE::special::demangle< T >(); +} + #endif #elif defined( _MSC_VER ) -#if( _MSC_VER < 1920 ) - - template< typename T > - [[nodiscard]] constexpr std::string_view demangle() noexcept - { - const std::string_view sv = __FUNCSIG__; - const auto begin = sv.find( "demangle<" ); - const auto tmp = sv.substr( begin + 9 ); - const auto end = tmp.rfind( '>' ); - return tmp.substr( 0, end ); - } +template< typename T > +[[nodiscard]] constexpr std::string_view TAO_PEGTL_NAMESPACE::demangle() noexcept +{ + // we can not add static_assert for additional safety, + // see issues #296, #301 and #308 + constexpr std::string_view sv = __FUNCSIG__; + constexpr auto begin = sv.find( "demangle<" ); + constexpr auto tmp = sv.substr( begin + 9 ); + constexpr auto end = tmp.rfind( '>' ); + return tmp.substr( 0, end ); +} #else - template< typename T > - [[nodiscard]] constexpr std::string_view demangle() noexcept - { - constexpr std::string_view sv = __FUNCSIG__; - constexpr auto begin = sv.find( "demangle<" ); - static_assert( begin != std::string_view::npos ); - constexpr auto tmp = sv.substr( begin + 9 ); - constexpr auto end = tmp.rfind( '>' ); - static_assert( end != std::string_view::npos ); - return tmp.substr( 0, end ); - } - -#endif - +#if !defined( __cpp_rtti ) +#error "RTTI support required for unknown compilers" #else - template< typename T > - [[nodiscard]] constexpr std::string_view demangle() noexcept - { - // fallback: requires RTTI, no demangling - return typeid( T ).name(); - } +#include <typeinfo> + +template< typename T > +[[nodiscard]] constexpr std::string_view TAO_PEGTL_NAMESPACE::demangle() noexcept +{ + // fallback: requires RTTI, no demangling + return typeid( T ).name(); +} #endif -} // namespace TAO_PEGTL_NAMESPACE +#endif #endif diff --git a/packages/PEGTL/include/tao/pegtl/disable_action.hpp b/packages/PEGTL/include/tao/pegtl/disable_action.hpp index 92bc2f4d3c0f5bc1c182a14b085729af580bab5f..d9ce99c149612d3f828370f79acb9372ec55fa87 100644 --- a/packages/PEGTL/include/tao/pegtl/disable_action.hpp +++ b/packages/PEGTL/include/tao/pegtl/disable_action.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/discard_input.hpp b/packages/PEGTL/include/tao/pegtl/discard_input.hpp index dec0a9af57f812850f981ad141487e01d2baf869..0cac8ecc6595c947643b856b71d87508bcbcc085 100644 --- a/packages/PEGTL/include/tao/pegtl/discard_input.hpp +++ b/packages/PEGTL/include/tao/pegtl/discard_input.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/discard_input_on_failure.hpp b/packages/PEGTL/include/tao/pegtl/discard_input_on_failure.hpp index 305038e96b4d44663d71508d932e848e35ed92aa..12cea02e1da6b3577c955f55ed487bbde7b695d1 100644 --- a/packages/PEGTL/include/tao/pegtl/discard_input_on_failure.hpp +++ b/packages/PEGTL/include/tao/pegtl/discard_input_on_failure.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/discard_input_on_success.hpp b/packages/PEGTL/include/tao/pegtl/discard_input_on_success.hpp index c5beb7d91e56bb68ea4a533e913ea36899ccd309..0ed60d8bd3827c218e7ea915f9cfbff001df3147 100644 --- a/packages/PEGTL/include/tao/pegtl/discard_input_on_success.hpp +++ b/packages/PEGTL/include/tao/pegtl/discard_input_on_success.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/enable_action.hpp b/packages/PEGTL/include/tao/pegtl/enable_action.hpp index ae0c09983afdb813ce806793beeb24cec0989140..da41b1871abad372b41345b13dd29ed6fd4bc3ef 100644 --- a/packages/PEGTL/include/tao/pegtl/enable_action.hpp +++ b/packages/PEGTL/include/tao/pegtl/enable_action.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/eol.hpp b/packages/PEGTL/include/tao/pegtl/eol.hpp index c2df140e3edf028695f3be563f4942e075d09e4b..aaae30008aef5d274a9130fd5539387273cfa649 100644 --- a/packages/PEGTL/include/tao/pegtl/eol.hpp +++ b/packages/PEGTL/include/tao/pegtl/eol.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -19,8 +19,11 @@ namespace TAO_PEGTL_NAMESPACE { inline namespace ascii { - // this is both a rule and a pseudo-namespace for eol::cr, ... - struct eol : internal::eol + // Struct eol is both a rule and a pseudo-namespace for the + // member structs cr, etc. (which are not themselves rules). + + struct eol + : internal::eol { // clang-format off struct cr : internal::cr_eol {}; diff --git a/packages/PEGTL/include/tao/pegtl/eol_pair.hpp b/packages/PEGTL/include/tao/pegtl/eol_pair.hpp deleted file mode 100644 index b139d3bdccffb9726233a52cf65108a96a628525..0000000000000000000000000000000000000000 --- a/packages/PEGTL/include/tao/pegtl/eol_pair.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) - -#ifndef TAO_PEGTL_EOL_PAIR_HPP -#define TAO_PEGTL_EOL_PAIR_HPP - -#include <cstddef> -#include <utility> - -#include "config.hpp" - -namespace TAO_PEGTL_NAMESPACE -{ - using eol_pair = std::pair< bool, std::size_t >; - -} // namespace TAO_PEGTL_NAMESPACE - -#endif diff --git a/packages/PEGTL/include/tao/pegtl/file_input.hpp b/packages/PEGTL/include/tao/pegtl/file_input.hpp index 408b89fc0e2cbfdb62342c78d111e7ca5a475017..3eb4270565e8e2a95bcfabd80e7f2902f440368b 100644 --- a/packages/PEGTL/include/tao/pegtl/file_input.hpp +++ b/packages/PEGTL/include/tao/pegtl/file_input.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/internal/action.hpp b/packages/PEGTL/include/tao/pegtl/internal/action.hpp index 8068241e87b14c3a72419038c30b29fd7da7f820..b1c3b2d1d9daa12b5ee64b64c97e0900875ec960 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/action.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/action.hpp @@ -1,17 +1,16 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_ACTION_HPP #define TAO_PEGTL_INTERNAL_ACTION_HPP -#include "../config.hpp" - #include "enable_control.hpp" #include "seq.hpp" #include "success.hpp" #include "../apply_mode.hpp" +#include "../config.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/internal/action_input.hpp b/packages/PEGTL/include/tao/pegtl/internal/action_input.hpp index fa622fa326cf0e87d9b9dc3ce91dda531b753070..b371736845fcf3efb52a98851443e0312e001b26 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/action_input.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/action_input.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +10,7 @@ #include <string> #include <string_view> -#include "iterator.hpp" +#include "frobnicator.hpp" #include "../config.hpp" #include "../position.hpp" @@ -22,9 +22,9 @@ namespace TAO_PEGTL_NAMESPACE::internal { public: using input_t = ParseInput; - using iterator_t = typename ParseInput::iterator_t; + using frobnicator_t = typename ParseInput::frobnicator_t; - action_input( const iterator_t& in_begin, const ParseInput& in_input ) noexcept + action_input( const frobnicator_t& in_begin, const ParseInput& in_input ) noexcept : m_begin( in_begin ), m_input( in_input ) {} @@ -37,7 +37,7 @@ namespace TAO_PEGTL_NAMESPACE::internal action_input& operator=( const action_input& ) = delete; action_input& operator=( action_input&& ) = delete; - [[nodiscard]] const iterator_t& iterator() const noexcept + [[nodiscard]] const frobnicator_t& frobnicator() const noexcept { return m_begin; } @@ -49,11 +49,11 @@ namespace TAO_PEGTL_NAMESPACE::internal [[nodiscard]] const char* begin() const noexcept { - if constexpr( std::is_same_v< iterator_t, const char* > ) { - return iterator(); + if constexpr( std::is_same_v< frobnicator_t, const char* > ) { + return frobnicator(); } else { - return iterator().data; + return frobnicator().data; } } @@ -94,11 +94,11 @@ namespace TAO_PEGTL_NAMESPACE::internal [[nodiscard]] TAO_PEGTL_NAMESPACE::position position() const { - return input().position( iterator() ); // NOTE: Not efficient with lazy inputs. + return input().position( frobnicator() ); // NOTE: Not efficient with lazy inputs. } protected: - const iterator_t m_begin; + const frobnicator_t m_begin; const ParseInput& m_input; }; diff --git a/packages/PEGTL/include/tao/pegtl/internal/any.hpp b/packages/PEGTL/include/tao/pegtl/internal/any.hpp index 9e710c5f876d154e3f78f4f631b6da419f9ed9b2..bc742d4d9bb63f1291b4c7fc6df3b315c91970e0 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/any.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/any.hpp @@ -1,15 +1,14 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_ANY_HPP #define TAO_PEGTL_INTERNAL_ANY_HPP -#include "../config.hpp" - #include "enable_control.hpp" #include "peek_char.hpp" +#include "../config.hpp" #include "../type_list.hpp" namespace TAO_PEGTL_NAMESPACE::internal @@ -26,7 +25,12 @@ namespace TAO_PEGTL_NAMESPACE::internal using rule_t = any; using subs_t = empty_list; - [[nodiscard]] static bool test( const char /*unused*/ ) noexcept + [[nodiscard]] static bool test_one( const char /*unused*/ ) noexcept + { + return true; + } + + [[nodiscard]] static bool test_any( const char /*unused*/ ) noexcept { return true; } @@ -51,10 +55,12 @@ namespace TAO_PEGTL_NAMESPACE::internal using rule_t = any; using subs_t = empty_list; - template< int Eol > - static constexpr bool can_match_eol = true; + [[nodiscard]] static bool test_one( const data_t /*unused*/ ) noexcept + { + return true; + } - [[nodiscard]] static bool test( const data_t /*unused*/ ) noexcept + [[nodiscard]] static bool test_any( const data_t /*unused*/ ) noexcept { return true; } diff --git a/packages/PEGTL/include/tao/pegtl/internal/apply.hpp b/packages/PEGTL/include/tao/pegtl/internal/apply.hpp index 97a342b86a45a096fa90a50af91113c698a9a39a..e83ba91141a4b6c8701ff0c7d743ae3a49186bf6 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/apply.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/apply.hpp @@ -1,16 +1,15 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_APPLY_HPP #define TAO_PEGTL_INTERNAL_APPLY_HPP -#include "../config.hpp" - #include "apply_single.hpp" #include "enable_control.hpp" #include "../apply_mode.hpp" +#include "../config.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" @@ -34,7 +33,7 @@ namespace TAO_PEGTL_NAMESPACE::internal { if constexpr( ( A == apply_mode::action ) && ( sizeof...( Actions ) > 0 ) ) { using action_t = typename ParseInput::action_t; - const action_t i2( in.iterator(), in ); // No data -- range is from begin to begin. + const action_t i2( in.frobnicator(), in ); // No data -- range is from begin to begin. return ( apply_single< Actions >::match( i2, st... ) && ... ); } else { diff --git a/packages/PEGTL/include/tao/pegtl/internal/apply0.hpp b/packages/PEGTL/include/tao/pegtl/internal/apply0.hpp index 2710de8e8ab89eea8b357b7de28f4e0dcd8b20d4..1d05592553a273f3858f057da34fe3387102d53e 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/apply0.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/apply0.hpp @@ -1,16 +1,15 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_APPLY0_HPP #define TAO_PEGTL_INTERNAL_APPLY0_HPP -#include "../config.hpp" - #include "apply0_single.hpp" #include "enable_control.hpp" #include "../apply_mode.hpp" +#include "../config.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/internal/apply0_single.hpp b/packages/PEGTL/include/tao/pegtl/internal/apply0_single.hpp index 167031924635e65c26d8a67093556fc4e33f67b5..2ecf4edb3cefee047f7f21d1a83ff1db9ac18c28 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/apply0_single.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/apply0_single.hpp @@ -1,14 +1,14 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_APPLY0_SINGLE_HPP #define TAO_PEGTL_INTERNAL_APPLY0_SINGLE_HPP -#include "../config.hpp" - #include <type_traits> +#include "../config.hpp" + namespace TAO_PEGTL_NAMESPACE::internal { template< typename Action > diff --git a/packages/PEGTL/include/tao/pegtl/internal/apply_single.hpp b/packages/PEGTL/include/tao/pegtl/internal/apply_single.hpp index 728ad4772e6d85a23f9f3d47bdde272543472b45..44c63059236f84e12a9693cd56c489a38a3b2405 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/apply_single.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/apply_single.hpp @@ -1,14 +1,14 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_APPLY_SINGLE_HPP #define TAO_PEGTL_INTERNAL_APPLY_SINGLE_HPP -#include "../config.hpp" - #include <type_traits> +#include "../config.hpp" + namespace TAO_PEGTL_NAMESPACE::internal { template< typename Action > diff --git a/packages/PEGTL/include/tao/pegtl/internal/at.hpp b/packages/PEGTL/include/tao/pegtl/internal/at.hpp index 117b5a429d943d5c224e4afcb3254c266bb600a5..a28ba39919adb60fe621af974867bc54cb56f2a0 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/at.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/at.hpp @@ -1,17 +1,16 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_AT_HPP #define TAO_PEGTL_INTERNAL_AT_HPP -#include "../config.hpp" - #include "enable_control.hpp" #include "seq.hpp" #include "success.hpp" #include "../apply_mode.hpp" +#include "../config.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" @@ -43,7 +42,7 @@ namespace TAO_PEGTL_NAMESPACE::internal typename... States > [[nodiscard]] static bool match( ParseInput& in, States&&... st ) { - const auto m = in.template mark< rewind_mode::required >(); + const auto m = in.template auto_rewind< rewind_mode::required >(); return Control< Rule >::template match< apply_mode::nothing, rewind_mode::active, Action, Control >( in, st... ); } }; diff --git a/packages/PEGTL/include/tao/pegtl/internal/bof.hpp b/packages/PEGTL/include/tao/pegtl/internal/bof.hpp index 7038d953f77dd727003bcd7d3e526f9d74b0e9e8..4bf5751ec04f193c9d89cd6466015e534703184e 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/bof.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/bof.hpp @@ -1,14 +1,13 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_BOF_HPP #define TAO_PEGTL_INTERNAL_BOF_HPP -#include "../config.hpp" - #include "enable_control.hpp" +#include "../config.hpp" #include "../type_list.hpp" namespace TAO_PEGTL_NAMESPACE::internal diff --git a/packages/PEGTL/include/tao/pegtl/internal/bol.hpp b/packages/PEGTL/include/tao/pegtl/internal/bol.hpp index 759a8bd01cf91665908301f5a25ad4365ce1c094..32ed3be87d0069b922d515995fdb86f567e1f95b 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/bol.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/bol.hpp @@ -1,15 +1,15 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_BOL_HPP #define TAO_PEGTL_INTERNAL_BOL_HPP +#include "enable_control.hpp" + #include "../config.hpp" #include "../type_list.hpp" -#include "enable_control.hpp" - namespace TAO_PEGTL_NAMESPACE::internal { struct bol diff --git a/packages/PEGTL/include/tao/pegtl/internal/bump.hpp b/packages/PEGTL/include/tao/pegtl/internal/bump.hpp index 1b305f3a2f65187c05c38f16c662e81cec364d8d..5ec599124b8c2211eae0d121238ce90ee9c48469 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/bump.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/bump.hpp @@ -1,17 +1,17 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_BUMP_HPP #define TAO_PEGTL_INTERNAL_BUMP_HPP -#include "../config.hpp" +#include "frobnicator.hpp" -#include "iterator.hpp" +#include "../config.hpp" namespace TAO_PEGTL_NAMESPACE::internal { - inline void bump( iterator& iter, const std::size_t count, const int ch ) noexcept + inline void bump( frobnicator& iter, const std::size_t count, const int ch ) noexcept { for( std::size_t i = 0; i < count; ++i ) { if( iter.data[ i ] == ch ) { @@ -26,14 +26,14 @@ namespace TAO_PEGTL_NAMESPACE::internal iter.data += count; } - inline void bump_in_this_line( iterator& iter, const std::size_t count ) noexcept + inline void bump_in_this_line( frobnicator& iter, const std::size_t count ) noexcept { iter.data += count; iter.byte += count; iter.column += count; } - inline void bump_to_next_line( iterator& iter, const std::size_t count ) noexcept + inline void bump_to_next_line( frobnicator& iter, const std::size_t count ) noexcept { ++iter.line; iter.byte += count; diff --git a/packages/PEGTL/include/tao/pegtl/internal/bump_help.hpp b/packages/PEGTL/include/tao/pegtl/internal/bump_help.hpp index f40c6171cb97390956532ea7ae67b92decb3241b..d39df08805fcce063a0e9d5610b842144be4a3c2 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/bump_help.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/bump_help.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -14,7 +14,7 @@ namespace TAO_PEGTL_NAMESPACE::internal template< typename Rule, typename ParseInput > void bump_help( ParseInput& in, const std::size_t count ) { - if constexpr( Rule::template can_match_eol< ParseInput::eol_t::ch > ) { + if constexpr( Rule::test_any( ParseInput::eol_t::ch ) ) { in.bump( count ); } else { diff --git a/packages/PEGTL/include/tao/pegtl/internal/bytes.hpp b/packages/PEGTL/include/tao/pegtl/internal/bytes.hpp index 2012f05c74c340ec6084d0855aae830d53b49a9f..b192d4d8aba2187b3f917ea1914fcd5cbad3d6a1 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/bytes.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/bytes.hpp @@ -1,15 +1,14 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_BYTES_HPP #define TAO_PEGTL_INTERNAL_BYTES_HPP -#include "../config.hpp" - #include "enable_control.hpp" #include "success.hpp" +#include "../config.hpp" #include "../type_list.hpp" namespace TAO_PEGTL_NAMESPACE::internal diff --git a/packages/PEGTL/include/tao/pegtl/internal/control.hpp b/packages/PEGTL/include/tao/pegtl/internal/control.hpp index a202f5d43922327f9ac482f42a443ccb3fe776aa..e0b9aa54cb885204188ecb9f50651e2b05bb3fd7 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/control.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/control.hpp @@ -1,17 +1,16 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_CONTROL_HPP #define TAO_PEGTL_INTERNAL_CONTROL_HPP -#include "../config.hpp" - #include "enable_control.hpp" #include "seq.hpp" #include "success.hpp" #include "../apply_mode.hpp" +#include "../config.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/internal/cr_crlf_eol.hpp b/packages/PEGTL/include/tao/pegtl/internal/cr_crlf_eol.hpp index cf2e72ec8a74b11f8b89526b1d861233b4b6b137..00723690b87c77b7888f5c931cf33f627ee92443 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/cr_crlf_eol.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/cr_crlf_eol.hpp @@ -1,12 +1,13 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_CR_CRLF_EOL_HPP #define TAO_PEGTL_INTERNAL_CR_CRLF_EOL_HPP +#include "data_and_size.hpp" + #include "../config.hpp" -#include "../eol_pair.hpp" namespace TAO_PEGTL_NAMESPACE::internal { @@ -15,13 +16,13 @@ namespace TAO_PEGTL_NAMESPACE::internal static constexpr int ch = '\r'; template< typename ParseInput > - [[nodiscard]] static eol_pair match( ParseInput& in ) noexcept( noexcept( in.size( 2 ) ) ) + [[nodiscard]] static bool_and_size eol_match( ParseInput& in ) noexcept( noexcept( in.size( 2 ) ) ) { - eol_pair p = { false, in.size( 2 ) }; - if( p.second ) { + bool_and_size p = { false, in.size( 2 ) }; + if( p.size > 0 ) { if( in.peek_char() == '\r' ) { - in.bump_to_next_line( 1 + ( ( p.second > 1 ) && ( in.peek_char( 1 ) == '\n' ) ) ); - p.first = true; + in.bump_to_next_line( ( p.size = 1 + ( ( p.size > 1 ) && ( in.peek_char( 1 ) == '\n' ) ) ) ); + p.data = true; } } return p; diff --git a/packages/PEGTL/include/tao/pegtl/internal/cr_eol.hpp b/packages/PEGTL/include/tao/pegtl/internal/cr_eol.hpp index 5d1a61951134c91904c87bb09d3cfbd9925872f5..0c42ba00638dd93bbc6c59a918d914aff9ae46e4 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/cr_eol.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/cr_eol.hpp @@ -1,12 +1,13 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_CR_EOL_HPP #define TAO_PEGTL_INTERNAL_CR_EOL_HPP +#include "data_and_size.hpp" + #include "../config.hpp" -#include "../eol_pair.hpp" namespace TAO_PEGTL_NAMESPACE::internal { @@ -15,13 +16,13 @@ namespace TAO_PEGTL_NAMESPACE::internal static constexpr int ch = '\r'; template< typename ParseInput > - [[nodiscard]] static eol_pair match( ParseInput& in ) noexcept( noexcept( in.size( 1 ) ) ) + [[nodiscard]] static bool_and_size eol_match( ParseInput& in ) noexcept( noexcept( in.size( 1 ) ) ) { - eol_pair p = { false, in.size( 1 ) }; - if( p.second ) { + bool_and_size p = { false, in.size( 1 ) }; + if( p.size > 0 ) { if( in.peek_char() == '\r' ) { in.bump_to_next_line(); - p.first = true; + p.data = true; } } return p; diff --git a/packages/PEGTL/include/tao/pegtl/internal/crlf_eol.hpp b/packages/PEGTL/include/tao/pegtl/internal/crlf_eol.hpp index f419a6f483ec64097884988a33ebd04240d14c0c..c8ea1aa9c0a15ec46b4ac5578bdc2b5b0138f05b 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/crlf_eol.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/crlf_eol.hpp @@ -1,12 +1,13 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_CRLF_EOL_HPP #define TAO_PEGTL_INTERNAL_CRLF_EOL_HPP +#include "data_and_size.hpp" + #include "../config.hpp" -#include "../eol_pair.hpp" namespace TAO_PEGTL_NAMESPACE::internal { @@ -15,13 +16,13 @@ namespace TAO_PEGTL_NAMESPACE::internal static constexpr int ch = '\n'; template< typename ParseInput > - [[nodiscard]] static eol_pair match( ParseInput& in ) noexcept( noexcept( in.size( 2 ) ) ) + [[nodiscard]] static bool_and_size eol_match( ParseInput& in ) noexcept( noexcept( in.size( 2 ) ) ) { - eol_pair p = { false, in.size( 2 ) }; - if( p.second > 1 ) { + bool_and_size p = { false, in.size( 2 ) }; + if( p.size > 1 ) { if( ( in.peek_char() == '\r' ) && ( in.peek_char( 1 ) == '\n' ) ) { in.bump_to_next_line( 2 ); - p.first = true; + p.data = true; } } return p; diff --git a/packages/PEGTL/include/tao/pegtl/internal/cstream_reader.hpp b/packages/PEGTL/include/tao/pegtl/internal/cstream_reader.hpp index 0dc630539a2d9a0b066986635627a29197b827d1..ace1a07bba5dcf1ca6d5c8103ed8f28839434353 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/cstream_reader.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/cstream_reader.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/internal/cstring_reader.hpp b/packages/PEGTL/include/tao/pegtl/internal/cstring_reader.hpp index 4c3b10e7496daccf5c75781f3b76f1c3f52b1905..4a680cd921e72707e311eab87fcdb8f7b87ec04d 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/cstring_reader.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/cstring_reader.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/internal/input_pair.hpp b/packages/PEGTL/include/tao/pegtl/internal/data_and_size.hpp similarity index 55% rename from packages/PEGTL/include/tao/pegtl/internal/input_pair.hpp rename to packages/PEGTL/include/tao/pegtl/internal/data_and_size.hpp index 423375c23f311ca3269a725280b8204b0a2484ac..ee1cdfb6411e6cf5298cc89d3e3cd73f1f2c2760 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/input_pair.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/data_and_size.hpp @@ -1,30 +1,32 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) -#ifndef TAO_PEGTL_INTERNAL_INPUT_PAIR_HPP -#define TAO_PEGTL_INTERNAL_INPUT_PAIR_HPP +#ifndef TAO_PEGTL_INTERNAL_DATA_AND_SIZE_HPP +#define TAO_PEGTL_INTERNAL_DATA_AND_SIZE_HPP -#include <cstdint> +#include <cstddef> #include "../config.hpp" namespace TAO_PEGTL_NAMESPACE::internal { template< typename Data > - struct input_pair + struct data_and_size { Data data; - std::uint8_t size; + std::size_t size; using data_t = Data; - explicit operator bool() const noexcept + [[nodiscard]] explicit operator bool() const noexcept { return size > 0; } }; + using bool_and_size = data_and_size< bool >; + } // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/dependent_false.hpp b/packages/PEGTL/include/tao/pegtl/internal/dependent_false.hpp index a5cc470a3a6cdb78b7f8f08d15ff39de33fbfa68..a96e5bcb24ff48eb9d43f10597700046dfb0dbb6 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/dependent_false.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/dependent_false.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/internal/disable.hpp b/packages/PEGTL/include/tao/pegtl/internal/disable.hpp index 76bdc5a8e1c0cbb0c6903c8bf25dc830856bd24c..5c35ee264939c7967d1866236a14416edfeb505e 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/disable.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/disable.hpp @@ -1,17 +1,16 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_DISABLE_HPP #define TAO_PEGTL_INTERNAL_DISABLE_HPP -#include "../config.hpp" - #include "enable_control.hpp" #include "seq.hpp" #include "success.hpp" #include "../apply_mode.hpp" +#include "../config.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/internal/discard.hpp b/packages/PEGTL/include/tao/pegtl/internal/discard.hpp index bea7aa3f2dace46471fcc4be7e683f7c22db1c36..fb609248e2d90fef8e1effa9633887d23a7210c0 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/discard.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/discard.hpp @@ -1,14 +1,13 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_DISCARD_HPP #define TAO_PEGTL_INTERNAL_DISCARD_HPP -#include "../config.hpp" - #include "enable_control.hpp" +#include "../config.hpp" #include "../type_list.hpp" namespace TAO_PEGTL_NAMESPACE::internal diff --git a/packages/PEGTL/include/tao/pegtl/internal/enable.hpp b/packages/PEGTL/include/tao/pegtl/internal/enable.hpp index cb4fbe9dbc7a4db4bf9729b4a7bc3d93c8054379..cf95b5bef044518f7359ccc19881dbe4532e1847 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/enable.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/enable.hpp @@ -1,17 +1,16 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_ENABLE_HPP #define TAO_PEGTL_INTERNAL_ENABLE_HPP -#include "../config.hpp" - #include "enable_control.hpp" #include "seq.hpp" #include "success.hpp" #include "../apply_mode.hpp" +#include "../config.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/internal/enable_control.hpp b/packages/PEGTL/include/tao/pegtl/internal/enable_control.hpp index 4fe5ae199cbbc1fe5d7950d4250cf7066763b555..9650594b22030edee18bba9747eac8b35e38e3f8 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/enable_control.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/enable_control.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/internal/eof.hpp b/packages/PEGTL/include/tao/pegtl/internal/eof.hpp index e227e0474fd0f19b40a0b070d599c77422972ee4..50b876739f6351e120b1f5d859120c8fc4abcb9b 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/eof.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/eof.hpp @@ -1,14 +1,13 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_EOF_HPP #define TAO_PEGTL_INTERNAL_EOF_HPP -#include "../config.hpp" - #include "enable_control.hpp" +#include "../config.hpp" #include "../type_list.hpp" namespace TAO_PEGTL_NAMESPACE::internal diff --git a/packages/PEGTL/include/tao/pegtl/internal/eol.hpp b/packages/PEGTL/include/tao/pegtl/internal/eol.hpp index 6f8633afc96504de82d797af0aaf5563f02698c5..7d65428517d3e43e2327928f2551a8ff919ac0c6 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/eol.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/eol.hpp @@ -1,14 +1,13 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_EOL_HPP #define TAO_PEGTL_INTERNAL_EOL_HPP -#include "../config.hpp" - #include "enable_control.hpp" +#include "../config.hpp" #include "../type_list.hpp" namespace TAO_PEGTL_NAMESPACE::internal @@ -19,9 +18,9 @@ namespace TAO_PEGTL_NAMESPACE::internal using subs_t = empty_list; template< typename ParseInput > - [[nodiscard]] static bool match( ParseInput& in ) noexcept( noexcept( ParseInput::eol_t::match( in ) ) ) + [[nodiscard]] static bool match( ParseInput& in ) noexcept( noexcept( ParseInput::eol_t::eol_match( in ) ) ) { - return ParseInput::eol_t::match( in ).first; + return ParseInput::eol_t::eol_match( in ).data; } }; diff --git a/packages/PEGTL/include/tao/pegtl/internal/eolf.hpp b/packages/PEGTL/include/tao/pegtl/internal/eolf.hpp index 101605b9e50d30e875722749e8c76ec1fee9203b..01fe64ff0e60e9f05e7076ed1eda22716f922b67 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/eolf.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/eolf.hpp @@ -1,14 +1,13 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_EOLF_HPP #define TAO_PEGTL_INTERNAL_EOLF_HPP -#include "../config.hpp" - #include "enable_control.hpp" +#include "../config.hpp" #include "../type_list.hpp" namespace TAO_PEGTL_NAMESPACE::internal @@ -19,10 +18,10 @@ namespace TAO_PEGTL_NAMESPACE::internal using subs_t = empty_list; template< typename ParseInput > - [[nodiscard]] static bool match( ParseInput& in ) noexcept( noexcept( ParseInput::eol_t::match( in ) ) ) + [[nodiscard]] static bool match( ParseInput& in ) noexcept( noexcept( ParseInput::eol_t::eol_match( in ) ) ) { - const auto p = ParseInput::eol_t::match( in ); - return p.first || ( !p.second ); + const auto p = ParseInput::eol_t::eol_match( in ); + return p.data || ( p.size == 0 ); } }; diff --git a/packages/PEGTL/include/tao/pegtl/internal/everything.hpp b/packages/PEGTL/include/tao/pegtl/internal/everything.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b3e9dd9605281a26f289fb6fd508f190d39896ad --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/internal/everything.hpp @@ -0,0 +1,34 @@ +// Copyright (c) 2022-2023 Dr. Colin Hirsch and Daniel Frey +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) + +#ifndef TAO_PEGTL_INTERNAL_EVERYTHING_HPP +#define TAO_PEGTL_INTERNAL_EVERYTHING_HPP + +#include "enable_control.hpp" + +#include "../config.hpp" +#include "../type_list.hpp" + +namespace TAO_PEGTL_NAMESPACE::internal +{ + template< typename Size > + struct everything + { + using rule_t = everything; + using subs_t = empty_list; + + template< typename ParseInput > + [[nodiscard]] static bool match( ParseInput& in ) noexcept( noexcept( in.size( 0 ) ) ) + { + in.bump( in.size( Size( -1 ) ) ); + return true; + } + }; + + template< typename Size > + inline constexpr bool enable_control< everything< Size > > = false; + +} // namespace TAO_PEGTL_NAMESPACE::internal + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/failure.hpp b/packages/PEGTL/include/tao/pegtl/internal/failure.hpp index 8f14322b8167f6466dd51a456f289a0c352b8a1a..d4cc8e4bbf3fec94f168045f8acf716df70c4667 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/failure.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/failure.hpp @@ -1,14 +1,13 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_FAILURE_HPP #define TAO_PEGTL_INTERNAL_FAILURE_HPP -#include "../config.hpp" - #include "enable_control.hpp" +#include "../config.hpp" #include "../type_list.hpp" namespace TAO_PEGTL_NAMESPACE::internal diff --git a/packages/PEGTL/include/tao/pegtl/internal/filesystem.hpp b/packages/PEGTL/include/tao/pegtl/internal/filesystem.hpp index fdb5e2f1013cf8af8dd337724a6a33690d512ed5..311c74577466be60f5e9379bbe8f255ea70c307b 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/filesystem.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/filesystem.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/internal/iterator.hpp b/packages/PEGTL/include/tao/pegtl/internal/frobnicator.hpp similarity index 51% rename from packages/PEGTL/include/tao/pegtl/internal/iterator.hpp rename to packages/PEGTL/include/tao/pegtl/internal/frobnicator.hpp index 96099cab899619a0cab5815caa8a79aff3e4128d..d846d6fd7b504a99163e74ab0d620ae2fa6dc9bf 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/iterator.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/frobnicator.hpp @@ -1,9 +1,9 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) -#ifndef TAO_PEGTL_INTERNAL_ITERATOR_HPP -#define TAO_PEGTL_INTERNAL_ITERATOR_HPP +#ifndef TAO_PEGTL_INTERNAL_FROBNICATOR_HPP +#define TAO_PEGTL_INTERNAL_FROBNICATOR_HPP #include <cassert> #include <cstdlib> @@ -12,15 +12,15 @@ namespace TAO_PEGTL_NAMESPACE::internal { - struct iterator + struct frobnicator { - iterator() = default; + frobnicator() = default; - explicit iterator( const char* in_data ) noexcept + explicit frobnicator( const char* in_data ) noexcept : data( in_data ) {} - iterator( const char* in_data, const std::size_t in_byte, const std::size_t in_line, const std::size_t in_column ) noexcept + frobnicator( const char* in_data, const std::size_t in_byte, const std::size_t in_line, const std::size_t in_column ) noexcept : data( in_data ), byte( in_byte ), line( in_line ), @@ -30,13 +30,13 @@ namespace TAO_PEGTL_NAMESPACE::internal assert( in_column != 0 ); } - iterator( const iterator& ) = default; - iterator( iterator&& ) = default; + frobnicator( const frobnicator& ) = default; + frobnicator( frobnicator&& ) = default; - ~iterator() = default; + ~frobnicator() = default; - iterator& operator=( const iterator& ) = default; - iterator& operator=( iterator&& ) = default; + frobnicator& operator=( const frobnicator& ) = default; + frobnicator& operator=( frobnicator&& ) = default; const char* data = nullptr; diff --git a/packages/PEGTL/include/tao/pegtl/internal/has_apply.hpp b/packages/PEGTL/include/tao/pegtl/internal/has_apply.hpp index 5b746ebccb65a25f284c471d9c20445a3da7ff91..4610981ffdb70ac2107e84863670ff8e0fbd67e7 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/has_apply.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/has_apply.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/internal/has_apply0.hpp b/packages/PEGTL/include/tao/pegtl/internal/has_apply0.hpp index cb14882ac98895a1ebf86f7743b1b1624f4b42ce..2763270387ca2604af00604b657c6469a180d785 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/has_apply0.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/has_apply0.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/internal/has_error_message.hpp b/packages/PEGTL/include/tao/pegtl/internal/has_error_message.hpp new file mode 100644 index 0000000000000000000000000000000000000000..050ba54479a77aa4be8efb994c4b1e297575412f --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/internal/has_error_message.hpp @@ -0,0 +1,22 @@ +// Copyright (c) 2021-2023 Dr. Colin Hirsch and Daniel Frey +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) + +#ifndef TAO_PEGTL_INTERNAL_HAS_ERROR_MESSAGE_HPP +#define TAO_PEGTL_INTERNAL_HAS_ERROR_MESSAGE_HPP + +#include <type_traits> + +#include "../config.hpp" + +namespace TAO_PEGTL_NAMESPACE::internal +{ + template< typename Rule, typename = const char* > + inline constexpr bool has_error_message = false; + + template< typename Rule > + inline constexpr bool has_error_message< Rule, std::decay_t< decltype( Rule::error_message ) > > = true; + +} // namespace TAO_PEGTL_NAMESPACE::internal + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/has_match.hpp b/packages/PEGTL/include/tao/pegtl/internal/has_match.hpp index ab842587437d7e32e36ab6dfabb64fad61e2dbae..dd9a0d91a7180b52dff8cda03b934b424c2186fd 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/has_match.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/has_match.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/internal/has_unwind.hpp b/packages/PEGTL/include/tao/pegtl/internal/has_unwind.hpp index 8714d93725868dfef1a148c6c6449a8841b26397..6054be151856e16cd67890d56d44eba70d13f983 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/has_unwind.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/has_unwind.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/internal/identifier.hpp b/packages/PEGTL/include/tao/pegtl/internal/identifier.hpp index fc78c220b993192dc47bc9375e933fd3d5ef374c..6dc90a6fc3cbcd216ab536116275997045621542 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/identifier.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/identifier.hpp @@ -1,17 +1,17 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_IDENTIFIER_HPP #define TAO_PEGTL_INTERNAL_IDENTIFIER_HPP -#include "../config.hpp" - #include "peek_char.hpp" #include "ranges.hpp" #include "seq.hpp" #include "star.hpp" +#include "../config.hpp" + namespace TAO_PEGTL_NAMESPACE::internal { using identifier_first = ranges< peek_char, 'a', 'z', 'A', 'Z', '_' >; diff --git a/packages/PEGTL/include/tao/pegtl/internal/if_apply.hpp b/packages/PEGTL/include/tao/pegtl/internal/if_apply.hpp index 797be335928f20dc3bb16772ca59c45f9e1af215..7ce7c48550481155e33b10f53ef93deb1942ee78 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/if_apply.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/if_apply.hpp @@ -1,16 +1,15 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_IF_APPLY_HPP #define TAO_PEGTL_INTERNAL_IF_APPLY_HPP -#include "../config.hpp" - #include "apply_single.hpp" #include "enable_control.hpp" #include "../apply_mode.hpp" +#include "../config.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" @@ -34,9 +33,9 @@ namespace TAO_PEGTL_NAMESPACE::internal { if constexpr( ( A == apply_mode::action ) && ( sizeof...( Actions ) != 0 ) ) { using action_t = typename ParseInput::action_t; - auto m = in.template mark< rewind_mode::required >(); + auto m = in.template auto_rewind< rewind_mode::required >(); if( Control< Rule >::template match< apply_mode::action, rewind_mode::active, Action, Control >( in, st... ) ) { - const action_t i2( m.iterator(), in ); + const action_t i2( m.frobnicator(), in ); return m( ( apply_single< Actions >::match( i2, st... ) && ... ) ); } return false; diff --git a/packages/PEGTL/include/tao/pegtl/internal/if_must.hpp b/packages/PEGTL/include/tao/pegtl/internal/if_must.hpp index 9f5e0bacc452056815610a0cce362aaf22fb2aa4..a0940c073eee970965bbf681f7c54f5f0fa25158 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/if_must.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/if_must.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -9,12 +9,11 @@ #error "Exception support required for tao/pegtl/internal/if_must.hpp" #else -#include "../config.hpp" - #include "enable_control.hpp" #include "must.hpp" #include "../apply_mode.hpp" +#include "../config.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/internal/if_must_else.hpp b/packages/PEGTL/include/tao/pegtl/internal/if_must_else.hpp index 51ad934824b5a48cb010fc909903c3691e3f05ea..d08fdd9f1a0eab9165afa3f63bbddc74a2fdc7ce 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/if_must_else.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/if_must_else.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -9,12 +9,10 @@ #error "Exception support required for tao/pegtl/internal/if_must_else.hpp" #else -#include "../config.hpp" - #include "if_then_else.hpp" #include "must.hpp" -#include "../type_list.hpp" +#include "../config.hpp" namespace TAO_PEGTL_NAMESPACE::internal { diff --git a/packages/PEGTL/include/tao/pegtl/internal/if_then_else.hpp b/packages/PEGTL/include/tao/pegtl/internal/if_then_else.hpp index dfe62ceb957f1943102f0837f4742fb64a3afa0a..95125b995e0ba5e16da259baddda30f09430f668 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/if_then_else.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/if_then_else.hpp @@ -1,18 +1,17 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_IF_THEN_ELSE_HPP #define TAO_PEGTL_INTERNAL_IF_THEN_ELSE_HPP -#include "../config.hpp" - #include "enable_control.hpp" #include "not_at.hpp" #include "seq.hpp" #include "sor.hpp" #include "../apply_mode.hpp" +#include "../config.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" @@ -34,7 +33,7 @@ namespace TAO_PEGTL_NAMESPACE::internal typename... States > [[nodiscard]] static bool match( ParseInput& in, States&&... st ) { - auto m = in.template mark< M >(); + auto m = in.template auto_rewind< M >(); using m_t = decltype( m ); if( Control< Cond >::template match< A, rewind_mode::required, Action, Control >( in, st... ) ) { diff --git a/packages/PEGTL/include/tao/pegtl/internal/istream_reader.hpp b/packages/PEGTL/include/tao/pegtl/internal/istream_reader.hpp index 4b67437194f2e69f73ab6762e58a5ffb941c9c26..8c4356e7b5e446b772d113c0cdc387b57c0b12fa 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/istream_reader.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/istream_reader.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -26,10 +26,10 @@ namespace TAO_PEGTL_NAMESPACE::internal [[nodiscard]] std::size_t operator()( char* buffer, const std::size_t length ) { - m_istream.read( buffer, std::streamsize( length ) ); + m_istream.read( buffer, static_cast< std::streamsize >( length ) ); if( const auto r = m_istream.gcount() ) { - return std::size_t( r ); + return static_cast< std::size_t >( r ); } if( m_istream.eof() ) { return 0; diff --git a/packages/PEGTL/include/tao/pegtl/internal/istring.hpp b/packages/PEGTL/include/tao/pegtl/internal/istring.hpp index 5969c0672f8e2075f691daa0328fcd359cccbf04..3fafca2e950d26e4fed25284ab2f500021d5c01f 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/istring.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/istring.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -7,14 +7,13 @@ #include <type_traits> -#include "../config.hpp" - #include "bump_help.hpp" #include "enable_control.hpp" #include "one.hpp" #include "result_on_found.hpp" #include "success.hpp" +#include "../config.hpp" #include "../type_list.hpp" namespace TAO_PEGTL_NAMESPACE::internal @@ -58,8 +57,16 @@ namespace TAO_PEGTL_NAMESPACE::internal using rule_t = istring; using subs_t = empty_list; - template< int Eol > - static constexpr bool can_match_eol = one< result_on_found::success, peek_char, Cs... >::template can_match_eol< Eol >; + [[nodiscard]] static constexpr bool test_one( const char c ) noexcept + { + static_assert( sizeof...( Cs ) == 1 ); + return one< result_on_found::success, peek_char, Cs... >::test_one( c ); + } + + [[nodiscard]] static constexpr bool test_any( const char c ) noexcept + { + return one< result_on_found::success, peek_char, Cs... >::test_one( c ); + } template< typename ParseInput > [[nodiscard]] static bool match( ParseInput& in ) noexcept( noexcept( in.size( 0 ) ) ) diff --git a/packages/PEGTL/include/tao/pegtl/internal/lf_crlf_eol.hpp b/packages/PEGTL/include/tao/pegtl/internal/lf_crlf_eol.hpp index ac266014a7f07f1990149e47241cc3e38d1c2f09..aaa40ef7f9fb6b277ca4afd63137b0f5a237ed78 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/lf_crlf_eol.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/lf_crlf_eol.hpp @@ -1,12 +1,13 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_LF_CRLF_EOL_HPP #define TAO_PEGTL_INTERNAL_LF_CRLF_EOL_HPP +#include "data_and_size.hpp" + #include "../config.hpp" -#include "../eol_pair.hpp" namespace TAO_PEGTL_NAMESPACE::internal { @@ -15,18 +16,20 @@ namespace TAO_PEGTL_NAMESPACE::internal static constexpr int ch = '\n'; template< typename ParseInput > - [[nodiscard]] static eol_pair match( ParseInput& in ) noexcept( noexcept( in.size( 2 ) ) ) + [[nodiscard]] static bool_and_size eol_match( ParseInput& in ) noexcept( noexcept( in.size( 2 ) ) ) { - eol_pair p = { false, in.size( 2 ) }; - if( p.second ) { + bool_and_size p = { false, in.size( 2 ) }; + if( p.size > 0 ) { const auto a = in.peek_char(); if( a == '\n' ) { in.bump_to_next_line(); - p.first = true; + p.size = 1; + p.data = true; } - else if( ( a == '\r' ) && ( p.second > 1 ) && ( in.peek_char( 1 ) == '\n' ) ) { + else if( ( a == '\r' ) && ( p.size > 1 ) && ( in.peek_char( 1 ) == '\n' ) ) { in.bump_to_next_line( 2 ); - p.first = true; + p.size = 2; + p.data = true; } } return p; diff --git a/packages/PEGTL/include/tao/pegtl/internal/lf_eol.hpp b/packages/PEGTL/include/tao/pegtl/internal/lf_eol.hpp index d0f3adceb71904a82e4848f253b4ea6a02d4b31b..75598d45ae55a649b017fecf0f6487d72698859a 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/lf_eol.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/lf_eol.hpp @@ -1,12 +1,13 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_LF_EOL_HPP #define TAO_PEGTL_INTERNAL_LF_EOL_HPP +#include "data_and_size.hpp" + #include "../config.hpp" -#include "../eol_pair.hpp" namespace TAO_PEGTL_NAMESPACE::internal { @@ -15,13 +16,13 @@ namespace TAO_PEGTL_NAMESPACE::internal static constexpr int ch = '\n'; template< typename ParseInput > - [[nodiscard]] static eol_pair match( ParseInput& in ) noexcept( noexcept( in.size( 1 ) ) ) + [[nodiscard]] static bool_and_size eol_match( ParseInput& in ) noexcept( noexcept( in.size( 1 ) ) ) { - eol_pair p = { false, in.size( 1 ) }; - if( p.second ) { + bool_and_size p = { false, in.size( 1 ) }; + if( p.size > 0 ) { if( in.peek_char() == '\n' ) { in.bump_to_next_line(); - p.first = true; + p.data = true; } } return p; diff --git a/packages/PEGTL/include/tao/pegtl/internal/list.hpp b/packages/PEGTL/include/tao/pegtl/internal/list.hpp index 24a3935163bfa627e80cc21df792f9cca5d3f41a..c08e53c0c0a6c45a147e5bfc6e2b706c37508157 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/list.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/list.hpp @@ -1,15 +1,15 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_LIST_HPP #define TAO_PEGTL_INTERNAL_LIST_HPP -#include "../config.hpp" - #include "seq.hpp" #include "star.hpp" +#include "../config.hpp" + namespace TAO_PEGTL_NAMESPACE::internal { template< typename Rule, typename Sep > diff --git a/packages/PEGTL/include/tao/pegtl/internal/list_must.hpp b/packages/PEGTL/include/tao/pegtl/internal/list_must.hpp index 1d9cef89ef7b31f22512bc1f426981a43409d081..e16f62515bbcdff993484919ff002137ca199dac 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/list_must.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/list_must.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -9,12 +9,12 @@ #error "Exception support required for tao/pegtl/internal/list_must.hpp" #else -#include "../config.hpp" - #include "must.hpp" #include "seq.hpp" #include "star.hpp" +#include "../config.hpp" + namespace TAO_PEGTL_NAMESPACE::internal { template< typename Rule, typename Sep > diff --git a/packages/PEGTL/include/tao/pegtl/internal/list_tail.hpp b/packages/PEGTL/include/tao/pegtl/internal/list_tail.hpp index 59fae07ff18b969770d379084ac84752a57721ac..03bf38f75162b64f9fd867eaea30e8efa8ea1706 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/list_tail.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/list_tail.hpp @@ -1,22 +1,19 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_LIST_TAIL_HPP #define TAO_PEGTL_INTERNAL_LIST_TAIL_HPP -#include "../config.hpp" - -#include "opt.hpp" #include "seq.hpp" -#include "star.hpp" +#include "star_partial.hpp" -#include "../type_list.hpp" +#include "../config.hpp" namespace TAO_PEGTL_NAMESPACE::internal { template< typename Rule, typename Sep > - using list_tail = seq< Rule, star< Sep, Rule >, opt< Sep > >; + using list_tail = seq< Rule, star_partial< Sep, Rule > >; } // namespace TAO_PEGTL_NAMESPACE::internal diff --git a/packages/PEGTL/include/tao/pegtl/internal/list_tail_pad.hpp b/packages/PEGTL/include/tao/pegtl/internal/list_tail_pad.hpp index f204b23e83f09302731442a12a71f8aae79fe27e..299e5fe975ab4b41de635c4ea92abb0b14ec3dc6 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/list_tail_pad.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/list_tail_pad.hpp @@ -1,22 +1,20 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_LIST_TAIL_PAD_HPP #define TAO_PEGTL_INTERNAL_LIST_TAIL_PAD_HPP -#include "../config.hpp" - -#include "list.hpp" -#include "opt.hpp" #include "pad.hpp" #include "seq.hpp" -#include "star.hpp" +#include "star_partial.hpp" + +#include "../config.hpp" namespace TAO_PEGTL_NAMESPACE::internal { template< typename Rule, typename Sep, typename Pad > - using list_tail_pad = seq< Rule, star< pad< Sep, Pad >, Rule >, opt< star< Pad >, Sep > >; + using list_tail_pad = seq< Rule, star_partial< lpad< Sep, Pad >, lpad< Rule, Pad > > >; } // namespace TAO_PEGTL_NAMESPACE::internal diff --git a/packages/PEGTL/include/tao/pegtl/internal/marker.hpp b/packages/PEGTL/include/tao/pegtl/internal/marker.hpp deleted file mode 100644 index a061aea738eef1866887be743e4f6125605526a3..0000000000000000000000000000000000000000 --- a/packages/PEGTL/include/tao/pegtl/internal/marker.hpp +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) - -#ifndef TAO_PEGTL_INTERNAL_MARKER_HPP -#define TAO_PEGTL_INTERNAL_MARKER_HPP - -#include "../config.hpp" -#include "../rewind_mode.hpp" - -namespace TAO_PEGTL_NAMESPACE::internal -{ - template< typename Iterator, rewind_mode M > - class [[nodiscard]] marker - { - public: - static constexpr rewind_mode next_rewind_mode = M; - - explicit marker( const Iterator& /*unused*/ ) noexcept - {} - - marker( const marker& ) = delete; - marker( marker&& ) = delete; - - ~marker() = default; - - marker& operator=( const marker& ) = delete; - marker& operator=( marker&& ) = delete; - - [[nodiscard]] bool operator()( const bool result ) const noexcept - { - return result; - } - }; - - template< typename Iterator > - class [[nodiscard]] marker< Iterator, rewind_mode::required > - { - public: - static constexpr rewind_mode next_rewind_mode = rewind_mode::active; - - explicit marker( Iterator& i ) noexcept - : m_saved( i ), - m_input( &i ) - {} - - marker( const marker& ) = delete; - marker( marker&& ) = delete; - - ~marker() - { - if( m_input != nullptr ) { - ( *m_input ) = m_saved; - } - } - - marker& operator=( const marker& ) = delete; - marker& operator=( marker&& ) = delete; - - [[nodiscard]] bool operator()( const bool result ) noexcept - { - if( result ) { - m_input = nullptr; - return true; - } - return false; - } - - [[nodiscard]] const Iterator& iterator() const noexcept - { - return m_saved; - } - - private: - const Iterator m_saved; - Iterator* m_input; - }; - -} // namespace TAO_PEGTL_NAMESPACE::internal - -#endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/minus.hpp b/packages/PEGTL/include/tao/pegtl/internal/minus.hpp index f89ec02c8bf04a4937a5f8a0036657899d63aa5d..9536b821774d85504d325cf9afcb4bf819ca9e9c 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/minus.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/minus.hpp @@ -1,17 +1,17 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_MINUS_HPP #define TAO_PEGTL_INTERNAL_MINUS_HPP -#include "../config.hpp" - #include "eof.hpp" #include "not_at.hpp" #include "rematch.hpp" #include "seq.hpp" +#include "../config.hpp" + namespace TAO_PEGTL_NAMESPACE::internal { template< typename M, typename S > diff --git a/packages/PEGTL/include/tao/pegtl/internal/missing_apply.hpp b/packages/PEGTL/include/tao/pegtl/internal/missing_apply.hpp index b979c1420357a2d24dd6762a8a384d899c3700c9..6885588210861762a194afb1b808f6303ff5b6c1 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/missing_apply.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/missing_apply.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -19,8 +19,8 @@ namespace TAO_PEGTL_NAMESPACE::internal { // This function only exists for better error messages, which means that it is only called when we know that it won't compile. // LCOV_EXCL_START - auto m = in.template mark< rewind_mode::required >(); - (void)Control::template apply< Action >( m.iterator(), in, st... ); + auto m = in.template auto_rewind< rewind_mode::required >(); + (void)Control::template apply< Action >( m.frobnicator(), in, st... ); // LCOV_EXCL_STOP } diff --git a/packages/PEGTL/include/tao/pegtl/internal/missing_apply0.hpp b/packages/PEGTL/include/tao/pegtl/internal/missing_apply0.hpp index fedd156c0cb6b622488f261545effc523db15742..30ca3951c551c894dc43885a8ebd0f4172532a45 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/missing_apply0.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/missing_apply0.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/internal/mmap_file.hpp b/packages/PEGTL/include/tao/pegtl/internal/mmap_file.hpp new file mode 100644 index 0000000000000000000000000000000000000000..361a6f0bdc9edeca5f8e886b1b0893c4a3fb82c9 --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/internal/mmap_file.hpp @@ -0,0 +1,44 @@ +// Copyright (c) 2022-2023 Dr. Colin Hirsch and Daniel Frey +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) + +#ifndef TAO_PEGTL_INTERNAL_MMAP_FILE_HPP +#define TAO_PEGTL_INTERNAL_MMAP_FILE_HPP + +#if defined( __unix__ ) || ( defined( __APPLE__ ) && defined( __MACH__ ) ) +#include <unistd.h> // Required for _POSIX_MAPPED_FILES +#endif + +#if defined( _POSIX_MAPPED_FILES ) +#include "mmap_file_posix.hpp" +#elif defined( _WIN32 ) +#include "mmap_file_win32.hpp" +#else +#endif + +#include "filesystem.hpp" + +#include "../config.hpp" + +namespace TAO_PEGTL_NAMESPACE::internal +{ + struct mmap_file + { + const mmap_file_impl data; + + explicit mmap_file( const internal::filesystem::path& path ) + : data( path ) + {} + + mmap_file( const mmap_file& ) = delete; + mmap_file( mmap_file&& ) = delete; + + ~mmap_file() = default; + + mmap_file& operator=( const mmap_file& ) = delete; + mmap_file& operator=( mmap_file&& ) = delete; + }; + +} // namespace TAO_PEGTL_NAMESPACE::internal + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/file_mapper_posix.hpp b/packages/PEGTL/include/tao/pegtl/internal/mmap_file_posix.hpp similarity index 66% rename from packages/PEGTL/include/tao/pegtl/internal/file_mapper_posix.hpp rename to packages/PEGTL/include/tao/pegtl/internal/mmap_file_posix.hpp index def276bce3bab1a100934f66f45946dde0baf31c..367ae90d4abb9902d8c0006932eb5161d6dce5f9 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/file_mapper_posix.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/mmap_file_posix.hpp @@ -1,9 +1,9 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) -#ifndef TAO_PEGTL_INTERNAL_FILE_MAPPER_POSIX_HPP -#define TAO_PEGTL_INTERNAL_FILE_MAPPER_POSIX_HPP +#ifndef TAO_PEGTL_INTERNAL_MMAP_FILE_POSIX_HPP +#define TAO_PEGTL_INTERNAL_MMAP_FILE_POSIX_HPP #include <fcntl.h> #include <sys/mman.h> @@ -18,29 +18,29 @@ #include <utility> -#include "../config.hpp" - #include "filesystem.hpp" +#include "../config.hpp" + namespace TAO_PEGTL_NAMESPACE::internal { - struct file_opener + struct mmap_file_open { - explicit file_opener( const internal::filesystem::path& path ) // NOLINT(modernize-pass-by-value) + explicit mmap_file_open( const internal::filesystem::path& path ) // NOLINT(modernize-pass-by-value) : m_path( path ), m_fd( open() ) {} - file_opener( const file_opener& ) = delete; - file_opener( file_opener&& ) = delete; + mmap_file_open( const mmap_file_open& ) = delete; + mmap_file_open( mmap_file_open&& ) = delete; - ~file_opener() + ~mmap_file_open() { ::close( m_fd ); } - file_opener& operator=( const file_opener& ) = delete; - file_opener& operator=( file_opener&& ) = delete; + mmap_file_open& operator=( const mmap_file_open& ) = delete; + mmap_file_open& operator=( mmap_file_open&& ) = delete; [[nodiscard]] std::size_t size() const { @@ -49,7 +49,7 @@ namespace TAO_PEGTL_NAMESPACE::internal if( ::fstat( m_fd, &st ) < 0 ) { // LCOV_EXCL_START #if defined( __cpp_exceptions ) - internal::error_code ec( errno, internal::system_category() ); + const internal::error_code ec( errno, internal::system_category() ); throw internal::filesystem::filesystem_error( "fstat() failed", m_path, ec ); #else std::perror( "fstat() failed" ); @@ -57,7 +57,7 @@ namespace TAO_PEGTL_NAMESPACE::internal #endif // LCOV_EXCL_STOP } - return std::size_t( st.st_size ); + return static_cast< std::size_t >( st.st_size ); } const internal::filesystem::path m_path; @@ -77,7 +77,7 @@ namespace TAO_PEGTL_NAMESPACE::internal return fd; } #if defined( __cpp_exceptions ) - internal::error_code ec( errno, internal::system_category() ); + const internal::error_code ec( errno, internal::system_category() ); throw internal::filesystem::filesystem_error( "open() failed", m_path, ec ); #else std::perror( "open() failed" ); @@ -86,21 +86,21 @@ namespace TAO_PEGTL_NAMESPACE::internal } }; - class file_mapper + class mmap_file_posix { public: - explicit file_mapper( const internal::filesystem::path& path ) - : file_mapper( file_opener( path ) ) + explicit mmap_file_posix( const internal::filesystem::path& path ) + : mmap_file_posix( mmap_file_open( path ) ) {} - explicit file_mapper( const file_opener& reader ) + explicit mmap_file_posix( const mmap_file_open& reader ) : m_size( reader.size() ), m_data( static_cast< const char* >( ::mmap( nullptr, m_size, PROT_READ, MAP_PRIVATE, reader.m_fd, 0 ) ) ) { - if( ( m_size != 0 ) && ( intptr_t( m_data ) == -1 ) ) { + if( ( m_size != 0 ) && ( reinterpret_cast< intptr_t >( m_data ) == -1 ) ) { // LCOV_EXCL_START #if defined( __cpp_exceptions ) - internal::error_code ec( errno, internal::system_category() ); + const internal::error_code ec( errno, internal::system_category() ); throw internal::filesystem::filesystem_error( "mmap() failed", reader.m_path, ec ); #else std::perror( "mmap() failed" ); @@ -110,17 +110,17 @@ namespace TAO_PEGTL_NAMESPACE::internal } } - file_mapper( const file_mapper& ) = delete; - file_mapper( file_mapper&& ) = delete; + mmap_file_posix( const mmap_file_posix& ) = delete; + mmap_file_posix( mmap_file_posix&& ) = delete; - ~file_mapper() + ~mmap_file_posix() { // Legacy C interface requires pointer-to-mutable but does not write through the pointer. ::munmap( const_cast< char* >( m_data ), m_size ); } - file_mapper& operator=( const file_mapper& ) = delete; - file_mapper& operator=( file_mapper&& ) = delete; + mmap_file_posix& operator=( const mmap_file_posix& ) = delete; + mmap_file_posix& operator=( mmap_file_posix&& ) = delete; [[nodiscard]] bool empty() const noexcept { @@ -155,6 +155,8 @@ namespace TAO_PEGTL_NAMESPACE::internal const char* const m_data; }; + using mmap_file_impl = mmap_file_posix; + } // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/file_mapper_win32.hpp b/packages/PEGTL/include/tao/pegtl/internal/mmap_file_win32.hpp similarity index 79% rename from packages/PEGTL/include/tao/pegtl/internal/file_mapper_win32.hpp rename to packages/PEGTL/include/tao/pegtl/internal/mmap_file_win32.hpp index 4a353ccf4fd0feda569010d281352ed39ba42b66..5f2a3dbeeaae26f2611ba56f374cf609f1d813bc 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/file_mapper_win32.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/mmap_file_win32.hpp @@ -1,9 +1,11 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) -#ifndef TAO_PEGTL_INTERNAL_FILE_MAPPER_WIN32_HPP -#define TAO_PEGTL_INTERNAL_FILE_MAPPER_WIN32_HPP +#ifndef TAO_PEGTL_INTERNAL_MMAP_FILE_WIN32_HPP +#define TAO_PEGTL_INTERNAL_MMAP_FILE_WIN32_HPP + +#include "../config.hpp" #if !defined( NOMINMAX ) #define NOMINMAX @@ -27,8 +29,6 @@ #undef TAO_PEGTL_WIN32_LEAN_AND_MEAN_WAS_DEFINED #endif -#include "../config.hpp" - #if !defined( __cpp_exceptions ) #include <cstdio> #include <exception> @@ -38,23 +38,23 @@ namespace TAO_PEGTL_NAMESPACE::internal { - struct file_opener + struct mmap_file_open { - explicit file_opener( const internal::filesystem::path& path ) + explicit mmap_file_open( const internal::filesystem::path& path ) : m_path( path ), m_handle( open() ) {} - file_opener( const file_opener& ) = delete; - file_opener( file_opener&& ) = delete; + mmap_file_open( const mmap_file_open& ) = delete; + mmap_file_open( mmap_file_open&& ) = delete; - ~file_opener() + ~mmap_file_open() { ::CloseHandle( m_handle ); } - file_opener& operator=( const file_opener& ) = delete; - file_opener& operator=( file_opener&& ) = delete; + mmap_file_open& operator=( const mmap_file_open& ) = delete; + mmap_file_open& operator=( mmap_file_open&& ) = delete; [[nodiscard]] std::size_t size() const { @@ -116,33 +116,33 @@ namespace TAO_PEGTL_NAMESPACE::internal } }; - struct win32_file_mapper + struct mmap_file_mmap { - explicit win32_file_mapper( const internal::filesystem::path& path ) - : win32_file_mapper( file_opener( path ) ) + explicit mmap_file_mmap( const internal::filesystem::path& path ) + : mmap_file_mmap( mmap_file_open( path ) ) {} - explicit win32_file_mapper( const file_opener& reader ) + explicit mmap_file_mmap( const mmap_file_open& reader ) : m_size( reader.size() ), m_handle( open( reader ) ) {} - win32_file_mapper( const win32_file_mapper& ) = delete; - win32_file_mapper( win32_file_mapper&& ) = delete; + mmap_file_mmap( const mmap_file_mmap& ) = delete; + mmap_file_mmap( mmap_file_mmap&& ) = delete; - ~win32_file_mapper() + ~mmap_file_mmap() { ::CloseHandle( m_handle ); } - win32_file_mapper& operator=( const win32_file_mapper& ) = delete; - win32_file_mapper& operator=( win32_file_mapper&& ) = delete; + mmap_file_mmap& operator=( const mmap_file_mmap& ) = delete; + mmap_file_mmap& operator=( mmap_file_mmap&& ) = delete; const size_t m_size; const HANDLE m_handle; private: - [[nodiscard]] HANDLE open( const file_opener& reader ) const + [[nodiscard]] HANDLE open( const mmap_file_open& reader ) const { const uint64_t file_size = reader.size(); SetLastError( 0 ); @@ -169,14 +169,14 @@ namespace TAO_PEGTL_NAMESPACE::internal } }; - class file_mapper + class mmap_file_win32 { public: - explicit file_mapper( const internal::filesystem::path& path ) - : file_mapper( win32_file_mapper( path ) ) + explicit mmap_file_win32( const internal::filesystem::path& path ) + : mmap_file_win32( mmap_file_mmap( path ) ) {} - explicit file_mapper( const win32_file_mapper& mapper ) + explicit mmap_file_win32( const mmap_file_mmap& mapper ) : m_size( mapper.m_size ), m_data( static_cast< const char* >( ::MapViewOfFile( mapper.m_handle, FILE_MAP_READ, @@ -195,16 +195,16 @@ namespace TAO_PEGTL_NAMESPACE::internal } } - file_mapper( const file_mapper& ) = delete; - file_mapper( file_mapper&& ) = delete; + mmap_file_win32( const mmap_file_win32& ) = delete; + mmap_file_win32( mmap_file_win32&& ) = delete; - ~file_mapper() + ~mmap_file_win32() { ::UnmapViewOfFile( LPCVOID( m_data ) ); } - file_mapper& operator=( const file_mapper& ) = delete; - file_mapper& operator=( file_mapper&& ) = delete; + mmap_file_win32& operator=( const mmap_file_win32& ) = delete; + mmap_file_win32& operator=( mmap_file_win32&& ) = delete; [[nodiscard]] bool empty() const noexcept { @@ -239,6 +239,8 @@ namespace TAO_PEGTL_NAMESPACE::internal const char* const m_data; }; + using mmap_file_impl = mmap_file_win32; + } // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/must.hpp b/packages/PEGTL/include/tao/pegtl/internal/must.hpp index cc77f705814392f5f43af452367d84c600172819..93be8941fd319d73d19fd9e612dd873ba868ce67 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/must.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/must.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -9,13 +9,12 @@ #error "Exception support required for tao/pegtl/internal/must.hpp" #else -#include "../config.hpp" - #include "enable_control.hpp" #include "seq.hpp" #include "success.hpp" #include "../apply_mode.hpp" +#include "../config.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/internal/not_at.hpp b/packages/PEGTL/include/tao/pegtl/internal/not_at.hpp index 2e27e2d629795cfd5b90ec53829bc5c974459c83..b665d1e739972e85296026f3b8d759f2f156457b 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/not_at.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/not_at.hpp @@ -1,17 +1,16 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_NOT_AT_HPP #define TAO_PEGTL_INTERNAL_NOT_AT_HPP -#include "../config.hpp" - #include "enable_control.hpp" #include "failure.hpp" #include "seq.hpp" #include "../apply_mode.hpp" +#include "../config.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" @@ -43,7 +42,7 @@ namespace TAO_PEGTL_NAMESPACE::internal typename... States > [[nodiscard]] static bool match( ParseInput& in, States&&... st ) { - const auto m = in.template mark< rewind_mode::required >(); + const auto m = in.template auto_rewind< rewind_mode::required >(); return !Control< Rule >::template match< apply_mode::nothing, rewind_mode::active, Action, Control >( in, st... ); } }; diff --git a/packages/PEGTL/include/tao/pegtl/internal/one.hpp b/packages/PEGTL/include/tao/pegtl/internal/one.hpp index 2eac40f659d9d982b7b60b2200b10e6495551ac1..94de5ee7abeef913f0091fa7375468200bf4000b 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/one.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/one.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -7,14 +7,13 @@ #include <cstddef> -#include "../config.hpp" - #include "any.hpp" #include "bump_help.hpp" #include "enable_control.hpp" #include "failure.hpp" #include "result_on_found.hpp" +#include "../config.hpp" #include "../type_list.hpp" namespace TAO_PEGTL_NAMESPACE::internal @@ -28,19 +27,21 @@ namespace TAO_PEGTL_NAMESPACE::internal using rule_t = one; using subs_t = empty_list; - [[nodiscard]] static constexpr bool test( const data_t c ) noexcept + [[nodiscard]] static constexpr bool test_one( const data_t c ) noexcept { - return ( ( c == Cs ) || ... ) == bool( R ); + return ( ( c == Cs ) || ... ) == static_cast< bool >( R ); } - template< int Eol > - static constexpr bool can_match_eol = test( Eol ); + [[nodiscard]] static constexpr bool test_any( const data_t c ) noexcept + { + return test_one( c ); + } 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 ) ) { + if( test_one( t.data ) ) { bump_help< one >( in, t.size ); return true; } diff --git a/packages/PEGTL/include/tao/pegtl/internal/opt.hpp b/packages/PEGTL/include/tao/pegtl/internal/opt.hpp index 4a10afe77090dea98fe3bcab1d4e570514f1318c..9d23d673c178afcdd46a3e289a9f6e2bbf8eb14e 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/opt.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/opt.hpp @@ -1,21 +1,16 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_OPT_HPP #define TAO_PEGTL_INTERNAL_OPT_HPP -#include <type_traits> - -#include "../config.hpp" - #include "enable_control.hpp" +#include "partial.hpp" #include "seq.hpp" #include "success.hpp" -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" -#include "../type_list.hpp" +#include "../config.hpp" namespace TAO_PEGTL_NAMESPACE::internal { @@ -31,23 +26,9 @@ namespace TAO_PEGTL_NAMESPACE::internal template< typename Rule > struct opt< Rule > + : partial< Rule > { using rule_t = opt; - using subs_t = type_list< Rule >; - - template< apply_mode A, - rewind_mode, - template< typename... > - class Action, - template< typename... > - class Control, - typename ParseInput, - typename... States > - [[nodiscard]] static bool match( ParseInput& in, States&&... st ) - { - (void)Control< Rule >::template match< A, rewind_mode::required, Action, Control >( in, st... ); - return true; - } }; template< typename... Rules > diff --git a/packages/PEGTL/include/tao/pegtl/internal/pad.hpp b/packages/PEGTL/include/tao/pegtl/internal/pad.hpp index 13b473e2479b27f6fb738f1b7d9bf4a18b774599..44def8d1be29a14e8458696a24d9b071d935bb12 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/pad.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/pad.hpp @@ -1,20 +1,26 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_PAD_HPP #define TAO_PEGTL_INTERNAL_PAD_HPP -#include "../config.hpp" - #include "seq.hpp" #include "star.hpp" +#include "../config.hpp" + namespace TAO_PEGTL_NAMESPACE::internal { + template< typename Rule, typename Pad1 > + using lpad = seq< star< Pad1 >, Rule >; + template< typename Rule, typename Pad1, typename Pad2 = Pad1 > using pad = seq< star< Pad1 >, Rule, star< Pad2 > >; + template< typename Rule, typename Pad2 > + using rpad = seq< Rule, star< Pad2 > >; + } // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/pad_opt.hpp b/packages/PEGTL/include/tao/pegtl/internal/pad_opt.hpp index 80b5064f796b8eb8818b8946742afc80871e69ec..27dffb8872f4380293203e32eb0206f8ed58fdfc 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/pad_opt.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/pad_opt.hpp @@ -1,16 +1,16 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_PAD_OPT_HPP #define TAO_PEGTL_INTERNAL_PAD_OPT_HPP -#include "../config.hpp" - #include "opt.hpp" #include "seq.hpp" #include "star.hpp" +#include "../config.hpp" + namespace TAO_PEGTL_NAMESPACE::internal { template< typename Rule, typename Pad > diff --git a/packages/PEGTL/include/tao/pegtl/internal/partial.hpp b/packages/PEGTL/include/tao/pegtl/internal/partial.hpp new file mode 100644 index 0000000000000000000000000000000000000000..eb27b8d893f1e97be7087c7300a8718d7f3d5fa3 --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/internal/partial.hpp @@ -0,0 +1,43 @@ +// Copyright (c) 2023 Dr. Colin Hirsch and Daniel Frey +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) + +#ifndef TAO_PEGTL_INTERNAL_PARTIAL_HPP +#define TAO_PEGTL_INTERNAL_PARTIAL_HPP + +#include "enable_control.hpp" + +#include "../apply_mode.hpp" +#include "../config.hpp" +#include "../rewind_mode.hpp" +#include "../type_list.hpp" + +namespace TAO_PEGTL_NAMESPACE::internal +{ + template< typename... Rules > + struct partial + { + using rule_t = partial; + using subs_t = type_list< Rules... >; + + template< apply_mode A, + rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename ParseInput, + typename... States > + [[nodiscard]] static bool match( ParseInput& in, States&&... st ) + { + (void)( Control< Rules >::template match< A, rewind_mode::required, Action, Control >( in, st... ) && ... ); + return true; + } + }; + + template< typename... Rules > + inline constexpr bool enable_control< partial< Rules... > > = false; + +} // namespace TAO_PEGTL_NAMESPACE::internal + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/path_to_string.hpp b/packages/PEGTL/include/tao/pegtl/internal/path_to_string.hpp index 7d7757a0bdf50f785f95bf7c6980dde0731c5b5d..4d5fe80d1bcbb2b59675f846be714ca99307bfe7 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/path_to_string.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/path_to_string.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -7,9 +7,10 @@ #include <string> -#include "../config.hpp" #include "filesystem.hpp" +#include "../config.hpp" + namespace TAO_PEGTL_NAMESPACE::internal { [[nodiscard]] inline std::string path_to_string( const internal::filesystem::path& path ) diff --git a/packages/PEGTL/include/tao/pegtl/internal/peek_char.hpp b/packages/PEGTL/include/tao/pegtl/internal/peek_char.hpp index e85e5607d94e95ce669cc2c9995d159928adb25c..603eef878dbcd323daddc0ec6e3fe255966c0eb4 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/peek_char.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/peek_char.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -7,16 +7,16 @@ #include <cstddef> -#include "../config.hpp" +#include "data_and_size.hpp" -#include "input_pair.hpp" +#include "../config.hpp" namespace TAO_PEGTL_NAMESPACE::internal { struct peek_char { using data_t = char; - using pair_t = input_pair< char >; + using pair_t = data_and_size< char >; template< typename ParseInput > [[nodiscard]] static pair_t peek( ParseInput& in ) noexcept( noexcept( in.empty() ) ) diff --git a/packages/PEGTL/include/tao/pegtl/internal/peek_utf8.hpp b/packages/PEGTL/include/tao/pegtl/internal/peek_utf8.hpp index a47d813a361d1af48209703b1bd6e108fd926c70..3555378331aa7459e02aa12481a3592f966249bb 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/peek_utf8.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/peek_utf8.hpp @@ -1,20 +1,20 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_PEEK_UTF8_HPP #define TAO_PEGTL_INTERNAL_PEEK_UTF8_HPP -#include "../config.hpp" +#include "data_and_size.hpp" -#include "input_pair.hpp" +#include "../config.hpp" namespace TAO_PEGTL_NAMESPACE::internal { struct peek_utf8 { using data_t = char32_t; - using pair_t = input_pair< char32_t >; + using pair_t = data_and_size< char32_t >; template< typename ParseInput > [[nodiscard]] static pair_t peek( ParseInput& in ) noexcept( noexcept( in.empty() ) ) diff --git a/packages/PEGTL/include/tao/pegtl/internal/pegtl_string.hpp b/packages/PEGTL/include/tao/pegtl/internal/pegtl_string.hpp index 576c216d286a45c7c8df26b8a6351526b5143855..3811179fd8c96672d8c67ccfd6e03cc476b03cee 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/pegtl_string.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/pegtl_string.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -10,6 +10,7 @@ #include "../ascii.hpp" #include "../config.hpp" +#include "../rules.hpp" namespace TAO_PEGTL_NAMESPACE::internal { @@ -52,17 +53,17 @@ namespace TAO_PEGTL_NAMESPACE::internal #define TAO_PEGTL_INTERNAL_EXPAND( ... ) __VA_ARGS__ #define TAO_PEGTL_INTERNAL_STRING_AT( S, x, n ) \ - TAO_PEGTL_NAMESPACE::internal::string_at< S, ( 0##n < ( sizeof( x ) / sizeof( char ) ) ) ? ( x )[ 0##n ] : 0, ( 0##n < ( sizeof( x ) / sizeof( char ) ) - 1 ) >::type - -#define TAO_PEGTL_INTERNAL_JOIN_8( M, S, x, n ) \ - TAO_PEGTL_NAMESPACE::internal::string_join< TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##0 ), \ - TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##1 ), \ - TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##2 ), \ - TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##3 ), \ - TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##4 ), \ - TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##5 ), \ - TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##6 ), \ - TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##7 ) >::type + ::TAO_PEGTL_NAMESPACE::internal::string_at< S, ( 0##n < ( sizeof( x ) / sizeof( char ) ) ) ? ( x )[ 0##n ] : 0, ( 0##n < ( sizeof( x ) / sizeof( char ) ) - 1 ) >::type + +#define TAO_PEGTL_INTERNAL_JOIN_8( M, S, x, n ) \ + ::TAO_PEGTL_NAMESPACE::internal::string_join< TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##0 ), \ + TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##1 ), \ + TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##2 ), \ + TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##3 ), \ + TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##4 ), \ + TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##5 ), \ + TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##6 ), \ + TAO_PEGTL_INTERNAL_DEFER( M )( S, x, n##7 ) >::type #define TAO_PEGTL_INTERNAL_STRING_8( S, x, n ) \ TAO_PEGTL_INTERNAL_JOIN_8( TAO_PEGTL_INTERNAL_STRING_AT, S, x, n ) @@ -77,15 +78,18 @@ namespace TAO_PEGTL_NAMESPACE::internal TAO_PEGTL_INTERNAL_EXPAND( \ TAO_PEGTL_INTERNAL_EXPAND( \ TAO_PEGTL_INTERNAL_EXPAND( \ - TAO_PEGTL_NAMESPACE::internal::string_max_length< TAO_PEGTL_INTERNAL_STRING_512( S, x, ), sizeof( x ) - 1 >::type ) ) ) + ::TAO_PEGTL_NAMESPACE::internal::string_max_length< TAO_PEGTL_INTERNAL_STRING_512( S, x, ), sizeof( x ) - 1 >::type ) ) ) #define TAO_PEGTL_STRING( x ) \ - TAO_PEGTL_INTERNAL_STRING( TAO_PEGTL_NAMESPACE::ascii::string, x ) + TAO_PEGTL_INTERNAL_STRING( ::TAO_PEGTL_NAMESPACE::ascii::string, x ) #define TAO_PEGTL_ISTRING( x ) \ - TAO_PEGTL_INTERNAL_STRING( TAO_PEGTL_NAMESPACE::ascii::istring, x ) + TAO_PEGTL_INTERNAL_STRING( ::TAO_PEGTL_NAMESPACE::ascii::istring, x ) #define TAO_PEGTL_KEYWORD( x ) \ - TAO_PEGTL_INTERNAL_STRING( TAO_PEGTL_NAMESPACE::ascii::keyword, x ) + TAO_PEGTL_INTERNAL_STRING( ::TAO_PEGTL_NAMESPACE::ascii::keyword, x ) + +#define TAO_PEGTL_RAISE_MESSAGE( x ) \ + TAO_PEGTL_INTERNAL_STRING( ::TAO_PEGTL_NAMESPACE::raise_message, x ) #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/plus.hpp b/packages/PEGTL/include/tao/pegtl/internal/plus.hpp index 2ebdd3e62e42437d299fd4b38f7ff3ad338b4aaf..5695a9a05b047347368e4af6011dad9ab611a86d 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/plus.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/plus.hpp @@ -1,18 +1,15 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_PLUS_HPP #define TAO_PEGTL_INTERNAL_PLUS_HPP -#include <type_traits> - -#include "../config.hpp" - #include "enable_control.hpp" #include "seq.hpp" #include "../apply_mode.hpp" +#include "../config.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/internal/raise.hpp b/packages/PEGTL/include/tao/pegtl/internal/raise.hpp index 11db9fce43efc3c33d438eddabbba4c6f02e148f..8e1d17fdf570a315779c6c8afd38194da79b0451 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/raise.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/raise.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -11,11 +11,10 @@ #include <stdexcept> -#include "../config.hpp" - #include "enable_control.hpp" #include "../apply_mode.hpp" +#include "../config.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/internal/range.hpp b/packages/PEGTL/include/tao/pegtl/internal/range.hpp index f504161d1c93485b4643c4ae74e055695b974ee7..3245d06c30cebb24bb53de30a561bc2f5bc7ade7 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/range.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/range.hpp @@ -1,17 +1,16 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_RANGE_HPP #define TAO_PEGTL_INTERNAL_RANGE_HPP -#include "../config.hpp" - #include "bump_help.hpp" #include "enable_control.hpp" #include "one.hpp" #include "result_on_found.hpp" +#include "../config.hpp" #include "../type_list.hpp" namespace TAO_PEGTL_NAMESPACE::internal @@ -27,19 +26,21 @@ namespace TAO_PEGTL_NAMESPACE::internal static_assert( Lo < Hi, "invalid range" ); - [[nodiscard]] static constexpr bool test( const data_t c ) noexcept + [[nodiscard]] static constexpr bool test_one( const data_t c ) noexcept { - return ( ( Lo <= c ) && ( c <= Hi ) ) == bool( R ); + return ( ( Lo <= c ) && ( c <= Hi ) ) == static_cast< bool >( R ); } - template< int Eol > - static constexpr bool can_match_eol = test( Eol ); + [[nodiscard]] static constexpr bool test_any( const data_t c ) noexcept + { + return test_one( c ); + } 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 ) ) { + if( test_one( t.data ) ) { bump_help< range >( in, t.size ); return true; } diff --git a/packages/PEGTL/include/tao/pegtl/internal/ranges.hpp b/packages/PEGTL/include/tao/pegtl/internal/ranges.hpp index 9df06d7b3d756778b2fc64dd1938378f7e156468..10de9d082eaeff9f24d1d8dae7a5e143ed699ec4 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/ranges.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/ranges.hpp @@ -1,12 +1,10 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_RANGES_HPP #define TAO_PEGTL_INTERNAL_RANGES_HPP -#include "../config.hpp" - #include <utility> #include "bump_help.hpp" @@ -15,6 +13,7 @@ #include "one.hpp" #include "range.hpp" +#include "../config.hpp" #include "../type_list.hpp" namespace TAO_PEGTL_NAMESPACE::internal @@ -36,7 +35,7 @@ namespace TAO_PEGTL_NAMESPACE::internal using subs_t = empty_list; template< std::size_t... Is > - [[nodiscard]] static constexpr bool test( std::index_sequence< Is... > /*unused*/, const data_t c ) noexcept + [[nodiscard]] static constexpr bool test_impl( std::index_sequence< Is... > /*unused*/, const data_t c ) noexcept { constexpr const data_t cs[] = { Cs... }; if constexpr( sizeof...( Cs ) % 2 == 0 ) { @@ -47,19 +46,21 @@ namespace TAO_PEGTL_NAMESPACE::internal } } - [[nodiscard]] static constexpr bool test( const data_t c ) noexcept + [[nodiscard]] static constexpr bool test_one( const data_t c ) noexcept { - return test( std::make_index_sequence< sizeof...( Cs ) / 2 >(), c ); + return test_impl( std::make_index_sequence< sizeof...( Cs ) / 2 >(), c ); } - template< int Eol > - static constexpr bool can_match_eol = test( Eol ); + [[nodiscard]] static constexpr bool test_any( const data_t c ) noexcept + { + return test_impl( std::make_index_sequence< sizeof...( Cs ) / 2 >(), c ); + } 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 ) ) { + if( test_one( t.data ) ) { bump_help< ranges >( in, t.size ); return true; } diff --git a/packages/PEGTL/include/tao/pegtl/internal/file_reader.hpp b/packages/PEGTL/include/tao/pegtl/internal/read_file_stdio.hpp similarity index 63% rename from packages/PEGTL/include/tao/pegtl/internal/file_reader.hpp rename to packages/PEGTL/include/tao/pegtl/internal/read_file_stdio.hpp index a842f4bd005724dea283075b7fbcca07c66b9b0d..afb08a67ee4e7062f7a6b6a98be599707085389e 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/file_reader.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/read_file_stdio.hpp @@ -1,9 +1,9 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) -#ifndef TAO_PEGTL_INTERNAL_FILE_READER_HPP -#define TAO_PEGTL_INTERNAL_FILE_READER_HPP +#ifndef TAO_PEGTL_INTERNAL_READ_FILE_STDIO_HPP +#define TAO_PEGTL_INTERNAL_READ_FILE_STDIO_HPP #include <cstdio> #include <memory> @@ -14,13 +14,14 @@ #include <exception> #endif -#include "../config.hpp" - #include "filesystem.hpp" +#include "resize_uninitialized.hpp" + +#include "../config.hpp" namespace TAO_PEGTL_NAMESPACE::internal { - [[nodiscard]] inline std::FILE* file_open( const internal::filesystem::path& path ) + [[nodiscard]] inline std::FILE* read_file_open( const internal::filesystem::path& path ) { errno = 0; #if defined( _MSC_VER ) @@ -29,7 +30,7 @@ namespace TAO_PEGTL_NAMESPACE::internal return file; } #if defined( __cpp_exceptions ) - internal::error_code ec( errno, internal::system_category() ); + const internal::error_code ec( errno, internal::system_category() ); throw internal::filesystem::filesystem_error( "_wfopen_s() failed", path, ec ); #else std::perror( "_wfopen_s() failed" ); @@ -45,7 +46,7 @@ namespace TAO_PEGTL_NAMESPACE::internal return file; } #if defined( __cpp_exceptions ) - internal::error_code ec( errno, internal::system_category() ); + const internal::error_code ec( errno, internal::system_category() ); throw internal::filesystem::filesystem_error( "std::fopen() failed", path, ec ); #else std::perror( "std::fopen() failed" ); @@ -54,7 +55,7 @@ namespace TAO_PEGTL_NAMESPACE::internal #endif } - struct file_close + struct read_file_close { void operator()( FILE* f ) const noexcept { @@ -62,25 +63,25 @@ namespace TAO_PEGTL_NAMESPACE::internal } }; - class file_reader + class read_file_stdio { public: - explicit file_reader( const internal::filesystem::path& path ) - : file_reader( file_open( path ), path ) + explicit read_file_stdio( const internal::filesystem::path& path ) + : read_file_stdio( read_file_open( path ), path ) {} - file_reader( FILE* file, const internal::filesystem::path& path ) // NOLINT(modernize-pass-by-value) + read_file_stdio( FILE* file, const internal::filesystem::path& path ) // NOLINT(modernize-pass-by-value) : m_path( path ), m_file( file ) {} - file_reader( const file_reader& ) = delete; - file_reader( file_reader&& ) = delete; + read_file_stdio( const read_file_stdio& ) = delete; + read_file_stdio( read_file_stdio&& ) = delete; - ~file_reader() = default; + ~read_file_stdio() = default; - file_reader& operator=( const file_reader& ) = delete; - file_reader& operator=( file_reader&& ) = delete; + read_file_stdio& operator=( const read_file_stdio& ) = delete; + read_file_stdio& operator=( read_file_stdio&& ) = delete; [[nodiscard]] std::size_t size() const { @@ -88,7 +89,7 @@ namespace TAO_PEGTL_NAMESPACE::internal if( std::fseek( m_file.get(), 0, SEEK_END ) != 0 ) { // LCOV_EXCL_START #if defined( __cpp_exceptions ) - internal::error_code ec( errno, internal::system_category() ); + const internal::error_code ec( errno, internal::system_category() ); throw internal::filesystem::filesystem_error( "std::fseek() failed [SEEK_END]", m_path, ec ); #else std::perror( "std::fseek() failed [SEEK_END]" ); @@ -101,7 +102,7 @@ namespace TAO_PEGTL_NAMESPACE::internal if( s < 0 ) { // LCOV_EXCL_START #if defined( __cpp_exceptions ) - internal::error_code ec( errno, internal::system_category() ); + const internal::error_code ec( errno, internal::system_category() ); throw internal::filesystem::filesystem_error( "std::ftell() failed", m_path, ec ); #else std::perror( "std::ftell() failed" ); @@ -113,7 +114,7 @@ namespace TAO_PEGTL_NAMESPACE::internal if( std::fseek( m_file.get(), 0, SEEK_SET ) != 0 ) { // LCOV_EXCL_START #if defined( __cpp_exceptions ) - internal::error_code ec( errno, internal::system_category() ); + const internal::error_code ec( errno, internal::system_category() ); throw internal::filesystem::filesystem_error( "std::fseek() failed [SEEK_SET]", m_path, ec ); #else std::perror( "std::fseek() failed [SEEK_SET]" ); @@ -121,18 +122,30 @@ namespace TAO_PEGTL_NAMESPACE::internal #endif // LCOV_EXCL_STOP } - return std::size_t( s ); + return static_cast< std::size_t >( s ); } - [[nodiscard]] std::string read() const + [[nodiscard]] std::string read_string() const { std::string nrv; - nrv.resize( size() ); + if( const std::size_t s = size(); s > 0 ) { + resize_uninitialized( nrv, s ); + read_impl( nrv.data(), nrv.size() ); + } + return nrv; + } + + private: + const internal::filesystem::path m_path; + const std::unique_ptr< std::FILE, read_file_close > m_file; + + void read_impl( void* buffer, const std::size_t length ) const + { errno = 0; - if( !nrv.empty() && ( std::fread( &nrv[ 0 ], nrv.size(), 1, m_file.get() ) != 1 ) ) { + if( std::fread( buffer, length, 1, m_file.get() ) != 1 ) { // LCOV_EXCL_START #if defined( __cpp_exceptions ) - internal::error_code ec( errno, internal::system_category() ); + const internal::error_code ec( errno, internal::system_category() ); throw internal::filesystem::filesystem_error( "std::fread() failed", m_path, ec ); #else std::perror( "std::fread() failed" ); @@ -140,12 +153,7 @@ namespace TAO_PEGTL_NAMESPACE::internal #endif // LCOV_EXCL_STOP } - return nrv; } - - private: - const internal::filesystem::path m_path; - const std::unique_ptr< std::FILE, file_close > m_file; }; } // namespace TAO_PEGTL_NAMESPACE::internal diff --git a/packages/PEGTL/include/tao/pegtl/internal/rematch.hpp b/packages/PEGTL/include/tao/pegtl/internal/rematch.hpp index 4877a3401e6d9f81d8b29159f1742f15dd6608dc..e5f8ac6fb8b1ef81772ca8eeadf9fdb8b555cb53 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/rematch.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/rematch.hpp @@ -1,15 +1,14 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_REMATCH_HPP #define TAO_PEGTL_INTERNAL_REMATCH_HPP -#include "../config.hpp" - #include "enable_control.hpp" #include "../apply_mode.hpp" +#include "../config.hpp" #include "../memory_input.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" @@ -55,10 +54,10 @@ namespace TAO_PEGTL_NAMESPACE::internal typename... States > [[nodiscard]] static bool match( ParseInput& in, States&&... st ) { - auto m = in.template mark< rewind_mode::required >(); + auto m = in.template auto_rewind< rewind_mode::required >(); if( Control< Head >::template match< A, rewind_mode::active, Action, Control >( in, st... ) ) { - memory_input< ParseInput::tracking_mode_v, typename ParseInput::eol_t, typename ParseInput::source_t > i2( m.iterator(), in.current(), in.source() ); + memory_input< ParseInput::tracking_mode_v, typename ParseInput::eol_t, typename ParseInput::source_t > i2( m.frobnicator(), in.current(), in.source() ); return m( ( Control< Rule >::template match< A, rewind_mode::active, Action, Control >( i2, st... ) && ... && ( i2.restart( m ), Control< Rules >::template match< A, rewind_mode::active, Action, Control >( i2, st... ) ) ) ); } return false; diff --git a/packages/PEGTL/include/tao/pegtl/internal/rep.hpp b/packages/PEGTL/include/tao/pegtl/internal/rep.hpp index 79a2be78917f73779e906b0e9c36b1dc552ab8c4..8a16fec0d0137f8df6007f7a441edaf9fe8bdebb 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/rep.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/rep.hpp @@ -1,17 +1,16 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_REP_HPP #define TAO_PEGTL_INTERNAL_REP_HPP -#include "../config.hpp" - #include "enable_control.hpp" #include "seq.hpp" #include "success.hpp" #include "../apply_mode.hpp" +#include "../config.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" @@ -48,7 +47,7 @@ namespace TAO_PEGTL_NAMESPACE::internal typename... States > [[nodiscard]] static bool match( ParseInput& in, States&&... st ) { - auto m = in.template mark< M >(); + auto m = in.template auto_rewind< M >(); using m_t = decltype( m ); for( unsigned i = 0; i != Cnt; ++i ) { diff --git a/packages/PEGTL/include/tao/pegtl/internal/rep_min.hpp b/packages/PEGTL/include/tao/pegtl/internal/rep_min.hpp index a6efe9e6734f44152544c4fc5ad8111ec662c21e..e368f8af037ea7cb955bcbd861ce7610dbecfce7 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/rep_min.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/rep_min.hpp @@ -1,16 +1,16 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_REP_MIN_HPP #define TAO_PEGTL_INTERNAL_REP_MIN_HPP -#include "../config.hpp" - #include "rep.hpp" #include "seq.hpp" #include "star.hpp" +#include "../config.hpp" + namespace TAO_PEGTL_NAMESPACE::internal { template< unsigned Min, typename Rule, typename... Rules > diff --git a/packages/PEGTL/include/tao/pegtl/internal/rep_min_max.hpp b/packages/PEGTL/include/tao/pegtl/internal/rep_min_max.hpp index b0026458efa40eb655aeac6f2dede2ab7111836c..562bccd26be957bd23f4f74c0103c146e198dde5 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/rep_min_max.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/rep_min_max.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -7,14 +7,13 @@ #include <type_traits> -#include "../config.hpp" - #include "enable_control.hpp" #include "failure.hpp" #include "not_at.hpp" #include "seq.hpp" #include "../apply_mode.hpp" +#include "../config.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" @@ -57,7 +56,7 @@ namespace TAO_PEGTL_NAMESPACE::internal typename... States > [[nodiscard]] static bool match( ParseInput& in, States&&... st ) { - auto m = in.template mark< M >(); + auto m = in.template auto_rewind< M >(); using m_t = decltype( m ); for( unsigned i = 0; i != Min; ++i ) { diff --git a/packages/PEGTL/include/tao/pegtl/internal/rep_opt.hpp b/packages/PEGTL/include/tao/pegtl/internal/rep_opt.hpp index bea26e5be97d4ff612e2c68b6e19c22d21094009..55f22308d61bed9c520827e5d4d0a06aecf7ae4e 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/rep_opt.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/rep_opt.hpp @@ -1,17 +1,16 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_REP_OPT_HPP #define TAO_PEGTL_INTERNAL_REP_OPT_HPP -#include "../config.hpp" - #include "enable_control.hpp" #include "seq.hpp" #include "success.hpp" #include "../apply_mode.hpp" +#include "../config.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/internal/require.hpp b/packages/PEGTL/include/tao/pegtl/internal/require.hpp index b4e24fb158c13e5bc4c3b697e8e58f2c5c20be3f..f30de0d21f22c50175da3c882b2b200d33101b64 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/require.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/require.hpp @@ -1,15 +1,14 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_REQUIRE_HPP #define TAO_PEGTL_INTERNAL_REQUIRE_HPP -#include "../config.hpp" - #include "enable_control.hpp" #include "success.hpp" +#include "../config.hpp" #include "../type_list.hpp" namespace TAO_PEGTL_NAMESPACE::internal diff --git a/packages/PEGTL/include/tao/pegtl/internal/resize_uninitialized.hpp b/packages/PEGTL/include/tao/pegtl/internal/resize_uninitialized.hpp new file mode 100644 index 0000000000000000000000000000000000000000..7046b7a3a311d50b018acea72885d1f446f7fc03 --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/internal/resize_uninitialized.hpp @@ -0,0 +1,124 @@ +// Copyright (c) 2021-2023 Dr. Colin Hirsch and Daniel Frey +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) + +#ifndef TAO_PEGTL_INTERNAL_RESIZE_UNINITIALIZED_HPP +#define TAO_PEGTL_INTERNAL_RESIZE_UNINITIALIZED_HPP + +#include <cstddef> +#include <string> + +#include "../config.hpp" + +namespace TAO_PEGTL_NAMESPACE::internal +{ + // the below uses a hack to call private member functions of a class, described here: + // https://github.com/facebook/folly/blob/master/folly/memory/UninitializedMemoryHacks.h + + namespace // NOLINT(google-build-namespaces) + { + // declare some functions... + void resize_uninitialized_proxy( std::string& v, const std::size_t n ); + void resize_uninitialized_proxy( std::basic_string< unsigned char >& v, const std::size_t n ); + void resize_uninitialized_proxy( std::basic_string< std::byte >& v, const std::size_t n ); + +#if defined( _LIBCPP_STRING ) + + // ...create a proxy to generate the actual implementation of the above function... + template< typename T, void ( T::*F )( std::size_t ) > + struct proxy + { + // ...define the function declared above... + friend void resize_uninitialized_proxy( T& v, const std::size_t n ) + { + ( v.*F )( n ); // v.__set_size( n ); + v[ v.size() ] = typename T::value_type( 0 ); + } + }; + + // ...and here's the actual "trick": an explicit template instantiation skips the access checks, + // so you can reference private members and forward them to the above proxy! + template struct proxy< std::string, &std::string::__set_size >; + template struct proxy< std::basic_string< unsigned char >, &std::basic_string< unsigned char >::__set_size >; + template struct proxy< std::basic_string< std::byte >, &std::basic_string< std::byte >::__set_size >; + +#elif defined( _GLIBCXX_STRING ) && _GLIBCXX_USE_CXX11_ABI + + template< typename T, void ( T::*F )( std::size_t ) > + struct proxy + { + friend void resize_uninitialized_proxy( T& v, const std::size_t n ) + { + ( v.*F )( n ); // v._M_set_length( n ); + } + }; + + template struct proxy< std::string, &std::string::_M_set_length >; + template struct proxy< std::basic_string< unsigned char >, &std::basic_string< unsigned char >::_M_set_length >; + template struct proxy< std::basic_string< std::byte >, &std::basic_string< std::byte >::_M_set_length >; + +#elif defined( _GLIBCXX_STRING ) + + template< typename T, + typename R, + R* ( T::*F )() const > + struct proxy + { + friend void resize_uninitialized_proxy( T& v, const std::size_t n ) + { + // v._M_rep()->_M_set_length_and_sharable( n ); + ( v.*F )()->_M_set_length_and_sharable( n ); + } + }; + + template struct proxy< std::string, + std::string::_Rep, + &std::string::_M_rep >; + + template struct proxy< std::basic_string< unsigned char >, + std::basic_string< unsigned char >::_Rep, + &std::basic_string< unsigned char >::_M_rep >; + + template struct proxy< std::basic_string< std::byte >, + std::basic_string< std::byte >::_Rep, + &std::basic_string< std::byte >::_M_rep >; + +#elif defined( _MSC_VER ) + + template< typename T, void ( T::*F )( std::size_t ) > + struct proxy + { + friend void resize_uninitialized_proxy( T& v, const std::size_t n ) + { + ( v.*F )( n ); // v._Eos( n ); + } + }; + + template struct proxy< std::string, &std::string::_Eos >; + template struct proxy< std::basic_string< unsigned char >, &std::basic_string< unsigned char >::_Eos >; + template struct proxy< std::basic_string< std::byte >, &std::basic_string< std::byte >::_Eos >; + +#else +#error "No implementation for resize_uninitialized available." +#endif + + } // namespace + + template< typename T > + void resize_uninitialized( std::basic_string< T >& v, const std::size_t n ) + { + if( n <= v.size() ) { + v.resize( n ); + } + else { + // careful not to call reserve() unless necessary, as it causes shrink_to_fit() on many platforms + if( n > v.capacity() ) { + v.reserve( n ); + } + internal::resize_uninitialized_proxy( v, n ); + } + } + +} // namespace TAO_PEGTL_NAMESPACE::internal + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/result_on_found.hpp b/packages/PEGTL/include/tao/pegtl/internal/result_on_found.hpp index df2bcd77b0e9a3d9c97783d456c0e1dd0aed0e6c..967c4427b667a123c65cf3867bf580f6fe70d523 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/result_on_found.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/result_on_found.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/internal/rewind_guard.hpp b/packages/PEGTL/include/tao/pegtl/internal/rewind_guard.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8c4a6461ac1f5c21f1f6af0aa2b8eba51f935e0c --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/internal/rewind_guard.hpp @@ -0,0 +1,86 @@ +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) + +#ifndef TAO_PEGTL_INTERNAL_REWIND_GUARD_HPP +#define TAO_PEGTL_INTERNAL_REWIND_GUARD_HPP + +#include <type_traits> +#include <utility> + +#include "../config.hpp" +#include "../rewind_mode.hpp" + +namespace TAO_PEGTL_NAMESPACE::internal +{ + template< rewind_mode M, typename ParseInput > + class [[nodiscard]] rewind_guard + { + public: + static constexpr rewind_mode next_rewind_mode = M; + + explicit rewind_guard( ParseInput* /*unused*/ ) noexcept + {} + + rewind_guard( const rewind_guard& ) = delete; + rewind_guard( rewind_guard&& ) = delete; + + ~rewind_guard() = default; + + rewind_guard& operator=( const rewind_guard& ) = delete; + rewind_guard& operator=( rewind_guard&& ) = delete; + + [[nodiscard]] bool operator()( const bool result ) const noexcept + { + return result; + } + }; + + template< typename ParseInput > + class [[nodiscard]] rewind_guard< rewind_mode::required, ParseInput > + { + public: + static constexpr rewind_mode next_rewind_mode = rewind_mode::active; + + using rewind_data = std::decay_t< decltype( std::declval< ParseInput >().rewind_save() ) >; + + explicit rewind_guard( ParseInput* in ) noexcept + : m_input( in ), + m_saved( in->rewind_save() ) + {} + + rewind_guard( const rewind_guard& ) = delete; + rewind_guard( rewind_guard&& ) = delete; + + ~rewind_guard() + { + if( m_input != nullptr ) { + m_input->rewind_restore( std::move( m_saved ) ); + } + } + + rewind_guard& operator=( const rewind_guard& ) = delete; + rewind_guard& operator=( rewind_guard&& ) = delete; + + [[nodiscard]] bool operator()( const bool result ) noexcept + { + if( result ) { + m_input = nullptr; + return true; + } + return false; + } + + [[nodiscard]] const rewind_data& frobnicator() const noexcept + { + return m_saved; + } + + private: + ParseInput* m_input; + rewind_data m_saved; + }; + +} // namespace TAO_PEGTL_NAMESPACE::internal + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/rules.hpp b/packages/PEGTL/include/tao/pegtl/internal/rules.hpp index 2f89826f167b17fdb77da2a21e20ea930c42925f..5a53bcf498ab5f497a46ed2c0291724ed2bca42a 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/rules.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/rules.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -21,6 +21,7 @@ #include "eof.hpp" #include "eol.hpp" #include "eolf.hpp" +#include "everything.hpp" #include "failure.hpp" #include "identifier.hpp" #include "if_apply.hpp" @@ -35,6 +36,7 @@ #include "opt.hpp" #include "pad.hpp" #include "pad_opt.hpp" +#include "partial.hpp" #include "plus.hpp" #include "range.hpp" #include "ranges.hpp" @@ -47,7 +49,10 @@ #include "seq.hpp" #include "sor.hpp" #include "star.hpp" +#include "star_partial.hpp" +#include "star_strict.hpp" #include "state.hpp" +#include "strict.hpp" #include "string.hpp" #include "success.hpp" #include "until.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/internal/seq.hpp b/packages/PEGTL/include/tao/pegtl/internal/seq.hpp index eb0a8624d7eea11ef11996f3885dff7092d6197a..277b6d9bbd78b61f5309f4ec4049f8f6990db95b 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/seq.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/seq.hpp @@ -1,16 +1,15 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_SEQ_HPP #define TAO_PEGTL_INTERNAL_SEQ_HPP -#include "../config.hpp" - #include "enable_control.hpp" #include "success.hpp" #include "../apply_mode.hpp" +#include "../config.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" @@ -44,7 +43,7 @@ namespace TAO_PEGTL_NAMESPACE::internal return Control< Rules... >::template match< A, M, Action, Control >( in, st... ); } else { - auto m = in.template mark< M >(); + auto m = in.template auto_rewind< M >(); using m_t = decltype( m ); return m( ( Control< Rules >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) && ... ) ); } diff --git a/packages/PEGTL/include/tao/pegtl/internal/sor.hpp b/packages/PEGTL/include/tao/pegtl/internal/sor.hpp index b09d6779c0cd781257028754012ab5f116afb35b..c153adf1420bef5d11d7ab9e9f088d5a4c543d64 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/sor.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/sor.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -7,12 +7,11 @@ #include <utility> -#include "../config.hpp" - #include "enable_control.hpp" #include "failure.hpp" #include "../apply_mode.hpp" +#include "../config.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/internal/star.hpp b/packages/PEGTL/include/tao/pegtl/internal/star.hpp index bc2360bf759b911ef7c27b74f9423fdbbb142a45..693cb28fe4603e41ceefa59586c3d5fd2b015942 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/star.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/star.hpp @@ -1,20 +1,15 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_STAR_HPP #define TAO_PEGTL_INTERNAL_STAR_HPP -#include <type_traits> - -#include "../config.hpp" - #include "enable_control.hpp" #include "seq.hpp" +#include "star_partial.hpp" -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" -#include "../type_list.hpp" +#include "../config.hpp" namespace TAO_PEGTL_NAMESPACE::internal { @@ -25,24 +20,9 @@ namespace TAO_PEGTL_NAMESPACE::internal template< typename Rule > struct star< Rule > + : star_partial< Rule > { using rule_t = star; - using subs_t = type_list< Rule >; - - template< apply_mode A, - rewind_mode, - template< typename... > - class Action, - template< typename... > - class Control, - typename ParseInput, - typename... States > - [[nodiscard]] static bool match( ParseInput& in, States&&... st ) - { - while( Control< Rule >::template match< A, rewind_mode::required, Action, Control >( in, st... ) ) { - } - return true; - } }; template< typename Rule, typename... Rules > diff --git a/packages/PEGTL/include/tao/pegtl/internal/star_must.hpp b/packages/PEGTL/include/tao/pegtl/internal/star_must.hpp index 8dff5771bef509bce1fb6634aea0f75006b89f7e..65474be3583a8d1755ca56a918b2a12cc7ee10d6 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/star_must.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/star_must.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -9,11 +9,11 @@ #error "Exception support required for tao/pegtl/internal/star_must.hpp" #else -#include "../config.hpp" - #include "if_must.hpp" #include "star.hpp" +#include "../config.hpp" + namespace TAO_PEGTL_NAMESPACE::internal { template< typename Cond, typename... Rules > diff --git a/packages/PEGTL/include/tao/pegtl/internal/star_partial.hpp b/packages/PEGTL/include/tao/pegtl/internal/star_partial.hpp new file mode 100644 index 0000000000000000000000000000000000000000..dbe1e04d2f3bdaca7c9945ed1b6b6d763ff45b05 --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/internal/star_partial.hpp @@ -0,0 +1,44 @@ +// Copyright (c) 2023 Dr. Colin Hirsch and Daniel Frey +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) + +#ifndef TAO_PEGTL_INTERNAL_STAR_PARTIAL_HPP +#define TAO_PEGTL_INTERNAL_STAR_PARTIAL_HPP + +#include "enable_control.hpp" + +#include "../apply_mode.hpp" +#include "../config.hpp" +#include "../rewind_mode.hpp" +#include "../type_list.hpp" + +namespace TAO_PEGTL_NAMESPACE::internal +{ + template< typename... Rules > + struct star_partial + { + using rule_t = star_partial; + using subs_t = type_list< Rules... >; + + template< apply_mode A, + rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename ParseInput, + typename... States > + [[nodiscard]] static bool match( ParseInput& in, States&&... st ) + { + while( ( Control< Rules >::template match< A, rewind_mode::required, Action, Control >( in, st... ) && ... ) ) { + } + return true; + } + }; + + template< typename... Rules > + inline constexpr bool enable_control< star_partial< Rules... > > = false; + +} // namespace TAO_PEGTL_NAMESPACE::internal + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/star_strict.hpp b/packages/PEGTL/include/tao/pegtl/internal/star_strict.hpp new file mode 100644 index 0000000000000000000000000000000000000000..633104ed60a8d48a19f1bb7cb5632bd94a812d7e --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/internal/star_strict.hpp @@ -0,0 +1,52 @@ +// Copyright (c) 2023 Dr. Colin Hirsch and Daniel Frey +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) + +#ifndef TAO_PEGTL_INTERNAL_STAR_STRICT_HPP +#define TAO_PEGTL_INTERNAL_STAR_STRICT_HPP + +#include "enable_control.hpp" +#include "seq.hpp" + +#include "../apply_mode.hpp" +#include "../config.hpp" +#include "../rewind_mode.hpp" +#include "../type_list.hpp" + +namespace TAO_PEGTL_NAMESPACE::internal +{ + template< typename Rule, typename... Rules > + struct star_strict + { + using rule_t = star_strict; + using subs_t = type_list< Rule, Rules... >; + + 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 ) + { + auto m = in.template auto_rewind< M >(); + using m_t = decltype( m ); + + while( Control< Rule >::template match< A, rewind_mode::required, Action, Control >( in, st... ) ) { + if( Control< seq< Rules... > >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ) { + continue; + } + return m( false ); + } + return m( true ); + } + }; + + template< typename... Rules > + inline constexpr bool enable_control< star_strict< Rules... > > = false; + +} // namespace TAO_PEGTL_NAMESPACE::internal + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/state.hpp b/packages/PEGTL/include/tao/pegtl/internal/state.hpp index 4ed8d22c859b10782101168cb60320d8da5047d0..ddfbad33a8c3c1f6dc29bd49f8ec3a7d8c9bc40f 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/state.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/state.hpp @@ -1,12 +1,10 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_STATE_HPP #define TAO_PEGTL_INTERNAL_STATE_HPP -#include "../config.hpp" - #include <type_traits> #include "dependent_false.hpp" @@ -15,6 +13,7 @@ #include "success.hpp" #include "../apply_mode.hpp" +#include "../config.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/internal/strict.hpp b/packages/PEGTL/include/tao/pegtl/internal/strict.hpp new file mode 100644 index 0000000000000000000000000000000000000000..a4c0ba44f0d3b00c7d88752a3efa496e5daaadf3 --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/internal/strict.hpp @@ -0,0 +1,52 @@ +// Copyright (c) 2023 Dr. Colin Hirsch and Daniel Frey +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) + +#ifndef TAO_PEGTL_INTERNAL_STRICT_HPP +#define TAO_PEGTL_INTERNAL_STRICT_HPP + +#include "enable_control.hpp" +#include "seq.hpp" + +#include "../apply_mode.hpp" +#include "../config.hpp" +#include "../rewind_mode.hpp" +#include "../type_list.hpp" + +namespace TAO_PEGTL_NAMESPACE::internal +{ + template< typename Rule, typename... Rules > + struct strict + { + using rule_t = strict; + using subs_t = type_list< Rule, Rules... >; + + 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 ) + { + auto m = in.template auto_rewind< M >(); + using m_t = decltype( m ); + + if( Control< Rule >::template match< A, rewind_mode::required, Action, Control >( in, st... ) ) { + if( Control< seq< Rules... > >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ) { + return m( true ); + } + return m( false ); + } + return m( true ); + } + }; + + template< typename... Rules > + inline constexpr bool enable_control< strict< Rules... > > = false; + +} // namespace TAO_PEGTL_NAMESPACE::internal + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/string.hpp b/packages/PEGTL/include/tao/pegtl/internal/string.hpp index 4ad5fcb548ef922fa21b4e3353d9d7eda83d53d1..9fadadaaa8c8d7cf1156900687421e4a696e25da 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/string.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/string.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -8,14 +8,13 @@ #include <cstring> #include <utility> -#include "../config.hpp" - #include "bump_help.hpp" #include "enable_control.hpp" #include "one.hpp" #include "result_on_found.hpp" #include "success.hpp" +#include "../config.hpp" #include "../type_list.hpp" namespace TAO_PEGTL_NAMESPACE::internal @@ -44,8 +43,16 @@ namespace TAO_PEGTL_NAMESPACE::internal using rule_t = string; using subs_t = empty_list; - template< int Eol > - static constexpr bool can_match_eol = one< result_on_found::success, peek_char, Cs... >::template can_match_eol< Eol >; + [[nodiscard]] static constexpr bool test_one( const char c ) noexcept + { + static_assert( sizeof...( Cs ) == 1 ); + return one< result_on_found::success, peek_char, Cs... >::test_one( c ); + } + + [[nodiscard]] static constexpr bool test_any( const char c ) noexcept + { + return one< result_on_found::success, peek_char, Cs... >::test_one( c ); + } template< typename ParseInput > [[nodiscard]] static bool match( ParseInput& in ) noexcept( noexcept( in.size( 0 ) ) ) diff --git a/packages/PEGTL/include/tao/pegtl/internal/success.hpp b/packages/PEGTL/include/tao/pegtl/internal/success.hpp index 706122bd578b2e98ae425d563556e5bbc91addd3..ea98b13d36d0a714b721ab87ea4ea6dcf58b51aa 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/success.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/success.hpp @@ -1,14 +1,13 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_SUCCESS_HPP #define TAO_PEGTL_INTERNAL_SUCCESS_HPP -#include "../config.hpp" - #include "enable_control.hpp" +#include "../config.hpp" #include "../type_list.hpp" namespace TAO_PEGTL_NAMESPACE::internal diff --git a/packages/PEGTL/include/tao/pegtl/internal/try_catch_type.hpp b/packages/PEGTL/include/tao/pegtl/internal/try_catch_type.hpp index ebeb3de01e3ede936f55682d9984f4616a26e930..f61a9ae9700c42fe6e7e5962da86bd833deb2a88 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/try_catch_type.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/try_catch_type.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -11,13 +11,12 @@ #include <type_traits> -#include "../config.hpp" - #include "enable_control.hpp" #include "seq.hpp" #include "success.hpp" #include "../apply_mode.hpp" +#include "../config.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" @@ -49,7 +48,7 @@ namespace TAO_PEGTL_NAMESPACE::internal typename... States > [[nodiscard]] static bool match( ParseInput& in, States&&... st ) { - auto m = in.template mark< M >(); + auto m = in.template auto_rewind< M >(); using m_t = decltype( m ); try { diff --git a/packages/PEGTL/include/tao/pegtl/internal/until.hpp b/packages/PEGTL/include/tao/pegtl/internal/until.hpp index b6efd3a18a963feae054cae9f05e363bb96145ba..f2b9a788281982d150644277536f71c911149bad 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/until.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/until.hpp @@ -1,12 +1,10 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_INTERNAL_UNTIL_HPP #define TAO_PEGTL_INTERNAL_UNTIL_HPP -#include "../config.hpp" - #include "bytes.hpp" #include "enable_control.hpp" #include "eof.hpp" @@ -15,6 +13,7 @@ #include "star.hpp" #include "../apply_mode.hpp" +#include "../config.hpp" #include "../rewind_mode.hpp" #include "../type_list.hpp" @@ -41,7 +40,7 @@ namespace TAO_PEGTL_NAMESPACE::internal typename... States > [[nodiscard]] static bool match( ParseInput& in, States&&... st ) { - auto m = in.template mark< M >(); + auto m = in.template auto_rewind< M >(); while( !Control< Cond >::template match< A, rewind_mode::required, Action, Control >( in, st... ) ) { if( in.empty() ) { @@ -69,7 +68,7 @@ namespace TAO_PEGTL_NAMESPACE::internal typename... States > [[nodiscard]] static bool match( ParseInput& in, States&&... st ) { - auto m = in.template mark< M >(); + auto m = in.template auto_rewind< M >(); using m_t = decltype( m ); while( !Control< Cond >::template match< A, rewind_mode::required, Action, Control >( in, st... ) ) { diff --git a/packages/PEGTL/include/tao/pegtl/internal/unwind_guard.hpp b/packages/PEGTL/include/tao/pegtl/internal/unwind_guard.hpp new file mode 100644 index 0000000000000000000000000000000000000000..d02e06f3c9b8c6b31dcd150b00a9fbbf780b1367 --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/internal/unwind_guard.hpp @@ -0,0 +1,40 @@ +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) + +#ifndef TAO_PEGTL_INTERNAL_UNWIND_GUARD_HPP +#define TAO_PEGTL_INTERNAL_UNWIND_GUARD_HPP + +#include <optional> +#include <utility> + +#include "../config.hpp" + +namespace TAO_PEGTL_NAMESPACE::internal +{ + template< typename Unwind > + struct unwind_guard + { + explicit unwind_guard( Unwind&& unwind_impl ) + : unwind( std::move( unwind_impl ) ) + {} + + ~unwind_guard() + { + if( unwind ) { + ( *unwind )(); + } + } + + unwind_guard( const unwind_guard& ) = delete; + unwind_guard( unwind_guard&& ) noexcept = delete; + + unwind_guard& operator=( const unwind_guard& ) = delete; + unwind_guard& operator=( unwind_guard&& ) noexcept = delete; + + std::optional< Unwind > unwind; + }; + +} // namespace TAO_PEGTL_NAMESPACE::internal + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/istream_input.hpp b/packages/PEGTL/include/tao/pegtl/istream_input.hpp index f37c1bc9653bddfaffaa5656d8e33914b1072278..a020734ce19c3b4e24a41327cce9152664cbd60c 100644 --- a/packages/PEGTL/include/tao/pegtl/istream_input.hpp +++ b/packages/PEGTL/include/tao/pegtl/istream_input.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/match.hpp b/packages/PEGTL/include/tao/pegtl/match.hpp index ad42582286d1a1e2364d302a60dec8a2aba9aa9a..f4c953f2458bd15fb62ada87ff0465a8e313870f 100644 --- a/packages/PEGTL/include/tao/pegtl/match.hpp +++ b/packages/PEGTL/include/tao/pegtl/match.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -17,9 +17,10 @@ #include "internal/has_apply.hpp" #include "internal/has_apply0.hpp" #include "internal/has_unwind.hpp" -#include "internal/marker.hpp" #include "internal/missing_apply.hpp" #include "internal/missing_apply0.hpp" +#include "internal/rewind_guard.hpp" +#include "internal/unwind_guard.hpp" #if defined( _MSC_VER ) #pragma warning( push ) @@ -73,13 +74,12 @@ namespace TAO_PEGTL_NAMESPACE { #if defined( __cpp_exceptions ) if constexpr( has_unwind< Control< Rule >, void, const ParseInput&, States... > ) { - try { - return match_no_control< Rule, A, M, Action, Control >( in, st... ); - } - catch( ... ) { + unwind_guard ug( [ & ] { Control< Rule >::unwind( static_cast< const ParseInput& >( in ), st... ); - throw; - } + } ); + const auto result = match_no_control< Rule, A, M, Action, Control >( in, st... ); + ug.unwind.reset(); + return result; } else { return match_no_control< Rule, A, M, Action, Control >( in, st... ); @@ -108,9 +108,9 @@ namespace TAO_PEGTL_NAMESPACE else { constexpr bool enable_action = ( A == apply_mode::action ); - using iterator_t = typename ParseInput::iterator_t; - constexpr bool has_apply_void = enable_action && internal::has_apply< Control< Rule >, void, Action, const iterator_t&, const ParseInput&, States... >; - constexpr bool has_apply_bool = enable_action && internal::has_apply< Control< Rule >, bool, Action, const iterator_t&, const ParseInput&, States... >; + using frobnicator_t = typename ParseInput::frobnicator_t; + constexpr bool has_apply_void = enable_action && internal::has_apply< Control< Rule >, void, Action, const frobnicator_t&, const ParseInput&, States... >; + constexpr bool has_apply_bool = enable_action && internal::has_apply< Control< Rule >, bool, Action, const frobnicator_t&, const ParseInput&, States... >; constexpr bool has_apply = has_apply_void || has_apply_bool; constexpr bool has_apply0_void = enable_action && internal::has_apply0< Control< Rule >, void, Action, const ParseInput&, States... >; @@ -135,17 +135,17 @@ namespace TAO_PEGTL_NAMESPACE constexpr bool is_maybe_nothing = std::is_base_of_v< maybe_nothing, Action< Rule > >; static_assert( !enable_action || !validate_nothing || is_nothing || is_maybe_nothing || has_apply || has_apply0, "either apply() or apply0() must be defined" ); - constexpr bool use_marker = has_apply || has_apply0_bool; + constexpr bool use_guard = has_apply || has_apply0_bool; - auto m = in.template mark< ( use_marker ? rewind_mode::required : rewind_mode::dontcare ) >(); + auto m = in.template auto_rewind< ( use_guard ? rewind_mode::required : rewind_mode::dontcare ) >(); Control< Rule >::start( static_cast< const ParseInput& >( in ), st... ); - auto result = internal::match_control_unwind< Rule, A, ( use_marker ? rewind_mode::active : M ), Action, Control >( in, st... ); + auto result = internal::match_control_unwind< Rule, A, ( use_guard ? rewind_mode::active : M ), Action, Control >( in, st... ); if( result ) { if constexpr( has_apply_void ) { - Control< Rule >::template apply< Action >( m.iterator(), static_cast< const ParseInput& >( in ), st... ); + Control< Rule >::template apply< Action >( m.frobnicator(), static_cast< const ParseInput& >( in ), st... ); } else if constexpr( has_apply_bool ) { - result = Control< Rule >::template apply< Action >( m.iterator(), static_cast< const ParseInput& >( in ), st... ); + result = Control< Rule >::template apply< Action >( m.frobnicator(), static_cast< const ParseInput& >( in ), st... ); } else if constexpr( has_apply0_void ) { Control< Rule >::template apply0< Action >( static_cast< const ParseInput& >( in ), st... ); diff --git a/packages/PEGTL/include/tao/pegtl/memory_input.hpp b/packages/PEGTL/include/tao/pegtl/memory_input.hpp index c20887131eb2beff684f74217df55ea5c90f31b0..93702353f9dddb13f5617f2116b8b77ce0a5d521 100644 --- a/packages/PEGTL/include/tao/pegtl/memory_input.hpp +++ b/packages/PEGTL/include/tao/pegtl/memory_input.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -25,8 +25,8 @@ #include "internal/at.hpp" #include "internal/bump.hpp" #include "internal/eolf.hpp" -#include "internal/iterator.hpp" -#include "internal/marker.hpp" +#include "internal/frobnicator.hpp" +#include "internal/rewind_guard.hpp" #include "internal/until.hpp" namespace TAO_PEGTL_NAMESPACE @@ -40,10 +40,10 @@ namespace TAO_PEGTL_NAMESPACE class memory_input_base< tracking_mode::eager, Eol, Source > { public: - using iterator_t = internal::iterator; + using frobnicator_t = internal::frobnicator; template< typename T > - memory_input_base( const iterator_t& in_begin, const char* in_end, T&& in_source ) noexcept( std::is_nothrow_constructible_v< Source, T&& > ) + memory_input_base( const frobnicator_t& in_begin, const char* in_end, T&& in_source ) noexcept( std::is_nothrow_constructible_v< Source, T&& > ) : m_begin( in_begin.data ), m_current( in_begin ), m_end( in_end ), @@ -111,7 +111,7 @@ namespace TAO_PEGTL_NAMESPACE internal::bump_to_next_line( m_current, in_count ); } - [[nodiscard]] TAO_PEGTL_NAMESPACE::position position( const iterator_t& it ) const + [[nodiscard]] TAO_PEGTL_NAMESPACE::position position( const frobnicator_t& it ) const { return TAO_PEGTL_NAMESPACE::position( it, m_source ); } @@ -130,7 +130,7 @@ namespace TAO_PEGTL_NAMESPACE protected: const char* const m_begin; - iterator_t m_current; + frobnicator_t m_current; const char* m_end; const Source m_source; @@ -142,10 +142,10 @@ namespace TAO_PEGTL_NAMESPACE class memory_input_base< tracking_mode::lazy, Eol, Source > { public: - using iterator_t = const char*; + using frobnicator_t = const char*; template< typename T > - memory_input_base( const internal::iterator& in_begin, const char* in_end, T&& in_source ) noexcept( std::is_nothrow_constructible_v< Source, T&& > ) + memory_input_base( const internal::frobnicator& in_begin, const char* in_end, T&& in_source ) noexcept( std::is_nothrow_constructible_v< Source, T&& > ) : m_begin( in_begin ), m_current( in_begin.data ), m_end( in_end ), @@ -203,10 +203,10 @@ namespace TAO_PEGTL_NAMESPACE m_current += in_count; } - [[nodiscard]] TAO_PEGTL_NAMESPACE::position position( const iterator_t it ) const + [[nodiscard]] TAO_PEGTL_NAMESPACE::position position( const frobnicator_t it ) const { - internal::iterator c( m_begin ); - internal::bump( c, std::size_t( it - m_begin.data ), Eol::ch ); + internal::frobnicator c( m_begin ); + internal::bump( c, static_cast< std::size_t >( it - m_begin.data ), Eol::ch ); return TAO_PEGTL_NAMESPACE::position( c, m_source ); } @@ -217,8 +217,8 @@ namespace TAO_PEGTL_NAMESPACE } protected: - const internal::iterator m_begin; - iterator_t m_current; + const internal::frobnicator m_begin; + frobnicator_t m_current; const char* m_end; const Source m_source; @@ -238,7 +238,7 @@ namespace TAO_PEGTL_NAMESPACE using eol_t = Eol; using source_t = Source; - using typename internal::memory_input_base< P, Eol, Source >::iterator_t; + using typename internal::memory_input_base< P, Eol, Source >::frobnicator_t; using action_t = internal::action_input< memory_input >; @@ -305,29 +305,29 @@ namespace TAO_PEGTL_NAMESPACE return static_cast< std::uint8_t >( peek_char( offset ) ); } - [[nodiscard]] iterator_t& iterator() noexcept + [[nodiscard]] frobnicator_t& frobnicator() noexcept { return this->m_current; } - [[nodiscard]] const iterator_t& iterator() const noexcept + [[nodiscard]] const frobnicator_t& frobnicator() const noexcept { return this->m_current; } using internal::memory_input_base< P, Eol, Source >::restart; - template< rewind_mode M > - void restart( const internal::marker< iterator_t, M >& m ) noexcept + template< rewind_mode M, typename ParseInput > + void restart( const internal::rewind_guard< M, ParseInput >& m ) noexcept { - iterator() = m.iterator(); + this->m_current = m.frobnicator(); } using internal::memory_input_base< P, Eol, Source >::position; [[nodiscard]] TAO_PEGTL_NAMESPACE::position position() const { - return position( iterator() ); + return position( frobnicator() ); } void discard() const noexcept {} @@ -335,9 +335,19 @@ namespace TAO_PEGTL_NAMESPACE void require( const std::size_t /*unused*/ ) const noexcept {} template< rewind_mode M > - [[nodiscard]] internal::marker< iterator_t, M > mark() noexcept + [[nodiscard]] internal::rewind_guard< M, memory_input > auto_rewind() noexcept + { + return internal::rewind_guard< M, memory_input >( this ); + } + + [[nodiscard]] const frobnicator_t& rewind_save() noexcept + { + return this->m_current; + } + + void rewind_restore( const frobnicator_t& data ) noexcept { - return internal::marker< iterator_t, M >( iterator() ); + this->m_current = data; } [[nodiscard]] const char* at( const TAO_PEGTL_NAMESPACE::position& p ) const noexcept @@ -362,7 +372,7 @@ namespace TAO_PEGTL_NAMESPACE [[nodiscard]] std::string_view line_at( const TAO_PEGTL_NAMESPACE::position& p ) const noexcept { const char* b = begin_of_line( p ); - return std::string_view( b, static_cast< std::size_t >( end_of_line( p ) - b ) ); + return { b, static_cast< std::size_t >( end_of_line( p ) - b ) }; } void private_set_end( const char* new_end ) noexcept diff --git a/packages/PEGTL/include/tao/pegtl/mmap_input.hpp b/packages/PEGTL/include/tao/pegtl/mmap_input.hpp index 759ea7035521ff20aac72e5a8d0068f9c25c26fb..83f69158b4c6d4b682569395ecad35404ec59cec 100644 --- a/packages/PEGTL/include/tao/pegtl/mmap_input.hpp +++ b/packages/PEGTL/include/tao/pegtl/mmap_input.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -13,49 +13,18 @@ #include "tracking_mode.hpp" #include "internal/filesystem.hpp" +#include "internal/mmap_file.hpp" #include "internal/path_to_string.hpp" -#if defined( __unix__ ) || ( defined( __APPLE__ ) && defined( __MACH__ ) ) -#include <unistd.h> // Required for _POSIX_MAPPED_FILES -#endif - -#if defined( _POSIX_MAPPED_FILES ) -#include "internal/file_mapper_posix.hpp" -#elif defined( _WIN32 ) -#include "internal/file_mapper_win32.hpp" -#else -#endif - namespace TAO_PEGTL_NAMESPACE { - namespace internal - { - struct mmap_holder - { - const file_mapper data; - - explicit mmap_holder( const internal::filesystem::path& path ) - : data( path ) - {} - - mmap_holder( const mmap_holder& ) = delete; - mmap_holder( mmap_holder&& ) = delete; - - ~mmap_holder() = default; - - mmap_holder& operator=( const mmap_holder& ) = delete; - mmap_holder& operator=( mmap_holder&& ) = delete; - }; - - } // namespace internal - template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > struct mmap_input - : private internal::mmap_holder, + : private internal::mmap_file, public memory_input< P, Eol > { mmap_input( const internal::filesystem::path& path, const std::string& source ) - : internal::mmap_holder( path ), + : internal::mmap_file( path ), memory_input< P, Eol >( data.begin(), data.end(), source ) {} diff --git a/packages/PEGTL/include/tao/pegtl/must_if.hpp b/packages/PEGTL/include/tao/pegtl/must_if.hpp index 875e7e9c2a20e0a6c948dfcbeeba0f42e7ff4a4a..f53b045836dd93680e619701ef59721369d59a48 100644 --- a/packages/PEGTL/include/tao/pegtl/must_if.hpp +++ b/packages/PEGTL/include/tao/pegtl/must_if.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -14,6 +14,8 @@ #include "config.hpp" #include "normal.hpp" +#include "internal/has_error_message.hpp" + namespace TAO_PEGTL_NAMESPACE { namespace internal @@ -47,9 +49,6 @@ namespace TAO_PEGTL_NAMESPACE template< typename ParseInput, typename... States > [[noreturn]] static void raise( const ParseInput& in, [[maybe_unused]] States&&... st ) { - if constexpr( RequireMessage ) { - static_assert( Errors::template message< Rule > != nullptr ); - } if constexpr( Errors::template message< Rule > != nullptr ) { constexpr const char* p = Errors::template message< Rule >; throw parse_error( p, in ); @@ -58,6 +57,9 @@ namespace TAO_PEGTL_NAMESPACE #endif } else { + if constexpr( !internal::has_error_message< Rule > ) { + static_assert( !RequireMessage, "explicit error message required for Rule" ); + } Base< Rule >::raise( in, st... ); } } diff --git a/packages/PEGTL/include/tao/pegtl/normal.hpp b/packages/PEGTL/include/tao/pegtl/normal.hpp index bdbdd85eedf79a606db8a376c473e7a6ac9f47c5..d370d8c2fc747d215987a96bd76f82c309adc62a 100644 --- a/packages/PEGTL/include/tao/pegtl/normal.hpp +++ b/packages/PEGTL/include/tao/pegtl/normal.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -16,6 +16,7 @@ #include "rewind_mode.hpp" #include "internal/enable_control.hpp" +#include "internal/has_error_message.hpp" #include "internal/has_match.hpp" #if defined( __cpp_exceptions ) @@ -48,7 +49,12 @@ namespace TAO_PEGTL_NAMESPACE [[noreturn]] static void raise( const ParseInput& in, States&&... /*unused*/ ) { #if defined( __cpp_exceptions ) - throw parse_error( "parse error matching " + std::string( demangle< Rule >() ), in ); + if constexpr( internal::has_error_message< Rule > ) { + throw parse_error( Rule::error_message, in ); + } + else { + throw parse_error( "parse error matching " + std::string( demangle< Rule >() ), in ); + } #else static_assert( internal::dependent_false< Rule >, "exception support required for normal< Rule >::raise()" ); (void)in; @@ -57,10 +63,10 @@ namespace TAO_PEGTL_NAMESPACE } template< template< typename... > class Action, - typename Iterator, + typename Frobnicator, typename ParseInput, typename... States > - static auto apply( const Iterator& begin, const ParseInput& in, States&&... st ) noexcept( noexcept( Action< Rule >::apply( std::declval< const typename ParseInput::action_t& >(), st... ) ) ) + static auto apply( const Frobnicator& begin, const ParseInput& in, States&&... st ) noexcept( noexcept( Action< Rule >::apply( std::declval< const typename ParseInput::action_t& >(), st... ) ) ) -> decltype( Action< Rule >::apply( std::declval< const typename ParseInput::action_t& >(), st... ) ) { const typename ParseInput::action_t action_input( begin, in ); diff --git a/packages/PEGTL/include/tao/pegtl/nothing.hpp b/packages/PEGTL/include/tao/pegtl/nothing.hpp index 28b68f8449c09c81303f53d9a965aadcac05bf74..04754dc2fd1e9a63a701f2a5aae77106500a1e2e 100644 --- a/packages/PEGTL/include/tao/pegtl/nothing.hpp +++ b/packages/PEGTL/include/tao/pegtl/nothing.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/parse.hpp b/packages/PEGTL/include/tao/pegtl/parse.hpp index 962f3051a2bdc94af2efc7157ba5048e64714db0..da05d0a2150893c99997bc1d28125f43b4eb1fc3 100644 --- a/packages/PEGTL/include/tao/pegtl/parse.hpp +++ b/packages/PEGTL/include/tao/pegtl/parse.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -36,7 +36,7 @@ namespace TAO_PEGTL_NAMESPACE template< typename... > class Action = nothing, template< typename... > class Control = normal, apply_mode A = apply_mode::action, - rewind_mode M = rewind_mode::required, + rewind_mode M = rewind_mode::dontcare, typename ParseInput, typename... States > auto parse( ParseInput&& in, States&&... st ) @@ -48,7 +48,7 @@ namespace TAO_PEGTL_NAMESPACE template< typename... > class Action = nothing, template< typename... > class Control = normal, apply_mode A = apply_mode::action, - rewind_mode M = rewind_mode::required, + rewind_mode M = rewind_mode::dontcare, typename Outer, typename ParseInput, typename... States > diff --git a/packages/PEGTL/include/tao/pegtl/parse_error.hpp b/packages/PEGTL/include/tao/pegtl/parse_error.hpp index 6a0ad019510caf8aa95132f1766d3806b11f99c7..954e5717ace970cdb0e1003cc918ad17da2a56ae 100644 --- a/packages/PEGTL/include/tao/pegtl/parse_error.hpp +++ b/packages/PEGTL/include/tao/pegtl/parse_error.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/position.hpp b/packages/PEGTL/include/tao/pegtl/position.hpp index 78ed32c9f35db5355f4df69ea6f43beed440d1e8..af20a0d5511383159767cb6c31b461f81a2c786e 100644 --- a/packages/PEGTL/include/tao/pegtl/position.hpp +++ b/packages/PEGTL/include/tao/pegtl/position.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -13,7 +13,7 @@ #include "config.hpp" -#include "internal/iterator.hpp" +#include "internal/frobnicator.hpp" namespace TAO_PEGTL_NAMESPACE { @@ -21,35 +21,14 @@ namespace TAO_PEGTL_NAMESPACE { position() = delete; -#if defined( __GNUC__ ) && !defined( __clang__ ) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" -#endif - position( position&& p ) noexcept - : byte( p.byte ), - line( p.line ), - column( p.column ), - source( std::move( p.source ) ) - {} -#if defined( __GNUC__ ) && !defined( __clang__ ) -#pragma GCC diagnostic pop -#endif - + position( position&& ) noexcept = default; position( const position& ) = default; - position& operator=( position&& p ) noexcept - { - byte = p.byte; - line = p.line; - column = p.column; - source = std::move( p.source ); - return *this; - } - + position& operator=( position&& p ) noexcept = default; position& operator=( const position& ) = default; template< typename T > - position( const internal::iterator& in_iter, T&& in_source ) + position( const internal::frobnicator& in_iter, T&& in_source ) : byte( in_iter.byte ), line( in_iter.line ), column( in_iter.column ), @@ -61,7 +40,7 @@ namespace TAO_PEGTL_NAMESPACE : byte( in_byte ), line( in_line ), column( in_column ), - source( in_source ) + source( std::forward< T >( in_source ) ) {} ~position() = default; @@ -72,12 +51,12 @@ namespace TAO_PEGTL_NAMESPACE std::string source; }; - inline bool operator==( const position& lhs, const position& rhs ) noexcept + [[nodiscard]] inline bool operator==( const position& lhs, const position& rhs ) noexcept { return ( lhs.byte == rhs.byte ) && ( lhs.source == rhs.source ); } - inline bool operator!=( const position& lhs, const position& rhs ) noexcept + [[nodiscard]] inline bool operator!=( const position& lhs, const position& rhs ) noexcept { return !( lhs == rhs ); } diff --git a/packages/PEGTL/include/tao/pegtl/read_input.hpp b/packages/PEGTL/include/tao/pegtl/read_input.hpp index adbad4ca0484f8aa3669e92948f4faa3bff023f5..b730aff8435cb7b2b2e4311445c8a48e6144faa8 100644 --- a/packages/PEGTL/include/tao/pegtl/read_input.hpp +++ b/packages/PEGTL/include/tao/pegtl/read_input.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -12,9 +12,9 @@ #include "string_input.hpp" #include "tracking_mode.hpp" -#include "internal/file_reader.hpp" #include "internal/filesystem.hpp" #include "internal/path_to_string.hpp" +#include "internal/read_file_stdio.hpp" namespace TAO_PEGTL_NAMESPACE { @@ -23,7 +23,7 @@ namespace TAO_PEGTL_NAMESPACE : string_input< P, Eol > { read_input( const internal::filesystem::path& path, const std::string& source ) - : string_input< P, Eol >( internal::file_reader( path ).read(), source ) + : string_input< P, Eol >( internal::read_file_stdio( path ).read_string(), source ) {} explicit read_input( const internal::filesystem::path& path ) @@ -31,7 +31,7 @@ namespace TAO_PEGTL_NAMESPACE {} read_input( FILE* file, const internal::filesystem::path& path, const std::string& source ) - : string_input< P, Eol >( internal::file_reader( file, path ).read(), source ) + : string_input< P, Eol >( internal::read_file_stdio( file, path ).read_string(), source ) {} read_input( FILE* file, const internal::filesystem::path& path ) diff --git a/packages/PEGTL/include/tao/pegtl/require_apply.hpp b/packages/PEGTL/include/tao/pegtl/require_apply.hpp index 7eaa5cc07bc2d85f5ed8d3037b03e8200d8110d1..b574cb3a25da7d832272537fc98dd4fde8ad50fc 100644 --- a/packages/PEGTL/include/tao/pegtl/require_apply.hpp +++ b/packages/PEGTL/include/tao/pegtl/require_apply.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/require_apply0.hpp b/packages/PEGTL/include/tao/pegtl/require_apply0.hpp index a20f0a21085a4db72278511ecc1b2df93c3dc936..fbbf59f8231cde44af1d6278404e8115fd7569be 100644 --- a/packages/PEGTL/include/tao/pegtl/require_apply0.hpp +++ b/packages/PEGTL/include/tao/pegtl/require_apply0.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/rewind_mode.hpp b/packages/PEGTL/include/tao/pegtl/rewind_mode.hpp index b97cbcfaf4e53593c7390b2170c22eb11226371e..e51a4281ea42dba18e91967eb3b53c10b423986c 100644 --- a/packages/PEGTL/include/tao/pegtl/rewind_mode.hpp +++ b/packages/PEGTL/include/tao/pegtl/rewind_mode.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/rules.hpp b/packages/PEGTL/include/tao/pegtl/rules.hpp index 59d73c742fae9131514ecd01aa421a71a3191ba5..9e4c111e1decf4847f649d3c7395dc26243b5b59 100644 --- a/packages/PEGTL/include/tao/pegtl/rules.hpp +++ b/packages/PEGTL/include/tao/pegtl/rules.hpp @@ -1,10 +1,12 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_RULES_HPP #define TAO_PEGTL_RULES_HPP +#include <cstddef> + #include "config.hpp" #include "parse_error.hpp" @@ -26,6 +28,7 @@ namespace TAO_PEGTL_NAMESPACE template< typename... Rules > struct enable : internal::enable< Rules... > {}; struct eof : internal::eof {}; struct eolf : internal::eolf {}; + struct everything : internal::everything< std::size_t > {}; struct failure : internal::failure {}; template< typename Rule, typename... Actions > struct if_apply : internal::if_apply< Rule, Actions... > {}; template< typename Cond, typename Then, typename Else > struct if_then_else : internal::if_then_else< Cond, Then, Else > {}; @@ -38,6 +41,7 @@ namespace TAO_PEGTL_NAMESPACE template< typename... Rules > struct opt : internal::opt< Rules... > {}; template< typename Rule, typename Pad1, typename Pad2 = Pad1 > struct pad : internal::pad< Rule, Pad1, Pad2 > {}; template< typename Rule, typename Pad > struct pad_opt : internal::pad_opt< Rule, Pad > {}; + template< typename Rule, typename... Rules > struct partial : internal::partial< Rule, Rules... > {}; template< typename Rule, typename... Rules > struct plus : internal::plus< Rule, Rules... > {}; template< typename Head, typename... Rules > struct rematch : internal::rematch< Head, Rules... > {}; template< unsigned Num, typename... Rules > struct rep : internal::rep< Num, Rules... > {}; @@ -49,7 +53,10 @@ namespace TAO_PEGTL_NAMESPACE template< typename... Rules > struct seq : internal::seq< Rules... > {}; template< typename... Rules > struct sor : internal::sor< Rules... > {}; template< typename Rule, typename... Rules > struct star : internal::star< Rule, Rules... > {}; + template< typename Rule, typename... Rules > struct star_partial : internal::star_partial< Rule, Rules... > {}; + template< typename Rule, typename... Rules > struct star_strict : internal::star_strict< Rule, Rules... > {}; template< typename State, typename... Rules > struct state : internal::state< State, Rules... > {}; + template< typename Rule, typename... Rules > struct strict : internal::strict< Rule, Rules... > {}; struct success : internal::success {}; template< typename Cond, typename... Rules > struct until : internal::until< Cond, Rules... > {}; @@ -61,6 +68,9 @@ namespace TAO_PEGTL_NAMESPACE template< typename... Rules > struct must : internal::must< Rules... > {}; template< typename Cond, typename... Rules > struct opt_must : internal::if_must< true, Cond, Rules... > {}; template< typename Exception > struct raise : internal::raise< Exception > {}; + template< char... Cs > struct raise_message : internal::raise< raise_message< Cs... > > { + static constexpr const char error_message[] = { Cs..., 0 }; + }; template< typename Cond, typename... Rules > struct star_must : internal::star_must< Cond, Rules... > {}; template< typename... Rules > struct try_catch : internal::try_catch_type< parse_error, Rules... > {}; template< typename Exception, typename... Rules > struct try_catch_type : internal::seq< internal::try_catch_type< Exception, Rules... > > {}; diff --git a/packages/PEGTL/include/tao/pegtl/string_input.hpp b/packages/PEGTL/include/tao/pegtl/string_input.hpp index f66ee24c8fb8ddd348efeb5393187852e6783274..91b66bef021939e81e3a690ded40ffe5f8be2e69 100644 --- a/packages/PEGTL/include/tao/pegtl/string_input.hpp +++ b/packages/PEGTL/include/tao/pegtl/string_input.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/tracking_mode.hpp b/packages/PEGTL/include/tao/pegtl/tracking_mode.hpp index 6e0f06b8fd5b74934c4a68d84502366eeaf639ad..a15e58d4346d702376c3f17fe52ebe3b83bf5f87 100644 --- a/packages/PEGTL/include/tao/pegtl/tracking_mode.hpp +++ b/packages/PEGTL/include/tao/pegtl/tracking_mode.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/type_list.hpp b/packages/PEGTL/include/tao/pegtl/type_list.hpp index f0704aabea50744da880609ee97aeb47eb8b41e2..3f30b0cad4dff0b79e38ca4162f3aae5598fb059 100644 --- a/packages/PEGTL/include/tao/pegtl/type_list.hpp +++ b/packages/PEGTL/include/tao/pegtl/type_list.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/utf8.hpp b/packages/PEGTL/include/tao/pegtl/utf8.hpp index 95b45ef49ccab20bb6a8b8bab23ad708104f4410..302b4b0ca5efb340c9250ed6b3710f9e5706754b 100644 --- a/packages/PEGTL/include/tao/pegtl/utf8.hpp +++ b/packages/PEGTL/include/tao/pegtl/utf8.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/include/tao/pegtl/version.hpp b/packages/PEGTL/include/tao/pegtl/version.hpp index 034954416633cf614672005f8047bd3b275a35d4..cc4023fd6c8af3097cb61315c5aa55ed8d5937cf 100644 --- a/packages/PEGTL/include/tao/pegtl/version.hpp +++ b/packages/PEGTL/include/tao/pegtl/version.hpp @@ -1,14 +1,14 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #ifndef TAO_PEGTL_VERSION_HPP #define TAO_PEGTL_VERSION_HPP -#define TAO_PEGTL_VERSION "3.3.0" +#define TAO_PEGTL_VERSION "4.0.0" -#define TAO_PEGTL_VERSION_MAJOR 3 -#define TAO_PEGTL_VERSION_MINOR 3 +#define TAO_PEGTL_VERSION_MAJOR 4 +#define TAO_PEGTL_VERSION_MINOR 0 #define TAO_PEGTL_VERSION_PATCH 0 #endif diff --git a/packages/PEGTL/include/tao/pegtl/visit.hpp b/packages/PEGTL/include/tao/pegtl/visit.hpp index 81ca6ac75cb151d9694b72f15b8f0196f66f1f52..4fa3a1380163d1bb87d82b1b408f731f81fe53ac 100644 --- a/packages/PEGTL/include/tao/pegtl/visit.hpp +++ b/packages/PEGTL/include/tao/pegtl/visit.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/CMakeLists.txt b/packages/PEGTL/src/example/pegtl/CMakeLists.txt index 236d365ddc71c1ce53e984963df5abd4c026765e..9fcabc707f20654bb6e8e9fd24a84f714ac84321 100644 --- a/packages/PEGTL/src/example/pegtl/CMakeLists.txt +++ b/packages/PEGTL/src/example/pegtl/CMakeLists.txt @@ -27,6 +27,7 @@ set(example_sources parse_tree.cpp parse_tree_user_state.cpp proto3.cpp + random_order.cpp recover.cpp s_expression.cpp sum.cpp diff --git a/packages/PEGTL/src/example/pegtl/abnf2pegtl.cpp b/packages/PEGTL/src/example/pegtl/abnf2pegtl.cpp index 3fd3b976941bb5c87770f31c33dbb46f14f886a1..dcdfd3548a4d2ee4f5e0bd8066db2e46f13cdfd2 100644 --- a/packages/PEGTL/src/example/pegtl/abnf2pegtl.cpp +++ b/packages/PEGTL/src/example/pegtl/abnf2pegtl.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -38,7 +38,7 @@ namespace TAO_PEGTL_NAMESPACE namespace { - std::string prefix = "tao::pegtl::"; + std::string prefix = "TAO_PEGTL_NAMESPACE::"; std::set< std::string > keywords = { "alignas", @@ -178,7 +178,7 @@ namespace TAO_PEGTL_NAMESPACE return v.substr( pos ); } - void shift( internal::iterator& it, int delta ) + void shift( internal::frobnicator& it, int delta ) { it.data += delta; it.byte += delta; diff --git a/packages/PEGTL/src/example/pegtl/analyze.cpp b/packages/PEGTL/src/example/pegtl/analyze.cpp index 8f7aa0057d4f51ff363936f6dfb70db07993dfa8..fae02a098eaa54340a045665701401b5cc703b80 100644 --- a/packages/PEGTL/src/example/pegtl/analyze.cpp +++ b/packages/PEGTL/src/example/pegtl/analyze.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/calculator.cpp b/packages/PEGTL/src/example/pegtl/calculator.cpp index ed9fb2b05512e06196ac23e136457b869c9fbb8d..76997f3fabf7014a900b740b78c5ee222e0109ab 100644 --- a/packages/PEGTL/src/example/pegtl/calculator.cpp +++ b/packages/PEGTL/src/example/pegtl/calculator.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -183,7 +183,7 @@ namespace calculator // Here the actual grammar starts. - using namespace tao::pegtl; + using namespace TAO_PEGTL_NAMESPACE; // Comments are introduced by a '#' and proceed to the end-of-line/file. diff --git a/packages/PEGTL/src/example/pegtl/chomsky_hierarchy.cpp b/packages/PEGTL/src/example/pegtl/chomsky_hierarchy.cpp index cb671c0e8894908e1dd3cf8f53bc852a617a2623..5832f3beeb656798319b8e43353683fd8d6b1484 100644 --- a/packages/PEGTL/src/example/pegtl/chomsky_hierarchy.cpp +++ b/packages/PEGTL/src/example/pegtl/chomsky_hierarchy.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/csv1.cpp b/packages/PEGTL/src/example/pegtl/csv1.cpp index 826363fde8d3b6dc213a591e3db7372c8f341444..4d9d24b31f4ad682f92f27d6f14ed56adb2b84f2 100644 --- a/packages/PEGTL/src/example/pegtl/csv1.cpp +++ b/packages/PEGTL/src/example/pegtl/csv1.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/csv2.cpp b/packages/PEGTL/src/example/pegtl/csv2.cpp index c4aafd56ca8860ec60e9857011b7b71f5f0a8b96..ac0d52e6deebd97250293c7a35a0015f14910633 100644 --- a/packages/PEGTL/src/example/pegtl/csv2.cpp +++ b/packages/PEGTL/src/example/pegtl/csv2.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/double.hpp b/packages/PEGTL/src/example/pegtl/double.hpp index c79f5cc755659155e64db2edfef6be602b476f2a..50c23bafd45d1fa8f46254008d8877fa548450ee 100644 --- a/packages/PEGTL/src/example/pegtl/double.hpp +++ b/packages/PEGTL/src/example/pegtl/double.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/dynamic_match.cpp b/packages/PEGTL/src/example/pegtl/dynamic_match.cpp index bf1465066e88c21dbcb5703f7a84ca7cb971299e..76213ef020ba871b439d7bfd50f8fb5422087d99 100644 --- a/packages/PEGTL/src/example/pegtl/dynamic_match.cpp +++ b/packages/PEGTL/src/example/pegtl/dynamic_match.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/expression.cpp b/packages/PEGTL/src/example/pegtl/expression.cpp index 5602ad3f09fb464f4fff6d963c1239d8496506b6..12be3bb8ba98423fca18e0f810e06a3462add501 100644 --- a/packages/PEGTL/src/example/pegtl/expression.cpp +++ b/packages/PEGTL/src/example/pegtl/expression.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2021-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/hello_world.cpp b/packages/PEGTL/src/example/pegtl/hello_world.cpp index 8ecbdb813a87e41c1410da79e786acb9e507a9fb..40eb9dd92107e4495609f4fc70758ce3bcfdb1d7 100644 --- a/packages/PEGTL/src/example/pegtl/hello_world.cpp +++ b/packages/PEGTL/src/example/pegtl/hello_world.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/indent_aware.cpp b/packages/PEGTL/src/example/pegtl/indent_aware.cpp index 1462f89af04646a740182e9554e0b5c965f8585e..54cada30506a28998d591acd7f17f23600bd08fc 100644 --- a/packages/PEGTL/src/example/pegtl/indent_aware.cpp +++ b/packages/PEGTL/src/example/pegtl/indent_aware.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/iri.cpp b/packages/PEGTL/src/example/pegtl/iri.cpp index aed3e981bf7630fd85f8ea330b1e5b373b6e317b..bfc0d876f4bddf20bd52408ea69f314c241f48f1 100644 --- a/packages/PEGTL/src/example/pegtl/iri.cpp +++ b/packages/PEGTL/src/example/pegtl/iri.cpp @@ -1,5 +1,5 @@ -// Copyright (c) 2021 Kelvin Hammond -// Copyright (c) 2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2021-2023 Kelvin Hammond +// Copyright (c) 2021-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/json_analyze.cpp b/packages/PEGTL/src/example/pegtl/json_analyze.cpp index 9a23359a53f694f672c821f78eb24738a729762a..44a552faf067021208f597c04b9d44ac6b650a57 100644 --- a/packages/PEGTL/src/example/pegtl/json_analyze.cpp +++ b/packages/PEGTL/src/example/pegtl/json_analyze.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/json_ast.cpp b/packages/PEGTL/src/example/pegtl/json_ast.cpp index e227ea874f418f034b9de2411cd4b12157ad181c..1b96455ff45be4a983422c944533f4064d26fb6d 100644 --- a/packages/PEGTL/src/example/pegtl/json_ast.cpp +++ b/packages/PEGTL/src/example/pegtl/json_ast.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/json_build.cpp b/packages/PEGTL/src/example/pegtl/json_build.cpp index 00d90a587455f721b7e5541ad9bd454fc6762cc2..bf945b317b447e66164043e5a2e11f39036b20ff 100644 --- a/packages/PEGTL/src/example/pegtl/json_build.cpp +++ b/packages/PEGTL/src/example/pegtl/json_build.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/json_classes.hpp b/packages/PEGTL/src/example/pegtl/json_classes.hpp index 840804328240a2f5534642682740576bd1e9b97d..7585b270dade7919e8950d75f3f0166a88dfc946 100644 --- a/packages/PEGTL/src/example/pegtl/json_classes.hpp +++ b/packages/PEGTL/src/example/pegtl/json_classes.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/json_count.cpp b/packages/PEGTL/src/example/pegtl/json_count.cpp index f5de1e2ed3b342b84c26faa152ea9760ba2227b0..efda8bf012d3762b0ccac9ecaf9138bdd34477b4 100644 --- a/packages/PEGTL/src/example/pegtl/json_count.cpp +++ b/packages/PEGTL/src/example/pegtl/json_count.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/json_coverage.cpp b/packages/PEGTL/src/example/pegtl/json_coverage.cpp index 99bf55a14ef4d383ec3692fb95e891e038e00b98..d73124cf14f4608ac5b319aa60727731f7c5241e 100644 --- a/packages/PEGTL/src/example/pegtl/json_coverage.cpp +++ b/packages/PEGTL/src/example/pegtl/json_coverage.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/json_errors.hpp b/packages/PEGTL/src/example/pegtl/json_errors.hpp index 5dd28f0ac628f9f6fd7b0faaf46560bcaaa03026..9f5eac7733c88181ff9afcc41afb28e79fb2d758 100644 --- a/packages/PEGTL/src/example/pegtl/json_errors.hpp +++ b/packages/PEGTL/src/example/pegtl/json_errors.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/json_parse.cpp b/packages/PEGTL/src/example/pegtl/json_parse.cpp index cdff8772a535a1a275e5bac85504998063e0e506..1681988b051e7c76c345d2629cc997e6b84197c8 100644 --- a/packages/PEGTL/src/example/pegtl/json_parse.cpp +++ b/packages/PEGTL/src/example/pegtl/json_parse.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -6,6 +6,7 @@ #include <iostream> #include <tao/pegtl.hpp> +#include <tao/pegtl/contrib/input_with_depth.hpp> #include <tao/pegtl/contrib/json.hpp> #include <tao/pegtl/contrib/limit_depth.hpp> #include <tao/pegtl/contrib/trace.hpp> @@ -38,7 +39,7 @@ int main( int argc, char** argv ) // NOLINT(bugprone-exception-escape) return 1; } - pegtl::argv_input in( argv, 1 ); + pegtl::input_with_depth< pegtl::argv_input<> > in( argv, 1 ); #if defined( __cpp_exceptions ) try { pegtl::parse< example::grammar, example::action, example::control >( in ); diff --git a/packages/PEGTL/src/example/pegtl/json_print_debug.cpp b/packages/PEGTL/src/example/pegtl/json_print_debug.cpp index 8adadfdb0aad76e2b702a1fe9d8ca300c6c13e58..ee344aa815d53400ec71645c2d7b232842b52ae9 100644 --- a/packages/PEGTL/src/example/pegtl/json_print_debug.cpp +++ b/packages/PEGTL/src/example/pegtl/json_print_debug.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -9,6 +9,6 @@ int main() // NOLINT(bugprone-exception-escape) { - tao::pegtl::print_debug< tao::pegtl::json::text >( std::cout ); + TAO_PEGTL_NAMESPACE::print_debug< TAO_PEGTL_NAMESPACE::json::text >( std::cout ); return 0; } diff --git a/packages/PEGTL/src/example/pegtl/json_print_names.cpp b/packages/PEGTL/src/example/pegtl/json_print_names.cpp index 2537b7c06b18fb21e50266acc6fc72c00e913819..7df4fbe674e3180d8ecb8c3b3728d7436811f6eb 100644 --- a/packages/PEGTL/src/example/pegtl/json_print_names.cpp +++ b/packages/PEGTL/src/example/pegtl/json_print_names.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -9,6 +9,6 @@ int main() // NOLINT(bugprone-exception-escape) { - tao::pegtl::print_names< tao::pegtl::json::text >( std::cout ); + TAO_PEGTL_NAMESPACE::print_names< TAO_PEGTL_NAMESPACE::json::text >( std::cout ); return 0; } diff --git a/packages/PEGTL/src/example/pegtl/json_trace.cpp b/packages/PEGTL/src/example/pegtl/json_trace.cpp index 345118a29e0681f845d545883c1f3274808687e0..c6a1ce673f624533d6e3eeeb51cd5e3922976ea9 100644 --- a/packages/PEGTL/src/example/pegtl/json_trace.cpp +++ b/packages/PEGTL/src/example/pegtl/json_trace.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/json_unescape.hpp b/packages/PEGTL/src/example/pegtl/json_unescape.hpp index 210087e205d9bd27fa2ee19e9a3cadb7f47ad17d..d96367c3f34e15aa4095ad2fb353165ce56f821a 100644 --- a/packages/PEGTL/src/example/pegtl/json_unescape.hpp +++ b/packages/PEGTL/src/example/pegtl/json_unescape.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -13,17 +13,19 @@ namespace example { + namespace pegtl = TAO_PEGTL_NAMESPACE; + // Action class for parsing literal strings, uses the PEGTL unescape utilities, cf. unescape.cpp. // clang-format off template< typename Rule > struct json_unescape_action {}; - template<> struct json_unescape_action< TAO_PEGTL_NAMESPACE::json::unicode > : TAO_PEGTL_NAMESPACE::unescape::unescape_j {}; - template<> struct json_unescape_action< TAO_PEGTL_NAMESPACE::json::escaped_char > : TAO_PEGTL_NAMESPACE::unescape::unescape_c< TAO_PEGTL_NAMESPACE::json::escaped_char, '"', '\\', '/', '\b', '\f', '\n', '\r', '\t' > {}; - template<> struct json_unescape_action< TAO_PEGTL_NAMESPACE::json::unescaped > : TAO_PEGTL_NAMESPACE::unescape::append_all {}; + template<> struct json_unescape_action< pegtl::json::unicode > : pegtl::unescape::unescape_j {}; + template<> struct json_unescape_action< pegtl::json::escaped_char > : pegtl::unescape::unescape_c< pegtl::json::escaped_char, '"', '\\', '/', '\b', '\f', '\n', '\r', '\t' > {}; + template<> struct json_unescape_action< pegtl::json::unescaped > : pegtl::unescape::append_all {}; // clang-format on - using json_unescape = tao::pegtl::change_action_and_states< json_unescape_action, std::string >; + using json_unescape = pegtl::change_action_and_states< json_unescape_action, std::string >; } // namespace example diff --git a/packages/PEGTL/src/example/pegtl/lua53.hpp b/packages/PEGTL/src/example/pegtl/lua53.hpp index da57ea822bb17947e8725e32ceabd64ab5a84fa0..371843cfd3261602f51d5f963d03c39adfb79695 100644 --- a/packages/PEGTL/src/example/pegtl/lua53.hpp +++ b/packages/PEGTL/src/example/pegtl/lua53.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -14,6 +14,8 @@ namespace lua53 { + namespace pegtl = TAO_PEGTL_NAMESPACE; + // PEGTL grammar for the Lua 5.3.0 lexer and parser. // // The grammar here is not very similar to the grammar @@ -97,12 +99,12 @@ namespace lua53 // right padding is used. // clang-format off - struct short_comment : tao::pegtl::until< tao::pegtl::eolf > {}; - struct long_string : tao::pegtl::raw_string< '[', '=', ']' > {}; - struct comment : tao::pegtl::disable< tao::pegtl::two< '-' >, tao::pegtl::sor< long_string, short_comment > > {}; + struct short_comment : pegtl::until< pegtl::eolf > {}; + struct long_string : pegtl::raw_string< '[', '=', ']' > {}; + struct comment : pegtl::disable< pegtl::two< '-' >, pegtl::sor< long_string, short_comment > > {}; - struct sep : tao::pegtl::sor< tao::pegtl::ascii::space, comment > {}; - struct seps : tao::pegtl::star< sep > {}; + struct sep : pegtl::sor< pegtl::ascii::space, comment > {}; + struct seps : pegtl::star< sep > {}; struct str_and : TAO_PEGTL_STRING( "and" ) {}; struct str_break : TAO_PEGTL_STRING( "break" ) {}; @@ -132,9 +134,9 @@ namespace lua53 // 'keyword' rule. template< typename Key > - struct key : tao::pegtl::seq< Key, tao::pegtl::not_at< tao::pegtl::identifier_other > > {}; + struct key : pegtl::seq< Key, pegtl::not_at< pegtl::identifier_other > > {}; - struct sor_keyword : tao::pegtl::sor< str_and, str_break, str_do, str_elseif, str_else, str_end, str_false, str_for, str_function, str_goto, str_if, str_in, str_local, str_nil, str_not, str_repeat, str_return, str_then, str_true, str_until, str_while > {}; + struct sor_keyword : pegtl::sor< str_and, str_break, str_do, str_elseif, str_else, str_end, str_false, str_for, str_function, str_goto, str_if, str_in, str_local, str_nil, str_not, str_repeat, str_return, str_then, str_true, str_until, str_while > {}; struct key_and : key< str_and > {}; struct key_break : key< str_break > {}; @@ -162,177 +164,177 @@ namespace lua53 struct keyword : key< sor_keyword > {}; template< typename R > - struct pad : tao::pegtl::pad< R, sep > {}; + struct pad : pegtl::pad< R, sep > {}; - struct name : tao::pegtl::seq< tao::pegtl::not_at< keyword >, tao::pegtl::identifier > {}; + struct name : pegtl::seq< pegtl::not_at< keyword >, pegtl::identifier > {}; - struct single : tao::pegtl::one< 'a', 'b', 'f', 'n', 'r', 't', 'v', '\\', '"', '\'', '0', '\n' > {}; - struct spaces : tao::pegtl::seq< tao::pegtl::one< 'z' >, tao::pegtl::star< tao::pegtl::space > > {}; - struct hexbyte : tao::pegtl::if_must< tao::pegtl::one< 'x' >, tao::pegtl::xdigit, tao::pegtl::xdigit > {}; - struct decbyte : tao::pegtl::if_must< tao::pegtl::digit, tao::pegtl::rep_opt< 2, tao::pegtl::digit > > {}; - struct unichar : tao::pegtl::if_must< tao::pegtl::one< 'u' >, tao::pegtl::one< '{' >, tao::pegtl::plus< tao::pegtl::xdigit >, tao::pegtl::one< '}' > > {}; - struct escaped : tao::pegtl::if_must< tao::pegtl::one< '\\' >, tao::pegtl::sor< hexbyte, decbyte, unichar, single, spaces > > {}; - struct regular : tao::pegtl::not_one< '\r', '\n' > {}; - struct character : tao::pegtl::sor< escaped, regular > {}; + struct single : pegtl::one< 'a', 'b', 'f', 'n', 'r', 't', 'v', '\\', '"', '\'', '0', '\n' > {}; + struct spaces : pegtl::seq< pegtl::one< 'z' >, pegtl::star< pegtl::space > > {}; + struct hexbyte : pegtl::if_must< pegtl::one< 'x' >, pegtl::xdigit, pegtl::xdigit > {}; + struct decbyte : pegtl::if_must< pegtl::digit, pegtl::rep_opt< 2, pegtl::digit > > {}; + struct unichar : pegtl::if_must< pegtl::one< 'u' >, pegtl::one< '{' >, pegtl::plus< pegtl::xdigit >, pegtl::one< '}' > > {}; + struct escaped : pegtl::if_must< pegtl::one< '\\' >, pegtl::sor< hexbyte, decbyte, unichar, single, spaces > > {}; + struct regular : pegtl::not_one< '\r', '\n' > {}; + struct character : pegtl::sor< escaped, regular > {}; template< char Q > - struct short_string : tao::pegtl::if_must< tao::pegtl::one< Q >, tao::pegtl::until< tao::pegtl::one< Q >, character > > {}; - struct literal_string : tao::pegtl::sor< short_string< '"' >, short_string< '\'' >, long_string > {}; + struct short_string : pegtl::if_must< pegtl::one< Q >, pegtl::until< pegtl::one< Q >, character > > {}; + struct literal_string : pegtl::sor< short_string< '"' >, short_string< '\'' >, long_string > {}; template< typename E > - struct exponent : tao::pegtl::opt_must< E, tao::pegtl::opt< tao::pegtl::one< '+', '-' > >, tao::pegtl::plus< tao::pegtl::digit > > {}; + struct exponent : pegtl::opt_must< E, pegtl::opt< pegtl::one< '+', '-' > >, pegtl::plus< pegtl::digit > > {}; template< typename D, typename E > - struct numeral_three : tao::pegtl::seq< tao::pegtl::if_must< tao::pegtl::one< '.' >, tao::pegtl::plus< D > >, exponent< E > > {}; + struct numeral_three : pegtl::seq< pegtl::if_must< pegtl::one< '.' >, pegtl::plus< D > >, exponent< E > > {}; template< typename D, typename E > - struct numeral_two : tao::pegtl::seq< tao::pegtl::plus< D >, tao::pegtl::opt< tao::pegtl::one< '.' >, tao::pegtl::star< D > >, exponent< E > > {}; + struct numeral_two : pegtl::seq< pegtl::plus< D >, pegtl::opt< pegtl::one< '.' >, pegtl::star< D > >, exponent< E > > {}; template< typename D, typename E > - struct numeral_one : tao::pegtl::sor< numeral_two< D, E >, numeral_three< D, E > > {}; + struct numeral_one : pegtl::sor< numeral_two< D, E >, numeral_three< D, E > > {}; - struct decimal : numeral_one< tao::pegtl::digit, tao::pegtl::one< 'e', 'E' > > {}; - struct hexadecimal : tao::pegtl::if_must< tao::pegtl::istring< '0', 'x' >, numeral_one< tao::pegtl::xdigit, tao::pegtl::one< 'p', 'P' > > > {}; - struct numeral : tao::pegtl::sor< hexadecimal, decimal > {}; + struct decimal : numeral_one< pegtl::digit, pegtl::one< 'e', 'E' > > {}; + struct hexadecimal : pegtl::if_must< pegtl::istring< '0', 'x' >, numeral_one< pegtl::xdigit, pegtl::one< 'p', 'P' > > > {}; + struct numeral : pegtl::sor< hexadecimal, decimal > {}; - struct label_statement : tao::pegtl::if_must< tao::pegtl::two< ':' >, seps, name, seps, tao::pegtl::two< ':' > > {}; - struct goto_statement : tao::pegtl::if_must< key_goto, seps, name > {}; + struct label_statement : pegtl::if_must< pegtl::two< ':' >, seps, name, seps, pegtl::two< ':' > > {}; + struct goto_statement : pegtl::if_must< key_goto, seps, name > {}; struct statement; struct expression; - struct name_list : tao::pegtl::list< name, tao::pegtl::one< ',' >, sep > {}; - struct name_list_must : tao::pegtl::list_must< name, tao::pegtl::one< ',' >, sep > {}; - struct expr_list_must : tao::pegtl::list_must< expression, tao::pegtl::one< ',' >, sep > {}; + struct name_list : pegtl::list< name, pegtl::one< ',' >, sep > {}; + struct name_list_must : pegtl::list_must< name, pegtl::one< ',' >, sep > {}; + struct expr_list_must : pegtl::list_must< expression, pegtl::one< ',' >, sep > {}; - struct statement_return : tao::pegtl::seq< tao::pegtl::pad_opt< expr_list_must, sep >, tao::pegtl::opt< tao::pegtl::one< ';' >, seps > > {}; + struct statement_return : pegtl::seq< pegtl::pad_opt< expr_list_must, sep >, pegtl::opt< pegtl::one< ';' >, seps > > {}; template< typename E > - struct statement_list : tao::pegtl::seq< seps, tao::pegtl::until< tao::pegtl::sor< E, tao::pegtl::if_must< key_return, statement_return, E > >, statement, seps > > {}; + struct statement_list : pegtl::seq< seps, pegtl::until< pegtl::sor< E, pegtl::if_must< key_return, statement_return, E > >, statement, seps > > {}; template< char O, char... N > - struct op_one : tao::pegtl::seq< tao::pegtl::one< O >, tao::pegtl::at< tao::pegtl::not_one< N... > > > {}; + struct op_one : pegtl::seq< pegtl::one< O >, pegtl::at< pegtl::not_one< N... > > > {}; template< char O, char P, char... N > - struct op_two : tao::pegtl::seq< tao::pegtl::string< O, P >, tao::pegtl::at< tao::pegtl::not_one< N... > > > {}; + struct op_two : pegtl::seq< pegtl::string< O, P >, pegtl::at< pegtl::not_one< N... > > > {}; - struct table_field_one : tao::pegtl::if_must< tao::pegtl::one< '[' >, seps, expression, seps, tao::pegtl::one< ']' >, seps, tao::pegtl::one< '=' >, seps, expression > {}; - struct table_field_two : tao::pegtl::if_must< tao::pegtl::seq< name, seps, op_one< '=', '=' > >, seps, expression > {}; - struct table_field : tao::pegtl::sor< table_field_one, table_field_two, expression > {}; - struct table_field_list : tao::pegtl::list_tail< table_field, tao::pegtl::one< ',', ';' >, sep > {}; - struct table_constructor : tao::pegtl::if_must< tao::pegtl::one< '{' >, tao::pegtl::pad_opt< table_field_list, sep >, tao::pegtl::one< '}' > > {}; + struct table_field_one : pegtl::if_must< pegtl::one< '[' >, seps, expression, seps, pegtl::one< ']' >, seps, pegtl::one< '=' >, seps, expression > {}; + struct table_field_two : pegtl::if_must< pegtl::seq< name, seps, op_one< '=', '=' > >, seps, expression > {}; + struct table_field : pegtl::sor< table_field_one, table_field_two, expression > {}; + struct table_field_list : pegtl::list_tail< table_field, pegtl::one< ',', ';' >, sep > {}; + struct table_constructor : pegtl::if_must< pegtl::one< '{' >, pegtl::pad_opt< table_field_list, sep >, pegtl::one< '}' > > {}; - struct parameter_list_one : tao::pegtl::seq< name_list, tao::pegtl::opt_must< pad< tao::pegtl::one< ',' > >, tao::pegtl::ellipsis > > {}; - struct parameter_list : tao::pegtl::sor< tao::pegtl::ellipsis, parameter_list_one > {}; + struct parameter_list_one : pegtl::seq< name_list, pegtl::opt_must< pad< pegtl::one< ',' > >, pegtl::ellipsis > > {}; + struct parameter_list : pegtl::sor< pegtl::ellipsis, parameter_list_one > {}; - struct function_body : tao::pegtl::seq< tao::pegtl::one< '(' >, tao::pegtl::pad_opt< parameter_list, sep >, tao::pegtl::one< ')' >, seps, statement_list< key_end > > {}; - struct function_literal : tao::pegtl::if_must< key_function, seps, function_body > {}; + struct function_body : pegtl::seq< pegtl::one< '(' >, pegtl::pad_opt< parameter_list, sep >, pegtl::one< ')' >, seps, statement_list< key_end > > {}; + struct function_literal : pegtl::if_must< key_function, seps, function_body > {}; - struct bracket_expr : tao::pegtl::if_must< tao::pegtl::one< '(' >, seps, expression, seps, tao::pegtl::one< ')' > > {}; + struct bracket_expr : pegtl::if_must< pegtl::one< '(' >, seps, expression, seps, pegtl::one< ')' > > {}; - struct function_args_one : tao::pegtl::if_must< tao::pegtl::one< '(' >, tao::pegtl::pad_opt< expr_list_must, sep >, tao::pegtl::one< ')' > > {}; - struct function_args : tao::pegtl::sor< function_args_one, table_constructor, literal_string > {}; + struct function_args_one : pegtl::if_must< pegtl::one< '(' >, pegtl::pad_opt< expr_list_must, sep >, pegtl::one< ')' > > {}; + struct function_args : pegtl::sor< function_args_one, table_constructor, literal_string > {}; - struct variable_tail_one : tao::pegtl::if_must< tao::pegtl::one< '[' >, seps, expression, seps, tao::pegtl::one< ']' > > {}; - struct variable_tail_two : tao::pegtl::if_must< tao::pegtl::seq< tao::pegtl::not_at< tao::pegtl::two< '.' > >, tao::pegtl::one< '.' > >, seps, name > {}; - struct variable_tail : tao::pegtl::sor< variable_tail_one, variable_tail_two > {}; + struct variable_tail_one : pegtl::if_must< pegtl::one< '[' >, seps, expression, seps, pegtl::one< ']' > > {}; + struct variable_tail_two : pegtl::if_must< pegtl::seq< pegtl::not_at< pegtl::two< '.' > >, pegtl::one< '.' > >, seps, name > {}; + struct variable_tail : pegtl::sor< variable_tail_one, variable_tail_two > {}; - struct function_call_tail_one : tao::pegtl::if_must< tao::pegtl::seq< tao::pegtl::not_at< tao::pegtl::two< ':' > >, tao::pegtl::one< ':' > >, seps, name, seps, function_args > {}; - struct function_call_tail : tao::pegtl::sor< function_args, function_call_tail_one > {}; + struct function_call_tail_one : pegtl::if_must< pegtl::seq< pegtl::not_at< pegtl::two< ':' > >, pegtl::one< ':' > >, seps, name, seps, function_args > {}; + struct function_call_tail : pegtl::sor< function_args, function_call_tail_one > {}; - struct variable_head_one : tao::pegtl::seq< bracket_expr, seps, variable_tail > {}; - struct variable_head : tao::pegtl::sor< name, variable_head_one > {}; + struct variable_head_one : pegtl::seq< bracket_expr, seps, variable_tail > {}; + struct variable_head : pegtl::sor< name, variable_head_one > {}; - struct function_call_head : tao::pegtl::sor< name, bracket_expr > {}; + struct function_call_head : pegtl::sor< name, bracket_expr > {}; - struct variable : tao::pegtl::seq< variable_head, tao::pegtl::star< tao::pegtl::star< seps, function_call_tail >, seps, variable_tail > > {}; - struct function_call : tao::pegtl::seq< function_call_head, tao::pegtl::plus< tao::pegtl::until< tao::pegtl::seq< seps, function_call_tail >, seps, variable_tail > > > {}; + struct variable : pegtl::seq< variable_head, pegtl::star< pegtl::star< seps, function_call_tail >, seps, variable_tail > > {}; + struct function_call : pegtl::seq< function_call_head, pegtl::plus< pegtl::until< pegtl::seq< seps, function_call_tail >, seps, variable_tail > > > {}; template< typename S, typename O > - struct left_assoc : tao::pegtl::seq< S, seps, tao::pegtl::star_must< O, seps, S, seps > > {}; + struct left_assoc : pegtl::seq< S, seps, pegtl::star_must< O, seps, S, seps > > {}; template< typename S, typename O > - struct right_assoc : tao::pegtl::seq< S, seps, tao::pegtl::opt_must< O, seps, right_assoc< S, O > > > {}; + struct right_assoc : pegtl::seq< S, seps, pegtl::opt_must< O, seps, right_assoc< S, O > > > {}; - struct unary_operators : tao::pegtl::sor< tao::pegtl::one< '-' >, - tao::pegtl::one< '#' >, - op_one< '~', '=' >, - key_not > {}; + struct unary_operators : pegtl::sor< pegtl::one< '-' >, + pegtl::one< '#' >, + op_one< '~', '=' >, + key_not > {}; struct expr_ten; - struct expr_thirteen : tao::pegtl::seq< tao::pegtl::sor< bracket_expr, name >, tao::pegtl::star< seps, tao::pegtl::sor< function_call_tail, variable_tail > > > {}; - struct expr_twelve : tao::pegtl::sor< key_nil, - key_true, - key_false, - tao::pegtl::ellipsis, - numeral, - literal_string, - function_literal, - expr_thirteen, - table_constructor > {}; - struct expr_eleven : tao::pegtl::seq< expr_twelve, seps, tao::pegtl::opt< tao::pegtl::one< '^' >, seps, expr_ten, seps > > {}; - struct unary_apply : tao::pegtl::if_must< unary_operators, seps, expr_ten, seps > {}; - struct expr_ten : tao::pegtl::sor< unary_apply, expr_eleven > {}; - struct operators_nine : tao::pegtl::sor< tao::pegtl::two< '/' >, - tao::pegtl::one< '/' >, - tao::pegtl::one< '*' >, - tao::pegtl::one< '%' > > {}; + struct expr_thirteen : pegtl::seq< pegtl::sor< bracket_expr, name >, pegtl::star< seps, pegtl::sor< function_call_tail, variable_tail > > > {}; + struct expr_twelve : pegtl::sor< key_nil, + key_true, + key_false, + pegtl::ellipsis, + numeral, + literal_string, + function_literal, + expr_thirteen, + table_constructor > {}; + struct expr_eleven : pegtl::seq< expr_twelve, seps, pegtl::opt< pegtl::one< '^' >, seps, expr_ten, seps > > {}; + struct unary_apply : pegtl::if_must< unary_operators, seps, expr_ten, seps > {}; + struct expr_ten : pegtl::sor< unary_apply, expr_eleven > {}; + struct operators_nine : pegtl::sor< pegtl::two< '/' >, + pegtl::one< '/' >, + pegtl::one< '*' >, + pegtl::one< '%' > > {}; struct expr_nine : left_assoc< expr_ten, operators_nine > {}; - struct operators_eight : tao::pegtl::sor< tao::pegtl::one< '+' >, - tao::pegtl::one< '-' > > {}; + struct operators_eight : pegtl::sor< pegtl::one< '+' >, + pegtl::one< '-' > > {}; struct expr_eight : left_assoc< expr_nine, operators_eight > {}; struct expr_seven : right_assoc< expr_eight, op_two< '.', '.', '.' > > {}; - struct operators_six : tao::pegtl::sor< tao::pegtl::two< '<' >, - tao::pegtl::two< '>' > > {}; + struct operators_six : pegtl::sor< pegtl::two< '<' >, + pegtl::two< '>' > > {}; struct expr_six : left_assoc< expr_seven, operators_six > {}; - struct expr_five : left_assoc< expr_six, tao::pegtl::one< '&' > > {}; + struct expr_five : left_assoc< expr_six, pegtl::one< '&' > > {}; struct expr_four : left_assoc< expr_five, op_one< '~', '=' > > {}; - struct expr_three : left_assoc< expr_four, tao::pegtl::one< '|' > > {}; - struct operators_two : tao::pegtl::sor< tao::pegtl::two< '=' >, - tao::pegtl::string< '<', '=' >, - tao::pegtl::string< '>', '=' >, - op_one< '<', '<' >, - op_one< '>', '>' >, - tao::pegtl::string< '~', '=' > > {}; + struct expr_three : left_assoc< expr_four, pegtl::one< '|' > > {}; + struct operators_two : pegtl::sor< pegtl::two< '=' >, + pegtl::string< '<', '=' >, + pegtl::string< '>', '=' >, + op_one< '<', '<' >, + op_one< '>', '>' >, + pegtl::string< '~', '=' > > {}; struct expr_two : left_assoc< expr_three, operators_two > {}; struct expr_one : left_assoc< expr_two, key_and > {}; struct expression : left_assoc< expr_one, key_or > {}; - struct do_statement : tao::pegtl::if_must< key_do, statement_list< key_end > > {}; - struct while_statement : tao::pegtl::if_must< key_while, seps, expression, seps, key_do, statement_list< key_end > > {}; - struct repeat_statement : tao::pegtl::if_must< key_repeat, statement_list< key_until >, seps, expression > {}; - - struct at_elseif_else_end : tao::pegtl::sor< tao::pegtl::at< key_elseif >, tao::pegtl::at< key_else >, tao::pegtl::at< key_end > > {}; - struct elseif_statement : tao::pegtl::if_must< key_elseif, seps, expression, seps, key_then, statement_list< at_elseif_else_end > > {}; - struct else_statement : tao::pegtl::if_must< key_else, statement_list< key_end > > {}; - struct if_statement : tao::pegtl::if_must< key_if, seps, expression, seps, key_then, statement_list< at_elseif_else_end >, seps, tao::pegtl::until< tao::pegtl::sor< else_statement, key_end >, elseif_statement, seps > > {}; - - struct for_statement_one : tao::pegtl::seq< tao::pegtl::one< '=' >, seps, expression, seps, tao::pegtl::one< ',' >, seps, expression, tao::pegtl::pad_opt< tao::pegtl::if_must< tao::pegtl::one< ',' >, seps, expression >, sep > > {}; - struct for_statement_two : tao::pegtl::seq< tao::pegtl::opt_must< tao::pegtl::one< ',' >, seps, name_list_must, seps >, key_in, seps, expr_list_must, seps > {}; - struct for_statement : tao::pegtl::if_must< key_for, seps, name, seps, tao::pegtl::sor< for_statement_one, for_statement_two >, key_do, statement_list< key_end > > {}; - - struct assignment_variable_list : tao::pegtl::list_must< variable, tao::pegtl::one< ',' >, sep > {}; - struct assignments_one : tao::pegtl::if_must< tao::pegtl::one< '=' >, seps, expr_list_must > {}; - struct assignments : tao::pegtl::seq< assignment_variable_list, seps, assignments_one > {}; - struct function_name : tao::pegtl::seq< tao::pegtl::list< name, tao::pegtl::one< '.' >, sep >, seps, tao::pegtl::opt_must< tao::pegtl::one< ':' >, seps, name, seps > > {}; - struct function_definition : tao::pegtl::if_must< key_function, seps, function_name, function_body > {}; - - struct local_function : tao::pegtl::if_must< key_function, seps, name, seps, function_body > {}; - struct local_variables : tao::pegtl::if_must< name_list_must, seps, tao::pegtl::opt< assignments_one > > {}; - struct local_statement : tao::pegtl::if_must< key_local, seps, tao::pegtl::sor< local_function, local_variables > > {}; - - struct semicolon : tao::pegtl::one< ';' > {}; - struct statement : tao::pegtl::sor< semicolon, - assignments, - function_call, - label_statement, - key_break, - goto_statement, - do_statement, - while_statement, - repeat_statement, - if_statement, - for_statement, - function_definition, - local_statement > {}; - - struct grammar : tao::pegtl::must< tao::pegtl::opt< tao::pegtl::shebang >, statement_list< tao::pegtl::eof > > {}; + struct do_statement : pegtl::if_must< key_do, statement_list< key_end > > {}; + struct while_statement : pegtl::if_must< key_while, seps, expression, seps, key_do, statement_list< key_end > > {}; + struct repeat_statement : pegtl::if_must< key_repeat, statement_list< key_until >, seps, expression > {}; + + struct at_elseif_else_end : pegtl::sor< pegtl::at< key_elseif >, pegtl::at< key_else >, pegtl::at< key_end > > {}; + struct elseif_statement : pegtl::if_must< key_elseif, seps, expression, seps, key_then, statement_list< at_elseif_else_end > > {}; + struct else_statement : pegtl::if_must< key_else, statement_list< key_end > > {}; + struct if_statement : pegtl::if_must< key_if, seps, expression, seps, key_then, statement_list< at_elseif_else_end >, seps, pegtl::until< pegtl::sor< else_statement, key_end >, elseif_statement, seps > > {}; + + struct for_statement_one : pegtl::seq< pegtl::one< '=' >, seps, expression, seps, pegtl::one< ',' >, seps, expression, pegtl::pad_opt< pegtl::if_must< pegtl::one< ',' >, seps, expression >, sep > > {}; + struct for_statement_two : pegtl::seq< pegtl::opt_must< pegtl::one< ',' >, seps, name_list_must, seps >, key_in, seps, expr_list_must, seps > {}; + struct for_statement : pegtl::if_must< key_for, seps, name, seps, pegtl::sor< for_statement_one, for_statement_two >, key_do, statement_list< key_end > > {}; + + struct assignment_variable_list : pegtl::list_must< variable, pegtl::one< ',' >, sep > {}; + struct assignments_one : pegtl::if_must< pegtl::one< '=' >, seps, expr_list_must > {}; + struct assignments : pegtl::seq< assignment_variable_list, seps, assignments_one > {}; + struct function_name : pegtl::seq< pegtl::list< name, pegtl::one< '.' >, sep >, seps, pegtl::opt_must< pegtl::one< ':' >, seps, name, seps > > {}; + struct function_definition : pegtl::if_must< key_function, seps, function_name, function_body > {}; + + struct local_function : pegtl::if_must< key_function, seps, name, seps, function_body > {}; + struct local_variables : pegtl::if_must< name_list_must, seps, pegtl::opt< assignments_one > > {}; + struct local_statement : pegtl::if_must< key_local, seps, pegtl::sor< local_function, local_variables > > {}; + + struct semicolon : pegtl::one< ';' > {}; + struct statement : pegtl::sor< semicolon, + assignments, + function_call, + label_statement, + key_break, + goto_statement, + do_statement, + while_statement, + repeat_statement, + if_statement, + for_statement, + function_definition, + local_statement > {}; + + struct grammar : pegtl::must< pegtl::opt< pegtl::shebang >, statement_list< pegtl::eof > > {}; // clang-format on } // namespace lua53 diff --git a/packages/PEGTL/src/example/pegtl/lua53_analyze.cpp b/packages/PEGTL/src/example/pegtl/lua53_analyze.cpp index d785e2a98c2139ef6fddab75cb5b95beceb6e658..572046486486e5ff9e794d71157b9e91fb7c4972 100644 --- a/packages/PEGTL/src/example/pegtl/lua53_analyze.cpp +++ b/packages/PEGTL/src/example/pegtl/lua53_analyze.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/lua53_parse.cpp b/packages/PEGTL/src/example/pegtl/lua53_parse.cpp index 317e23c47b2454d33fb9d1817e61d51bd35b63a2..95ad94ea372138e969efaabb428d4949c50bc369 100644 --- a/packages/PEGTL/src/example/pegtl/lua53_parse.cpp +++ b/packages/PEGTL/src/example/pegtl/lua53_parse.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/modulus_match.cpp b/packages/PEGTL/src/example/pegtl/modulus_match.cpp index fd866c5a53d167f67f043e833c41d98c38a089f7..2ebf1c7904caabb778343be19ac81c79e49c7348 100644 --- a/packages/PEGTL/src/example/pegtl/modulus_match.cpp +++ b/packages/PEGTL/src/example/pegtl/modulus_match.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/parse_tree.cpp b/packages/PEGTL/src/example/pegtl/parse_tree.cpp index c105e1621fc06a747f7c07ad5aacb930a14fd647..77436e7b83de1b895ceb435c58748c0b333f82c6 100644 --- a/packages/PEGTL/src/example/pegtl/parse_tree.cpp +++ b/packages/PEGTL/src/example/pegtl/parse_tree.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/parse_tree_user_state.cpp b/packages/PEGTL/src/example/pegtl/parse_tree_user_state.cpp index 6bb7a382a26fec64a91d16e6ac8451b66db3a978..98faabf283d12aa3fdce5dcecd769f9664145c3a 100644 --- a/packages/PEGTL/src/example/pegtl/parse_tree_user_state.cpp +++ b/packages/PEGTL/src/example/pegtl/parse_tree_user_state.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/proto3.cpp b/packages/PEGTL/src/example/pegtl/proto3.cpp index cb7303787ccc7be48c9e5cc4887b9f511264d974..d49dcdbd44097b9eb4927e01730d18373a5f5cd0 100644 --- a/packages/PEGTL/src/example/pegtl/proto3.cpp +++ b/packages/PEGTL/src/example/pegtl/proto3.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/random_order.cpp b/packages/PEGTL/src/example/pegtl/random_order.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e9842291c773fc302b8d0ab89c35acbcdd07a758 --- /dev/null +++ b/packages/PEGTL/src/example/pegtl/random_order.cpp @@ -0,0 +1,109 @@ +// Copyright (c) 2023 Dr. Colin Hirsch and Daniel Frey +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) + +#include <bitset> +#include <iostream> +#include <utility> + +#include <tao/pegtl.hpp> + +namespace TAO_PEGTL_NAMESPACE +{ + namespace internal + { + template< bool Optional, typename... Rules > + struct rnd; + + template< bool Optional > + struct rnd< Optional > + : success + {}; + + template< bool Optional, typename... Rules > + struct rnd + { + using rule_t = rnd; + using subs_t = type_list< Rules... >; + + static constexpr std::size_t rule_count = sizeof...( Rules ); + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + std::size_t... Indices, + typename ParseInput, + typename... States > + [[nodiscard]] static bool match( std::index_sequence< Indices... > /*unused*/, ParseInput& in, States&&... st ) + { + std::bitset< rule_count > b; + auto m = in.template auto_rewind< M >(); + using m_t = decltype( m ); + for( std::size_t i = 0; i < rule_count; ++i ) { + if( !( ( ( b.test( Indices ) == false ) && ( Control< Rules >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ) && ( b.set( Indices ), true ) ) || ... ) ) { + return m( Optional ); + } + } + return m( true ); + } + + 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 ) + { + if constexpr( sizeof...( Rules ) == 1 ) { + return Control< Rules... >::template match< A, M, Action, Control >( in, st... ); + } + else { + return match< A, M, Action, Control >( std::index_sequence_for< Rules... >(), in, st... ); + } + } + }; + + template< bool Optional, typename... Rules > + inline constexpr bool enable_control< rnd< Optional, Rules... > > = false; + + } // namespace internal + + template< typename... Rules > + struct rnd + : internal::rnd< false, Rules... > + {}; + + template< typename... Rules > + struct rnd_opt + : internal::rnd< true, Rules... > + {}; + +} // namespace TAO_PEGTL_NAMESPACE + +int main( int argc, char** argv ) +{ + using namespace TAO_PEGTL_NAMESPACE; + + using grammar1 = seq< rnd< one< 'a' >, one< 'b' >, one< 'c' > >, eolf >; + using grammar2 = seq< rnd_opt< one< 'a' >, one< 'b' >, one< 'c' > >, eolf >; + + for( int i = 1; i < argc; ++i ) { + { + argv_input in( argv, i ); + const bool b = parse< grammar1 >( in ); + std::cout << "input: " << argv[ i ] << " rnd: " << b << std::endl; + } + { + argv_input in( argv, i ); + const bool b = parse< grammar2 >( in ); + std::cout << "input: " << argv[ i ] << " rnd_opt: " << b << std::endl; + } + } + return 0; +} diff --git a/packages/PEGTL/src/example/pegtl/recover.cpp b/packages/PEGTL/src/example/pegtl/recover.cpp index 9f6e2076799d5b8e34c58eba022f10340c3f72a9..12d581e918b549cc7e2c524e60ab22c03f491209 100644 --- a/packages/PEGTL/src/example/pegtl/recover.cpp +++ b/packages/PEGTL/src/example/pegtl/recover.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/s_expression.cpp b/packages/PEGTL/src/example/pegtl/s_expression.cpp index d0ab218c5928e8c326b3bdf81a22c4108aa84690..a93dbb8b68e2db72f11ced567468ebb5746ee77b 100644 --- a/packages/PEGTL/src/example/pegtl/s_expression.cpp +++ b/packages/PEGTL/src/example/pegtl/s_expression.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -19,31 +19,33 @@ int main() namespace sexpr { + namespace pegtl = TAO_PEGTL_NAMESPACE; + // clang-format off - struct hash_comment : tao::pegtl::until< tao::pegtl::eolf > {}; + struct hash_comment : pegtl::until< pegtl::eolf > {}; struct list; - struct list_comment : tao::pegtl::if_must< tao::pegtl::at< tao::pegtl::one< '(' > >, tao::pegtl::disable< list > > {}; + struct list_comment : pegtl::if_must< pegtl::at< pegtl::one< '(' > >, pegtl::disable< list > > {}; - struct read_include : tao::pegtl::seq< tao::pegtl::one< ' ' >, tao::pegtl::one< '"' >, tao::pegtl::plus< tao::pegtl::not_one< '"' > >, tao::pegtl::one< '"' > > {}; - struct hash_include : tao::pegtl::if_must< tao::pegtl::string< 'i', 'n', 'c', 'l', 'u', 'd', 'e' >, read_include > {}; + struct read_include : pegtl::seq< pegtl::one< ' ' >, pegtl::one< '"' >, pegtl::plus< pegtl::not_one< '"' > >, pegtl::one< '"' > > {}; + struct hash_include : pegtl::if_must< pegtl::string< 'i', 'n', 'c', 'l', 'u', 'd', 'e' >, read_include > {}; - struct hashed : tao::pegtl::if_must< tao::pegtl::one< '#' >, tao::pegtl::sor< hash_include, list_comment, hash_comment > > {}; + struct hashed : pegtl::if_must< pegtl::one< '#' >, pegtl::sor< hash_include, list_comment, hash_comment > > {}; - struct number : tao::pegtl::plus< tao::pegtl::digit > {}; - struct symbol : tao::pegtl::identifier {}; + struct number : pegtl::plus< pegtl::digit > {}; + struct symbol : pegtl::identifier {}; - struct atom : tao::pegtl::sor< number, symbol > {}; + struct atom : pegtl::sor< number, symbol > {}; struct anything; - struct list : tao::pegtl::if_must< tao::pegtl::one< '(' >, tao::pegtl::until< tao::pegtl::one< ')' >, anything > > {}; + struct list : pegtl::if_must< pegtl::one< '(' >, pegtl::until< pegtl::one< ')' >, anything > > {}; - struct normal : tao::pegtl::sor< atom, list > {}; + struct normal : pegtl::sor< atom, list > {}; - struct anything : tao::pegtl::sor< tao::pegtl::space, hashed, normal > {}; + struct anything : pegtl::sor< pegtl::space, hashed, normal > {}; - struct main : tao::pegtl::until< tao::pegtl::eof, tao::pegtl::must< anything > > {}; + struct main : pegtl::until< pegtl::eof, pegtl::must< anything > > {}; // clang-format on template< typename Rule > @@ -51,7 +53,7 @@ namespace sexpr {}; template<> - struct action< tao::pegtl::plus< tao::pegtl::not_one< '"' > > > + struct action< pegtl::plus< pegtl::not_one< '"' > > > { template< typename ActionInput > static void apply( const ActionInput& in, std::string& fn ) @@ -73,8 +75,8 @@ namespace sexpr // last string literal that we use as filename here, and // the input is passed on for chained error messages (as // in "error in line x file foo included from file bar...) - tao::pegtl::file_input i2( fn ); - tao::pegtl::parse_nested< main, sexpr::action >( in, i2, f2 ); + pegtl::file_input i2( fn ); + pegtl::parse_nested< main, sexpr::action >( in, i2, f2 ); } }; @@ -82,16 +84,16 @@ namespace sexpr int main( int argc, char** argv ) // NOLINT(bugprone-exception-escape) { - if( tao::pegtl::analyze< sexpr::main >() != 0 ) { + if( TAO_PEGTL_NAMESPACE::analyze< sexpr::main >() != 0 ) { return 1; } for( int i = 1; i < argc; ++i ) { std::string fn; - tao::pegtl::argv_input in( argv, i ); + TAO_PEGTL_NAMESPACE::argv_input in( argv, i ); try { - tao::pegtl::parse< sexpr::main, sexpr::action >( in, fn ); + TAO_PEGTL_NAMESPACE::parse< sexpr::main, sexpr::action >( in, fn ); } - catch( const tao::pegtl::parse_error& e ) { + catch( const TAO_PEGTL_NAMESPACE::parse_error& e ) { const auto p = e.positions().front(); std::cerr << e.what() << '\n' << in.line_at( p ) << '\n' diff --git a/packages/PEGTL/src/example/pegtl/sum.cpp b/packages/PEGTL/src/example/pegtl/sum.cpp index 9867e3ab84475b9a2c06fbd52ea791d46e36beff..d632e5a6e9d6ee603d3fef95636d79f38a0a8b22 100644 --- a/packages/PEGTL/src/example/pegtl/sum.cpp +++ b/packages/PEGTL/src/example/pegtl/sum.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/symbol_table.cpp b/packages/PEGTL/src/example/pegtl/symbol_table.cpp index 5dba51e3b91b1ebab816d25d759854b3e1286a90..3b10a9813226d5a78a3c2947c35964b2bfb1af87 100644 --- a/packages/PEGTL/src/example/pegtl/symbol_table.cpp +++ b/packages/PEGTL/src/example/pegtl/symbol_table.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/token_input.cpp b/packages/PEGTL/src/example/pegtl/token_input.cpp index df35d4aafdbc061753dd69ca6d75a79b766a6ee3..2ddf46053d78286d3313b277cac881a2ed0960e2 100644 --- a/packages/PEGTL/src/example/pegtl/token_input.cpp +++ b/packages/PEGTL/src/example/pegtl/token_input.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -24,9 +24,9 @@ namespace TAO_PEGTL_NAMESPACE public: using input_t = ParseInput; using value_t = typename ParseInput::value_t; - using iterator_t = typename ParseInput::iterator_t; + using frobnicator_t = typename ParseInput::frobnicator_t; - token_action_input( const iterator_t& in_begin, const ParseInput& in_input ) noexcept + token_action_input( const frobnicator_t& in_begin, const ParseInput& in_input ) noexcept : m_begin( in_begin ), m_input( in_input ) {} @@ -39,7 +39,7 @@ namespace TAO_PEGTL_NAMESPACE token_action_input& operator=( const token_action_input& ) = delete; token_action_input& operator=( token_action_input&& ) = delete; - [[nodiscard]] const iterator_t& iterator() const noexcept + [[nodiscard]] const frobnicator_t& frobnicator() const noexcept { return m_begin; } @@ -49,12 +49,12 @@ namespace TAO_PEGTL_NAMESPACE return m_input; } - [[nodiscard]] iterator_t begin() const noexcept + [[nodiscard]] frobnicator_t begin() const noexcept { return m_begin; } - [[nodiscard]] iterator_t end() const noexcept + [[nodiscard]] frobnicator_t end() const noexcept { return m_input.current(); } @@ -70,7 +70,7 @@ namespace TAO_PEGTL_NAMESPACE } protected: - const iterator_t m_begin; + const frobnicator_t m_begin; const ParseInput& m_input; }; @@ -80,12 +80,12 @@ namespace TAO_PEGTL_NAMESPACE public: using value_t = T; using source_t = Source; - using iterator_t = const T*; + using frobnicator_t = const T*; using action_t = token_action_input< token_parse_input >; template< typename S > - token_parse_input( const iterator_t in_begin, const iterator_t in_end, S&& in_source ) + token_parse_input( const frobnicator_t in_begin, const frobnicator_t in_end, S&& in_source ) : m_begin( in_begin ), m_current( in_begin ), m_end( in_end ), @@ -109,17 +109,17 @@ namespace TAO_PEGTL_NAMESPACE void require( const std::size_t /*unused*/ ) const noexcept {} - [[nodiscard]] iterator_t current() const noexcept + [[nodiscard]] frobnicator_t current() const noexcept { return m_current; } - [[nodiscard]] iterator_t begin() const noexcept + [[nodiscard]] frobnicator_t begin() const noexcept { return m_begin; } - [[nodiscard]] iterator_t end( const std::size_t /*unused*/ = 0 ) const noexcept + [[nodiscard]] frobnicator_t end( const std::size_t /*unused*/ = 0 ) const noexcept { return m_end; } @@ -130,9 +130,19 @@ namespace TAO_PEGTL_NAMESPACE } template< rewind_mode M > - [[nodiscard]] internal::marker< iterator_t, M > mark() noexcept + [[nodiscard]] internal::rewind_guard< M, token_parse_input > auto_rewind() noexcept { - return internal::marker< iterator_t, M >( iterator() ); + return internal::rewind_guard< M, token_parse_input >( this ); + } + + [[nodiscard]] const frobnicator_t& rewind_save() const noexcept + { + return m_current; + } + + void rewind_restore( const frobnicator_t& data ) noexcept + { + m_current = data; } void bump( const std::size_t in_count = 1 ) noexcept @@ -165,20 +175,20 @@ namespace TAO_PEGTL_NAMESPACE return this->current()[ offset ]; } - [[nodiscard]] iterator_t& iterator() noexcept + [[nodiscard]] frobnicator_t& frobnicator() noexcept { return this->m_current; } - [[nodiscard]] const iterator_t& iterator() const noexcept + [[nodiscard]] const frobnicator_t& frobnicator() const noexcept { return this->m_current; } private: - const iterator_t m_begin; - iterator_t m_current; - const iterator_t m_end; + const frobnicator_t m_begin; + frobnicator_t m_current; + const frobnicator_t m_end; const Source m_source; }; diff --git a/packages/PEGTL/src/example/pegtl/unescape.cpp b/packages/PEGTL/src/example/pegtl/unescape.cpp index 10f2a1f4071517108dad344cef0a938ec384264b..7ae3b96e8f2988c8ec9d18057bd0c50518cf2baa 100644 --- a/packages/PEGTL/src/example/pegtl/unescape.cpp +++ b/packages/PEGTL/src/example/pegtl/unescape.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/uri.cpp b/packages/PEGTL/src/example/pegtl/uri.cpp index a964959c41d1b7e9840eceb1b2f9c2ebc737f8da..62ceaf6ccf1ffe392285bc03a866c71ca118340d 100644 --- a/packages/PEGTL/src/example/pegtl/uri.cpp +++ b/packages/PEGTL/src/example/pegtl/uri.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/example/pegtl/uri_print_debug.cpp b/packages/PEGTL/src/example/pegtl/uri_print_debug.cpp index f535e3a11b5c070e95ad64a3b9511b65a5b989c6..f71c8c0f3b4330900a6f6a068a57a8a99a4f7692 100644 --- a/packages/PEGTL/src/example/pegtl/uri_print_debug.cpp +++ b/packages/PEGTL/src/example/pegtl/uri_print_debug.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -18,7 +18,7 @@ int main() int main() // NOLINT(bugprone-exception-escape) { - tao::pegtl::print_debug< tao::pegtl::uri::URI >( std::cout ); + TAO_PEGTL_NAMESPACE::print_debug< TAO_PEGTL_NAMESPACE::uri::URI >( std::cout ); return 0; } diff --git a/packages/PEGTL/src/example/pegtl/uri_print_names.cpp b/packages/PEGTL/src/example/pegtl/uri_print_names.cpp index 95361921756a6d13d4c4a0b73ba6f533e6bf1097..1e766fdbd3053746f71c9a601704fc636b3446a9 100644 --- a/packages/PEGTL/src/example/pegtl/uri_print_names.cpp +++ b/packages/PEGTL/src/example/pegtl/uri_print_names.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -18,7 +18,7 @@ int main() int main() // NOLINT(bugprone-exception-escape) { - tao::pegtl::print_names< tao::pegtl::uri::URI >( std::cout ); + TAO_PEGTL_NAMESPACE::print_names< TAO_PEGTL_NAMESPACE::uri::URI >( std::cout ); return 0; } diff --git a/packages/PEGTL/src/example/pegtl/uri_trace.cpp b/packages/PEGTL/src/example/pegtl/uri_trace.cpp index d041d3343a468a1c651fbd6d09edc3e354b6f20a..ba64c55c56665e555e700cc5d2d155a65dcbe2b6 100644 --- a/packages/PEGTL/src/example/pegtl/uri_trace.cpp +++ b/packages/PEGTL/src/example/pegtl/uri_trace.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/CMakeLists.txt b/packages/PEGTL/src/test/pegtl/CMakeLists.txt index eae7a9546c6fa5b0cb113cb999788a6cbbd828cc..7f707c33a4c9306c84642b3fe297855212e3d263 100644 --- a/packages/PEGTL/src/test/pegtl/CMakeLists.txt +++ b/packages/PEGTL/src/test/pegtl/CMakeLists.txt @@ -36,6 +36,7 @@ set(test_sources contrib_integer.cpp contrib_iri.cpp contrib_json.cpp + contrib_limit_depth.cpp contrib_parse_tree.cpp contrib_parse_tree_to_dot.cpp contrib_partial_trace.cpp @@ -59,6 +60,8 @@ set(test_sources discard_input.cpp enable_control.cpp error_message.cpp + error_message_2.cpp + error_message_3.cpp file_cstream.cpp file_file.cpp file_istream.cpp @@ -69,7 +72,6 @@ set(test_sources internal_file_mapper.cpp internal_file_opener.cpp limit_bytes.cpp - limit_depth.cpp parse_error.cpp pegtl_string_t.cpp position.cpp @@ -86,6 +88,7 @@ set(test_sources rule_discard.cpp rule_enable.cpp rule_eof.cpp + rule_everything.cpp rule_failure.cpp rule_if_apply.cpp rule_if_must.cpp @@ -101,6 +104,7 @@ set(test_sources rule_opt_must.cpp rule_pad.cpp rule_pad_opt.cpp + rule_partial.cpp rule_plus.cpp rule_raise.cpp rule_rematch.cpp @@ -114,6 +118,7 @@ set(test_sources rule_sor.cpp rule_star.cpp rule_star_must.cpp + rule_star_partial.cpp rule_state.cpp rule_success.cpp rule_try_catch.cpp diff --git a/packages/PEGTL/src/test/pegtl/action_enable.cpp b/packages/PEGTL/src/test/pegtl/action_enable.cpp index 3f7a5cb4228da53c3ec04d1b4938925631b38c22..89118e275454777b67c992bca91a8b64e3238fa8 100644 --- a/packages/PEGTL/src/test/pegtl/action_enable.cpp +++ b/packages/PEGTL/src/test/pegtl/action_enable.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/action_match.cpp b/packages/PEGTL/src/test/pegtl/action_match.cpp index af6f5709d0902103073a114981bc0cb065fe641b..29446bc6c681b9b6213c0534a0e320390913a771 100644 --- a/packages/PEGTL/src/test/pegtl/action_match.cpp +++ b/packages/PEGTL/src/test/pegtl/action_match.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/actions_one.cpp b/packages/PEGTL/src/test/pegtl/actions_one.cpp index 4b0f4b6fda87e735883ec3e2f5a27c586f7dbbf6..5e6172986ad7215652bae95192f6040129cc45f8 100644 --- a/packages/PEGTL/src/test/pegtl/actions_one.cpp +++ b/packages/PEGTL/src/test/pegtl/actions_one.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/actions_three.cpp b/packages/PEGTL/src/test/pegtl/actions_three.cpp index 987f764578a77f2c8d9afdcd1983b968d927b318..4accf9c2e9a0c74b32b20f75eae9dc28a4ebce4a 100644 --- a/packages/PEGTL/src/test/pegtl/actions_three.cpp +++ b/packages/PEGTL/src/test/pegtl/actions_three.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/actions_two.cpp b/packages/PEGTL/src/test/pegtl/actions_two.cpp index 77687875c6755d5f8558a3fc4f6445ac69ecf2b7..f55f08134fa6b3e765c74e182edea7fd53fa2a40 100644 --- a/packages/PEGTL/src/test/pegtl/actions_two.cpp +++ b/packages/PEGTL/src/test/pegtl/actions_two.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -102,9 +102,9 @@ namespace TAO_PEGTL_NAMESPACE template< typename ActionInput > static void apply( const ActionInput& in ) { - TAO_PEGTL_TEST_ASSERT( in.iterator().byte == count_byte ); - TAO_PEGTL_TEST_ASSERT( in.iterator().line == count_line ); - TAO_PEGTL_TEST_ASSERT( in.iterator().column == count_column ); + TAO_PEGTL_TEST_ASSERT( in.frobnicator().byte == count_byte ); + TAO_PEGTL_TEST_ASSERT( in.frobnicator().line == count_line ); + TAO_PEGTL_TEST_ASSERT( in.frobnicator().column == count_column ); TAO_PEGTL_TEST_ASSERT( in.input().source() == count_source ); TAO_PEGTL_TEST_ASSERT( in.size() == 1 ); TAO_PEGTL_TEST_ASSERT( in.begin() + 1 == in.end() ); diff --git a/packages/PEGTL/src/test/pegtl/argv_input.cpp b/packages/PEGTL/src/test/pegtl/argv_input.cpp index 0f3c283d20b99ae08f1e94a265a4f7c0ffd440c4..b6788378f66a5f56b503b212a561461f4073d9f5 100644 --- a/packages/PEGTL/src/test/pegtl/argv_input.cpp +++ b/packages/PEGTL/src/test/pegtl/argv_input.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/ascii_classes.cpp b/packages/PEGTL/src/test/pegtl/ascii_classes.cpp index f9e255c33f11bbe7e47e6f879a8234271faf061d..bf9db08d9672ea70b02dce408e621d8c6d9b5a69 100644 --- a/packages/PEGTL/src/test/pegtl/ascii_classes.cpp +++ b/packages/PEGTL/src/test/pegtl/ascii_classes.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/ascii_eol.cpp b/packages/PEGTL/src/test/pegtl/ascii_eol.cpp index 0169eda66cd94f2794254e7990b6dd7e4c93ced5..da2364479728fa5539e84177d29a08472f3bb95e 100644 --- a/packages/PEGTL/src/test/pegtl/ascii_eol.cpp +++ b/packages/PEGTL/src/test/pegtl/ascii_eol.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/ascii_eolf.cpp b/packages/PEGTL/src/test/pegtl/ascii_eolf.cpp index c6033080c516ba6b6eeebd9755511834f9067c6d..32bb2801896cc09c3e692f82240923c1d115a43c 100644 --- a/packages/PEGTL/src/test/pegtl/ascii_eolf.cpp +++ b/packages/PEGTL/src/test/pegtl/ascii_eolf.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/ascii_forty_two.cpp b/packages/PEGTL/src/test/pegtl/ascii_forty_two.cpp index bf3edcbdc123c1b33e39f655f05cd15ec51f8d22..e5854c57c658770528d7eb2351c28efee4c07b1b 100644 --- a/packages/PEGTL/src/test/pegtl/ascii_forty_two.cpp +++ b/packages/PEGTL/src/test/pegtl/ascii_forty_two.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -17,19 +17,19 @@ namespace TAO_PEGTL_NAMESPACE verify_rule< forty_two< 'a' > >( __LINE__, __FILE__, std::string( i, 'a' ), result_type::local_failure ); } for( std::size_t i = 42; i < 100; ++i ) { - verify_rule< forty_two< 'a' > >( __LINE__, __FILE__, std::string( i, 'a' ), result_type::success, int( i - 42 ) ); + verify_rule< forty_two< 'a' > >( __LINE__, __FILE__, std::string( i, 'a' ), result_type::success, static_cast< int >( i - 42 ) ); } for( std::size_t i = 0; i < 42; ++i ) { verify_rule< forty_two< 'a', 'z' > >( __LINE__, __FILE__, std::string( i, 'a' ), result_type::local_failure ); } for( std::size_t i = 42; i < 100; ++i ) { - verify_rule< forty_two< 'a', 'z' > >( __LINE__, __FILE__, std::string( i, 'a' ), result_type::success, int( i - 42 ) ); + verify_rule< forty_two< 'a', 'z' > >( __LINE__, __FILE__, std::string( i, 'a' ), result_type::success, static_cast< int >( i - 42 ) ); } for( std::size_t i = 0; i < 42; ++i ) { verify_rule< forty_two< 'a', 'z' > >( __LINE__, __FILE__, std::string( i, 'z' ), result_type::local_failure ); } for( std::size_t i = 42; i < 100; ++i ) { - verify_rule< forty_two< 'a', 'z' > >( __LINE__, __FILE__, std::string( i, 'z' ), result_type::success, int( i - 42 ) ); + verify_rule< forty_two< 'a', 'z' > >( __LINE__, __FILE__, std::string( i, 'z' ), result_type::success, static_cast< int >( i - 42 ) ); } verify_rule< forty_two< 'a', 'z' > >( __LINE__, __FILE__, "azzaazaazaaazzzaaaazzaaazzaazazzzaazzazaza", result_type::success ); } diff --git a/packages/PEGTL/src/test/pegtl/ascii_identifier.cpp b/packages/PEGTL/src/test/pegtl/ascii_identifier.cpp index 8c1a14b852f6d3ea69a194ff625f7eb6b80be8e6..0e613d1a15f8b6ab415116c3010d15b30ff012e7 100644 --- a/packages/PEGTL/src/test/pegtl/ascii_identifier.cpp +++ b/packages/PEGTL/src/test/pegtl/ascii_identifier.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/ascii_istring.cpp b/packages/PEGTL/src/test/pegtl/ascii_istring.cpp index 3f1b1ff09aa1aa19dffc33e55dc256d80baaeaa7..be028c65e19fad39cad7448457392e403d4d9c23 100644 --- a/packages/PEGTL/src/test/pegtl/ascii_istring.cpp +++ b/packages/PEGTL/src/test/pegtl/ascii_istring.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/ascii_keyword.cpp b/packages/PEGTL/src/test/pegtl/ascii_keyword.cpp index 5d384c5f120f3eb644533944031d14875058bef6..43182bfeb5d75fecfc7c0e048a6ba444cc7285c1 100644 --- a/packages/PEGTL/src/test/pegtl/ascii_keyword.cpp +++ b/packages/PEGTL/src/test/pegtl/ascii_keyword.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/ascii_shebang.cpp b/packages/PEGTL/src/test/pegtl/ascii_shebang.cpp index 71fc843daa3365e3c2eda3f4c7c7b7e273a87f00..06a6393998c696228fbcf3040ec61717a6030e18 100644 --- a/packages/PEGTL/src/test/pegtl/ascii_shebang.cpp +++ b/packages/PEGTL/src/test/pegtl/ascii_shebang.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/ascii_string.cpp b/packages/PEGTL/src/test/pegtl/ascii_string.cpp index e128dca6a002a1f92d10227996d37292da275207..3f846d6b9921f732bf2c80411f9d836b54a7f21a 100644 --- a/packages/PEGTL/src/test/pegtl/ascii_string.cpp +++ b/packages/PEGTL/src/test/pegtl/ascii_string.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/ascii_three.cpp b/packages/PEGTL/src/test/pegtl/ascii_three.cpp index 68a026debfec176c96238da99298b896669b1610..7da1ef3659b73e67bcb40086149e645af3edd027 100644 --- a/packages/PEGTL/src/test/pegtl/ascii_three.cpp +++ b/packages/PEGTL/src/test/pegtl/ascii_three.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/ascii_two.cpp b/packages/PEGTL/src/test/pegtl/ascii_two.cpp index 8c0ff00973cd87f0bf28eb3108aa3ac10e4d5a80..4f94775e796eb01de8a893cb8b9fa356a9445198 100644 --- a/packages/PEGTL/src/test/pegtl/ascii_two.cpp +++ b/packages/PEGTL/src/test/pegtl/ascii_two.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/buffer_input.cpp b/packages/PEGTL/src/test/pegtl/buffer_input.cpp index eff7614e5f347d52cc942487ecf8856643f94e70..74ec6173b7aac21e2bbde62576ec4579f2dc4b4b 100644 --- a/packages/PEGTL/src/test/pegtl/buffer_input.cpp +++ b/packages/PEGTL/src/test/pegtl/buffer_input.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/change_action_and_state.cpp b/packages/PEGTL/src/test/pegtl/change_action_and_state.cpp index 9cf3cce155c0ce5ab17966ad50bb2637f989fcf5..4f2039a131f29fd79ca27d70d4ffc639a88aef92 100644 --- a/packages/PEGTL/src/test/pegtl/change_action_and_state.cpp +++ b/packages/PEGTL/src/test/pegtl/change_action_and_state.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/change_action_and_states.cpp b/packages/PEGTL/src/test/pegtl/change_action_and_states.cpp index 9ea7faa781b2f2aad0ce01633e4e15908dc3d7e0..e03eca89555959caad9b069b93a04637a8043a44 100644 --- a/packages/PEGTL/src/test/pegtl/change_action_and_states.cpp +++ b/packages/PEGTL/src/test/pegtl/change_action_and_states.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/change_state.cpp b/packages/PEGTL/src/test/pegtl/change_state.cpp index 6061b9178cc9e0ec0a3e5ebcfa2182a5d8a051d8..d52302a236cb6a56bb3bb9fe28a4a1511a971e8e 100644 --- a/packages/PEGTL/src/test/pegtl/change_state.cpp +++ b/packages/PEGTL/src/test/pegtl/change_state.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/change_states.cpp b/packages/PEGTL/src/test/pegtl/change_states.cpp index 64a4b27620d241d9e23d02860b8dd972e8a66773..b401332717a0e00da62d4fadfa67a7e07f8f7a3c 100644 --- a/packages/PEGTL/src/test/pegtl/change_states.cpp +++ b/packages/PEGTL/src/test/pegtl/change_states.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/check_bytes.cpp b/packages/PEGTL/src/test/pegtl/check_bytes.cpp index d5dc2ad00eb8e9c666f352df8a9cf674f59aa021..c02e91a4708a6ba5e85ccb0816dc69c4e1bd1dc9 100644 --- a/packages/PEGTL/src/test/pegtl/check_bytes.cpp +++ b/packages/PEGTL/src/test/pegtl/check_bytes.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2021-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -29,20 +29,20 @@ namespace TAO_PEGTL_NAMESPACE void unit_test() { memory_input<> i1( "aaa", __FUNCTION__ ); - const auto r1 = pegtl::parse< test_grammar >( i1 ); + const auto r1 = parse< test_grammar >( i1 ); TAO_PEGTL_TEST_ASSERT( r1 ); memory_input<> i2( "aaaaaaaaaaa", __FUNCTION__ ); - const auto r2 = pegtl::parse< test_grammar >( i2 ); + const auto r2 = parse< test_grammar >( i2 ); TAO_PEGTL_TEST_ASSERT( r2 ); memory_input<> i3( "aaa", __FUNCTION__ ); - const auto r3 = pegtl::parse< test_grammar, test_action >( i3 ); + const auto r3 = parse< test_grammar, test_action >( i3 ); TAO_PEGTL_TEST_ASSERT( r3 ); #if defined( __cpp_exceptions ) memory_input<> i4( "aaaaaaaaaaa", __FUNCTION__ ); - TAO_PEGTL_TEST_THROWS( pegtl::parse< test_grammar, test_action >( i4 ) ); + TAO_PEGTL_TEST_THROWS( parse< test_grammar, test_action >( i4 ) ); #endif } diff --git a/packages/PEGTL/src/test/pegtl/contains.cpp b/packages/PEGTL/src/test/pegtl/contains.cpp index ee1d9a6fb2a9b57d86c87af48d6fb966354c5d62..764b0d152e240ab439980a61b7337253e82d3d83 100644 --- a/packages/PEGTL/src/test/pegtl/contains.cpp +++ b/packages/PEGTL/src/test/pegtl/contains.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2021-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_alphabet.cpp b/packages/PEGTL/src/test/pegtl/contrib_alphabet.cpp index 73fdecf224063ac5e1e0f3900b35c3b459238f72..8b01e1e3dcbe1c1178ac66a86c5c2b0062bc3ac3 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_alphabet.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_alphabet.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_analyze.cpp b/packages/PEGTL/src/test/pegtl/contrib_analyze.cpp index cce72b544c35918843e7707def84b4f28019709c..6880f406a60daec90d6523ce9e96ed7929e066da 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_analyze.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_analyze.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_control_action.cpp b/packages/PEGTL/src/test/pegtl/contrib_control_action.cpp index 512d1ba541fcccb93543b5c3b0cd3747497f9386..df0f802cfeb05397a52d71a15b9c604134432061 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_control_action.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_control_action.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -15,6 +15,11 @@ namespace TAO_PEGTL_NAMESPACE : nothing< Rule > {}; + template< typename Rule > + struct dummy_action + : control_action + {}; + struct first_rule : sor< alpha, digit > {}; @@ -137,6 +142,12 @@ namespace TAO_PEGTL_NAMESPACE void unit_test() { + { + memory_input in( "0", __FUNCTION__ ); + const auto b = parse< first_rule, dummy_action >( in, 42 ); + TAO_PEGTL_TEST_ASSERT( b ); + TAO_PEGTL_TEST_ASSERT( story.empty() ); + } { memory_input in( "0", __FUNCTION__ ); const auto b = parse< first_rule, test_action >( in, 42 ); diff --git a/packages/PEGTL/src/test/pegtl/contrib_coverage.cpp b/packages/PEGTL/src/test/pegtl/contrib_coverage.cpp index b70954e24ec22f59ecf26775aa8d703e6461cd75..2c1d5798fa870382eeba9f6b084c2d4226c5f9ae 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_coverage.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_coverage.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_function.cpp b/packages/PEGTL/src/test/pegtl/contrib_function.cpp index 3455fe18cc4046c29bb47bfda689ff5dc2ce0e42..eca901aab5ed7c9ebe240944d712d2c3f8b602f7 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_function.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_function.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_http.cpp b/packages/PEGTL/src/test/pegtl/contrib_http.cpp index 3bdb52d59c4fa9d9756b5ecf5189fb45da75d8b4..486a8774a3ba7841dc1bee0d992bda379d859dbf 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_http.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_http.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_if_then.cpp b/packages/PEGTL/src/test/pegtl/contrib_if_then.cpp index b98a3ba598dababe65395bf4e85653b369373cc5..ff40b3bfd8d494e7d4f9a3cd23df6043fdfc12da 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_if_then.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_if_then.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_instantiate.cpp b/packages/PEGTL/src/test/pegtl/contrib_instantiate.cpp index 86566822b095f1465fd9ca848e365c7c4bba89da..a8257c72cca2c8a990ff522ef748e953b893e160 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_instantiate.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_instantiate.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_integer.cpp b/packages/PEGTL/src/test/pegtl/contrib_integer.cpp index f3441c0ea0e199e58083c8426d8589ef555def94..1421cd8f9991bb04da02f01dd86f4142f75c8cc4 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_integer.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_integer.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_iri.cpp b/packages/PEGTL/src/test/pegtl/contrib_iri.cpp index 96890d71c3e66aa9f68db8f7c3f2486c99bcc890..84440b48670faf2cfda0b05e5184e0b7851082df 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_iri.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_iri.cpp @@ -1,5 +1,5 @@ -// Copyright (c) 2021 Kelvin Hammond -// Copyright (c) 2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2021-2023 Kelvin Hammond +// Copyright (c) 2021-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_json.cpp b/packages/PEGTL/src/test/pegtl/contrib_json.cpp index 62cf3b778a657c90cfc029cc83b85d97773f61ad..d57adc48648dd5a86463813a08c30ae87b4acace 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_json.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_json.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/limit_depth.cpp b/packages/PEGTL/src/test/pegtl/contrib_limit_depth.cpp similarity index 54% rename from packages/PEGTL/src/test/pegtl/limit_depth.cpp rename to packages/PEGTL/src/test/pegtl/contrib_limit_depth.cpp index 3f9df51639fef2d3eef3d5414845fd29c4163666..b32055cccb0d9bfe044624f59f075451db5e1112 100644 --- a/packages/PEGTL/src/test/pegtl/limit_depth.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_limit_depth.cpp @@ -1,7 +1,8 @@ -// Copyright (c) 2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2021-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) +#include <tao/pegtl/contrib/input_with_depth.hpp> #include <tao/pegtl/contrib/limit_depth.hpp> #include "test.hpp" @@ -28,21 +29,23 @@ namespace TAO_PEGTL_NAMESPACE void unit_test() { - memory_input<> i1( "aaa", __FUNCTION__ ); - const auto r1 = pegtl::parse< test_grammar >( i1 ); + using memory_input_with_depth = input_with_depth< memory_input<> >; + + memory_input_with_depth i1( "aaa", __FUNCTION__ ); + const auto r1 = parse< test_grammar >( i1 ); TAO_PEGTL_TEST_ASSERT( r1 ); - memory_input<> i2( "aaaaaaaaaaa", __FUNCTION__ ); - const auto r2 = pegtl::parse< test_grammar >( i2 ); + memory_input_with_depth i2( "aaaaaaaaaaa", __FUNCTION__ ); + const auto r2 = parse< test_grammar >( i2 ); TAO_PEGTL_TEST_ASSERT( r2 ); - memory_input<> i3( "aaa", __FUNCTION__ ); - const auto r3 = pegtl::parse< test_grammar, test_action >( i3 ); + memory_input_with_depth i3( "aaa", __FUNCTION__ ); + const auto r3 = parse< test_grammar, test_action >( i3 ); TAO_PEGTL_TEST_ASSERT( r3 ); #if defined( __cpp_exceptions ) - memory_input<> i4( "aaaaaaaaaaa", __FUNCTION__ ); - TAO_PEGTL_TEST_THROWS( pegtl::parse< test_grammar, test_action >( i4 ) ); + memory_input_with_depth i4( "aaaaaaaaaaa", __FUNCTION__ ); + TAO_PEGTL_TEST_THROWS( parse< test_grammar, test_action >( i4 ) ); #endif } diff --git a/packages/PEGTL/src/test/pegtl/contrib_parse_tree.cpp b/packages/PEGTL/src/test/pegtl/contrib_parse_tree.cpp index 04a8a0a797fae9a1b0967c25af2aa0fb9e8294ac..cf2387fb6b27c024afd23395459549aa29c60297 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_parse_tree.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_parse_tree.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_parse_tree_to_dot.cpp b/packages/PEGTL/src/test/pegtl/contrib_parse_tree_to_dot.cpp index 517092ab26237f66b7d563e84c84aebcba0af72b..160c3f1a06d05c3f029e278f49641f9206d6633c 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_parse_tree_to_dot.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_parse_tree_to_dot.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_partial_trace.cpp b/packages/PEGTL/src/test/pegtl/contrib_partial_trace.cpp index 1c8f1a97786d7e4632dc596a573eca742b202641..a643026b6a588b62ecb52fa9a89a02e69e076ba5 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_partial_trace.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_partial_trace.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_predicates.cpp b/packages/PEGTL/src/test/pegtl/contrib_predicates.cpp index 00403c330686cb07f8dcd52d86192314f0db2588..548a5447eab5052cb853d0938a66aa392ac02ec6 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_predicates.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_predicates.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_print.cpp b/packages/PEGTL/src/test/pegtl/contrib_print.cpp index 2c2bde7e73dca9565e4c44b1ffcbda2216208e57..c07a63c1a768332265e98ca99ea1655f9413989a 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_print.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_print.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_raw_string.cpp b/packages/PEGTL/src/test/pegtl/contrib_raw_string.cpp index ef6abda59265fd317fc3bded653ceb7559c6767d..b2a95a4d492af29ed6335ebfd68ba3f7382e7d23 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_raw_string.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_raw_string.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_remove_first_state.cpp b/packages/PEGTL/src/test/pegtl/contrib_remove_first_state.cpp index c31ef5d40739576a07e59fcaad5db9a7a7e2bc07..b3283dfb433ba2851c0fdf9720b8420f9dec15f2 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_remove_first_state.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_remove_first_state.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_remove_last_states.cpp b/packages/PEGTL/src/test/pegtl/contrib_remove_last_states.cpp index 240c2abb0001d82c8e7dbc6596740900620c6f33..fd9a6149c5b2704a6f2b9bf682a7764d8599c60c 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_remove_last_states.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_remove_last_states.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_rep_one_min_max.cpp b/packages/PEGTL/src/test/pegtl/contrib_rep_one_min_max.cpp index 69dd862afa5312d7ef385552e2dbf7a7d8ba1af3..17518ab82fc44483bdbf08520748a7ff41229e18 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_rep_one_min_max.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_rep_one_min_max.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_rep_string.cpp b/packages/PEGTL/src/test/pegtl/contrib_rep_string.cpp index 91eda129eb8fc62b9a70c2caca00947cb4b02dc6..bbecece8f7b38c3f76f0e608e8b3f6f1ba08cd04 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_rep_string.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_rep_string.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_separated_seq.cpp b/packages/PEGTL/src/test/pegtl/contrib_separated_seq.cpp index 1a47a5fbeddf3a2c826a5ab95c96f1086d56f1a3..870237d36043a77e88136d7d9b735f709fac7901 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_separated_seq.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_separated_seq.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2021-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_state_control.cpp b/packages/PEGTL/src/test/pegtl/contrib_state_control.cpp index 7fc3b2b2929a904fe4c30efb1bd3fbc8e107a986..0ee3293ecba120fac145e9f33532d48e5fdd870a 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_state_control.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_state_control.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_to_string.cpp b/packages/PEGTL/src/test/pegtl/contrib_to_string.cpp index bd03ed78940f1abbf14f56d7abffd71c6c038717..3d94ee8fa570d8d8977a2647a36067aaeb357317 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_to_string.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_to_string.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_trace1.cpp b/packages/PEGTL/src/test/pegtl/contrib_trace1.cpp index 31cc5c866e3d732f0c26a53276f534a1aca443f6..ec207cf23123172d425ab396d0741475e4bcfc77 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_trace1.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_trace1.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -8,14 +8,20 @@ #include <tao/pegtl/contrib/trace.hpp> -namespace TAO_PEGTL_NAMESPACE +namespace test { + using namespace TAO_PEGTL_NAMESPACE; + #if defined( __cpp_exceptions ) using grammar = seq< sor< try_catch< must< one< 'a' > > >, one< 'F' > >, eof >; #else using grammar = seq< sor< one< 'a' >, one< 'F' > >, eof >; #endif +} // namespace test + +namespace TAO_PEGTL_NAMESPACE +{ void unit_test() { const std::string data = "F"; @@ -23,9 +29,9 @@ namespace TAO_PEGTL_NAMESPACE // Just enough to see that it compiles and nothing explodes; // the output format probabaly changes between compilers and // versions making a proper test difficult. - standard_trace< grammar >( in ); + standard_trace< test::grammar >( in ); in.restart(); - complete_trace< grammar >( in ); + complete_trace< test::grammar >( in ); } } // namespace TAO_PEGTL_NAMESPACE diff --git a/packages/PEGTL/src/test/pegtl/contrib_trace2.cpp b/packages/PEGTL/src/test/pegtl/contrib_trace2.cpp index 90112f7e896c7a3af151d23d884cf9990ccc9621..a717379687db4cf8fe206caad1f135b64e5ef421 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_trace2.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_trace2.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -6,8 +6,10 @@ #include <tao/pegtl/contrib/trace.hpp> -namespace TAO_PEGTL_NAMESPACE +namespace test { + using namespace TAO_PEGTL_NAMESPACE; + using GRAMMAR1 = sor< failure, one< 'a' > >; using GRAMMAR2 = seq< one< 'a' >, any, any, any, any, one< 'b' >, eof >; using GRAMMAR3 = sor< one< 'a' >, one< 'b' > >; @@ -42,45 +44,49 @@ namespace TAO_PEGTL_NAMESPACE } }; +} // namespace test + +namespace TAO_PEGTL_NAMESPACE +{ void unit_test() { { memory_input in( "ab", "trace test please ignore" ); - const auto result = standard_trace< GRAMMAR1 >( in ); + const auto result = standard_trace< test::GRAMMAR1 >( in ); TAO_PEGTL_TEST_ASSERT( result ); - TAO_PEGTL_TEST_ASSERT( a0 == 0 ); - TAO_PEGTL_TEST_ASSERT( a == 0 ); + TAO_PEGTL_TEST_ASSERT( test::a0 == 0 ); + TAO_PEGTL_TEST_ASSERT( test::a == 0 ); } { memory_input in( "ab", "trace test please ignore" ); - const auto result = standard_trace< GRAMMAR1, trace_action >( in ); + const auto result = standard_trace< test::GRAMMAR1, test::trace_action >( in ); TAO_PEGTL_TEST_ASSERT( result ); - TAO_PEGTL_TEST_ASSERT( a0 == 1 ); - TAO_PEGTL_TEST_ASSERT( a == 1 ); + TAO_PEGTL_TEST_ASSERT( test::a0 == 1 ); + TAO_PEGTL_TEST_ASSERT( test::a == 1 ); } { memory_input in( "a\r\n\t\0b", 6, "trace test please ignore" ); - const auto result = standard_trace< GRAMMAR2 >( in ); + const auto result = standard_trace< test::GRAMMAR2 >( in ); TAO_PEGTL_TEST_ASSERT( result ); - TAO_PEGTL_TEST_ASSERT( a0 == 1 ); - TAO_PEGTL_TEST_ASSERT( a == 1 ); + TAO_PEGTL_TEST_ASSERT( test::a0 == 1 ); + TAO_PEGTL_TEST_ASSERT( test::a == 1 ); } { memory_input in( "a\r\n\t\0b", 6, "trace test please ignore" ); - const auto result = standard_trace< GRAMMAR2, trace_action >( in ); + const auto result = standard_trace< test::GRAMMAR2, test::trace_action >( in ); TAO_PEGTL_TEST_ASSERT( result ); - TAO_PEGTL_TEST_ASSERT( a0 == 2 ); - TAO_PEGTL_TEST_ASSERT( a == 1 ); + TAO_PEGTL_TEST_ASSERT( test::a0 == 2 ); + TAO_PEGTL_TEST_ASSERT( test::a == 1 ); } { memory_input in( "c", "trace test please ignore" ); - const auto result = standard_trace< GRAMMAR3 >( in ); + const auto result = standard_trace< test::GRAMMAR3 >( in ); TAO_PEGTL_TEST_ASSERT( !result ); } #if defined( __cpp_exceptions ) { memory_input in( "c", "trace test please ignore" ); - const auto result = standard_trace< GRAMMAR4 >( in ); + const auto result = standard_trace< test::GRAMMAR4 >( in ); TAO_PEGTL_TEST_ASSERT( !result ); } #endif diff --git a/packages/PEGTL/src/test/pegtl/contrib_unescape.cpp b/packages/PEGTL/src/test/pegtl/contrib_unescape.cpp index 9efda4b9001406bcfd82d09cc5a6aedb25b01f89..6a21ff9f17acaba64ddd9d153593a2a83de65172 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_unescape.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_unescape.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/contrib_uri.cpp b/packages/PEGTL/src/test/pegtl/contrib_uri.cpp index 9162abe33b8b81c83a92a0d468ff3f686fcbd1ff..9121b7f9ee9b7d2387cd56c807c9391efe2077ba 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_uri.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_uri.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/control_unwind.cpp b/packages/PEGTL/src/test/pegtl/control_unwind.cpp index 468678e23268f6bd7d830d6f9a83a83cd4487acd..d69eb6914e6760b2e43800e2affc5ffa36bb1e72 100644 --- a/packages/PEGTL/src/test/pegtl/control_unwind.cpp +++ b/packages/PEGTL/src/test/pegtl/control_unwind.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/data_cstring.cpp b/packages/PEGTL/src/test/pegtl/data_cstring.cpp index f8e86171e85e0e00ac5ec5a0b0c706eb6097e222..d361e7d388fa1386b3fa10f8e3882e7d47de0251 100644 --- a/packages/PEGTL/src/test/pegtl/data_cstring.cpp +++ b/packages/PEGTL/src/test/pegtl/data_cstring.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/demangle.cpp b/packages/PEGTL/src/test/pegtl/demangle.cpp index b7acf79c27f62ec3e8f1058213f34e29e284b7ac..38217f1953c326059f979678d7a0e3cae5189d37 100644 --- a/packages/PEGTL/src/test/pegtl/demangle.cpp +++ b/packages/PEGTL/src/test/pegtl/demangle.cpp @@ -1,35 +1,45 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) #include "test.hpp" +#include <string> + #include <tao/pegtl/demangle.hpp> +#define TAO_PEGTL_STRINGIFY( a ) TAO_PEGTL_STRINGIFY_IMPL( a ) +#define TAO_PEGTL_STRINGIFY_IMPL( a ) #a + namespace TAO_PEGTL_NAMESPACE { template< typename T > void test( const std::string& s ) { + std::cerr << s << std::endl; + std::cerr << demangle< T >() << std::endl; TAO_PEGTL_TEST_ASSERT( demangle< T >() == s ); } void unit_test() { + const std::string ns = TAO_PEGTL_STRINGIFY( TAO_PEGTL_NAMESPACE ); #if !defined( __clang__ ) && defined( __GNUC__ ) && ( __GNUC__ == 9 ) && ( __GNUC_MINOR__ <= 2 ) // see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91155 test< int >( "i" ); test< double >( "d" ); - test< seq< bytes< 42 >, eof > >( "N3tao5pegtl3seqIJNS0_5bytesILj42EEENS0_3eofEEEE" ); + if( ns == "tao::pegtl" ) { + test< seq< bytes< 42 >, eof > >( "N3tao5pegtl3seqIJNS0_5bytesILj42EEENS0_3eofEEEE" ); + } #elif defined( _MSC_VER ) && !defined( __clang__ ) test< int >( "int" ); test< double >( "double" ); // in the Microsoft world, class and struct are not the same! - test< seq< bytes< 42 >, eof > >( "struct tao::pegtl::seq<struct tao::pegtl::bytes<42>,struct tao::pegtl::eof>" ); + test< seq< bytes< 42 >, eof > >( "struct " + ns + "::seq<struct " + ns + "::bytes<42>,struct " + ns + "::eof>" ); #else test< int >( "int" ); test< double >( "double" ); - test< seq< bytes< 42 >, eof > >( "tao::pegtl::seq<tao::pegtl::bytes<42>, tao::pegtl::eof>" ); + test< seq< bytes< 42 >, eof > >( ns + "::seq<" + ns + "::bytes<42>, " + ns + "::eof>" ); #endif } diff --git a/packages/PEGTL/src/test/pegtl/discard_input.cpp b/packages/PEGTL/src/test/pegtl/discard_input.cpp index 3dac97076d12635e3cb8ea9f209b262a3aedd043..3e8a39187246718a6ac0d792737261ccc4abe14f 100644 --- a/packages/PEGTL/src/test/pegtl/discard_input.cpp +++ b/packages/PEGTL/src/test/pegtl/discard_input.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/enable_control.cpp b/packages/PEGTL/src/test/pegtl/enable_control.cpp index 49429e39142d7a05b5074af83a41b5300e118dda..72a3cb64d1a0078ef15b46bbfc9bf4d5d09b2a9c 100644 --- a/packages/PEGTL/src/test/pegtl/enable_control.cpp +++ b/packages/PEGTL/src/test/pegtl/enable_control.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/error_message.cpp b/packages/PEGTL/src/test/pegtl/error_message.cpp index 220cfbc5292fb517020a67b5f256e5ad643ea3fd..66cc87444ec46983856449f701362ec9e0b47c09 100644 --- a/packages/PEGTL/src/test/pegtl/error_message.cpp +++ b/packages/PEGTL/src/test/pegtl/error_message.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -22,7 +22,7 @@ namespace test1 struct grammar : sor< a, b > {}; template< typename > inline constexpr const char* error_message = nullptr; - template<> inline constexpr auto error_message< test1::b > = "test123"; + template<> inline constexpr auto error_message< b > = "test123"; // clang-format on struct error diff --git a/packages/PEGTL/src/test/pegtl/error_message_2.cpp b/packages/PEGTL/src/test/pegtl/error_message_2.cpp new file mode 100644 index 0000000000000000000000000000000000000000..15aff7a7a628c57940e79d22728b058eed4bc598 --- /dev/null +++ b/packages/PEGTL/src/test/pegtl/error_message_2.cpp @@ -0,0 +1,44 @@ +// Copyright (c) 2021-2023 Dr. Colin Hirsch and Daniel Frey +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) + +#if !defined( __cpp_exceptions ) +#include <iostream> +int main() +{ + std::cout << "Exception support disabled, skipping test..." << std::endl; +} +#else + +#include "test.hpp" + +namespace test2 +{ + using namespace TAO_PEGTL_NAMESPACE; + + // clang-format off + struct a : one< 'a' > {}; + struct b : one< 'b' > {}; + struct grammar : sor< a, sor< b, TAO_PEGTL_RAISE_MESSAGE( "test123" ) > > {}; + // clang-format on + +} // namespace test2 + +namespace TAO_PEGTL_NAMESPACE +{ + void unit_test() + { + try { + parse< test2::grammar >( memory_input( "c", __FUNCTION__ ) ); + TAO_PEGTL_TEST_UNREACHABLE; // LCOV_EXCL_LINE + } + catch( const parse_error& e ) { + TAO_PEGTL_TEST_ASSERT( e.message() == "test123" ); + } + } + +} // namespace TAO_PEGTL_NAMESPACE + +#include "main.hpp" + +#endif diff --git a/packages/PEGTL/src/test/pegtl/error_message_3.cpp b/packages/PEGTL/src/test/pegtl/error_message_3.cpp new file mode 100644 index 0000000000000000000000000000000000000000..16b00ae7d6acae8eb698c2e26ffb230a7bd6df91 --- /dev/null +++ b/packages/PEGTL/src/test/pegtl/error_message_3.cpp @@ -0,0 +1,48 @@ +// Copyright (c) 2021-2023 Dr. Colin Hirsch and Daniel Frey +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) + +#if !defined( __cpp_exceptions ) +#include <iostream> +int main() +{ + std::cout << "Exception support disabled, skipping test..." << std::endl; +} +#else + +#include "test.hpp" + +namespace test3 +{ + using namespace TAO_PEGTL_NAMESPACE; + + // clang-format off + struct a : one< 'a' > {}; + + struct b : one< 'b' > { + static constexpr const char* error_message = "test123"; + }; + + struct grammar : sor< a, must< b > > {}; + // clang-format on + +} // namespace test3 + +namespace TAO_PEGTL_NAMESPACE +{ + void unit_test() + { + try { + parse< test3::grammar >( memory_input( "c", __FUNCTION__ ) ); + TAO_PEGTL_TEST_UNREACHABLE; // LCOV_EXCL_LINE + } + catch( const parse_error& e ) { + TAO_PEGTL_TEST_ASSERT( e.message() == "test123" ); + } + } + +} // namespace TAO_PEGTL_NAMESPACE + +#include "main.hpp" + +#endif diff --git a/packages/PEGTL/src/test/pegtl/file_cstream.cpp b/packages/PEGTL/src/test/pegtl/file_cstream.cpp index d51dbd2b08f669e6a1edda1b18f82219fc8ab656..72b3f857c016bd181ffdefcc52aebedcf0696f71 100644 --- a/packages/PEGTL/src/test/pegtl/file_cstream.cpp +++ b/packages/PEGTL/src/test/pegtl/file_cstream.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/file_file.cpp b/packages/PEGTL/src/test/pegtl/file_file.cpp index fcc20af53b7d42e61ae4362a2a409d8b469be792..b1b3b18193a1dfe2b62c08aff119ac2b9d6821b5 100644 --- a/packages/PEGTL/src/test/pegtl/file_file.cpp +++ b/packages/PEGTL/src/test/pegtl/file_file.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/file_istream.cpp b/packages/PEGTL/src/test/pegtl/file_istream.cpp index cb4e3cae24b090ec563cd5c19279bf2a326f4820..b315c497f69bfa86f588b7eb23eae43aba70dc72 100644 --- a/packages/PEGTL/src/test/pegtl/file_istream.cpp +++ b/packages/PEGTL/src/test/pegtl/file_istream.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/file_mmap.cpp b/packages/PEGTL/src/test/pegtl/file_mmap.cpp index afa83d1c3a635c36122aae00ca22010fabf00bf1..6c15aa139fb7ff07afa961e71587ba5df402dc74 100644 --- a/packages/PEGTL/src/test/pegtl/file_mmap.cpp +++ b/packages/PEGTL/src/test/pegtl/file_mmap.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/file_read.cpp b/packages/PEGTL/src/test/pegtl/file_read.cpp index 963120e7d66733c080c98cfefa17a703d6934879..36e07afbfbdbbe019d150e23764ba4444fe18eb1 100644 --- a/packages/PEGTL/src/test/pegtl/file_read.cpp +++ b/packages/PEGTL/src/test/pegtl/file_read.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -12,7 +12,7 @@ namespace TAO_PEGTL_NAMESPACE : public read_input< P, Eol > { explicit open_input( const internal::filesystem::path& path ) - : read_input< P, Eol >( internal::file_open( path ), path ) + : read_input< P, Eol >( internal::read_file_open( path ), path ) {} }; diff --git a/packages/PEGTL/src/test/pegtl/icu_general.cpp b/packages/PEGTL/src/test/pegtl/icu_general.cpp index 15e6e62cd7424d3c1c00687ea44675b607ae1c2e..9db69db5346fb2510f49902351a1457b92cd2ca1 100644 --- a/packages/PEGTL/src/test/pegtl/icu_general.cpp +++ b/packages/PEGTL/src/test/pegtl/icu_general.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/internal_endian.cpp b/packages/PEGTL/src/test/pegtl/internal_endian.cpp index f1bb6b1cb57b838aea115e93aa0b424931a758e5..b890817789dd3576922124ed6eb2263fab706cf3 100644 --- a/packages/PEGTL/src/test/pegtl/internal_endian.cpp +++ b/packages/PEGTL/src/test/pegtl/internal_endian.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/internal_file_mapper.cpp b/packages/PEGTL/src/test/pegtl/internal_file_mapper.cpp index 94f6e3f5bf94eb71c1e4e0bbdbb6e0dd0e653e91..1034bea58edc0117b4eef4a411be8e5c84bb2522 100644 --- a/packages/PEGTL/src/test/pegtl/internal_file_mapper.cpp +++ b/packages/PEGTL/src/test/pegtl/internal_file_mapper.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/internal_file_opener.cpp b/packages/PEGTL/src/test/pegtl/internal_file_opener.cpp index 1ca75d9609c386e2fd1945b25c24868d29fb5b94..b3f05ef34a38ffe85b2e654997085f4e60950065 100644 --- a/packages/PEGTL/src/test/pegtl/internal_file_opener.cpp +++ b/packages/PEGTL/src/test/pegtl/internal_file_opener.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/limit_bytes.cpp b/packages/PEGTL/src/test/pegtl/limit_bytes.cpp index f376ad835650bd77f27cd284bf3323ef11bb7afa..2ef432af1d80b107ae9a51353add866169461822 100644 --- a/packages/PEGTL/src/test/pegtl/limit_bytes.cpp +++ b/packages/PEGTL/src/test/pegtl/limit_bytes.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2021-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -29,20 +29,20 @@ namespace TAO_PEGTL_NAMESPACE void unit_test() { memory_input<> i1( "aaa", __FUNCTION__ ); - const auto r1 = pegtl::parse< test_grammar >( i1 ); + const auto r1 = parse< test_grammar >( i1 ); TAO_PEGTL_TEST_ASSERT( r1 ); memory_input<> i2( "aaaaaaaaaaa", __FUNCTION__ ); - const auto r2 = pegtl::parse< test_grammar >( i2 ); + const auto r2 = parse< test_grammar >( i2 ); TAO_PEGTL_TEST_ASSERT( r2 ); memory_input<> i3( "aaa", __FUNCTION__ ); - const auto r3 = pegtl::parse< test_grammar, test_action >( i3 ); + const auto r3 = parse< test_grammar, test_action >( i3 ); TAO_PEGTL_TEST_ASSERT( r3 ); #if defined( __cpp_exceptions ) memory_input<> i4( "aaaaaaaaaaa", __FUNCTION__ ); - TAO_PEGTL_TEST_THROWS( pegtl::parse< test_grammar, test_action >( i4 ) ); + TAO_PEGTL_TEST_THROWS( parse< test_grammar, test_action >( i4 ) ); #endif } diff --git a/packages/PEGTL/src/test/pegtl/main.hpp b/packages/PEGTL/src/test/pegtl/main.hpp index cb09aebbe7c1832dce27c9f46c8a370d97a3ef47..05bdb03697aee20263a2d2c1ddca54965118ca46 100644 --- a/packages/PEGTL/src/test/pegtl/main.hpp +++ b/packages/PEGTL/src/test/pegtl/main.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/parse_error.cpp b/packages/PEGTL/src/test/pegtl/parse_error.cpp index 7fda8f61eea8ab51a9b077e7b8791097aba6e442..c8582482c6f301583eda475b2ee304a3b7b27b1f 100644 --- a/packages/PEGTL/src/test/pegtl/parse_error.cpp +++ b/packages/PEGTL/src/test/pegtl/parse_error.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/pegtl_string_t.cpp b/packages/PEGTL/src/test/pegtl/pegtl_string_t.cpp index 41147a373d26bdb40c23f3cf6f600b544e212293..1f224414e837583d1b8b7e85c44058ca7741a526 100644 --- a/packages/PEGTL/src/test/pegtl/pegtl_string_t.cpp +++ b/packages/PEGTL/src/test/pegtl/pegtl_string_t.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/position.cpp b/packages/PEGTL/src/test/pegtl/position.cpp index 60590e47492627cc48448d98308871d62dc046e5..4759fc68b34ad8d3b6c220d442c8b59e64f75dd5 100644 --- a/packages/PEGTL/src/test/pegtl/position.cpp +++ b/packages/PEGTL/src/test/pegtl/position.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -125,10 +125,10 @@ namespace TAO_PEGTL_NAMESPACE } } - void test_iterator() + void test_frobnicator() { const std::string s = "source"; - const internal::iterator i( nullptr, 1, 2, 3 ); + const internal::frobnicator i( nullptr, 1, 2, 3 ); const position p( i, s ); TAO_PEGTL_TEST_ASSERT( p.byte == 1 ); TAO_PEGTL_TEST_ASSERT( p.line == 2 ); @@ -209,7 +209,7 @@ namespace TAO_PEGTL_NAMESPACE test_nested<>(); test_nested< buffer_input_t >(); - test_iterator(); + test_frobnicator(); } } // namespace TAO_PEGTL_NAMESPACE diff --git a/packages/PEGTL/src/test/pegtl/restart_input.cpp b/packages/PEGTL/src/test/pegtl/restart_input.cpp index 648d118289f8a425f61627e4ea9d2d9f206b6b43..a8b5a122103befde7bbf530620957c9cf3022b6e 100644 --- a/packages/PEGTL/src/test/pegtl/restart_input.cpp +++ b/packages/PEGTL/src/test/pegtl/restart_input.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -22,7 +22,7 @@ namespace TAO_PEGTL_NAMESPACE void test_eager() { const std::string data = "abc"; - memory_input< tracking_mode::eager, eol::lf_crlf, std::string > in( std::string_view( data ), __FUNCTION__ ); + memory_input< tracking_mode::eager, eol::lf_crlf, std::string > in( std::string_view{ data }, __FUNCTION__ ); bool success = parse< grammar >( in ); TAO_PEGTL_TEST_ASSERT( success ); in.restart(); diff --git a/packages/PEGTL/src/test/pegtl/result_type.hpp b/packages/PEGTL/src/test/pegtl/result_type.hpp index 9f8448f3e7de52869b388ab776d5e18101391415..995af78b263528fb9ad529ae0ba60369c197b078 100644 --- a/packages/PEGTL/src/test/pegtl/result_type.hpp +++ b/packages/PEGTL/src/test/pegtl/result_type.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -7,8 +7,6 @@ #include <ostream> -#include <tao/pegtl/config.hpp> - namespace TAO_PEGTL_NAMESPACE { enum class result_type : int diff --git a/packages/PEGTL/src/test/pegtl/rule_action.cpp b/packages/PEGTL/src/test/pegtl/rule_action.cpp index c9e5a9f600340fdbf1f9c7cf3e46fb8f1e11b3be..95a26ba81f295bde456b1d02d9af906589313086 100644 --- a/packages/PEGTL/src/test/pegtl/rule_action.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_action.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_apply.cpp b/packages/PEGTL/src/test/pegtl/rule_apply.cpp index 6ae99f88a5b216b01eea245915289baeda386896..7504613a539fcd9f528cdf0ac9f8dc9fb54c9d31 100644 --- a/packages/PEGTL/src/test/pegtl/rule_apply.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_apply.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_apply0.cpp b/packages/PEGTL/src/test/pegtl/rule_apply0.cpp index 2c4fdfffe86bfe68f384ab84b53355d8a7b74fa3..d70f4af2c75709577d8112f82e19082d7a06467f 100644 --- a/packages/PEGTL/src/test/pegtl/rule_apply0.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_apply0.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_at.cpp b/packages/PEGTL/src/test/pegtl/rule_at.cpp index 996081fda56252f71c57de571a4ade36b4bc0f12..9ef61d6a509d79c47065267928fb132cc5bf30c3 100644 --- a/packages/PEGTL/src/test/pegtl/rule_at.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_at.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_bof.cpp b/packages/PEGTL/src/test/pegtl/rule_bof.cpp index 7462e560b4edfeec65c4ae2960a58790beef7875..125dc810313abb357acf6012d61e563d8e3bb322 100644 --- a/packages/PEGTL/src/test/pegtl/rule_bof.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_bof.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_bol.cpp b/packages/PEGTL/src/test/pegtl/rule_bol.cpp index 837fcc331eebf5a82b9f6703c781d331470086f4..2ec7667f8e8b052914b44af6207bb5b0ecb729b7 100644 --- a/packages/PEGTL/src/test/pegtl/rule_bol.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_bol.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_bytes.cpp b/packages/PEGTL/src/test/pegtl/rule_bytes.cpp index 806640778857cfa885171e8a6046d8eb6f71c86d..a8ede5fba61abdf3f55e291b1c8cbe045654d458 100644 --- a/packages/PEGTL/src/test/pegtl/rule_bytes.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_bytes.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_control.cpp b/packages/PEGTL/src/test/pegtl/rule_control.cpp index 1b69ebd453c300e8de8cb37ce0543f3985b0e9a8..a76a5897422b625c18a2fb56dade4e09398103ef 100644 --- a/packages/PEGTL/src/test/pegtl/rule_control.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_control.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_disable.cpp b/packages/PEGTL/src/test/pegtl/rule_disable.cpp index 65570121b73fad4b103dae193cbb019180f982cc..ec3035ada1e6bd219f959afd01ca2d77c034ee19 100644 --- a/packages/PEGTL/src/test/pegtl/rule_disable.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_disable.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_discard.cpp b/packages/PEGTL/src/test/pegtl/rule_discard.cpp index bce896337e55c24232496ef593ef926c1277cc5b..462612809e3e1840daee3504a6b583077ae0982f 100644 --- a/packages/PEGTL/src/test/pegtl/rule_discard.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_discard.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_enable.cpp b/packages/PEGTL/src/test/pegtl/rule_enable.cpp index 63c4d1560339faaa290c9ead46c2b82517340528..7dde7516d8ddc5ae76a95be5dfb0a26b66e575a2 100644 --- a/packages/PEGTL/src/test/pegtl/rule_enable.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_enable.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_eof.cpp b/packages/PEGTL/src/test/pegtl/rule_eof.cpp index 8ed986e9b6a6d40821811d8dbe061b74cac8bd26..8111a046faa8e0ea748964ea8d62e4b09dc30fbd 100644 --- a/packages/PEGTL/src/test/pegtl/rule_eof.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_eof.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_everything.cpp b/packages/PEGTL/src/test/pegtl/rule_everything.cpp new file mode 100644 index 0000000000000000000000000000000000000000..735ea87763b3e0544d8614bff8615a27ce0f235c --- /dev/null +++ b/packages/PEGTL/src/test/pegtl/rule_everything.cpp @@ -0,0 +1,24 @@ +// Copyright (c) 2022-2023 Dr. Colin Hirsch and Daniel Frey +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) + +#include "test.hpp" +#include "verify_meta.hpp" +#include "verify_rule.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + void unit_test() + { + verify_meta< everything, internal::everything< std::size_t > >(); + + verify_analyze< everything >( __LINE__, __FILE__, false, false ); + + verify_rule< everything >( __LINE__, __FILE__, "", result_type::success ); + verify_rule< everything >( __LINE__, __FILE__, "asodfuaofj", result_type::success ); + verify_rule< everything >( __LINE__, __FILE__, "asfhalfj;alsjfdo;asjdfo;asjf;laskjdfl;afwfj2;093vmu;oaivu;v390fm;aosumvos3fefalihgfis", result_type::success ); + } + +} // namespace TAO_PEGTL_NAMESPACE + +#include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_failure.cpp b/packages/PEGTL/src/test/pegtl/rule_failure.cpp index 19044b3446f767d1af60e7c46daf353d3486f8ab..4a5010d15b5a68ad90b81bcc8162a57fb3839be4 100644 --- a/packages/PEGTL/src/test/pegtl/rule_failure.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_failure.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_if_apply.cpp b/packages/PEGTL/src/test/pegtl/rule_if_apply.cpp index 74602f9a77e384c5dc69eb3266d3bbaa32de5755..daa028292b84ea2d96284867abb4d4c5654ec4da 100644 --- a/packages/PEGTL/src/test/pegtl/rule_if_apply.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_if_apply.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_if_must.cpp b/packages/PEGTL/src/test/pegtl/rule_if_must.cpp index 13f7332ae56146a674760412432539bc0c494e85..9918b2c645bc2ae32a51d0ad48860b207954a0bd 100644 --- a/packages/PEGTL/src/test/pegtl/rule_if_must.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_if_must.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_if_must_else.cpp b/packages/PEGTL/src/test/pegtl/rule_if_must_else.cpp index fa28715d0f1b4170f3607d94383a97e9820a0b27..569430ab2e3d82e2fcdf877c28068120c84cc132 100644 --- a/packages/PEGTL/src/test/pegtl/rule_if_must_else.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_if_must_else.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_if_then_else.cpp b/packages/PEGTL/src/test/pegtl/rule_if_then_else.cpp index b1596f69085b28266f70d966bc52e8dcb7d1f2b2..50a6192d4d77bd9d514ce43aada23c926c17fc37 100644 --- a/packages/PEGTL/src/test/pegtl/rule_if_then_else.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_if_then_else.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_list.cpp b/packages/PEGTL/src/test/pegtl/rule_list.cpp index 2abf474ee895277bf3d88d7d6a0e11e9ea4c5c11..03dac04c3791cc2c1b64b77e4616495a985b02ce 100644 --- a/packages/PEGTL/src/test/pegtl/rule_list.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_list.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_list_must.cpp b/packages/PEGTL/src/test/pegtl/rule_list_must.cpp index 0fab79e8a76524d455a32f45b3f39c0e9f052607..5361e4ebc109449081f650606b698712f190707c 100644 --- a/packages/PEGTL/src/test/pegtl/rule_list_must.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_list_must.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_list_tail.cpp b/packages/PEGTL/src/test/pegtl/rule_list_tail.cpp index 41296111d8b3356af4771f20bd934d575e87d8ff..9a51f59269964ca8efd4ec939792892609c39f1c 100644 --- a/packages/PEGTL/src/test/pegtl/rule_list_tail.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_list_tail.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -10,18 +10,18 @@ namespace TAO_PEGTL_NAMESPACE { void unit_test() { - verify_analyze< list_tail< eof, eof > >( __LINE__, __FILE__, false, true ); - verify_analyze< list_tail< eof, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< list_tail< any, eof > >( __LINE__, __FILE__, true, false ); + verify_analyze< list_tail< opt< any >, opt< any > > >( __LINE__, __FILE__, false, true ); + verify_analyze< list_tail< opt< any >, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< list_tail< any, opt< any > > >( __LINE__, __FILE__, true, false ); verify_analyze< list_tail< any, any > >( __LINE__, __FILE__, true, false ); - verify_analyze< list_tail< eof, eof, eof > >( __LINE__, __FILE__, false, true ); - verify_analyze< list_tail< eof, eof, any > >( __LINE__, __FILE__, false, true ); - verify_analyze< list_tail< eof, any, eof > >( __LINE__, __FILE__, false, true ); - verify_analyze< list_tail< eof, any, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< list_tail< any, eof, eof > >( __LINE__, __FILE__, true, true ); - verify_analyze< list_tail< any, eof, any > >( __LINE__, __FILE__, true, false ); - verify_analyze< list_tail< any, any, eof > >( __LINE__, __FILE__, true, true ); + verify_analyze< list_tail< opt< any >, opt< any >, opt< any > > >( __LINE__, __FILE__, false, true ); + verify_analyze< list_tail< opt< any >, opt< any >, any > >( __LINE__, __FILE__, false, true ); + verify_analyze< list_tail< opt< any >, any, opt< any > > >( __LINE__, __FILE__, false, true ); + verify_analyze< list_tail< opt< any >, any, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< list_tail< any, opt< any >, opt< any > > >( __LINE__, __FILE__, true, true ); + verify_analyze< list_tail< any, opt< any >, any > >( __LINE__, __FILE__, true, false ); + verify_analyze< list_tail< any, any, opt< any > > >( __LINE__, __FILE__, true, true ); verify_analyze< list_tail< any, any, any > >( __LINE__, __FILE__, true, false ); verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); @@ -33,6 +33,7 @@ namespace TAO_PEGTL_NAMESPACE verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,a", result_type::success, 0 ); verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,b", result_type::success, 1 ); verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,a,a", result_type::success, 0 ); + verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,a,a,", result_type::success, 0 ); verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,a,a,a", result_type::success, 0 ); verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,a,a,b", result_type::success, 1 ); verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,a,a,,", result_type::success, 1 ); @@ -51,6 +52,8 @@ namespace TAO_PEGTL_NAMESPACE verify_rule< list_tail< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a, a", result_type::success, 0 ); verify_rule< list_tail< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a, a,", result_type::success, 0 ); verify_rule< list_tail< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a, a ,", result_type::success, 0 ); + verify_rule< list_tail< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a , a ,", result_type::success, 0 ); + verify_rule< list_tail< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a , a , ", result_type::success, 1 ); verify_rule< list_tail< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, " a , a ", result_type::local_failure, 7 ); } diff --git a/packages/PEGTL/src/test/pegtl/rule_minus.cpp b/packages/PEGTL/src/test/pegtl/rule_minus.cpp index 66c37197343fe2a3376554d14dc0e94827d639ec..f9b7c3c46b8291ab71bd6b95cabc1fe27a15ebaa 100644 --- a/packages/PEGTL/src/test/pegtl/rule_minus.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_minus.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_must.cpp b/packages/PEGTL/src/test/pegtl/rule_must.cpp index 1065457c58dca1c5796bf9b15c6a88f27081fafa..d10d793b8d8c707b004562a80ed435aa3d104b5f 100644 --- a/packages/PEGTL/src/test/pegtl/rule_must.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_must.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_not_at.cpp b/packages/PEGTL/src/test/pegtl/rule_not_at.cpp index aa5ba3b6641a13a1f2943f98887f149361e96c98..dedb5751f972c4c53ff821727ce22ff5ff388ad4 100644 --- a/packages/PEGTL/src/test/pegtl/rule_not_at.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_not_at.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_opt.cpp b/packages/PEGTL/src/test/pegtl/rule_opt.cpp index f05a738b7514319540fd3bf6f03f075bebbe5065..f145f091b9ad5a4aef36f08fd2b71f6501cea58b 100644 --- a/packages/PEGTL/src/test/pegtl/rule_opt.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_opt.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_opt_must.cpp b/packages/PEGTL/src/test/pegtl/rule_opt_must.cpp index 0adb157f657ccc8fb822782eab8d56c99bab3926..a6948b628a3a0c8f04a10ecd9dc345577193d293 100644 --- a/packages/PEGTL/src/test/pegtl/rule_opt_must.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_opt_must.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_pad.cpp b/packages/PEGTL/src/test/pegtl/rule_pad.cpp index 2bbfc254b2294c58d678e30540717005fb450174..8799e4eb047ab16276bf95de37b0ef2f1a65d703 100644 --- a/packages/PEGTL/src/test/pegtl/rule_pad.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_pad.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_pad_opt.cpp b/packages/PEGTL/src/test/pegtl/rule_pad_opt.cpp index d21bb55d8ef48f307918216618941aa71e7db600..993064a3fc86faef35d8a77e3798b7d9b5ce864d 100644 --- a/packages/PEGTL/src/test/pegtl/rule_pad_opt.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_pad_opt.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_partial.cpp b/packages/PEGTL/src/test/pegtl/rule_partial.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f1cc24df95cc1a4780b6b7b0b4adf12494c780a5 --- /dev/null +++ b/packages/PEGTL/src/test/pegtl/rule_partial.cpp @@ -0,0 +1,70 @@ +// Copyright (c) 2023 Dr. Colin Hirsch and Daniel Frey +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) + +#include "test.hpp" + +#include "verify_meta.hpp" +#include "verify_rule.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + template< typename Rule > + struct my_action + {}; + + template<> + struct my_action< eof > + { + static void apply0( bool& b ) + { + b = true; + } + }; + + void unit_test() + { + verify_meta< partial< eof >, internal::partial< eof >, eof >(); + verify_meta< partial< eof, any >, internal::partial< eof, any >, eof, any >(); + + verify_analyze< partial< any > >( __LINE__, __FILE__, false, false ); + verify_analyze< partial< eof > >( __LINE__, __FILE__, false, false ); + + verify_rule< partial< one< 'a' > > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< partial< one< 'a' > > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< partial< one< 'a' > > >( __LINE__, __FILE__, "aa", result_type::success, 1 ); + verify_rule< partial< one< 'a' > > >( __LINE__, __FILE__, "ab", result_type::success, 1 ); + verify_rule< partial< one< 'a' > > >( __LINE__, __FILE__, "ba", result_type::success, 2 ); + + verify_rule< partial< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< partial< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< partial< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::success, 0 ); + verify_rule< partial< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aba", result_type::success, 1 ); + verify_rule< partial< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abab", result_type::success, 2 ); + verify_rule< partial< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "bab", result_type::success, 3 ); + verify_rule< partial< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "cb", result_type::success, 2 ); + +#if defined( __cpp_exceptions ) + verify_rule< must< partial< one< 'a' > > > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< must< partial< one< 'a' > > > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< must< partial< one< 'a' > > > >( __LINE__, __FILE__, "aa", result_type::success, 1 ); + verify_rule< must< partial< one< 'a' > > > >( __LINE__, __FILE__, "ab", result_type::success, 1 ); + verify_rule< must< partial< one< 'a' > > > >( __LINE__, __FILE__, "ba", result_type::success, 2 ); + + verify_rule< must< partial< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< must< partial< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< must< partial< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "ab", result_type::success, 0 ); + verify_rule< must< partial< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "aba", result_type::success, 1 ); + verify_rule< must< partial< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "abab", result_type::success, 2 ); + verify_rule< must< partial< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "bab", result_type::success, 3 ); + verify_rule< must< partial< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "cb", result_type::success, 2 ); +#endif + + bool success = false; + TAO_PEGTL_TEST_ASSERT( parse< partial< eof >, my_action >( memory_input( "", __FUNCTION__ ), success ) ); + TAO_PEGTL_TEST_ASSERT( success ); + } + +} // namespace TAO_PEGTL_NAMESPACE + +#include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_plus.cpp b/packages/PEGTL/src/test/pegtl/rule_plus.cpp index f0b0942d34399a8d700f7c234e54829f23cc628c..4159bc6620760d0998683498d1811536414353e1 100644 --- a/packages/PEGTL/src/test/pegtl/rule_plus.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_plus.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_raise.cpp b/packages/PEGTL/src/test/pegtl/rule_raise.cpp index 7eaa05d97f5cdb1bc7f73c8c0c19e2934fad116e..2829d8033a05c888e6e5817a663d1ad32af1b746 100644 --- a/packages/PEGTL/src/test/pegtl/rule_raise.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_raise.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_rematch.cpp b/packages/PEGTL/src/test/pegtl/rule_rematch.cpp index 3c505d0b0cd627d47e4bd71d415edc9c64d260f1..b161a9c904d7ea1a8803862e22d51b0cdd5f9e52 100644 --- a/packages/PEGTL/src/test/pegtl/rule_rematch.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_rematch.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2019-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2019-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_rep.cpp b/packages/PEGTL/src/test/pegtl/rule_rep.cpp index ce259438a70d88b1c3030ebaa95b4d1d47c6c614..44d4303cdcfc5096eaa44e795716232b6d997e70 100644 --- a/packages/PEGTL/src/test/pegtl/rule_rep.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_rep.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_rep_max.cpp b/packages/PEGTL/src/test/pegtl/rule_rep_max.cpp index 2ff63e9cc90302325b70e90ffd2f53302b89fa0c..0c11dbb101b7d8317013807a830d8725fb1e92ef 100644 --- a/packages/PEGTL/src/test/pegtl/rule_rep_max.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_rep_max.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_rep_min.cpp b/packages/PEGTL/src/test/pegtl/rule_rep_min.cpp index 614db7363e91a188c27cd03e8f38523e3b28b2be..9d45e9b3b6958914482a4e1604835a20dd7588f2 100644 --- a/packages/PEGTL/src/test/pegtl/rule_rep_min.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_rep_min.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_rep_min_max.cpp b/packages/PEGTL/src/test/pegtl/rule_rep_min_max.cpp index ebf85c500b889a5df9b39322f85c1336b04cf7e1..8cd7143ae892010e16ce7e5d9d0a4efc04b967c5 100644 --- a/packages/PEGTL/src/test/pegtl/rule_rep_min_max.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_rep_min_max.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_rep_opt.cpp b/packages/PEGTL/src/test/pegtl/rule_rep_opt.cpp index c94a11ab7c0186463b1d714eea5e2b8d3b5f3917..75752541766eb8ec7097e7575c6f5f84bfba3138 100644 --- a/packages/PEGTL/src/test/pegtl/rule_rep_opt.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_rep_opt.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_require.cpp b/packages/PEGTL/src/test/pegtl/rule_require.cpp index b93e2e3a1c31ed9059de670ec98c3360a49697af..ce27ddf3480e2178a98145123008e684ab053439 100644 --- a/packages/PEGTL/src/test/pegtl/rule_require.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_require.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_seq.cpp b/packages/PEGTL/src/test/pegtl/rule_seq.cpp index f5eac6bbdbaad5755b2bbe5f62ec99885f3e569c..e5c72db17c520937be18fa2cf99e038340abfade 100644 --- a/packages/PEGTL/src/test/pegtl/rule_seq.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_seq.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_sor.cpp b/packages/PEGTL/src/test/pegtl/rule_sor.cpp index 7d087cb73c1a279bfb1beff03e7f7d8d52a7f9a9..decd73168d7e7523f4810bd17e7f100defa65464 100644 --- a/packages/PEGTL/src/test/pegtl/rule_sor.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_sor.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_star.cpp b/packages/PEGTL/src/test/pegtl/rule_star.cpp index df7d63e08164efe27e35c2572c2d7a9fe0f04dde..eb856b6987a6cafc73be9799845ece7cf62b30c2 100644 --- a/packages/PEGTL/src/test/pegtl/rule_star.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_star.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -23,6 +23,7 @@ namespace TAO_PEGTL_NAMESPACE verify_rule< star< one< 'a' > > >( __LINE__, __FILE__, "a", result_type::success, 0 ); verify_rule< star< one< 'a' > > >( __LINE__, __FILE__, "aa", result_type::success, 0 ); verify_rule< star< one< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::success, 0 ); + verify_rule< star< one< 'a' > > >( __LINE__, __FILE__, "aaab", result_type::success, 1 ); verify_rule< star< one< 'a' > > >( __LINE__, __FILE__, "ba", result_type::success, 2 ); verify_rule< star< one< 'a' > > >( __LINE__, __FILE__, "b", result_type::success, 1 ); @@ -30,6 +31,7 @@ namespace TAO_PEGTL_NAMESPACE verify_rule< star< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", result_type::success, 1 ); verify_rule< star< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::success, 0 ); verify_rule< star< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aba", result_type::success, 1 ); + verify_rule< star< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abac", result_type::success, 2 ); verify_rule< star< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abb", result_type::success, 1 ); verify_rule< star< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abab", result_type::success, 0 ); verify_rule< star< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ababc", result_type::success, 1 ); diff --git a/packages/PEGTL/src/test/pegtl/rule_star_must.cpp b/packages/PEGTL/src/test/pegtl/rule_star_must.cpp index 6b22eac70ffe94e4180473135e29fa7d68374941..60b88510fd84be6f3dcf93062f0f4e8bff2fa6c8 100644 --- a/packages/PEGTL/src/test/pegtl/rule_star_must.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_star_must.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_star_partial.cpp b/packages/PEGTL/src/test/pegtl/rule_star_partial.cpp new file mode 100644 index 0000000000000000000000000000000000000000..99826a3c2787b3b53b2ff53296697dfa8f1c564f --- /dev/null +++ b/packages/PEGTL/src/test/pegtl/rule_star_partial.cpp @@ -0,0 +1,44 @@ +// Copyright (c) 2023 Dr. Colin Hirsch and Daniel Frey +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) + +#include "test.hpp" + +#include "verify_meta.hpp" +#include "verify_rule.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + void unit_test() + { + verify_meta< star_partial< alpha >, internal::star_partial< alpha >, alpha >(); + verify_meta< star_partial< alpha, digit >, internal::star_partial< alpha, digit >, alpha, digit >(); + + verify_analyze< star_partial< eof > >( __LINE__, __FILE__, false, true ); + verify_analyze< star_partial< any > >( __LINE__, __FILE__, false, false ); + verify_analyze< star_partial< eof, eof, eof > >( __LINE__, __FILE__, false, true ); + verify_analyze< star_partial< any, eof, any > >( __LINE__, __FILE__, false, false ); + + verify_rule< star_partial< one< 'a' > > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< star_partial< one< 'a' > > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< star_partial< one< 'a' > > >( __LINE__, __FILE__, "aa", result_type::success, 0 ); + verify_rule< star_partial< one< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::success, 0 ); + verify_rule< star_partial< one< 'a' > > >( __LINE__, __FILE__, "aaab", result_type::success, 1 ); + verify_rule< star_partial< one< 'a' > > >( __LINE__, __FILE__, "ba", result_type::success, 2 ); + verify_rule< star_partial< one< 'a' > > >( __LINE__, __FILE__, "b", result_type::success, 1 ); + + verify_rule< star_partial< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< star_partial< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< star_partial< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aa", result_type::success, 1 ); + verify_rule< star_partial< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::success, 0 ); + verify_rule< star_partial< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aba", result_type::success, 0 ); + verify_rule< star_partial< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abac", result_type::success, 1 ); + verify_rule< star_partial< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abb", result_type::success, 1 ); + verify_rule< star_partial< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abab", result_type::success, 0 ); + verify_rule< star_partial< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ababc", result_type::success, 1 ); + verify_rule< star_partial< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ababab", result_type::success, 0 ); + } + +} // namespace TAO_PEGTL_NAMESPACE + +#include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_state.cpp b/packages/PEGTL/src/test/pegtl/rule_state.cpp index f29701262982d0eb081acbc42725dbd792b09aa7..30178bb7d01a80d3f5c0611b2a510cf80cc8a824 100644 --- a/packages/PEGTL/src/test/pegtl/rule_state.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_state.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_success.cpp b/packages/PEGTL/src/test/pegtl/rule_success.cpp index 03e0835369ed22bb8981190a6284b90acb729421..248b1a9b53903cb8943d888f4bc3c0542a032a33 100644 --- a/packages/PEGTL/src/test/pegtl/rule_success.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_success.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_try_catch.cpp b/packages/PEGTL/src/test/pegtl/rule_try_catch.cpp index 909cc77d9943b7c76d1259cd9da90ceeec3d225e..4fa24e6890664868740901b0e58cae65d04f7b51 100644 --- a/packages/PEGTL/src/test/pegtl/rule_try_catch.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_try_catch.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/rule_until.cpp b/packages/PEGTL/src/test/pegtl/rule_until.cpp index 12385c15a5ee30481d2118d1df11bd327d4ea8e5..32a19fef4be7e6f9f6ed5fec83fc8305165ff62f 100644 --- a/packages/PEGTL/src/test/pegtl/rule_until.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_until.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/test.hpp b/packages/PEGTL/src/test/pegtl/test.hpp index e25635ee2c02fbfe6ced5f1cfcd1079e9ec611d0..1fdba82661020ae838b1265ba0b8d6cbcb850a5c 100644 --- a/packages/PEGTL/src/test/pegtl/test.hpp +++ b/packages/PEGTL/src/test/pegtl/test.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -24,18 +24,18 @@ namespace TAO_PEGTL_NAMESPACE #define TAO_PEGTL_TEST_UNWRAP( ... ) __VA_ARGS__ -#define TAO_PEGTL_TEST_FAILED( MeSSaGe ) \ - do { \ - std::cerr << "pegtl: unit test failed for [ " \ - << TAO_PEGTL_NAMESPACE::demangle< Rule >() \ - << " ] " \ - << TAO_PEGTL_TEST_UNWRAP( MeSSaGe ) \ - << " in line [ " \ - << line \ - << " ] file [ " \ - << file << " ]" \ - << std::endl; \ - ++TAO_PEGTL_NAMESPACE::failed; \ +#define TAO_PEGTL_TEST_FAILED( MeSSaGe ) \ + do { \ + std::cerr << "pegtl: unit test failed for [ " \ + << TAO_PEGTL_NAMESPACE::demangle< Rule >() \ + << " ] " \ + << TAO_PEGTL_TEST_UNWRAP( MeSSaGe ) \ + << " in line [ " \ + << line \ + << " ] file [ " \ + << file << " ]" \ + << std::endl; \ + ++TAO_PEGTL_NAMESPACE::failed; \ } while( false ) #define TAO_PEGTL_TEST_ASSERT( ... ) \ @@ -48,7 +48,7 @@ namespace TAO_PEGTL_NAMESPACE << " ] file [ " \ << __FILE__ << " ]" \ << std::endl; \ - ++TAO_PEGTL_NAMESPACE::failed; \ + ++TAO_PEGTL_NAMESPACE::failed; \ } \ } while( false ) @@ -63,7 +63,7 @@ namespace TAO_PEGTL_NAMESPACE << " ] file [ " \ << __FILE__ << " ]" \ << std::endl; \ - ++TAO_PEGTL_NAMESPACE::failed; \ + ++TAO_PEGTL_NAMESPACE::failed; \ } \ catch( ... ) { \ } \ diff --git a/packages/PEGTL/src/test/pegtl/test_empty.cpp b/packages/PEGTL/src/test/pegtl/test_empty.cpp index bfc9967778d806fb6ee34979cba1ee8232a17c88..ab937430aac72d3973f1dac704d33e8b1e182038 100644 --- a/packages/PEGTL/src/test/pegtl/test_empty.cpp +++ b/packages/PEGTL/src/test/pegtl/test_empty.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/test_result.cpp b/packages/PEGTL/src/test/pegtl/test_result.cpp index 86554fb558a4cad9e4a3fdb75af72188cee44082..e95e9eb0ad1657e0c3546a07fe3a1f9cd9a72dd7 100644 --- a/packages/PEGTL/src/test/pegtl/test_result.cpp +++ b/packages/PEGTL/src/test/pegtl/test_result.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -29,7 +29,7 @@ namespace TAO_PEGTL_NAMESPACE } { std::ostringstream oss; - oss << result_type( 1764 ); + oss << static_cast< result_type >( 1764 ); TAO_PEGTL_TEST_ASSERT( oss.str() == "1764" ); } } diff --git a/packages/PEGTL/src/test/pegtl/test_setup.cpp b/packages/PEGTL/src/test/pegtl/test_setup.cpp index 20c3737bfa10b1986bdca50114aeb613fc25cb75..8496d8861441e48db291f11ca3bf66370de4c270 100644 --- a/packages/PEGTL/src/test/pegtl/test_setup.cpp +++ b/packages/PEGTL/src/test/pegtl/test_setup.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/uint16_general.cpp b/packages/PEGTL/src/test/pegtl/uint16_general.cpp index 134ecbb9baf87083b59a0b516cc1059d07d42a2f..7e82970265b57b574264e9a28594e79034328d9e 100644 --- a/packages/PEGTL/src/test/pegtl/uint16_general.cpp +++ b/packages/PEGTL/src/test/pegtl/uint16_general.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/uint32_general.cpp b/packages/PEGTL/src/test/pegtl/uint32_general.cpp index f5f259df1b85902578c1fcb058fdd2011322d8bd..45a8f376e49a643249abd7963cac0dd1389511b0 100644 --- a/packages/PEGTL/src/test/pegtl/uint32_general.cpp +++ b/packages/PEGTL/src/test/pegtl/uint32_general.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/uint64_general.cpp b/packages/PEGTL/src/test/pegtl/uint64_general.cpp index 91daedb35648d9bef7a01ed482e5e4f92c31ffaf..47a7326f23f3565ce03fd2ff28e386566990a88f 100644 --- a/packages/PEGTL/src/test/pegtl/uint64_general.cpp +++ b/packages/PEGTL/src/test/pegtl/uint64_general.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/uint8_general.cpp b/packages/PEGTL/src/test/pegtl/uint8_general.cpp index ee6baff86d76ca5992d7171392a293c2a9761111..df2ed319ae167dc11acf4d0c5d835ef6fd19b16c 100644 --- a/packages/PEGTL/src/test/pegtl/uint8_general.cpp +++ b/packages/PEGTL/src/test/pegtl/uint8_general.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/utf16_general.cpp b/packages/PEGTL/src/test/pegtl/utf16_general.cpp index 7e32a8cce8a3e4de9d92dc00bc419fe98c885edb..875395ca82a33a7926945bd3ddf1ddd057a66aee 100644 --- a/packages/PEGTL/src/test/pegtl/utf16_general.cpp +++ b/packages/PEGTL/src/test/pegtl/utf16_general.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -13,19 +13,19 @@ namespace TAO_PEGTL_NAMESPACE { std::string u16s( const char16_t u ) { - return std::string( reinterpret_cast< const char* >( &u ), sizeof( u ) ); + return { reinterpret_cast< const char* >( &u ), sizeof( u ) }; } std::string u16s_be( const char16_t v ) { - const std::uint16_t u = internal::h_to_be( std::uint16_t( v ) ); - return std::string( reinterpret_cast< const char* >( &u ), sizeof( u ) ); + const std::uint16_t u = internal::h_to_be( static_cast< std::uint16_t >( v ) ); + return { reinterpret_cast< const char* >( &u ), sizeof( u ) }; } std::string u16s_le( const char16_t v ) { - const std::uint16_t u = internal::h_to_le( std::uint16_t( v ) ); - return std::string( reinterpret_cast< const char* >( &u ), sizeof( u ) ); + const std::uint16_t u = internal::h_to_le( static_cast< std::uint16_t >( v ) ); + return { reinterpret_cast< const char* >( &u ), sizeof( u ) }; } } // namespace diff --git a/packages/PEGTL/src/test/pegtl/utf32_general.cpp b/packages/PEGTL/src/test/pegtl/utf32_general.cpp index 21895a9dfb3534c4a639c6a3c2d7d54a3cbc4876..837fcd149578709388d018ea4958b2ab33a6ac26 100644 --- a/packages/PEGTL/src/test/pegtl/utf32_general.cpp +++ b/packages/PEGTL/src/test/pegtl/utf32_general.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) @@ -13,19 +13,19 @@ namespace TAO_PEGTL_NAMESPACE { std::string u32s( const char32_t u ) { - return std::string( reinterpret_cast< const char* >( &u ), sizeof( u ) ); + return { reinterpret_cast< const char* >( &u ), sizeof( u ) }; } std::string u32s_be( const char32_t v ) { - const std::uint32_t u = internal::h_to_be( std::uint32_t( v ) ); - return std::string( reinterpret_cast< const char* >( &u ), sizeof( u ) ); + const std::uint32_t u = internal::h_to_be( static_cast< std::uint32_t >( v ) ); + return { reinterpret_cast< const char* >( &u ), sizeof( u ) }; } std::string u32s_le( const char32_t v ) { - const std::uint32_t u = internal::h_to_le( std::uint32_t( v ) ); - return std::string( reinterpret_cast< const char* >( &u ), sizeof( u ) ); + const std::uint32_t u = internal::h_to_le( static_cast< std::uint32_t >( v ) ); + return { reinterpret_cast< const char* >( &u ), sizeof( u ) }; } } // namespace diff --git a/packages/PEGTL/src/test/pegtl/utf8_general.cpp b/packages/PEGTL/src/test/pegtl/utf8_general.cpp index cab108dc67bfa4766f7b83f505a268eb5177cbd4..3f06ef683734ca2e4b5c07a6e081fe486ebb0df5 100644 --- a/packages/PEGTL/src/test/pegtl/utf8_general.cpp +++ b/packages/PEGTL/src/test/pegtl/utf8_general.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/verify_char.hpp b/packages/PEGTL/src/test/pegtl/verify_char.hpp index 32290bc4f82a36d1bf4763c1a5d4bb11205fb122..301687f89a2db4c058c000a8217a31f45910da46 100644 --- a/packages/PEGTL/src/test/pegtl/verify_char.hpp +++ b/packages/PEGTL/src/test/pegtl/verify_char.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/verify_file.hpp b/packages/PEGTL/src/test/pegtl/verify_file.hpp index b8a27230c97778eb286be3387d25dffb02b6efb9..f146e55dd9b11446d85f3b8716ec36ee4531e97b 100644 --- a/packages/PEGTL/src/test/pegtl/verify_file.hpp +++ b/packages/PEGTL/src/test/pegtl/verify_file.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/verify_ifmt.hpp b/packages/PEGTL/src/test/pegtl/verify_ifmt.hpp index 1dffef16e4b02cbfd93e8e6983cb0e14c5afbfcc..94312aedec06af1b5cb80db5bf2c1ebfc872e995 100644 --- a/packages/PEGTL/src/test/pegtl/verify_ifmt.hpp +++ b/packages/PEGTL/src/test/pegtl/verify_ifmt.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/verify_impl.hpp b/packages/PEGTL/src/test/pegtl/verify_impl.hpp index 6a4a93f898f08aa29558eb334bc0b0e4d11326df..cfe61a1aa04da0dbe0ab09fdc0356076d0c30314 100644 --- a/packages/PEGTL/src/test/pegtl/verify_impl.hpp +++ b/packages/PEGTL/src/test/pegtl/verify_impl.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/verify_meta.hpp b/packages/PEGTL/src/test/pegtl/verify_meta.hpp index 40d871210d756f4c90579c75281d5420395bac56..6f4252ec984319ce2b18e49cbd886cbb09b4b5e1 100644 --- a/packages/PEGTL/src/test/pegtl/verify_meta.hpp +++ b/packages/PEGTL/src/test/pegtl/verify_meta.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/verify_rule.hpp b/packages/PEGTL/src/test/pegtl/verify_rule.hpp index d24076b9d4eb38d08fa8b4b0d4be52c6e7238474..e952a83770d3f3b6398c1ac1cfa1b9580a6faca3 100644 --- a/packages/PEGTL/src/test/pegtl/verify_rule.hpp +++ b/packages/PEGTL/src/test/pegtl/verify_rule.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/verify_seqs.hpp b/packages/PEGTL/src/test/pegtl/verify_seqs.hpp index 487c995276b64ccbd82fd75496229b6fa5289e9f..6b57e0a88e585d111ebb8eee2ba2dfb3d94aaa8e 100644 --- a/packages/PEGTL/src/test/pegtl/verify_seqs.hpp +++ b/packages/PEGTL/src/test/pegtl/verify_seqs.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/packages/PEGTL/src/test/pegtl/visit.cpp b/packages/PEGTL/src/test/pegtl/visit.cpp index 2b30442f05dcceaa0c7de9fba8b8d901de8e5a94..837250edf16a321f392e21cf34c75968fa37c7cd 100644 --- a/packages/PEGTL/src/test/pegtl/visit.cpp +++ b/packages/PEGTL/src/test/pegtl/visit.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2020-2023 Dr. Colin Hirsch and Daniel Frey // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt) diff --git a/tests/test_ASTNode.cpp b/tests/test_ASTNode.cpp index 468a27a89dbe3be40c20ad386cd82434e52f2807..cda39283b3848f893a8bae7955d9ef57efc70839 100644 --- a/tests/test_ASTNode.cpp +++ b/tests/test_ASTNode.cpp @@ -54,8 +54,8 @@ TEST_CASE("ASTNode", "[language]") ASTNode ast_node; ast_node.source = "content"; const char* const start = &ast_node.source[0]; - ast_node.m_begin = TAO_PEGTL_NAMESPACE::internal::iterator{start}; - ast_node.m_end = TAO_PEGTL_NAMESPACE::internal::iterator{start + 7}; + ast_node.m_begin = TAO_PEGTL_NAMESPACE::internal::frobnicator{start}; + ast_node.m_end = TAO_PEGTL_NAMESPACE::internal::frobnicator{start + 7}; REQUIRE(ast_node.string() == "content"); REQUIRE(ast_node.string_view() == "content"); @@ -66,13 +66,13 @@ TEST_CASE("ASTNode", "[language]") ASTNode ast_node; ast_node.source = "content"; const char* const start = &ast_node.source[0]; - ast_node.m_begin = TAO_PEGTL_NAMESPACE::internal::iterator{start + 2}; + ast_node.m_begin = TAO_PEGTL_NAMESPACE::internal::frobnicator{start + 2}; { std::unique_ptr<ASTNode> child0_node = std::make_unique<ASTNode>(); - child0_node->m_begin = TAO_PEGTL_NAMESPACE::internal::iterator{start}; - child0_node->m_end = TAO_PEGTL_NAMESPACE::internal::iterator{start + 3}; + child0_node->m_begin = TAO_PEGTL_NAMESPACE::internal::frobnicator{start}; + child0_node->m_end = TAO_PEGTL_NAMESPACE::internal::frobnicator{start + 3}; ast_node.children.emplace_back(std::move(child0_node)); } @@ -80,8 +80,8 @@ TEST_CASE("ASTNode", "[language]") { std::unique_ptr<ASTNode> child1_node = std::make_unique<ASTNode>(); - child1_node->m_begin = TAO_PEGTL_NAMESPACE::internal::iterator{start + 4}; - child1_node->m_end = TAO_PEGTL_NAMESPACE::internal::iterator{start + 7}; + child1_node->m_begin = TAO_PEGTL_NAMESPACE::internal::frobnicator{start + 4}; + child1_node->m_end = TAO_PEGTL_NAMESPACE::internal::frobnicator{start + 7}; ast_node.children.emplace_back(std::move(child1_node)); } diff --git a/tests/test_ASTNodeDataType.cpp b/tests/test_ASTNodeDataType.cpp index 420ca58f6b366b8d41f14eafb5b22f43b52e6c99..b58ffe19772faef4de5b00e784207b806d101d00 100644 --- a/tests/test_ASTNodeDataType.cpp +++ b/tests/test_ASTNodeDataType.cpp @@ -116,8 +116,8 @@ TEST_CASE("ASTNodeDataType", "[language]") dimension_node->set_type<language::integer>(); dimension_node->source = "3"; const char* const beginning = &dimension_node->source[0]; - dimension_node->m_begin = TAO_PEGTL_NAMESPACE::internal::iterator{beginning}; - dimension_node->m_end = TAO_PEGTL_NAMESPACE::internal::iterator{beginning + 1}; + dimension_node->m_begin = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning}; + dimension_node->m_end = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning + 1}; type_node->emplace_back(std::move(dimension_node)); } @@ -156,8 +156,8 @@ TEST_CASE("ASTNodeDataType", "[language]") { type_node->children[1]->source = "0"; const char* const beginning = &type_node->children[1]->source[0]; - type_node->children[1]->m_begin = TAO_PEGTL_NAMESPACE::internal::iterator{beginning}; - type_node->children[1]->m_end = TAO_PEGTL_NAMESPACE::internal::iterator{beginning + 1}; + type_node->children[1]->m_begin = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning}; + type_node->children[1]->m_end = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning + 1}; REQUIRE_THROWS_WITH(getVectorDataType(*type_node), "invalid dimension (must be 1, 2 or 3)"); } @@ -165,8 +165,8 @@ TEST_CASE("ASTNodeDataType", "[language]") { type_node->children[1]->source = "1"; const char* const beginning = &type_node->children[1]->source[0]; - type_node->children[1]->m_begin = TAO_PEGTL_NAMESPACE::internal::iterator{beginning}; - type_node->children[1]->m_end = TAO_PEGTL_NAMESPACE::internal::iterator{beginning + 1}; + type_node->children[1]->m_begin = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning}; + type_node->children[1]->m_end = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning + 1}; REQUIRE_NOTHROW(getVectorDataType(*type_node)); } @@ -174,8 +174,8 @@ TEST_CASE("ASTNodeDataType", "[language]") { type_node->children[1]->source = "4"; const char* const beginning = &type_node->children[1]->source[0]; - type_node->children[1]->m_begin = TAO_PEGTL_NAMESPACE::internal::iterator{beginning}; - type_node->children[1]->m_end = TAO_PEGTL_NAMESPACE::internal::iterator{beginning + 1}; + type_node->children[1]->m_begin = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning}; + type_node->children[1]->m_end = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning + 1}; REQUIRE_THROWS_WITH(getVectorDataType(*type_node), "invalid dimension (must be 1, 2 or 3)"); } @@ -257,8 +257,8 @@ TEST_CASE("ASTNodeDataType", "[language]") dimension0_node->set_type<language::integer>(); dimension0_node->source = "3"; const char* const beginning = &dimension0_node->source[0]; - dimension0_node->m_begin = TAO_PEGTL_NAMESPACE::internal::iterator{beginning}; - dimension0_node->m_end = TAO_PEGTL_NAMESPACE::internal::iterator{beginning + 1}; + dimension0_node->m_begin = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning}; + dimension0_node->m_end = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning + 1}; type_node->emplace_back(std::move(dimension0_node)); } { @@ -266,8 +266,8 @@ TEST_CASE("ASTNodeDataType", "[language]") dimension1_node->set_type<language::integer>(); dimension1_node->source = "3"; const char* const beginning = &dimension1_node->source[0]; - dimension1_node->m_begin = TAO_PEGTL_NAMESPACE::internal::iterator{beginning}; - dimension1_node->m_end = TAO_PEGTL_NAMESPACE::internal::iterator{beginning + 1}; + dimension1_node->m_begin = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning}; + dimension1_node->m_end = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning + 1}; type_node->emplace_back(std::move(dimension1_node)); } } @@ -314,14 +314,14 @@ TEST_CASE("ASTNodeDataType", "[language]") { type_node->children[1]->source = "0"; const char* const beginning = &type_node->children[1]->source[0]; - type_node->children[1]->m_begin = TAO_PEGTL_NAMESPACE::internal::iterator{beginning}; - type_node->children[1]->m_end = TAO_PEGTL_NAMESPACE::internal::iterator{beginning + 1}; + type_node->children[1]->m_begin = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning}; + type_node->children[1]->m_end = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning + 1}; } { type_node->children[2]->source = "0"; const char* const beginning = &type_node->children[2]->source[0]; - type_node->children[2]->m_begin = TAO_PEGTL_NAMESPACE::internal::iterator{beginning}; - type_node->children[2]->m_end = TAO_PEGTL_NAMESPACE::internal::iterator{beginning + 1}; + type_node->children[2]->m_begin = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning}; + type_node->children[2]->m_end = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning + 1}; } REQUIRE_THROWS_WITH(getMatrixDataType(*type_node), "invalid dimension (must be 1, 2 or 3)"); @@ -329,14 +329,14 @@ TEST_CASE("ASTNodeDataType", "[language]") { type_node->children[1]->source = "4"; const char* const beginning = &type_node->children[1]->source[0]; - type_node->children[1]->m_begin = TAO_PEGTL_NAMESPACE::internal::iterator{beginning}; - type_node->children[1]->m_end = TAO_PEGTL_NAMESPACE::internal::iterator{beginning + 1}; + type_node->children[1]->m_begin = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning}; + type_node->children[1]->m_end = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning + 1}; } { type_node->children[2]->source = "4"; const char* const beginning = &type_node->children[2]->source[0]; - type_node->children[2]->m_begin = TAO_PEGTL_NAMESPACE::internal::iterator{beginning}; - type_node->children[2]->m_end = TAO_PEGTL_NAMESPACE::internal::iterator{beginning + 1}; + type_node->children[2]->m_begin = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning}; + type_node->children[2]->m_end = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning + 1}; } REQUIRE_THROWS_WITH(getMatrixDataType(*type_node), "invalid dimension (must be 1, 2 or 3)"); @@ -347,14 +347,14 @@ TEST_CASE("ASTNodeDataType", "[language]") { type_node->children[1]->source = "1"; const char* const beginning = &type_node->children[1]->source[0]; - type_node->children[1]->m_begin = TAO_PEGTL_NAMESPACE::internal::iterator{beginning}; - type_node->children[1]->m_end = TAO_PEGTL_NAMESPACE::internal::iterator{beginning + 1}; + type_node->children[1]->m_begin = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning}; + type_node->children[1]->m_end = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning + 1}; } { type_node->children[2]->source = "2"; const char* const beginning = &type_node->children[2]->source[0]; - type_node->children[2]->m_begin = TAO_PEGTL_NAMESPACE::internal::iterator{beginning}; - type_node->children[2]->m_end = TAO_PEGTL_NAMESPACE::internal::iterator{beginning + 1}; + type_node->children[2]->m_begin = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning}; + type_node->children[2]->m_end = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning + 1}; } REQUIRE_THROWS_WITH(getMatrixDataType(*type_node), "only square matrices are supported"); } diff --git a/tests/test_ASTNodeNaturalConversionChecker.cpp b/tests/test_ASTNodeNaturalConversionChecker.cpp index 0d6dbd3d60550dcfae86e32398c987f8b2d4583b..161b934cb68b1825b5878f380e7cd395a7c612c0 100644 --- a/tests/test_ASTNodeNaturalConversionChecker.cpp +++ b/tests/test_ASTNodeNaturalConversionChecker.cpp @@ -100,8 +100,8 @@ TEST_CASE("ASTNodeNaturalConversionChecker", "[language]") data_node->set_type<language::integer>(); data_node->source = "0"; const char* const beginning = &data_node->source[0]; - data_node->m_begin = TAO_PEGTL_NAMESPACE::internal::iterator{beginning}; - data_node->m_end = TAO_PEGTL_NAMESPACE::internal::iterator{beginning + 1}; + data_node->m_begin = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning}; + data_node->m_end = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning + 1}; SECTION("d = 1") { @@ -150,8 +150,8 @@ TEST_CASE("ASTNodeNaturalConversionChecker", "[language]") data_node->set_type<language::integer>(); data_node->source = "0"; const char* const beginning = &data_node->source[0]; - data_node->m_begin = TAO_PEGTL_NAMESPACE::internal::iterator{beginning}; - data_node->m_end = TAO_PEGTL_NAMESPACE::internal::iterator{beginning + 1}; + data_node->m_begin = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning}; + data_node->m_end = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning + 1}; SECTION("d = 1") { @@ -924,8 +924,8 @@ TEST_CASE("ASTNodeNaturalConversionChecker", "[language]") data_node->set_type<language::integer>(); data_node->source = "1"; const char* const beginning = &data_node->source[0]; - data_node->m_begin = TAO_PEGTL_NAMESPACE::internal::iterator{beginning}; - data_node->m_end = TAO_PEGTL_NAMESPACE::internal::iterator{beginning + 1}; + data_node->m_begin = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning}; + data_node->m_end = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning + 1}; SECTION("d=1") { @@ -1382,8 +1382,8 @@ TEST_CASE("ASTNodeNaturalConversionChecker", "[language]") data_node->set_type<language::integer>(); data_node->source = "1"; const char* const beginning = &data_node->source[0]; - data_node->m_begin = TAO_PEGTL_NAMESPACE::internal::iterator{beginning}; - data_node->m_end = TAO_PEGTL_NAMESPACE::internal::iterator{beginning + 1}; + data_node->m_begin = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning}; + data_node->m_end = TAO_PEGTL_NAMESPACE::internal::frobnicator{beginning + 1}; SECTION("d=1") { diff --git a/tests/test_ASTSymbolInitializationChecker.cpp b/tests/test_ASTSymbolInitializationChecker.cpp index b9bcef85937ee0563bb1d7f51e55ceaa00eaa93a..52b49d7c90ef3183a1cb6bd984493320f7484495 100644 --- a/tests/test_ASTSymbolInitializationChecker.cpp +++ b/tests/test_ASTSymbolInitializationChecker.cpp @@ -27,8 +27,8 @@ let p:N; ASTSymbolTableBuilder{*ast}; ASTSymbolInitializationChecker{*ast}; - position position{internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + position position{data.size(), 1, 1, "fixture"}; auto [symbol_m, found_m] = ast->m_symbol_table->find("m", position); REQUIRE(found_m); @@ -59,8 +59,8 @@ m = n; ASTSymbolTableBuilder{*ast}; ASTSymbolInitializationChecker{*ast}; - position position{internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + position position{data.size(), 1, 1, "fixture"}; auto [symbol_m, found_m] = ast->m_symbol_table->find("m", position); REQUIRE(found_m); @@ -87,8 +87,8 @@ let f: R->R, x->x+1; ASTSymbolTableBuilder{*ast}; ASTSymbolInitializationChecker{*ast}; - position position{internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + position position{data.size(), 1, 1, "fixture"}; auto [symbol_m, found_m] = ast->m_symbol_table->find("f", position); REQUIRE(found_m); @@ -109,8 +109,8 @@ let (x,y):R*R, (x,y) = (2.3, 4.1); ASTSymbolTableBuilder{*ast}; ASTSymbolInitializationChecker{*ast}; - position position{internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + position position{data.size(), 1, 1, "fixture"}; auto [symbol_x, found_x] = ast->m_symbol_table->find("x", position); REQUIRE(found_x); @@ -133,8 +133,8 @@ let x:R^2, x = (2.3, 4.1); ASTSymbolTableBuilder{*ast}; ASTSymbolInitializationChecker{*ast}; - position position{internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + position position{data.size(), 1, 1, "fixture"}; auto [symbol_x, found_x] = ast->m_symbol_table->find("x", position); REQUIRE(found_x); @@ -154,8 +154,8 @@ y = 3; ASTSymbolTableBuilder{*ast}; ASTSymbolInitializationChecker{*ast}; - position position{internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + position position{data.size(), 1, 1, "fixture"}; auto [symbol_x, found_x] = ast->m_symbol_table->find("x", position); REQUIRE(found_x); @@ -179,8 +179,8 @@ let (x,y):R*R; ASTSymbolTableBuilder{*ast}; ASTSymbolInitializationChecker{*ast}; - position position{internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + position position{data.size(), 1, 1, "fixture"}; auto [symbol_x, found_x] = ast->m_symbol_table->find("x", position); REQUIRE(found_x); @@ -204,8 +204,8 @@ let (x,y):R^3*R; ASTSymbolTableBuilder{*ast}; ASTSymbolInitializationChecker{*ast}; - position position{internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + position position{data.size(), 1, 1, "fixture"}; auto [symbol_x, found_x] = ast->m_symbol_table->find("x", position); REQUIRE(found_x); diff --git a/tests/test_AffectationProcessor.cpp b/tests/test_AffectationProcessor.cpp index 03781088ae664cff01ebde37314e0af1b15826ca..599a9457f4cb940f08409d47ebb7ef2c792e7478 100644 --- a/tests/test_AffectationProcessor.cpp +++ b/tests/test_AffectationProcessor.cpp @@ -45,8 +45,7 @@ auto symbol_table = ast->m_symbol_table; \ \ using namespace TAO_PEGTL_NAMESPACE; \ - position use_position{internal::iterator{"fixture"}, "fixture"}; \ - use_position.byte = 10000; \ + position use_position{10000, 1000, 10, "fixture"}; \ auto [symbol, found] = symbol_table->find(variable_name, use_position); \ \ auto attributes = symbol->attributes(); \ @@ -106,8 +105,7 @@ ASTBacktrace::destroy(); \ \ using namespace TAO_PEGTL_NAMESPACE; \ - position use_position{internal::iterator{"fixture"}, "fixture"}; \ - use_position.byte = 10000; \ + position use_position{10000, 1000, 10, "fixture"}; \ auto [symbol, found] = symbol_table.find(variable_name, use_position); \ \ auto attributes = symbol->attributes(); \ diff --git a/tests/test_AffectationToStringProcessor.cpp b/tests/test_AffectationToStringProcessor.cpp index 8e15ddc66cb379b841232ad377d244833aa618a6..68f97dfedd38da47c31a3aef9e64364e31e29a97 100644 --- a/tests/test_AffectationToStringProcessor.cpp +++ b/tests/test_AffectationToStringProcessor.cpp @@ -40,7 +40,7 @@ auto symbol_table = ast->m_symbol_table; \ \ using namespace TAO_PEGTL_NAMESPACE; \ - position use_position{internal::iterator{"fixture"}, "fixture"}; \ + position use_position{10000, 1000, 10, "fixture"}; \ use_position.byte = 10000; \ auto [symbol, found] = symbol_table->find(variable_name, use_position); \ \ diff --git a/tests/test_AffectationToTupleProcessor.cpp b/tests/test_AffectationToTupleProcessor.cpp index ca6a6294b77f14ed8846a60823fdf8d8632a56ba..b8e7010c9bcd748b168f048163619b7c61622edc 100644 --- a/tests/test_AffectationToTupleProcessor.cpp +++ b/tests/test_AffectationToTupleProcessor.cpp @@ -40,8 +40,7 @@ auto symbol_table = ast->m_symbol_table; \ \ using namespace TAO_PEGTL_NAMESPACE; \ - position use_position{internal::iterator{"fixture"}, "fixture"}; \ - use_position.byte = 10000; \ + position use_position{10000, 1000, 10, "fixture"}; \ auto [symbol, found] = symbol_table->find(variable_name, use_position); \ \ auto attributes = symbol->attributes(); \ diff --git a/tests/test_ArraySubscriptProcessor.cpp b/tests/test_ArraySubscriptProcessor.cpp index 949951c226c55ee77234885175e5f0f9a42f287f..48998c7d39999b5c45590a80054377d5057c4355 100644 --- a/tests/test_ArraySubscriptProcessor.cpp +++ b/tests/test_ArraySubscriptProcessor.cpp @@ -41,8 +41,7 @@ auto symbol_table = ast->m_symbol_table; \ \ using namespace TAO_PEGTL_NAMESPACE; \ - position use_position{internal::iterator{"fixture"}, "fixture"}; \ - use_position.byte = 10000; \ + position use_position{10000, 1000, 10, "fixture"}; \ auto [symbol, found] = symbol_table->find(variable_name, use_position); \ \ auto attributes = symbol->attributes(); \ diff --git a/tests/test_BinaryExpressionProcessor_arithmetic.cpp b/tests/test_BinaryExpressionProcessor_arithmetic.cpp index c93face344864f42e968322ce86f0f03efeabae9..c1ce3de0e03f5d9b0b14e43ba71cc06fd4c70359 100644 --- a/tests/test_BinaryExpressionProcessor_arithmetic.cpp +++ b/tests/test_BinaryExpressionProcessor_arithmetic.cpp @@ -81,8 +81,7 @@ ASTBacktrace::destroy(); \ \ using namespace TAO_PEGTL_NAMESPACE; \ - position use_position{internal::iterator{"fixture"}, "fixture"}; \ - use_position.byte = 10000; \ + position use_position{10000, 1000, 10, "fixture"}; \ auto [symbol, found] = symbol_table.find("r", use_position); \ \ auto attributes = symbol->attributes(); \ diff --git a/tests/test_BinaryExpressionProcessor_utils.hpp b/tests/test_BinaryExpressionProcessor_utils.hpp index 5983cda355f76c7ed58d47fa544dc5fd82ba3b09..4b5deff94b6cab09ccdb72e6113dd5c2cc83d2e5 100644 --- a/tests/test_BinaryExpressionProcessor_utils.hpp +++ b/tests/test_BinaryExpressionProcessor_utils.hpp @@ -38,8 +38,7 @@ auto symbol_table = ast->m_symbol_table; \ \ using namespace TAO_PEGTL_NAMESPACE; \ - position use_position{internal::iterator{"fixture"}, "fixture"}; \ - use_position.byte = 10000; \ + position use_position{10000, 1000, 1, "fixture"}; \ auto [symbol, found] = symbol_table->find(variable_name, use_position); \ \ auto attributes = symbol->attributes(); \ diff --git a/tests/test_BuiltinFunctionProcessor.cpp b/tests/test_BuiltinFunctionProcessor.cpp index 67812b0a4442e4d336dd20d5d579137804fe190b..de04b76016ad02a78130574129b74d95ca38ba94 100644 --- a/tests/test_BuiltinFunctionProcessor.cpp +++ b/tests/test_BuiltinFunctionProcessor.cpp @@ -39,8 +39,7 @@ auto symbol_table = ast->m_symbol_table; \ \ using namespace TAO_PEGTL_NAMESPACE; \ - position use_position{internal::iterator{"fixture"}, "fixture"}; \ - use_position.byte = 10000; \ + position use_position{10000, 1000, 10, "fixture"}; \ auto [symbol, found] = symbol_table->find(variable_name, use_position); \ \ REQUIRE_THAT(found, Catch::Matchers::Predicate<bool>([](bool found) -> bool { return found; }, \ diff --git a/tests/test_ConcatExpressionProcessor.cpp b/tests/test_ConcatExpressionProcessor.cpp index e7779f0bc3296773915de07d529b126b5380674c..315f89d518e0262cdc6b44d3d99f13673d803168 100644 --- a/tests/test_ConcatExpressionProcessor.cpp +++ b/tests/test_ConcatExpressionProcessor.cpp @@ -38,8 +38,7 @@ auto symbol_table = ast->m_symbol_table; \ \ using namespace TAO_PEGTL_NAMESPACE; \ - position use_position{internal::iterator{"fixture"}, "fixture"}; \ - use_position.byte = 10000; \ + position use_position{10000, 1000, 10, "fixture"}; \ auto [symbol, found] = symbol_table->find(variable_name, use_position); \ \ auto attributes = symbol->attributes(); \ diff --git a/tests/test_DiscreteFunctionIntegrator.cpp b/tests/test_DiscreteFunctionIntegrator.cpp index 26a14385f67501c8f9145d5bfa6756517726849e..8970a360d6c0bf96feae69f17df05ba806cc44ef 100644 --- a/tests/test_DiscreteFunctionIntegrator.cpp +++ b/tests/test_DiscreteFunctionIntegrator.cpp @@ -87,8 +87,8 @@ let R3x3_non_linear_1d: R^1 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin( std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("B_scalar_non_linear_1d") { @@ -323,8 +323,8 @@ let R3x3_non_linear_2d: R^2 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin( std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("B_scalar_non_linear_2d") { @@ -559,8 +559,8 @@ let R3x3_non_linear_3d: R^3 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin( std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("B_scalar_non_linear_3d") { diff --git a/tests/test_DiscreteFunctionIntegratorByZone.cpp b/tests/test_DiscreteFunctionIntegratorByZone.cpp index 0b550b063fd14ec53df39f9395c4061ef997f17e..4027507e4c06ab7b97acec7a42707a03536f79c8 100644 --- a/tests/test_DiscreteFunctionIntegratorByZone.cpp +++ b/tests/test_DiscreteFunctionIntegratorByZone.cpp @@ -90,8 +90,8 @@ let R3x3_non_linear_1d: R^1 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin( std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("B_scalar_non_linear_1d") { @@ -419,8 +419,8 @@ let R3x3_non_linear_2d: R^2 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin( std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("B_scalar_non_linear_2d") { @@ -748,8 +748,8 @@ let R3x3_non_linear_3d: R^3 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin( std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("B_scalar_non_linear_3d") { diff --git a/tests/test_DiscreteFunctionInterpoler.cpp b/tests/test_DiscreteFunctionInterpoler.cpp index fd3f3b6724e3ff8efd1cd3446d261cd06de448fb..ed28e8f929d3b640395a17981c3b86abb57018bd 100644 --- a/tests/test_DiscreteFunctionInterpoler.cpp +++ b/tests/test_DiscreteFunctionInterpoler.cpp @@ -85,8 +85,8 @@ let R3x3_non_linear_1d: R^1 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin( std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("B_scalar_non_linear_1d") { @@ -374,8 +374,8 @@ let R3x3_non_linear_2d: R^2 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin( std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("B_scalar_non_linear_2d") { @@ -664,8 +664,8 @@ let R3x3_non_linear_3d: R^3 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin( std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("B_scalar_non_linear_3d") { diff --git a/tests/test_DiscreteFunctionInterpolerByZone.cpp b/tests/test_DiscreteFunctionInterpolerByZone.cpp index 8a0297d3ef1de251c23a66107303aa02f3d23fb8..dd242220e3eb17b8d45c8cbf8a83ada5b10acd83 100644 --- a/tests/test_DiscreteFunctionInterpolerByZone.cpp +++ b/tests/test_DiscreteFunctionInterpolerByZone.cpp @@ -93,8 +93,8 @@ let R3x3_non_linear_1d: R^1 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin( std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("B_scalar_non_linear_1d") { @@ -426,8 +426,8 @@ let R3x3_non_linear_2d: R^2 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin( std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("B_scalar_non_linear_2d") { @@ -760,8 +760,8 @@ let R3x3_non_linear_3d: R^3 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin( std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("B_scalar_non_linear_3d") { diff --git a/tests/test_DiscreteFunctionVectorIntegrator.cpp b/tests/test_DiscreteFunctionVectorIntegrator.cpp index 60afd2dbcf3e1e730cbaf273166e0258d8ae40f2..e5712786254c42723778e05cc37e2a3158f90bda 100644 --- a/tests/test_DiscreteFunctionVectorIntegrator.cpp +++ b/tests/test_DiscreteFunctionVectorIntegrator.cpp @@ -90,8 +90,8 @@ let R_scalar_non_linear_1d: R^1 -> R, x -> 2 * exp(x[0]) + 3; ASTNodeTypeCleaner<language::fct_declaration>{*ast}; ASTNodeExpressionBuilder{*ast}; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; @@ -179,8 +179,8 @@ let R_scalar_non_linear_2d: R^2 -> R, x -> 2 * exp(x[0] + x[1]) + 3; ASTNodeTypeCleaner<language::fct_declaration>{*ast}; ASTNodeExpressionBuilder{*ast}; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; @@ -268,8 +268,8 @@ let R_scalar_non_linear_3d: R^3 -> R, x -> 2 * exp(x[0] + x[1]) + 3 * x[2]; ASTNodeTypeCleaner<language::fct_declaration>{*ast}; ASTNodeExpressionBuilder{*ast}; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; @@ -356,8 +356,8 @@ let R2_scalar_non_linear_3d: R^3 -> R^2, x -> [2 * exp(x[0] + x[1]) + 3 * x[2], ASTNodeTypeCleaner<language::fct_declaration>{*ast}; ASTNodeExpressionBuilder{*ast}; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; diff --git a/tests/test_DiscreteFunctionVectorIntegratorByZone.cpp b/tests/test_DiscreteFunctionVectorIntegratorByZone.cpp index 01297d03df6cbadc0a7cff50546aa2737444e4d8..c6526f0c14880cfe7e918053ded8acbb48b92eeb 100644 --- a/tests/test_DiscreteFunctionVectorIntegratorByZone.cpp +++ b/tests/test_DiscreteFunctionVectorIntegratorByZone.cpp @@ -93,8 +93,8 @@ let R_scalar_non_linear_1d: R^1 -> R, x -> 2 * exp(x[0]) + 3; ASTNodeTypeCleaner<language::fct_declaration>{*ast}; ASTNodeExpressionBuilder{*ast}; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; @@ -221,8 +221,8 @@ let R_scalar_non_linear_2d: R^2 -> R, x -> 2 * exp(x[0] + x[1]) + 3; ASTNodeTypeCleaner<language::fct_declaration>{*ast}; ASTNodeExpressionBuilder{*ast}; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; @@ -349,8 +349,8 @@ let R_scalar_non_linear_3d: R^3 -> R, x -> 2 * exp(x[0] + x[1]) + 3 * x[2]; ASTNodeTypeCleaner<language::fct_declaration>{*ast}; ASTNodeExpressionBuilder{*ast}; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; diff --git a/tests/test_DiscreteFunctionVectorInterpoler.cpp b/tests/test_DiscreteFunctionVectorInterpoler.cpp index 3a4871076739a3fc873bd0cd69547099f9f67c67..2069db16cbd638dadc093fa02bde505f342db768 100644 --- a/tests/test_DiscreteFunctionVectorInterpoler.cpp +++ b/tests/test_DiscreteFunctionVectorInterpoler.cpp @@ -87,8 +87,8 @@ let R_scalar_non_linear_1d: R^1 -> R, x -> 2 * exp(x[0]) + 3; ASTNodeTypeCleaner<language::fct_declaration>{*ast}; ASTNodeExpressionBuilder{*ast}; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; @@ -191,8 +191,8 @@ let R_scalar_non_linear_2d: R^2 -> R, x -> 2 * exp(x[0] + x[1]) + 3; ASTNodeTypeCleaner<language::fct_declaration>{*ast}; ASTNodeExpressionBuilder{*ast}; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; @@ -295,8 +295,8 @@ let R_scalar_non_linear_3d: R^3 -> R, x -> 2 * exp(x[0] + x[1]) + 3 * x[2]; ASTNodeTypeCleaner<language::fct_declaration>{*ast}; ASTNodeExpressionBuilder{*ast}; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; @@ -398,8 +398,8 @@ let R2_scalar_non_linear_3d: R^3 -> R^2, x -> [2 * exp(x[0] + x[1]) + 3 * x[2], ASTNodeTypeCleaner<language::fct_declaration>{*ast}; ASTNodeExpressionBuilder{*ast}; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; diff --git a/tests/test_DiscreteFunctionVectorInterpolerByZone.cpp b/tests/test_DiscreteFunctionVectorInterpolerByZone.cpp index 0547aa3cf6bfe74a27b44630a34bb1d6f9e7724b..b486cd528743a337c7a127499c62c7bd71748db4 100644 --- a/tests/test_DiscreteFunctionVectorInterpolerByZone.cpp +++ b/tests/test_DiscreteFunctionVectorInterpolerByZone.cpp @@ -95,8 +95,8 @@ let R_scalar_non_linear_1d: R^1 -> R, x -> 2 * exp(x[0]) + 3; ASTNodeTypeCleaner<language::fct_declaration>{*ast}; ASTNodeExpressionBuilder{*ast}; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; @@ -220,8 +220,8 @@ let R_scalar_non_linear_2d: R^2 -> R, x -> 2 * exp(x[0] + x[1]) + 3; ASTNodeTypeCleaner<language::fct_declaration>{*ast}; ASTNodeExpressionBuilder{*ast}; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; @@ -345,8 +345,8 @@ let R_scalar_non_linear_3d: R^3 -> R, x -> 2 * exp(x[0] + x[1]) + 3 * x[2]; ASTNodeTypeCleaner<language::fct_declaration>{*ast}; ASTNodeExpressionBuilder{*ast}; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; @@ -463,8 +463,8 @@ let R2_scalar_non_linear_3d: R^3 -> R^2, x -> [2 * exp(x[0] + x[1]) + 3 * x[2], ASTNodeTypeCleaner<language::fct_declaration>{*ast}; ASTNodeExpressionBuilder{*ast}; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; diff --git a/tests/test_DoWhileProcessor.cpp b/tests/test_DoWhileProcessor.cpp index 13942906c78cc81abde2ba40b64c1adb91756434..ca8138191bf37e963d56492adb682b3cc66fe161 100644 --- a/tests/test_DoWhileProcessor.cpp +++ b/tests/test_DoWhileProcessor.cpp @@ -37,8 +37,7 @@ auto symbol_table = ast->m_symbol_table; \ \ using namespace TAO_PEGTL_NAMESPACE; \ - position use_position{internal::iterator{"fixture"}, "fixture"}; \ - use_position.byte = 10000; \ + position use_position{10000, 1000, 10, "fixture"}; \ auto [symbol, found] = symbol_table->find(variable_name, use_position); \ \ auto attributes = symbol->attributes(); \ diff --git a/tests/test_ForProcessor.cpp b/tests/test_ForProcessor.cpp index a83482550be288ed2104c6f28ed348955aee2914..b55de095c9335178bd0dcc92543218a1bde9c14e 100644 --- a/tests/test_ForProcessor.cpp +++ b/tests/test_ForProcessor.cpp @@ -37,8 +37,7 @@ auto symbol_table = ast->m_symbol_table; \ \ using namespace TAO_PEGTL_NAMESPACE; \ - position use_position{internal::iterator{"fixture"}, "fixture"}; \ - use_position.byte = 10000; \ + position use_position{10000, 1000, 10, "fixture"}; \ auto [symbol, found] = symbol_table->find(variable_name, use_position); \ \ auto attributes = symbol->attributes(); \ diff --git a/tests/test_FunctionProcessor.cpp b/tests/test_FunctionProcessor.cpp index 500998b50f1729e9416b26cef7462bcc101b3151..2a11caff89e418956cea81a8f4f64276c93c5756 100644 --- a/tests/test_FunctionProcessor.cpp +++ b/tests/test_FunctionProcessor.cpp @@ -37,8 +37,7 @@ auto symbol_table = ast->m_symbol_table; \ \ using namespace TAO_PEGTL_NAMESPACE; \ - position use_position{internal::iterator{"fixture"}, "fixture"}; \ - use_position.byte = 10000; \ + position use_position{10000, 1000, 1, "fixture"}; \ auto [symbol, found] = symbol_table->find(variable_name, use_position); \ \ auto attributes = symbol->attributes(); \ diff --git a/tests/test_IfProcessor.cpp b/tests/test_IfProcessor.cpp index 461f3a98f8279a55e098e22fc5b63cec8276cc35..8c0ee437d76585d3a0381d136ed70de136ed0cba 100644 --- a/tests/test_IfProcessor.cpp +++ b/tests/test_IfProcessor.cpp @@ -35,8 +35,7 @@ auto symbol_table = ast->m_symbol_table; \ \ using namespace TAO_PEGTL_NAMESPACE; \ - position use_position{internal::iterator{"fixture"}, "fixture"}; \ - use_position.byte = 10000; \ + position use_position{10000, 1000, 10, "fixture"}; \ auto [symbol, found] = symbol_table->find(variable_name, use_position); \ \ auto attributes = symbol->attributes(); \ diff --git a/tests/test_IncDecExpressionProcessor.cpp b/tests/test_IncDecExpressionProcessor.cpp index ba04c7ab259797b49ca6a9ffd1eb57f5d1a72b38..960845cf229abb9f436e6016e6202d5b0d8dcb99 100644 --- a/tests/test_IncDecExpressionProcessor.cpp +++ b/tests/test_IncDecExpressionProcessor.cpp @@ -35,8 +35,7 @@ auto symbol_table = ast->m_symbol_table; \ \ using namespace TAO_PEGTL_NAMESPACE; \ - position use_position{internal::iterator{"fixture"}, "fixture"}; \ - use_position.byte = 10000; \ + position use_position{10000, 1000, 10, "fixture"}; \ auto [symbol, found] = symbol_table->find(variable_name, use_position); \ \ auto attributes = symbol->attributes(); \ diff --git a/tests/test_IntegrateCellArray.cpp b/tests/test_IntegrateCellArray.cpp index 0b64ca10e057803c4b8bd0befd06a27277239c9c..8a3692ca56bb0c04bbbb4417e4d6ccac6a57b707 100644 --- a/tests/test_IntegrateCellArray.cpp +++ b/tests/test_IntegrateCellArray.cpp @@ -78,8 +78,8 @@ let g: R^1 -> R, x -> 2 * exp(x[0]) + 3; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::vector<FunctionSymbolId> function_symbol_id_list; @@ -164,8 +164,8 @@ let g: R^2 -> R, x -> 2*exp(x[0])*sin(x[1])+3; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::vector<FunctionSymbolId> function_symbol_id_list; @@ -261,8 +261,8 @@ let g: R^3 -> R, x -> 2 * exp(x[0]) * sin(x[1]) * x[2] + 3; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::vector<FunctionSymbolId> function_symbol_id_list; @@ -372,8 +372,8 @@ let g: R^1 -> R, x -> 2 * exp(x[0]) + 3; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::vector<FunctionSymbolId> function_symbol_id_list; @@ -467,8 +467,8 @@ let g: R^2 -> R, x -> 2*exp(x[0])*sin(x[1])+3; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::vector<FunctionSymbolId> function_symbol_id_list; @@ -573,8 +573,8 @@ let g: R^3 -> R, x -> 2 * exp(x[0]) * sin(x[1]) * x[2] + 3; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::vector<FunctionSymbolId> function_symbol_id_list; diff --git a/tests/test_IntegrateCellValue.cpp b/tests/test_IntegrateCellValue.cpp index c109c227c35eeb10362a339dd9aaa5e8a947114f..a230b9530056f764f0061abaa8dcd151087d6f44 100644 --- a/tests/test_IntegrateCellValue.cpp +++ b/tests/test_IntegrateCellValue.cpp @@ -74,8 +74,8 @@ let R2x2_1d: R^1 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; using R2x2 = TinyMatrix<2>; auto [i_symbol, found] = symbol_table->find("R2x2_1d", position); @@ -132,8 +132,8 @@ let R3_2d: R^2 -> R^3, x -> [2*exp(x[0])*sin(x[1])+3, x[0]-2*x[1], 3]; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; using R3 = TinyVector<3>; auto [i_symbol, found] = symbol_table->find("R3_2d", position); @@ -201,8 +201,8 @@ let scalar_3d: R^3 -> R, x -> 2 * exp(x[0]) * sin(x[1]) * x[2] + 3; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; auto [i_symbol, found] = symbol_table->find("scalar_3d", position); REQUIRE(found); @@ -279,8 +279,8 @@ let scalar_1d: R^1 -> R, x -> 2 * exp(x[0]) + 3; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; auto [i_symbol, found] = symbol_table->find("scalar_1d", position); REQUIRE(found); @@ -344,8 +344,8 @@ let R3_2d: R^2 -> R^3, x -> [2*exp(x[0])*sin(x[1])+3, x[0]-2*x[1], 3]; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; using R3 = TinyVector<3>; auto [i_symbol, found] = symbol_table->find("R3_2d", position); @@ -423,8 +423,8 @@ let R2x2_3d: R^3 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; using R2x2 = TinyMatrix<2>; auto [i_symbol, found] = symbol_table->find("R2x2_3d", position); diff --git a/tests/test_IntegrateOnCells.cpp b/tests/test_IntegrateOnCells.cpp index 5207325e8a4d36c1b8dd66ea24d3ddfa3be3af9f..2104bcbf364b8aa039bbb896e56e958188c5f96d 100644 --- a/tests/test_IntegrateOnCells.cpp +++ b/tests/test_IntegrateOnCells.cpp @@ -78,8 +78,8 @@ let R2x2_1d: R^1 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar 1d") { @@ -179,8 +179,8 @@ let R2x2_2d: R^2 -> R^2x2, x -> [[2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1])], [3 std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar 2d") { @@ -292,8 +292,8 @@ let R2x2_3d: R^3 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar 3d") { @@ -419,8 +419,8 @@ let R2x2_1d: R^1 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar 1d") { @@ -530,8 +530,8 @@ let R2x2_2d: R^2 -> R^2x2, x -> [[2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1])], [3 std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar 2d") { @@ -653,8 +653,8 @@ let R2x2_3d: R^3 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar 3d") { @@ -774,8 +774,8 @@ let R2x2_1d: R^1 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar 1d") { @@ -875,8 +875,8 @@ let R2x2_2d: R^2 -> R^2x2, x -> [[2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1])], [3 std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar 2d") { @@ -988,8 +988,8 @@ let R2x2_3d: R^3 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar 3d") { @@ -1115,8 +1115,8 @@ let R2x2_1d: R^1 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar 1d") { @@ -1226,8 +1226,8 @@ let R2x2_2d: R^2 -> R^2x2, x -> [[2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1])], [3 std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar 2d") { @@ -1349,8 +1349,8 @@ let R2x2_3d: R^3 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar 3d") { @@ -1470,8 +1470,8 @@ let R2x2_1d: R^1 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar 1d") { @@ -1571,8 +1571,8 @@ let R2x2_2d: R^2 -> R^2x2, x -> [[2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1])], [3 std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar 2d") { @@ -1684,8 +1684,8 @@ let R2x2_3d: R^3 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar 3d") { @@ -1811,8 +1811,8 @@ let R2x2_1d: R^1 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin(x[0] - 2 * std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar 1d") { @@ -1922,8 +1922,8 @@ let R2x2_2d: R^2 -> R^2x2, x -> [[2*exp(x[0])*sin(x[1])+3, sin(x[0]-2*x[1])], [3 std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar 2d") { @@ -2045,8 +2045,8 @@ let R2x2_3d: R^3 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3 * cos(x[2]), sin std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar 3d") { diff --git a/tests/test_InterpolateItemArray.cpp b/tests/test_InterpolateItemArray.cpp index 61674ce2d3d5e105fb7f8f1b6322ccc0f6ff4dcd..01720b617888bda30674993a42a0dc78ef951cc6 100644 --- a/tests/test_InterpolateItemArray.cpp +++ b/tests/test_InterpolateItemArray.cpp @@ -81,8 +81,8 @@ let scalar_non_linear_1d: R^1 -> R, x -> 2 * exp(x[0]) + 3; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::vector<FunctionSymbolId> function_symbol_id_list; @@ -149,8 +149,8 @@ let f_1d: R^1 -> (R), x -> (2*x[0] + 2, 2 * exp(x[0]) + 3); std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::vector<FunctionSymbolId> function_symbol_id_list; @@ -208,8 +208,8 @@ let f_1d: R^1 -> (R^1), x -> (2*x[0] + 2, [2 * exp(x[0]) + 3]); std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::vector<FunctionSymbolId> function_symbol_id_list; @@ -277,8 +277,8 @@ let scalar_non_linear_2d: R^2 -> R, x -> 2*exp(x[0])*sin(x[1])+3; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::vector<FunctionSymbolId> function_symbol_id_list; @@ -345,8 +345,8 @@ let f_2d: R^2 -> (R), x -> (2*x[0] + 3*x[1] + 2, 2*exp(x[0])*sin(x[1])+3); std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::vector<FunctionSymbolId> function_symbol_id_list; @@ -412,8 +412,8 @@ let scalar_non_linear_3d: R^3 -> R, x -> 2 * exp(x[0]) * sin(x[1]) * x[2] + 3; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::vector<FunctionSymbolId> function_symbol_id_list; @@ -480,8 +480,8 @@ let f_3d: R^3 -> (R), x -> (2 * x[0] + 3 * x[1] + 2 * x[2] - 1, 2 * exp(x[0]) * std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::vector<FunctionSymbolId> function_symbol_id_list; @@ -569,8 +569,8 @@ let scalar_non_linear_1d: R^1 -> R, x -> 2 * exp(x[0]) + 3; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::vector<FunctionSymbolId> function_symbol_id_list; @@ -646,8 +646,8 @@ let f_1d: R^1 -> (R), x -> (2*x[0] + 2, 2 * exp(x[0]) + 3); std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::vector<FunctionSymbolId> function_symbol_id_list; @@ -719,8 +719,8 @@ let scalar_non_linear_2d: R^2 -> R, x -> 2*exp(x[0])*sin(x[1])+3; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::vector<FunctionSymbolId> function_symbol_id_list; @@ -793,8 +793,8 @@ let f_2d: R^2 -> (R), x -> (2*x[0] + 3*x[1] + 2, 2*exp(x[0])*sin(x[1])+3); std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::vector<FunctionSymbolId> function_symbol_id_list; @@ -858,8 +858,8 @@ let f_2d: R^2 -> (R^2x2), x -> ([[x[0],0],[2-x[1], x[0]*x[1]]], [[2*x[0], x[1]], std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::vector<FunctionSymbolId> function_symbol_id_list; @@ -936,8 +936,8 @@ let scalar_non_linear_3d: R^3 -> R, x -> 2 * exp(x[0]) * sin(x[1]) * x[2] + 3; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::vector<FunctionSymbolId> function_symbol_id_list; @@ -1010,8 +1010,8 @@ let f_3d: R^3 -> (R), x -> (2 * x[0] + 3 * x[1] + 2 * x[2] - 1, 2 * exp(x[0]) * std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::vector<FunctionSymbolId> function_symbol_id_list; @@ -1075,8 +1075,8 @@ let f_3d: R^3 -> (R^3), x -> (2*x, [2*x[0]-x[1], 3*x[2]-x[0], x[1]+x[2]], 0); std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; std::vector<FunctionSymbolId> function_symbol_id_list; diff --git a/tests/test_InterpolateItemValue.cpp b/tests/test_InterpolateItemValue.cpp index 9ee0a324f01728d54f88c0d864dd5950c7cb2339..a06eee8ca72584903c73b28defdba220ca7dadf7 100644 --- a/tests/test_InterpolateItemValue.cpp +++ b/tests/test_InterpolateItemValue.cpp @@ -80,8 +80,8 @@ let R2x2_non_linear_1d: R^1 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin( std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar_affine_1d") { @@ -251,8 +251,8 @@ let R2x2_non_linear_2d: R^2 -> R^2x2, x -> [[2*exp(x[0])*sin(x[1])+3, sin(x[0]-2 std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar_affine_2d") { @@ -416,8 +416,8 @@ let R2x2_non_linear_3d: R^3 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3 * cos std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar_affine_3d") { @@ -603,8 +603,8 @@ let R2x2_non_linear_1d: R^1 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin( std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar_affine_1d") { @@ -782,8 +782,8 @@ let R2x2_non_linear_2d: R^2 -> R^2x2, x -> [[2*exp(x[0])*sin(x[1])+3, sin(x[0]-2 std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar_affine_2d") { @@ -956,8 +956,8 @@ let R2x2_non_linear_3d: R^3 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3 * cos std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("scalar_affine_3d") { diff --git a/tests/test_ItemArrayVariantFunctionInterpoler.cpp b/tests/test_ItemArrayVariantFunctionInterpoler.cpp index 3a2c4aadaaba0794a3ebca697739e093e712ef3e..05d0ab6a7a0d96d7913b8949f2256fb494b465b4 100644 --- a/tests/test_ItemArrayVariantFunctionInterpoler.cpp +++ b/tests/test_ItemArrayVariantFunctionInterpoler.cpp @@ -104,8 +104,8 @@ let R3x3_non_linear_1d: R^1 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin( std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("B_scalar_non_linear_1d") { @@ -460,8 +460,8 @@ let R3x3_non_linear_2d: R^2 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin( std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("B_scalar_non_linear_2d") { @@ -592,8 +592,8 @@ let R2x2_non_linear_3d: R^3 -> R^2x2, std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("R_scalar_non_linear_3d") { diff --git a/tests/test_ItemValueVariantFunctionInterpoler.cpp b/tests/test_ItemValueVariantFunctionInterpoler.cpp index be1d4272b8019d493760d228735fa5d08985ef04..bd05f94e9ade781d2e36fdc075a977166597ffaf 100644 --- a/tests/test_ItemValueVariantFunctionInterpoler.cpp +++ b/tests/test_ItemValueVariantFunctionInterpoler.cpp @@ -83,8 +83,8 @@ let R3x3_non_linear_1d: R^1 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[0]) + 3, sin( std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("B_scalar_non_linear_1d") { @@ -355,8 +355,8 @@ let R3x3_non_linear_2d: R^2 -> R^3x3, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin( std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("B_scalar_non_linear_2d") { @@ -474,8 +474,8 @@ let R2x2_non_linear_3d: R^3 -> R^2x2, x -> [[2 * exp(x[0]) * sin(x[1]) + 3, sin( std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this point + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; SECTION("R_scalar_non_linear_3d") { diff --git a/tests/test_ListAffectationProcessor.cpp b/tests/test_ListAffectationProcessor.cpp index 2c28e6e0b0e6a8c8ae8c61d4b5778c8e3617af58..5910b3b4967acb846c11ff768ae4aa043772be57 100644 --- a/tests/test_ListAffectationProcessor.cpp +++ b/tests/test_ListAffectationProcessor.cpp @@ -35,8 +35,7 @@ auto symbol_table = ast->m_symbol_table; \ \ using namespace TAO_PEGTL_NAMESPACE; \ - position use_position{internal::iterator{"fixture"}, "fixture"}; \ - use_position.byte = 10000; \ + position use_position{10000, 1000, 1, "fixture"}; \ auto [symbol, found] = symbol_table->find(variable_name, use_position); \ \ auto attributes = symbol->attributes(); \ diff --git a/tests/test_NameProcessor.cpp b/tests/test_NameProcessor.cpp index 3e607bb52eded2c70d411ed4298951b95585311b..1433eff93265614a36dfd0dcb16d4d9c7db13257 100644 --- a/tests/test_NameProcessor.cpp +++ b/tests/test_NameProcessor.cpp @@ -45,10 +45,9 @@ n = 2; auto symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position use_position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - use_position.byte = 100; // after declarative position - auto symbol_n = symbol_table->find("n", use_position).first->attributes(); - auto value_n = std::get<long unsigned int>(symbol_n.value()); + TAO_PEGTL_NAMESPACE::position use_position{100, 1, 1, "fixture"}; + auto symbol_n = symbol_table->find("n", use_position).first->attributes(); + auto value_n = std::get<long unsigned int>(symbol_n.value()); REQUIRE(value_n == 2); diff --git a/tests/test_ParseError.cpp b/tests/test_ParseError.cpp index 9555711966d2a37121d4afa223f193a3441455ad..12ee1ff1332affa22a9e13a2333781d4fa6648c1 100644 --- a/tests/test_ParseError.cpp +++ b/tests/test_ParseError.cpp @@ -15,7 +15,7 @@ TEST_CASE("ParseError", "[language]") a first line a second line )"; - TAO_PEGTL_NAMESPACE::internal::iterator i(&source[0], 3, 1, 2); + TAO_PEGTL_NAMESPACE::internal::frobnicator i(&source[0], 3, 1, 2); TAO_PEGTL_NAMESPACE::position p{i, source}; ParseError parse_error("error message", p); REQUIRE(parse_error.positions() == std::vector{p}); @@ -28,9 +28,9 @@ a second line a first line a second line )"; - TAO_PEGTL_NAMESPACE::internal::iterator i0(&source[0], 3, 1, 2); + TAO_PEGTL_NAMESPACE::internal::frobnicator i0(&source[0], 3, 1, 2); TAO_PEGTL_NAMESPACE::position p0{i0, source}; - TAO_PEGTL_NAMESPACE::internal::iterator i1(&source[0], 4, 1, 3); + TAO_PEGTL_NAMESPACE::internal::frobnicator i1(&source[0], 4, 1, 3); TAO_PEGTL_NAMESPACE::position p1{i1, source}; ParseError parse_error("error message", std::vector{p0, p1}); diff --git a/tests/test_PugsFunctionAdapter.cpp b/tests/test_PugsFunctionAdapter.cpp index 9e645802fde6e286abfeb57e7c4c35dd584583c4..68d02133b26e07382dac7f6588f4554093bd2151 100644 --- a/tests/test_PugsFunctionAdapter.cpp +++ b/tests/test_PugsFunctionAdapter.cpp @@ -102,8 +102,8 @@ let R33toR33zero: R^3x3 -> R^3x3, x -> 0; std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; { auto [i_symbol, found] = symbol_table->find("Rtimes2", position); @@ -390,8 +390,8 @@ let R33toR22: R^3x3 -> R^2x2, x -> [[x[0,0], x[0,1]+x[0,2]], [x[2,0]*x[1,1], x[2 std::shared_ptr<SymbolTable> symbol_table = ast->m_symbol_table; - TAO_PEGTL_NAMESPACE::position position{TAO_PEGTL_NAMESPACE::internal::iterator{"fixture"}, "fixture"}; - position.byte = data.size(); // ensure that variables are declared at this + // ensure that variables are declared at this point + TAO_PEGTL_NAMESPACE::position position{data.size(), 1, 1, "fixture"}; { auto [i_symbol, found] = symbol_table->find("R1toR1", position); diff --git a/tests/test_SymbolTable.cpp b/tests/test_SymbolTable.cpp index 78cd4373b9901aa69a65bc8bceaa4a7e68c1ad0b..ed93b4d21c48499f455d4fe5544608e2fea9324d 100644 --- a/tests/test_SymbolTable.cpp +++ b/tests/test_SymbolTable.cpp @@ -5,7 +5,7 @@ #include <language/utils/SymbolTable.hpp> #include <language/utils/TypeDescriptor.hpp> -#include <pegtl/internal/iterator.hpp> +#include <pegtl/internal/frobnicator.hpp> #include <sstream> @@ -18,7 +18,7 @@ TEST_CASE("SymbolTable", "[language]") std::shared_ptr root_st = std::make_shared<SymbolTable>(); using namespace TAO_PEGTL_NAMESPACE; - position begin_position{internal::iterator{"fixture"}, "fixture"}; + position begin_position{internal::frobnicator{"fixture"}, "fixture"}; begin_position.byte = 2; auto [i_symbol_a, created_a] = root_st->add("a", begin_position); @@ -29,7 +29,7 @@ TEST_CASE("SymbolTable", "[language]") // Check that one cannot build another "a" in this table REQUIRE(not root_st->add("a", begin_position).second); - position use_position{internal::iterator{"fixture"}, "fixture"}; + position use_position{internal::frobnicator{"fixture"}, "fixture"}; use_position.byte = 3; // after declarative position auto [i_search_a, found_a] = root_st->find("a", use_position); @@ -106,15 +106,15 @@ TEST_CASE("SymbolTable", "[language]") std::shared_ptr root_st = std::make_shared<SymbolTable>(); using namespace TAO_PEGTL_NAMESPACE; - position begin_position{internal::iterator{"fixture"}, "fixture"}; - position end_declaration{internal::iterator{"fixture"}, "fixture"}; + position begin_position{internal::frobnicator{"fixture"}, "fixture"}; + position end_declaration{internal::frobnicator{"fixture"}, "fixture"}; auto [i_root_symbol_a, created_root_a] = root_st->add("a", begin_position); REQUIRE(created_root_a); std::shared_ptr nested_st = std::make_shared<SymbolTable>(root_st); - position use_position{internal::iterator{"fixture"}, "fixture"}; + position use_position{internal::frobnicator{"fixture"}, "fixture"}; auto [i_search_a, found_a] = nested_st->find("a", use_position); REQUIRE(found_a); // symbol "a" is the one defined in root_st @@ -139,13 +139,13 @@ TEST_CASE("SymbolTable", "[language]") std::shared_ptr root_st = std::make_shared<SymbolTable>(); using namespace TAO_PEGTL_NAMESPACE; - position begin_position{internal::iterator{"fixture"}, "fixture"}; + position begin_position{internal::frobnicator{"fixture"}, "fixture"}; begin_position.byte = 2; auto [i_symbol_a, created_a] = root_st->add("a", begin_position); REQUIRE(i_symbol_a->attributes().position().byte == 2); - position use_position{internal::iterator{"fixture"}, "fixture"}; + position use_position{internal::frobnicator{"fixture"}, "fixture"}; use_position.byte = 3; // after declarative position auto [i_search_a, found_a] = root_st->find("a", use_position); diff --git a/tests/test_TupleToVectorProcessor.cpp b/tests/test_TupleToVectorProcessor.cpp index 74865d2ce1019e19e2474f059fde4708a2e5e735..0eab5884c6a590a8adf8ee656bd62cf3b528deb5 100644 --- a/tests/test_TupleToVectorProcessor.cpp +++ b/tests/test_TupleToVectorProcessor.cpp @@ -36,8 +36,7 @@ auto symbol_table = ast->m_symbol_table; \ \ using namespace TAO_PEGTL_NAMESPACE; \ - position use_position{internal::iterator{"fixture"}, "fixture"}; \ - use_position.byte = 10000; \ + position use_position{10000, 1000, 10, "fixture"}; \ auto [symbol, found] = symbol_table->find(variable_name, use_position); \ \ auto attributes = symbol->attributes(); \ diff --git a/tests/test_UnaryExpressionProcessor.cpp b/tests/test_UnaryExpressionProcessor.cpp index 2c3f6acb8eb7f8280e8717cdf495abd341dec5d0..235ba29d9f370b53abbf82a5d027797bd834e672 100644 --- a/tests/test_UnaryExpressionProcessor.cpp +++ b/tests/test_UnaryExpressionProcessor.cpp @@ -45,8 +45,7 @@ auto symbol_table = ast->m_symbol_table; \ \ using namespace TAO_PEGTL_NAMESPACE; \ - position use_position{internal::iterator{"fixture"}, "fixture"}; \ - use_position.byte = 10000; \ + position use_position{10000, 1000, 10, "fixture"}; \ auto [symbol, found] = symbol_table->find(variable_name, use_position); \ \ auto attributes = symbol->attributes(); \ @@ -126,8 +125,7 @@ TEST_CASE("UnaryExpressionProcessor", "[language]") ast->execute(exec_policy); using namespace TAO_PEGTL_NAMESPACE; - position use_position{internal::iterator{"fixture"}, "fixture"}; - use_position.byte = 10000; + position use_position{10000, 1000, 10, "fixture"}; auto [symbol, found] = symbol_table.find("r", use_position); auto attributes = symbol->attributes(); diff --git a/tests/test_WhileProcessor.cpp b/tests/test_WhileProcessor.cpp index 1de4c6c5c4a7aa8b356a2fb77d4c211b521eedf5..69fa63d729c669dd4aba67f29887699147f428db 100644 --- a/tests/test_WhileProcessor.cpp +++ b/tests/test_WhileProcessor.cpp @@ -36,8 +36,7 @@ auto symbol_table = ast->m_symbol_table; \ \ using namespace TAO_PEGTL_NAMESPACE; \ - position use_position{internal::iterator{"fixture"}, "fixture"}; \ - use_position.byte = 10000; \ + position use_position{10000, 1000, 10, "fixture"}; \ auto [symbol, found] = symbol_table->find(variable_name, use_position); \ \ auto attributes = symbol->attributes(); \