Skip to content

Commit

Permalink
Port master branch changes to 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
d-frey committed Jun 14, 2019
1 parent b9643de commit 164835b
Show file tree
Hide file tree
Showing 21 changed files with 257 additions and 107 deletions.
8 changes: 4 additions & 4 deletions .conan/build.py
Expand Up @@ -52,17 +52,17 @@ def stable_branch_pattern(self):

@property
def reference(self):
""" Read project version from CMake file to create Conan referece
""" Read project version from version.hpp file to create Conan referece
"""
pattern = re.compile(r"project\(pegtl VERSION (\d+\.\d+\.\d+) LANGUAGES CXX\)")
pattern = re.compile(r"#define TAO_PEGTL_VERSION \"(\d+\.\d+\.\d+)\"")
version = None
with open('CMakeLists.txt') as file:
with open('include/tao/pegtl/version.hpp') as file:
for line in file:
result = pattern.match(line)
if result:
version = result.group(1)
if not version:
raise Exception("Could not find version in CMakeLists.txt")
raise Exception("Could not find version in version.hpp")
return os.getenv("CONAN_REFERENCE", "pegtl/{}@taocpp/stable".format(version))

if __name__ == "__main__":
Expand Down
49 changes: 20 additions & 29 deletions CMakeLists.txt
@@ -1,6 +1,11 @@
cmake_minimum_required(VERSION 3.3.0 FATAL_ERROR)
cmake_minimum_required(VERSION 3.8.0 FATAL_ERROR)

project(pegtl VERSION 2.8.0 LANGUAGES CXX)
# Read version from version.hpp
file(READ "${CMAKE_CURRENT_LIST_DIR}/include/tao/pegtl/version.hpp" version_hpp_data)
string(REGEX MATCH "#define TAO_PEGTL_VERSION \"([^\"]+)\"" _ ${version_hpp_data})
set(PEGTL_VERSION "${CMAKE_MATCH_1}")

project(pegtl VERSION ${PEGTL_VERSION} LANGUAGES CXX)

if(${PROJECT_NAME}_FOUND)
# Multiple versions of PEGTL can't co-exist
Expand Down Expand Up @@ -36,33 +41,8 @@ target_include_directories(pegtl INTERFACE
$<INSTALL_INTERFACE:${PEGTL_INSTALL_INCLUDE_DIR}>
)

# features required by the PEGTL
target_compile_features(pegtl INTERFACE
cxx_alias_templates
cxx_auto_type
cxx_constexpr
cxx_decltype
cxx_default_function_template_args
cxx_defaulted_functions
cxx_delegating_constructors
cxx_deleted_functions
cxx_explicit_conversions
cxx_generalized_initializers
cxx_inheriting_constructors
cxx_inline_namespaces
cxx_noexcept
cxx_nonstatic_member_init
cxx_nullptr
cxx_range_for
cxx_rvalue_references
cxx_static_assert
cxx_strong_enums
cxx_template_template_parameters
cxx_trailing_return_types
cxx_uniform_initialization
cxx_variadic_macros
cxx_variadic_templates
)
# require C++11
target_compile_features(pegtl INTERFACE cxx_std_11)

# testing
enable_testing()
Expand All @@ -77,6 +57,16 @@ if(PEGTL_BUILD_EXAMPLES)
add_subdirectory(src/example/pegtl)
endif()

# Make package findable
configure_file(cmake/dummy-config.cmake.in pegtl-config.cmake @ONLY)

# Ignore pointer width differences since this is a header-only library
unset(CMAKE_SIZEOF_VOID_P)

# Enable version checks in find_package
include(CMakePackageConfigHelpers)
write_basic_package_version_file(pegtl-config-version.cmake COMPATIBILITY SameMajorVersion)

# install and export target
install(TARGETS pegtl EXPORT pegtl-targets)

Expand All @@ -86,5 +76,6 @@ install(EXPORT pegtl-targets
DESTINATION ${PEGTL_INSTALL_CMAKE_DIR}
)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pegtl-config-version.cmake DESTINATION ${PEGTL_INSTALL_CMAKE_DIR})
install(DIRECTORY include/ DESTINATION ${PEGTL_INSTALL_INCLUDE_DIR})
install(FILES LICENSE DESTINATION ${PEGTL_INSTALL_DOC_DIR})
42 changes: 40 additions & 2 deletions README.md
Expand Up @@ -89,11 +89,49 @@ Code coverage is automatically measured and the unit tests cover 100% of the cor
Incompatible API changes are *only* allowed to occur between major versions.
For details see the [changelog](doc/Changelog.md).
## Contact
## Thank You
In appreciation of all contributions here are the people that have [directly contributed](https://github.com/taocpp/PEGTL/graphs/contributors) to the PEGTL and/or its development.
[<img alt="andoma" src="https://avatars2.githubusercontent.com/u/216384?v=4&s=117" width="117">](https://github.com/andoma)
[<img alt="Bjoe" src="https://avatars3.githubusercontent.com/u/727911?v=4&s=117" width="117">](https://github.com/Bjoe)
[<img alt="bwagner" src="https://avatars3.githubusercontent.com/u/447049?v=4&s=117" width="117">](https://github.com/bwagner)
[<img alt="cdiggins" src="https://avatars2.githubusercontent.com/u/1759994?s=460&v=4?v=4&s=117" width="117">](https://github.com/cdiggins)
[<img alt="delpinux" src="https://avatars0.githubusercontent.com/u/35096584?v=4&s=117" width="117">](https://github.com/delpinux)
[<img alt="dkopecek" src="https://avatars2.githubusercontent.com/u/1353140?v=4&s=117" width="117">](https://github.com/dkopecek)
[<img alt="irrequietus" src="https://avatars0.githubusercontent.com/u/231192?v=4&s=117" width="117">](https://github.com/irrequietus)
[<img alt="jedelbo" src="https://avatars2.githubusercontent.com/u/572755?v=4&s=117" width="117">](https://github.com/jedelbo)
[<img alt="joelfrederico" src="https://avatars0.githubusercontent.com/u/458871?v=4&s=117" width="117">](https://github.com/joelfrederico)
[<img alt="jovermann" src="https://avatars3.githubusercontent.com/u/6087443?v=4&s=117" width="117">](https://github.com/jovermann)
[<img alt="kneth" src="https://avatars0.githubusercontent.com/u/1225363?v=4&s=117" width="117">](https://github.com/kneth)
[<img alt="kuzmas" src="https://avatars1.githubusercontent.com/u/1858553?v=4&s=117" width="117">](https://github.com/kuzmas)
[<img alt="lambdafu" src="https://avatars1.githubusercontent.com/u/1138455?v=4&s=117" width="117">](https://github.com/lambdafu)
[<img alt="lichray" src="https://avatars2.githubusercontent.com/u/433009?v=4&s=117" width="117">](https://github.com/lichray)
[<img alt="michael-brade" src="https://avatars0.githubusercontent.com/u/8768950?v=4&s=117" width="117">](https://github.com/michael-brade)
[<img alt="mkrupcale" src="https://avatars1.githubusercontent.com/u/13936020?v=4&s=117" width="117">](https://github.com/mkrupcale)
[<img alt="NewProggie" src="https://avatars3.githubusercontent.com/u/162319?s=460&v=4?v=4&s=117" width="117">](https://github.com/NewProggie)
[<img alt="pauloscustodio" src="https://avatars1.githubusercontent.com/u/70773?v=4&s=117" width="117">](https://github.com/pauloscustodio)
[<img alt="pleroux0" src="https://avatars2.githubusercontent.com/u/39619854?v=4&s=117" width="117">](https://github.com/pleroux0)
[<img alt="quadfault" src="https://avatars3.githubusercontent.com/u/30195320?v=4&s=117" width="117">](https://github.com/quadfault)
[<img alt="robertcampion" src="https://avatars2.githubusercontent.com/u/4220569?v=4&s=117" width="117">](https://github.com/robertcampion)
[<img alt="samhocevar" src="https://avatars2.githubusercontent.com/u/245089?v=4&s=117" width="117">](https://github.com/samhocevar)
[<img alt="sanssecours" src="https://avatars2.githubusercontent.com/u/691989?v=4&s=117" width="117">](https://github.com/sanssecours)
[<img alt="sgbeal" src="https://avatars1.githubusercontent.com/u/235303?v=4&s=117" width="117">](https://github.com/sgbeal)
[<img alt="studoot" src="https://avatars1.githubusercontent.com/u/799344?v=4&s=117" width="117">](https://github.com/studoot)
[<img alt="SvenJo" src="https://avatars1.githubusercontent.com/u/1538181?s=460&v=4?v=4&s=117" width="117">](https://github.com/SvenJo)
[<img alt="wickedmic" src="https://avatars1.githubusercontent.com/u/12001183?v=4&s=117" width="117">](https://github.com/wickedmic)
[<img alt="wravery" src="https://avatars0.githubusercontent.com/u/6502881?v=4&s=117" width="117">](https://github.com/wravery)
[<img alt="zhihaoy" src="https://avatars2.githubusercontent.com/u/43971430?v=4&s=117" width="117">](https://github.com/zhihaoy)
## The Art of C++
The PEGTL is part of [The Art of C++](https://taocpp.github.io/).
We [are grateful](doc/Thank-You.md) for all support and contributions.
[<img alt="ColinH" src="https://avatars0.githubusercontent.com/u/113184?v=4&s=117" width="117">](https://github.com/ColinH)
[<img alt="d-frey" src="https://avatars2.githubusercontent.com/u/3956325?v=4&s=117" width="117">](https://github.com/d-frey)
[<img alt="uilianries" src="https://avatars0.githubusercontent.com/u/4870173?v=4&s=117" width="117">](https://github.com/uilianries)
## Contact
For questions and suggestions regarding the PEGTL, success or failure stories, and any other kind of feedback, please feel free to open an issue or a PR on GitHub or contact the authors at `taocpp(at)icemx.net`.
Expand Down
2 changes: 1 addition & 1 deletion conanfile.py
Expand Up @@ -11,7 +11,7 @@ class PEGTLConan(ConanFile):
license = "MIT"
author = "taocpp@icemx.net"
exports = "LICENSE"
exports_sources = "include/*", "CMakeLists.txt"
exports_sources = "cmake/*", "include/*", "CMakeLists.txt"
settings = "build_type", "compiler", "os", "arch"
generators = "cmake"
no_copy_source = True
Expand Down
1 change: 1 addition & 0 deletions doc/Changelog.md
Expand Up @@ -5,6 +5,7 @@
**Not yet released**

* Fixed missing `string_input<>` in amalgamated header.
* Fixed `discard_input*` actions to properly forward the apply mode.

## 2.8.0

Expand Down
6 changes: 3 additions & 3 deletions doc/Contrib-and-Examples.md
Expand Up @@ -206,12 +206,12 @@ The example shows how to choose which rules will produce a parse tree node, whic
The output is in [DOT](https://en.wikipedia.org/wiki/DOT_(graph_description_language)) format and can be converted into a graph.

```sh
$ build/src/example/pegtl/parse_tree "(2*a + 3*b) / (4*n)" | dot -Tpng -o parse_tree.png
$ build/src/example/pegtl/parse_tree "(2*a + 3*b) / (4*n)" | dot -Tsvg -o parse_tree.svg
```

The above will generate a PNG with a graphical representation of the parse tree.
The above will generate an SVG file with a graphical representation of the parse tree.

![Parse Tree](Parse-Tree.png)
![Parse Tree](Parse-Tree.svg)

###### `src/example/pegtl/proto3.cpp`

Expand Down
8 changes: 6 additions & 2 deletions doc/Control-and-Debug.md
Expand Up @@ -131,9 +131,13 @@ Similarly, the control's `apply()` and `apply0()` can customise action invocatio

## Changing Control

Just like the action class template, a custom control class template can be used by either
Just like the action class template, a custom control class template can be used (or changed) by either

1. supplying it as explicit template argument to the `parse()` functions, or
2. setting it for a portion of the grammar with the `tao::pegtl::control` combinator.
2. setting it as control class with the [`tao::pegtl::control`](Rule-Reference.md#control-c-r-) combinator, or
3. setting it as control class with the `change_control` action.

The latter requires the use of a [custom action](Actions-and-States.md).
Deriving the specialisation of the custom action for `my_rule` from `tao::pegtl::change_control< my_control >` will switch the current control to `my_control` before attempting to match `my_rule`.

Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey
9 changes: 7 additions & 2 deletions doc/Inputs-and-Parsing.md
Expand Up @@ -42,7 +42,7 @@ All classes and functions on this page are in namespace `tao::pegtl`.
* [Nested Parsing](#nested-parsing)
* [Incremental Input](#incremental-input)
* [Buffer Size](#buffer-size)
* [Discard Input](#discard-input)
* [Discard Buffer](#discard-buffer)
* [Custom Rules](#custom-rules)
* [Custom Readers](#custom-readers)
* [Buffer Details](#buffer-details)
Expand Down Expand Up @@ -389,6 +389,10 @@ To prevent the buffer from overflowing, the `discard()` member function of class

**Discarding invalidates all pointers to the input's data and 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.**

Calling `discard()` on a non-buffered input is an empty method and will be optimised away completely.

Usually you don't call `discard()` manually. Instead, one of the two following methods might be used.

#### Via Rules

The [`discard`](Rule-Reference#discard) rule behaves just like the [`success`](Rule-Reference.md#success) rule but calls the discard function on the input before returning `true`.
Expand All @@ -399,6 +403,7 @@ The `tao::pegtl::discard_input`, `tao::pegtl::discard_input_on_success` and `tao

These actions are used in the usual way, by deriving a custom action class template specialisation from them.
In the case of `discard_input`, the input is discarded unconditionally after every match attempt of the rule that the action is attached to.
As `discard_input` is based on the `match()` method, it is unaffected by enabling or disabling actions (which only applies to the `apply`/`apply0`-methods).

The other two variants behave as implied by their respective names, keeping in mind that "failure" is to be understood as "local failure" (false), no discard is performed on global failure (exception).
Similarly "unconditional" is wrt. success or local failure, not global failure.
Expand Down Expand Up @@ -436,7 +441,7 @@ struct my_action< rep< 4, must< xdigit > >
: tao::pegtl::discard_input
{
template< typename Input >
void apply( const Input& in, /* the states */ )
static void apply( const Input& in, /* the states */ )
{
assert( in.size() == 4 );
// process the 4 xdigits
Expand Down
Binary file removed doc/Parse-Tree.png
Binary file not shown.

0 comments on commit 164835b

Please sign in to comment.