Skip to content

Commit

Permalink
Upgrade PEGTL to latest version 3.2.7. In upcoming version 4+, they have
Browse files Browse the repository at this point in the history
removed support for the amalgamated header.  In anticipation of this, we add a
new pxr/base/pegtl library rather than embedding it in pxr/base/tf.

(Internal change: 2324194)
  • Loading branch information
gitamohr authored and pixar-oss committed Apr 19, 2024
1 parent 8daf935 commit e1e77d5
Show file tree
Hide file tree
Showing 207 changed files with 14,128 additions and 12,584 deletions.
4 changes: 2 additions & 2 deletions LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ The Art of C++ : PEGTL (Parsing Expression Grammar Template Library)

The MIT License (MIT)

Copyright (c) 2007-2020 Dr. Colin Hirsch and Daniel Frey
Copyright (c) 2007-2022 Dr. Colin Hirsch and Daniel Frey

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -748,4 +748,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
1 change: 1 addition & 0 deletions pxr/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ set(DIRS
arch
tf
gf
pegtl
js
trace
work
Expand Down
206 changes: 206 additions & 0 deletions pxr/base/pegtl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
set(PXR_PREFIX pxr/base)
set(PXR_PACKAGE pegtl)

pxr_library(pegtl
# Workaround lack of build support for header-only libs.
LIBRARIES
arch

PUBLIC_HEADERS
pegtl.hpp
pegtl/apply_mode.hpp
pegtl/argv_input.hpp
pegtl/ascii.hpp
pegtl/buffer_input.hpp
pegtl/change_action.hpp
pegtl/change_action_and_state.hpp
pegtl/change_action_and_states.hpp
pegtl/change_control.hpp
pegtl/change_state.hpp
pegtl/change_states.hpp
pegtl/config.hpp
pegtl/contrib/abnf.hpp
pegtl/contrib/add_state.hpp
pegtl/contrib/alphabet.hpp
pegtl/contrib/analyze.hpp
pegtl/contrib/analyze_traits.hpp
pegtl/contrib/check_bytes.hpp
pegtl/contrib/control_action.hpp
pegtl/contrib/coverage.hpp
pegtl/contrib/forward.hpp
pegtl/contrib/function.hpp
pegtl/contrib/http.hpp
pegtl/contrib/icu/internal.hpp
pegtl/contrib/icu/utf16.hpp
pegtl/contrib/icu/utf32.hpp
pegtl/contrib/icu/utf8.hpp
pegtl/contrib/if_then.hpp
pegtl/contrib/instantiate.hpp
pegtl/contrib/integer.hpp
pegtl/contrib/internal/endian.hpp
pegtl/contrib/internal/endian_gcc.hpp
pegtl/contrib/internal/endian_win.hpp
pegtl/contrib/internal/peek_mask_uint.hpp
pegtl/contrib/internal/peek_mask_uint8.hpp
pegtl/contrib/internal/peek_uint.hpp
pegtl/contrib/internal/peek_uint8.hpp
pegtl/contrib/internal/peek_utf16.hpp
pegtl/contrib/internal/peek_utf32.hpp
pegtl/contrib/internal/read_uint.hpp
pegtl/contrib/internal/set_stack_guard.hpp
pegtl/contrib/internal/vector_stack_guard.hpp
pegtl/contrib/iri.hpp
pegtl/contrib/json.hpp
pegtl/contrib/json_pointer.hpp
pegtl/contrib/limit_bytes.hpp
pegtl/contrib/limit_depth.hpp
pegtl/contrib/parse_tree.hpp
pegtl/contrib/parse_tree_to_dot.hpp
pegtl/contrib/peg.hpp
pegtl/contrib/predicates.hpp
pegtl/contrib/print.hpp
pegtl/contrib/print_coverage.hpp
pegtl/contrib/proto3.hpp
pegtl/contrib/raw_string.hpp
pegtl/contrib/remove_first_state.hpp
pegtl/contrib/remove_last_states.hpp
pegtl/contrib/rep_one_min_max.hpp
pegtl/contrib/rep_string.hpp
pegtl/contrib/separated_seq.hpp
pegtl/contrib/shuffle_states.hpp
pegtl/contrib/state_control.hpp
pegtl/contrib/to_string.hpp
pegtl/contrib/trace.hpp
pegtl/contrib/uint16.hpp
pegtl/contrib/uint32.hpp
pegtl/contrib/uint64.hpp
pegtl/contrib/uint8.hpp
pegtl/contrib/unescape.hpp
pegtl/contrib/uri.hpp
pegtl/contrib/utf16.hpp
pegtl/contrib/utf32.hpp
pegtl/cstream_input.hpp
pegtl/demangle.hpp
pegtl/disable_action.hpp
pegtl/discard_input.hpp
pegtl/discard_input_on_failure.hpp
pegtl/discard_input_on_success.hpp
pegtl/enable_action.hpp
pegtl/eol.hpp
pegtl/eol_pair.hpp
pegtl/file_input.hpp
pegtl/internal/action.hpp
pegtl/internal/action_input.hpp
pegtl/internal/any.hpp
pegtl/internal/apply.hpp
pegtl/internal/apply0.hpp
pegtl/internal/apply0_single.hpp
pegtl/internal/apply_single.hpp
pegtl/internal/at.hpp
pegtl/internal/bof.hpp
pegtl/internal/bol.hpp
pegtl/internal/bump.hpp
pegtl/internal/bump_help.hpp
pegtl/internal/bytes.hpp
pegtl/internal/control.hpp
pegtl/internal/cr_crlf_eol.hpp
pegtl/internal/cr_eol.hpp
pegtl/internal/crlf_eol.hpp
pegtl/internal/cstream_reader.hpp
pegtl/internal/cstring_reader.hpp
pegtl/internal/dependent_false.hpp
pegtl/internal/disable.hpp
pegtl/internal/discard.hpp
pegtl/internal/enable.hpp
pegtl/internal/enable_control.hpp
pegtl/internal/eof.hpp
pegtl/internal/eol.hpp
pegtl/internal/eolf.hpp
pegtl/internal/failure.hpp
pegtl/internal/file_mapper_posix.hpp
pegtl/internal/file_mapper_win32.hpp
pegtl/internal/file_reader.hpp
pegtl/internal/filesystem.hpp
pegtl/internal/has_apply.hpp
pegtl/internal/has_apply0.hpp
pegtl/internal/has_match.hpp
pegtl/internal/has_unwind.hpp
pegtl/internal/identifier.hpp
pegtl/internal/if_apply.hpp
pegtl/internal/if_must.hpp
pegtl/internal/if_must_else.hpp
pegtl/internal/if_then_else.hpp
pegtl/internal/input_pair.hpp
pegtl/internal/istream_reader.hpp
pegtl/internal/istring.hpp
pegtl/internal/iterator.hpp
pegtl/internal/lf_crlf_eol.hpp
pegtl/internal/lf_eol.hpp
pegtl/internal/list.hpp
pegtl/internal/list_must.hpp
pegtl/internal/list_tail.hpp
pegtl/internal/list_tail_pad.hpp
pegtl/internal/marker.hpp
pegtl/internal/minus.hpp
pegtl/internal/missing_apply.hpp
pegtl/internal/missing_apply0.hpp
pegtl/internal/must.hpp
pegtl/internal/not_at.hpp
pegtl/internal/one.hpp
pegtl/internal/opt.hpp
pegtl/internal/pad.hpp
pegtl/internal/pad_opt.hpp
pegtl/internal/path_to_string.hpp
pegtl/internal/peek_char.hpp
pegtl/internal/peek_utf8.hpp
pegtl/internal/pegtl_string.hpp
pegtl/internal/plus.hpp
pegtl/internal/raise.hpp
pegtl/internal/range.hpp
pegtl/internal/ranges.hpp
pegtl/internal/rematch.hpp
pegtl/internal/rep.hpp
pegtl/internal/rep_min.hpp
pegtl/internal/rep_min_max.hpp
pegtl/internal/rep_opt.hpp
pegtl/internal/require.hpp
pegtl/internal/result_on_found.hpp
pegtl/internal/rules.hpp
pegtl/internal/seq.hpp
pegtl/internal/sor.hpp
pegtl/internal/star.hpp
pegtl/internal/star_must.hpp
pegtl/internal/state.hpp
pegtl/internal/string.hpp
pegtl/internal/success.hpp
pegtl/internal/try_catch_type.hpp
pegtl/internal/until.hpp
pegtl/internal/unwind_guard.hpp
pegtl/istream_input.hpp
pegtl/match.hpp
pegtl/memory_input.hpp
pegtl/mmap_input.hpp
pegtl/must_if.hpp
pegtl/normal.hpp
pegtl/nothing.hpp
pegtl/parse.hpp
pegtl/parse_error.hpp
pegtl/position.hpp
pegtl/read_input.hpp
pegtl/require_apply.hpp
pegtl/require_apply0.hpp
pegtl/rewind_mode.hpp
pegtl/rules.hpp
pegtl/string_input.hpp
pegtl/tracking_mode.hpp
pegtl/type_list.hpp
pegtl/utf8.hpp
pegtl/version.hpp
pegtl/visit.hpp

CPPFILES
# Workaround lack of build support for header-only libs.
build-workaround.cpp

DISABLE_PRECOMPILED_HEADERS
)
47 changes: 47 additions & 0 deletions pxr/base/pegtl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# The Art of C++ : PEGTL (Parsing Expression Grammar Template Library)

[PEGTL](https://github.com/taocpp/PEGTL) is a library for creating
parsers according to a Parsing Expression Grammar.

## Version

v3.2.7

## Setup

Refer to the [Installing and Using](https://github.com/taocpp/PEGTL/blob/3.x/doc/Installing-and-Using.md)
documentation

## Copy headers

1. Copy PEGTL-3.2.7/include/tao/... to pxr/base/pegtl/...

2. Replace Macro Names

Change macro names from TAO_PEGTL_ to PXR_PEGTL_. You can do this in a
bash-like shell with the following:

`sed -i 's/TAO_PEGTL_/PXR_PEGTL_/g' $(find -name '[^.]*.[hc]pp')`

3. Update CMakeLists.txt and any other build configuration files.

You can get a full list of the header files by running:

`find -type f`

4. Update pxr/base/pegtl/pegtl/config.hpp

This file defines the namespace name that PEGTL uses:

```
// Define PXR_PEGTL_NAMESPACE based on the internal namespace to isolate
// it from other versions of USD/PEGTL in client code.
#include "pxr/pxr.h"
#if PXR_USE_NAMESPACES
#define PXR_PEGTL_NAMESPACE PXR_INTERNAL_NS ## _pegtl
#else
#define PXR_PEGTL_NAMESPACE pxr_pegtl
#endif
```

8 changes: 8 additions & 0 deletions pxr/base/pegtl/build-workaround.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// This is required since our build does not currently support header-only
// libraries. Without this the headers install okay, but other libs that try to
// use this library will fail to link, like: `ld: cannot find -lpegtl`. By
// adding this, an "empty" .so gets built and other libs can link it.

#include "pxr/base/arch/export.h"

ARCH_EXPORT int __pxr_pegtl_workaround__;
48 changes: 48 additions & 0 deletions pxr/base/pegtl/pegtl.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright (c) 2014-2022 Dr. Colin Hirsch and Daniel Frey
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/

#ifndef PXR_PEGTL_HPP
#define PXR_PEGTL_HPP

#include "pegtl/config.hpp"
#include "pegtl/demangle.hpp"
#include "pegtl/parse.hpp"
#include "pegtl/version.hpp"

#include "pegtl/ascii.hpp"
#include "pegtl/rules.hpp"
#include "pegtl/utf8.hpp"

#include "pegtl/argv_input.hpp"
#include "pegtl/buffer_input.hpp"
#include "pegtl/cstream_input.hpp"
#include "pegtl/istream_input.hpp"
#include "pegtl/memory_input.hpp"
#include "pegtl/read_input.hpp"
#include "pegtl/string_input.hpp"

// This has to be included *after* the above inputs,
// otherwise the amalgamated header will not work!
#include "pegtl/file_input.hpp"

#include "pegtl/change_action.hpp"
#include "pegtl/change_action_and_state.hpp"
#include "pegtl/change_action_and_states.hpp"
#include "pegtl/change_control.hpp"
#include "pegtl/change_state.hpp"
#include "pegtl/change_states.hpp"

#include "pegtl/disable_action.hpp"
#include "pegtl/enable_action.hpp"

#include "pegtl/discard_input.hpp"
#include "pegtl/discard_input_on_failure.hpp"
#include "pegtl/discard_input_on_success.hpp"

#include "pegtl/visit.hpp"

#if defined( __cpp_exceptions )
#include "pegtl/must_if.hpp"
#endif

#endif
19 changes: 19 additions & 0 deletions pxr/base/pegtl/pegtl/apply_mode.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) 2014-2022 Dr. Colin Hirsch and Daniel Frey
// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/

#ifndef PXR_PEGTL_APPLY_MODE_HPP
#define PXR_PEGTL_APPLY_MODE_HPP

#include "config.hpp"

namespace PXR_PEGTL_NAMESPACE
{
enum class apply_mode : bool
{
action = true,
nothing = false
};

} // namespace PXR_PEGTL_NAMESPACE

#endif
Loading

0 comments on commit e1e77d5

Please sign in to comment.