From 10e253d874c9ac059c525711723baed5be29a16d Mon Sep 17 00:00:00 2001 From: Stephane Del Pino <stephane.delpino44@gmail.com> Date: Thu, 11 Apr 2019 21:42:38 +0200 Subject: [PATCH] git subrepo pull packages/PEGTL subrepo: subdir: "packages/PEGTL" merged: "68790bd2c" upstream: origin: "git@github.com:taocpp/PEGTL.git" branch: "master" commit: "68790bd2c" git-subrepo: version: "0.4.0" origin: "git@github.com:ingydotnet/git-subrepo.git" commit: "5d6aba9" --- packages/PEGTL/.appveyor.yml | 35 +- packages/PEGTL/.clang-format | 23 +- packages/PEGTL/.conan/build.py | 2 +- .../.conan/test_package/test_package.cpp | 55 +- packages/PEGTL/.doozer.json | 74 - packages/PEGTL/.gitrepo | 7 +- packages/PEGTL/.travis.yml | 380 +---- packages/PEGTL/CMakeLists.txt | 95 +- packages/PEGTL/LICENSE | 2 +- packages/PEGTL/Makefile | 51 +- packages/PEGTL/README.md | 73 +- packages/PEGTL/cmake/dummy-config.cmake.in | 5 + packages/PEGTL/conanfile.py | 6 +- packages/PEGTL/doc/Actions-and-States.md | 532 +++++-- packages/PEGTL/doc/Changelog.md | 76 +- packages/PEGTL/doc/Contrib-and-Examples.md | 72 +- packages/PEGTL/doc/Control-and-Debug.md | 99 +- packages/PEGTL/doc/Errors-and-Exceptions.md | 78 +- packages/PEGTL/doc/Getting-Started.md | 9 +- packages/PEGTL/doc/Grammar-Analysis.md | 36 +- packages/PEGTL/doc/Inputs-and-Parsing.md | 284 ++-- packages/PEGTL/doc/Installing-and-Using.md | 187 ++- packages/PEGTL/doc/Migration-Guide.md | 38 +- packages/PEGTL/doc/Parse-Tree.md | 197 ++- packages/PEGTL/doc/Parse-Tree.png | Bin 0 -> 59564 bytes packages/PEGTL/doc/Performance-Notes.md | 2 +- packages/PEGTL/doc/README.md | 54 +- packages/PEGTL/doc/Rule-Reference.md | 40 +- packages/PEGTL/doc/Rules-and-Grammars.md | 49 +- packages/PEGTL/doc/Thank-You.md | 41 + packages/PEGTL/include/tao/pegtl.hpp | 19 +- .../tao/pegtl/analysis/analyze_cycles.hpp | 188 ++- .../include/tao/pegtl/analysis/counted.hpp | 22 +- .../include/tao/pegtl/analysis/generic.hpp | 38 +- .../tao/pegtl/analysis/grammar_info.hpp | 32 +- .../tao/pegtl/analysis/insert_guard.hpp | 77 +- .../tao/pegtl/analysis/insert_rules.hpp | 38 +- .../include/tao/pegtl/analysis/rule_info.hpp | 28 +- .../include/tao/pegtl/analysis/rule_type.hpp | 26 +- packages/PEGTL/include/tao/pegtl/analyze.hpp | 18 +- .../PEGTL/include/tao/pegtl/apply_mode.hpp | 18 +- .../PEGTL/include/tao/pegtl/argv_input.hpp | 62 +- packages/PEGTL/include/tao/pegtl/ascii.hpp | 94 +- .../PEGTL/include/tao/pegtl/buffer_input.hpp | 278 ++-- .../PEGTL/include/tao/pegtl/change_action.hpp | 38 + .../tao/pegtl/change_action_and_state.hpp | 53 + .../tao/pegtl/change_action_and_states.hpp | 62 + .../include/tao/pegtl/change_control.hpp | 36 + .../PEGTL/include/tao/pegtl/change_state.hpp | 50 + .../PEGTL/include/tao/pegtl/change_states.hpp | 61 + packages/PEGTL/include/tao/pegtl/config.hpp | 11 +- .../PEGTL/include/tao/pegtl/contrib/abnf.hpp | 56 +- .../include/tao/pegtl/contrib/alphabet.hpp | 118 +- .../include/tao/pegtl/contrib/changes.hpp | 86 -- .../include/tao/pegtl/contrib/counter.hpp | 68 +- .../PEGTL/include/tao/pegtl/contrib/http.hpp | 175 ++- .../tao/pegtl/contrib/icu/internal.hpp | 88 +- .../include/tao/pegtl/contrib/icu/utf16.hpp | 376 +++-- .../include/tao/pegtl/contrib/icu/utf32.hpp | 376 +++-- .../include/tao/pegtl/contrib/icu/utf8.hpp | 180 ++- .../include/tao/pegtl/contrib/if_then.hpp | 62 +- .../include/tao/pegtl/contrib/integer.hpp | 158 +-- .../PEGTL/include/tao/pegtl/contrib/json.hpp | 156 +-- .../include/tao/pegtl/contrib/parse_tree.hpp | 870 ++++++------ .../tao/pegtl/contrib/parse_tree_to_dot.hpp | 48 + .../include/tao/pegtl/contrib/raw_string.hpp | 334 ++--- .../tao/pegtl/contrib/rep_one_min_max.hpp | 76 +- .../include/tao/pegtl/contrib/rep_string.hpp | 44 + .../include/tao/pegtl/contrib/to_string.hpp | 44 +- .../include/tao/pegtl/contrib/tracer.hpp | 143 +- .../include/tao/pegtl/contrib/unescape.hpp | 353 +++-- .../PEGTL/include/tao/pegtl/contrib/uri.hpp | 144 +- .../PEGTL/include/tao/pegtl/cstream_input.hpp | 32 +- .../include/tao/pegtl/disable_action.hpp | 35 + .../PEGTL/include/tao/pegtl/discard_input.hpp | 37 + .../tao/pegtl/discard_input_on_failure.hpp | 39 + .../tao/pegtl/discard_input_on_success.hpp | 39 + .../PEGTL/include/tao/pegtl/enable_action.hpp | 35 + packages/PEGTL/include/tao/pegtl/eol.hpp | 38 +- packages/PEGTL/include/tao/pegtl/eol_pair.hpp | 12 +- .../PEGTL/include/tao/pegtl/file_input.hpp | 40 +- .../PEGTL/include/tao/pegtl/input_error.hpp | 51 - .../include/tao/pegtl/internal/action.hpp | 54 +- .../tao/pegtl/internal/action_input.hpp | 177 ++- .../include/tao/pegtl/internal/alnum.hpp | 16 +- .../include/tao/pegtl/internal/alpha.hpp | 16 +- .../tao/pegtl/internal/always_false.hpp | 21 + .../PEGTL/include/tao/pegtl/internal/any.hpp | 84 +- .../include/tao/pegtl/internal/apply.hpp | 101 +- .../include/tao/pegtl/internal/apply0.hpp | 96 +- .../tao/pegtl/internal/apply0_single.hpp | 44 +- .../tao/pegtl/internal/apply_single.hpp | 44 +- .../PEGTL/include/tao/pegtl/internal/at.hpp | 75 +- .../PEGTL/include/tao/pegtl/internal/bof.hpp | 36 +- .../PEGTL/include/tao/pegtl/internal/bol.hpp | 36 +- .../PEGTL/include/tao/pegtl/internal/bump.hpp | 45 + .../include/tao/pegtl/internal/bump_help.hpp | 60 +- .../include/tao/pegtl/internal/bump_impl.hpp | 53 - .../include/tao/pegtl/internal/bytes.hpp | 50 +- .../tao/pegtl/internal/conditional.hpp | 38 - .../include/tao/pegtl/internal/control.hpp | 54 +- .../tao/pegtl/internal/cr_crlf_eol.hpp | 42 +- .../include/tao/pegtl/internal/cr_eol.hpp | 42 +- .../include/tao/pegtl/internal/crlf_eol.hpp | 42 +- .../tao/pegtl/internal/cstream_reader.hpp | 67 +- .../tao/pegtl/internal/cstring_reader.hpp | 59 +- .../include/tao/pegtl/internal/demangle.hpp | 30 +- .../tao/pegtl/internal/demangle_cxxabi.hpp | 34 +- .../tao/pegtl/internal/demangle_nop.hpp | 20 +- .../tao/pegtl/internal/demangle_sanitise.hpp | 58 +- .../include/tao/pegtl/internal/disable.hpp | 54 +- .../include/tao/pegtl/internal/discard.hpp | 40 +- .../include/tao/pegtl/internal/dusel_mode.hpp | 26 +- .../tao/pegtl/internal/duseltronik.hpp | 308 +++-- .../include/tao/pegtl/internal/enable.hpp | 54 +- .../include/tao/pegtl/internal/endian.hpp | 80 +- .../include/tao/pegtl/internal/endian_gcc.hpp | 359 +++-- .../include/tao/pegtl/internal/endian_win.hpp | 185 ++- .../PEGTL/include/tao/pegtl/internal/eof.hpp | 36 +- .../PEGTL/include/tao/pegtl/internal/eol.hpp | 36 +- .../PEGTL/include/tao/pegtl/internal/eolf.hpp | 38 +- .../tao/pegtl/internal/file_mapper_posix.hpp | 144 +- .../tao/pegtl/internal/file_mapper_win32.hpp | 375 ++--- .../tao/pegtl/internal/file_opener.hpp | 96 +- .../tao/pegtl/internal/file_reader.hpp | 163 +-- .../include/tao/pegtl/internal/has_apply.hpp | 30 +- .../include/tao/pegtl/internal/has_apply0.hpp | 30 +- .../include/tao/pegtl/internal/has_match.hpp | 56 + .../include/tao/pegtl/internal/identifier.hpp | 20 +- .../include/tao/pegtl/internal/if_apply.hpp | 123 +- .../include/tao/pegtl/internal/if_must.hpp | 63 +- .../tao/pegtl/internal/if_must_else.hpp | 18 +- .../tao/pegtl/internal/if_then_else.hpp | 66 +- .../include/tao/pegtl/internal/input_pair.hpp | 34 +- .../tao/pegtl/internal/integer_sequence.hpp | 86 -- .../tao/pegtl/internal/istream_reader.hpp | 59 +- .../include/tao/pegtl/internal/istring.hpp | 123 +- .../include/tao/pegtl/internal/iterator.hpp | 68 +- .../tao/pegtl/internal/lf_crlf_eol.hpp | 52 +- .../include/tao/pegtl/internal/lf_eol.hpp | 42 +- .../PEGTL/include/tao/pegtl/internal/list.hpp | 18 +- .../include/tao/pegtl/internal/list_must.hpp | 18 +- .../include/tao/pegtl/internal/list_tail.hpp | 18 +- .../tao/pegtl/internal/list_tail_pad.hpp | 18 +- .../include/tao/pegtl/internal/marker.hpp | 155 +-- .../include/tao/pegtl/internal/minus.hpp | 69 - .../tao/pegtl/internal/missing_apply.hpp | 25 + .../tao/pegtl/internal/missing_apply0.hpp | 23 + .../PEGTL/include/tao/pegtl/internal/must.hpp | 103 +- .../include/tao/pegtl/internal/not_at.hpp | 75 +- .../PEGTL/include/tao/pegtl/internal/one.hpp | 92 +- .../PEGTL/include/tao/pegtl/internal/opt.hpp | 70 +- .../PEGTL/include/tao/pegtl/internal/pad.hpp | 18 +- .../include/tao/pegtl/internal/pad_opt.hpp | 18 +- .../include/tao/pegtl/internal/peek_char.hpp | 33 +- .../tao/pegtl/internal/peek_mask_uint.hpp | 65 +- .../tao/pegtl/internal/peek_mask_uint8.hpp | 35 +- .../include/tao/pegtl/internal/peek_uint.hpp | 63 +- .../include/tao/pegtl/internal/peek_uint8.hpp | 33 +- .../include/tao/pegtl/internal/peek_utf16.hpp | 83 +- .../include/tao/pegtl/internal/peek_utf32.hpp | 60 +- .../include/tao/pegtl/internal/peek_utf8.hpp | 130 +- .../tao/pegtl/internal/pegtl_string.hpp | 111 +- .../PEGTL/include/tao/pegtl/internal/plus.hpp | 64 +- .../include/tao/pegtl/internal/raise.hpp | 56 +- .../include/tao/pegtl/internal/range.hpp | 67 +- .../include/tao/pegtl/internal/ranges.hpp | 137 +- .../include/tao/pegtl/internal/read_uint.hpp | 130 +- .../include/tao/pegtl/internal/rematch.hpp | 69 + .../PEGTL/include/tao/pegtl/internal/rep.hpp | 91 +- .../include/tao/pegtl/internal/rep_min.hpp | 18 +- .../tao/pegtl/internal/rep_min_max.hpp | 111 +- .../include/tao/pegtl/internal/rep_opt.hpp | 58 +- .../include/tao/pegtl/internal/require.hpp | 54 +- .../tao/pegtl/internal/result_on_found.hpp | 22 +- .../tao/pegtl/internal/rule_conjunction.hpp | 63 - .../include/tao/pegtl/internal/rules.hpp | 6 +- .../PEGTL/include/tao/pegtl/internal/seq.hpp | 107 +- .../tao/pegtl/internal/skip_control.hpp | 32 +- .../PEGTL/include/tao/pegtl/internal/sor.hpp | 88 +- .../PEGTL/include/tao/pegtl/internal/star.hpp | 59 +- .../include/tao/pegtl/internal/star_must.hpp | 18 +- .../include/tao/pegtl/internal/state.hpp | 92 +- .../include/tao/pegtl/internal/string.hpp | 70 +- .../include/tao/pegtl/internal/three.hpp | 52 - .../include/tao/pegtl/internal/trivial.hpp | 38 +- .../tao/pegtl/internal/try_catch_type.hpp | 88 +- .../PEGTL/include/tao/pegtl/internal/two.hpp | 52 - .../include/tao/pegtl/internal/until.hpp | 117 +- .../PEGTL/include/tao/pegtl/istream_input.hpp | 32 +- packages/PEGTL/include/tao/pegtl/match.hpp | 73 + .../PEGTL/include/tao/pegtl/memory_input.hpp | 539 ++++---- .../PEGTL/include/tao/pegtl/mmap_input.hpp | 82 +- packages/PEGTL/include/tao/pegtl/normal.hpp | 122 +- packages/PEGTL/include/tao/pegtl/nothing.hpp | 21 +- packages/PEGTL/include/tao/pegtl/parse.hpp | 91 +- .../PEGTL/include/tao/pegtl/parse_error.hpp | 89 +- packages/PEGTL/include/tao/pegtl/position.hpp | 56 +- .../PEGTL/include/tao/pegtl/read_input.hpp | 90 +- .../PEGTL/include/tao/pegtl/require_apply.hpp | 16 + .../include/tao/pegtl/require_apply0.hpp | 16 + .../PEGTL/include/tao/pegtl/rewind_mode.hpp | 20 +- packages/PEGTL/include/tao/pegtl/rules.hpp | 109 +- .../PEGTL/include/tao/pegtl/string_input.hpp | 78 +- .../PEGTL/include/tao/pegtl/tracking_mode.hpp | 18 +- packages/PEGTL/include/tao/pegtl/uint16.hpp | 96 +- packages/PEGTL/include/tao/pegtl/uint32.hpp | 96 +- packages/PEGTL/include/tao/pegtl/uint64.hpp | 88 +- packages/PEGTL/include/tao/pegtl/uint8.hpp | 50 +- packages/PEGTL/include/tao/pegtl/utf16.hpp | 72 +- packages/PEGTL/include/tao/pegtl/utf32.hpp | 72 +- packages/PEGTL/include/tao/pegtl/utf8.hpp | 36 +- packages/PEGTL/include/tao/pegtl/version.hpp | 16 +- .../PEGTL/src/example/pegtl/CMakeLists.txt | 57 +- .../PEGTL/src/example/pegtl/abnf2pegtl.cpp | 1230 ++++++++--------- packages/PEGTL/src/example/pegtl/analyze.cpp | 4 +- .../PEGTL/src/example/pegtl/calculator.cpp | 63 +- .../src/example/pegtl/chomsky_hierarchy.cpp | 18 +- packages/PEGTL/src/example/pegtl/csv1.cpp | 13 +- packages/PEGTL/src/example/pegtl/csv2.cpp | 16 +- packages/PEGTL/src/example/pegtl/double.hpp | 4 +- .../PEGTL/src/example/pegtl/dynamic_match.cpp | 36 +- .../PEGTL/src/example/pegtl/hello_world.cpp | 10 +- .../PEGTL/src/example/pegtl/indent_aware.cpp | 31 +- .../{json_build_two.cpp => json_build.cpp} | 80 +- .../src/example/pegtl/json_build_one.cpp | 192 --- .../PEGTL/src/example/pegtl/json_classes.hpp | 26 +- .../PEGTL/src/example/pegtl/json_count.cpp | 8 +- .../PEGTL/src/example/pegtl/json_errors.hpp | 44 +- .../PEGTL/src/example/pegtl/json_parse.cpp | 6 +- .../PEGTL/src/example/pegtl/json_unescape.hpp | 36 +- .../PEGTL/src/example/pegtl/lua53_parse.cpp | 20 +- .../PEGTL/src/example/pegtl/modulus_match.cpp | 8 +- .../PEGTL/src/example/pegtl/parse_tree.cpp | 82 +- .../example/pegtl/parse_tree_user_state.cpp | 37 + packages/PEGTL/src/example/pegtl/proto3.cpp | 200 ++- packages/PEGTL/src/example/pegtl/recover.cpp | 10 +- .../PEGTL/src/example/pegtl/s_expression.cpp | 81 +- packages/PEGTL/src/example/pegtl/sum.cpp | 22 +- .../PEGTL/src/example/pegtl/symbol_table.cpp | 12 +- packages/PEGTL/src/example/pegtl/unescape.cpp | 14 +- packages/PEGTL/src/example/pegtl/uri.cpp | 8 +- .../PEGTL/src/example/pegtl/uri_trace.cpp | 6 +- packages/PEGTL/src/test/pegtl/CMakeLists.txt | 73 +- .../PEGTL/src/test/pegtl/action_enable.cpp | 64 + .../PEGTL/src/test/pegtl/action_match.cpp | 116 ++ packages/PEGTL/src/test/pegtl/actions_one.cpp | 142 +- .../PEGTL/src/test/pegtl/actions_three.cpp | 147 +- packages/PEGTL/src/test/pegtl/actions_two.cpp | 208 ++- .../PEGTL/src/test/pegtl/analyze_cycles.cpp | 594 ++++---- packages/PEGTL/src/test/pegtl/argv_input.cpp | 28 +- .../PEGTL/src/test/pegtl/ascii_classes.cpp | 208 ++- packages/PEGTL/src/test/pegtl/ascii_eol.cpp | 144 +- packages/PEGTL/src/test/pegtl/ascii_eolf.cpp | 144 +- .../PEGTL/src/test/pegtl/ascii_forty_two.cpp | 54 +- .../PEGTL/src/test/pegtl/ascii_identifier.cpp | 42 +- .../PEGTL/src/test/pegtl/ascii_istring.cpp | 64 +- .../PEGTL/src/test/pegtl/ascii_keyword.cpp | 38 +- .../PEGTL/src/test/pegtl/ascii_shebang.cpp | 46 +- .../PEGTL/src/test/pegtl/ascii_string.cpp | 62 +- packages/PEGTL/src/test/pegtl/ascii_three.cpp | 34 +- packages/PEGTL/src/test/pegtl/ascii_two.cpp | 28 +- .../PEGTL/src/test/pegtl/buffer_input.cpp | 41 + .../test/pegtl/change_action_and_state.cpp | 122 ++ .../test/pegtl/change_action_and_states.cpp | 112 ++ .../PEGTL/src/test/pegtl/change_state.cpp | 105 ++ .../PEGTL/src/test/pegtl/change_states.cpp | 89 ++ .../PEGTL/src/test/pegtl/contrib_alphabet.cpp | 118 +- .../PEGTL/src/test/pegtl/contrib_if_then.cpp | 33 +- .../PEGTL/src/test/pegtl/contrib_integer.cpp | 266 ++-- .../PEGTL/src/test/pegtl/contrib_json.cpp | 232 ++-- .../src/test/pegtl/contrib_parse_tree.cpp | 84 +- .../src/test/pegtl/contrib_partial_trace.cpp | 28 + .../src/test/pegtl/contrib_raw_string.cpp | 224 ++- .../test/pegtl/contrib_rep_one_min_max.cpp | 54 +- .../src/test/pegtl/contrib_to_string.cpp | 40 +- .../PEGTL/src/test/pegtl/contrib_tracer.cpp | 133 +- .../PEGTL/src/test/pegtl/contrib_unescape.cpp | 212 ++- packages/PEGTL/src/test/pegtl/contrib_uri.cpp | 62 +- packages/PEGTL/src/test/pegtl/data/blns.json | 0 .../PEGTL/src/test/pegtl/data_cstring.cpp | 42 +- packages/PEGTL/src/test/pegtl/demangle.cpp | 52 +- .../PEGTL/src/test/pegtl/discard_input.cpp | 56 + .../PEGTL/src/test/pegtl/file_cstream.cpp | 40 +- packages/PEGTL/src/test/pegtl/file_file.cpp | 16 +- .../PEGTL/src/test/pegtl/file_istream.cpp | 39 +- packages/PEGTL/src/test/pegtl/file_mmap.cpp | 16 +- packages/PEGTL/src/test/pegtl/file_read.cpp | 38 +- .../PEGTL/src/test/pegtl/internal_endian.cpp | 134 +- .../src/test/pegtl/internal_file_mapper.cpp | 34 +- .../src/test/pegtl/internal_file_opener.cpp | 31 +- packages/PEGTL/src/test/pegtl/main.hpp | 10 +- .../PEGTL/src/test/pegtl/pegtl_string_t.cpp | 21 +- packages/PEGTL/src/test/pegtl/position.cpp | 300 ++-- packages/PEGTL/src/test/pegtl/result_type.hpp | 42 +- packages/PEGTL/src/test/pegtl/rule_action.cpp | 22 +- packages/PEGTL/src/test/pegtl/rule_apply.cpp | 136 +- packages/PEGTL/src/test/pegtl/rule_apply0.cpp | 126 +- packages/PEGTL/src/test/pegtl/rule_at.cpp | 84 +- packages/PEGTL/src/test/pegtl/rule_bof.cpp | 34 +- packages/PEGTL/src/test/pegtl/rule_bol.cpp | 32 +- packages/PEGTL/src/test/pegtl/rule_bytes.cpp | 44 +- .../PEGTL/src/test/pegtl/rule_control.cpp | 22 +- .../PEGTL/src/test/pegtl/rule_disable.cpp | 16 +- packages/PEGTL/src/test/pegtl/rule_enable.cpp | 16 +- packages/PEGTL/src/test/pegtl/rule_eof.cpp | 24 +- .../PEGTL/src/test/pegtl/rule_failure.cpp | 22 +- .../PEGTL/src/test/pegtl/rule_if_apply.cpp | 199 ++- .../PEGTL/src/test/pegtl/rule_if_must.cpp | 68 +- .../src/test/pegtl/rule_if_must_else.cpp | 16 +- .../src/test/pegtl/rule_if_then_else.cpp | 16 +- packages/PEGTL/src/test/pegtl/rule_list.cpp | 100 +- .../PEGTL/src/test/pegtl/rule_list_must.cpp | 96 +- .../PEGTL/src/test/pegtl/rule_list_tail.cpp | 100 +- packages/PEGTL/src/test/pegtl/rule_minus.cpp | 84 +- packages/PEGTL/src/test/pegtl/rule_must.cpp | 16 +- packages/PEGTL/src/test/pegtl/rule_not_at.cpp | 94 +- packages/PEGTL/src/test/pegtl/rule_opt.cpp | 97 +- .../PEGTL/src/test/pegtl/rule_opt_must.cpp | 68 +- packages/PEGTL/src/test/pegtl/rule_pad.cpp | 76 +- .../PEGTL/src/test/pegtl/rule_pad_opt.cpp | 54 +- packages/PEGTL/src/test/pegtl/rule_plus.cpp | 62 +- .../PEGTL/src/test/pegtl/rule_rematch.cpp | 97 ++ packages/PEGTL/src/test/pegtl/rule_rep.cpp | 118 +- .../PEGTL/src/test/pegtl/rule_rep_max.cpp | 92 +- .../PEGTL/src/test/pegtl/rule_rep_min.cpp | 56 +- .../PEGTL/src/test/pegtl/rule_rep_min_max.cpp | 82 +- .../PEGTL/src/test/pegtl/rule_rep_opt.cpp | 72 +- .../PEGTL/src/test/pegtl/rule_require.cpp | 54 +- packages/PEGTL/src/test/pegtl/rule_seq.cpp | 16 +- packages/PEGTL/src/test/pegtl/rule_sor.cpp | 82 +- packages/PEGTL/src/test/pegtl/rule_star.cpp | 50 +- .../PEGTL/src/test/pegtl/rule_star_must.cpp | 50 +- packages/PEGTL/src/test/pegtl/rule_state.cpp | 59 +- .../PEGTL/src/test/pegtl/rule_success.cpp | 24 +- .../PEGTL/src/test/pegtl/rule_try_catch.cpp | 24 +- packages/PEGTL/src/test/pegtl/rule_until.cpp | 206 ++- packages/PEGTL/src/test/pegtl/test.hpp | 81 +- packages/PEGTL/src/test/pegtl/tester.cpp | 2 +- .../PEGTL/src/test/pegtl/uint16_general.cpp | 240 ++-- .../PEGTL/src/test/pegtl/uint32_general.cpp | 248 ++-- .../PEGTL/src/test/pegtl/uint64_general.cpp | 248 ++-- .../PEGTL/src/test/pegtl/uint8_general.cpp | 476 ++++--- .../PEGTL/src/test/pegtl/utf16_general.cpp | 270 ++-- .../PEGTL/src/test/pegtl/utf32_general.cpp | 228 ++- .../PEGTL/src/test/pegtl/utf8_general.cpp | 508 ++++--- .../PEGTL/src/test/pegtl/verify_analyze.hpp | 36 +- packages/PEGTL/src/test/pegtl/verify_char.hpp | 28 +- packages/PEGTL/src/test/pegtl/verify_fail.hpp | 28 +- packages/PEGTL/src/test/pegtl/verify_file.hpp | 257 ++-- packages/PEGTL/src/test/pegtl/verify_ifmt.hpp | 62 +- packages/PEGTL/src/test/pegtl/verify_impl.hpp | 54 +- packages/PEGTL/src/test/pegtl/verify_rule.hpp | 106 +- packages/PEGTL/src/test/pegtl/verify_seqs.hpp | 100 +- 354 files changed, 15300 insertions(+), 15506 deletions(-) delete mode 100644 packages/PEGTL/.doozer.json create mode 100644 packages/PEGTL/cmake/dummy-config.cmake.in create mode 100644 packages/PEGTL/doc/Parse-Tree.png create mode 100644 packages/PEGTL/doc/Thank-You.md create mode 100644 packages/PEGTL/include/tao/pegtl/change_action.hpp create mode 100644 packages/PEGTL/include/tao/pegtl/change_action_and_state.hpp create mode 100644 packages/PEGTL/include/tao/pegtl/change_action_and_states.hpp create mode 100644 packages/PEGTL/include/tao/pegtl/change_control.hpp create mode 100644 packages/PEGTL/include/tao/pegtl/change_state.hpp create mode 100644 packages/PEGTL/include/tao/pegtl/change_states.hpp delete mode 100644 packages/PEGTL/include/tao/pegtl/contrib/changes.hpp create mode 100644 packages/PEGTL/include/tao/pegtl/contrib/parse_tree_to_dot.hpp create mode 100644 packages/PEGTL/include/tao/pegtl/contrib/rep_string.hpp create mode 100644 packages/PEGTL/include/tao/pegtl/disable_action.hpp create mode 100644 packages/PEGTL/include/tao/pegtl/discard_input.hpp create mode 100644 packages/PEGTL/include/tao/pegtl/discard_input_on_failure.hpp create mode 100644 packages/PEGTL/include/tao/pegtl/discard_input_on_success.hpp create mode 100644 packages/PEGTL/include/tao/pegtl/enable_action.hpp delete mode 100644 packages/PEGTL/include/tao/pegtl/input_error.hpp create mode 100644 packages/PEGTL/include/tao/pegtl/internal/always_false.hpp create mode 100644 packages/PEGTL/include/tao/pegtl/internal/bump.hpp delete mode 100644 packages/PEGTL/include/tao/pegtl/internal/bump_impl.hpp delete mode 100644 packages/PEGTL/include/tao/pegtl/internal/conditional.hpp create mode 100644 packages/PEGTL/include/tao/pegtl/internal/has_match.hpp delete mode 100644 packages/PEGTL/include/tao/pegtl/internal/integer_sequence.hpp delete mode 100644 packages/PEGTL/include/tao/pegtl/internal/minus.hpp create mode 100644 packages/PEGTL/include/tao/pegtl/internal/missing_apply.hpp create mode 100644 packages/PEGTL/include/tao/pegtl/internal/missing_apply0.hpp create mode 100644 packages/PEGTL/include/tao/pegtl/internal/rematch.hpp delete mode 100644 packages/PEGTL/include/tao/pegtl/internal/rule_conjunction.hpp delete mode 100644 packages/PEGTL/include/tao/pegtl/internal/three.hpp delete mode 100644 packages/PEGTL/include/tao/pegtl/internal/two.hpp create mode 100644 packages/PEGTL/include/tao/pegtl/match.hpp create mode 100644 packages/PEGTL/include/tao/pegtl/require_apply.hpp create mode 100644 packages/PEGTL/include/tao/pegtl/require_apply0.hpp rename packages/PEGTL/src/example/pegtl/{json_build_two.cpp => json_build.cpp} (59%) delete mode 100644 packages/PEGTL/src/example/pegtl/json_build_one.cpp create mode 100644 packages/PEGTL/src/example/pegtl/parse_tree_user_state.cpp create mode 100644 packages/PEGTL/src/test/pegtl/action_enable.cpp create mode 100644 packages/PEGTL/src/test/pegtl/action_match.cpp create mode 100644 packages/PEGTL/src/test/pegtl/buffer_input.cpp create mode 100644 packages/PEGTL/src/test/pegtl/change_action_and_state.cpp create mode 100644 packages/PEGTL/src/test/pegtl/change_action_and_states.cpp create mode 100644 packages/PEGTL/src/test/pegtl/change_state.cpp create mode 100644 packages/PEGTL/src/test/pegtl/change_states.cpp create mode 100644 packages/PEGTL/src/test/pegtl/contrib_partial_trace.cpp mode change 100755 => 100644 packages/PEGTL/src/test/pegtl/data/blns.json create mode 100644 packages/PEGTL/src/test/pegtl/discard_input.cpp create mode 100644 packages/PEGTL/src/test/pegtl/rule_rematch.cpp diff --git a/packages/PEGTL/.appveyor.yml b/packages/PEGTL/.appveyor.yml index db3d921f8..8150fbf6e 100644 --- a/packages/PEGTL/.appveyor.yml +++ b/packages/PEGTL/.appveyor.yml @@ -1,41 +1,23 @@ version: '{branch}-{build}' os: -- Visual Studio 2015 +- Visual Studio 2017 configuration: - Release - Debug +skip_commits: + files: + - doc/**/* + environment: matrix: - - GENERATOR: Visual Studio 14 2015 - - - GENERATOR: Visual Studio 14 2015 Win64 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - GENERATOR: Visual Studio 15 2017 - - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - GENERATOR: Visual Studio 15 2017 Win64 - - - GENERATOR: MinGW Makefiles - BINDIR: C:\MinGW\bin - - - GENERATOR: MinGW Makefiles - COMPILER: MinGW 5 - BINDIR: C:\mingw-w64\i686-5.3.0-posix-dwarf-rt_v4-rev0\mingw32\bin - - - GENERATOR: MinGW Makefiles - COMPILER: MinGW 6 - BINDIR: C:\mingw-w64\i686-6.3.0-posix-dwarf-rt_v5-rev1\mingw32\bin + - GENERATOR: Visual Studio 15 2017 - - GENERATOR: MinGW Makefiles - COMPILER: MinGW 6 - BINDIR: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin + - GENERATOR: Visual Studio 15 2017 Win64 - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - GENERATOR: Visual Studio 15 2017 + - GENERATOR: Visual Studio 15 2017 CONAN_VISUAL_VERSIONS: 15 PYTHON: "C:\\Python27" PYTHON_VERSION: "2.7.8" @@ -49,7 +31,6 @@ install: - if defined CONAN (conan profile new default --detect) before_build: -- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" (del "C:\Program Files (x86)\MSBuild\14.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets") - if defined BINDIR (set "PATH=%BINDIR%;%PATH:C:\Program Files\Git\usr\bin;=%") - md build - cd build diff --git a/packages/PEGTL/.clang-format b/packages/PEGTL/.clang-format index f72eb4c25..729f882aa 100644 --- a/packages/PEGTL/.clang-format +++ b/packages/PEGTL/.clang-format @@ -1,6 +1,6 @@ # the official .clang-format style for https://github.com/taocpp # -# clang-format-5.0 -i -style=file $(find . -name '[^.]*.[hc]pp') +# clang-format -i -style=file $(find . -name '[^.]*.[hc]pp') Language: Cpp Standard: Cpp11 @@ -20,7 +20,7 @@ AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: true +AlwaysBreakTemplateDeclarations: Yes BinPackArguments: false BinPackParameters: false BraceWrapping: @@ -31,15 +31,21 @@ BraceWrapping: AfterNamespace : true AfterStruct : true AfterUnion : true + AfterExternBlock: true BeforeCatch : true BeforeElse : true IndentBraces : false + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: false BreakBeforeBinaryOperators: All BreakBeforeBraces: Custom BreakBeforeTernaryOperators: false +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon BreakStringLiterals: false -BreakConstructorInitializersBeforeComma: false ColumnLimit: 0 +CompactNamespaces: false ConstructorInitializerAllOnOneLineOrOnePerLine: true ConstructorInitializerIndentWidth: 3 ContinuationIndentWidth: 3 @@ -47,24 +53,31 @@ Cpp11BracedListStyle: false DerivePointerAlignment: false DisableFormat: false ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +IncludeBlocks: Preserve IndentCaseLabels: true +IndentPPDirectives: None IndentWidth: 3 IndentWrappedFunctionNames: false -KeepEmptyLinesAtTheStartOfBlocks: true +KeepEmptyLinesAtTheStartOfBlocks: false MaxEmptyLinesToKeep: 1 NamespaceIndentation: All PointerAlignment: Left ReflowComments: false SortIncludes: true +SortUsingDeclarations: false SpaceAfterCStyleCast: false SpaceAfterTemplateKeyword: false SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true SpaceBeforeParens: Never +SpaceBeforeRangeBasedForLoopColon: true SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 2 SpacesInAngles: true SpacesInCStyleCastParentheses: false -SpacesInContainerLiterals: true SpacesInParentheses: true SpacesInSquareBrackets: true TabWidth: 8 diff --git a/packages/PEGTL/.conan/build.py b/packages/PEGTL/.conan/build.py index 4c23b8385..838e79755 100644 --- a/packages/PEGTL/.conan/build.py +++ b/packages/PEGTL/.conan/build.py @@ -54,7 +54,7 @@ class BuilderSettings(object): def reference(self): """ Read project version from CMake file to create Conan referece """ - pattern = re.compile(r"project \(pegtl VERSION (\d+\.\d+\.\d+) LANGUAGES CXX\)") + pattern = re.compile(r"project\(pegtl VERSION (\d+\.\d+\.\d+) LANGUAGES CXX\)") version = None with open('CMakeLists.txt') as file: for line in file: diff --git a/packages/PEGTL/.conan/test_package/test_package.cpp b/packages/PEGTL/.conan/test_package/test_package.cpp index 5404848ed..f16aa2309 100644 --- a/packages/PEGTL/.conan/test_package/test_package.cpp +++ b/packages/PEGTL/.conan/test_package/test_package.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <cassert> @@ -15,7 +15,7 @@ #include <tao/pegtl/analyze.hpp> -namespace pegtl = tao::TAO_PEGTL_NAMESPACE; +namespace pegtl = TAO_PEGTL_NAMESPACE; namespace calculator { @@ -168,7 +168,7 @@ namespace calculator void insert( const std::string& name, const order p, const std::function< long( long, long ) >& f ) { assert( !name.empty() ); - m_ops.insert( { name, { p, f } } ); + m_ops.emplace( name, op{ p, f } ); } const std::map< std::string, op >& ops() const @@ -182,14 +182,13 @@ namespace calculator // Here the actual grammar starts. - using namespace tao::pegtl; // NOLINT + using namespace pegtl; // NOLINT // Comments are introduced by a '#' and proceed to the end-of-line/file. struct comment : if_must< one< '#' >, until< eolf > > - { - }; + {}; // The calculator ignores all spaces and comments; space is a pegtl rule // that matches the usual ascii characters ' ', '\t', '\n' etc. In other @@ -197,8 +196,7 @@ namespace calculator struct ignored : sor< space, comment > - { - }; + {}; // Since the binary operators are taken from a runtime data structure // (rather than hard-coding them into the grammar), we need a custom @@ -207,14 +205,17 @@ namespace calculator struct infix { - using analyze_t = analysis::generic< analysis::rule_type::ANY >; + using analyze_t = analysis::generic< analysis::rule_type::any >; template< apply_mode, rewind_mode, - template< typename... > class Action, - template< typename... > class Control, - typename Input > - static bool match( Input& in, const operators& b, stacks& s ) + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, const operators& b, stacks& s, States&&... /*unused*/ ) { // Look for the longest match of the input against the operators in the operator map. @@ -250,8 +251,7 @@ namespace calculator struct number : seq< opt< one< '+', '-' > >, plus< digit > > - { - }; + {}; struct expression; @@ -260,16 +260,14 @@ namespace calculator struct bracket : if_must< one< '(' >, expression, one< ')' > > - { - }; + {}; // An atomic expression, i.e. one without operators, is either a number or // a bracketed expression. struct atomic : sor< number, bracket > - { - }; + {}; // An expression is a non-empty list of atomic expressions where each pair // of atomic expressions is separated by an infix operator and we allow @@ -277,28 +275,20 @@ namespace calculator struct expression : list< atomic, infix, ignored > - { - }; + {}; // The top-level grammar allows one expression and then expects eof. struct grammar : must< expression, eof > - { - }; + {}; // After the grammar we proceed with the additional actions that are // required to let our calculator actually do something. - // The base-case of the class template for the actions must derive from - // pegtl::nothing (or, alternatively, define an action that does something - // sensible for all rules for which no specialisation exists). - template< typename Rule > struct action - : pegtl::nothing< Rule > - { - }; + {}; // This action will be called when the number rule matches; it converts the // matched portion of the input to a long and pushes it onto the operand @@ -310,8 +300,7 @@ namespace calculator template< typename Input > static void apply( const Input& in, const operators& /*unused*/, stacks& s ) { - std::stringstream ss; - ss.str( in.string() ); + std::stringstream ss( in.string() ); long v; ss >> v; s.push( v ); @@ -355,7 +344,7 @@ int main( int argc, char** argv ) for( int i = 1; i < argc; ++i ) { // Parse and process the command-line arguments as calculator expressions... - pegtl::argv_input<> in( argv, i ); + pegtl::argv_input in( argv, i ); pegtl::parse< calculator::grammar, calculator::action >( in, b, s ); // ...and print the respective results to std::cout. diff --git a/packages/PEGTL/.doozer.json b/packages/PEGTL/.doozer.json deleted file mode 100644 index 9f877bda3..000000000 --- a/packages/PEGTL/.doozer.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "targets": { - "jessie-i386": { - "buildenv": "jessie-i386", - "builddeps": ["build-essential"], - "buildcmd": "make -j" - }, - "trusty-i386": { - "buildenv": "trusty-i386", - "builddeps": ["build-essential"], - "buildcmd": "make -j" - }, - "trusty-amd64": { - "buildenv": "trusty-amd64", - "builddeps": ["build-essential"], - "buildcmd": "make -j" - }, - "xenial-i386": { - "buildenv": "xenial-i386", - "builddeps": ["build-essential"], - "buildcmd": "make -j" - }, - "xenial-amd64": { - "buildenv": "xenial-amd64", - "builddeps": ["build-essential"], - "buildcmd": "make -j" - }, - "xenial-armhf": { - "buildenv": "xenial-armhf", - "builddeps": ["build-essential"], - "buildcmd": "make -j" - }, - "xenial-arm64": { - "buildenv": "xenial-arm64", - "builddeps": ["build-essential"], - "buildcmd": "make -j" - }, - "fedora24-x86_64-g++": { - "buildenv": "fedora24-x86_64", - "builddeps": ["cmake", "make", "clang"], - "buildcmd": ["mkdir build", "cd build", "CXX=g++ cmake ..", "make -j", "ctest --output-on-failure"] - }, - "fedora24-x86_64-clang": { - "buildenv": "fedora24-x86_64", - "builddeps": ["cmake", "make", "clang"], - "buildcmd": ["mkdir build", "cd build", "CXX=clang++ cmake ..", "make -j", "ctest --output-on-failure"] - }, - "fedora24-x86_64-g++-debug": { - "buildenv": "fedora24-x86_64", - "builddeps": ["cmake", "make", "clang"], - "buildcmd": ["mkdir build", "cd build", "CXX=g++ cmake -DCMAKE_BUILD_TYPE=Debug ..", "make -j", "ctest --output-on-failure"] - }, - "fedora24-x86_64-clang-debug": { - "buildenv": "fedora24-x86_64", - "builddeps": ["cmake", "make", "clang"], - "buildcmd": ["mkdir build", "cd build", "CXX=clang++ cmake -DCMAKE_BUILD_TYPE=Debug ..", "make -j", "ctest --output-on-failure"] - }, - "fedora24-x86_64-g++-release": { - "buildenv": "fedora24-x86_64", - "builddeps": ["cmake", "make", "clang"], - "buildcmd": ["mkdir build", "cd build", "CXX=g++ cmake -DCMAKE_BUILD_TYPE=Release ..", "make -j", "ctest --output-on-failure"] - }, - "fedora24-x86_64-clang-release": { - "buildenv": "fedora24-x86_64", - "builddeps": ["cmake", "make", "clang"], - "buildcmd": ["mkdir build", "cd build", "CXX=clang++ cmake -DCMAKE_BUILD_TYPE=Release ..", "make -j", "ctest --output-on-failure"] - }, - "osx": { - "buildenv": "osx", - "builddeps": ["build-essential"], - "buildcmd": "make -j" - } - } -} diff --git a/packages/PEGTL/.gitrepo b/packages/PEGTL/.gitrepo index 13c3bc8b3..943a88058 100644 --- a/packages/PEGTL/.gitrepo +++ b/packages/PEGTL/.gitrepo @@ -6,6 +6,7 @@ [subrepo] remote = git@github.com:taocpp/PEGTL.git branch = master - commit = 0a5ab8c8efb421f00d9b0e3f593c971991888a97 - parent = 8a3664d89a9a662c3dfdd402d573b3618ebbdbbf - cmdver = 0.3.1 + commit = 68790bd2c25fceff1049e9fc2fb9528ca4d93bbf + parent = 0fc26ddb5da553e9b9ddff3db48b3d6a1617eb96 + cmdver = 0.4.0 + method = merge diff --git a/packages/PEGTL/.travis.yml b/packages/PEGTL/.travis.yml index f4e899c9c..32500f242 100644 --- a/packages/PEGTL/.travis.yml +++ b/packages/PEGTL/.travis.yml @@ -1,46 +1,9 @@ language: generic os: linux -dist: trusty +dist: xenial matrix: include: - - compiler: gcc - env: - - CXX=g++-4.8 - - - compiler: gcc - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-4.9'] - env: - - CXX=g++-4.9 - - - compiler: gcc - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-5'] - env: - - CXX=g++-5 - - - compiler: gcc - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-5'] - env: - - CXX=g++-5 - - CXXSTD=-std=c++14 - - - compiler: gcc - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-6'] - env: - - CXX=g++-6 - - compiler: gcc addons: apt: @@ -49,23 +12,6 @@ matrix: env: - CXX=g++-7 - - compiler: gcc - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-7'] - env: - - CXX=g++-7 - - CXXSTD=-std=c++17 - - - compiler: gcc - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-8'] - env: - - CXX=g++-8 - - compiler: gcc addons: apt: @@ -73,295 +19,60 @@ matrix: packages: ['g++-8'] env: - CXX=g++-8 - - CXXSTD=-std=c++17 - - - dist: precise - compiler: clang - env: - - CXX=clang++ - - - compiler: clang - addons: - apt: - packages: ['clang-3.5'] - env: - - CXX=clang++-3.5 - - - compiler: clang - addons: - apt: - packages: ['clang-3.6'] - env: - - CXX=clang++-3.6 - - - dist: precise - compiler: clang - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7'] - packages: ['clang-3.7'] - env: - - CXX=clang++-3.7 - - - compiler: clang - addons: - apt: - packages: ['clang-3.8'] - env: - - CXX=clang++-3.8 - compiler: clang addons: apt: - packages: ['clang-3.9'] + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-xenial-5'] + packages: ['clang-5.0', 'g++-7'] env: - - CXX=clang++-3.9 - - - compiler: clang - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-4.0'] - packages: ['clang-4.0'] - env: - - CXX=clang++-4.0 + - CXX=clang++-5.0 - compiler: clang addons: apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-4.0'] - packages: ['clang-4.0'] + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-xenial-6'] + packages: ['clang-6.0', 'g++-7'] env: - - CXX=clang++-4.0 - - CXXSTD=-std=c++14 + - CXX=clang++-6.0 - compiler: clang addons: apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0'] - packages: ['clang-5.0'] + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-xenial-7'] + packages: ['clang-7', 'g++-7'] env: - - CXX=clang++-5.0 + - CXX=clang++-7 - compiler: clang addons: apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-6.0'] - packages: ['clang-6.0'] + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-xenial-8'] + packages: ['clang-8', 'g++-8'] env: - - CXX=clang++-6.0 + - CXX=clang++-8 - compiler: clang addons: apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-6.0'] - packages: ['clang-6.0'] + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-xenial-8'] + packages: ['clang-8', 'g++-8'] env: - - CXX=clang++-6.0 + - CXX=clang++-8 - CPPFLAGS=-fms-extensions - - compiler: clang - addons: - apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-6.0'] - packages: ['clang-6.0'] - env: - - CXX=clang++-6.0 - - CXXSTD=-std=c++17 - - os: osx - osx_image: xcode6.4 - compiler: clang - env: - - CXX=clang++ - - - os: osx - osx_image: xcode7.3 - compiler: clang - env: - - CXX=clang++ - - - os: osx - osx_image: xcode8.3 + osx_image: xcode9.4 compiler: clang env: - CXX=clang++ - os: osx - osx_image: xcode9.4 + osx_image: xcode10.2 compiler: clang env: - CXX=clang++ - - language: android - jdk: openjdk8 - android: - components: - - tools - - platform-tools - - build-tools-23.0.3 - - extra-android-support - - extra-android-m2repository - - android-19 - - sys-img-armeabi-v7a-android-19 - # Unfortunately travis uses the old android sdk tool instead of the new sdkmanager. - # In this deprecated android sdk tool there is no ndk-bundle or cmake package! - licenses: - - '.+' - before_install: - # Install NDK and cmake via android sdkmanager. Unfortunately to acknowledge the licenses - # takes a while. Looks like the "echo y" solution is not working. Needs improvement! - - export TERM=dumb - - touch ~/.android/repositories.cfg - - mkdir -p /usr/local/android-sdk/licenses - - echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > /usr/local/android-sdk/licenses/android-sdk-license - - echo -e "\nd56f5187479451eabf01fb78af6dfcb131a6481e" >> /usr/local/android-sdk/licenses/android-sdk-license - # Install NDK and cmake via android sdkmanager. - - /usr/local/android-sdk/tools/bin/sdkmanager --update > /dev/null - - echo "y" | /usr/local/android-sdk/tools/bin/sdkmanager "emulator" "ndk-bundle" "cmake;3.6.4111459" > /dev/null - before_script: - - export TERM=dumb - - export _NO_CHECK_SIGNATURE=true - - echo no | /usr/local/android-sdk/tools/bin/avdmanager create avd -n test -k "system-images;android-19;default;armeabi-v7a" - - /usr/local/android-sdk/emulator/emulator -avd test -no-audio -no-window -dns-server 8.8.8.8 & - - android-wait-for-emulator || android-wait-for-emulator - - /usr/local/android-sdk/platform-tools/adb shell input keyevent 82 & - script: - # Using the ninja build command. Is much faster then make build command. - - /usr/local/android-sdk/cmake/3.6.4111459/bin/cmake -G'Android Gradle - Ninja' -DANDROID_ABI=armeabi-v7a -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/usr/local/android-sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-19 -DCMAKE_MAKE_PROGRAM=/usr/local/android-sdk/cmake/3.6.4111459/bin/ninja -DPEGTL_BUILD_EXAMPLES=OFF - - /usr/local/android-sdk/cmake/3.6.4111459/bin/cmake --build . --target all - - /usr/local/android-sdk/cmake/3.6.4111459/bin/ctest --output-on-failure - - - - language: android - jdk: openjdk8 - android: - components: - - tools - - platform-tools - - build-tools-23.0.3 - - extra-android-support - - extra-android-m2repository - - android-22 - - sys-img-armeabi-v7a-android-22 - # Unfortunately travis uses the old android sdk tool instead of the new sdkmanager. - # In this deprecated android sdk tool there is no ndk-bundle or cmake package! - licenses: - - '.+' - before_install: - # Install NDK and cmake via android sdkmanager. Unfortunately to acknowledge the licenses - # takes a while. Looks like the "echo y" solution is not working. Needs improvement! - - export TERM=dumb - - touch ~/.android/repositories.cfg - - mkdir -p /usr/local/android-sdk/licenses - - echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > /usr/local/android-sdk/licenses/android-sdk-license - - echo -e "\nd56f5187479451eabf01fb78af6dfcb131a6481e" >> /usr/local/android-sdk/licenses/android-sdk-license - # Install NDK and cmake via android sdkmanager. - - /usr/local/android-sdk/tools/bin/sdkmanager --update > /dev/null - - echo "y" | /usr/local/android-sdk/tools/bin/sdkmanager "emulator" "ndk-bundle" "cmake;3.6.4111459" > /dev/null - before_script: - - export TERM=dumb - - export _NO_CHECK_SIGNATURE=true - - echo no | /usr/local/android-sdk/tools/bin/avdmanager create avd -n test -k "system-images;android-22;default;armeabi-v7a" - - /usr/local/android-sdk/emulator/emulator -avd test -no-audio -no-window -dns-server 8.8.8.8 & - - android-wait-for-emulator || android-wait-for-emulator - - /usr/local/android-sdk/platform-tools/adb shell input keyevent 82 & - script: - # Using the ninja build command. Is much faster then make build command. - - /usr/local/android-sdk/cmake/3.6.4111459/bin/cmake -G'Android Gradle - Ninja' -DANDROID_ABI=armeabi-v7a -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/usr/local/android-sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-22 -DCMAKE_MAKE_PROGRAM=/usr/local/android-sdk/cmake/3.6.4111459/bin/ninja -DPEGTL_BUILD_EXAMPLES=OFF - - /usr/local/android-sdk/cmake/3.6.4111459/bin/cmake --build . --target all - - /usr/local/android-sdk/cmake/3.6.4111459/bin/ctest --output-on-failure - - - language: android - jdk: openjdk8 - android: - components: - - tools - - platform-tools - - build-tools-23.0.3 - - extra-android-support - - extra-android-m2repository - - android-23 - # Unfortunately travis uses the old android sdk tool instead of the new sdkmanager. - # In this deprecated android sdk tool there is no ndk-bundle or cmake package! - licenses: - - '.+' - before_install: - # Install NDK and cmake via android sdkmanager. Unfortunately to acknowledge the licenses - # takes a while. Looks like the "echo y" solution is not working. Needs improvement! - - export TERM=dumb - - touch ~/.android/repositories.cfg - - mkdir -p /usr/local/android-sdk/licenses - - echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > /usr/local/android-sdk/licenses/android-sdk-license - - echo -e "\nd56f5187479451eabf01fb78af6dfcb131a6481e" >> /usr/local/android-sdk/licenses/android-sdk-license - # Install NDK and cmake via android sdkmanager. - - /usr/local/android-sdk/tools/bin/sdkmanager --update > /dev/null - - echo "y" | /usr/local/android-sdk/tools/bin/sdkmanager "emulator" "ndk-bundle" "cmake;3.6.4111459" "system-images;android-23;google_apis;armeabi-v7a" > /dev/null - before_script: - - export TERM=dumb - - export _NO_CHECK_SIGNATURE=true - - echo no | /usr/local/android-sdk/tools/bin/avdmanager create avd -n test -k "system-images;android-23;google_apis;armeabi-v7a" - - /usr/local/android-sdk/emulator/emulator -avd test -no-audio -no-window -dns-server 8.8.8.8 & - - android-wait-for-emulator || android-wait-for-emulator - - /usr/local/android-sdk/platform-tools/adb shell input keyevent 82 & - script: - # Using the ninja build command. Is much faster then make build command. - - /usr/local/android-sdk/cmake/3.6.4111459/bin/cmake -G'Android Gradle - Ninja' -DANDROID_ABI=armeabi-v7a -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/usr/local/android-sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-23 -DCMAKE_MAKE_PROGRAM=/usr/local/android-sdk/cmake/3.6.4111459/bin/ninja -DPEGTL_BUILD_EXAMPLES=OFF - - /usr/local/android-sdk/cmake/3.6.4111459/bin/cmake --build . --target all - - /usr/local/android-sdk/cmake/3.6.4111459/bin/ctest --output-on-failure - - - language: android - jdk: openjdk8 - android: - components: - - tools - - platform-tools - - build-tools-23.0.3 - - extra-android-support - - extra-android-m2repository - - android-24 - - sys-img-armeabi-v7a-android-24 - # Unfortunately travis uses the old android sdk tool instead of the new sdkmanager. - # In this deprecated android sdk tool there is no ndk-bundle or cmake package! - licenses: - - '.+' - before_install: - # Install NDK and cmake via android sdkmanager. Unfortunately to acknowledge the licenses - # takes a while. Looks like the "echo y" solution is not working. Needs improvement! - - export TERM=dumb - - touch ~/.android/repositories.cfg - - mkdir -p /usr/local/android-sdk/licenses - - echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > /usr/local/android-sdk/licenses/android-sdk-license - - echo -e "\nd56f5187479451eabf01fb78af6dfcb131a6481e" >> /usr/local/android-sdk/licenses/android-sdk-license - # Install NDK and cmake via android sdkmanager. - - /usr/local/android-sdk/tools/bin/sdkmanager --update > /dev/null - - echo "y" | /usr/local/android-sdk/tools/bin/sdkmanager "emulator" "ndk-bundle" "cmake;3.6.4111459" > /dev/null - before_script: - - export TERM=dumb - - export _NO_CHECK_SIGNATURE=true - - echo no | /usr/local/android-sdk/tools/bin/avdmanager create avd -n test -k "system-images;android-24;default;armeabi-v7a" - - /usr/local/android-sdk/emulator/emulator -avd test -no-audio -no-window -dns-server 8.8.8.8 & - - android-wait-for-emulator || android-wait-for-emulator - - /usr/local/android-sdk/platform-tools/adb shell input keyevent 82 & - script: - # Using the ninja build command. Is much faster then make build command. - - /usr/local/android-sdk/cmake/3.6.4111459/bin/cmake -G'Android Gradle - Ninja' -DANDROID_ABI=armeabi-v7a -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/usr/local/android-sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-24 -DCMAKE_MAKE_PROGRAM=/usr/local/android-sdk/cmake/3.6.4111459/bin/ninja -DPEGTL_BUILD_EXAMPLES=OFF - - /usr/local/android-sdk/cmake/3.6.4111459/bin/cmake --build . --target all - - /usr/local/android-sdk/cmake/3.6.4111459/bin/ctest --output-on-failure - - - compiler: gcc - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-7'] - env: - - CXX=g++-7 - - CXXFLAGS="-O0 --coverage" - before_script: - - pip install --user cpp-coveralls - script: - - make -kj3 check - - coveralls --gcov gcov-7 --gcov-options '\-lp' --exclude src - - compiler: gcc addons: apt: @@ -384,55 +95,66 @@ matrix: - compiler: clang addons: apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-6.0'] - packages: ['clang-6.0'] + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-xenial-8'] + packages: ['clang-8', 'g++-8'] env: - - CXX=clang++-6.0 + - CXX=clang++-8 - CPPFLAGS=-fsanitize=undefined - compiler: clang sudo: true addons: apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-6.0'] - packages: ['clang-6.0'] + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-xenial-8'] + packages: ['clang-8', 'g++-8'] env: - - CXX=clang++-6.0 + - CXX=clang++-8 - CPPFLAGS=-fsanitize=address - - compiler: gcc + - compiler: clang addons: apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-8', 'valgrind'] + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-xenial-8'] + packages: ['clang-8', 'clang-tidy-8', 'g++-8'] env: - - CXX=g++-8 - - SPECIAL=valgrind + - CXX=clang++-8 + - CLANG_TIDY=clang-tidy-8 script: - - make -kj3 valgrind + - "sed -i 's#namespace TAO_PEGTL_NAMESPACE#namespace tao::pegtl#g' $(find . -name '*.[hc]pp')" + - make -kj3 clang-tidy + + - compiler: clang + addons: + apt: + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-xenial-8'] + packages: ['clang-8', 'clang-tools-8', 'g++-8'] + script: + - scan-build-8 --use-c++=clang++-8 --status-bugs make -kj3 - compiler: gcc addons: apt: sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-8', 'cppcheck'] + packages: ['g++-8', 'valgrind'] env: - CXX=g++-8 - - SPECIAL=cppcheck + - SPECIAL=valgrind script: - - make -kj3 cppcheck + - make -kj3 valgrind - - compiler: clang + - compiler: gcc addons: apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-6.0'] - packages: ['clang-6.0', 'clang-tidy-6.0'] + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-7'] env: - - CXX=clang++-6.0 - - CLANG_TIDY=clang-tidy-6.0 + - CXX=g++-7 + - CXXFLAGS="-O0 --coverage" + before_script: + - pip install --user cpp-coveralls script: - - "sed -i 's#TAO_PEGTL_NAMESPACE#pegtl#g' $(find . -name '*.[hc]pp')" - - make -kj3 clang-tidy + - make -kj3 check + - coveralls --gcov gcov-7 --gcov-options '\-lp' --exclude src - language: python python: diff --git a/packages/PEGTL/CMakeLists.txt b/packages/PEGTL/CMakeLists.txt index c355e7cfb..410ec90d1 100644 --- a/packages/PEGTL/CMakeLists.txt +++ b/packages/PEGTL/CMakeLists.txt @@ -1,69 +1,68 @@ -cmake_minimum_required (VERSION 3.3.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.8.0 FATAL_ERROR) -project (pegtl VERSION 2.7.1 LANGUAGES CXX) +project(pegtl VERSION 3.0.0 LANGUAGES CXX) + +if(${PROJECT_NAME}_FOUND) + # Multiple versions of PEGTL can't co-exist + if(NOT ${PROJECT_NAME}_VERSION STREQUAL ${PROJECT_VERSION}) + message(FATAL_ERROR "Multiple mismatched PEGTL versions") + endif() + + # Only include if this is the first include + if(NOT ${PROJECT_NAME}_DIR STREQUAL "${PROJECT_BINARY_DIR}") + return() + endif() +endif() + +# Keep track of pegtl version +set(${PROJECT_NAME}_FOUND TRUE CACHE BOOL "" FORCE) +set(${PROJECT_NAME}_VERSION "${PROJECT_VERSION}" CACHE STRING "" FORCE) +set(${PROJECT_NAME}_DIR "${PROJECT_BINARY_DIR}" CACHE PATH "" FORCE) + +mark_as_advanced(${PROJECT_NAME}_FOUND) +mark_as_advanced(${PROJECT_NAME}_VERSION) +mark_as_advanced(${PROJECT_NAME}_DIR) # installation directories -set (PEGTL_INSTALL_INCLUDE_DIR "include" CACHE STRING "The installation include directory") -set (PEGTL_INSTALL_DOC_DIR "share/doc/tao/pegtl" CACHE STRING "The installation doc directory") -set (PEGTL_INSTALL_CMAKE_DIR "share/pegtl/cmake" CACHE STRING "The installation cmake directory") +set(PEGTL_INSTALL_INCLUDE_DIR "include" CACHE STRING "The installation include directory") +set(PEGTL_INSTALL_DOC_DIR "share/doc/tao/pegtl" CACHE STRING "The installation doc directory") +set(PEGTL_INSTALL_CMAKE_DIR "share/pegtl/cmake" CACHE STRING "The installation cmake directory") # define a header-only library -add_library (pegtl INTERFACE) -add_library (taocpp::pegtl ALIAS pegtl) -target_include_directories (pegtl INTERFACE +add_library(pegtl INTERFACE) +add_library(taocpp::pegtl ALIAS pegtl) +target_include_directories(pegtl INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${PEGTL_INSTALL_INCLUDE_DIR}> ) -# 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++17 +target_compile_features(pegtl INTERFACE cxx_std_17) # testing -enable_testing () -option (PEGTL_BUILD_TESTS "Build test programs" ON) -if (PEGTL_BUILD_TESTS) - add_subdirectory (src/test/pegtl) -endif () +enable_testing() +option(PEGTL_BUILD_TESTS "Build test programs" ON) +if(PEGTL_BUILD_TESTS) + add_subdirectory(src/test/pegtl) +endif() # examples -option (PEGTL_BUILD_EXAMPLES "Build example programs" ON) -if (PEGTL_BUILD_EXAMPLES) - add_subdirectory (src/example/pegtl) -endif () +option(PEGTL_BUILD_EXAMPLES "Build example programs" ON) +if(PEGTL_BUILD_EXAMPLES) + add_subdirectory(src/example/pegtl) +endif() + +# Make package findable +configure_file(cmake/dummy-config.cmake.in pegtl-config.cmake @ONLY) # install and export target -install (TARGETS pegtl EXPORT pegtl-targets) +install(TARGETS pegtl EXPORT pegtl-targets) -install (EXPORT pegtl-targets +install(EXPORT pegtl-targets FILE pegtl-config.cmake NAMESPACE taocpp:: DESTINATION ${PEGTL_INSTALL_CMAKE_DIR} ) -install (DIRECTORY include/ DESTINATION ${PEGTL_INSTALL_INCLUDE_DIR}) -install (FILES LICENSE DESTINATION ${PEGTL_INSTALL_DOC_DIR}) +install(DIRECTORY include/ DESTINATION ${PEGTL_INSTALL_INCLUDE_DIR}) +install(FILES LICENSE DESTINATION ${PEGTL_INSTALL_DOC_DIR}) diff --git a/packages/PEGTL/LICENSE b/packages/PEGTL/LICENSE index 84bd84ac1..378c177b9 100644 --- a/packages/PEGTL/LICENSE +++ b/packages/PEGTL/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2007-2018 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2007-2019 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 diff --git a/packages/PEGTL/Makefile b/packages/PEGTL/Makefile index edf34b2f0..983c806fa 100644 --- a/packages/PEGTL/Makefile +++ b/packages/PEGTL/Makefile @@ -1,5 +1,5 @@ # The Art of C++ -# Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +# Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey # Please see LICENSE for license or visit https://github.com/taocpp/PEGTL .SUFFIXES: @@ -16,11 +16,11 @@ endif # For Darwin (Mac OS X / macOS) we assume that the default compiler # clang++ is used; when $(CXX) is some version of g++, then -# $(CXXSTD) has to be set to -std=c++11 (or newer) so +# $(CXXSTD) has to be set to -std=c++17 (or newer) so # that -stdlib=libc++ is not automatically added. ifeq ($(CXXSTD),) -CXXSTD := -std=c++11 +CXXSTD := -std=c++17 ifeq ($(UNAME_S),Darwin) CXXSTD += -stdlib=libc++ endif @@ -34,11 +34,13 @@ CXXFLAGS ?= -Wall -Wextra -Wshadow -Werror -O3 $(MINGW_CXXFLAGS) CLANG_TIDY ?= clang-tidy -HEADERS := $(filter-out include/tao/pegtl/internal/endian_win.hpp include/tao/pegtl/internal/file_mapper_win32.hpp,$(shell find include -name '*.hpp')) $(filter-out src/test/pegtl/main.hpp,$(shell find src -name '*.hpp')) +HEADERS := $(shell find include -name '*.hpp') SOURCES := $(shell find src -name '*.cpp') DEPENDS := $(SOURCES:%.cpp=build/%.d) BINARIES := $(SOURCES:%.cpp=build/%) +CLANG_TIDY_HEADERS := $(filter-out include/tao/pegtl/internal/endian_win.hpp include/tao/pegtl/internal/file_mapper_win32.hpp,$(HEADER)) $(filter-out src/test/pegtl/main.hpp,$(shell find src -name '*.hpp')) + UNIT_TESTS := $(filter build/src/test/%,$(BINARIES)) .PHONY: all @@ -59,23 +61,14 @@ build/%.valgrind: build/% valgrind: $(UNIT_TESTS:%=%.valgrind) @echo "All $(words $(UNIT_TESTS)) valgrind tests passed." -build/%.cppcheck: %.hpp - cppcheck --error-exitcode=1 --inconclusive --force --std=c++11 $< - @mkdir -p $(@D) - @touch $@ - -.PHONY: cppcheck -cppcheck: $(HEADERS:%.hpp=build/%.cppcheck) - @echo "All $(words $(HEADERS)) cppcheck tests passed." - build/%.clang-tidy: % - $(CLANG_TIDY) -extra-arg "-Iinclude" -extra-arg "-std=c++11" -checks=*,-fuchsia-*,-google-runtime-references,-google-runtime-int,-google-readability-todo,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-hicpp-no-array-decay,-hicpp-signed-bitwise,-modernize-raw-string-literal,-misc-sizeof-expression -warnings-as-errors=* $< 2>/dev/null + $(CLANG_TIDY) -extra-arg "-Iinclude" -extra-arg "-std=c++17" -checks=*,-fuchsia-*,-google-runtime-references,-google-runtime-int,-google-readability-todo,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-*-magic-numbers,-cppcoreguidelines-non-private-member-variables-in-classes,-cppcoreguidelines-macro-usage,-hicpp-no-array-decay,-hicpp-signed-bitwise,-modernize-raw-string-literal,-misc-sizeof-expression,-misc-non-private-member-variables-in-classes,-bugprone-sizeof-expression,-bugprone-exception-escape -warnings-as-errors=* $< 2>/dev/null @mkdir -p $(@D) @touch $@ .PHONY: clang-tidy -clang-tidy: $(HEADERS:%=build/%.clang-tidy) $(SOURCES:%=build/%.clang-tidy) - @echo "All $(words $(HEADERS) $(SOURCES)) clang-tidy tests passed." +clang-tidy: $(CLANG_TIDY_HEADERS:%=build/%.clang-tidy) $(SOURCES:%=build/%.clang-tidy) + @echo "All $(words $(CLANG_TIDY_HEADERS) $(SOURCES)) clang-tidy tests passed." .PHONY: clean clean: @@ -89,6 +82,32 @@ build/%.d: %.cpp Makefile build/%: %.cpp build/%.d $(CXX) $(CXXSTD) -Iinclude $(CPPFLAGS) $(CXXFLAGS) $< -o $@ +.PHONY: amalgamate +amalgamate: build/amalgamated/pegtl.hpp + +build/amalgamated/pegtl.hpp: $(HEADERS) + @mkdir -p $(@D) + @rm -rf build/include + @cp -a include build/ + @rm -rf build/include/tao/pegtl/contrib/icu + @sed -i -e 's%^#%//#%g' $$(find build/include -name '*.hpp') + @sed -i -e 's%^//#include "%#include "%g' $$(find build/include -name '*.hpp') + @for i in $$(find build/include -name '*.hpp'); do echo "#pragma once" >tmp.out; echo "#line 1" >>tmp.out; cat $$i >>tmp.out; mv tmp.out $$i; done + @echo '#include "tao/pegtl.hpp"' >build/include/amalgamated.hpp + @echo '#include "tao/pegtl/analyze.hpp"' >>build/include/amalgamated.hpp + @( cd build/include ; for i in tao/pegtl/contrib/*.hpp; do echo "#include \"$$i\""; done ) >>build/include/amalgamated.hpp + @echo -e "/*\n\nWelcome to the Parsing Expression Grammar Template Library (PEGTL)." >$@ + @echo -e "See https://github.com/taocpp/PEGTL/ for more information, documentation, etc.\n" >>$@ + @echo -e "The library is licensed as follows:\n" >>$@ + @cat LICENSE >>$@ + @echo -e "\n*/\n" >>$@ + @( cd build/include ; g++ -E -C -nostdinc amalgamated.hpp ) >>$@ + @sed -i -e 's%^//#%#%g' $@ + @sed -i -e 's%^# \([0-9]* "[^"]*"\).*%#line \1%g' $@ + @sed -i -e 's%^// Copyright.*%%g' $@ + @sed -i -e 's%^// Please.*%%g' $@ + @echo "Generated/updated $@ successfully." + ifeq ($(findstring $(MAKECMDGOALS),clean),) -include $(DEPENDS) endif diff --git a/packages/PEGTL/README.md b/packages/PEGTL/README.md index 150ea9e90..d9798a226 100644 --- a/packages/PEGTL/README.md +++ b/packages/PEGTL/README.md @@ -4,15 +4,16 @@ [](https://bintray.com/taocpp/public-conan/pegtl%3Ataocpp/_latestVersion) [](https://travis-ci.org/taocpp/PEGTL) [](https://ci.appveyor.com/project/taocpp/PEGTL) -[](https://doozer.io/user/taocpp/PEGTL) [](https://coveralls.io/github/taocpp/PEGTL) +[](https://lgtm.com/projects/g/taocpp/PEGTL/context:cpp) -The Parsing Expression Grammar Template Library (PEGTL) is a zero-dependency C++11 header-only parser combinator library for creating parsers according to a [Parsing Expression Grammar](http://en.wikipedia.org/wiki/Parsing_expression_grammar) (PEG). +The Parsing Expression Grammar Template Library (PEGTL) is a zero-dependency C++ header-only parser combinator library for creating parsers according to a [Parsing Expression Grammar](http://en.wikipedia.org/wiki/Parsing_expression_grammar) (PEG). ## Documentation -* [Version 2.x Documentation](doc/README.md) -* [Version 1.3 Documentation](https://github.com/taocpp/PEGTL/blob/1.3.x/doc/README.md) +* [Version 3.x](doc/README.md) (requires C++17) +* [Version 2.x](https://github.com/taocpp/PEGTL/blob/2.x/doc/README.md) (requires C++11) +* [Version 1.x](https://github.com/taocpp/PEGTL/blob/1.x/doc/README.md) (requires C++11) ## Introduction @@ -25,13 +26,15 @@ Here is an example of how a PEG grammar rule is implemented as C++ class with th // PEG rule for integers consisting of a non-empty // sequence of digits with an optional sign: -// integer ::= ( '+' / '-' )? digit+ +// sign ::= '+' / '-' +// integer ::= sign? digit+ // The same parsing rule implemented with the PEGTL: using namespace tao::pegtl; -struct integer : seq< opt< one< '+', '-' > >, plus< digit > > {}; +struct sign : one< '+', '-' > {}; +struct integer : seq< opt< sign >, plus< digit > > {}; ``` PEGs are superficially similar to Context-Free Grammars (CFGs), however the more deterministic nature of PEGs gives rise to some very important differences. @@ -57,74 +60,38 @@ Each commit is automatically tested with multiple architectures, operating syste * Windows - * Visual Studio 2015 (x86, x64) * Visual Studio 2017 (x86, x64) - * MinGW (i686), GCC 5.x - * MinGW-w64 (i686), GCC 5.x, 6.x - * MinGW-w64 (x86_64), GCC 6.x -* Mac OS X / macOS (using libc++) +* macOS (using libc++) - * Mac OS X 10.10, Xcode 6.4 - * Mac OS X 10.11, Xcode 7.3 - * macOS 10.12, Xcode 8.3 * macOS 10.13, Xcode 9.4 + * macOS 10.14, Xcode 10.2 -* Linux (using libstdc++) +* Ubuntu 16.04 LTS (using libstdc++) - * Debian 8 (i386), GCC 4.9 - * Ubuntu 12.04 LTS (amd64), Clang 3.4, 3.7 - * Ubuntu 14.04 LTS (amd64), GCC 4.8, 4.9, 5.x, 6.x, 7.x, 8.x - * Ubuntu 14.04 LTS (amd64), Clang 3.5, 3.6, 3.8, 3.9, 4.x, 5.x, 6.x - * Ubuntu 14.04 LTS (i386, amd64), GCC 4.8 - * Ubuntu 16.04 LTS (i386, amd64, armhf, arm64), GCC 5.x - * Fedora 24 (x86_64), GCC 6.x - * Fedora 24 (x86_64), Clang 3.8 + * GCC 7.x, 8.x + * Clang 5.x, 6.x, 7.x, 8.x -* Android - - * Android 4.4 "KitKat" (API level 19) - * Android 5.1 "Lollipop" (API level 22) - * Android 6.0 "Marshmellow" (API level 23) - * Android 7.0 "Nougat" (API level 24) - -Additionally, each commit is checked with GCC's and Clang's sanitizers, as well as [`valgrind`](http://valgrind.org/) -and [`clang-tidy`](http://clang.llvm.org/extra/clang-tidy/). Code coverage is automatically measured and the unit tests -cover 100% of the core library code (for releases). +Additionally, each commit is checked with Clang's [Static Analyzer](https://clang-analyzer.llvm.org/), GCC's and Clang's [sanitizers](https://github.com/google/sanitizers), [`clang-tidy`](http://clang.llvm.org/extra/clang-tidy/), and [`valgrind`](http://valgrind.org/). +Code coverage is automatically measured and the unit tests cover 100% of the core library code (for releases). [Releases](https://github.com/taocpp/PEGTL/releases) are done in accordance with [Semantic Versioning](http://semver.org/). Incompatible API changes are *only* allowed to occur between major versions. For details see the [changelog](doc/Changelog.md). -## Thank You - -* Christopher Diggins and the YARD parser for the general idea. -* George Makrydakis for the [inspiration](https://github.com/irrequietus/typestring) to `TAO_PEGTL_STRING`. -* Johannes Overmann for his invaluable [`streplace`](https://code.google.com/p/streplace/) command-line tool. -* Jörg-Christian Böhme for improving the Android CI build. -* Kai Wolf for help with CMake. -* Kenneth Geisshirt for Android compatibility and Android CI. -* Kuzma Shapran for EOL testing and fixes. -* Michael Becker for help with CMake. -* Paul Le Roux for CMake improvements and Conan support. -* Paulo Custodio for Windows-related fixes. -* Sam Hocevar for contributing Visual Studio 2015 compatibility. -* Stephan Beal for the bug reports, suggestions and discussions. -* Stuart Dootson for `mmap_input<>` support on Windows. -* Sven Johannsen for help with CMake. -* Zhihao Yuan for fixing several warnings when compiling with Visual Studio 2015. - ## Contact The PEGTL is part of [The Art of C++](https://taocpp.github.io/). -For questions and suggestions regarding the PEGTL, success or failure stories, and any other kind of feedback, please feel free to contact the authors at `taocpp(at)icemx.net`. +We [are grateful](doc/Thank-You.md) for all support and contributions. + +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`. ## License The PEGTL is certified [Open Source](http://www.opensource.org/docs/definition.html) software. It may be used for any purpose, including commercial purposes, at absolutely no cost. It is distributed under the terms of the [MIT license](http://www.opensource.org/licenses/mit-license.html) reproduced here. -> Copyright (c) 2007-2018 Dr. Colin Hirsch and Daniel Frey +> Copyright (c) 2007-2019 Dr. Colin Hirsch and Daniel Frey > > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: > diff --git a/packages/PEGTL/cmake/dummy-config.cmake.in b/packages/PEGTL/cmake/dummy-config.cmake.in new file mode 100644 index 000000000..3374d615f --- /dev/null +++ b/packages/PEGTL/cmake/dummy-config.cmake.in @@ -0,0 +1,5 @@ +# Dummy config file +# When a dependency is added with add_subdirectory, but searched with find_package + +# Redirect to the directory added with add_subdirectory +add_subdirectory(@PROJECT_SOURCE_DIR@ @PROJECT_BINARY_DIR@) diff --git a/packages/PEGTL/conanfile.py b/packages/PEGTL/conanfile.py index 78036adca..39ae05aa1 100644 --- a/packages/PEGTL/conanfile.py +++ b/packages/PEGTL/conanfile.py @@ -4,13 +4,15 @@ from conans import ConanFile, CMake class PEGTLConan(ConanFile): name = "pegtl" - description = "C++11 header-only parser combinator library for creating PEG parsers" + description = "C++ header-only parser combinator library for creating PEG parsers" homepage = "https://github.com/taocpp/PEGTL" + topics = ("conan", "taocpp", "pegtl", "peg", "grammar", "parsing") url = homepage 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 diff --git a/packages/PEGTL/doc/Actions-and-States.md b/packages/PEGTL/doc/Actions-and-States.md index 0b1149297..0f65e5593 100644 --- a/packages/PEGTL/doc/Actions-and-States.md +++ b/packages/PEGTL/doc/Actions-and-States.md @@ -1,119 +1,169 @@ # Actions and States -Parsing, i.e. matching an input with a grammar rule, by itself only indicates whether (a portion of) the input is valid according to the grammar. -In order to do something useful with the input, it is usually necessary to attach user-defined *actions* to one or more rules. -An action is *applied* whenever the rule to which it is attached succeeds. -Applying an action means that its static `apply()` or `apply0()`-method is called. -The first argument to an `apply()` method is always an object that represents the portion of the input consumed by the successful match of the rule. -An action's `apply()` or `apply0()`-method can either return `void`, or a `bool`. +In its most simple form, a parsing run only returns whether (a portion of) the input matches the grammar. +To actually do something useful during a parsing run it is necessary to attach (user-defined) *actions* to one or more grammar rules. + +Actions are essentially functions that are called during the parsing run whenever the rule they are attached to successfully matched. +When an action is *applied*, the corresponding function receives the *states*, an arbitrary list of (user-defined) objects, as arguments. ## Contents -* [Actions](#actions) - * [Apply0](#apply0) - * [Apply](#apply) +* [Overview](#overview) +* [Example](#example) * [States](#states) -* [Action Specialisation](#action-specialisation) +* [Apply](#apply) +* [Apply0](#apply0) +* [Inheriting](#inheriting) +* [Specialising](#specialising) * [Changing Actions](#changing-actions) + * [Via Rules](#via-rules) + * [Via Actions](#via-actions) * [Changing States](#changing-states) - * [No Switching](#no-switching) - * [Intrusive Switching](#intrusive-switching) - * [External Switching](#external-switching) + * [Via Rules](#via-rules-1) + * [Via Actions](#via-actions-1) +* [Changing Actions and States](#changing-actions-and-states) +* [Match](#match) +* [Nothing](#nothing) +* [Troubleshooting](#troubleshooting) + * [Boolean Return](#boolean-return) + * [State Mismatch](#state-mismatch) * [Legacy Actions](#legacy-actions) -## Actions +## Overview + +Actions are implemented as static member functions called `apply()` or `apply0()` of specialisations of custom class templates (which is not quite as difficult as it sounds). + +States are additional function arguments to `tao::pegtl::parse()` that are forwarded to all actions. + +To use actions during a parsing run they first need to be implemented. + +* Define a custom action class template. +* Specialise the action class template for every rule for which a function is to be called and + * either implement an `apply()` or `apply0()` static member function, + * or derive from a class that implements the desired function. -Actions are implemented as static `apply()` or `apply0()`-method of specialisations of custom class templates (which is not quite as difficult as it sounds). -First the default- or base-case of the action class template has to be defined: +The very first step, defining a custom action class template, usually looks like this. ```c++ template< typename Rule > -struct my_actions +struct my_action : tao::pegtl::nothing< Rule > {}; ``` -Inheriting from `tao::pegtl::nothing< Rule >` indicates to the PEGTL that no action is attached to `Rule`, i.e. that no `apply()` or `apply0()`-method should be called for successful matches of `Rule`. +Instantiations of the primary template for `my_action< Rule >` inherit from `tao::pegtl::nothing< Rule >` to indicate that, by default, neither `my_action< Rule >::apply()` nor `my_action< Rule >::apply0()` are to be called when `Rule` is successfully matched during a parsing run, or, in short, that no action is to be applied to `Rule`. -To attach an action to `Rule`, this class template has to be specialised for `Rule` with two important properties. +You then specialise the action class template for those rules that you *do* want to call an action on. +An example for a simple action for a specific state might look like this. -1. The specialisation *must not* inherit from `tao::pegtl::nothing< Rule >`. +```c++ +template<> +struct my_action< my_rule > +{ + template< typename Input > + static void apply( const Input& in, my_state& s ) + { + // ... implement + } +}; +``` -2. An *appropriate* static `apply()` or `apply0()`-method has to be implemented. +Then the parsing run needs to be set up with the actions and any required states. +For this, the initial action can be passed as the second template parameter and the initial states can be passed as additional arguments to `tao::pegtl::parse()`. -The PEGTL will auto-detect whether an action, i.e. a specialisation of an action class template, contains an appropriate `apply()` or `apply0()` function, and whether it returns `void` or `bool`. -It will fail to compile when both `apply()` and `apply0()` are found. +In order to manage the complexity in larger parsers and/or compose multiple grammars that each bring their own actions which in turn expect certain states, it can be useful to [change the actions](#changing-actions) and/or [change the states](#changing-states) within a parsing run. -### Apply0 +## Example -In cases where the matched part of the input is not required, an action method named `apply0()` is implemented. -This allows for some optimisations compared to the `apply()` method which receives the matched input as first argument. +Here is a very short example that shows the basic way to put together a parsing run with actions and states. ```c++ +// Define a simple grammar consisting of a single rule. +struct my_grammar + : tao::pegtl::star< tao::pegtl::any > {}; + +// Primary action class template. +template< typename Rule > +struct my_action + : tao::pegtl::nothing< Rule > {}; + +// Specialise the action class template. template<> -struct my_actions< tao::pegtl::plus< tao::pegtl::alpha > > +struct my_action< tao::pegtl::any > { - static void apply0( /* all the states */ ) + // Implement an apply() function that will be called by + // the PEGTL every time tao::pegtl::any matches during + // the parsing run. + template< typename Input > + static void apply( const Input& in, std::string& out ) { - // Called whenever a call to tao::pegtl::plus< tao::pegtl::alpha > - // in the grammar succeeds. + // Get the portion of the original input that the + // rule matched this time as string and append it + // to the result string. + out += in.string(); } +}; - // OR ALTERNATIVELY +template< typename Input > +std::string as_string( Input& in ) +{ + // Set up the states, here a single std::string as that is + // what our action requires as additional function argument. + std::string out; - static bool apply0( /* all the states */ ) - { - // Called whenever a call to tao::pegtl::plus< tao::pegtl::alpha > - // in the grammar succeeds. - return // see below - } + // Start the parsing run with our grammar, action and state. + tao::pegtl::parse< my_grammar, my_action >( in, out ); + + // Do something with the result. + return out; } ``` -When the return type is `bool`, the action can determine whether matching the rule to which it was attached, and which already returned with success, should be retro-actively considered a (local) failure. -For the overall parsing run, there is no difference between a rule or an attached action returning `false` (but of course the action is not called when the rule already returned `false`). -When an action returns `false`, the PEGTL takes care of rewinding the input to where it was when the rule to which the action was attached started its (successful) match (which is unlike rules' `match()` methods that have to take care of rewinding themselves). +All together the `as_string()` function is a convoluted way of turning an [input](Inputs-and-Parsing.md) into a `std::string` byte-by-byte. -Note that actions returning `bool` are an advanced use case that should be used with caution. -They prevent some internal optimisations, in particular when used with `apply0()`. -They can also have weird effects on the semantics of a parsing run, for example `at< rule >` can succeed for the same input for which `rule` fails when there is a `bool`-action attached to `rule` that returns `false` (remembering that actions are disabled within an `at<>` combinator). +In the following we will take a more in-depth look at states and `apply()` and `apply0()` before diving into more advanced subjects. -### Apply +## States -When the action method is called `apply()`, it receives a const-reference to an instance of an input class as first argument. +There is not much more to say about the states other than what has already been mentioned, namely that they are a list (colloquial list, not `std::list`) of objects that are + +* passed by the user as additional arguments to [`tao::pegtl::parse()`](Inputs-and-Parsing.md#parse-function), and then + +* passed by the PEGTL as additional arguments to all actions' `apply()` or `apply0()` static member functions. + +The additional arguments to `apply()` and `apply0()` can be chosen freely, however all actions must accept the same list of states since they are all called with the same arguments by default. + +States are not forwarded with "perfect forwarding" since r-value references don't make much sense when they will be used as action arguments many times. +The `parse()` function still uses universal references to bind to the state arguments in order to allow temporary objects. + +## Apply + +As seen above, the actual functions that are called when an action is applied are static member functions named `apply()` of the specialisations of the action class template. ```c++ template<> -struct my_actions< tao::pegtl::plus< tao::pegtl::digit > > +struct my_action< my_rule > { template< typename Input > static void apply( const Input& in, /* all the states */ ) { - // Called whenever a call to tao::pegtl::plus< tao::pegtl::digit > - // in the grammar succeeds. The argument named 'in' represents the - // matched part of the input. - } - - // OR ALTERNATIVELY - - template< typename Input > - static bool apply( const Input& in, /* all the states */ ) - { - // Called whenever a call to tao::pegtl::plus< tao::pegtl::digit > - // in the grammar succeeds. The argument named 'in' represents the - // matched part of the input. - return // see description for apply0() above + // Called whenever matching my_rule during a parsing run + // succeeds (and actions are not disabled). The argument + // named 'in' represents the matched part of the input. + // Can also return bool instead of void. } } ``` -The exact type of the input class passed to an action's `apply()`-method is not specified. -It is currently best practice to "template over" the type of the input as shown above. +The first argument is not the input used in the parsing run, but rather a separate object of distinct type that represents the portion of the input that the rule to which the action is attached just matched. The remaining arguments to `apply()` are the current state arguments. -Actions can then assume that the input provides (at least) the following members. -The `Input` template parameter is set to the class of the input used at the point in the parsing run where the action is applied. +The exact type of the input class passed to `apply()` is not specified. +It is best practice to "template over" the type of the input as shown above. + +Actions can then assume that the input provides (at least) the following interface. +The `Input` template parameter is set to the class of the input used as input in the parsing run at the point where the action is applied. For illustrative purposes, we will assume that the input passed to `apply()` is of type `action_input`. -Any resemblance to real classes is not a coincidence. +Any resemblance to real classes is not a coincidence, see `include/tao/pegtl/internal/action_input.hpp`. ```c++ template< typename Input > @@ -129,163 +179,363 @@ public: const char* begin() const noexcept; // Non-owning pointer! const char* end() const noexcept; // Non-owning pointer! - std::string string() const; // { return std::string( begin(), end() ); } - - char peek_char( const std::size_t offset = 0 ) const noexcept; // { return begin()[ offset ]; } - unsigned char peek_byte( const std::size_t offset = 0 ) const noexcept; // As above with cast. + std::string string() const; // std::string( begin(), end() ) + std::string_view string_view() const noexcept; // std::string_view( begin(), size() ) - pegtl::position position() const noexcept; // Not efficient with LAZY inputs. + char peek_char( const std::size_t offset = 0 ) const noexcept; // begin()[ offset ] + std::uint8_t peek_uint8( const std::size_t offset = 0 ) const noexcept; // similar - const Input& input() const noexcept; // The input from the parsing run. + pegtl::position position() const noexcept; // Not efficient with tracking_mode::lazy. + const Input& input() const noexcept; const iterator_t& iterator() const noexcept; }; ``` -Note that the `action_input` does **not** own the data it points to, it belongs to the original input used in the parsing run. Therefore **the validity of the pointed-to data might not extend (much) beyond the call to the `apply()`-method**! +Note that `input()` returns the input from the parsing run which will be at the position after what has just been parsed, i.e. for an action input `ai` the assertion `ai.end() == ai.input().current()` will always hold true. +Conversely `iterator()` returns a pointer or iterator to the beginning of the action input's data, i.e. where the successful match attempt to the rule the action called with the action input is attached to started. -When the original input has tracking mode `IMMEDIATE`, the `iterator_t` returned by `action_input::iterator()` will contain the `byte`, `line` and `byte_in_line` counters corresponding to the beginning of the matched input represented by the `action_input`. +More importantly the `action_input` does **not** own the data it points to, it belongs to the original input used in the parsing run. +Therefore **the validity of the pointed-to data might not extend (much) beyond the call to `apply()`**! -When the original input has tracking mode `LAZY`, then `action_input::position()` is not efficient because it calculates the line number etc. by scanning the complete original input from the beginning. +When the original input has tracking mode `eager`, the `iterator_t` returned by `action_input::iterator()` will contain the `byte`, `line` and `byte_in_line` counters corresponding to the beginning of the matched input represented by the `action_input`. + +When the original input has tracking mode `lazy`, then `action_input::position()` is not efficient because it calculates the line number etc. by scanning the complete original input from the beginning Actions often need to store and/or reference portions of the input for after the parsing run, for example when an abstract syntax tree is generated. Some of the syntax tree nodes will contain portions of the input, for example for a variable name in a script language that needs to be stored in the syntax tree just as it occurs in the input data. -The **default safe choice** is to copy the matched portions of the input data that are passed to an action by storing a deep copy of the data as `std::string`, as obtained by the input class' `string()` method, in the data structures built while parsing. - -## States - -In most applications, the actions also need some kind of data or user-defined (parser/action) *state* to operate on. -Since the `apply()` and `apply0()`-methods are `static`, they do not have an instance of the class of which they are a member function available for this purpose. -Therefore the *state(s)* are an arbitrary collection of objects that are +The **default safe choice** is to copy the matched portions of the input data that are passed to an action by storing a deep copy of the data as `std::string`, as obtained by the input class' `string()` member function, in the data structures built while parsing. -* passed by the user as additional arguments to the [`parse()`-function](Inputs-and-Parsing.md#parse-function) that starts a parsing run, and then +When the return type of an action, i.e. its `apply()`, is `bool`, it can retro-actively let the library consider the attempt to match the rule to which the action is attached a (local) failure. +For the overall parsing run, there is no difference between a rule returning `false` and an attached action returning `false`, however the action is only called when the rule returned `true`. +When an action returns `false`, the library rewinds the input to where it was when the rule to which the action was attached started its successful match. +This is unlike `match()` static member functions that have to rewind the input themselves. -* passed by the PEGTL as additional arguments to all actions' `apply()` or `apply0()`-method. +## Apply0 -In other words, the additional arguments to the `apply()` and `apply0()`-method can be chosen freely, however **all** actions **must** accept the same argument list since they are **all** called with the same arguments. - -For example, in a practical grammar the example from above might use a second argument to store the parsed sequence of digits somewhere. +In cases where the matched part of the input is not required, an action can implement a static member function called `apply0()` instead of `apply()`. +What changes is that `apply0()` will be called without an input as first argument, i.e. only with all the states. ```c++ -template<> struct my_actions< tao::pegtl::plus< tao::pegtl::digit > > +template<> +struct my_action< my_rule > { - template< typename Input > - static void apply( const Input& in, - std::vector< std::string >& digit_strings ) + static void apply0( /* all the states */ ) { - digit_strings.push_back( in.string() ); + // Called whenever matching my_rule during a parsing run + // succeeds (and actions are not disabled). Can also return + // bool instead of void. } -} +}; ``` -If we then assume that our grammar `my_grammar` contains the rule `tao::pegtl::plus< tao::pegtl::digit >` somewhere, we can use +Using `apply0()` is never necessary, it is "only" an optimisation with minor benefits at compile time, and potentially more noteworthy benefits at run time. +We recommend implementing `apply0()` over `apply()` whenever both are viable. + +Though an infrequently used feature, `apply0()` can also return `bool` instead of `void`, just like `apply()` and with the same implications. + +## Inheriting + +We will use an example to show how to use existing actions via inheritance. +The grammar for this example consists of a couple of simple rules. ```c++ -const std::string parsed_data = ...; -std::vector< std::string > digit_strings; +struct plain + : tao::pegtl::utf8::range< 0x20, 0x10FFFF > {}; -tao::pegtl::memory_input<> in( parsed_data, "data-source-name" ); -tao::pegtl::parse< my_grammar, my_actions >( in, digit_strings ); +struct escaped + : tao::pegtl::one< '\'', '"', '?', '\\', 'a', 'b', 'f', 'n', 'r', 't', 'v' > {}; + +struct character + : tao::pegtl::if_must_else< tao::pegtl::one< '\\' >, escaped, plain > {}; + +struct text + : tao::pegtl::must< tao::pegtl::star< character >, tao::pegtl::eof > {}; ``` -to collect all `digit_strings` that were detected by the grammar, i.e. the vector will contain one string for every time that the `tao::pegtl::plus< tao::pegtl::digit >` rule was matched against the input. +Our goal is for a parsing run with the `text` rule to produce a copy of the input where the backslash escape sequences are replaced by the character they represent. +When the `plain` rule matches, the bytes of the matched UTF-8-encoded code-point can be appended to the result. +When the `escaped` rule matches, the bytes corresponding to the character represented by the escape sequence must be appended to the result. +This can be achieved with appropriate specialisations of `my_action` using some [contrib](Contrib-and-Examples.md#contrib) classes from `tao/pegtl/contrib/unescape.hpp`. -Since the `parse()`-functions are variadic function templates, an arbitrary sequence of state arguments can be used. +```c++ +template<> +struct my_action< plain > + : tao::pegtl::append_all {}; -## Action Specialisation +template<> +struct my_action< escaped > + : tao::pegtl::unescape_c< escaped, '\'', '"', '?', '\\', '\a', '\b', '\f', '\n', '\r', '\t', '\v' > {}; +``` -The rule class for which the action class template is specialised *must* exactly match how the rule is defined and referenced in the grammar. -For example given the rule +For step three the [input for the parsing run](Inputs-and-Parsing.md) is set up as usual. +In addition, the actions are passed as second template parameter, and a `std::string` as second argument to `parse()`. +Here `unescaped` is the state that is required by the `append_all` and `unescape_c` actions; all additional arguments passed to `parse()` are forwarded to all actions. ```c++ -struct foo : tao::pegtl::plus< tao::pegtl::one< '*' > > {}; +std::string unescape( const std::string& escaped ) +{ + std::string unescaped; + tao::pegtl::memory_input in( result, __FUNCTION__ ); + tao::pegtl::parse< text, my_action >( in, unescaped ); + return unescaped; +} ``` -an action class template can be specialised for `foo` or for `tao::pegtl::one< '*' >`, but *not* for `tao::pegtl::plus< tao::pegtl::one< '*' > >` because that is not the rule class name whose `match()`-method is called. +At the end of the parsing run, the complete unescaped string can be found in the aptly named variable `unescaped`. -(The method is called on class `foo`, which happens to inherit `match()` from `tao::pegtl::plus< tao::pegtl::one< '*' > >`, however base classes are not taken into consideration by the C++ language when choosing a specialisation.) +A more complete example of how to unescape strings can be found in `src/examples/pegtl/unescape.cpp`. -While it is possible to specialize for `tao::pegtl::one< '*' >` in the above rule, any such specialization would also match any other occurrence in the grammar. It is therefore best practice to *always* specialize for explicitly named top-level rules. +## Specialising -To then use these actions in a parsing run, simply pass them as additional template parameter to one of the parser functions defined in `<tao/pegtl/parse.hpp>`. +The rule class for which an action class template is specialised *must* exactly match the definition of the rule in the grammar. +For example consider the following rule. ```c++ -tao::pegtl::parse< my_grammar, my_actions >( ... ); +struct foo + : tao::pegtl::plus< tao::pegtl::alpha > {}; ``` -## Changing Actions +Now an action class template can be specialised for `foo`, or for `tao::pegtl::alpha`, but *not* for `tao::pegtl::plus< tao::pegtl::alpha >`. -Within a grammar, the action class template can be changed, enabled or disabled using the `action<>`, `enable<>` and `disable<>` rules. +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. -The following two lines effectively do the same thing, namely parse with `my_grammar` as top-level parsing rule without invoking actions (unless actions are enabled again somewhere within the grammar). +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 >`. + +While it is possible to specialise the action class template for `tao::pegtl::alpha`, it might not be a good idea since the action would be applied for *all* occurrences of `tao::pegtl::alpha` in the grammar. +To circumvent this issue a new name can be given to the `tao::pegtl::alpha`, a name that will not be "randomly" used in other places of the grammar. ```c++ -tao::pegtl::parse< my_grammar >( ... ); -tao::pegtl::parse< tao::pegtl::disable< my_grammar >, my_actions >( ... ); +struct bar + : tao::pegtl::alpha {}; + +struct foo + : tao::pegtl::plus< bar > {}; ``` -Similarly the following two lines both start parsing `my_grammar` with `my_actions` (again with the caveat that something might change somewhere in the grammar). +Now an action class template can be specialised for `foo` and `bar`, but again *not* for `tao::pegtl::plus< bar >` or `tao::pegtl::alpha`. + +More precisely, it could be specialised for the latter two rules, but wouldn't ever be called unless these rules were used elsewhere in the grammar, a different kettle of fish. + +Note that this is also the reason why you should **not** use type aliases instead of inheritance when defining your grammars. + +## Changing Actions + +The action class template can be changed, and actions enabled or disabled, in ways beyond supplying, or not, an action to `tao::pegtl::parse()` at the start of a parsing run. + +### Via Rules + +The [`tao::pegtl::enable<>`](Rule-Reference.md#enable-r-) and [`tao::pegtl::disable<>`](Rule-Reference.md#disable-r-) rules behave just like [`seq<>`](Rule-Reference.md#seq-r-) but, without touching the current action, enable or disable calling of actions within their sub-rules, respectively. + +The [`tao::pegtl::action<>`](Rule-Reference.md#action-a-r-) rule also behaves similarly to [`seq<>`](Rule-Reference.md#seq-r-) but takes an action class template as first template parameter and, without enabling or disabling actions, uses its first template parameter as action for the sub-rules. + +The following two lines effectively do the same thing, namely parse with `my_grammar` as top-level parsing rule without invoking actions (unless actions are enabled again somewhere else). ```c++ -tao::pegtl::parse< my_grammar, my_actions >( ... ); -tao::pegtl::parse< tao::pegtl::action< my_actions, my_grammar > >( ... ); +tao::pegtl::parse< my_grammar >( ... ); +tao::pegtl::parse< tao::pegtl::disable< my_grammar >, my_action >( ... ); ``` -In other words, `enable<>` and `disable<>` behave just like `seq<>` but enable or disable the calling of actions. `action<>` changes the active action class template, which must be supplied as first template parameter to `action<>`. +Similarly the following two lines both start parsing `my_grammar` with `my_action` (again only unless something changes somewhere else). -Note that `action<>` does *not* implicitly enable actions when they were previously explicitly disabled. +```c++ +tao::pegtl::parse< my_grammar, my_action >( ... ); +tao::pegtl::parse< tao::pegtl::action< my_action, my_grammar > >( ... ); +``` -User-defined parsing rules can use `action<>`, `enable<>` and `disable<>` just like any other combinator rules, for example to disable actions in LISP-style comments: +User-defined parsing rules can use `action<>`, `enable<>` and `disable<>` just like any other combinator rules. +For example to disable actions in LISP-style comments the following rule could be used as per `src/example/pegtl/s_expression.cpp`. ```c++ struct comment : tao::pegtl::seq< tao::pegtl::one< '#' >, tao::pegtl::disable< cons_list > > {}; ``` -This also allows using the same rules multiple times with different actions within the grammar. +The ability to change the actions during a parsing run also allows using the same rules multiple times with different action class templates within a grammar. + +### Via Actions + +The action classes `tao::pegtl::disable_action` and `tao::pegtl::enable_action` can be used to disable and enable actions, respectively, for any rule (and its sub-rules). +For example actions can be disabled for `my_rule` in a parsing run using `my_action` as follows. + +```c++ +template<> +struct my_action< my_rule > + : tao::pegtl::disable_action {}; + +tao::pegtl::parse< my_grammar, my_action >( ... ); +``` + +Conversely `tao::pegtl::change_action<>` takes a new action class template as only template parameter and changes the current action in a parsing run to its template parameter. + +Note that parsing proceeds with the rule to which the action changing action is attached to "as if" the new action had been the current action all along. +The new action can even perform an action change *on the same rule*, however care should be taken to not introduce infinite cycles of changes. ## Changing States -Implementing a parser with the PEGTL consists of two main parts. +The states, too, can be changed in ways beyond supplying them, or not, to `tao::pegtl::parse()` at the start of a parsing run. + +### Via Rules + +The [`state` rule](Rule-Reference.md#state-s-r-) behaves similarly to [`seq`](Rule-Reference.md#seq-r-) but uses the first template parameter as type of a new object. +This new object is used replaces the current state(s) for the remainder of the implicit [`seq`](Rule-Reference.md#seq-r-). + +The new object is constructed with a const-reference to the current input of the parsing run, and all previous states, if any, as arguments. +If the implicit [`seq`](Rule-Reference.md#seq-r-) of the sub-rules succeeds, then, by default, a member function named `success()` is called on this "new" object, receiving the same arguments as the constructor. +At this point the input will be advanced by whatever the sub-rules have consumed in the meantime. + +Please consult `include/tao/pegtl/internal/state.hpp` to see how the default behaviour on success can be changed by overriding `tao::pegtl::state<>::success()` in a derived class when using that class instead. + +Embedding a state change into the grammar with [`state<>`](Rule-Reference.md#state-s-r-) is only recommended when some state is used by custom parsing rules. + +### Via Actions + +The actions `tao::pegtl::change_state<>` and `tao::pegtl::change_states<>` can be used to change from the current to a new set of states while parsing the rules they are attached to. + +The differences are summarised in this table; note that `change_state` is more similar to the legacy `change_state` control class as included with the 2.z versions of the PEGTL. + +| Feature | `change_state` | `change_states` | +| --- | --- | --- | +| Number of new states | one | any | +| Construction of new states | with input and old states | default | +| Success function on action | if not on new state | required | + +With `change_state` only a single new state type can be given as template parameter, and only a single new state will be created. +The constructor of the new state receives the same arguments as per `tao::pegtl::state<>`, the current input from the parsing run and all previous states. + +A `success()` static member function is supplied that calls the `success()` member function on the new state, again with the current input from the parsing run and all previous states. +The supplied `success()` can of course be overridden in a derived class. + +With `change_states`, being a variadic template, any number of new state types can be given and an appropriate set of new states will be created (nearly) simultaneously. +All new states are default-constructed, if something else is required the reader is encouraged to copy and modify the implementation of `change_states` in their project. + +The user *must* implement a custom `success()` static member function that takes the current input from the parsing run, the new states, and the old states as arguments. + +Note that, *unlike* the `tao::pegtl::state<>` combinator, the success functions are *only called when actions are currently enabled*! + +Using the changing actions is again done via inheritance as shown in the following example for `change_states`. + +```c++ +template<> +struct my_action< my_rule > + : tao::pegtl::change_states< new_state_1, new_state_2 > +{ + template< typename Input > + static void success( const Input&, new_state_1&, new_state_2&, /* the previous states*/ ) + { + // Do whatever with both the new and the old states... + } +}; +``` + +For a more complete example of how to build a generic JSON data structure with `change_state` and friends see `src/example/pegtl/json_build.cpp`. + +## Changing Actions and States + +The actions `change_action_and_state<>` and `change_action_and_states<>` combine `change_action` with one of the `change_state<>` or `change_states<>` actions, respectively. +For `change_action_and_state<>` and `change_action_and_states<>` the new action class template is passed as first template parameter as for `change_action`, followed by the new state(s) as given to `change_state<>` and `change_states<>`. + +Note that `change_action_and_state<>` and `change_action_and_states<>` behave like `change_action<>` in that they proceed to match the rule to which the changing action is attached to "as if" the new action had been the current action all along. -1. The actual grammar that drives the parser. -2. The states and actions that "do something". +## Match + +Besides `apply()` and `apply0()`, an action class specialization can also have a `match()` static member function. +The default control class template `normal` will detect the presence of a suitable `match()` function and call this function instead of `tao::pegtl::match()`. + +```c++ +template<> +struct my_action< my_rule > +{ + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > class Action, + template< typename... > class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) + { + // Call the function that would have been called otherwise, + // in this case without changing anything... + return tao::pegtl::match< Rule, A, M, Action, Control >( in, st... ); + } +} +``` -For the second part, there are three distinct styles of how to manage the states and actions in non-trivial parsers. +Implementing a custom `match()` for an action is considered a rather advanced feature that is not used directly very often. +All "changing" action classes mentioned in this document are implemented as actions with `match()`. +Their implementations can be found in `<tao/pegtl/change_*.hpp>` and should be studied before implementing a custom action with `match()`. -The **main issue** addressed by the switching styles is the **growing complexity** encountered when a single state argument to a parsing run must perform multiple different tasks, including the management of nested data structures. +## Nothing -The way that this issue is addressed is by providing another tool for performing divide-and-conquer: A large state class with multiple tasks can be divided into +Letting the primary template of an action class template derive from `tao::pegtl::nothing` is recommended, but not necessary. -- multiple smaller state classes that each take care of a single issue, -- one or more [control classes](Control-and-Debug.md) that switch between the states, -- using the C++ stack for nested structures (rather than manually managing a stack). +When using `nothing`, some assertions are enabled that are usually very helpful while developing a parser. -The different styles can also be freely mixed within the same parser. +When not using `nothing`, simply by never mentioning it (as base class), these assertions are disabled and it is possible for an action's `apply()` or `apply0()` implementation to be silently ignored. -### No Switching +In the following let `a` be an action template class, i.e. the instantiation of an action class template `action` for some rule `r`, or `using a = action< r >` for short. -The "no switching style" consists of having one (or more) state-arguments that are passed to a parsing run and that are the arguments to all action's `apply0()`- and `apply()`-methods. +We say that `apply()` is *callable* when it is the name of a static member function of `a` that returns either `void` or `bool` and can be called with an input and the current states. -For an example of how to build a generic JSON data structure with the "no switching style" see `src/example/pegtl/json_build_two.cpp`. +We say that `apply0()` is *callable* when it is the name of a static member function of `a` that returns either `void` or `bool` and can be called with the current states. -### Intrusive Switching +The following assertions are always enabled. -The `state<>` and `action<>` [meta combinators](Rule-Reference.md#meta-rules) can be used to hard-code state and actions switches in the grammar. +* There must be at most one callable `apply` or `apply0()` in `a`. +* If `nothing< r >` is an accessible base class of `a` then `a` must not have a callable `apply()`. +* If `nothing< r >` is an accessible base class of `a` then `a` must not have a callable `apply0()`. +* If `require_apply` is an accessible base class of `a` then it must have a callable `apply()`. +* If `require_apply0` is an accessible base class of `a` then it must have a callable `apply0()`. -In some cases a state object is required for the grammar itself, and in these cases embedding the state-switch into the grammar is recommended. +The classes `require_apply` and `require_apply0` are also explained in [the State Mismatch section](#state-mismatch). -### External Switching +The following assertion is only enabled when `std::is_base_of_v< tao::pegtl::nothing< void >, action< void > >` is `true`. -"External switching" is when the states and/or actions are switched from outside of the grammar by providing a specialised control class. +* Either `nothing` must be an accessible base class of `a`, or +* `maybe_nothing` must be an accessible base class of `a`, or +* `a` must have a callable `apply()` or `apply0()`. -For an example of how to build a generic JSON data structure with the "external switching style" see `src/example/pegtl/json_build_one.cpp`. +The class `tao::pegtl::maybe_nothing` is an accessible base class of all the changing actions explained above. +This make is possible, but not necessary, to implement `apply()` or `apply0()` for actions derived from them. + +Note that `maybe_nothing` can be combined, through multiple inheritance, with one of `nothing< r >`, `require_apply` or `require_apply0`. + +For example when a class `b` is derived from `change_state`, it also gains that class' `maybe_nothing` as accessible base class. +At this point `b` is allowed to either have or not have an `apply()` or `apply0()`. +By letting `b` also derive from one of the three mentioned classes, the `maybe_nothing` will be ignored and `b` will be checked to have or not have the functions as dictated by the respective additional base class. + +## Troubleshooting + +### Boolean Return + +Actions returning `bool` are an advanced use case that should be used with caution. +They prevent some internal optimisations, in particular when used with `apply0()`. +They can also have weird effects on the semantics of a parsing run, for example `at< rule >` can succeed for the same input for which `rule` fails when there is a `bool`-action attached to `rule` that returns `false` (remember that actions are disabled within `at<>`). + +### State Mismatch + +When an action's `apply()` or `apply0()` expects different states than those present in the parsing run there will either be a possibly not very helpful compiler error, or it will compile without a call to the action, depending on whether `tao::pegtl::nothing<>` is used as base class of the primary action class template. + +By deriving an action specialisation from either `tao::pegtl::require_apply` or `tao::pegtl::require_apply0`, as appropriate, a -- potentially more helpful -- compiler error can be provoked, so when the grammar contains `my_rule` and the action is `my_action` then silently compiling without a call to `apply0()` is no longer possible. + +```c++ +template<> +struct my_action< my_rule > + : require_apply0 +{ + static void apply0( double ) + { + // ... + } +} +``` -The actual switching control classes are defined in `<tao/pegtl/contrib/changes.hpp>` and can be used as template for custom switching. +Note that deriving from `require_apply` or `require_apply0` is optional and usually only used for troubleshooting. ## Legacy Actions See the [section on legacy-style action rules](Rule-Reference.md#action-rules). -Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey diff --git a/packages/PEGTL/doc/Changelog.md b/packages/PEGTL/doc/Changelog.md index 06b7ff0fd..37b4184c7 100644 --- a/packages/PEGTL/doc/Changelog.md +++ b/packages/PEGTL/doc/Changelog.md @@ -1,5 +1,48 @@ # Changelog +## 3.0.0 + +**Not yet released** + +* Use the [**migration guide**](Migration-Guide.md#version-300) when updating. +* Updated required C++ standard to C++17. +* Updated required [CMake](https://cmake.org/) version to 3.8. +* The macro `TAO_PEGTL_NAMESPACE` now contains the fully qualified namespace, e.g. `tao::pegtl`. +* Replaced `tao::pegtl::input_error` with `std::system_error`. +* Changed message of `tao::pegtl::parse_error` to no longer contain the position redundantly. +* Removed option of [state](Rule-Reference.md#state-s-r-)'s `S::success()` to have an extended signature to get access to the current `apply_mode`, `rewind_mode`, *action*- and *control* class (template). +* Added `[[nodiscard]]` to most non-void functions. +* Removed compatibility macros starting with `TAOCPP_PEGTL_`. +* Removed compatibility uppercase enumerators. +* Removed compatibility `peek_byte()` member functions. +* Removed compatibility header `changes.hpp` from contrib. + +## 2.8.0 + +Released 2019-04-09 + +* Use the [**migration guide**](Migration-Guide.md#version-280) when updating. +* Changed enumerators to lowercase. + * Renamed `tracking_mode::IMMEDIATE` to `tracking_mode::eager`. + * Compatibility enumerators with uppercase names are still included. + * Will be removed in version 3.0.0. +* Renamed `peek_byte()` to `peek_uint8()`. + * Compatibility member functions with previous names are still included. + * Will be removed in version 3.0.0. +* Allowed actions to implement `match`. +* Made deriving action class templates from `nothing` optional. +* Added debug tools `require_apply` and `require_apply0`. +* Added combinator class [`rematch`](Rule-Reference.md#rematch-r-s-). +* Improved the [Parse Tree / AST interface](Parse-Tree.md) to mostly hide its internal state. +* Added new action-based helpers `change_*.hpp`. + * The control-based helpers in `contrib/changes.hpp` are still included. + * Will be removed in version 3.0.0. +* Added new action-based helpers `disable_action.hpp` and `enable_action.hpp`. +* Added new action-based helpers `discard_input.hpp`, `discard_input_on_success.hpp`, and `discard_input_on_failure.hpp`. +* Added [Clang Static Analyzer](https://clang-analyzer.llvm.org/) to the CI build. +* Added new Makefile target `amalgamate` to generate a single-header version of the PEGTL. +* Added support for [Universal Windows Platform (UWP)](https://en.wikipedia.org/wiki/Universal_Windows_Platform). + ## 2.7.1 Released 2018-09-29 @@ -60,8 +103,8 @@ Released 2018-05-01 * Fixed parse tree node generation to correctly remove intermediate nodes. * Added big- and little-endian support to the UTF-16 and UTF-32 rules. * Added rules for UINT-8 and big- and little-endian UINT-16, UINT-32 and UINT-64. -* Added function to `memory_input<>` to obtain the line around a position. -* Added function to `memory_input<>` to start again from the beginning. +* Added member functions to `memory_input<>` to obtain the line around a position. +* Added member functions to `memory_input<>` to start again from the beginning. * Added example for Python-style indentation-aware grammars. * Added examples for regular, context-free, and context-sensitive grammars. * Added example for how to parse with a symbol table. @@ -73,8 +116,11 @@ Released 2018-05-01 Released 2018-02-17 +* Use the [**migration guide**](Migration-Guide.md#version-240) when updating. * Improved and documented the [Parse Tree / AST support](Parse-Tree.md). -* Changed prefix of all macros from `TAOCPP_PEGTL_` to `TAO_PEGTL_`. Compatibility macros with the old names are provided, they will be removed in version 3.0. +* Changed prefix of all macros from `TAOCPP_PEGTL_` to `TAO_PEGTL_`. + * Compatibility macros with the old names are provided. + * They will be removed in version 3.0.0. * Added a deleted overload to prevent creating a `memory_input<>` from a temporary `std::string`. ## 2.3.4 @@ -109,9 +155,9 @@ Released 2017-12-14 Released 2017-12-11 * Added constructor to `read_input<>` that accepts a `FILE*`, see issue [#78](https://github.com/taocpp/PEGTL/issues/78). -* Enhanced [`apply`](Rule-Reference.md#apply-a-), [`apply0`](Rule-Reference.md#apply0-a-) and [`if_apply`](Rule-Reference.md#if_apply-r-a-) to support `apply()`/`apply0()`-methods returning boolean values. -* Simplified implementation of [`raw_string`](Contrib-and-Examples.md#taopegtlcontribraw_stringhpp), the optional `Contents...` rules' `apply()`/`apply0()`-methods are now called with the original states. -* Fixed the tracer to work with `apply()`/`apply0()`-methods returning boolean values. (Thanks Joel Frederico) +* Enhanced [`apply`](Rule-Reference.md#apply-a-), [`apply0`](Rule-Reference.md#apply0-a-) and [`if_apply`](Rule-Reference.md#if_apply-r-a-) to support `apply()`/`apply0()` returning boolean values. +* Simplified implementation of [`raw_string`](Contrib-and-Examples.md#taopegtlcontribraw_stringhpp), the optional `Contents...` rules' `apply()`/`apply0()` are now called with the original states. +* Fixed the tracer to work with `apply()`/`apply0()` returning boolean values. * Fixed, simplified and improved [`examples/parse_tree.cpp`](Contrib-and-Examples.md#srcexamplepegtlparse_treecpp). ## 2.2.2 @@ -125,7 +171,7 @@ Released 2017-11-22 Released 2017-11-22 * Celebrating the PEGTL's 10th anniversary! -* Fixed missing call to the [control class'](Control-and-Debug.md#control-functions) `failure()`-method when a rule with an `apply()`-method with a boolean return type fails. +* Fixed missing call to the [control class'](Control-and-Debug.md#control-functions) `failure()` when a rule with `apply()` with a boolean return type fails. * Fixed string handling in [`examples/abnf2pegtl.cc`](Contrib-and-Examples.md#srcexamplepegtlabnf2pegtlcpp). * Simplified/improved Android build. @@ -133,7 +179,7 @@ Released 2017-11-22 Released 2017-09-24 -* Added possibility for actions' `apply()`- or `apply0()`-methods to return a `bool` which is then used to determine overall success or failure of the rule to which such an action was attached. +* Added possibility for an action's `apply()` or `apply0()` to return `bool` which is then used to determine overall success or failure of the rule to which such an action was attached. * Added [`<tao/pegtl/contrib/parse_tree.hpp>`](Contrib-and-Examples.md#taopegtlcontribparse_treehpp) and the [`examples/parse_tree.cpp`](Contrib-and-Examples.md#srcexamplepegtlparse_treecpp) application that shows how to build a [parse tree](https://en.wikipedia.org/wiki/Parse_tree). The example goes beyond a traditional parse tree and demonstrates how to select which nodes to include in the parse tree and how to transform the nodes into an [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree)-like structure. * Added `bom` rules for UTF-8, UTF-16 and UTF-32. * Added some missing includes for `config.hpp`. @@ -184,7 +230,7 @@ Released 2017-05-18 * Project * Migrated to ["The Art of C++"](https://github.com/taocpp). - * A [**migration guide**](Migration-Guide.md#from-1y-to-2z) for porting applications from 1.y to 2.z is available. + * Use the [**migration guide**](Migration-Guide.md#version-200) when updating. * Version 2.z can be installed and used in parallel to version 1.y of the PEGTL. * The semantics of all parsing rules and grammars is the same as for versions 1.y. @@ -220,7 +266,7 @@ Released 2017-05-18 * Other Changes - * Added `apply()` and `apply0()` methods to [control class](Control-and-Debug.md#control-functions). + * Added `apply()` and `apply0()` to the [control class](Control-and-Debug.md#control-functions). * Optimised superfluous input markers. * Allowed optimisation of [actions that do not need the input](Actions-and-States.md#apply0). * Replaced layered matching with superior Duseltronik™. @@ -285,7 +331,7 @@ Released 2015-07-31 * Added experimental support for UTF-16 similar to the previously existing UTF-32 parsing rules. * Added support for merging escaped UTF-16 surrogate pairs to `pegtl/contrib/unescape.hh`. * Fixed incorrect handling of escaped UTF-16 surrogate pairs in the JSON examples. -* A [state](Rule-Reference.md#state-s-r-)'s `S::success()`-method can now have an extended signature to get access to the current `apply_mode`, *action*- and *control* class (template). +* A [state](Rule-Reference.md#state-s-r-)'s `S::success()` can now have an extended signature to get access to the current `apply_mode`, *action*- and *control* class (template). * The `contrib/raw_string` class template now calls `Action<raw_string<...>::content>::apply()` with the user's state(s). ## 1.0.0 @@ -311,7 +357,7 @@ Semantic versioning was introduced with version 1.0.0. * The variadic `states...` arguments that are passed through all rule invocations for use by the actions are *not* forwarded with `std::forward<>` anymore since it (usually) doesn't make much sense to move them, and accidentially moving multiple times was a possible error scenario. * There are now five different `rep` rules for repeating a sequence of rules with more control over the acceptable or required number of repetitions. * There are new rules `try_catch<>` and `try_catch_type<>` that convert global errors, i.e. exceptions, into local errors, i.e. a return value of `false`. -* Unified concept for actions and debug hooks, i.e. just like the actions are called from a class template that is passed into the top-level `parse()`-function, there is another class template that is called for debug/trace and error throwing purposes; both can be changed at any point within the grammar. +* Unified concept for actions and debug hooks, i.e. just like the actions are called from a class template that is passed into the top-level `parse()` function, there is another class template that is called for debug/trace and error throwing purposes; both can be changed at any point within the grammar. * A large under-the-hood reorganisation has the benefit of preventing actions from being invoked on rules that are implementation details of other rules, e.g. the `pad< Rule, Padding >` rule contains `star< Padding >` in its implementation, so a specialisation of the action-class-template for `star< Padding >` would be called within `pad<>`, even though the `star< Pad >` was not explicitly written by the user; in PEGTL 1.y these unintended action invocations no longer occur. * Partial support for Unicode has been added in the form of some basic rules like `one<>` and `range<>` also being supplied in a UTF-8 (and experimental UTF-16 and UTF-32) aware version(s) that can correctly process arbitrary code points from `0` to `0x10ffff`. * The supplied input classes work together with the supplied exception throwing to support better error locations when performing nested file parsing, i.e. a `parse_error` contains a vector of parse positions. @@ -322,7 +368,7 @@ Semantic versioning was introduced with version 1.0.0. * The `if_then<>` rule was removed. * The `error_mode` flag was removed. * The semantics of the `must<>` rules was changed to convert local failure to global failure only for the immediate sub-rules of a `must<>` rule. -* The `parse` methods now return a `bool` and can also produce local failures. To obtain the previous behaviour of success-or-global-failure, the top-level grammar rule has to be wrapped in a `must<>`. +* The `parse()` functions now return a `bool` and can also produce local failures. To obtain the previous behaviour of success-or-global-failure, the top-level grammar rule has to be wrapped in a `must<>`. ## 0.32 @@ -355,7 +401,7 @@ Released 2011-02 * Changed the type of exceptions thrown by the library to `pegtl::parse_error`. * Changed class `basic_debug` to only generate a grammar back-trace when a `pegtl::parse_error` is flying. -* Changed logging to use a virtual method on the debug class inherited from common debug base class. +* Changed logging to use a virtual member function on the debug class inherited from common debug base class. * Removed all `*_parse_*_nothrow()` parse functions. * Removed the `_throws` substring from all remaining parse functions and changed the return type to `void`. * Added convenience classes `file_input`, `ascii_file_input` and `dummy_file_input` for custom parse functions. @@ -500,4 +546,4 @@ Released 2008 Development of the PEGTL started in November 2007 as an experiment in C++0x. It is based on ideas from the YARD library by Christopher Diggins. -Copyright (c) 2007-2018 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2007-2019 Dr. Colin Hirsch and Daniel Frey diff --git a/packages/PEGTL/doc/Contrib-and-Examples.md b/packages/PEGTL/doc/Contrib-and-Examples.md index fc311f854..f83cc6cf1 100644 --- a/packages/PEGTL/doc/Contrib-and-Examples.md +++ b/packages/PEGTL/doc/Contrib-and-Examples.md @@ -29,10 +29,26 @@ For all questions and remarks contact us at **taocpp(at)icemx.net**. * Constants for ASCII letters. * Shortens `string<'f','o','o'>` to `string<f,o,o>`. * Ready for production use. +* Superceeded by `TAO_PEGTL_STRING()`. -###### `<tao/pegtl/contrib/changes.hpp>` +###### `<tao/pegtl/contrib/change_action.hpp>` -* Control class components for [external switching style](Actions-and-States.md#external-switching). +* Changes the action class template. +* Ready for production use. + +###### `<tao/pegtl/contrib/change_action_and_state.hpp>` + +* Changes the action class template and the state. +* Ready for production use but might be changed in the future. + +###### `<tao/pegtl/contrib/change_control.hpp>` + +* Changes the control class template. +* Ready for production use. + +###### `<tao/pegtl/contrib/change_state.hpp>` + +* Changes the state. * Ready for production use but might be changed in the future. ###### `<tao/pegtl/contrib/counter.hpp>` @@ -42,6 +58,16 @@ For all questions and remarks contact us at **taocpp(at)icemx.net**. 2. succeeded to match, 3. failed to match. +###### `<tao/pegtl/contrib/disable_action.hpp>` + +* Disables actions. +* Ready for production use. + +###### `<tao/pegtl/contrib/enable_action.hpp>` + +* Enables actions. +* Ready for production use. + ###### `<tao/pegtl/contrib/http.hpp>` * HTTP 1.1 grammar according to [RFC 7230](https://tools.ietf.org/html/rfc7230). @@ -65,11 +91,15 @@ For all questions and remarks contact us at **taocpp(at)icemx.net**. * Grammar rules to parse Lua-style long (or raw) string literals. * Ready for production use. +###### `<tao/pegtl/contrib/rep_string.hpp>` + +* Contains optimised version of `rep< N, string< Cs... > >`: +* Rule `ascii::rep_string< N, Cs... >`. + ###### `<tao/pegtl/contrib/rep_one_min_max.hpp>` * Contains optimised version of `rep_min_max< Min, Max, ascii::one< C > >`: * Rule `ascii::rep_one_min_max< Min, Max, C >`. -* Rule `ascii::ellipsis` as shortcut for `ascii::rep_one_min_max< 3, 3, '.' >`. ###### `<tao/pegtl/contrib/to_string.hpp>` @@ -150,13 +180,9 @@ Shows one approach to implementing an indentation-aware language with a very ver Shows how to use the custom error messages defined in `json_errors.hpp` with the `<tao/pegtl/contrib/json.hpp>` grammar to parse command line arguments as JSON data. -###### `src/example/pegtl/json_build_one.cpp` - -Extends on `json_parse.cpp` by parsing JSON files into generic JSON data structures using the "[switching style](Actions-and-States.md#changing-state)" of managing actions and states. - -###### `src/example/pegtl/json_build_two.cpp` +###### `src/example/pegtl/json_build.cpp` -Extends on `json_parse.cpp` by parsing JSON files into generic JSON data structures using a more monolithic approach to managing the states and actions. +Extends on `json_parse.cpp` by parsing JSON files into generic JSON data structure. ###### `src/example/pegtl/json_count.cpp` @@ -177,30 +203,16 @@ A small example which shows how to create a parse tree for a given grammar using The example shows how to choose which rules will produce a parse tree node, which rules will store the content, and how to add additional transformations to the parse tree to transform it into an AST-like structure or to simplify it. -Running the example with a slightly longer expression: +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*b*4 - x / ( 2 - b + c - d )" -ROOT - example::minus at :1:9(9) - example::plus at :1:1(1) - example::integer "2" at :1:0(0) to :1:1(1) - example::multiply at :1:7(7) - example::multiply at :1:5(5) - example::variable "a" at :1:4(4) to :1:5(5) - example::variable "b" at :1:6(6) to :1:7(7) - example::integer "4" at :1:8(8) to :1:9(9) - example::divide at :1:13(13) - example::variable "x" at :1:12(12) to :1:13(13) - example::minus at :1:27(27) - example::plus at :1:23(23) - example::minus at :1:19(19) - example::integer "2" at :1:18(18) to :1:19(19) - example::variable "b" at :1:22(22) to :1:23(23) - example::variable "c" at :1:26(26) to :1:27(27) - example::variable "d" at :1:30(30) to :1:31(31) +$ build/src/example/pegtl/parse_tree "(2*a + 3*b) / (4*n)" | dot -Tpng -o parse_tree.png ``` +The above will generate a PNG with a graphical representation of the parse tree. + + + ###### `src/example/pegtl/proto3.cpp` Experimental grammar that parses Protocol Buffers (`.proto3`) files. @@ -230,4 +242,4 @@ Uses the building blocks from `<tao/pegtl/contrib/unescape.hpp>` to show how to Shows how to use the included [tracer control](#taopegtlcontribtracerhpp), here together with the URI grammar from `<tao/pegtl/contrib/uri.hpp>`. Invoked with one or more URIs as command line arguments will attempt to parse the URIs while printing trace information to `std::cerr`. -Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey diff --git a/packages/PEGTL/doc/Control-and-Debug.md b/packages/PEGTL/doc/Control-and-Debug.md index ef851de2f..af5ef5a67 100644 --- a/packages/PEGTL/doc/Control-and-Debug.md +++ b/packages/PEGTL/doc/Control-and-Debug.md @@ -5,12 +5,12 @@ Beyond the top-level grammar rule, which *has* to be supplied to a parsing run, (Actually the control class is a class template which takes a parsing rule as template argument, however in many cases there will be no specialisations, wherefore we will drop the distinction and pretend here that it is simply a class.) Functions from the control class are called in strategic places during a parsing run and can be used to customise internal behaviour of the PEGTL and/or as debug aids. -More precisely, the control class has functions to +More precisely, the control class has static member functions to 1. trace which rules are attempted to match where, and whether they succeed or fail, -1. customise which exceptions are thrown in case of errors, -3. customise how actions' `apply()` and `apply0()` methods are called, -4. customise how rules' `match()` methods are called. +2. customise which exceptions are thrown in case of errors, +3. customise how an action's `apply()` or `apply0()` is called, +4. customise how a rule's `match()` is called. ## Contents @@ -30,48 +30,32 @@ struct normal { template< typename Input, typename... States > - static void start( const Input&, States&&... ) - { - } + static void start( const Input&, States&&... ); template< typename Input, typename... States > - static void success( const Input&, States&&... ) - { - } + static void success( const Input&, States&&... ); template< typename Input, typename... States > - static void failure( const Input&, States&&... ) - { - } + static void failure( const Input&, States&&... ); template< typename Input, typename... States > - static void raise( const Input& in, States&&... ) - { - throw parse_error( "parse error matching " + - internal::demangle< Rule >(), in ); - } + static void raise( const Input& in, States&&... ); template< template< typename... > class Action, + typename Iterator, typename Input, typename... States > - static void apply0( const Input&, States&&... st ) - { - Action< Rule >::apply0( st... ); - } + static auto apply( const Iterator& begin, const Input& in, States&&... st ) + -> decltype( ... ); template< template< typename... > class Action, - typename Iterator, typename Input, typename... States > - static void apply( const Iterator& begin, const Input& in, States&&... st ) - { - using action_t = typename Input::action_t; - const action_t action_input( begin, in ); - Action< Rule >::apply( action_input, st... ); - } + static auto apply0( const Input&, States&&... st ) + -> decltype( ... ); template< apply_mode A, rewind_mode M, @@ -79,28 +63,23 @@ struct normal template< typename... > class Control, typename Input, typename... States > - static bool match( Input& in, States&&... st ) - { - constexpr bool use_control = !internal::skip_control< Rule >::value; - constexpr bool use_action = use_control && ( A == apply_mode::ACTION ) && ( !is_nothing< Action, Rule >::value ); - constexpr bool use_apply0 = use_action && internal::has_apply0< Action< Rule >, internal::type_list< States... > >::value; - constexpr dusel_mode mode = static_cast< dusel_mode >( static_cast< char >( use_control ) + static_cast< char >( use_action ) + static_cast< char >( use_apply0 ) ); - return internal::duseltronik< Rule, A, M, Action, Control, mode >::match( in, st... ); - } + static bool match( Input& in, States&&... st ); }; ``` -The `start()`, `success()` and `failure()`-functions can be used to debug a grammar by using them to provide insight into what exactly is going on during a parsing run. +The static member functions `start()`, `success()` and `failure()` can be used to debug a grammar by using them to provide insight into what exactly is going on during a parsing run, or to construct a parse tree, etc. -The `raise()`-function is used to create a global error, and any replacement should again throw an exception, or abort the application. +The static member function `raise()` is used to create a global error, and any replacement should again throw an exception, or abort the application. -The `apply()` and `apply0()`-functions can customise how actions with, and without, receiving the matched input are called, respectively. +The static member functions `apply()` and `apply0()` can customise how actions with, and without, receiving the matched input are called, respectively. +Note that these functions should only exist or be visible when an appropriate `apply()` or `apply0` exists in the action class template. +This can be achieved via SFINAE, e.g. with a trailing return type as shown above. -The `match`-function wraps the actual matching duseltronik and chooses the correct one based on whether control is enabled for `Rule`, and whether the current action is enabled and has an `apply()` or `apply0()`-function. +The static member function `match()` by default checks if there exists a suitable `match()` in the action class template for the current rule. If so, it is called, otherwise it calls the main `tao::pegtl::match()` function. ## Control Functions -For debugging a grammar and tracing exactly what happens during a parsing run, the control class methods `start()`, `success()` and `failure()` can be used. +For debugging a grammar and tracing exactly what happens during a parsing run, the control class' `start()`, `success()` and `failure()` can be used. In addition, `apply()` and `apply0()` can be used to see which actions are invoked. Before attempting to match a rule `R`, the PEGTL calls `C< R >::start()` where `C` is the current control class template. @@ -109,31 +88,33 @@ Depending on what happens during the attempt to match `R`, one of the other thre - If `R` succeeds, then `C< R >::success()` is called; compared to the call to `C< R >::start()`, the input will have consumed whatever the successful match of `R` consumed. -- If `R` finishes with a failure, i.e. a return value of `false` from its `match()`-function, then `C< R >::failure()` is called; a failed match is not allowed to consume input. +- If `R` finishes with a failure, i.e. a return value of `false` from `match()`, then `C< R >::failure()` is called; a failed match **must not** consume input. - If `R` is wrapped in `must< R >`, a global failure is generated by calling `C< R >::raise()` to throw some exception as is expected by the PEGTL in this case. - If a sub-rule of `R` finishes with a global failure, and the exception is not caught by a `try_catch` or similar combinator, then no other function of `C< R >` is called after `C< R >::start()`. -Additionally, if matching `R` was successful, actions are enabled, and `A< R >` is not derived from `tao::pegtl::nothing`, where `A` is the current action class template: +Additionally, if matching `R` was successful and actions are enabled: -- If `A< R >::apply0()` exists, then `C< R >::apply0()` is called with the current state arguments. +- If `C< R >::apply()` exists, then `C< R >::apply()` is called with the matched input and the current state arguments. -- If `A< R >::apply()` exists, then `C< R >::apply()` is called with the matched input and the current state arguments. +- If `C< R >::apply0()` exists, then `C< R >::apply0()` is called with the current state arguments. -It is an error when both `A< R >::apply0()` and `A< R >::apply()` exist. +It is an error when both `C< R >::apply()` and `C< R >::apply0()` exist. -In case of actions that return `bool`, i.e. actions whose `apply0()` or `apply()` function returns `bool`, the `C< R >::success()` function is only called when both the rule *and* the action succeed. +Note that the default `C< R >::apply()` is SFINAE-enabled if `A< R >::apply()` exists (where `A` is the current action class template) and calls the latter. A control class might modify state, etc. + +In case of actions that return `bool`, i.e. actions where `apply()` or `apply0()` return `bool`, `C< R >::success()` is only called when both the rule *and* the action succeed. If either produce a (local) failure then `C< R >::failure()` is called. In all cases where an action is called, the success or failure hooks are invoked after the action returns. -The included class `tao::pegtl::tracer` in `<tao/pegtl/contrib/tracer.hpp>` gives a pratical example that can be used as control class to debug grammars. +The included class `tao::pegtl::tracer` in `<tao/pegtl/contrib/tracer.hpp>` gives a practical example that can be used as control class to debug grammars. When an instance of class `tao::pegtl::trace_state` is used as single state in a parsing run with the tracer-control then the debug output contains a line number and rule number as additional information. ## Exception Throwing -The `raise()`-control-hook-function **must** throw an exception. +The control-hook, the `raise()` static member function, **must** throw an exception. For most parts of the PEGTL the exception class is irrelevant and any user-defined data type can be thrown by a user-defined control hook. The `try_catch` rule only catches exceptions of type `tao::pegtl::parse_error`! @@ -142,17 +123,21 @@ When custom exception types are used then `try_catch_type` must be used with the ## Advanced Control -The control template's `match()`-function is the first, or outside-most, function that is called in the flow that eventually leads to calling a rule's `match()`-function. +The control's `match()` is the first, outer-most function in the call-chain that eventually calls the rule's `match()`. -For advanced use cases it is possible to create a custom control class with a custom `match()`-function that can change "everything" before calling the actual rule's `match()`-function. +For advanced use cases, it is possible to create a custom control class with a custom `match()` that can change "everything" before calling the rule's `match()`. -Similarly the control's `apply()` and `apply0()`-functions can customise action invocation; in particular `apply()` can change how the matched portion of the input is presented to the action. +Similarly, the control's `apply()` and `apply0()` can customise action invocation; in particular `apply()` can change how the matched portion of the input is passed to the action. ## 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 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. -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. +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-2018 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey diff --git a/packages/PEGTL/doc/Errors-and-Exceptions.md b/packages/PEGTL/doc/Errors-and-Exceptions.md index bfa14bd4a..d632031ea 100644 --- a/packages/PEGTL/doc/Errors-and-Exceptions.md +++ b/packages/PEGTL/doc/Errors-and-Exceptions.md @@ -1,6 +1,6 @@ # Errors and Exceptions -A parsing run, a call to one of the `parse()`-functions as explained in [Inputs and Parsing](Inputs-and-Parsing.md), can have the same results as calling the `match()`-method on a grammar rule. +A parsing run, a call to one of the `parse()` functions as explained in [Inputs and Parsing](Inputs-and-Parsing.md), can have the same results as calling `match()` on a grammar rule. * A return value of `true` indicates a *successful* match. * A return value of `false` is called a *local failure* (even when propagated to the top). @@ -29,7 +29,7 @@ The `must<>` rule is equivalent to `seq<>` in that it attempts to match all sub- Global failures can also be unconditionally provoked with the `raise<>` grammar rule, which is more flexible since the template argument can be any type, not just a parsing rule. 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()`-method. +In any case, the task of actually throwing an exception is delegated to the [control class'](Control-and-Debug.md) `raise()`. ## Global to Local Failure @@ -45,10 +45,10 @@ For another use case consider the following parsing rules for a simplified C-str The rule `escaped` is for a single escaped character, the rule `content` is for the complete content of such a literal. ```c++ - using namespace tao::pegtl; - struct escaped : seq< one< '\\' >, one< 'n', 'r', 't' > > {}; - struct content : star< sor< escaped, not_one< '\\', '"' > > > {}; - struct literal : seq< one< '"' >, content, one< '"' > > {}; +using namespace tao::pegtl; +struct escaped : seq< one< '\\' >, one< 'n', 'r', 't' > > {}; +struct content : star< sor< escaped, not_one< '\\', '"' > > > {}; +struct literal : seq< one< '"' >, content, one< '"' > > {}; ``` The `escaped` rule first matches a backslash, and then one of the allowed subsequent characters. @@ -61,24 +61,24 @@ It is however *not* appropriate when the backslash was not followed by one of th We can therefore re-write the `escaped` rule as follows so that once the backslash has matched we need one of the following allowed characters to match, otherwise a global failure is thrown. ```c++ - using namespace tao::pegtl; - struct escaped : seq< one< '\\' >, must< one< 'n', 'r', 't' > > > {}; +using namespace tao::pegtl; +struct escaped : seq< one< '\\' >, must< one< 'n', 'r', 't' > > > {}; ``` A `seq<>` where all but the first sub-rule is inside a `must<>` occurs frequently enough to merit a convenience rule. The following rule is equivalent to the above. ```c++ - using namespace tao::pegtl; - struct escaped : if_must< one< '\\' >, one< 'n', 'r', 't' > > {}; +using namespace tao::pegtl; +struct escaped : if_must< one< '\\' >, one< 'n', 'r', 't' > > {}; ``` Now the `escaped` rule can only return local failure when the next input byte is not a backslash. This knowledge can be used to simplify the `content` rule by not needing to exclude the backslash in the following rule. ```c++ - using namespace tao::pegtl; - struct content : star< sor< escaped, not_one< '"' > > > {}; +using namespace tao::pegtl; +struct content : star< sor< escaped, not_one< '"' > > > {}; ``` Finally we apply our "best practice" and give the `one< 'n', 'r', 't' >` rule a dedicated name. @@ -86,11 +86,11 @@ This will improve the built-in error message when the global failure is thrown, The resulting example is as follows. ```c++ - using namespace tao::pegtl; - struct escchar : one< 'n', 'r', 't' > {}; - struct escaped : if_must< one< '\\' >, escchar > {}; - struct content : star< sor< escaped, not_one< '"' > > > {}; - struct literal : seq< one< '"' >, content, one< '"' > > {}; +using namespace tao::pegtl; +struct escchar : one< 'n', 'r', 't' > {}; +struct escaped : if_must< one< '\\' >, escchar > {}; +struct content : star< sor< escaped, not_one< '"' > > > {}; +struct literal : seq< one< '"' >, content, one< '"' > > {}; ``` The same use of `if_must<>` can be applied to the `literal` rule assuming that it occurs in some `sor<>` where it is the only rule whose matched input can begin with a quotation mark... @@ -99,7 +99,7 @@ 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 message for all `must<>` error points uses a custom control class whose `raise()`-method uses a static string as error message. +A practical technique to provide customised error message for all `must<>` error points uses a custom control class whose `raise()` uses a static string as error message. ```c++ template< typename Rule > @@ -119,38 +119,38 @@ struct my_control Now only the `error_message` string needs to be specialised per error point as follows. ```c++ -template<> const std::string my_control< MyRule >::error_message = "expected ..."; +template<> inline const std::string my_control< MyRule >::error_message = "expected ..."; ``` -Since the `raise()`-method is only instantiated for those rules for which `must<>` could trigger an exception, it is sufficient to provide specialisations of the error message string for those rules. +Since `raise()` is only instantiated for those rules for which `must<>` could trigger an exception, it is sufficient to provide specialisations of the error message string for those rules. Furthermore, there will be a linker error for all rules for which the specialisation was forgotten although `raise()` could be called. For an example of this method see `src/examples/pegtl/json_errors.hpp`, where all errors that might occur in the supplied JSON grammar are customised like this: ```c++ -template<> const std::string errors< tao::pegtl::json::text >::error_message = "no valid JSON"; - -template<> const std::string errors< tao::pegtl::json::end_array >::error_message = "incomplete array, expected ']'"; -template<> const std::string errors< tao::pegtl::json::end_object >::error_message = "incomplete object, expected '}'"; -template<> const std::string errors< tao::pegtl::json::member >::error_message = "expected member"; -template<> const std::string errors< tao::pegtl::json::name_separator >::error_message = "expected ':'"; -template<> const std::string errors< tao::pegtl::json::array_element >::error_message = "expected value"; -template<> const std::string errors< tao::pegtl::json::value >::error_message = "expected value"; - -template<> const std::string errors< tao::pegtl::json::digits >::error_message = "expected at least one digit"; -template<> const std::string errors< tao::pegtl::json::xdigit >::error_message = "incomplete universal character name"; -template<> const std::string errors< tao::pegtl::json::escaped >::error_message = "unknown escape sequence"; -template<> const std::string errors< tao::pegtl::json::char_ >::error_message = "invalid character in string"; -template<> const std::string errors< tao::pegtl::json::string::content >::error_message = "unterminated string"; -template<> const std::string errors< tao::pegtl::json::key::content >::error_message = "unterminated key"; - -template<> const std::string errors< tao::pegtl::eof >::error_message = "unexpected character after JSON value"; +template<> inline const std::string errors< tao::pegtl::json::text >::error_message = "no valid JSON"; + +template<> inline const std::string errors< tao::pegtl::json::end_array >::error_message = "incomplete array, expected ']'"; +template<> inline const std::string errors< tao::pegtl::json::end_object >::error_message = "incomplete object, expected '}'"; +template<> inline const std::string errors< tao::pegtl::json::member >::error_message = "expected member"; +template<> inline const std::string errors< tao::pegtl::json::name_separator >::error_message = "expected ':'"; +template<> inline const std::string errors< tao::pegtl::json::array_element >::error_message = "expected value"; +template<> inline const std::string errors< tao::pegtl::json::value >::error_message = "expected value"; + +template<> inline const std::string errors< tao::pegtl::json::digits >::error_message = "expected at least one digit"; +template<> inline const std::string errors< tao::pegtl::json::xdigit >::error_message = "incomplete universal character name"; +template<> inline const std::string errors< tao::pegtl::json::escaped >::error_message = "unknown escape sequence"; +template<> inline const std::string errors< tao::pegtl::json::char_ >::error_message = "invalid character in string"; +template<> inline const std::string errors< tao::pegtl::json::string::content >::error_message = "unterminated string"; +template<> inline const std::string errors< tao::pegtl::json::key::content >::error_message = "unterminated key"; + +template<> inline const std::string errors< tao::pegtl::eof >::error_message = "unexpected character after JSON value"; ``` It is also possible to provide a default error message that will be chosen by the compiler in the absence of a specialised one as follows. ```c++ template< typename T > -const std::string my_control< T >::error_message = +inline const std::string my_control< T >::error_message = "parse error matching " + tao::pegtl::internal::demangle< T >(); ``` @@ -159,4 +159,4 @@ This is similar to the default behaviour, but one will not get a linker error in It is advisable to choose the error points in the grammar with prudence. This choice becoming particularly cumbersome and/or resulting in a large number of error points might be an indication of the grammar needing some kind of simplification or restructuring. -Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey diff --git a/packages/PEGTL/doc/Getting-Started.md b/packages/PEGTL/doc/Getting-Started.md index f294acd97..aa87cda47 100644 --- a/packages/PEGTL/doc/Getting-Started.md +++ b/packages/PEGTL/doc/Getting-Started.md @@ -4,7 +4,7 @@ Since the PEGTL is a parser library, here is an "inverse hello world" example th rather than prints, the string `Hello, foo!` for any sequence of alphabetic ASCII characters `foo`. ```c++ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <string> @@ -43,7 +43,6 @@ namespace hello template< typename Rule > struct action - : pegtl::nothing< Rule > {}; // Specialisation of the user-defined action to do @@ -71,7 +70,7 @@ int main( int argc, char* argv[] ) std::string name; - pegtl::argv_input<> in( argv, 1 ); + pegtl::argv_input in( argv, 1 ); pegtl::parse< hello::grammar, hello::action >( in, name ); std::cout << "Good bye, " << name << "!" << std::endl; @@ -83,7 +82,7 @@ Assuming you are in the main directory of the PEGTL, the above source can be found in the `src/example/pegtl/` directory. Compile the program with something like ```sh -$ g++ --std=c++11 -Iinclude src/example/pegtl/hello_world.cpp -o hello_world +$ g++ --std=c++17 -Iinclude src/example/pegtl/hello_world.cpp -o hello_world ``` and then invoke it as follows: @@ -102,4 +101,4 @@ Aborted (core dumped) Frequently an application will include a top-level `try-catch` block to handle the exception. -Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey diff --git a/packages/PEGTL/doc/Grammar-Analysis.md b/packages/PEGTL/doc/Grammar-Analysis.md index 43b1c49e7..ad9070ce9 100644 --- a/packages/PEGTL/doc/Grammar-Analysis.md +++ b/packages/PEGTL/doc/Grammar-Analysis.md @@ -1,11 +1,17 @@ # Grammar Analysis -The PEGTL contains an `analyze()`-function that checks a grammar for rules that can go into an infinite loop without consuming input. +The PEGTL contains an `analyze()` function that checks a grammar for rules that can go into an infinite loop without consuming input. Unfortunately, given the expressive power of PEGs and the possibility of arbitrary custom combinator rules, it is impossible to detect *all* kinds of infinite loops. It does however catch most cases of left-recursion that are typical for grammars converted from CFGs or other formalisms that gracefully handle left-recursion. +## Content + +* [Rule Analysis](#rule-analysis) +* [Background](#background) +* [Custom Rules](#custom-rules) + ## Rule Analysis In order to run an analysis on a grammar it is necessary to explicitly include `<tao/pegtl/analyze.hpp>`. @@ -17,7 +23,7 @@ Then call `tao::pegtl::analyze()` with the top-level grammar rule as template ar const std::size_t issues_found = tao::pegtl::analyze< my_grammar >(); ``` -The `analyze()`-function returns the number of issues found and writes some information about them to `std::cout`. +`analyze()` returns the number of issues found and writes some information about them to `std::cout`. Analysing a grammar is usually only done while developing and debugging a grammar, or after changing it. @@ -41,7 +47,7 @@ Due to the differences regarding back-tracking and non-deterministic behaviour, ## Background -In order to look for infinite loops in a grammar, the `analyze()`-function needs some information about all rules in the grammar. +In order to look for infinite loops in a grammar, `analyze()` needs some information about all rules in the grammar. This "information" consists of a classification of the rules according to the following enum, plus, for non-atomic rules, a list of the sub-rules. ```c++ @@ -49,30 +55,30 @@ This "information" consists of a classification of the rules according to the fo enum class rule_type : char { - ANY, - OPT, - SEQ, - SOR + any, + opt, + seq, + sor }; ``` -This enum value and rule list are provided to the `analyze()`-function via an `analyze_t` type member that all rules that are part of a grammar that is to be analysed with `analyze()` need to define. +This enum value and rule list are provided to `analyze()` via an `analyze_t` type member that all rules that are part of a grammar that is to be analysed with `analyze()` need to define. The names of the enum values correspond to one of the PEGTL rule classes that has this rule type, however some rule types are used by many different classes. -* `ANY` is for rules where "success implies consumption" is true; assumes bounded repetition of conjunction of sub-rules. -* `OPT` is for rules where "success implies consumption" is false; assumes bounded repetition of conjunction of sub-rules. -* `SEQ` is for rules where consumption on success depends on non-zero bounded repetition of the conjunction of sub-rules. -* `SOR` is for rules where consumption on success depends on non-zero bounded repetition of the disjunction of sub-rules. +* `any` is for rules where "success implies consumption" is true; assumes bounded repetition of conjunction of sub-rules. +* `opt` is for rules where "success implies consumption" is false; assumes bounded repetition of conjunction of sub-rules. +* `seq` is for rules where consumption on success depends on non-zero bounded repetition of the conjunction of sub-rules. +* `sor` is for rules where consumption on success depends on non-zero bounded repetition of the disjunction of sub-rules. -At the beginning of an `analyze()`-run the function `R::analyze_t::insert()` is called for all rules `R` in the grammar in order to insert the information about the rule `R` into a data structure. +At the beginning of an `analyze()` run the function `R::analyze_t::insert()` is called for all rules `R` in the grammar in order to insert the information about the rule `R` into a data structure. ## Custom Rules For custom rules it should usually be sufficient to follow the lead of the rules supplied with the PEGTL and define `analyze_t` to either `tao::pegtl::analysis::generic` or `tao::pegtl::analysis::counted`. In both cases, the `rule_type` and the list of sub-rules must be supplied as template parameters. -Class `tao::pegtl::analysis::counted` additionally takes an integer argument `Count` with the assumption being that a count of zero indicates that everything the rule type is `OPT` while a non-zero count uses the rule type given as template parameter. +Class `tao::pegtl::analysis::counted` additionally takes an integer argument `Count` with the assumption being that a count of zero indicates that everything the rule type is `opt` while a non-zero count uses the rule type given as template parameter. When a custom rule goes beyond what can be currently expressed and all other questions, please contact the authors at **taocpp(at)icemx.net**. -Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey diff --git a/packages/PEGTL/doc/Inputs-and-Parsing.md b/packages/PEGTL/doc/Inputs-and-Parsing.md index 16aa7e9c2..0066d35c6 100644 --- a/packages/PEGTL/doc/Inputs-and-Parsing.md +++ b/packages/PEGTL/doc/Inputs-and-Parsing.md @@ -11,13 +11,13 @@ using namespace tao::pegtl; struct my_grammar : ...; template< typename Rule > -struct my_actions : nothing< Rule > {}; +struct my_actions {}; // Specialisations of my_actions as required... bool my_parse( const std::string& filename, my_state& state ) { - file_input<> in( filename ); + file_input in( filename ); return parse< my_grammar, my_actions >( in, state ); } ``` @@ -41,25 +41,28 @@ All classes and functions on this page are in namespace `tao::pegtl`. * [Parse Function](#parse-function) * [Nested Parsing](#nested-parsing) * [Incremental Input](#incremental-input) - * [Grammars and Buffering](#grammars-and-buffering) - * [Custom Data Sources](#custom-data-sources) + * [Buffer Size](#buffer-size) + * [Discard Input](#discard-input) + * [Custom Rules](#custom-rules) + * [Custom Readers](#custom-readers) + * [Buffer Details](#buffer-details) * [Error Reporting](#error-reporting) -* [C++17 Deduction Guides](#c17-deduction-guides) +* [Deduction Guides](#deduction-guides) ## Tracking Mode -Some input classes allow a choice of tracking mode, or whether the `byte`, `line` and `byte_in_line` counters are continuously updated during a parsing run with `tracking_mode::IMMEDIATE`, or only calculated on-demand in the `position()`-method by scanning the complete input again with `tracking_mode::LAZY`. +Some input classes allow a choice of tracking mode, or whether the `byte`, `line` and `byte_in_line` counters are continuously updated during a parsing run with `tracking_mode::eager`, or only calculated on-demand in `position()` by scanning the complete input again with `tracking_mode::lazy`. Lazy tracking is recommended when the position is used very infrequently, for example only in the case of throwing a `parse_error`. -Immediate tracking is recommended when the position is used frequently and/or in non-exceptional cases, for example when annotating every AST node with the line number. +Eager tracking is recommended when the position is used frequently and/or in non-exceptional cases, for example when annotating every AST node with the line number. ## Line Ending All input classes allow the choice of which line endings should be recognised by the `eol` and `eolf` rules, and used for line counting. The supported line endings are `cr`, a single carriage-return/`"\r"`/`0x0d` character as used on classic Mac OS, `lf`, a single line-feed/`"\n"`/`0x0a` as used on Unix, Linux, Mac OS X and macOS, and `crlf`, a sequence of both as used on MS-DOS and Windows. -The default template argument for all input classes is `eol::lf_crlf` which recognises both Unix and MS-DOS line endings. +The default template parameter for all input classes is `eol::lf_crlf` which recognises both Unix and MS-DOS line endings. The supplied alternatives are `eol::cr`, `eol::lf`, `eol::crlf` and `eol::cr_crlf`. ## Source @@ -73,7 +76,7 @@ The classes `file_input<>`, `read_input<>` and, on supported platforms, `mmap_in * `read_input<>` uses C "stdio" facilities to read the file. * `mmap_input<>` uses `mmap(2)` on POSIX compliant systems or `MapViewOfFile()` on Windows. -* `file_input<>` is derived from `mmap_input<>` when available, and `read_input<>` otherwise, inheriting the respective contructors. +* `file_input<>` is derived from `mmap_input<>` when available, and `read_input<>` otherwise, inheriting the respective constructors. Most file input classes take a single argument, the filename, which can be supplied as `std::string` or `const char*`. They immediately make available the complete contents of the file; `read_input<>` reads the entire file upon construction. @@ -81,7 +84,7 @@ They immediately make available the complete contents of the file; `read_input<> The constructors that take a `FILE*` argument take ownership of the file pointer, i.e. they `fclose()` it in the destructor. ```c++ -template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf > +template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > struct read_input { explicit read_input( const char* filename ); @@ -91,14 +94,14 @@ struct read_input read_input( FILE* file, const std::string& filename ); }; -template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf > +template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > struct mmap_input { explicit mmap_input( const char* filename ); explicit mmap_input( const std::string& filename ); }; -template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf > +template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > using file_input = mmap_input< P, Eol >; // Or read_input when no mmap_input available. ``` @@ -119,7 +122,7 @@ It will therefore *only* work correctly with data that is terminated with a 0-by The constructors that take additional `byte`, `line` and `byte_in_line` arguments initialise the internal counters with the supplied values, rather than the defaults of `0`, `1` and `0`. ```c++ -template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf, typename Source = std::string > +template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf, typename Source = std::string > class memory_input { template< typename T > @@ -148,7 +151,7 @@ class memory_input ###### Example 1 ```c++ -memory_input<> in1( "this is the input to parse", "" ); +memory_input in1( "this is the input to parse", "" ); ``` Construct a `memory_input` with default tracking mode, default end-of-line mode (accepting Unix and MS-DOS line endings), and default source storage. @@ -170,7 +173,7 @@ struct packet packet p = ...; // some UDP packet class -memory_input< tracking_mode::LAZY, eol::crlf > in2( p.buffer().begin(), p.buffer().end(), p.identifier() ); +memory_input< tracking_mode::lazy, eol::crlf > in2( p.buffer().begin(), p.buffer().end(), p.identifier() ); ``` Consider a UDP packet that was received and should be parsed. @@ -196,7 +199,7 @@ The class `string_input<>` can also be used to parse a `std::string`. Unlike class `memory_input<>`, this class stores a copied (or moved) version of the data for which it takes ownership. ```c++ -template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf, typename Source = std::string > +template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf, typename Source = std::string > class string_input { template< typename V, typename T > @@ -208,6 +211,18 @@ class string_input }; ``` +### Example + +```c++ +std::string content(); // returns the content + +string_input in1( content(), "from_content" ); +``` + +Construct a `string_input` with default tracking mode, default end-of-line mode (accepting Unix and MS-DOS line endings), and default source storage. +The data returned from calling `content()` is copied into the input. +The source is `from_content`. + ### Additional Remarks Note that the implementation of the constructors is different than shown. @@ -221,7 +236,7 @@ Unlike the file inputs above, they internally use `buffer_input<>` and therefore They all have a single constructor that takes a stream, the maximum buffer size, and the name of the source. Note that these classes only keep a pointer/reference to the stream and do **not** take ownership; in particular `cstream_input<>` does **not** call `std::close()`. -See [Incremental Input](#incremental-input) for details on the `maximum` argument, and how to prepare a grammar for incremental input support using the `discard`-rule. +See [Incremental Input](#incremental-input) for details on the `maximum` argument, and how to use the mandatory [discard facilities](#discard-buffer). ```c++ template< typename Eol = eol::lf_crlf > @@ -247,7 +262,7 @@ They should be used "as if" this was the actual signature. The class `argv_input<>` can be used to parse a string passed from the command line. ```c++ -template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf > +template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > class argv_input { argv_input( char** argv, const std::size_t n ); @@ -272,22 +287,22 @@ 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 `dontcare` in order to not require rewinding of the input on local failure, a micro optimisation. The result of a parsing run, i.e. an invocation of `tao::pegtl::parse()`, can be either - *success*, a return value of `true`, - *local failure*, a return value of `false`, - *global failure*, an exception of type `tao::pegtl::parse_error`, or -- any other exception thrown by the input class or an action method. +- any other exception thrown by the input class or an action function. ```c++ 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, + apply_mode A = apply_mode::action, + rewind_mode M = rewind_mode::required, typename Input, typename... States > bool parse( Input& in, @@ -308,8 +323,8 @@ Everything else remains the same. 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, + apply_mode A = apply_mode::action, + rewind_mode M = rewind_mode::required, typename Outer, typename Input, typename... States > @@ -320,100 +335,193 @@ bool parse_nested( const Outer& oi, ## Incremental Input -The PEGTL is designed and optimised for parsing single contiguous blocks of memory, e.g. the contents of a file made available via `mmap(2)`, or the contents of a `std::string`. +The PEGTL is designed and optimised for parsing single contiguous blocks of memory like a memory-mapped file or the contents of a `std::string`. +In cases where the data does not fit into memory, or other reasons prevent parsing the data as single memory block, an *incremental* input can be used. + +This allows parsing with only (small) portions of the input in a memory buffer at any single time. +The buffer is filled automatically, however the [*discard* facilities](#discard-buffer) must be used to regularly flush the buffer and make space for a new portion of input data. -In cases where the input does not fit into memory, or there are other reasons to not create a single memory block containing all input data, it is possible, with a little help from the grammar, to perform incremental parsing, where the data is incrementally made available, e.g. when reading from a stream. +The [stream inputs](#stream-inputs) are ready-to-use input classes for C++-style and C-style streams. +Apart from having to use the [discard facilities](#discard-buffer), and some extra care when implementing [custom rules](#custom-rules), they can be used just like any other [input class](Inputs-and-Parsing.md). -### Grammars and Buffering +### Buffer Size -A buffer is used to keep a portion of the input data in a contiguous memory block. -The buffer is allocated at the begin of the parsing run with a user-supplied maximum size. +The [stream inputs](#stream-inputs), and all other inputs based on `buffer_input<>`, contain a buffer that is allocated in the constructor. +The buffer capacity is the sum of a *maximum* value and a *chunk* size. -The maximum buffer size usually depends on the grammar, the actions, and the input data. -It must be chosen large enough to keep the data required for (a) any backtracking, and (b) all action invocations. +The maximum value is passed to the constructor as function argument, the chunk size is a (rarely changed) template parameter. +The required buffer capacity depends on the grammar, the actions, *and* the input data. -The buffer is automatically filled by the parsing rules that require input data, however **discarding data from the buffer is** (currently) **not automatic**: -The grammar has to call [`discard`](Rule-Reference.md#discard) in appropriate places to free the buffer again. +The buffer must be able to hold -More precisely, each rule that uses one of the following methods on the input will implicitly make a call to `tao::pegtl::buffer_input<>::require( amount )`. -(The `empty()`-method uses a hard-coded `amount` of 1.) +* any and all data for look-ahead performed by the grammar, +* any and all data for back-tracking performed by the grammar, +* any and all data for actions' [`apply()`](Actions-and-States.md#apply) (not [`apply0()`](Actions-and-States.md#apply0)). + +For example consider an excerpt from the JSON grammar from `include/tao/pegtl/contrib/json.hpp`. ```c++ -namespace tao +struct xdigit : abnf::HEXDIG {}; +struct unicode : list< seq< one< 'u' >, rep< 4, must< xdigit > > >, one< '\\' > > {}; +struct escaped_char : one< '"', '\\', '/', 'b', 'f', 'n', 'r', 't' > {}; +struct escaped : sor< escaped_char, unicode > {}; +struct unescaped : utf8::range< 0x20, 0x10FFFF > {}; +struct char_ : if_then_else< one< '\\' >, must< escaped >, unescaped > {}; + +struct string_content : until< at< one< '"' > >, must< char_ > > {}; +struct string : seq< one< '"' >, must< string_content >, any > { - namespace pegtl - { - template< class Reader, typename Eol = eol::lf_crlf > - class buffer_input - { - empty(); - size( const std::size_t amount ); - end( const std::size_t amount ); - ... - }; - } -} + using content = string_content; +}; +``` + +The rule `string_content` matches JSON strings as they occur in a JSON document. +If an action with `apply()` (rather than `apply0()`) is attached to the `string_content` rule, the buffer capacity is an upper bound on the length of the JSON strings that can be processed. + +If the actions are only attached to say `unescaped`, `escaped_char` and `rep< 4, must< xdigit > >`, the latter because it, too, occurs in an (implicit, inside of `list`) unbounded loop, then the JSON strings are processed unescaped-character-by-unescaped-character and escape-sequence-by-escape-sequence. +As long as the buffer is [discarded](#discard-buffer) frequently, like after every unescaped character and every single escape sequence, a buffer capacity as small as 8 or 12 should suffice for parsing arbitrarily long JSON strings. + +Note that the [`eof`](Rule-Reference.md#eof) rule requires at least one byte of free buffer space when there is no unconsumed data in the buffer. + +### Discard Buffer + +To prevent the buffer from overflowing, the `discard()` member function of class `buffer_input<>` must be called regularly. + +**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.** + +#### 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`. + +#### Via Actions + +The `tao::pegtl::discard_input`, `tao::pegtl::discard_input_on_success` and `tao::pegtl::discard_input_on_failure` [actions](Actions-and-States.md) can be used to discard input non-intrusively, i.e. without changing the grammar like with the [`discard`](Rule-Reference.md#discard) rule. + +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. + +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. + +```c++ +template<> +struct my_action< R > + : tao::pegtl::discard_input +{ + // It is safe to implement apply() here if appropriate: + // discard() will be called by discard_input's match() + // only _after_ calling this action's apply(). +}; ``` -This tells the input that a rule wants to inspect and/or consume a certain `amount` of input bytes, and it will attempt to fill the buffer accordingly. -The returned `size()`, and the distance from `begin()` to `end()`, can also be larger than the requested amount. +In practice, since the "must"-rules like `must<>` and `if_must<>` inhibit backtracking, they can be good indicators of where to perform a discard. +For example consider again this rule from the JSON grammar from `include/tao/pegtl/contrib/json.hpp`. -For example, the rule `tao::pegtl::ascii::eol`, which (usually) checks for both `"\r\n"` and "`\n`", calls `size(2)` because it needs to inspect up to two bytes. -Depending on whether the result of `size(2)` is `0`, `1` or `2`, it will choose which of these two sequences it can attempt to match. -The number of actually consumed bytes can again be `0`, `1` or `2`, depending on whether they match a valid `eol`-sequence. +```c++ +struct unicode : list< seq< one< 'u' >, rep< 4, must< xdigit > > >, one< '\\' > > {}; +``` -To prevent the buffer from overflowing, the `discard()`-method of class `tao::pegtl::buffer_input` must be called, usually by using the `discard` parsing rule. -It discards all data in the buffer that precedes the current `begin()`-point, and any remaining data is moved to the beginning of the buffer. +The `xdigit` rule is within a `must`, wherefore we know that no backtracking is possible, so we could discard after `xdigit` or `must< xdigit >`. +However then we can't attach an action with [`apply()`](Actions-and-States.md#apply) to the `rep< 4, ... >` since we would be discarding after every single digit. +This is not ideal, it would be more efficient to process all four xdigits in a single action invocation. -**A `discard` 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.** +Looking close we can see that backtracking to before the `rep<>` is actually impossible because once the `list<>` has successfully matched `seq< one< 'u' >, rep< 4, must< xdigit > > >` it will never go back. +It will attempt to match another backslash, the list item separator, and if successful loop to the `seq<>`, but once the next character is a `'u'`, the `must<>` in the `rep` seals the deal, there is no way to not complete the next list entry. +Therefore we can safely attach an action to the `rep<>` that processes the four xdigits and then discards the input. + +```c++ +template<> +struct my_action< rep< 4, must< xdigit > > + : tao::pegtl::discard_input +{ + template< typename Input > + void apply( const Input& in, /* the states */ ) + { + assert( in.size() == 4 ); + // process the 4 xdigits + } +}; ``` -Buffer Memory Layout - -B begin of buffer space -: -B + X begin of unconsumed buffered data as per begin() -: -B + X + size( 0 ) end of unconsumed buffered data as per end( 0 ) -: -B + maximum end of buffer space + +Another good candidate in the JSON grammar to discard after is the `tao::pegtl::json::value` rule... + +### Custom Rules + +All incremental inputs included with the library and documented here are based on `buffer_input<>`. +A custom rule that is compatible with incremental inputs needs to pay attention to the `amount` argument in the input's interface. +Unlike the inputs based on `memory_input<>`, the `size( amount )` and `end( amount )` member functions do not ignore the `amount` argument, and the `require( amount )` member function is not a complete dummy. + +```c++ +template< ... > +class buffer_input +{ + bool empty(); + std::size_t size( const std::size_t amount ); + const char* end( const std::size_t amount ); + void require( const std::size_t amount ); + ... +}; ``` -A discard moves the data in the buffer such that `X` is zero, and updates `begin()` to point at the beginning of the buffer. +The `require( amount )` member function tells the input to make available at least `amount` unconsumed bytes of input data. +It is not normally called directly unless there is good reason to prefetch some data. + +The `empty()`, `size( amount )` and `end( amount )` member functions call `require( amount )`, or, in the case of `empty()`, `require( 1 )`. +The `amount` parameter should be understood as a parsing rule wishing to inspect and consume *up to* `amount` bytes of input. -### Custom Data Sources +A custom rule must make sure to use appropriate values of `amount`. +For examples of how the `amount` is set by parsing rules please search for `in.size` in `include/tao/pegtl/internal/`. -The PEGTL contains a set of stream parser input classes that take care of everything (except discarding data from the buffer, see above) for certain data sources. -In order to support other data sources, it is necessary to create a custom input class, usually by creating a suitable *reader* class that can be supplied as template argument to class `tao::pegtl::buffer_input<>`. +### Custom Readers -The reader class can be anything that can be called like the following standard function wrapper: +An incremental input consists of `buffer_input<>` together with a *reader*, a class or function that is used by the buffer input to fill the buffer. + +The buffer input is a class template with multiple template parameters. + +```c++ +template< typename Reader, + typename Eol = eol::lf_crlf, + typename Source = std::string, + std::size_t Chunk = 64 > +class buffer_input; +``` + +The `Eol` and `Source` parameters are like for the other [input classes](Inputs-and-Parsing.md#memory-input). +The `Chunk` parameter is explained below in detail. +The `Reader` can be anything that can be called like the following wrapper. ```c++ std::function< std::size_t( char* buffer, const std::size_t length ) > ``` -The arguments and return value are similar to other `read()`-style functions: -Attempt to read up to `length` bytes into the memory pointed to by `buffer` and return the number of bytes actually read. -Reaching the end of the input should be the only reason for the reader to return zero. +The arguments and return value are similar to other `read()`-style functions, a request to read `length` bytes into the memory pointed to by `buffer` that returns the number of bytes actually read. +Reaching the end of the input MUST be the only reason for the reader to return zero. +The reader might be called again after returning zero, with the expectation of returning zero again. + +Note that `buffer_input<>` consumes the first two arguments to its constructor for the *source* and *maximum*, and uses perfect forwarding to pass everything else to the constructor of the embedded instance of `Reader`. -The steps required to use a custom reader for a parsing run are: +For examples of how to implement readers please look at `istream_reader.hpp` and `cstream_reader.hpp` in `include/tao/pegtl/internal/`. -1. Create a suitable reader class `Reader` (or function). -2. Create an instance of class `tao::pegtl::buffer_input< Reader >`, using the fact that the `buffer_input`'s constructor can pass arbitrary arguments to the embedded reader instance. -3. Call `tao::pegtl::parse()` (or `tao::pegtl::parse_nested()`) with the previously created `buffer_input` instance as first argument. +### Buffer Details -The included examples for C- and C++-style streams can also be used as reference on how to create and use suitable readers, simply `grep(1)` for `cstream_reader` and `istream_reader` (and `cstring_reader`) in the PEGTL source code. +The buffer input's `Chunk` template parameter is actually used in multiple places. + +1. The `maximum` buffer capacity passed by the user is incremented by `Chunk`. +2. A discard does nothing when there are less than `Chunk` bytes of consumed buffered data. +3. The buffer input requests at least `Chunk` bytes from the reader if there is enough space. + +Note that the first and second point go hand-in-hand, in order to optimise away some discards, the buffer must be extended in order to guarantee that at least `maximum` bytes can be buffered after a call to discard, even when it does nothing. The third point is simply an optimisation to call the reader less frequently. ## Error Reporting When reporting an error, one often wants to print the complete line from the input where the error occurred and a marker at the position where the error is found within that line. -To support this, the `memory_input<>` class has methods `at( p )`, `begin_of_line( p )`, `end_of_line( p )` and `line_as_string( p )` which take a `tao::pegtl::position` as parameter. -The first three methods return a `const char*` to position `p`, the begin-of-line before `p`, or the end-of-line after `p` (or the end of the input if the input is not terminated by an end-of-line), respectively. -For convenience, `line_as_string( p )` returns a `std::string` with the complete line around `p`. +To support this, the `memory_input<>` class has member functions `at( p )`, `begin_of_line( p )`, `end_of_line( p )` and `line_at( p )` which take a `tao::pegtl::position` as parameter. +The first three functions return a `const char*` to position `p`, the begin-of-line before `p`, or the end-of-line after `p` (or the end of the input if the input is not terminated by an end-of-line), respectively. +For convenience, `line_at( p )` returns a `std::string_view` with the complete line around `p`. Example usage: ```c++ - // create input 'in' here... try { // call parse on the input 'in' here... @@ -421,16 +529,16 @@ try { catch( const parse_error& e ) { const auto p = e.positions.front(); std::cerr << e.what() << std::endl - << in.line_as_string( p ) << std::endl + << in.line_at( p ) << std::endl << std::string( p.byte_in_line, ' ' ) << '^' << std::endl; } ``` All input classes based on `memory_input<>` support the above, while all classes based on `buffer_input<>` are unable to supply the same functionality as previous input might have been discarded already. -Trying to call any of those methods on `buffer_input<>`-based instances will lead to a compile error. +Trying to call any of those functions on `buffer_input<>`-based instances will lead to a compile error. -## C++17 Deduction Guides +## Deduction Guides -All input classes support C++17's [deduction guides](https://en.cppreference.com/w/cpp/language/class_template_argument_deduction) when compiling with C++17 or newer, e.g. instead of `file_input<> in( "filename.txt" )` one can use `file_input in( "filename.txt" )`. +All input classes support [deduction guides](https://en.cppreference.com/w/cpp/language/class_template_argument_deduction), e.g. instead of `file_input<> in( "filename.txt" )` one can use `file_input in( "filename.txt" )`. -Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey diff --git a/packages/PEGTL/doc/Installing-and-Using.md b/packages/PEGTL/doc/Installing-and-Using.md index 7c3ab624b..d0b78a470 100644 --- a/packages/PEGTL/doc/Installing-and-Using.md +++ b/packages/PEGTL/doc/Installing-and-Using.md @@ -4,20 +4,28 @@ * [Requirements](#requirements) * [Installation Packages](#installation-packages) -* [CMake Installation](#cmake-installation) +* [Using CMake](#using-cmake) + * [CMake Installation](#cmake-installation) + * [`find_package`](#find_package) + * [`add_subdirectory`](#add_subdirectory) + * [Mixing `find_package` and `add_subdirectory`](#mixing-find_package-and-add_subdirectory) +* [Conan](#conan) + * [Using a development version](#using-a-development-version) + * [Developing with conan editable](#developing-with-conan-editable) * [Manual Installation](#manual-installation) * [Embedding the PEGTL](#embedding-the-pegtl) * [Embedding in Binaries](#embedding-in-binaries) * [Embedding in Libraries](#embedding-in-libraries) * [Embedding in Library Interfaces](#embedding-in-library-interfaces) +* [Single Header Version](#single-header-version) ## Requirements -The PEGTL requires a C++11-capable compiler, e.g. one of +The PEGTL requires a C++17-capable compiler, e.g. one of -* GCC 4.8 -* Clang 3.4 -* Visual Studio 2015 +* GCC 7 +* Clang 5 +* Visual Studio 2017 on either @@ -25,10 +33,10 @@ on either * macOS * Windows -It requires C++11, e.g. using the `--std=c++11` compiler switch. +It requires C++17, e.g. using the `--std=c++17` compiler switch. Using newer versions of the C++ standard is supported. -It should also work with other C++11 compilers on other Unix systems (or any sufficiently compatible platform). +It should also work with other C++17 compilers on other Unix systems (or any sufficiently compatible platform). The PEGTL is written with an emphasis on clean code and is compatible with the `-pedantic`, `-Wall`, `-Wextra` and `-Werror` compiler switches. @@ -44,7 +52,9 @@ Installation packages are available from several package managers. Note that som * [Conan] * [Spack] -## CMake Installation +## Using CMake + +### CMake Installation The PEGTL can be built and installed using [CMake], e.g. @@ -56,14 +66,127 @@ $ make $ make install ``` -The above will install the PEGTL into the standard installation path on a -UNIX system, e.g. `/usr/local/include/`. To change the installation path, use: +The above will install the PEGTL into the standard installation path on a UNIX +system, e.g. `/usr/local/include/`. To change the installation path, use: ```sh $ cmake .. -DCMAKE_INSTALL_PREFIX=../install ``` -in the above. For more options and ways to use CMake, please refer to the [CMake documentation]. +in the above. + +### `find_package` + +Installation creates a `pegtl-config.cmake` which allows CMake +projects to find the PEGTL using `find_package`: + +```cmake +find_package(pegtl) +``` + +This exports the `taocpp::pegtl` target which can be linked against any other +target. Linking against `taocpp:pegtl` automatically sets the include +directories and required flags for C++17 or later. For example: + +```cmake +add_executable(myexe mysources...) +target_link_libraries(myexe PRIVATE taocpp::pegtl) +``` + +### `add_subdirectory` + +The PEGTL can also be added as a dependency with `add_subdirectory`: + +```cmake +add_subdirectory(path/to/PEGTL) +``` + +This also exports the `taocpp::pegtl` target which can be linked against any +other target just as with the installation case. + +Due to the global nature of CMake targets the target `pegtl` is also defined, +but only `taocpp::pegtl` should be used for consistency. + +If `PEGTL_BUILD_TESTS` is true then the test targets, `pegtl-test-*`, are also +defined and their corresponding tests registered with `add_test`. +If `PEGTL_BUILD_EXAMPLES` is true then the example targets, `pegtl-example-*`, +are also defined. + +### Mixing `find_package` and `add_subdirectory` + +With the advent of improved methods of managing dependencies (such as [Conan], +[Spack], [CMake FetchContent]), multiple package inclusion methods needs to be +able to co-exist. + +If PEGTL was first included with `find_package` then subsequent calls to +`add_subdirectory(path/to/PEGTL)` will skip over the body of the +`CMakeLists.txt` and use the installed package if the version matches. +If the version does not match a fatal error will be signalled. + +If PEGTL was first included with `add_subdirectory` then a dummy +`pegtl-config.cmake` is created and `pegtl_DIR` is set. Subsequent calls to +`find_package(pegtl)` will then use the already added package if the version +matches. If the version does not match a fatal error will be signalled. + +Since CMake targets are global, there exists no way for a CMake project to use +two different versions of PEGTL simultaneously and signalling a fatal error +becomes the only practical way of handling the inclusion of multiple different +PEGTL versions. + +For more options and ways to use CMake, please refer to the +[CMake documentation]. + +Conan +--- + +The [PEGTL conan package](https://bintray.com/taocpp/public-conan/pegtl%3Ataocpp) is automatically updated when a release is made, and it should always be up to date with the latest official release. + +Simply add + +```ini +pegtl/<version>@taocpp/stable +``` + +as a dependency to your conan project where `<version>` is the version of PEGTL you want to use. + +### Using a development version + +If a not yet released PEGTL version is required, then PEGTL can be exported in its current state. + +```bash +mkdir build +conan install -if build +conan export-pkg -if build -bf build . pegtl/<version>@taocpp/devel +``` + +Then proceed by adding + +```ini +pegtl/<version>@taocpp/devel +``` + +as a dependency to your conan project. + +### Developing with conan editable + +If it is required to develop PEGTL alongside another library/application then the package can be put into editable mode with + +```bash +conan editable add . pegtl/<version>@taocpp/devel +``` + +If the editable layout has `[builddirs]` set correctly and one is using the `cmake_paths` or `cmake`generator + +```cmake +find_package(pegtl) +``` + +will work as expected. It will find the editable package and add it to the current CMake project. An editable package implies that it is under development so tests and examples will be automatically built unless `PEGTL_BUILD_TESTS` and `PEGTL_BUILD_EXAMPLES` are turned off. + +Caveats with the editable package: + +- Currently, if the package is included with `CONAN_PKG::pegtl` or used in a build system other than CMake then the tests and examples won't be built as the CMake config script is bypassed. +- CMake will compulsively rebuild tests and examples if the build directory is reconfigured from another directory. ## Manual Installation @@ -113,12 +236,11 @@ or patch releases, libraries *have* to ensure that the symbols for the PEGTL they include differ from those of the applications that use them. This can be achieved by changing the macro `TAO_PEGTL_NAMESPACE` which, by -default, is set to `pegtl`, which leads to all symbols residing in namespace -`tao::pegtl`. To change the namespace, simply define `TAO_PEGTL_NAMESPACE` -to a unique name before including the PEGTL, for example: +default, is set to `tao::pegtl`. To change the namespace, simply define +`TAO_PEGTL_NAMESPACE` to a unique name before including the PEGTL, for example: ```c++ -#define TAO_PEGTL_NAMESPACE mylib_pegtl +#define TAO_PEGTL_NAMESPACE mylib::pegtl #include <tao/pegtl.hpp> #include <tao/contrib/json.hpp> @@ -126,8 +248,8 @@ to a unique name before including the PEGTL, for example: int main( int argc, char* argv[] ) { if( argc > 1 ) { - tao::mylib_pegtl::argv_input<> in( argv, 1 ); - tao::mylib_pegtl::parse< tao::mylib_pegtl::json::text >( in ); + mylib::pegtl::argv_input in( argv, 1 ); + mylib::pegtl::parse< mylib::pegtl::json::text >( in ); } } @@ -141,29 +263,34 @@ application's and the library's copy of the PEGTL use the same macro names. In this case it is necessary to change the prefix of all macros of the embedded PEGTL from `TAO_PEGTL_` to another unique string in order to prevent macros -from clashing. In a Unix-shell, the following commands will achieve this: +from clashing. In a Unix-shell, the following command will achieve this: ```sh -$ sed -i 's/TAO_PEGTL_/MYLIB_TAO_PEGTL_/g' $(find -name '[^.]*.[hc]pp') -$ sed -i 's/TAOCPP_PEGTL_/MYLIB_TAOCPP_PEGTL_/g' $(find -name '[^.]*.[hc]pp') +$ sed -i 's/TAO_PEGTL_/MYLIB_PEGTL_/g' $(find -name '[^.]*.[hc]pp') ``` -The above commands needs to run from the top-level directory of the embedded -PEGTL. Additionally, `MYLIB_TAO_PEGTL_NAMESPACE` needs to be set as explained +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. -Note that the second command is only needed because the PEGTL contains -some compatibility macros for older versions that start with `TAOCPP_PEGTL_` -instead of `TAO_PEGTL_`. Those older compatibility macros will be removed -in version 3.0. Starting with version 2.4.0 you should only use macros -that start with `TAO_PEGTL_`. - A practical example of how the result looks like can be found in our own -header-only [JSON library](https://github.com/taocpp/json/). +header-only JSON library [taoJSON](https://github.com/taocpp/json/). + +## Single Header Version + +You can generate a single-header-version of the PEGTL with the included `Makefile`. +In a Unix-shell, the following command will achieve this: + +```sh +$ make amalgamate +``` + +The above will generate a `build/amalgamated/pegtl.hpp` which will consist of the headers `tao/pegtl.hpp`, `tao/pegtl/analyze.hpp`, their dependencies, and all headers in `tao/pegtl/contrib/` except for the headers in `tao/pegtl/contrib/icu/`. -Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey [CMake]: https://cmake.org/ [CMake documentation]: https://cmake.org/documentation/ +[CMake FetchContent]: https://cmake.org/cmake/help/latest/module/FetchContent.html [Conan]: https://bintray.com/taocpp/public-conan/pegtl%3Ataocpp [Spack]: http://spack.readthedocs.io/en/latest/package_list.html#pegtl diff --git a/packages/PEGTL/doc/Migration-Guide.md b/packages/PEGTL/doc/Migration-Guide.md index 6b8c95af9..a63ee5b5e 100644 --- a/packages/PEGTL/doc/Migration-Guide.md +++ b/packages/PEGTL/doc/Migration-Guide.md @@ -1,17 +1,35 @@ # Migration Guide +## Version 3.0.0 + +* The build system needs to be configured for C++17 or later. +* The macro `TAO_PEGTL_NAMESPACE` now defines the fully qualified namespace and was changed from `pegtl` to `tao::pegtl`. When setting `TAO_PEGTL_NAMESPACE`, adapt as needed; in case of doubt, add `tao::` as prefix. +* The control class template's `apply()` and `apply0()` must only be visible (e.g. via SFINAE) when an action class template function with the appropriate signature exists. See `tao::pegtl::normal` as example. +* The error message from `tao::pegtl::parse_error` no longer contains the position as a prefix. The positions are available from the `positions` member variable. +* If you have a use-case for [state](Rule-Reference.md#state-s-r-)'s `S::success()` to have an extended signature to get access to the current `apply_mode`, `rewind_mode`, *action*- and *control* class (template), please let us know and we'll re-add this feature. +* The compatibility macros starting with `TAOCPP_PEGTL_` were removed, the corresponding `TAO_PEGTL_`-prefixed macros must be used. +* The compatibility uppercase enumerators were removed, the corresponding lowercase enumerators must be used. +* The compatibility `peek_byte()` member functions were removed, the `peek_uint8()` member functions must be used. +* The compatibility header `changes.hpp` was removed, use the action-based `change_*.hpp` headers. + +## Version 2.8.0 + +* All enumerators were changed from uppercase to lowercase. +* The enumerator `tracking_mode::IMMEDIATE` was renamed to `tracking_mode::eager`. +* The input-classes' `peek_byte()` member function was renamed to `peek_uint8()`. + +Compatibility enumerators and functions are provided, they will be removed in version 3.0.0. + ## Version 2.4.0 -The common prefix for all macros was changed from `TAOCPP_PEGTL_` to `TAO_PEGTL_`. +* The common prefix for all macros was changed from `TAOCPP_PEGTL_` to `TAO_PEGTL_`. -Compatibility macros can still be used, the library should be fully compatible when -used with older macros. Note, however, that the old macros will be removed in a -future version 3.0. Consider updating your macro prefixes now. +Compatibility macros are provided, they will be removed in version 3.0.0. -## From 1.y to 2.z +## Version 2.0.0 Some of the [changes](Changelog.md#200) for version 2.0.0 require modifications to any source using the PEGTL. -The good news is that the semantics of all parsing rules and grammars is the same as for versions 1.y. +The good news is that the semantics of all parsing rules and grammars is the same as for versions 1.x. Existing grammars will continue to work as before once the following list of mostly naming and namespace related changes is taken into account. * Everything in the PEGTL is now in namespace `tao::pegtl`. @@ -19,8 +37,8 @@ Existing grammars will continue to work as before once the following list of mos * The main include file is now `<tao/pegtl.hpp>`, all other include files are `<tao/pegtl/*.hpp>`. * The distribution of tasks between [the parse functions and input classes](Inputs-and-Parsing.md) was changed. * The string macros have been renamed from `pegtl_(i)string_t` to `TAOCPP_PEGTL_(I)STRING`. -* The `begin()` method of the input-classes is now called `current()`. -* The first argument to actions' `apply()`-methods is now of type `tao::pegtl::internal::action_input< ... >`. +* The `begin()` member function of the input-classes is now called `current()`. +* The first argument to actions' `apply()` is now of type `tao::pegtl::internal::action_input< ... >`. For flexibility and future compatibility it is recommended to "template over" the first argument to `apply()` as shown in [Actions and States](Actions-and-States.md#actions). @@ -31,9 +49,9 @@ Applications integrated more tightly with the PEGTL might require additional cha Please contact the authors at `taocpp(at)icemx.net` for any further questions when updating the PEGTL. -## From 0.x to 1.y or 2.z +## Version 1.0.0 There were [many important changes](Changelog.md#100) leading up to version 1.0.0. Please contact the authors at `taocpp(at)icemx.net` for any further questions when updating the PEGTL. -Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey diff --git a/packages/PEGTL/doc/Parse-Tree.md b/packages/PEGTL/doc/Parse-Tree.md index 961ecba1e..cc1f31923 100644 --- a/packages/PEGTL/doc/Parse-Tree.md +++ b/packages/PEGTL/doc/Parse-Tree.md @@ -1,34 +1,51 @@ # Parse Tree -The PEGTL provides facilities for building a [parse tree](https://en.wikipedia.org/wiki/Parse_tree) / [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree) in the header +The PEGTL provides facilities for building a [parse tree](https://en.wikipedia.org/wiki/Parse_tree) (or [AST](https://en.wikipedia.org/wiki/Abstract_syntax_tree)). -```c++ -#include <tao/pegtl/contrib/parse_tree.hpp> -``` +It provides the basic infrastructure to build a parse tree that -It provides the basic infrastructure to build a parse tree and: - -* Builds a full parse tree (one node for each matched rule) by default. -* Includes a default node class to hold parse tree information. -* Supports custom node classes to contain additional information. -* Supports a selector class template to choose which nodes to store in the parse tree. -* Supports a transform method in the selector specialization for custom modifications of the tree. +* by default is *complete*, with one tree node for every successfully matched rule, + * with an optional *selection* to only generate nodes for a chosen subset of rules; +* by default uses the included tree node class that stores all pertinent information, + * but can also be used with a custom tree node class that adheres to certain rules; +* and supports on-the-fly tree transformations; some of the more common ones are included. > The parse tree / AST part of the PEGTL is currently in active development and serves as a prove-of-concept, expect changes at any time. Try it out, experiment with it, and most importantly let us know what you think of it. We need **your** feedback! +## Content + +* [Full Parse Tree](#full-parse-tree) +* [Partial Parse Tree](#partial-parse-tree) +* [Transforming Nodes](#transforming-nodes) +* [Transformers](#transformers) +* [`tao::pegtl::parse_tree::node`](#taopegtlparse_treenode) +* [Custom Node Class](#custom-node-class) + ## Full Parse Tree -To obtain a full parse tree, call the `tao::pegtl::parse_tree::parse()`-method with a grammar and an input: +To obtain a (complete) parse tree, simply call `tao::pegtl::parse_tree::parse()` with a grammar and an input. ```c++ +#include <tao/pegtl/contrib/parse_tree.hpp> + auto root = tao::pegtl::parse_tree::parse< my_grammar >( in ); ``` -The result is a `std::unique_ptr< tao::pegtl::parse_tree::node >`. The pointer is empty when the input did not match the grammar, otherwise it contains the root node of the resulting parse tree. Intermediate nodes from rules which did not match will be removed automatically. +The result is a `std::unique_ptr< tao::pegtl::parse_tree::node >`. +The pointer is empty when the input did not match the grammar, otherwise it contains the root node of the resulting parse tree. + +The tree nodes have a `name()` member function that returns the name of the grammar rule of which it represents a successful match, `begin()` and `end()` member functions to access the position of the matched portion of the input, `string()` and `string_view()` to actually access said matched input, and a vector called `children` with unique pointers to the child nodes. + +Note that the included tree node class **points** to the matched data, rather than copying it into the node, wherefore the input **must** still be "alive" when accessing the matched data! + +A more complete description of the included tree node class can be found below. ## Partial Parse Tree -When a full parse tree with nodes for all rules is too much it is possible to supply a second template parameter to the `parse_tree::parse()` function that controls which rules get a parse tree node. This second template parameter `S` is itself a class template. For each rule `Rule` that matched, a node is generated only when `S<Rule>::value` is `true`. It is then possible to select the rules that should generate nodes as follows: +Usually only a subset of grammar rules should generate parse tree nodes. +In order to select the grammar rules for which a successful match is to generate a parse tree node, a second template parameter can be passed to `parse_tree::parse()`. +This parameter is a class template that is called a *selector*. +For each rule `Rule`, the boolean value `selector< Rule >::value` determines whether a parse tree node is generated. ```c++ template< typename Rule > struct my_selector : std::false_type {}; @@ -41,11 +58,32 @@ template<> struct my_selector< my_rule_3 > : std::true_type {}; auto root = tao::pegtl::parse_tree::parse< my_grammar, my_selector >( in ); ``` -The above style is a white-list, where the default is `std::false_type` and you explicitly list those rules which will generate a node. Of course, you can also set the default to `std::true_type` and explicitly list the rules that are *not* to generate a node (black-list style). +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. + +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. + +```c++ +template< typename Rule > +using my_selector = tao::pegtl::parse_tree::selector< Rule, + tao::pegtl::parse_tree::store_content::on< + my_rule_1, + my_rule_2, + my_rule_3 > >; + +// ... + +auto root = tao::pegtl::parse_tree::parse< my_grammar, my_selector >( in ); +``` + +Note that `store_content` further specifies that the information about the matched portion of the input be stored in the generated nodes; other possibilities are discussed below. ## Transforming Nodes -A parse tree, full or partial, can still be too closely related to the structure of the grammar. In order to simplify the tree (or otherwise improve its structure), an optional `transform()` method can be added to each specialization of the selector class template (that generates a node). This methods gets passed a reference to the current node, which also gives access to the children, but not to the parent: +A parse tree, full or partial, can still be too closely related to the structure of the grammar. +In order to simplify the tree (or otherwise improve its structure), an optional `transform()` static member function can be added to each specialization of the selector class template (that generates a node). +This function gets passed a reference to the current node, which also gives access to the children, but not to the parent: ```c++ template<> struct my_selector< my_rule_2 > : std::true_type @@ -57,82 +95,145 @@ template<> struct my_selector< my_rule_2 > : std::true_type }; ``` -You can transform `n` in almost any way you can imagine, the [`parse_tree.cpp`](https://github.com/taocpp/PEGTL/blob/master/src/example/pegtl/parse_tree.cpp)-example shows two techniques for marking nodes as "content-less", and for actual transformations of the parse tree into an AST. +`transform` can modify `n` in any way you like, the [`parse_tree.cpp`](https://github.com/taocpp/PEGTL/blob/master/src/example/pegtl/parse_tree.cpp)-example shows two techniques for marking nodes as "content-less", and for transforming the parse tree into an AST. + +It is also possible to call `n.reset()`, or otherwise set `n` to an empty pointer, which effectively removes `n` (and all of its child nodes) from the parse tree. -There is another option not shown in the example: You can call `n.reset()` before returning from `transform()`. This prevents the node from being added to its parent. It removes the node (as well as all of its children) from the generated parse tree. +## Transformer + +As shown above, the selector class template allows to specify which nodes should be stored. Several additional helper classes are predefined that have common `transform` methods. The selector allows to add multiple sections with different helpers like this: + +```c++ +template< typename Rule > +using my_selector = tao::pegtl::parse_tree::selector< Rule, + tao::pegtl::parse_tree::store_content::on< + my_rule_1, + my_rule_2, + my_rule_3 >, + tao::pegtl::parse_tree::remove_content::on< + my_rule_4, + my_rule_5 >, + tao::pegtl::parse_tree::apply< my_helper >::on< + my_rule_7, + my_rule_8 > >; +``` + +Note that each rule may only be used in one section, it is an error to add a rule to multiple sections. + +`store_content` and `remove_content` are predefined by the library, whereas `my_helper` can be defined by yourself. + +###### `tao::pegtl::parse_tree::store_content` + +This stores the node, including pointing to the content it matched on. + +###### `tao::pegtl::parse_tree::remove_content` + +This stores the node, but calls the node's `remove_content` member function. + +###### `tao::pegtl::parse_tree::fold_one` + +This stores the node, but when a node has exactly one child, the node replaces itself with this child, otherwise removes its own content (not children). + +###### `tao::pegtl::parse_tree::discard_empty` + +This stores the node, except for when the node does *not* have any children, in which case it removes itself, otherwise removes its own content (not children). + +### Example + +An example of using some of the transformers can be found in `src/example/pegtl/abnf2pegtl.cpp`. ## `tao::pegtl::parse_tree::node` -This is the default node class used by `tao::pegtl::parse_tree::parse` if no custom node class is specified. In that case, the root node, as well as all (nested) child nodes, provide the following interface: +This is the interface of the node class used by `tao::pegtl::parse_tree::parse` when no custom node class is specified. ```c++ -struct node +template< typename T > +struct basic_node { - std::vector< std::unique_ptr< node > > children; + using node_t = T; + using children_t = std::vector< std::unique_ptr< node_t > >; - bool is_root() const noexcept(); + children_t children; + std::type_index id; + std::string source; + + template< typename U > + bool is() const noexcept { return id == typeid( U ); } + + bool is_root() const noexcept; // precondition from here on: !is_root() std::string name() const; - bool has_content() const noexcept(); - std::string content() const; // precondition: has_content() + position begin() const; + position end() const; + + bool has_content() const noexcept; + std::string_view string_view() const noexcept; // precondition: has_content() + std::string string() const; // precondition: has_content() - std::string source() const; + template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > + memory_input< P, Eol > as_memory_input() const; // useful for transform: void remove_content(); }; + +struct node : basic_node< node > {}; ``` -The name is the demangled name of the rule. By default all nodes (except the root node) can provide the content that matched, i.e. the part of the input that the rule the node was created for matched. You only need to check `has_content()` if you previously used `remove_content()` in your transform methods, otherwise there will always be content (except for at the root). +The name is the demangled name of the rule. By default, all nodes (except the root node) can provide the content that matched, i.e. the part of the input that the rule the node was created for matched. It is only necessary to check `has_content()` when `remove_content()` was used by a transform function (either directly or indirectly via one of the convenience helpers), otherwise all nodes except for the root will always "have content". -See the [`parse_tree.cpp`](https://github.com/taocpp/PEGTL/blob/master/src/example/pegtl/parse_tree.cpp)-example for more information how to output (or otherwise use) the nodes. +See [`parse_tree.cpp`](https://github.com/taocpp/PEGTL/blob/master/src/example/pegtl/parse_tree.cpp) for more information on how to output (or otherwise use) the nodes. ## Custom Node Class -If you need more control over how data is stored/handled in the nodes, you can provide your own node class. You can add it to the parse call as an additional template parameter after the rule: +For more control over how data is stored/handled in the nodes, a custom node class can be utilised. +The type of node is passed as an additional template parameter to the parse tree `parse()` function. ```c++ auto r1 = tao::pegtl::parse_tree::parse< my_grammar, my_node >( in ); auto r2 = tao::pegtl::parse_tree::parse< my_grammar, my_node, my_selector >( in ); ``` -Note that `my_node` is a class type while `my_selector` is a class template. If you provide your own node class, it must provide the following interface: +Note that `my_node` is a class, while `my_selector` is a class template. A custom node class must implement the following interface. ```c++ struct my_node { - // it must be default constructible + // Must be default constructible my_node() = default; - // no copy/move is necessary - // (nodes are always owned/handled by a std::unique_ptr) + // Nodes are always owned/handled by a std::unique_ptr + // and never copied or assigned... my_node( const my_node& ) = delete; my_node( my_node&& ) = delete; + my_node& operator=( const my_node& ) = delete; + my_node& operator=( my_node&& ) = delete; - // it must be destructible + // Must be destructible ~my_node() = default; - // no assignment necessary - my_node& operator=( const my_node& ) = delete; - my_node& operator=( my_node&& ) = delete; + // All non-root nodes receive a call to start() when + // a match is attempted for Rule in a parsing run... + template< typename Rule, typename Input, typename... States > + void start( const Input& in, States&&... st ); - // all non-root nodes are initialized by calling this method - template< typename Rule, typename Input > - void start( const Input& in ); + // ...and later a call to success() when the match succeeded... + template< typename Rule, typename Input, typename... States > + void success( const Input& in, States&&... st ); - // if parsing of the rule succeeded, this method is called - template< typename Rule, typename Input > - void success( const Input& in ); + // ...or to failure() when a (local) failure was encountered. + template< typename Rule, typename Input, typename... States > + void failure( const Input& in, States&&... st ); - // if parsing succeeded and the (optional) transform call - // did not discard the node, it is appended to its parent. - // note that "child" is the node whose Rule just succeeded - // and *this is the parent where the node should be appended. - void append( std::unique_ptr< my_node > child ); + // After a call to success(), and the (optional) call to the selector's + // transform() did not discard a node, it is passed to its parent node + // with a call to the parent node's emplace_back() member function. + template< typename... States > + void emplace_back( std::unique_ptr< node_t > child, States&&... st ); }; ``` -Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey diff --git a/packages/PEGTL/doc/Parse-Tree.png b/packages/PEGTL/doc/Parse-Tree.png new file mode 100644 index 0000000000000000000000000000000000000000..fcacd0611dbb67c7516dbc0df9c54211d21d3ae9 GIT binary patch literal 59564 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 Hr-UW|J)&VW literal 0 HcmV?d00001 diff --git a/packages/PEGTL/doc/Performance-Notes.md b/packages/PEGTL/doc/Performance-Notes.md index 699319d28..43198177d 100644 --- a/packages/PEGTL/doc/Performance-Notes.md +++ b/packages/PEGTL/doc/Performance-Notes.md @@ -42,4 +42,4 @@ However with `-O0`, the optimised `at_one< '"' >` was faster by 5-10% in a [JSON We still need to test whether the compiler manages to perform the same optimisation in more complex cases. -Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey diff --git a/packages/PEGTL/doc/README.md b/packages/PEGTL/doc/README.md index 4fc2c5e2d..4f98196ac 100644 --- a/packages/PEGTL/doc/README.md +++ b/packages/PEGTL/doc/README.md @@ -5,13 +5,17 @@ * [Installing and Using](Installing-and-Using.md) * [Requirements](Installing-and-Using.md#requirements) * [Installation Packages](Installing-and-Using.md#installation-packages) - * [CMake Installation](Installing-and-Using.md#cmake-installation) + * [Using CMake](Installing-and-Using.md#using-cmake) + * [CMake Installation](Installing-and-Using.md#cmake-installation) + * [`find_package`](Installing-and-Using.md#find_package) + * [`add_subdirectory`](Installing-and-Using.md#add_subdirectory) + * [Mixing `find_package` and `add_subdirectory`](Installing-and-Using.md#mixing-find_package-and-add_subdirectory) * [Manual Installation](Installing-and-Using.md#manual-installation) * [Embedding the PEGTL](Installing-and-Using.md#embedding-the-pegtl) * [Embedding in Binaries](Installing-and-Using.md#embedding-in-binaries) * [Embedding in Libraries](Installing-and-Using.md#embedding-in-libraries) * [Embedding in Library Interfaces](Installing-and-Using.md#embedding-in-library-interfaces) - * [Limitations](Installing-and-Using.md#limitations) + * [Single Header Version](Installing-and-Using.md#single-header-version) * [Rules and Grammars](Rules-and-Grammars.md) * [Combining Existing Rules](Rules-and-Grammars.md#combining-existing-rules) * [Toy S-Expression Grammar](Rules-and-Grammars.md#toy-s-expression-grammar) @@ -19,16 +23,26 @@ * [Simple Rules](Rules-and-Grammars.md#simple-rules) * [Complex Rules](Rules-and-Grammars.md#complex-rules) * [Actions and States](Actions-and-States.md) - * [Actions](Actions-and-States.md#actions) - * [Apply0](Actions-and-States.md#apply0) - * [Apply](Actions-and-States.md#apply) + * [Overview](Actions-and-States.md#overview) + * [Example](Actions-and-States.md#example) * [States](Actions-and-States.md#states) - * [Action Specialisation](Actions-and-States.md#action-specialisation) + * [Apply](Actions-and-States.md#apply) + * [Apply0](Actions-and-States.md#apply0) + * [Inheriting](Actions-and-States.md#inheriting) + * [Specialising](Actions-and-States.md#specialising) * [Changing Actions](Actions-and-States.md#changing-actions) + * [Via Rules](Actions-and-States.md#via-rules) + * [Via Actions](Actions-and-States.md#via-actions) * [Changing States](Actions-and-States.md#changing-states) - * [No Switching](Actions-and-States.md#no-switching) - * [Intrusive Switching](Actions-and-States.md#intrusive-switching) - * [External Switching](Actions-and-States.md#external-switching) + * [Via Rules](Actions-and-States.md#via-rules-1) + * [Via Actions](Actions-and-States.md#via-actions-1) + * [Changing Actions and States](Actions-and-States.md#changing-actions-and-states) + * [Match](Actions-and-States.md#match) + * [Nothing](Actions-and-States.md#nothing) + * [Troubleshooting](Actions-and-States.md#troubleshooting) + * [Boolean Return](Actions-and-States.md#boolean-return) + * [State Mismatch](Actions-and-States.md#state-mismatch) + * [Legacy Actions](Actions-and-States.md#legacy-actions) * [Errors and Exceptions](Errors-and-Exceptions.md) * [Local to Global Failure](Errors-and-Exceptions.md#local-to-global-failure) * [Global to Local Failure](Errors-and-Exceptions.md#global-to-local-failure) @@ -61,10 +75,13 @@ * [Parse Function](Inputs-and-Parsing.md#parse-function) * [Nested Parsing](Inputs-and-Parsing.md#nested-parsing) * [Incremental Input](Inputs-and-Parsing.md#incremental-input) - * [Grammars and Buffering](Inputs-and-Parsing.md#grammars-and-buffering) - * [Custom Data Sources](Inputs-and-Parsing.md#custom-data-sources) + * [Buffer Size](Inputs-and-Parsing.md#buffer-size) + * [Discard Input](Inputs-and-Parsing.md#discard-input) + * [Custom Rules](Inputs-and-Parsing.md#custom-rules) + * [Custom Readers](Inputs-and-Parsing.md#custom-readers) + * [Buffer Details](Inputs-and-Parsing.md#buffer-details) * [Error Reporting](Inputs-and-Parsing.md#error-reporting) - * [C++17 Deduction Guides](Inputs-and-Parsing.md#c17-deduction-guides) + * [Deduction Guides](Inputs-and-Parsing.md#deduction-guides) * [Control and Debug](Control-and-Debug.md) * [Normal Control](Control-and-Debug.md#normal-control) * [Control Functions](Control-and-Debug.md#control-functions) @@ -72,12 +89,22 @@ * [Advanced Control](Control-and-Debug.md#advanced-control) * [Changing Control](Control-and-Debug.md#changing-control) * [Parse Tree](Parse-Tree.md) + * [Full Parse Tree](Parse-Tree.md#full-parse-tree) + * [Partial Parse Tree](Parse-Tree.md#partial-parse-tree) + * [Transforming Nodes](Parse-Tree.md#transforming-nodes) + * [Transformers](Parse-Tree.md#transformers) + * [`tao::pegtl::parse_tree::node`](Parse-Tree.md#taopegtlparse_treenode) + * [Custom Node Class](Parse-Tree.md#custom-node-class) * [Contrib and Examples](Contrib-and-Examples.md) * [Contrib](Contrib-and-Examples.md#contrib) * [Examples](Contrib-and-Examples.md#examples) * [Grammar Analysis](Grammar-Analysis.md) + * [Rule Analysis](Grammar-Analysis.md#rule-analysis) + * [Background](Grammar-Analysis.md#background) + * [Custom Rules](Grammar-Analysis.md#custom-rules) * [Changelog](Changelog.md) * [Migration Guide](Migration-Guide.md) +* [Thank You](Thank-You.md) # Rule Reference Index @@ -212,6 +239,7 @@ * [`ranges< C1, D1, C2, D2, ..., E >`](Rule-Reference.md#ranges-c1-d1-c2-d2--e-) <sup>[(ascii rules)](Rule-Reference.md#ascii-rules)</sup> * [`ranges< C1, D1, C2, D2, ..., E >`](Rule-Reference.md#ranges-c1-d1-c2-d2--e--1) <sup>[(unicode rules)](Rule-Reference.md#unicode-rules)</sup> * [`ranges< C1, D1, C2, D2, ..., E >`](Rule-Reference.md#ranges-c1-d1-c2-d2--e--2) <sup>[(binary rules)](Rule-Reference.md#binary-rules)</sup> +* [`rematch< R, S... >`](Rule-Reference.md#rematch-r-s-) <sup>[(convenience)](Rule-Reference.md#convenience)</sup> * [`rep< Num, R... >`](Rule-Reference.md#rep-num-r-) <sup>[(convenience)](Rule-Reference.md#convenience)</sup> * [`rep_max< Max, R... >`](Rule-Reference.md#rep_max-max-r-) <sup>[(convenience)](Rule-Reference.md#convenience)</sup> * [`rep_min< Min, R... >`](Rule-Reference.md#rep_min-min-r-) <sup>[(convenience)](Rule-Reference.md#convenience)</sup> @@ -255,4 +283,4 @@ * [`xid_continue`](Rule-Reference.md#xid_continue) <sup>[(icu rules)](Rule-Reference.md#icu-rules-for-binary-properties)</sup> * [`xid_start`](Rule-Reference.md#xid_start) <sup>[(icu rules)](Rule-Reference.md#icu-rules-for-binary-properties)</sup> -Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey diff --git a/packages/PEGTL/doc/Rule-Reference.md b/packages/PEGTL/doc/Rule-Reference.md index bb9180433..85040484d 100644 --- a/packages/PEGTL/doc/Rule-Reference.md +++ b/packages/PEGTL/doc/Rule-Reference.md @@ -9,7 +9,7 @@ rules **never** consume input when they do not succeed. Remember that there are two failure modes, only the first of which usually leads to back-tracking: - *Local failure* or a return value of `false`, in which case the rule must rewind the input to the position at which the rule match was attempted. -- *Global failure* or an exception (usually of type `tao::parse_error`) that is usually generated by a control-class' `raise()`-method. +- *Global failure* or an exception (usually of type `tao::parse_error`) that is usually generated by a control-class' `raise()` static member function. ## Equivalence @@ -21,7 +21,7 @@ is not how they are implemented, therefore: - *not* with regard to which actions will be invoked while matching. However, rule equivalence does show exactly where the `raise<>` rule is inserted -and therefore which rule will be used to call the control class' `raise()`-method. +and therefore which rule will be used to call the control class' `raise()`. ## Parameter Packs @@ -70,7 +70,7 @@ These rules are in namespace `tao::pegtl`. ###### `discard` * Equivalent to `success`, but: -* Calls the input's `discard()`-method. +* 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. @@ -89,7 +89,7 @@ These rules are in namespace `tao::pegtl`. * Equivalent to `seq< R... >`, but: * Replaces all state arguments with a new instance `s` of type `S`. * `s` is constructed with the input and all previous states as arguments. -* If `seq< R... >` succeeds then `s.success()` is called with the input after the match and all previous states as arguments, and, if expected, with `A, M, Action, Control` as template parameters. +* If `seq< R... >` succeeds then `s.success()` is called with the input after the match and all previous states as arguments. ## Combinators @@ -210,9 +210,8 @@ These rules are in namespace `tao::pegtl`. ###### `minus< M, S >` -* Succeeds if `M` matches, and then `S` does **not** match all of the input that `M` matched. -* Does not call actions for `S` (unless `S` contains `enable<>`). -* Ignores `S` for the [grammar analysis](Grammar-Analysis.md). +* Succeeds if `M` matches, and `S` does *not* match *all* of the input that `M` matched. +* Equivalent to `rematch< M, not_at< S, eof > >`. ###### `must< R... >` @@ -235,6 +234,11 @@ These rules are in namespace `tao::pegtl`. * Matches an optional `R` that can be padded by arbitrary many `P` or just arbitrary many `P`. * Equivalent to `seq< star< P >, opt< R, star< P > > >`. +###### `rematch< R, S... >` + +* Succeeds if `R` matches, and each `S` matches the input that `R` matched. +* Ignores all `S` for the [grammar analysis](Grammar-Analysis.md). + ###### `rep< Num, R... >` * Matches `seq< R... >` for `Num` times without checking for further matches. @@ -293,7 +297,7 @@ These rules are in namespace `tao::pegtl`. These rules are in namespace `tao::pegtl`. These rules replicate the intrusive way actions were called from within the grammar in the PEGTL 0.x with the `apply<>` and `if_apply<>` rules. -The actions for these rules are classes (rather than class templates as required for the `parse()`-functions and `action<>`-rule). +The actions for these rules are classes (rather than class templates as required for `parse()` and the `action<>`-rule). These rules respect the current `apply_mode`, but don't use the control-class to invoke the actions. ###### `apply< A... >` @@ -322,15 +326,15 @@ Atomic rules do not rely on other rules. ###### `bof` -* Succeeds at "beginning-of-file", i.e. when the input's `byte()` method returns zero. +* Succeeds at "beginning-of-file", i.e. when the input's `byte()` member function returns zero. * Does not consume input. -* Does **not** work with inputs that don't have a `byte()` method. +* Does **not** work with inputs that don't have a `byte()` member function. ###### `bol` -* Succeeds at "beginning-of-line", i.e. when the input's `byte_in_line()` method returns zero. +* Succeeds at "beginning-of-line", i.e. when the input's `byte_in_line()` member function returns zero. * Does not consume input. -* Does **not** work with inputs that don't have a `byte_in_line()` method. +* Does **not** work with inputs that don't have a `byte_in_line()` member function. ###### `bytes< Num >` @@ -350,7 +354,7 @@ Atomic rules do not rely on other rules. ###### `raise< T >` * Generates a *global failure*. -* Calls the control-class' `Control< T >::raise()`-method. +* Calls the control-class' `Control< T >::raise()` static member function. * `T` *can* be a rule, but it does not have to be a rule. * Does not consume input. @@ -398,6 +402,11 @@ can be matched by either `tao::pegtl::ascii::string< 0xe2, 0x82, 0xac >` or `tao * Matches and consumes a single ASCII decimal digit character. * Equivalent to `range< '0', '9' >`. +###### `ellipsis` + +* Matches and consumes three dots. +* Equivalent to `three< '.' >`. + ###### `eol` * Depends on the `Eol` template parameter of the input, by default: @@ -582,7 +591,7 @@ It is an error when a code unit in the range `0xd800` to `0xdfff` is encountered ###### `any` * Succeeds when the input is not empty, and: -* The next N bytes encode of a valid Unicode code point. +* The next N bytes encode a valid Unicode code point. * Consumes the N bytes when it succeeds. ###### `bom` @@ -1192,6 +1201,7 @@ The term *input value* indicates a correspondingly sized integer value read from * [`ranges< C1, D1, C2, D2, ..., E >`](#ranges-c1-d1-c2-d2--e-) <sup>[(ascii rules)](#ascii-rules)</sup> * [`ranges< C1, D1, C2, D2, ..., E >`](#ranges-c1-d1-c2-d2--e--1) <sup>[(unicode rules)](#unicode-rules)</sup> * [`ranges< C1, D1, C2, D2, ..., E >`](#ranges-c1-d1-c2-d2--e--2) <sup>[(binary rules)](#binary-rules)</sup> +* [`rematch< R, S... >`](#rematch-r-s-) <sup>[(convenience)](#convenience)</sup> * [`rep< Num, R... >`](#rep-num-r-) <sup>[(convenience)](#convenience)</sup> * [`rep_max< Max, R... >`](#rep_max-max-r-) <sup>[(convenience)](#convenience)</sup> * [`rep_min< Min, R... >`](#rep_min-min-r-) <sup>[(convenience)](#convenience)</sup> @@ -1235,4 +1245,4 @@ The term *input value* indicates a correspondingly sized integer value read from * [`xid_continue`](#xid_continue) <sup>[(icu rules)](#icu-rules-for-binary-properties)</sup> * [`xid_start`](#xid_start) <sup>[(icu rules)](#icu-rules-for-binary-properties)</sup> -Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey diff --git a/packages/PEGTL/doc/Rules-and-Grammars.md b/packages/PEGTL/doc/Rules-and-Grammars.md index 78c548c2d..f577ad97d 100644 --- a/packages/PEGTL/doc/Rules-and-Grammars.md +++ b/packages/PEGTL/doc/Rules-and-Grammars.md @@ -79,7 +79,7 @@ struct line_comment struct list; struct list_comment - : if_must< at< one< '(' >, disable< list > > > {}; + : if_must< at< one< '(' > >, disable< list > > {}; struct comment : if_must< one< '#' >, sor< list_comment, line_comment > > {}; @@ -116,21 +116,21 @@ In order to let a parsing run do more than verify whether an input conforms to t ## Creating New Rules Sometimes a grammar requires a parsing rule that can not be readily created as combination of the existing rules. -In these cases a custom grammar rule, i.e. a class with a static `match()`-method that has to adhere to one of two possible interfaces or prototypes, can be implemented from scratch. +In these cases a custom grammar rule, i.e. a class with a static member function called `match()` that has to adhere to one of two possible interfaces or prototypes, can be implemented from scratch. -When implementing a custom rule class, it is important to remember that the input passed to a rules' `match()`-method represents the *remainder* of the complete input. +When implementing a custom rule class, it is important to remember that the input passed to `match()` represents the *remainder* of the complete input. At the beginning of a parsing run, the input represents the complete data-to-be-parsed. During the parsing run, many rules *consume* the data that matched from the input. -Consuming data from an input advances the pointer to the data that the input's `begin()`-method returns, and decrements the size by the same amount. +Consuming data from an input advances the pointer to the data that the input's `begin()` member function returns, and decrements the size by the same amount. The PEGTL makes one **important** assumption about all parsing rules. -If a call to a `match()`-method returns with `false`, then the rule **must not** have consumed input (for [complex rules](#complex-rules): only when the `rewind_mode` is `REQUIRED`). +If a call to `match()` returns with `false`, then the rule **must not** have consumed input (for [complex rules](#complex-rules): only when the `rewind_mode` is `required`). For performance reasons this assumption is neither ensured nor verified by the PEGTL. ### Simple Rules -In the simplified rule, the `match()`-function is called with a single argument, the input. -All rules' `match()`-method return a `bool` to indicate success or (local) failure. +In the simplified rule, `match()` is called with a single argument, the input. +It returns a `bool` to indicate success or (local) failure. Rules with the simplified interface are called without the states as arguments. ```c++ @@ -142,7 +142,7 @@ struct simple_rule ``` Here is an excerpt from the included example program `src/example/pegtl/modulus_match.cpp` that shows a simple custom rule. -The - slightly artificial - rule `my_rule` uses three important `input` methods, +The - slightly artificial - rule `my_rule` uses three important `input` functions, 1. first `size()` to check whether the input is not empty, @@ -183,7 +183,7 @@ namespace modulus int main( int argc, char* argv[] ) { if( argc > 1 ) { - tao::pegtl::argv_input<> in( argv, 1 ); + tao::pegtl::argv_input in( argv, 1 ); tao::pegtl::parse< modulus::grammar >( in ); } return 0; @@ -192,10 +192,10 @@ int main( int argc, char* argv[] ) ### Complex Rules -The complex calling convention gives a rule's `match()`-method access to "everything", i.e. some modes, the action and control classes, and all state arguments. +The complex calling convention gives a rule's `match()` member function access to "everything", i.e. some modes, the action- and control class, and all state arguments. All of these parameters are required for custom rules that need to themselves call other rules for matching. -The `match()`-method in a complex rule takes the following form. +The signature of `match()` in a complex rule takes the following form. ```c++ struct complex_rule @@ -216,19 +216,19 @@ struct complex_rule #### Modes -The `apply_mode` can take the value `apply_mode::ACTION` or `apply_mode::NOTHING`, depending on whether actions are currently enabled or disabled. +The `apply_mode` can take the value `apply_mode::action` or `apply_mode::nothing`, depending on whether actions are currently enabled or disabled. Most custom parsing rules will either ignore, or pass on the `apply_mode` unchanged; usually only the control interprets the `apply_mode`. -The `rewind_mode` can take the value `rewind_mode::ACTIVE`, `rewind_mode::REQUIRED` or `rewind_mode::DONTCARE`. -When `M` is `rewind_mode::REQUIRED`, the custom rule's `match()`-implementation **must**, on local failure, rewind the input to where it (the input) was when it (the `match()`-function) was first called. +The `rewind_mode` can take the value `rewind_mode::active`, `rewind_mode::required` or `rewind_mode::dontcare`. +When `M` is `rewind_mode::required`, the custom rule's `match()`-implementation **must**, on local failure, rewind the input to where it (the input) was when `match()` was called. -When `M` is **not** `rewind_mode::REQUIRED`, it is not necessary to perform rewinding as either some other rule further up the call stack is already taking care of it (`rewind_mode::ACTIVE`), or rewinding is not necessary (`rewind_mode::DONTCARE`). -For example within a `must<>`-rule (which converts local failure, a return value of `false` from the `match()`-function, to global failure, an exception) the `rewind_mode` is `DONTCARE`. +When `M` is **not** `rewind_mode::required`, it is not necessary to perform rewinding as either some other rule further up the call stack is already taking care of it (`rewind_mode::active`), or rewinding is not necessary (`rewind_mode::dontcare`). +For example within a `must<>`-rule (which converts local failure, a return value of `false` from `match()`, to global failure, an exception) the `rewind_mode` is `dontcare`. -The following implementation of the `seq`-rule's `match()`-method shows how to correctly handle the `rewind_mode`. -The input's `mark()`-method uses the `rewind_mode` to choose which input marker to return, either one that takes care of rewinding when required, or a dummy object that does nothing. -In the first case, `next_rewind_mode` is set to `ACTIVE`, otherwise it is equal to `M`, just as required for the next rules called by the current one. -The return value of the `match()`-method is then passed through the input marker `m` so that, if the return value is `false` and the marker is not the dummy, it can rewind the input `in`. +The following implementation of the `seq`-rule's `match()` shows how to correctly handle the `rewind_mode`. +The input's `mark()` member function uses the `rewind_mode` to choose which input marker to return, either one that takes care of rewinding when required, or a dummy object that does nothing. +In the first case, `next_rewind_mode` is set to `active`, otherwise it is equal to `M`, just as required for the next rules called by the current one. +The return value of `match()` is then passed through the input marker `m` so that, if the return value is `false` and the marker is not the dummy, it can rewind the input `in`. ```c++ template< typename... Rules > @@ -281,8 +281,7 @@ The action stores the matched string that corresponds to `"foo"` in a string var ```c++ template< typename Rule > - struct action - : tao::pegtl::nothing< Rule > {}; + struct action {}; template<> struct action< long_literal_id > @@ -320,7 +319,7 @@ The custom rule itself template< tao::pegtl::apply_mode A, tao::pegtl::rewind_mode M, template< typename... > class Action, - template< typename... > class Control + template< typename... > class Control, typename Input > static bool match( Input& in, const std::string& id, @@ -373,7 +372,7 @@ int main( int argc, char* argv[] ) std::string id; std::string body; - tao::pegtl::argv_input<> in( argv, 1 ); + tao::pegtl::argv_input in( argv, 1 ); tao::pegtl::parse< dynamic::grammar, dynamic::action >( in, id, body ); std::cout << "long literal id was: " << id << std::endl; @@ -395,4 +394,4 @@ long literal id was: "fraggle" long literal body was: "[foo[" ``` -Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey diff --git a/packages/PEGTL/doc/Thank-You.md b/packages/PEGTL/doc/Thank-You.md new file mode 100644 index 000000000..63beb187c --- /dev/null +++ b/packages/PEGTL/doc/Thank-You.md @@ -0,0 +1,41 @@ +# 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="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="zhihaoy" src="https://avatars2.githubusercontent.com/u/43971430?v=4&s=117" width="117">](https://github.com/zhihaoy) + +## The Art of C++ + +Members of the *Art of C++* project. + +[<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) + +Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey diff --git a/packages/PEGTL/include/tao/pegtl.hpp b/packages/PEGTL/include/tao/pegtl.hpp index 993dfc193..42141a9df 100644 --- a/packages/PEGTL/include/tao/pegtl.hpp +++ b/packages/PEGTL/include/tao/pegtl.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_HPP @@ -7,8 +7,9 @@ #include "pegtl/config.hpp" #include "pegtl/version.hpp" -#include "pegtl/ascii.hpp" #include "pegtl/parse.hpp" + +#include "pegtl/ascii.hpp" #include "pegtl/rules.hpp" #include "pegtl/uint16.hpp" #include "pegtl/uint32.hpp" @@ -27,6 +28,20 @@ #include "pegtl/read_input.hpp" #include "pegtl/string_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" + // The following are not included by // default because they include <iostream>. diff --git a/packages/PEGTL/include/tao/pegtl/analysis/analyze_cycles.hpp b/packages/PEGTL/include/tao/pegtl/analysis/analyze_cycles.hpp index e25f3bbf2..9f7ce5f83 100644 --- a/packages/PEGTL/include/tao/pegtl/analysis/analyze_cycles.hpp +++ b/packages/PEGTL/include/tao/pegtl/analysis/analyze_cycles.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_ANALYSIS_ANALYZE_CYCLES_HPP @@ -18,118 +18,110 @@ #include "grammar_info.hpp" #include "insert_guard.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::analysis { - namespace TAO_PEGTL_NAMESPACE + class analyze_cycles_impl { - namespace analysis + protected: + explicit analyze_cycles_impl( const bool verbose ) noexcept + : m_verbose( verbose ), + m_problems( 0 ) { - class analyze_cycles_impl - { - protected: - explicit analyze_cycles_impl( const bool verbose ) noexcept - : m_verbose( verbose ), - m_problems( 0 ) - { - } + } - const bool m_verbose; - unsigned m_problems; - grammar_info m_info; - std::set< std::string > m_stack; - std::map< std::string, bool > m_cache; - std::map< std::string, bool > m_results; - - const std::map< std::string, rule_info >::const_iterator find( const std::string& name ) const noexcept - { - const auto iter = m_info.map.find( name ); - assert( iter != m_info.map.end() ); - return iter; - } + const bool m_verbose; + unsigned m_problems; + grammar_info m_info; + std::set< std::string > m_stack; + std::map< std::string, bool > m_cache; + std::map< std::string, bool > m_results; - bool work( const std::map< std::string, rule_info >::const_iterator& start, const bool accum ) - { - const auto j = m_cache.find( start->first ); + [[nodiscard]] std::map< std::string, rule_info >::const_iterator find( const std::string& name ) const noexcept + { + const auto iter = m_info.map.find( name ); + assert( iter != m_info.map.end() ); + return iter; + } - if( j != m_cache.end() ) { - return j->second; + [[nodiscard]] bool work( const std::map< std::string, rule_info >::const_iterator& start, const bool accum ) + { + const auto j = m_cache.find( start->first ); + + if( j != m_cache.end() ) { + return j->second; + } + if( const auto g = insert_guard( m_stack, start->first ) ) { + switch( start->second.type ) { + case rule_type::any: { + bool a = false; + for( const auto& r : start->second.rules ) { + a = a || work( find( r ), accum || a ); + } + return m_cache[ start->first ] = true; } - if( const auto g = make_insert_guard( m_stack, start->first ) ) { - switch( start->second.type ) { - case rule_type::ANY: { - bool a = false; - for( const auto& r : start->second.rules ) { - a = a || work( find( r ), accum || a ); - } - return m_cache[ start->first ] = true; - } - case rule_type::OPT: { - bool a = false; - for( const auto& r : start->second.rules ) { - a = a || work( find( r ), accum || a ); - } - return m_cache[ start->first ] = false; - } - case rule_type::SEQ: { - bool a = false; - for( const auto& r : start->second.rules ) { - a = a || work( find( r ), accum || a ); - } - return m_cache[ start->first ] = a; - } - case rule_type::SOR: { - bool a = true; - for( const auto& r : start->second.rules ) { - a = a && work( find( r ), accum ); - } - return m_cache[ start->first ] = a; - } + case rule_type::opt: { + bool a = false; + for( const auto& r : start->second.rules ) { + a = a || work( find( r ), accum || a ); } - throw std::logic_error( "code should be unreachable: invalid rule_type value" ); // NOLINT, LCOV_EXCL_LINE + return m_cache[ start->first ] = false; } - if( !accum ) { - ++m_problems; - if( m_verbose ) { - std::cout << "problem: cycle without progress detected at rule class " << start->first << std::endl; // LCOV_EXCL_LINE + case rule_type::seq: { + bool a = false; + for( const auto& r : start->second.rules ) { + a = a || work( find( r ), accum || a ); } + return m_cache[ start->first ] = a; } - return m_cache[ start->first ] = accum; - } - }; - - template< typename Grammar > - class analyze_cycles - : private analyze_cycles_impl - { - public: - explicit analyze_cycles( const bool verbose ) - : analyze_cycles_impl( verbose ) - { - Grammar::analyze_t::template insert< Grammar >( m_info ); - } - - std::size_t problems() - { - for( auto i = m_info.map.begin(); i != m_info.map.end(); ++i ) { - m_results[ i->first ] = work( i, false ); - m_cache.clear(); + case rule_type::sor: { + bool a = true; + for( const auto& r : start->second.rules ) { + a = a && work( find( r ), accum ); + } + return m_cache[ start->first ] = a; } - return m_problems; } - - template< typename Rule > - bool consumes() const noexcept - { - const auto i = m_results.find( internal::demangle< Rule >() ); - assert( i != m_results.end() ); - return i->second; + throw std::logic_error( "code should be unreachable: invalid rule_type value" ); // NOLINT, LCOV_EXCL_LINE + } + if( !accum ) { + ++m_problems; + if( m_verbose ) { + std::cout << "problem: cycle without progress detected at rule class " << start->first << std::endl; // LCOV_EXCL_LINE } - }; - - } // namespace analysis + } + return m_cache[ start->first ] = accum; + } + }; + + template< typename Grammar > + class analyze_cycles + : private analyze_cycles_impl + { + public: + explicit analyze_cycles( const bool verbose ) + : analyze_cycles_impl( verbose ) + { + Grammar::analyze_t::template insert< Grammar >( m_info ); + } - } // namespace TAO_PEGTL_NAMESPACE + [[nodiscard]] std::size_t problems() + { + for( auto i = m_info.map.begin(); i != m_info.map.end(); ++i ) { + m_results[ i->first ] = work( i, false ); + m_cache.clear(); + } + return m_problems; + } + + template< typename Rule > + [[nodiscard]] bool consumes() const noexcept + { + const auto i = m_results.find( internal::demangle< Rule >() ); + assert( i != m_results.end() ); + return i->second; + } + }; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::analysis #endif diff --git a/packages/PEGTL/include/tao/pegtl/analysis/counted.hpp b/packages/PEGTL/include/tao/pegtl/analysis/counted.hpp index 6dff5b989..2c1939ca1 100644 --- a/packages/PEGTL/include/tao/pegtl/analysis/counted.hpp +++ b/packages/PEGTL/include/tao/pegtl/analysis/counted.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_ANALYSIS_COUNTED_HPP @@ -8,22 +8,14 @@ #include "generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::analysis { - namespace TAO_PEGTL_NAMESPACE + template< rule_type Type, unsigned Count, typename... Rules > + struct counted + : generic< ( Count != 0 ) ? Type : rule_type::opt, Rules... > { - namespace analysis - { - template< rule_type Type, unsigned Count, typename... Rules > - struct counted - : generic< ( Count != 0 ) ? Type : rule_type::OPT, Rules... > - { - }; + }; - } // namespace analysis - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::analysis #endif diff --git a/packages/PEGTL/include/tao/pegtl/analysis/generic.hpp b/packages/PEGTL/include/tao/pegtl/analysis/generic.hpp index 9c0f4e6d6..ae8685ab8 100644 --- a/packages/PEGTL/include/tao/pegtl/analysis/generic.hpp +++ b/packages/PEGTL/include/tao/pegtl/analysis/generic.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_ANALYSIS_GENERIC_HPP @@ -10,30 +10,22 @@ #include "insert_rules.hpp" #include "rule_type.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::analysis { - namespace TAO_PEGTL_NAMESPACE + template< rule_type Type, typename... Rules > + struct generic { - namespace analysis + template< typename Name > + static std::string insert( grammar_info& g ) { - template< rule_type Type, typename... Rules > - struct generic - { - template< typename Name > - static std::string insert( grammar_info& g ) - { - const auto r = g.insert< Name >( Type ); - if( r.second ) { - insert_rules< Rules... >::insert( g, r.first->second ); - } - return r.first->first; - } - }; - - } // namespace analysis - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + const auto [ it, success ] = g.insert< Name >( Type ); + if( success ) { + insert_rules< Rules... >::insert( g, it->second ); + } + return it->first; + } + }; + +} // namespace TAO_PEGTL_NAMESPACE::analysis #endif diff --git a/packages/PEGTL/include/tao/pegtl/analysis/grammar_info.hpp b/packages/PEGTL/include/tao/pegtl/analysis/grammar_info.hpp index 06d73e844..a6f63ed68 100644 --- a/packages/PEGTL/include/tao/pegtl/analysis/grammar_info.hpp +++ b/packages/PEGTL/include/tao/pegtl/analysis/grammar_info.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_ANALYSIS_GRAMMAR_INFO_HPP @@ -13,28 +13,20 @@ #include "rule_info.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::analysis { - namespace TAO_PEGTL_NAMESPACE + struct grammar_info { - namespace analysis - { - struct grammar_info - { - using map_t = std::map< std::string, rule_info >; - map_t map; - - template< typename Name > - std::pair< map_t::iterator, bool > insert( const rule_type type ) - { - return map.insert( map_t::value_type( internal::demangle< Name >(), rule_info( type ) ) ); - } - }; + using map_t = std::map< std::string, rule_info >; + map_t map; - } // namespace analysis - - } // namespace TAO_PEGTL_NAMESPACE + template< typename Name > + auto insert( const rule_type type ) + { + return map.emplace( internal::demangle< Name >(), rule_info( type ) ); + } + }; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::analysis #endif diff --git a/packages/PEGTL/include/tao/pegtl/analysis/insert_guard.hpp b/packages/PEGTL/include/tao/pegtl/analysis/insert_guard.hpp index 6cd61c806..1fb00503c 100644 --- a/packages/PEGTL/include/tao/pegtl/analysis/insert_guard.hpp +++ b/packages/PEGTL/include/tao/pegtl/analysis/insert_guard.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_ANALYSIS_INSERT_GUARD_HPP @@ -8,61 +8,44 @@ #include "../config.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::analysis { - namespace TAO_PEGTL_NAMESPACE + template< typename C > + class insert_guard { - namespace analysis + public: + insert_guard( C& container, const typename C::value_type& value ) + : m_i( container.insert( value ) ), + m_c( container ) { - template< typename C > - class insert_guard - { - public: - insert_guard( C& container, const typename C::value_type& value ) - : m_i( container.insert( value ) ), - m_c( &container ) - { - } + } - insert_guard( const insert_guard& ) = delete; + insert_guard( const insert_guard& ) = delete; + insert_guard( insert_guard&& ) = delete; - insert_guard( insert_guard&& other ) noexcept - : m_i( other.m_i ), - m_c( other.m_c ) - { - other.m_c = nullptr; - } - - ~insert_guard() - { - if( m_c && m_i.second ) { - m_c->erase( m_i.first ); - } - } - - void operator=( const insert_guard& ) = delete; - void operator=( insert_guard&& ) = delete; - - explicit operator bool() const noexcept - { - return m_i.second; - } + ~insert_guard() + { + if( m_i.second ) { + m_c.erase( m_i.first ); + } + } - private: - const std::pair< typename C::iterator, bool > m_i; - C* m_c; - }; + void operator=( const insert_guard& ) = delete; + void operator=( insert_guard&& ) = delete; - template< typename C > - insert_guard< C > make_insert_guard( C& container, const typename C::value_type& value ) - { - return insert_guard< C >( container, value ); - } + explicit operator bool() const noexcept + { + return m_i.second; + } - } // namespace analysis + private: + const std::pair< typename C::iterator, bool > m_i; + C& m_c; + }; - } // namespace TAO_PEGTL_NAMESPACE + template< typename C > + insert_guard( C&, const typename C::value_type& )->insert_guard< C >; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::analysis #endif diff --git a/packages/PEGTL/include/tao/pegtl/analysis/insert_rules.hpp b/packages/PEGTL/include/tao/pegtl/analysis/insert_rules.hpp index 6e172b3c7..617031a63 100644 --- a/packages/PEGTL/include/tao/pegtl/analysis/insert_rules.hpp +++ b/packages/PEGTL/include/tao/pegtl/analysis/insert_rules.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_ANALYSIS_INSERT_RULES_HPP @@ -9,37 +9,17 @@ #include "grammar_info.hpp" #include "rule_info.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::analysis { - namespace TAO_PEGTL_NAMESPACE + template< typename... Rules > + struct insert_rules { - namespace analysis + static void insert( grammar_info& g, rule_info& r ) { - template< typename... > - struct insert_rules; + ( r.rules.emplace_back( Rules::analyze_t::template insert< Rules >( g ) ), ... ); + } + }; - template<> - struct insert_rules<> - { - static void insert( grammar_info& /*unused*/, rule_info& /*unused*/ ) - { - } - }; - - template< typename Rule, typename... Rules > - struct insert_rules< Rule, Rules... > - { - static void insert( grammar_info& g, rule_info& r ) - { - r.rules.push_back( Rule::analyze_t::template insert< Rule >( g ) ); - insert_rules< Rules... >::insert( g, r ); - } - }; - - } // namespace analysis - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::analysis #endif diff --git a/packages/PEGTL/include/tao/pegtl/analysis/rule_info.hpp b/packages/PEGTL/include/tao/pegtl/analysis/rule_info.hpp index 30af0ed00..0f06950bd 100644 --- a/packages/PEGTL/include/tao/pegtl/analysis/rule_info.hpp +++ b/packages/PEGTL/include/tao/pegtl/analysis/rule_info.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_ANALYSIS_RULE_INFO_HPP @@ -11,27 +11,19 @@ #include "rule_type.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::analysis { - namespace TAO_PEGTL_NAMESPACE + struct rule_info { - namespace analysis + explicit rule_info( const rule_type in_type ) noexcept + : type( in_type ) { - struct rule_info - { - explicit rule_info( const rule_type in_type ) noexcept - : type( in_type ) - { - } + } - rule_type type; - std::vector< std::string > rules; - }; + rule_type type; + std::vector< std::string > rules; + }; - } // namespace analysis - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::analysis #endif diff --git a/packages/PEGTL/include/tao/pegtl/analysis/rule_type.hpp b/packages/PEGTL/include/tao/pegtl/analysis/rule_type.hpp index ebd7f4e3e..ec1f29c91 100644 --- a/packages/PEGTL/include/tao/pegtl/analysis/rule_type.hpp +++ b/packages/PEGTL/include/tao/pegtl/analysis/rule_type.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_ANALYSIS_RULE_TYPE_HPP @@ -6,24 +6,16 @@ #include "../config.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::analysis { - namespace TAO_PEGTL_NAMESPACE + enum class rule_type : char { - namespace analysis - { - enum class rule_type : char - { - ANY, // Consumption-on-success is always true; assumes bounded repetition of conjunction of sub-rules. - OPT, // Consumption-on-success not necessarily true; assumes bounded repetition of conjunction of sub-rules. - SEQ, // Consumption-on-success depends on consumption of (non-zero bounded repetition of) conjunction of sub-rules. - SOR // Consumption-on-success depends on consumption of (non-zero bounded repetition of) disjunction of sub-rules. - }; + any, // Consumption-on-success is always true; assumes bounded repetition of conjunction of sub-rules. + opt, // Consumption-on-success not necessarily true; assumes bounded repetition of conjunction of sub-rules. + seq, // Consumption-on-success depends on consumption of (non-zero bounded repetition of) conjunction of sub-rules. + sor // Consumption-on-success depends on consumption of (non-zero bounded repetition of) disjunction of sub-rules. + }; - } // namespace analysis - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::analysis #endif diff --git a/packages/PEGTL/include/tao/pegtl/analyze.hpp b/packages/PEGTL/include/tao/pegtl/analyze.hpp index 08e0d7b40..d0e0641ce 100644 --- a/packages/PEGTL/include/tao/pegtl/analyze.hpp +++ b/packages/PEGTL/include/tao/pegtl/analyze.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_ANALYZE_HPP @@ -8,18 +8,14 @@ #include "analysis/analyze_cycles.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + template< typename Rule > + [[nodiscard]] std::size_t analyze( const bool verbose = true ) { - template< typename Rule > - std::size_t analyze( const bool verbose = true ) - { - return analysis::analyze_cycles< Rule >( verbose ).problems(); - } + return analysis::analyze_cycles< Rule >( verbose ).problems(); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/apply_mode.hpp b/packages/PEGTL/include/tao/pegtl/apply_mode.hpp index c403c1b72..144f0cb79 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_APPLY_MODE_HPP @@ -6,18 +6,14 @@ #include "config.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + enum class apply_mode : bool { - enum class apply_mode : bool - { - ACTION = true, - NOTHING = false - }; + action = true, + nothing = false + }; - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/argv_input.hpp b/packages/PEGTL/include/tao/pegtl/argv_input.hpp index de2343c5b..c7b1430d0 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_ARGV_INPUT_HPP @@ -14,44 +14,38 @@ #include "memory_input.hpp" #include "tracking_mode.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace internal { - namespace internal + [[nodiscard]] inline std::string make_argv_source( const std::size_t argn ) { - inline std::string make_argv_source( const std::size_t argn ) - { - std::ostringstream os; - os << "argv[" << argn << ']'; - return os.str(); - } - - } // namespace internal - - template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf > - struct argv_input - : public memory_input< P, Eol > + std::ostringstream os; + os << "argv[" << argn << ']'; + return os.str(); + } + + } // namespace internal + + template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > + struct argv_input + : public memory_input< P, Eol > + { + template< typename T > + argv_input( char** argv, const std::size_t argn, T&& in_source ) // NOLINT + : memory_input< P, Eol >( static_cast< const char* >( argv[ argn ] ), std::forward< T >( in_source ) ) { - template< typename T > - argv_input( char** argv, const std::size_t argn, T&& in_source ) - : memory_input< P, Eol >( static_cast< const char* >( argv[ argn ] ), std::forward< T >( in_source ) ) - { - } - - argv_input( char** argv, const std::size_t argn ) - : argv_input( argv, argn, internal::make_argv_source( argn ) ) - { - } - }; - -#ifdef __cpp_deduction_guides - template< typename... Ts > - argv_input( Ts&&... )->argv_input<>; -#endif + } + + argv_input( char** argv, const std::size_t argn ) // NOLINT + : argv_input( argv, argn, internal::make_argv_source( argn ) ) + { + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template< typename... Ts > + argv_input( Ts&&... )->argv_input<>; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/ascii.hpp b/packages/PEGTL/include/tao/pegtl/ascii.hpp index b440b4d91..b28cc350a 100644 --- a/packages/PEGTL/include/tao/pegtl/ascii.hpp +++ b/packages/PEGTL/include/tao/pegtl/ascii.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_ASCII_HPP @@ -7,62 +7,60 @@ #include "config.hpp" #include "eol.hpp" +#include "internal/always_false.hpp" #include "internal/result_on_found.hpp" #include "internal/rules.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + inline namespace ascii { - inline namespace ascii - { - // clang-format off - struct alnum : internal::alnum {}; - struct alpha : internal::alpha {}; - struct any : internal::any< internal::peek_char > {}; - struct blank : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, ' ', '\t' > {}; - struct digit : internal::range< internal::result_on_found::SUCCESS, internal::peek_char, '0', '9' > {}; - struct eolf : internal::eolf {}; - template< char... Cs > struct forty_two : internal::rep< 42, internal::one< internal::result_on_found::SUCCESS, internal::peek_char, Cs... > > {}; - struct identifier_first : internal::identifier_first {}; - struct identifier_other : internal::identifier_other {}; - struct identifier : internal::identifier {}; - template< char... Cs > struct istring : internal::istring< Cs... > {}; - template< char... Cs > struct keyword : internal::seq< internal::string< Cs... >, internal::not_at< internal::identifier_other > > {}; - 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 ) > {}; - template< char... Cs > struct one : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, Cs... > {}; - struct print : internal::range< internal::result_on_found::SUCCESS, internal::peek_char, char( 32 ), char( 126 ) > {}; - template< char Lo, char Hi > struct range : internal::range< internal::result_on_found::SUCCESS, internal::peek_char, Lo, Hi > {}; - template< char... Cs > struct ranges : internal::ranges< internal::peek_char, Cs... > {}; - struct seven : internal::range< internal::result_on_found::SUCCESS, internal::peek_char, char( 0 ), char( 127 ) > {}; - struct shebang : internal::if_must< false, internal::string< '#', '!' >, internal::until< internal::eolf > > {}; - struct space : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, ' ', '\n', '\r', '\t', '\v', '\f' > {}; - template< char... Cs > struct string : internal::string< Cs... > {}; - template< char C > struct three : internal::three< C > {}; - template< char C > struct two : internal::two< C > {}; - struct upper : internal::range< internal::result_on_found::SUCCESS, internal::peek_char, 'A', 'Z' > {}; - struct xdigit : internal::ranges< internal::peek_char, '0', '9', 'a', 'f', 'A', 'F' > {}; - // clang-format on + // clang-format off + struct alnum : internal::alnum {}; + struct alpha : internal::alpha {}; + struct any : internal::any< internal::peek_char > {}; + struct blank : internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\t' > {}; + struct digit : internal::range< internal::result_on_found::success, internal::peek_char, '0', '9' > {}; + struct ellipsis : internal::string< '.', '.', '.' > {}; + struct eolf : internal::eolf {}; + template< char... Cs > struct forty_two : internal::rep< 42, internal::one< internal::result_on_found::success, internal::peek_char, Cs... > > {}; + struct identifier_first : internal::identifier_first {}; + struct identifier_other : internal::identifier_other {}; + struct identifier : internal::identifier {}; + template< char... Cs > struct istring : internal::istring< Cs... > {}; + template< char... Cs > struct keyword : internal::seq< internal::string< Cs... >, internal::not_at< internal::identifier_other > > {}; + 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 ) > {}; + template< char... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_char, Cs... > {}; + struct print : internal::range< internal::result_on_found::success, internal::peek_char, char( 32 ), char( 126 ) > {}; + template< char Lo, char Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_char, Lo, Hi > {}; + template< char... Cs > struct ranges : internal::ranges< internal::peek_char, Cs... > {}; + struct seven : internal::range< internal::result_on_found::success, internal::peek_char, char( 0 ), char( 127 ) > {}; + struct shebang : internal::if_must< false, internal::string< '#', '!' >, internal::until< internal::eolf > > {}; + struct space : internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\n', '\r', '\t', '\v', '\f' > {}; + template< char... Cs > struct string : internal::string< Cs... > {}; + template< char C > struct three : internal::string< C, C, C > {}; + template< char C > struct two : internal::string< C, C > {}; + struct upper : internal::range< internal::result_on_found::success, internal::peek_char, 'A', 'Z' > {}; + struct xdigit : internal::ranges< internal::peek_char, '0', '9', 'a', 'f', 'A', 'F' > {}; + // clang-format on - template<> - struct keyword<> + template<> + struct keyword<> + { + template< typename Input > + [[nodiscard]] static bool match( Input& /*unused*/ ) noexcept { - template< typename Input > - static bool match( Input& /*unused*/ ) noexcept - { - static_assert( sizeof( Input ) == 0, "empty keywords not allowed" ); - return false; - } - }; - - } // namespace ascii + static_assert( internal::always_false< Input >::value, "empty keywords not allowed" ); + return false; + } + }; - } // namespace TAO_PEGTL_NAMESPACE + } // namespace ascii -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "internal/pegtl_string.hpp" diff --git a/packages/PEGTL/include/tao/pegtl/buffer_input.hpp b/packages/PEGTL/include/tao/pegtl/buffer_input.hpp index 143d94d31..0487b48ec 100644 --- a/packages/PEGTL/include/tao/pegtl/buffer_input.hpp +++ b/packages/PEGTL/include/tao/pegtl/buffer_input.hpp @@ -1,13 +1,16 @@ -// Copyright (c) 2016-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_BUFFER_INPUT_HPP #define TAO_PEGTL_BUFFER_INPUT_HPP +#include <algorithm> +#include <cassert> #include <cstddef> #include <cstdint> #include <cstring> #include <memory> +#include <stdexcept> #include <string> #include "config.hpp" @@ -17,170 +20,193 @@ #include "tracking_mode.hpp" #include "internal/action_input.hpp" -#include "internal/bump_impl.hpp" +#include "internal/bump.hpp" #include "internal/iterator.hpp" #include "internal/marker.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + template< typename Reader, typename Eol = eol::lf_crlf, typename Source = std::string, std::size_t Chunk = 64 > + class buffer_input { - template< typename Reader, typename Eol = eol::lf_crlf, typename Source = std::string > - class buffer_input - { - public: - static constexpr tracking_mode tracking_mode_v = tracking_mode::IMMEDIATE; - using reader_t = Reader; + public: + using reader_t = Reader; - using eol_t = Eol; - using source_t = Source; + using eol_t = Eol; + using source_t = Source; - using iterator_t = internal::iterator; + using iterator_t = internal::iterator; - using action_t = internal::action_input< buffer_input >; + using action_t = internal::action_input< buffer_input >; - template< typename T, typename... As > - buffer_input( T&& in_source, const std::size_t maximum, As&&... as ) - : m_reader( std::forward< As >( as )... ), - m_maximum( maximum ), - m_buffer( new char[ maximum ] ), - m_current( m_buffer.get() ), - m_end( m_buffer.get() ), - m_source( std::forward< T >( in_source ) ) - { - } + static constexpr std::size_t chunk_size = Chunk; + static constexpr tracking_mode tracking_mode_v = tracking_mode::eager; - buffer_input( const buffer_input& ) = delete; - buffer_input( buffer_input&& ) = delete; + template< typename T, typename... As > + buffer_input( T&& in_source, const std::size_t maximum, As&&... as ) + : m_reader( std::forward< As >( as )... ), + m_maximum( maximum + Chunk ), + m_buffer( new char[ maximum + Chunk ] ), + m_current( m_buffer.get() ), + m_end( m_buffer.get() ), + m_source( std::forward< T >( in_source ) ) + { + static_assert( Chunk, "zero chunk size not implemented" ); + assert( m_maximum > maximum ); // Catches overflow; change to >= when zero chunk size is implemented. + } - ~buffer_input() = default; + buffer_input( const buffer_input& ) = delete; + buffer_input( buffer_input&& ) = delete; - void operator=( const buffer_input& ) = delete; - void operator=( buffer_input&& ) = delete; + ~buffer_input() = default; - bool empty() - { - require( 1 ); - return m_current.data == m_end; - } + void operator=( const buffer_input& ) = delete; + void operator=( buffer_input&& ) = delete; - std::size_t size( const std::size_t amount ) - { - require( amount ); - return std::size_t( m_end - m_current.data ); - } + [[nodiscard]] bool empty() + { + require( 1 ); + return m_current.data == m_end; + } - const char* current() const noexcept - { - return m_current.data; - } + [[nodiscard]] std::size_t size( const std::size_t amount ) + { + require( amount ); + return buffer_occupied(); + } - const char* end( const std::size_t amount ) - { - require( amount ); - return m_end; - } + [[nodiscard]] const char* current() const noexcept + { + return m_current.data; + } - std::size_t byte() const noexcept - { - return m_current.byte; - } + [[nodiscard]] const char* end( const std::size_t amount ) + { + require( amount ); + return m_end; + } - std::size_t line() const noexcept - { - return m_current.line; - } + [[nodiscard]] std::size_t byte() const noexcept + { + return m_current.byte; + } - std::size_t byte_in_line() const noexcept - { - return m_current.byte_in_line; - } + [[nodiscard]] std::size_t line() const noexcept + { + return m_current.line; + } - const Source& source() const noexcept - { - return m_source; - } + [[nodiscard]] std::size_t byte_in_line() const noexcept + { + return m_current.byte_in_line; + } - char peek_char( const std::size_t offset = 0 ) const noexcept - { - return m_current.data[ offset ]; - } + [[nodiscard]] const Source& source() const noexcept + { + return m_source; + } - std::uint8_t peek_byte( const std::size_t offset = 0 ) const noexcept - { - return static_cast< std::uint8_t >( peek_char( offset ) ); - } + [[nodiscard]] char peek_char( const std::size_t offset = 0 ) const noexcept + { + return m_current.data[ offset ]; + } - void bump( const std::size_t in_count = 1 ) noexcept - { - internal::bump( m_current, in_count, Eol::ch ); - } + [[nodiscard]] std::uint8_t peek_uint8( const std::size_t offset = 0 ) const noexcept + { + return static_cast< std::uint8_t >( peek_char( offset ) ); + } - void bump_in_this_line( const std::size_t in_count = 1 ) noexcept - { - internal::bump_in_this_line( m_current, in_count ); - } + void bump( const std::size_t in_count = 1 ) noexcept + { + internal::bump( m_current, in_count, Eol::ch ); + } - void bump_to_next_line( const std::size_t in_count = 1 ) noexcept - { - internal::bump_to_next_line( m_current, in_count ); - } + void bump_in_this_line( const std::size_t in_count = 1 ) noexcept + { + internal::bump_in_this_line( m_current, in_count ); + } + + void bump_to_next_line( const std::size_t in_count = 1 ) noexcept + { + internal::bump_to_next_line( m_current, in_count ); + } - void discard() noexcept - { + void discard() noexcept + { + if( m_current.data > m_buffer.get() + Chunk ) { const auto s = m_end - m_current.data; std::memmove( m_buffer.get(), m_current.data, s ); m_current.data = m_buffer.get(); m_end = m_buffer.get() + s; } + } - void require( const std::size_t amount ) - { - if( m_current.data + amount > m_end ) { - if( m_current.data + amount <= m_buffer.get() + m_maximum ) { - if( const auto r = m_reader( m_end, amount - std::size_t( m_end - m_current.data ) ) ) { - m_end += r; - } - else { - m_maximum = 0; - } - } - } + void require( const std::size_t amount ) + { + if( m_current.data + amount <= m_end ) { + return; } - - template< rewind_mode M > - internal::marker< iterator_t, M > mark() noexcept - { - return internal::marker< iterator_t, M >( m_current ); + if( m_current.data + amount > m_buffer.get() + m_maximum ) { + throw std::overflow_error( "require beyond end of buffer" ); } - - TAO_PEGTL_NAMESPACE::position position( const iterator_t& it ) const - { - return TAO_PEGTL_NAMESPACE::position( it, m_source ); + if( const auto r = m_reader( m_end, ( std::min )( buffer_free_after_end(), ( std::max )( amount, Chunk ) ) ) ) { + m_end += r; } + } - TAO_PEGTL_NAMESPACE::position position() const - { - return position( m_current ); - } + template< rewind_mode M > + [[nodiscard]] internal::marker< iterator_t, M > mark() noexcept + { + return internal::marker< iterator_t, M >( m_current ); + } - const iterator_t& iterator() const noexcept - { - return m_current; - } + [[nodiscard]] TAO_PEGTL_NAMESPACE::position position( const iterator_t& it ) const + { + return TAO_PEGTL_NAMESPACE::position( it, m_source ); + } + + [[nodiscard]] TAO_PEGTL_NAMESPACE::position position() const + { + return position( m_current ); + } - private: - Reader m_reader; - std::size_t m_maximum; - std::unique_ptr< char[] > m_buffer; - iterator_t m_current; - char* m_end; - const Source m_source; - void* internal_state = nullptr; - }; + [[nodiscard]] const iterator_t& iterator() const noexcept + { + return m_current; + } - } // namespace TAO_PEGTL_NAMESPACE + [[nodiscard]] std::size_t buffer_capacity() const noexcept + { + return m_maximum; + } -} // namespace tao + [[nodiscard]] std::size_t buffer_occupied() const noexcept + { + assert( m_end >= m_current.data ); + return std::size_t( m_end - m_current.data ); + } + + [[nodiscard]] std::size_t buffer_free_before_current() const noexcept + { + assert( m_current.data >= m_buffer.get() ); + return std::size_t( m_current.data - m_buffer.get() ); + } + + [[nodiscard]] std::size_t buffer_free_after_end() const noexcept + { + assert( m_buffer.get() + m_maximum >= m_end ); + return std::size_t( m_buffer.get() + m_maximum - m_end ); + } + + private: + Reader m_reader; + std::size_t m_maximum; + std::unique_ptr< char[] > m_buffer; // NOLINT + iterator_t m_current; + char* m_end; + const Source m_source; + }; + +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/change_action.hpp b/packages/PEGTL/include/tao/pegtl/change_action.hpp new file mode 100644 index 000000000..bd73db852 --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/change_action.hpp @@ -0,0 +1,38 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CHANGE_ACTION_HPP +#define TAO_PEGTL_CHANGE_ACTION_HPP + +#include <type_traits> + +#include "apply_mode.hpp" +#include "config.hpp" +#include "nothing.hpp" +#include "rewind_mode.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + template< template< typename... > class NewAction > + struct change_action + : maybe_nothing + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + static_assert( !std::is_same_v< Action< void >, NewAction< void > >, "old and new action class templates are identical" ); + return Control< Rule >::template match< A, M, NewAction, Control >( in, st... ); + } + }; + +} // namespace TAO_PEGTL_NAMESPACE + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/change_action_and_state.hpp b/packages/PEGTL/include/tao/pegtl/change_action_and_state.hpp new file mode 100644 index 000000000..84a174f17 --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/change_action_and_state.hpp @@ -0,0 +1,53 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CHANGE_ACTION_AND_STATE_HPP +#define TAO_PEGTL_CHANGE_ACTION_AND_STATE_HPP + +#include <type_traits> + +#include "apply_mode.hpp" +#include "config.hpp" +#include "match.hpp" +#include "nothing.hpp" +#include "rewind_mode.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + template< template< typename... > class NewAction, typename NewState > + struct change_action_and_state + : maybe_nothing + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + static_assert( !std::is_same_v< Action< void >, NewAction< void > >, "old and new action class templates are identical" ); + NewState s( static_cast< const Input& >( in ), st... ); + if( Control< Rule >::template match< A, M, NewAction, Control >( in, s ) ) { + if constexpr( A == apply_mode::action ) { + Action< Rule >::success( static_cast< const Input& >( in ), s, st... ); + } + return true; + } + return false; + } + + template< typename Input, + typename... States > + static void success( const Input& in, NewState& s, States&&... st ) noexcept( noexcept( s.success( in, st... ) ) ) + { + s.success( in, st... ); + } + }; + +} // namespace TAO_PEGTL_NAMESPACE + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/change_action_and_states.hpp b/packages/PEGTL/include/tao/pegtl/change_action_and_states.hpp new file mode 100644 index 000000000..c4fd02eee --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/change_action_and_states.hpp @@ -0,0 +1,62 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CHANGE_ACTION_AND_STATES_HPP +#define TAO_PEGTL_CHANGE_ACTION_AND_STATES_HPP + +#include <tuple> +#include <utility> + +#include "apply_mode.hpp" +#include "config.hpp" +#include "match.hpp" +#include "nothing.hpp" +#include "rewind_mode.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + template< template< typename... > class NewAction, typename... NewStates > + struct change_action_and_states + : maybe_nothing + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + std::size_t... Ns, + typename Input, + typename... States > + [[nodiscard]] static bool match( std::index_sequence< Ns... >, Input& in, States&&... st ) + { + auto t = std::tie( st... ); + if( Control< Rule >::template match< A, M, NewAction, Control >( in, std::get< Ns >( t )... ) ) { + if constexpr( A == apply_mode::action ) { + Action< Rule >::success( static_cast< const Input& >( in ), st... ); + } + return true; + } + return false; + } + + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + static_assert( !std::is_same_v< Action< void >, NewAction< void > >, "old and new action class templates are identical" ); + return match< Rule, A, M, Action, Control >( std::index_sequence_for< NewStates... >(), in, NewStates()..., st... ); + } + }; + +} // namespace TAO_PEGTL_NAMESPACE + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/change_control.hpp b/packages/PEGTL/include/tao/pegtl/change_control.hpp new file mode 100644 index 000000000..cef670118 --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/change_control.hpp @@ -0,0 +1,36 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CHANGE_CONTROL_HPP +#define TAO_PEGTL_CHANGE_CONTROL_HPP + +#include "apply_mode.hpp" +#include "config.hpp" +#include "match.hpp" +#include "nothing.hpp" +#include "rewind_mode.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + template< template< typename... > class NewControl > + struct change_control + : maybe_nothing + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + return TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, NewControl >( in, st... ); + } + }; + +} // namespace TAO_PEGTL_NAMESPACE + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/change_state.hpp b/packages/PEGTL/include/tao/pegtl/change_state.hpp new file mode 100644 index 000000000..9e3568e94 --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/change_state.hpp @@ -0,0 +1,50 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CHANGE_STATE_HPP +#define TAO_PEGTL_CHANGE_STATE_HPP + +#include "apply_mode.hpp" +#include "config.hpp" +#include "match.hpp" +#include "nothing.hpp" +#include "rewind_mode.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + template< typename NewState > + struct change_state + : maybe_nothing + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + NewState s( static_cast< const Input& >( in ), st... ); + if( TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, s ) ) { + if constexpr( A == apply_mode::action ) { + Action< Rule >::success( static_cast< const Input& >( in ), s, st... ); + } + return true; + } + return false; + } + + template< typename Input, + typename... States > + static void success( const Input& in, NewState& s, States&&... st ) noexcept( noexcept( s.success( in, st... ) ) ) + { + s.success( in, st... ); + } + }; + +} // namespace TAO_PEGTL_NAMESPACE + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/change_states.hpp b/packages/PEGTL/include/tao/pegtl/change_states.hpp new file mode 100644 index 000000000..09d49dd10 --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/change_states.hpp @@ -0,0 +1,61 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CHANGE_STATES_HPP +#define TAO_PEGTL_CHANGE_STATES_HPP + +#include <tuple> +#include <utility> + +#include "apply_mode.hpp" +#include "config.hpp" +#include "match.hpp" +#include "nothing.hpp" +#include "rewind_mode.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + template< typename... NewStates > + struct change_states + : maybe_nothing + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + std::size_t... Ns, + typename Input, + typename... States > + [[nodiscard]] static bool match( std::index_sequence< Ns... >, Input& in, States&&... st ) + { + auto t = std::tie( st... ); + if( TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, std::get< Ns >( t )... ) ) { + if constexpr( A == apply_mode::action ) { + Action< Rule >::success( static_cast< const Input& >( in ), st... ); + } + return true; + } + return false; + } + + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + return match< Rule, A, M, Action, Control >( std::index_sequence_for< NewStates... >(), in, NewStates()..., st... ); + } + }; + +} // namespace TAO_PEGTL_NAMESPACE + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/config.hpp b/packages/PEGTL/include/tao/pegtl/config.hpp index ed8cbd1df..4bcdd1035 100644 --- a/packages/PEGTL/include/tao/pegtl/config.hpp +++ b/packages/PEGTL/include/tao/pegtl/config.hpp @@ -1,16 +1,11 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 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 -// Compatibility, remove with 3.0 -#ifdef TAOCPP_PEGTL_NAMESPACE -#define TAO_PEGTL_NAMESPACE TAOCPP_PEGTL_NAMESPACE -#endif - -#ifndef TAO_PEGTL_NAMESPACE -#define TAO_PEGTL_NAMESPACE pegtl +#if !defined( TAO_PEGTL_NAMESPACE ) +#define TAO_PEGTL_NAMESPACE tao::pegtl #endif // Enable some improvements to the readability of diff --git a/packages/PEGTL/include/tao/pegtl/contrib/abnf.hpp b/packages/PEGTL/include/tao/pegtl/contrib/abnf.hpp index e006f0659..f90d6b949 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_CONTRIB_ABNF_HPP @@ -7,37 +7,29 @@ #include "../config.hpp" #include "../internal/rules.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::abnf { - namespace TAO_PEGTL_NAMESPACE - { - namespace abnf - { - // Core ABNF rules according to RFC 5234, Appendix B - - // clang-format off - struct ALPHA : internal::ranges< internal::peek_char, 'a', 'z', 'A', 'Z' > {}; - struct BIT : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, '0', '1' > {}; - struct CHAR : internal::range< internal::result_on_found::SUCCESS, internal::peek_char, char( 1 ), char( 127 ) > {}; - struct CR : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, '\r' > {}; - struct CRLF : internal::string< '\r', '\n' > {}; - struct CTL : internal::ranges< internal::peek_char, char( 0 ), char( 31 ), char( 127 ) > {}; - struct DIGIT : internal::range< internal::result_on_found::SUCCESS, internal::peek_char, '0', '9' > {}; - struct DQUOTE : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, '"' > {}; - struct HEXDIG : internal::ranges< internal::peek_char, '0', '9', 'a', 'f', 'A', 'F' > {}; - struct HTAB : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, '\t' > {}; - struct LF : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, '\n' > {}; - struct LWSP : internal::star< internal::sor< internal::string< '\r', '\n' >, internal::one< internal::result_on_found::SUCCESS, internal::peek_char, ' ', '\t' > >, internal::one< internal::result_on_found::SUCCESS, internal::peek_char, ' ', '\t' > > {}; - struct OCTET : internal::any< internal::peek_char > {}; - struct SP : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, ' ' > {}; - struct VCHAR : internal::range< internal::result_on_found::SUCCESS, internal::peek_char, char( 33 ), char( 126 ) > {}; - struct WSP : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, ' ', '\t' > {}; - // clang-format on - - } // namespace abnf - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + // Core ABNF rules according to RFC 5234, Appendix B + + // clang-format off + struct ALPHA : internal::ranges< internal::peek_char, 'a', 'z', 'A', 'Z' > {}; + struct BIT : internal::one< internal::result_on_found::success, internal::peek_char, '0', '1' > {}; + struct CHAR : internal::range< internal::result_on_found::success, internal::peek_char, char( 1 ), char( 127 ) > {}; + struct CR : internal::one< internal::result_on_found::success, internal::peek_char, '\r' > {}; + struct CRLF : internal::string< '\r', '\n' > {}; + struct CTL : internal::ranges< internal::peek_char, char( 0 ), char( 31 ), char( 127 ) > {}; + struct DIGIT : internal::range< internal::result_on_found::success, internal::peek_char, '0', '9' > {}; + struct DQUOTE : internal::one< internal::result_on_found::success, internal::peek_char, '"' > {}; + struct HEXDIG : internal::ranges< internal::peek_char, '0', '9', 'a', 'f', 'A', 'F' > {}; + struct HTAB : internal::one< internal::result_on_found::success, internal::peek_char, '\t' > {}; + struct LF : internal::one< internal::result_on_found::success, internal::peek_char, '\n' > {}; + struct LWSP : internal::star< internal::sor< internal::string< '\r', '\n' >, internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\t' > >, internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\t' > > {}; + struct OCTET : internal::any< internal::peek_char > {}; + struct SP : internal::one< internal::result_on_found::success, internal::peek_char, ' ' > {}; + struct VCHAR : internal::range< internal::result_on_found::success, internal::peek_char, char( 33 ), char( 126 ) > {}; + struct WSP : internal::one< internal::result_on_found::success, internal::peek_char, ' ', '\t' > {}; + // clang-format on + +} // namespace TAO_PEGTL_NAMESPACE::abnf #endif diff --git a/packages/PEGTL/include/tao/pegtl/contrib/alphabet.hpp b/packages/PEGTL/include/tao/pegtl/contrib/alphabet.hpp index 2e0228b32..e1d3292d5 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_CONTRIB_ALPHABET_HPP @@ -6,70 +6,62 @@ #include "../config.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::alphabet { - namespace TAO_PEGTL_NAMESPACE - { - namespace alphabet - { - static const int a = 'a'; - static const int b = 'b'; - static const int c = 'c'; - static const int d = 'd'; - static const int e = 'e'; - static const int f = 'f'; - static const int g = 'g'; - static const int h = 'h'; - static const int i = 'i'; - static const int j = 'j'; - static const int k = 'k'; - static const int l = 'l'; - static const int m = 'm'; - static const int n = 'n'; - static const int o = 'o'; - static const int p = 'p'; - static const int q = 'q'; - static const int r = 'r'; - static const int s = 's'; - static const int t = 't'; - static const int u = 'u'; - static const int v = 'v'; - static const int w = 'w'; - static const int x = 'x'; - static const int y = 'y'; - static const int z = 'z'; + static const int a = 'a'; + static const int b = 'b'; + static const int c = 'c'; + static const int d = 'd'; + static const int e = 'e'; + static const int f = 'f'; + static const int g = 'g'; + static const int h = 'h'; + static const int i = 'i'; + static const int j = 'j'; + static const int k = 'k'; + static const int l = 'l'; + static const int m = 'm'; + static const int n = 'n'; + static const int o = 'o'; + static const int p = 'p'; + static const int q = 'q'; + static const int r = 'r'; + static const int s = 's'; + static const int t = 't'; + static const int u = 'u'; + static const int v = 'v'; + static const int w = 'w'; + static const int x = 'x'; + static const int y = 'y'; + static const int z = 'z'; - static const int A = 'A'; - static const int B = 'B'; - static const int C = 'C'; - static const int D = 'D'; - static const int E = 'E'; - static const int F = 'F'; - static const int G = 'G'; - static const int H = 'H'; - static const int I = 'I'; - static const int J = 'J'; - static const int K = 'K'; - static const int L = 'L'; - static const int M = 'M'; - static const int N = 'N'; - static const int O = 'O'; - static const int P = 'P'; - static const int Q = 'Q'; - static const int R = 'R'; - static const int S = 'S'; - static const int T = 'T'; - static const int U = 'U'; - static const int V = 'V'; - static const int W = 'W'; - static const int X = 'X'; - static const int Y = 'Y'; - static const int Z = 'Z'; + static const int A = 'A'; + static const int B = 'B'; + static const int C = 'C'; + static const int D = 'D'; + static const int E = 'E'; + static const int F = 'F'; + static const int G = 'G'; + static const int H = 'H'; + static const int I = 'I'; + static const int J = 'J'; + static const int K = 'K'; + static const int L = 'L'; + static const int M = 'M'; + static const int N = 'N'; + static const int O = 'O'; + static const int P = 'P'; + static const int Q = 'Q'; + static const int R = 'R'; + static const int S = 'S'; + static const int T = 'T'; + static const int U = 'U'; + static const int V = 'V'; + static const int W = 'W'; + static const int X = 'X'; + static const int Y = 'Y'; + static const int Z = 'Z'; - } // namespace alphabet - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::alphabet #endif diff --git a/packages/PEGTL/include/tao/pegtl/contrib/changes.hpp b/packages/PEGTL/include/tao/pegtl/contrib/changes.hpp deleted file mode 100644 index 0aa8ab038..000000000 --- a/packages/PEGTL/include/tao/pegtl/contrib/changes.hpp +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2015-2018 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_CONTRIB_CHANGES_HPP -#define TAO_PEGTL_CONTRIB_CHANGES_HPP - -#include "../config.hpp" -#include "../normal.hpp" - -#include "../internal/conditional.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - struct dummy_disabled_state - { - template< typename... Ts > - void success( Ts&&... /*unused*/ ) const noexcept - { - } - }; - - template< apply_mode A, typename State > - using state_disable_helper = typename conditional< A == apply_mode::ACTION >::template type< State, dummy_disabled_state >; - - } // namespace internal - - template< typename Rule, typename State, template< typename... > class Base = normal > - struct change_state - : public Base< Rule > - { - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - internal::state_disable_helper< A, State > s; - - if( Base< Rule >::template match< A, M, Action, Control >( in, s ) ) { - s.success( st... ); - return true; - } - return false; - } - }; - - template< typename Rule, template< typename... > class Action, template< typename... > class Base = normal > - struct change_action - : public Base< Rule > - { - template< apply_mode A, - rewind_mode M, - template< typename... > class, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return Base< Rule >::template match< A, M, Action, Control >( in, st... ); - } - }; - - template< template< typename... > class Action, template< typename... > class Base > - struct change_both_helper - { - template< typename T > - using change_action = change_action< T, Action, Base >; - }; - - template< typename Rule, typename State, template< typename... > class Action, template< typename... > class Base = normal > - struct change_state_and_action - : public change_state< Rule, State, change_both_helper< Action, Base >::template change_action > - { - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/packages/PEGTL/include/tao/pegtl/contrib/counter.hpp b/packages/PEGTL/include/tao/pegtl/contrib/counter.hpp index 111fd38a8..fab396f93 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/counter.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/counter.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_CONTRIB_COUNTER_HPP @@ -12,47 +12,43 @@ #include "../internal/demangle.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + struct counter_data { - struct counter_data + unsigned start = 0; + unsigned success = 0; + unsigned failure = 0; + }; + + struct counter_state + { + std::map< std::string, counter_data > counts; + }; + + template< typename Rule > + struct counter + : normal< Rule > + { + template< typename Input > + static void start( const Input& /*unused*/, counter_state& ts ) { - unsigned start = 0; - unsigned success = 0; - unsigned failure = 0; - }; + ++ts.counts[ internal::demangle< Rule >() ].start; + } - struct counter_state + template< typename Input > + static void success( const Input& /*unused*/, counter_state& ts ) { - std::map< std::string, counter_data > counts; - }; + ++ts.counts[ internal::demangle< Rule >() ].success; + } - template< typename Rule > - struct counter - : normal< Rule > + template< typename Input > + static void failure( const Input& /*unused*/, counter_state& ts ) { - template< typename Input > - static void start( const Input& /*unused*/, counter_state& ts ) - { - ++ts.counts[ internal::demangle< Rule >() ].start; - } - - template< typename Input > - static void success( const Input& /*unused*/, counter_state& ts ) - { - ++ts.counts[ internal::demangle< Rule >() ].success; - } - - template< typename Input > - static void failure( const Input& /*unused*/, counter_state& ts ) - { - ++ts.counts[ internal::demangle< Rule >() ].failure; - } - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + ++ts.counts[ internal::demangle< Rule >() ].failure; + } + }; + +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/contrib/http.hpp b/packages/PEGTL/include/tao/pegtl/contrib/http.hpp index c49cb6f68..3d28f466a 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_CONTRIB_HTTP_HPP @@ -12,140 +12,131 @@ #include "abnf.hpp" #include "uri.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::http { - namespace TAO_PEGTL_NAMESPACE - { - namespace http - { - // HTTP 1.1 grammar according to RFC 7230. + // HTTP 1.1 grammar according to RFC 7230. - // This grammar is a direct PEG translation of the original HTTP grammar. - // It should be considered experimental -- in case of any issues, in particular - // missing rules for attached actions, please contact the developers. + // This grammar is a direct PEG translation of the original HTTP grammar. + // It should be considered experimental -- in case of any issues, in particular + // missing rules for attached actions, please contact the developers. - using OWS = star< abnf::WSP >; // optional whitespace - using RWS = plus< abnf::WSP >; // required whitespace - using BWS = OWS; // "bad" whitespace + using OWS = star< abnf::WSP >; // optional whitespace + using RWS = plus< abnf::WSP >; // required whitespace + using BWS = OWS; // "bad" whitespace - // cppcheck-suppress constStatement - using obs_text = not_range< 0x00, 0x7F >; - using obs_fold = seq< abnf::CRLF, plus< abnf::WSP > >; + using obs_text = not_range< 0x00, 0x7F >; + using obs_fold = seq< abnf::CRLF, plus< abnf::WSP > >; - // clang-format off - struct tchar : sor< abnf::ALPHA, abnf::DIGIT, one< '!', '#', '$', '%', '&', '\'', '*', '+', '-', '.', '^', '_', '`', '|', '~' > > {}; - struct token : plus< tchar > {}; + // clang-format off + struct tchar : sor< abnf::ALPHA, abnf::DIGIT, one< '!', '#', '$', '%', '&', '\'', '*', '+', '-', '.', '^', '_', '`', '|', '~' > > {}; + struct token : plus< tchar > {}; - struct field_name : token {}; + struct field_name : token {}; - struct field_vchar : sor< abnf::VCHAR, obs_text > {}; - struct field_content : list< field_vchar, plus< abnf::WSP > > {}; - struct field_value : star< sor< field_content, obs_fold > > {}; + struct field_vchar : sor< abnf::VCHAR, obs_text > {}; + struct field_content : list< field_vchar, plus< abnf::WSP > > {}; + struct field_value : star< sor< field_content, obs_fold > > {}; - struct header_field : seq< field_name, one< ':' >, OWS, field_value, OWS > {}; + struct header_field : seq< field_name, one< ':' >, OWS, field_value, OWS > {}; - struct method : token {}; + struct method : token {}; - struct absolute_path : plus< one< '/' >, uri::segment > {}; + struct absolute_path : plus< one< '/' >, uri::segment > {}; - struct origin_form : seq< absolute_path, uri::opt_query > {}; - struct absolute_form : uri::absolute_URI {}; - struct authority_form : uri::authority {}; - struct asterisk_form : one< '*' > {}; + struct origin_form : seq< absolute_path, uri::opt_query > {}; + struct absolute_form : uri::absolute_URI {}; + struct authority_form : uri::authority {}; + struct asterisk_form : one< '*' > {}; - struct request_target : sor< origin_form, absolute_form, authority_form, asterisk_form > {}; + struct request_target : sor< origin_form, absolute_form, authority_form, asterisk_form > {}; - struct status_code : rep< 3, abnf::DIGIT > {}; - struct reason_phrase : star< sor< abnf::VCHAR, obs_text, abnf::WSP > > {}; + struct status_code : rep< 3, abnf::DIGIT > {}; + struct reason_phrase : star< sor< abnf::VCHAR, obs_text, abnf::WSP > > {}; - struct HTTP_version : if_must< string< 'H', 'T', 'T', 'P', '/' >, abnf::DIGIT, one< '.' >, abnf::DIGIT > {}; + struct HTTP_version : if_must< string< 'H', 'T', 'T', 'P', '/' >, abnf::DIGIT, one< '.' >, abnf::DIGIT > {}; - struct request_line : if_must< method, abnf::SP, request_target, abnf::SP, HTTP_version, abnf::CRLF > {}; - struct status_line : if_must< HTTP_version, abnf::SP, status_code, abnf::SP, reason_phrase, abnf::CRLF > {}; - struct start_line : sor< status_line, request_line > {}; + struct request_line : if_must< method, abnf::SP, request_target, abnf::SP, HTTP_version, abnf::CRLF > {}; + struct status_line : if_must< HTTP_version, abnf::SP, status_code, abnf::SP, reason_phrase, abnf::CRLF > {}; + struct start_line : sor< status_line, request_line > {}; - struct message_body : star< abnf::OCTET > {}; - struct HTTP_message : seq< start_line, star< header_field, abnf::CRLF >, abnf::CRLF, opt< message_body > > {}; + struct message_body : star< abnf::OCTET > {}; + struct HTTP_message : seq< start_line, star< header_field, abnf::CRLF >, abnf::CRLF, opt< message_body > > {}; - struct Content_Length : plus< abnf::DIGIT > {}; + struct Content_Length : plus< abnf::DIGIT > {}; - struct uri_host : uri::host {}; - struct port : uri::port {}; + struct uri_host : uri::host {}; + struct port : uri::port {}; - struct Host : seq< uri_host, opt< one< ':' >, port > > {}; + struct Host : seq< uri_host, opt< one< ':' >, port > > {}; - // PEG are different from CFGs! (this replaces ctext and qdtext) - using text = sor< abnf::HTAB, range< 0x20, 0x7E >, obs_text >; + // PEG are different from CFGs! (this replaces ctext and qdtext) + using text = sor< abnf::HTAB, range< 0x20, 0x7E >, obs_text >; - struct quoted_pair : if_must< one< '\\' >, sor< abnf::VCHAR, obs_text, abnf::WSP > > {}; - struct quoted_string : if_must< abnf::DQUOTE, until< abnf::DQUOTE, sor< quoted_pair, text > > > {}; + struct quoted_pair : if_must< one< '\\' >, sor< abnf::VCHAR, obs_text, abnf::WSP > > {}; + struct quoted_string : if_must< abnf::DQUOTE, until< abnf::DQUOTE, sor< quoted_pair, text > > > {}; - struct transfer_parameter : seq< token, BWS, one< '=' >, BWS, sor< token, quoted_string > > {}; - struct transfer_extension : seq< token, star< OWS, one< ';' >, OWS, transfer_parameter > > {}; - struct transfer_coding : sor< istring< 'c', 'h', 'u', 'n', 'k', 'e', 'd' >, - istring< 'c', 'o', 'm', 'p', 'r', 'e', 's', 's' >, - istring< 'd', 'e', 'f', 'l', 'a', 't', 'e' >, - istring< 'g', 'z', 'i', 'p' >, - transfer_extension > {}; + struct transfer_parameter : seq< token, BWS, one< '=' >, BWS, sor< token, quoted_string > > {}; + struct transfer_extension : seq< token, star< OWS, one< ';' >, OWS, transfer_parameter > > {}; + struct transfer_coding : sor< istring< 'c', 'h', 'u', 'n', 'k', 'e', 'd' >, + istring< 'c', 'o', 'm', 'p', 'r', 'e', 's', 's' >, + istring< 'd', 'e', 'f', 'l', 'a', 't', 'e' >, + istring< 'g', 'z', 'i', 'p' >, + transfer_extension > {}; - struct rank : sor< seq< one< '0' >, opt< one< '.' >, rep_opt< 3, abnf::DIGIT > > >, - seq< one< '1' >, opt< one< '.' >, rep_opt< 3, one< '0' > > > > > {}; + struct rank : sor< seq< one< '0' >, opt< one< '.' >, rep_opt< 3, abnf::DIGIT > > >, + seq< one< '1' >, opt< one< '.' >, rep_opt< 3, one< '0' > > > > > {}; - struct t_ranking : seq< OWS, one< ';' >, OWS, one< 'q', 'Q' >, one< '=' >, rank > {}; - struct t_codings : sor< istring< 't', 'r', 'a', 'i', 'l', 'e', 'r', 's' >, seq< transfer_coding, opt< t_ranking > > > {}; + struct t_ranking : seq< OWS, one< ';' >, OWS, one< 'q', 'Q' >, one< '=' >, rank > {}; + struct t_codings : sor< istring< 't', 'r', 'a', 'i', 'l', 'e', 'r', 's' >, seq< transfer_coding, opt< t_ranking > > > {}; - struct TE : opt< sor< one< ',' >, t_codings >, star< OWS, one< ',' >, opt< OWS, t_codings > > > {}; + struct TE : opt< sor< one< ',' >, t_codings >, star< OWS, one< ',' >, opt< OWS, t_codings > > > {}; - template< typename T > - using make_comma_list = seq< star< one< ',' >, OWS >, T, star< OWS, one< ',' >, opt< OWS, T > > >; + template< typename T > + using make_comma_list = seq< star< one< ',' >, OWS >, T, star< OWS, one< ',' >, opt< OWS, T > > >; - struct connection_option : token {}; - struct Connection : make_comma_list< connection_option > {}; + struct connection_option : token {}; + struct Connection : make_comma_list< connection_option > {}; - struct Trailer : make_comma_list< field_name > {}; + struct Trailer : make_comma_list< field_name > {}; - struct Transfer_Encoding : make_comma_list< transfer_coding > {}; + struct Transfer_Encoding : make_comma_list< transfer_coding > {}; - struct protocol_name : token {}; - struct protocol_version : token {}; - struct protocol : seq< protocol_name, opt< one< '/' >, protocol_version > > {}; - struct Upgrade : make_comma_list< protocol > {}; + struct protocol_name : token {}; + struct protocol_version : token {}; + struct protocol : seq< protocol_name, opt< one< '/' >, protocol_version > > {}; + struct Upgrade : make_comma_list< protocol > {}; - struct pseudonym : token {}; + struct pseudonym : token {}; - struct received_protocol : seq< opt< protocol_name, one< '/' > >, protocol_version > {}; - struct received_by : sor< seq< uri_host, opt< one< ':' >, port > >, pseudonym > {}; + struct received_protocol : seq< opt< protocol_name, one< '/' > >, protocol_version > {}; + struct received_by : sor< seq< uri_host, opt< one< ':' >, port > >, pseudonym > {}; - struct comment : if_must< one< '(' >, until< one< ')' >, sor< comment, quoted_pair, text > > > {}; + struct comment : if_must< one< '(' >, until< one< ')' >, sor< comment, quoted_pair, text > > > {}; - struct Via : make_comma_list< seq< received_protocol, RWS, received_by, opt< RWS, comment > > > {}; + struct Via : make_comma_list< seq< received_protocol, RWS, received_by, opt< RWS, comment > > > {}; - struct http_URI : if_must< istring< 'h', 't', 't', 'p', ':', '/', '/' >, uri::authority, uri::path_abempty, uri::opt_query, uri::opt_fragment > {}; - struct https_URI : if_must< istring< 'h', 't', 't', 'p', 's', ':', '/', '/' >, uri::authority, uri::path_abempty, uri::opt_query, uri::opt_fragment > {}; + struct http_URI : if_must< istring< 'h', 't', 't', 'p', ':', '/', '/' >, uri::authority, uri::path_abempty, uri::opt_query, uri::opt_fragment > {}; + struct https_URI : if_must< istring< 'h', 't', 't', 'p', 's', ':', '/', '/' >, uri::authority, uri::path_abempty, uri::opt_query, uri::opt_fragment > {}; - struct partial_URI : seq< uri::relative_part, uri::opt_query > {}; + struct partial_URI : seq< uri::relative_part, uri::opt_query > {}; - struct chunk_size : plus< abnf::HEXDIG > {}; + struct chunk_size : plus< abnf::HEXDIG > {}; - struct chunk_ext_name : token {}; - struct chunk_ext_val : sor< quoted_string, token > {}; - struct chunk_ext : star_must< one< ';' >, chunk_ext_name, if_must< one< '=' >, chunk_ext_val > > {}; + struct chunk_ext_name : token {}; + struct chunk_ext_val : sor< quoted_string, token > {}; + struct chunk_ext : star_must< one< ';' >, chunk_ext_name, if_must< one< '=' >, chunk_ext_val > > {}; - struct chunk_data : until< at< abnf::CRLF >, abnf::OCTET > {}; + struct chunk_data : until< at< abnf::CRLF >, abnf::OCTET > {}; - struct chunk : seq< chunk_size, opt< chunk_ext >, abnf::CRLF, chunk_data, abnf::CRLF > {}; + struct chunk : seq< chunk_size, opt< chunk_ext >, abnf::CRLF, chunk_data, abnf::CRLF > {}; - struct last_chunk : seq< plus< one< '0' > >, opt< chunk_ext >, abnf::CRLF > {}; + struct last_chunk : seq< plus< one< '0' > >, opt< chunk_ext >, abnf::CRLF > {}; - struct trailer_part : star< header_field, abnf::CRLF > {}; + struct trailer_part : star< header_field, abnf::CRLF > {}; - struct chunked_body : seq< until< last_chunk, chunk >, trailer_part, abnf::CRLF > {}; - // clang-format on + struct chunked_body : seq< until< last_chunk, chunk >, trailer_part, abnf::CRLF > {}; + // clang-format on - } // namespace http - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::http #endif diff --git a/packages/PEGTL/include/tao/pegtl/contrib/icu/internal.hpp b/packages/PEGTL/include/tao/pegtl/contrib/icu/internal.hpp index e1af0bba2..c71bac342 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 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_CONTRIB_ICU_INTERNAL_HPP @@ -11,66 +11,58 @@ #include "../../analysis/generic.hpp" #include "../../internal/skip_control.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + namespace icu { - namespace internal + template< typename Peek, UProperty P, bool V = true > + struct binary_property { - namespace icu - { - template< typename Peek, UProperty P, bool V = true > - struct binary_property - { - using analyze_t = analysis::generic< analysis::rule_type::ANY >; + using analyze_t = analysis::generic< analysis::rule_type::any >; - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( Peek::peek( in ) ) ) - { - if( const auto r = Peek::peek( in ) ) { - if( u_hasBinaryProperty( r.data, P ) == V ) { - in.bump( r.size ); - return true; - } + template< typename Input > + [[nodiscard]] static bool match( Input& in ) noexcept( noexcept( in.size( Peek::max_input_size ) ) ) + { + if( const std::size_t s = in.size( Peek::max_input_size ); s >= Peek::min_input_size ) { + if( const auto r = Peek::peek( in, s ) ) { + if( u_hasBinaryProperty( r.data, P ) == V ) { + in.bump( r.size ); + return true; } - return false; } - }; + } + return false; + } + }; - template< typename Peek, UProperty P, int V > - struct property_value - { - using analyze_t = analysis::generic< analysis::rule_type::ANY >; + template< typename Peek, UProperty P, int V > + struct property_value + { + using analyze_t = analysis::generic< analysis::rule_type::any >; - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( Peek::peek( in ) ) ) - { - if( const auto r = Peek::peek( in ) ) { - if( u_getIntPropertyValue( r.data, P ) == V ) { - in.bump( r.size ); - return true; - } + template< typename Input > + [[nodiscard]] static bool match( Input& in ) noexcept( noexcept( in.size( Peek::max_input_size ) ) ) + { + if( const std::size_t s = in.size( Peek::max_input_size ); s >= Peek::min_input_size ) { + if( const auto r = Peek::peek( in, s ) ) { + if( u_getIntPropertyValue( r.data, P ) == V ) { + in.bump( r.size ); + return true; } - return false; } - }; + } + return false; + } + }; - } // namespace icu - - template< typename Peek, UProperty P, bool V > - struct skip_control< icu::binary_property< Peek, P, V > > : std::true_type - { - }; - - template< typename Peek, UProperty P, int V > - struct skip_control< icu::property_value< Peek, P, V > > : std::true_type - { - }; + } // namespace icu - } // namespace internal + template< typename Peek, UProperty P, bool V > + inline constexpr bool skip_control< icu::binary_property< Peek, P, V > > = true; - } // namespace TAO_PEGTL_NAMESPACE + template< typename Peek, UProperty P, int V > + inline constexpr bool skip_control< icu::property_value< Peek, P, V > > = true; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/contrib/icu/utf16.hpp b/packages/PEGTL/include/tao/pegtl/contrib/icu/utf16.hpp index 2412545d3..316eb84c3 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/icu/utf16.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/icu/utf16.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_CONTRIB_ICU_UTF16_HPP @@ -11,202 +11,190 @@ #include "../../internal/peek_utf16.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace utf16_be::icu { - namespace utf16_be + template< UProperty P, bool V = true > + struct binary_property + : internal::icu::binary_property< internal::peek_utf16_be, P, V > { - namespace icu - { - template< UProperty P, bool V = true > - struct binary_property - : internal::icu::binary_property< internal::peek_utf16_be, P, V > - { - }; - - template< UProperty P, int V > - struct property_value - : internal::icu::property_value< internal::peek_utf16_be, P, V > - { - }; - - // clang-format off - struct alphabetic : binary_property< UCHAR_ALPHABETIC > {}; - struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {}; - struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {}; - struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {}; - struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {}; - struct dash : binary_property< UCHAR_DASH > {}; - struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {}; - struct deprecated : binary_property< UCHAR_DEPRECATED > {}; - struct diacritic : binary_property< UCHAR_DIACRITIC > {}; - struct extender : binary_property< UCHAR_EXTENDER > {}; - struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {}; - struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {}; - struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {}; - struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {}; - struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {}; - struct hyphen : binary_property< UCHAR_HYPHEN > {}; - struct id_continue : binary_property< UCHAR_ID_CONTINUE > {}; - struct id_start : binary_property< UCHAR_ID_START > {}; - struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {}; - struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {}; - struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {}; - struct join_control : binary_property< UCHAR_JOIN_CONTROL > {}; - struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {}; - struct lowercase : binary_property< UCHAR_LOWERCASE > {}; - struct math : binary_property< UCHAR_MATH > {}; - struct nfc_inert : binary_property< UCHAR_NFC_INERT > {}; - struct nfd_inert : binary_property< UCHAR_NFD_INERT > {}; - struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {}; - struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {}; - struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {}; - struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {}; - struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {}; - struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {}; - struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {}; - struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {}; - struct posix_print : binary_property< UCHAR_POSIX_PRINT > {}; - struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {}; - struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {}; - struct radical : binary_property< UCHAR_RADICAL > {}; - struct s_term : binary_property< UCHAR_S_TERM > {}; - struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {}; - struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {}; - struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {}; - struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {}; - struct uppercase : binary_property< UCHAR_UPPERCASE > {}; - struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {}; - struct white_space : binary_property< UCHAR_WHITE_SPACE > {}; - struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {}; - struct xid_start : binary_property< UCHAR_XID_START > {}; - - template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {}; - template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {}; - template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {}; - template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {}; - template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {}; - template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {}; - template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {}; - template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {}; - template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {}; - template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {}; - // UNormalizationCheckResult requires an additional header <unicode/unorm2.h>: - // template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {}; - template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {}; - template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {}; - template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {}; - - template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {}; - template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {}; - template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {}; - // clang-format on - - } // namespace icu - - } // namespace utf16_be - - namespace utf16_le + }; + + template< UProperty P, int V > + struct property_value + : internal::icu::property_value< internal::peek_utf16_be, P, V > + { + }; + + // clang-format off + struct alphabetic : binary_property< UCHAR_ALPHABETIC > {}; + struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {}; + struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {}; + struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {}; + struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {}; + struct dash : binary_property< UCHAR_DASH > {}; + struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {}; + struct deprecated : binary_property< UCHAR_DEPRECATED > {}; + struct diacritic : binary_property< UCHAR_DIACRITIC > {}; + struct extender : binary_property< UCHAR_EXTENDER > {}; + struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {}; + struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {}; + struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {}; + struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {}; + struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {}; + struct hyphen : binary_property< UCHAR_HYPHEN > {}; + struct id_continue : binary_property< UCHAR_ID_CONTINUE > {}; + struct id_start : binary_property< UCHAR_ID_START > {}; + struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {}; + struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {}; + struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {}; + struct join_control : binary_property< UCHAR_JOIN_CONTROL > {}; + struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {}; + struct lowercase : binary_property< UCHAR_LOWERCASE > {}; + struct math : binary_property< UCHAR_MATH > {}; + struct nfc_inert : binary_property< UCHAR_NFC_INERT > {}; + struct nfd_inert : binary_property< UCHAR_NFD_INERT > {}; + struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {}; + struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {}; + struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {}; + struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {}; + struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {}; + struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {}; + struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {}; + struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {}; + struct posix_print : binary_property< UCHAR_POSIX_PRINT > {}; + struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {}; + struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {}; + struct radical : binary_property< UCHAR_RADICAL > {}; + struct s_term : binary_property< UCHAR_S_TERM > {}; + struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {}; + struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {}; + struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {}; + struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {}; + struct uppercase : binary_property< UCHAR_UPPERCASE > {}; + struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {}; + struct white_space : binary_property< UCHAR_WHITE_SPACE > {}; + struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {}; + struct xid_start : binary_property< UCHAR_XID_START > {}; + + template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {}; + template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {}; + template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {}; + template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {}; + template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {}; + template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {}; + template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {}; + template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {}; + template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {}; + template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {}; + // UNormalizationCheckResult requires an additional header <unicode/unorm2.h>: + // template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {}; + template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {}; + template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {}; + template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {}; + + template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {}; + template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {}; + template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {}; + // clang-format on + + } // namespace utf16_be::icu + + namespace utf16_le::icu + { + template< UProperty P, bool V = true > + struct binary_property + : internal::icu::binary_property< internal::peek_utf16_le, P, V > + { + }; + + template< UProperty P, int V > + struct property_value + : internal::icu::property_value< internal::peek_utf16_le, P, V > { - namespace icu - { - template< UProperty P, bool V = true > - struct binary_property - : internal::icu::binary_property< internal::peek_utf16_le, P, V > - { - }; - - template< UProperty P, int V > - struct property_value - : internal::icu::property_value< internal::peek_utf16_le, P, V > - { - }; - - // clang-format off - struct alphabetic : binary_property< UCHAR_ALPHABETIC > {}; - struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {}; - struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {}; - struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {}; - struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {}; - struct dash : binary_property< UCHAR_DASH > {}; - struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {}; - struct deprecated : binary_property< UCHAR_DEPRECATED > {}; - struct diacritic : binary_property< UCHAR_DIACRITIC > {}; - struct extender : binary_property< UCHAR_EXTENDER > {}; - struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {}; - struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {}; - struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {}; - struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {}; - struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {}; - struct hyphen : binary_property< UCHAR_HYPHEN > {}; - struct id_continue : binary_property< UCHAR_ID_CONTINUE > {}; - struct id_start : binary_property< UCHAR_ID_START > {}; - struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {}; - struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {}; - struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {}; - struct join_control : binary_property< UCHAR_JOIN_CONTROL > {}; - struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {}; - struct lowercase : binary_property< UCHAR_LOWERCASE > {}; - struct math : binary_property< UCHAR_MATH > {}; - struct nfc_inert : binary_property< UCHAR_NFC_INERT > {}; - struct nfd_inert : binary_property< UCHAR_NFD_INERT > {}; - struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {}; - struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {}; - struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {}; - struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {}; - struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {}; - struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {}; - struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {}; - struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {}; - struct posix_print : binary_property< UCHAR_POSIX_PRINT > {}; - struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {}; - struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {}; - struct radical : binary_property< UCHAR_RADICAL > {}; - struct s_term : binary_property< UCHAR_S_TERM > {}; - struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {}; - struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {}; - struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {}; - struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {}; - struct uppercase : binary_property< UCHAR_UPPERCASE > {}; - struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {}; - struct white_space : binary_property< UCHAR_WHITE_SPACE > {}; - struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {}; - struct xid_start : binary_property< UCHAR_XID_START > {}; - - template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {}; - template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {}; - template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {}; - template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {}; - template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {}; - template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {}; - template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {}; - template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {}; - template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {}; - template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {}; - // UNormalizationCheckResult requires an additional header <unicode/unorm2.h>: - // template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {}; - template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {}; - template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {}; - template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {}; - - template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {}; - template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {}; - template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {}; - // clang-format on - - } // namespace icu - - } // namespace utf16_le - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + }; + + // clang-format off + struct alphabetic : binary_property< UCHAR_ALPHABETIC > {}; + struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {}; + struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {}; + struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {}; + struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {}; + struct dash : binary_property< UCHAR_DASH > {}; + struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {}; + struct deprecated : binary_property< UCHAR_DEPRECATED > {}; + struct diacritic : binary_property< UCHAR_DIACRITIC > {}; + struct extender : binary_property< UCHAR_EXTENDER > {}; + struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {}; + struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {}; + struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {}; + struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {}; + struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {}; + struct hyphen : binary_property< UCHAR_HYPHEN > {}; + struct id_continue : binary_property< UCHAR_ID_CONTINUE > {}; + struct id_start : binary_property< UCHAR_ID_START > {}; + struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {}; + struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {}; + struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {}; + struct join_control : binary_property< UCHAR_JOIN_CONTROL > {}; + struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {}; + struct lowercase : binary_property< UCHAR_LOWERCASE > {}; + struct math : binary_property< UCHAR_MATH > {}; + struct nfc_inert : binary_property< UCHAR_NFC_INERT > {}; + struct nfd_inert : binary_property< UCHAR_NFD_INERT > {}; + struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {}; + struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {}; + struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {}; + struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {}; + struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {}; + struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {}; + struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {}; + struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {}; + struct posix_print : binary_property< UCHAR_POSIX_PRINT > {}; + struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {}; + struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {}; + struct radical : binary_property< UCHAR_RADICAL > {}; + struct s_term : binary_property< UCHAR_S_TERM > {}; + struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {}; + struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {}; + struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {}; + struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {}; + struct uppercase : binary_property< UCHAR_UPPERCASE > {}; + struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {}; + struct white_space : binary_property< UCHAR_WHITE_SPACE > {}; + struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {}; + struct xid_start : binary_property< UCHAR_XID_START > {}; + + template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {}; + template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {}; + template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {}; + template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {}; + template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {}; + template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {}; + template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {}; + template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {}; + template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {}; + template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {}; + // UNormalizationCheckResult requires an additional header <unicode/unorm2.h>: + // template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {}; + template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {}; + template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {}; + template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {}; + + template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {}; + template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {}; + template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {}; + // clang-format on + + } // namespace utf16_le::icu + +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/contrib/icu/utf32.hpp b/packages/PEGTL/include/tao/pegtl/contrib/icu/utf32.hpp index 95c1a34b8..8c7189edf 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/icu/utf32.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/icu/utf32.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_CONTRIB_ICU_UTF32_HPP @@ -11,202 +11,190 @@ #include "../../internal/peek_utf32.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace utf32_be::icu { - namespace utf32_be + template< UProperty P, bool V = true > + struct binary_property + : internal::icu::binary_property< internal::peek_utf32_be, P, V > { - namespace icu - { - template< UProperty P, bool V = true > - struct binary_property - : internal::icu::binary_property< internal::peek_utf32_be, P, V > - { - }; - - template< UProperty P, int V > - struct property_value - : internal::icu::property_value< internal::peek_utf32_be, P, V > - { - }; - - // clang-format off - struct alphabetic : binary_property< UCHAR_ALPHABETIC > {}; - struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {}; - struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {}; - struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {}; - struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {}; - struct dash : binary_property< UCHAR_DASH > {}; - struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {}; - struct deprecated : binary_property< UCHAR_DEPRECATED > {}; - struct diacritic : binary_property< UCHAR_DIACRITIC > {}; - struct extender : binary_property< UCHAR_EXTENDER > {}; - struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {}; - struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {}; - struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {}; - struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {}; - struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {}; - struct hyphen : binary_property< UCHAR_HYPHEN > {}; - struct id_continue : binary_property< UCHAR_ID_CONTINUE > {}; - struct id_start : binary_property< UCHAR_ID_START > {}; - struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {}; - struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {}; - struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {}; - struct join_control : binary_property< UCHAR_JOIN_CONTROL > {}; - struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {}; - struct lowercase : binary_property< UCHAR_LOWERCASE > {}; - struct math : binary_property< UCHAR_MATH > {}; - struct nfc_inert : binary_property< UCHAR_NFC_INERT > {}; - struct nfd_inert : binary_property< UCHAR_NFD_INERT > {}; - struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {}; - struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {}; - struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {}; - struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {}; - struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {}; - struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {}; - struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {}; - struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {}; - struct posix_print : binary_property< UCHAR_POSIX_PRINT > {}; - struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {}; - struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {}; - struct radical : binary_property< UCHAR_RADICAL > {}; - struct s_term : binary_property< UCHAR_S_TERM > {}; - struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {}; - struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {}; - struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {}; - struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {}; - struct uppercase : binary_property< UCHAR_UPPERCASE > {}; - struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {}; - struct white_space : binary_property< UCHAR_WHITE_SPACE > {}; - struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {}; - struct xid_start : binary_property< UCHAR_XID_START > {}; - - template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {}; - template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {}; - template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {}; - template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {}; - template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {}; - template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {}; - template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {}; - template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {}; - template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {}; - template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {}; - // UNormalizationCheckResult requires an additional header <unicode/unorm2.h>: - // template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {}; - template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {}; - template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {}; - template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {}; - - template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {}; - template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {}; - template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {}; - // clang-format on - - } // namespace icu - - } // namespace utf32_be - - namespace utf32_le + }; + + template< UProperty P, int V > + struct property_value + : internal::icu::property_value< internal::peek_utf32_be, P, V > + { + }; + + // clang-format off + struct alphabetic : binary_property< UCHAR_ALPHABETIC > {}; + struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {}; + struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {}; + struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {}; + struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {}; + struct dash : binary_property< UCHAR_DASH > {}; + struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {}; + struct deprecated : binary_property< UCHAR_DEPRECATED > {}; + struct diacritic : binary_property< UCHAR_DIACRITIC > {}; + struct extender : binary_property< UCHAR_EXTENDER > {}; + struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {}; + struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {}; + struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {}; + struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {}; + struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {}; + struct hyphen : binary_property< UCHAR_HYPHEN > {}; + struct id_continue : binary_property< UCHAR_ID_CONTINUE > {}; + struct id_start : binary_property< UCHAR_ID_START > {}; + struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {}; + struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {}; + struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {}; + struct join_control : binary_property< UCHAR_JOIN_CONTROL > {}; + struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {}; + struct lowercase : binary_property< UCHAR_LOWERCASE > {}; + struct math : binary_property< UCHAR_MATH > {}; + struct nfc_inert : binary_property< UCHAR_NFC_INERT > {}; + struct nfd_inert : binary_property< UCHAR_NFD_INERT > {}; + struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {}; + struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {}; + struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {}; + struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {}; + struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {}; + struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {}; + struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {}; + struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {}; + struct posix_print : binary_property< UCHAR_POSIX_PRINT > {}; + struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {}; + struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {}; + struct radical : binary_property< UCHAR_RADICAL > {}; + struct s_term : binary_property< UCHAR_S_TERM > {}; + struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {}; + struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {}; + struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {}; + struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {}; + struct uppercase : binary_property< UCHAR_UPPERCASE > {}; + struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {}; + struct white_space : binary_property< UCHAR_WHITE_SPACE > {}; + struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {}; + struct xid_start : binary_property< UCHAR_XID_START > {}; + + template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {}; + template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {}; + template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {}; + template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {}; + template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {}; + template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {}; + template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {}; + template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {}; + template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {}; + template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {}; + // UNormalizationCheckResult requires an additional header <unicode/unorm2.h>: + // template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {}; + template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {}; + template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {}; + template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {}; + + template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {}; + template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {}; + template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {}; + // clang-format on + + } // namespace utf32_be::icu + + namespace utf32_le::icu + { + template< UProperty P, bool V = true > + struct binary_property + : internal::icu::binary_property< internal::peek_utf32_le, P, V > + { + }; + + template< UProperty P, int V > + struct property_value + : internal::icu::property_value< internal::peek_utf32_le, P, V > { - namespace icu - { - template< UProperty P, bool V = true > - struct binary_property - : internal::icu::binary_property< internal::peek_utf32_le, P, V > - { - }; - - template< UProperty P, int V > - struct property_value - : internal::icu::property_value< internal::peek_utf32_le, P, V > - { - }; - - // clang-format off - struct alphabetic : binary_property< UCHAR_ALPHABETIC > {}; - struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {}; - struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {}; - struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {}; - struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {}; - struct dash : binary_property< UCHAR_DASH > {}; - struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {}; - struct deprecated : binary_property< UCHAR_DEPRECATED > {}; - struct diacritic : binary_property< UCHAR_DIACRITIC > {}; - struct extender : binary_property< UCHAR_EXTENDER > {}; - struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {}; - struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {}; - struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {}; - struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {}; - struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {}; - struct hyphen : binary_property< UCHAR_HYPHEN > {}; - struct id_continue : binary_property< UCHAR_ID_CONTINUE > {}; - struct id_start : binary_property< UCHAR_ID_START > {}; - struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {}; - struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {}; - struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {}; - struct join_control : binary_property< UCHAR_JOIN_CONTROL > {}; - struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {}; - struct lowercase : binary_property< UCHAR_LOWERCASE > {}; - struct math : binary_property< UCHAR_MATH > {}; - struct nfc_inert : binary_property< UCHAR_NFC_INERT > {}; - struct nfd_inert : binary_property< UCHAR_NFD_INERT > {}; - struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {}; - struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {}; - struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {}; - struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {}; - struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {}; - struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {}; - struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {}; - struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {}; - struct posix_print : binary_property< UCHAR_POSIX_PRINT > {}; - struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {}; - struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {}; - struct radical : binary_property< UCHAR_RADICAL > {}; - struct s_term : binary_property< UCHAR_S_TERM > {}; - struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {}; - struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {}; - struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {}; - struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {}; - struct uppercase : binary_property< UCHAR_UPPERCASE > {}; - struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {}; - struct white_space : binary_property< UCHAR_WHITE_SPACE > {}; - struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {}; - struct xid_start : binary_property< UCHAR_XID_START > {}; - - template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {}; - template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {}; - template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {}; - template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {}; - template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {}; - template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {}; - template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {}; - template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {}; - template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {}; - template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {}; - // UNormalizationCheckResult requires an additional header <unicode/unorm2.h>: - // template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {}; - template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {}; - template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {}; - template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {}; - - template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {}; - template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {}; - template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {}; - // clang-format on - - } // namespace icu - - } // namespace utf32_le - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + }; + + // clang-format off + struct alphabetic : binary_property< UCHAR_ALPHABETIC > {}; + struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {}; + struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {}; + struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {}; + struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {}; + struct dash : binary_property< UCHAR_DASH > {}; + struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {}; + struct deprecated : binary_property< UCHAR_DEPRECATED > {}; + struct diacritic : binary_property< UCHAR_DIACRITIC > {}; + struct extender : binary_property< UCHAR_EXTENDER > {}; + struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {}; + struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {}; + struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {}; + struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {}; + struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {}; + struct hyphen : binary_property< UCHAR_HYPHEN > {}; + struct id_continue : binary_property< UCHAR_ID_CONTINUE > {}; + struct id_start : binary_property< UCHAR_ID_START > {}; + struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {}; + struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {}; + struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {}; + struct join_control : binary_property< UCHAR_JOIN_CONTROL > {}; + struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {}; + struct lowercase : binary_property< UCHAR_LOWERCASE > {}; + struct math : binary_property< UCHAR_MATH > {}; + struct nfc_inert : binary_property< UCHAR_NFC_INERT > {}; + struct nfd_inert : binary_property< UCHAR_NFD_INERT > {}; + struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {}; + struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {}; + struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {}; + struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {}; + struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {}; + struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {}; + struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {}; + struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {}; + struct posix_print : binary_property< UCHAR_POSIX_PRINT > {}; + struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {}; + struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {}; + struct radical : binary_property< UCHAR_RADICAL > {}; + struct s_term : binary_property< UCHAR_S_TERM > {}; + struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {}; + struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {}; + struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {}; + struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {}; + struct uppercase : binary_property< UCHAR_UPPERCASE > {}; + struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {}; + struct white_space : binary_property< UCHAR_WHITE_SPACE > {}; + struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {}; + struct xid_start : binary_property< UCHAR_XID_START > {}; + + template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {}; + template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {}; + template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {}; + template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {}; + template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {}; + template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {}; + template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {}; + template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {}; + template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {}; + template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {}; + // UNormalizationCheckResult requires an additional header <unicode/unorm2.h>: + // template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {}; + template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {}; + template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {}; + template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {}; + + template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {}; + template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {}; + template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {}; + // clang-format on + + } // namespace utf32_le::icu + +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/contrib/icu/utf8.hpp b/packages/PEGTL/include/tao/pegtl/contrib/icu/utf8.hpp index a2aba563f..7c7cc5573 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/icu/utf8.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/icu/utf8.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_CONTRIB_ICU_UTF8_HPP @@ -11,107 +11,95 @@ #include "../../internal/peek_utf8.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::utf8::icu { - namespace TAO_PEGTL_NAMESPACE + template< UProperty P, bool V = true > + struct binary_property + : internal::icu::binary_property< internal::peek_utf8, P, V > { - namespace utf8 - { - namespace icu - { - template< UProperty P, bool V = true > - struct binary_property - : internal::icu::binary_property< internal::peek_utf8, P, V > - { - }; + }; - template< UProperty P, int V > - struct property_value - : internal::icu::property_value< internal::peek_utf8, P, V > - { - }; - - // clang-format off - struct alphabetic : binary_property< UCHAR_ALPHABETIC > {}; - struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {}; - struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {}; - struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {}; - struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {}; - struct dash : binary_property< UCHAR_DASH > {}; - struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {}; - struct deprecated : binary_property< UCHAR_DEPRECATED > {}; - struct diacritic : binary_property< UCHAR_DIACRITIC > {}; - struct extender : binary_property< UCHAR_EXTENDER > {}; - struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {}; - struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {}; - struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {}; - struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {}; - struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {}; - struct hyphen : binary_property< UCHAR_HYPHEN > {}; - struct id_continue : binary_property< UCHAR_ID_CONTINUE > {}; - struct id_start : binary_property< UCHAR_ID_START > {}; - struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {}; - struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {}; - struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {}; - struct join_control : binary_property< UCHAR_JOIN_CONTROL > {}; - struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {}; - struct lowercase : binary_property< UCHAR_LOWERCASE > {}; - struct math : binary_property< UCHAR_MATH > {}; - struct nfc_inert : binary_property< UCHAR_NFC_INERT > {}; - struct nfd_inert : binary_property< UCHAR_NFD_INERT > {}; - struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {}; - struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {}; - struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {}; - struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {}; - struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {}; - struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {}; - struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {}; - struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {}; - struct posix_print : binary_property< UCHAR_POSIX_PRINT > {}; - struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {}; - struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {}; - struct radical : binary_property< UCHAR_RADICAL > {}; - struct s_term : binary_property< UCHAR_S_TERM > {}; - struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {}; - struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {}; - struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {}; - struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {}; - struct uppercase : binary_property< UCHAR_UPPERCASE > {}; - struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {}; - struct white_space : binary_property< UCHAR_WHITE_SPACE > {}; - struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {}; - struct xid_start : binary_property< UCHAR_XID_START > {}; - - template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {}; - template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {}; - template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {}; - template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {}; - template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {}; - template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {}; - template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {}; - template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {}; - template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {}; - template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {}; - // UNormalizationCheckResult requires an additional header <unicode/unorm2.h>: - // template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {}; - // template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {}; - template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {}; - template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {}; - template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {}; - - template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {}; - template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {}; - template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {}; - // clang-format on + template< UProperty P, int V > + struct property_value + : internal::icu::property_value< internal::peek_utf8, P, V > + { + }; - } // namespace icu + // clang-format off + struct alphabetic : binary_property< UCHAR_ALPHABETIC > {}; + struct ascii_hex_digit : binary_property< UCHAR_ASCII_HEX_DIGIT > {}; + struct bidi_control : binary_property< UCHAR_BIDI_CONTROL > {}; + struct bidi_mirrored : binary_property< UCHAR_BIDI_MIRRORED > {}; + struct case_sensitive : binary_property< UCHAR_CASE_SENSITIVE > {}; + struct dash : binary_property< UCHAR_DASH > {}; + struct default_ignorable_code_point : binary_property< UCHAR_DEFAULT_IGNORABLE_CODE_POINT > {}; + struct deprecated : binary_property< UCHAR_DEPRECATED > {}; + struct diacritic : binary_property< UCHAR_DIACRITIC > {}; + struct extender : binary_property< UCHAR_EXTENDER > {}; + struct full_composition_exclusion : binary_property< UCHAR_FULL_COMPOSITION_EXCLUSION > {}; + struct grapheme_base : binary_property< UCHAR_GRAPHEME_BASE > {}; + struct grapheme_extend : binary_property< UCHAR_GRAPHEME_EXTEND > {}; + struct grapheme_link : binary_property< UCHAR_GRAPHEME_LINK > {}; + struct hex_digit : binary_property< UCHAR_HEX_DIGIT > {}; + struct hyphen : binary_property< UCHAR_HYPHEN > {}; + struct id_continue : binary_property< UCHAR_ID_CONTINUE > {}; + struct id_start : binary_property< UCHAR_ID_START > {}; + struct ideographic : binary_property< UCHAR_IDEOGRAPHIC > {}; + struct ids_binary_operator : binary_property< UCHAR_IDS_BINARY_OPERATOR > {}; + struct ids_trinary_operator : binary_property< UCHAR_IDS_TRINARY_OPERATOR > {}; + struct join_control : binary_property< UCHAR_JOIN_CONTROL > {}; + struct logical_order_exception : binary_property< UCHAR_LOGICAL_ORDER_EXCEPTION > {}; + struct lowercase : binary_property< UCHAR_LOWERCASE > {}; + struct math : binary_property< UCHAR_MATH > {}; + struct nfc_inert : binary_property< UCHAR_NFC_INERT > {}; + struct nfd_inert : binary_property< UCHAR_NFD_INERT > {}; + struct nfkc_inert : binary_property< UCHAR_NFKC_INERT > {}; + struct nfkd_inert : binary_property< UCHAR_NFKD_INERT > {}; + struct noncharacter_code_point : binary_property< UCHAR_NONCHARACTER_CODE_POINT > {}; + struct pattern_syntax : binary_property< UCHAR_PATTERN_SYNTAX > {}; + struct pattern_white_space : binary_property< UCHAR_PATTERN_WHITE_SPACE > {}; + struct posix_alnum : binary_property< UCHAR_POSIX_ALNUM > {}; + struct posix_blank : binary_property< UCHAR_POSIX_BLANK > {}; + struct posix_graph : binary_property< UCHAR_POSIX_GRAPH > {}; + struct posix_print : binary_property< UCHAR_POSIX_PRINT > {}; + struct posix_xdigit : binary_property< UCHAR_POSIX_XDIGIT > {}; + struct quotation_mark : binary_property< UCHAR_QUOTATION_MARK > {}; + struct radical : binary_property< UCHAR_RADICAL > {}; + struct s_term : binary_property< UCHAR_S_TERM > {}; + struct segment_starter : binary_property< UCHAR_SEGMENT_STARTER > {}; + struct soft_dotted : binary_property< UCHAR_SOFT_DOTTED > {}; + struct terminal_punctuation : binary_property< UCHAR_TERMINAL_PUNCTUATION > {}; + struct unified_ideograph : binary_property< UCHAR_UNIFIED_IDEOGRAPH > {}; + struct uppercase : binary_property< UCHAR_UPPERCASE > {}; + struct variation_selector : binary_property< UCHAR_VARIATION_SELECTOR > {}; + struct white_space : binary_property< UCHAR_WHITE_SPACE > {}; + struct xid_continue : binary_property< UCHAR_XID_CONTINUE > {}; + struct xid_start : binary_property< UCHAR_XID_START > {}; - } // namespace utf8 + template< UCharDirection V > struct bidi_class : property_value< UCHAR_BIDI_CLASS, V > {}; + template< UBlockCode V > struct block : property_value< UCHAR_BLOCK, V > {}; + template< UDecompositionType V > struct decomposition_type : property_value< UCHAR_DECOMPOSITION_TYPE, V > {}; + template< UEastAsianWidth V > struct east_asian_width : property_value< UCHAR_EAST_ASIAN_WIDTH, V > {}; + template< UCharCategory V > struct general_category : property_value< UCHAR_GENERAL_CATEGORY, V > {}; + template< UGraphemeClusterBreak V > struct grapheme_cluster_break : property_value< UCHAR_GRAPHEME_CLUSTER_BREAK, V > {}; + template< UHangulSyllableType V > struct hangul_syllable_type : property_value< UCHAR_HANGUL_SYLLABLE_TYPE, V > {}; + template< UJoiningGroup V > struct joining_group : property_value< UCHAR_JOINING_GROUP, V > {}; + template< UJoiningType V > struct joining_type : property_value< UCHAR_JOINING_TYPE, V > {}; + template< ULineBreak V > struct line_break : property_value< UCHAR_LINE_BREAK, V > {}; + // UNormalizationCheckResult requires an additional header <unicode/unorm2.h>: + // template< UNormalizationCheckResult V > struct nfc_quick_check : property_value< UCHAR_NFC_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfd_quick_check : property_value< UCHAR_NFD_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfkc_quick_check : property_value< UCHAR_NFKC_QUICK_CHECK, V > {}; + // template< UNormalizationCheckResult V > struct nfkd_quick_check : property_value< UCHAR_NFKD_QUICK_CHECK, V > {}; + template< UNumericType V > struct numeric_type : property_value< UCHAR_NUMERIC_TYPE, V > {}; + template< USentenceBreak V > struct sentence_break : property_value< UCHAR_SENTENCE_BREAK, V > {}; + template< UWordBreakValues V > struct word_break : property_value< UCHAR_WORD_BREAK, V > {}; - } // namespace TAO_PEGTL_NAMESPACE + template< std::uint8_t V > struct canonical_combining_class : property_value< UCHAR_CANONICAL_COMBINING_CLASS, V > {}; + template< std::uint8_t V > struct lead_canonical_combining_class : property_value< UCHAR_LEAD_CANONICAL_COMBINING_CLASS, V > {}; + template< std::uint8_t V > struct trail_canonical_combining_class : property_value< UCHAR_TRAIL_CANONICAL_COMBINING_CLASS, V > {}; + // clang-format on -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::utf8::icu #endif diff --git a/packages/PEGTL/include/tao/pegtl/contrib/if_then.hpp b/packages/PEGTL/include/tao/pegtl/contrib/if_then.hpp index 496ada60e..63e4e9c96 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 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_CONTRIB_IF_THEN_HPP @@ -13,49 +13,43 @@ #include "../internal/skip_control.hpp" #include "../internal/trivial.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace internal { - namespace internal + template< typename Cond, typename Then > + struct if_pair { - template< typename Cond, typename Then > - struct if_pair - { - }; + }; - template< typename... Pairs > - struct if_then; + template< typename... Pairs > + struct if_then; - template< typename Cond, typename Then, typename... Pairs > - struct if_then< if_pair< Cond, Then >, Pairs... > - : if_then_else< Cond, Then, if_then< Pairs... > > - { - template< typename ElseCond, typename... Thens > - using else_if_then = if_then< if_pair< Cond, Then >, Pairs..., if_pair< ElseCond, seq< Thens... > > >; - - template< typename... Thens > - using else_then = if_then_else< Cond, Then, if_then< Pairs..., if_pair< trivial< true >, seq< Thens... > > > >; - }; + template< typename Cond, typename Then, typename... Pairs > + struct if_then< if_pair< Cond, Then >, Pairs... > + : if_then_else< Cond, Then, if_then< Pairs... > > + { + template< typename ElseCond, typename... Thens > + using else_if_then = if_then< if_pair< Cond, Then >, Pairs..., if_pair< ElseCond, seq< Thens... > > >; - template<> - struct if_then<> - : trivial< false > - { - }; + template< typename... Thens > + using else_then = if_then_else< Cond, Then, if_then< Pairs..., if_pair< trivial< true >, seq< Thens... > > > >; + }; - template< typename... Pairs > - struct skip_control< if_then< Pairs... > > : std::true_type - { - }; + template<> + struct if_then<> + : trivial< false > + { + }; - } // namespace internal + template< typename... Pairs > + inline constexpr bool skip_control< if_then< Pairs... > > = true; - template< typename Cond, typename... Thens > - using if_then = internal::if_then< internal::if_pair< Cond, internal::seq< Thens... > > >; + } // namespace internal - } // namespace TAO_PEGTL_NAMESPACE + template< typename Cond, typename... Thens > + using if_then = internal::if_then< internal::if_pair< Cond, internal::seq< Thens... > > >; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/contrib/integer.hpp b/packages/PEGTL/include/tao/pegtl/contrib/integer.hpp index d619afd31..77d11421b 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) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_CONTRIB_INTEGER_HPP @@ -11,98 +11,90 @@ #include "../parse_error.hpp" #include "../rules.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::integer { - namespace TAO_PEGTL_NAMESPACE + namespace internal { - namespace integer + template< typename I, I Limit, typename Input > + [[nodiscard]] I actual_convert( const Input& in, std::size_t index ) { - namespace internal - { - template< typename I, I Limit, typename Input > - I actual_convert( const Input& in, std::size_t index ) - { - static constexpr I cutoff = Limit / 10; - static constexpr I cutlim = Limit % 10; - - I out = in.peek_char( index ) - '0'; - while( ++index < in.size() ) { - const I c = in.peek_char( index ) - '0'; - if( ( out > cutoff ) || ( ( out == cutoff ) && ( c > cutlim ) ) ) { - throw parse_error( "integer out of range", in ); - } - out *= 10; - out += c; - } - return out; - } - - template< typename I, typename Input > - I convert_positive( const Input& in, std::size_t index ) - { - static constexpr I limit = std::numeric_limits< I >::max(); - return actual_convert< I, limit >( in, index ); - } - - template< typename I, typename Input > - I convert_negative( const Input& in, std::size_t index ) - { - using U = typename std::make_unsigned< I >::type; - static constexpr U limit = static_cast< U >( std::numeric_limits< I >::max() ) + 1; - return static_cast< I >( ~actual_convert< U, limit >( in, index ) ) + 1; + static constexpr I cutoff = Limit / 10; + static constexpr I cutlim = Limit % 10; + + I out = in.peek_char( index ) - '0'; + while( ++index < in.size() ) { + const I c = in.peek_char( index ) - '0'; + if( ( out > cutoff ) || ( ( out == cutoff ) && ( c > cutlim ) ) ) { + throw parse_error( "integer out of range", in ); } + out *= 10; + out += c; + } + return out; + } + + template< typename I, typename Input > + [[nodiscard]] I convert_positive( const Input& in, std::size_t index ) + { + static constexpr I limit = ( std::numeric_limits< I >::max )(); + return actual_convert< I, limit >( in, index ); + } - } // namespace internal + template< typename I, typename Input > + [[nodiscard]] I convert_negative( const Input& in, std::size_t index ) + { + using U = std::make_unsigned_t< I >; + static constexpr U limit = static_cast< U >( ( std::numeric_limits< I >::max )() ) + 1; + return static_cast< I >( ~actual_convert< U, limit >( in, index ) ) + 1; + } - struct unsigned_rule - : plus< digit > - { - }; + } // namespace internal - struct unsigned_action - { - // Assumes that 'in' contains a non-empty sequence of ASCII digits. + struct unsigned_rule + : plus< digit > + { + }; - template< typename Input, typename State > - static void apply( const Input& in, State& st ) - { - using T = typename std::decay< decltype( st.converted ) >::type; - static_assert( std::is_integral< T >::value, "need integral type" ); - static_assert( std::is_unsigned< T >::value, "need unsigned type" ); - st.converted = internal::convert_positive< T >( in, 0 ); - } - }; - - struct signed_rule - : seq< opt< one< '+', '-' > >, plus< digit > > - { - }; - - struct signed_action - { - // Assumes that 'in' contains a non-empty sequence of ASCII digits, - // with optional leading sign; with sign, in.size() must be >= 2. - - template< typename Input, typename State > - static void apply( const Input& in, State& st ) - { - using T = typename std::decay< decltype( st.converted ) >::type; - static_assert( std::is_integral< T >::value, "need integral type" ); - static_assert( std::is_signed< T >::value, "need signed type" ); - const auto c = in.peek_char(); - if( c == '-' ) { - st.converted = internal::convert_negative< T >( in, 1 ); - } - else { - st.converted = internal::convert_positive< T >( in, std::size_t( c == '+' ) ); - } - } - }; + struct unsigned_action + { + // Assumes that 'in' contains a non-empty sequence of ASCII digits. - } // namespace integer + template< typename Input, typename State > + static void apply( const Input& in, State& st ) + { + using T = std::decay_t< decltype( st.converted ) >; + static_assert( std::is_integral_v< T > ); + static_assert( std::is_unsigned_v< T > ); + st.converted = internal::convert_positive< T >( in, 0 ); + } + }; + + struct signed_rule + : seq< opt< one< '+', '-' > >, plus< digit > > + { + }; - } // namespace TAO_PEGTL_NAMESPACE + struct signed_action + { + // Assumes that 'in' contains a non-empty sequence of ASCII digits, + // with optional leading sign; with sign, in.size() must be >= 2. -} // namespace tao + template< typename Input, typename State > + static void apply( const Input& in, State& st ) + { + using T = std::decay_t< decltype( st.converted ) >; + static_assert( std::is_integral_v< T > ); + static_assert( std::is_signed_v< T > ); + const auto c = in.peek_char(); + if( c == '-' ) { + st.converted = internal::convert_negative< T >( in, 1 ); + } + else { + st.converted = internal::convert_positive< T >( in, std::size_t( c == '+' ) ); + } + } + }; + +} // namespace TAO_PEGTL_NAMESPACE::integer #endif diff --git a/packages/PEGTL/include/tao/pegtl/contrib/json.hpp b/packages/PEGTL/include/tao/pegtl/contrib/json.hpp index 576532c62..76564b5ef 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_CONTRIB_JSON_HPP @@ -11,88 +11,80 @@ #include "abnf.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::json { - namespace TAO_PEGTL_NAMESPACE + // JSON grammar according to RFC 8259 + + // clang-format off + struct ws : one< ' ', '\t', '\n', '\r' > {}; + + template< typename R, typename P = ws > + struct padr : internal::seq< R, internal::star< P > > {}; + + struct begin_array : padr< one< '[' > > {}; + struct begin_object : padr< one< '{' > > {}; + struct end_array : one< ']' > {}; + struct end_object : one< '}' > {}; + struct name_separator : pad< one< ':' >, ws > {}; + struct value_separator : padr< one< ',' > > {}; + + struct false_ : string< 'f', 'a', 'l', 's', 'e' > {}; + struct null : string< 'n', 'u', 'l', 'l' > {}; + struct true_ : string< 't', 'r', 'u', 'e' > {}; + + struct digits : plus< abnf::DIGIT > {}; + struct exp : seq< one< 'e', 'E' >, opt< one< '-', '+'> >, must< digits > > {}; + struct frac : if_must< one< '.' >, digits > {}; + struct int_ : sor< one< '0' >, digits > {}; + struct number : seq< opt< one< '-' > >, int_, opt< frac >, opt< exp > > {}; + + struct xdigit : abnf::HEXDIG {}; + struct unicode : list< seq< one< 'u' >, rep< 4, must< xdigit > > >, one< '\\' > > {}; + struct escaped_char : one< '"', '\\', '/', 'b', 'f', 'n', 'r', 't' > {}; + struct escaped : sor< escaped_char, unicode > {}; + struct unescaped : utf8::range< 0x20, 0x10FFFF > {}; + struct char_ : if_then_else< one< '\\' >, must< escaped >, unescaped > {}; + + struct string_content : until< at< one< '"' > >, must< char_ > > {}; + struct string : seq< one< '"' >, must< string_content >, any > { - namespace json - { - // JSON grammar according to RFC 8259 - - // clang-format off - struct ws : one< ' ', '\t', '\n', '\r' > {}; - - template< typename R, typename P = ws > - struct padr : internal::seq< R, internal::star< P > > {}; - - struct begin_array : padr< one< '[' > > {}; - struct begin_object : padr< one< '{' > > {}; - struct end_array : one< ']' > {}; - struct end_object : one< '}' > {}; - struct name_separator : pad< one< ':' >, ws > {}; - struct value_separator : padr< one< ',' > > {}; - - struct false_ : string< 'f', 'a', 'l', 's', 'e' > {}; - struct null : string< 'n', 'u', 'l', 'l' > {}; - struct true_ : string< 't', 'r', 'u', 'e' > {}; - - struct digits : plus< abnf::DIGIT > {}; - struct exp : seq< one< 'e', 'E' >, opt< one< '-', '+'> >, must< digits > > {}; - struct frac : if_must< one< '.' >, digits > {}; - struct int_ : sor< one< '0' >, digits > {}; - struct number : seq< opt< one< '-' > >, int_, opt< frac >, opt< exp > > {}; - - struct xdigit : abnf::HEXDIG {}; - struct unicode : list< seq< one< 'u' >, rep< 4, must< xdigit > > >, one< '\\' > > {}; - struct escaped_char : one< '"', '\\', '/', 'b', 'f', 'n', 'r', 't' > {}; - struct escaped : sor< escaped_char, unicode > {}; - struct unescaped : utf8::range< 0x20, 0x10FFFF > {}; - struct char_ : if_then_else< one< '\\' >, must< escaped >, unescaped > {}; - - struct string_content : until< at< one< '"' > >, must< char_ > > {}; - struct string : seq< one< '"' >, must< string_content >, any > - { - using content = string_content; - }; - - struct key_content : until< at< one< '"' > >, must< char_ > > {}; - struct key : seq< one< '"' >, must< key_content >, any > - { - using content = key_content; - }; - - struct value; - - struct array_element; - struct array_content : opt< list_must< array_element, value_separator > > {}; - struct array : seq< begin_array, array_content, must< end_array > > - { - using begin = begin_array; - using end = end_array; - using element = array_element; - using content = array_content; - }; - - struct member : if_must< key, name_separator, value > {}; - struct object_content : opt< list_must< member, value_separator > > {}; - struct object : seq< begin_object, object_content, must< end_object > > - { - using begin = begin_object; - using end = end_object; - using element = member; - using content = object_content; - }; - - struct value : padr< sor< string, number, object, array, false_, true_, null > > {}; - struct array_element : seq< value > {}; - - struct text : seq< star< ws >, value > {}; - // clang-format on - - } // namespace json - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + using content = string_content; + }; + + struct key_content : until< at< one< '"' > >, must< char_ > > {}; + struct key : seq< one< '"' >, must< key_content >, any > + { + using content = key_content; + }; + + struct value; + + struct array_element; + struct array_content : opt< list_must< array_element, value_separator > > {}; + struct array : seq< begin_array, array_content, must< end_array > > + { + using begin = begin_array; + using end = end_array; + using element = array_element; + using content = array_content; + }; + + struct member : if_must< key, name_separator, value > {}; + struct object_content : opt< list_must< member, value_separator > > {}; + struct object : seq< begin_object, object_content, must< end_object > > + { + using begin = begin_object; + using end = end_object; + using element = member; + using content = object_content; + }; + + struct value : padr< sor< string, number, object, array, false_, true_, null > > {}; + struct array_element : seq< value > {}; + + struct text : seq< star< ws >, value > {}; + // clang-format on + +} // namespace TAO_PEGTL_NAMESPACE::json #endif diff --git a/packages/PEGTL/include/tao/pegtl/contrib/parse_tree.hpp b/packages/PEGTL/include/tao/pegtl/contrib/parse_tree.hpp index 66401e5ea..61182d770 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_CONTRIB_PARSE_TREE_HPP @@ -6,456 +6,550 @@ #include <cassert> #include <memory> +#include <string> +#include <string_view> +#include <tuple> #include <type_traits> -#include <typeinfo> +#include <typeindex> #include <utility> #include <vector> #include "../config.hpp" +#include "../memory_input.hpp" #include "../normal.hpp" #include "../nothing.hpp" #include "../parse.hpp" #include "../analysis/counted.hpp" #include "../analysis/generic.hpp" -#include "../internal/conditional.hpp" #include "../internal/demangle.hpp" #include "../internal/iterator.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::parse_tree { - namespace TAO_PEGTL_NAMESPACE + template< typename T > + struct basic_node { - namespace parse_tree + using node_t = T; + using children_t = std::vector< std::unique_ptr< node_t > >; + children_t children; + + std::type_index id = typeid( void ); + std::string source; + + TAO_PEGTL_NAMESPACE::internal::iterator m_begin; + TAO_PEGTL_NAMESPACE::internal::iterator m_end; + + // each node will be default constructed + basic_node() = default; + + // no copy/move is necessary + // (nodes are always owned/handled by a std::unique_ptr) + basic_node( const basic_node& ) = delete; + basic_node( basic_node&& ) = delete; + + ~basic_node() = default; + + // no assignment either + basic_node& operator=( const basic_node& ) = delete; + basic_node& operator=( basic_node&& ) = delete; + + [[nodiscard]] bool is_root() const noexcept { - template< typename T > - struct basic_node - { - using node_t = T; - using children_t = std::vector< std::unique_ptr< node_t > >; - children_t children; + return id == typeid( void ); + } - const std::type_info* id = nullptr; - std::string source; + template< typename U > + [[nodiscard]] bool is() const noexcept + { + return id == typeid( U ); + } - TAO_PEGTL_NAMESPACE::internal::iterator m_begin; - TAO_PEGTL_NAMESPACE::internal::iterator m_end; + [[nodiscard]] std::string name() const + { + assert( !is_root() ); + return TAO_PEGTL_NAMESPACE::internal::demangle( id.name() ); + } - // each node will be default constructed - basic_node() = default; + [[nodiscard]] position begin() const + { + return position( m_begin, source ); + } - // no copy/move is necessary - // (nodes are always owned/handled by a std::unique_ptr) - basic_node( const basic_node& ) = delete; - basic_node( basic_node&& ) = delete; + [[nodiscard]] position end() const + { + return position( m_end, source ); + } - ~basic_node() = default; + [[nodiscard]] bool has_content() const noexcept + { + return m_end.data != nullptr; + } - // no assignment either - basic_node& operator=( const basic_node& ) = delete; - basic_node& operator=( basic_node&& ) = delete; + [[nodiscard]] std::string_view string_view() const noexcept + { + assert( has_content() ); + return std::string_view( m_begin.data, m_end.data - m_begin.data ); + } - bool is_root() const noexcept - { - return id == nullptr; - } + [[nodiscard]] std::string string() const + { + assert( has_content() ); + return std::string( m_begin.data, m_end.data ); + } - template< typename U > - bool is() const noexcept - { - return id == &typeid( U ); - } + template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > + [[nodiscard]] memory_input< P, Eol > as_memory_input() const + { + assert( has_content() ); + return { m_begin.data, m_end.data, source, m_begin.byte, m_begin.line, m_begin.byte_in_line }; + } - std::string name() const - { - assert( !is_root() ); - return TAO_PEGTL_NAMESPACE::internal::demangle( id->name() ); - } + template< typename... States > + void remove_content( States&&... /*unused*/ ) noexcept + { + m_end.reset(); + } - position begin() const - { - return position( m_begin, source ); - } + // all non-root nodes are initialized by calling this method + template< typename Rule, typename Input, typename... States > + void start( const Input& in, States&&... /*unused*/ ) + { + id = typeid( Rule ); + source = in.source(); + m_begin = TAO_PEGTL_NAMESPACE::internal::iterator( in.iterator() ); + } + + // if parsing of the rule succeeded, this method is called + template< typename Rule, typename Input, typename... States > + void success( const Input& in, States&&... /*unused*/ ) noexcept + { + m_end = TAO_PEGTL_NAMESPACE::internal::iterator( in.iterator() ); + } - position end() const - { - return position( m_end, source ); - } + // if parsing of the rule failed, this method is called + template< typename Rule, typename Input, typename... States > + void failure( const Input& /*unused*/, States&&... /*unused*/ ) noexcept + { + } + + // if parsing succeeded and the (optional) transform call + // did not discard the node, it is appended to its parent. + // note that "child" is the node whose Rule just succeeded + // and "*this" is the parent where the node should be appended. + template< typename... States > + void emplace_back( std::unique_ptr< node_t >&& child, States&&... /*unused*/ ) + { + assert( child ); + children.emplace_back( std::move( child ) ); + } + }; - bool has_content() const noexcept - { - return m_end.data != nullptr; - } + struct node + : basic_node< node > + { + }; - std::string content() const - { - assert( has_content() ); - return std::string( m_begin.data, m_end.data ); - } + namespace internal + { + template< typename Node > + struct state + { + std::vector< std::unique_ptr< Node > > stack; - template< typename... States > - void remove_content( States&&... /*unused*/ ) noexcept - { - m_end.reset(); - } + state() + { + emplace_back(); + } - // all non-root nodes are initialized by calling this method - template< typename Rule, typename Input, typename... States > - void start( const Input& in, States&&... /*unused*/ ) - { - id = &typeid( Rule ); - source = in.source(); - m_begin = in.iterator(); - } + void emplace_back() + { + stack.emplace_back( std::make_unique< Node >() ); + } - // if parsing of the rule succeeded, this method is called - template< typename Rule, typename Input, typename... States > - void success( const Input& in, States&&... /*unused*/ ) noexcept - { - m_end = in.iterator(); - } + [[nodiscard]] std::unique_ptr< Node >& back() noexcept + { + assert( !stack.empty() ); + return stack.back(); + } - // if parsing of the rule failed, this method is called - template< typename Rule, typename Input, typename... States > - void failure( const Input& /*unused*/, States&&... /*unused*/ ) noexcept - { - } + void pop_back() noexcept + { + assert( !stack.empty() ); + return stack.pop_back(); + } + }; - // if parsing succeeded and the (optional) transform call - // did not discard the node, it is appended to its parent. - // note that "child" is the node whose Rule just succeeded - // and "*this" is the parent where the node should be appended. - template< typename... States > - void emplace_back( std::unique_ptr< node_t > child, States&&... /*unused*/ ) - { - assert( child ); - children.emplace_back( std::move( child ) ); - } - }; + template< typename Selector, typename... Parameters > + void transform( Parameters&&... /*unused*/ ) noexcept + { + } + + // this one, if applicable, is more specialized than the above + template< typename Selector, typename Node, typename... States > + auto transform( std::unique_ptr< Node >& n, States&&... st ) noexcept( noexcept( Selector::transform( n, st... ) ) ) + -> decltype( Selector::transform( n, st... ), void() ) + { + Selector::transform( n, st... ); + } - struct node - : basic_node< node > + template< unsigned Level, typename Analyse, template< typename... > class Selector > + struct is_leaf + : std::false_type + { + }; + + template< analysis::rule_type Type, template< typename... > class Selector > + struct is_leaf< 0, analysis::generic< Type >, Selector > + : std::true_type + { + }; + + template< analysis::rule_type Type, unsigned Count, template< typename... > class Selector > + struct is_leaf< 0, analysis::counted< Type, Count >, Selector > + : std::true_type + { + }; + + template< analysis::rule_type Type, typename... Rules, template< typename... > class Selector > + struct is_leaf< 0, analysis::generic< Type, Rules... >, Selector > + : std::false_type + { + }; + + template< analysis::rule_type Type, unsigned Count, typename... Rules, template< typename... > class Selector > + struct is_leaf< 0, analysis::counted< Type, Count, Rules... >, Selector > + : std::false_type + { + }; + + template< unsigned Level, typename Rule, template< typename... > class Selector > + inline constexpr bool is_unselected_leaf = !Selector< Rule >::value && is_leaf< Level, typename Rule::analyze_t, Selector >::value; + + template< unsigned Level, analysis::rule_type Type, typename... Rules, template< typename... > class Selector > + struct is_leaf< Level, analysis::generic< Type, Rules... >, Selector > + : std::bool_constant< ( is_unselected_leaf< Level - 1, Rules, Selector > && ... ) > + { + }; + + template< unsigned Level, analysis::rule_type Type, unsigned Count, typename... Rules, template< typename... > class Selector > + struct is_leaf< Level, analysis::counted< Type, Count, Rules... >, Selector > + : std::bool_constant< ( is_unselected_leaf< Level - 1, Rules, Selector > && ... ) > + { + }; + + template< typename T > + struct control + { + template< typename Input, typename Tuple, std::size_t... Is > + static void start_impl( const Input& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( T::start( in, std::get< sizeof...( Is ) >( t ), std::get< Is >( t )... ) ) ) { - }; + T::start( in, std::get< sizeof...( Is ) >( t ), std::get< Is >( t )... ); + } - namespace internal + template< typename Input, typename... States > + static void start( const Input& in, States&&... st ) noexcept( noexcept( start_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - 1 >() ) ) ) { - template< typename Node > - struct state - { - std::vector< std::unique_ptr< Node > > stack; - - state() - { - emplace_back(); - } - - void emplace_back() - { - stack.emplace_back( std::unique_ptr< Node >( new Node ) ); // NOLINT: std::make_unique requires C++14 - } - - std::unique_ptr< Node >& back() noexcept - { - return stack.back(); - } - - void pop_back() noexcept - { - return stack.pop_back(); - } - }; - - template< typename Node, typename Selector, typename = void > - struct transform - { - template< typename... States > - static void call( std::unique_ptr< Node >& /*unused*/, States&&... /*unused*/ ) noexcept - { - } - }; - - template< typename Node, typename Selector > - struct transform< Node, Selector, decltype( Selector::transform( std::declval< std::unique_ptr< Node >& >() ), void() ) > - { - template< typename... States > - static void call( std::unique_ptr< Node >& n, States&&... st ) noexcept( noexcept( Selector::transform( n, st... ) ) ) - { - Selector::transform( n, st... ); - } - }; - - template< unsigned Level, typename Analyse, template< typename... > class Selector > - struct is_leaf - : std::false_type - { - }; - - template< analysis::rule_type Type, template< typename... > class Selector > - struct is_leaf< 0, analysis::generic< Type >, Selector > - : std::true_type - { - }; - - template< analysis::rule_type Type, unsigned Count, template< typename... > class Selector > - struct is_leaf< 0, analysis::counted< Type, Count >, Selector > - : std::true_type - { - }; - - template< analysis::rule_type Type, typename... Rules, template< typename... > class Selector > - struct is_leaf< 0, analysis::generic< Type, Rules... >, Selector > - : std::false_type - { - }; - - template< analysis::rule_type Type, unsigned Count, typename... Rules, template< typename... > class Selector > - struct is_leaf< 0, analysis::counted< Type, Count, Rules... >, Selector > - : std::false_type - { - }; - - template< bool... > - struct bool_sequence; - - template< bool... Bs > - using is_all = std::is_same< bool_sequence< Bs..., true >, bool_sequence< true, Bs... > >; - - template< unsigned Level, typename Rule, template< typename... > class Selector > - using is_unselected_leaf = std::integral_constant< bool, !Selector< Rule >::value && is_leaf< Level, typename Rule::analyze_t, Selector >::value >; - - template< unsigned Level, analysis::rule_type Type, typename... Rules, template< typename... > class Selector > - struct is_leaf< Level, analysis::generic< Type, Rules... >, Selector > - : is_all< is_unselected_leaf< Level - 1, Rules, Selector >::value... > - { - }; - - template< unsigned Level, analysis::rule_type Type, unsigned Count, typename... Rules, template< typename... > class Selector > - struct is_leaf< Level, analysis::counted< Type, Count, Rules... >, Selector > - : is_all< is_unselected_leaf< Level - 1, Rules, Selector >::value... > - { - }; - - template< typename Node, template< typename... > class Selector, template< typename... > class Control > - struct make_control - { - template< typename Rule, bool, bool > - struct control; - - template< typename Rule > - using type = control< Rule, Selector< Rule >::value, is_leaf< 8, typename Rule::analyze_t, Selector >::value >; - }; - - template< typename Node, template< typename... > class Selector, template< typename... > class Control > - template< typename Rule > - struct make_control< Node, Selector, Control >::control< Rule, false, true > - : Control< Rule > - { - }; - - template< typename Node, template< typename... > class Selector, template< typename... > class Control > - template< typename Rule > - struct make_control< Node, Selector, Control >::control< Rule, false, false > - : Control< Rule > - { - template< typename Input, typename... States > - static void start( const Input& in, States&&... st ) - { - Control< Rule >::start( in, st... ); - auto& state = *static_cast< internal::state< Node >* >( in.internal_state ); - state.emplace_back(); - } - - template< typename Input, typename... States > - static void success( const Input& in, States&&... st ) - { - Control< Rule >::success( in, st... ); - auto& state = *static_cast< internal::state< Node >* >( in.internal_state ); - auto n = std::move( state.back() ); - state.pop_back(); - for( auto& c : n->children ) { - state.back()->children.emplace_back( std::move( c ) ); - } - } - - template< typename Input, typename... States > - static void failure( const Input& in, States&&... st ) noexcept( noexcept( Control< Rule >::failure( in, st... ) ) ) - { - Control< Rule >::failure( in, st... ); - auto& state = *static_cast< internal::state< Node >* >( in.internal_state ); - state.pop_back(); - } - }; - - template< typename Node, template< typename... > class Selector, template< typename... > class Control > - template< typename Rule, bool B > - struct make_control< Node, Selector, Control >::control< Rule, true, B > - : Control< Rule > - { - template< typename Input, typename... States > - static void start( const Input& in, States&&... st ) - { - Control< Rule >::start( in, st... ); - auto& state = *static_cast< internal::state< Node >* >( in.internal_state ); - state.emplace_back(); - state.back()->template start< Rule >( in, st... ); - } - - template< typename Input, typename... States > - static void success( const Input& in, States&&... st ) - { - Control< Rule >::success( in, st... ); - auto& state = *static_cast< internal::state< Node >* >( in.internal_state ); - auto n = std::move( state.back() ); - state.pop_back(); - n->template success< Rule >( in, st... ); - transform< Node, Selector< Rule > >::call( n, st... ); - if( n ) { - state.back()->emplace_back( std::move( n ), st... ); - } - } - - template< typename Input, typename... States > - static void failure( const Input& in, States&&... st ) noexcept( noexcept( Control< Rule >::failure( in, st... ) ) && noexcept( std::declval< node& >().template failure< Rule >( in, st... ) ) ) - { - Control< Rule >::failure( in, st... ); - auto& state = *static_cast< internal::state< Node >* >( in.internal_state ); - state.back()->template failure< Rule >( in, st... ); - state.pop_back(); - } - }; - - template< typename > - struct element - { - }; - - template< typename > - struct store_all : std::true_type - { - }; - - } // namespace internal - - struct store_content : std::true_type + start_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - 1 >() ); + } + + template< typename Input, typename Tuple, std::size_t... Is > + static void success_impl( const Input& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( T::success( in, std::get< sizeof...( Is ) >( t ), std::get< Is >( t )... ) ) ) { - template< typename Node, typename... States > - static void transform( std::unique_ptr< Node >& /*unused*/, States&&... /*unused*/ ) noexcept - { - } - }; + T::success( in, std::get< sizeof...( Is ) >( t ), std::get< Is >( t )... ); + } - // some nodes don't need to store their content - struct remove_content : std::true_type + template< typename Input, typename... States > + static void success( const Input& in, States&&... st ) noexcept( noexcept( success_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - 1 >() ) ) ) { - template< typename Node, typename... States > - static void transform( std::unique_ptr< Node >& n, States&&... st ) noexcept( noexcept( n->Node::remove_content( st... ) ) ) - { - n->remove_content( st... ); - } - }; + success_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - 1 >() ); + } - // if a node has only one child, replace the node with its child, otherwise apply B - template< typename Base > - struct fold_one_or : Base + template< typename Input, typename Tuple, std::size_t... Is > + static void failure_impl( const Input& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( T::failure( in, std::get< sizeof...( Is ) >( t ), std::get< Is >( t )... ) ) ) { - template< typename Node, typename... States > - static void transform( std::unique_ptr< Node >& n, States&&... st ) noexcept( noexcept( n->children.size(), Base::transform( n, st... ) ) ) - { - if( n->children.size() == 1 ) { - n = std::move( n->children.front() ); - } - else { - Base::transform( n, st... ); - } - } - }; + T::failure( in, std::get< sizeof...( Is ) >( t ), std::get< Is >( t )... ); + } - // if a node has no children, discard the node, otherwise apply B - template< typename Base > - struct discard_empty_or : Base + template< typename Input, typename... States > + static void failure( const Input& in, States&&... st ) noexcept( noexcept( failure_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - 1 >() ) ) ) { - template< typename Node, typename... States > - static void transform( std::unique_ptr< Node >& n, States&&... st ) noexcept( noexcept( n->children.empty(), Base::transform( n, st... ) ) ) - { - if( n->children.empty() ) { - n.reset(); - } - else { - Base::transform( n, st... ); - } - } - }; + failure_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - 1 >() ); + } - using fold_one = fold_one_or< remove_content >; - using discard_empty = discard_empty_or< remove_content >; + template< typename Input, typename Tuple, std::size_t... Is > + static void raise_impl( const Input& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( T::raise( in, std::get< Is >( t )... ) ) ) + { + T::raise( in, std::get< Is >( t )... ); + } + + template< typename Input, typename... States > + static void raise( const Input& in, States&&... st ) noexcept( noexcept( raise_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - 1 >() ) ) ) + { + raise_impl( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - 1 >() ); + } - template< typename Rule, typename... Collections > - struct selector : std::false_type + template< template< typename... > class Action, typename Iterator, typename Input, typename Tuple, std::size_t... Is > + static auto apply_impl( const Iterator& begin, const Input& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( T::template apply< Action >( begin, in, std::get< Is >( t )... ) ) ) + -> decltype( T::template apply< Action >( begin, in, std::get< Is >( t )... ) ) { - }; + return T::template apply< Action >( begin, in, std::get< Is >( t )... ); + } - // TODO: Implement in a non-recursive way - // TODO: Check for multiple matches (currently: first match wins) - template< typename Rule, typename Collection, typename... Collections > - struct selector< Rule, Collection, Collections... > - : TAO_PEGTL_NAMESPACE::internal::conditional< Collection::template contains< Rule >::value >::template type< typename Collection::type, selector< Rule, Collections... > > + template< template< typename... > class Action, typename Iterator, typename Input, typename... States > + static auto apply( const Iterator& begin, const Input& in, States&&... st ) noexcept( noexcept( apply_impl< Action >( begin, in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - 1 >() ) ) ) + -> decltype( apply_impl< Action >( begin, in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - 1 >() ) ) { - }; + return apply_impl< Action >( begin, in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - 1 >() ); + } + + template< template< typename... > class Action, typename Input, typename Tuple, std::size_t... Is > + static auto apply0_impl( const Input& in, const Tuple& t, std::index_sequence< Is... > /*unused*/ ) noexcept( noexcept( T::template apply0< Action >( in, std::get< Is >( t )... ) ) ) + -> decltype( T::template apply0< Action >( in, std::get< Is >( t )... ) ) + { + return T::template apply0< Action >( in, std::get< Is >( t )... ); + } - template< typename Base > - struct apply + template< template< typename... > class Action, typename Input, typename... States > + static auto apply0( const Input& in, States&&... st ) noexcept( noexcept( apply0_impl< Action >( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - 1 >() ) ) ) + -> decltype( apply0_impl< Action >( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - 1 >() ) ) { - template< typename... Rules > - struct to - : internal::element< Rules >... - { - using type = Base; - - template< typename Rule > - using contains = std::is_base_of< internal::element< Rule >, to >; - }; - }; - - using apply_store_content = apply< store_content >; - using apply_remove_content = apply< remove_content >; - using apply_fold_one = apply< fold_one >; - using apply_discard_empty = apply< discard_empty >; - - template< typename Rule, - typename Node, - template< typename... > class Selector = internal::store_all, - template< typename... > class Action = nothing, - template< typename... > class Control = normal, + return apply0_impl< Action >( in, std::tie( st... ), std::make_index_sequence< sizeof...( st ) - 1 >() ); + } + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, typename Input, typename... States > - std::unique_ptr< Node > parse( Input&& in, States&&... st ) + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + return T::template match< A, M, Action, Control >( in, st... ); + } + }; + + template< typename Node, template< typename... > class Selector, template< typename... > class Control > + struct make_control + { + template< typename Rule, bool, bool > + struct state_handler; + + template< typename Rule > + using type = control< state_handler< Rule, Selector< Rule >::value, is_leaf< 8, typename Rule::analyze_t, Selector >::value > >; + }; + + 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 > + : Control< Rule > + { + template< typename Input, typename... States > + static void start( const Input& in, state< Node >& /*unused*/, States&&... st ) noexcept( noexcept( Control< Rule >::start( in, st... ) ) ) { - internal::state< Node > state; - assert( in.internal_state == nullptr ); - in.internal_state = &state; - if( !TAO_PEGTL_NAMESPACE::parse< Rule, Action, internal::make_control< Node, Selector, Control >::template type >( in, st... ) ) { - return nullptr; + Control< Rule >::start( in, st... ); + } + + template< typename Input, typename... States > + static void success( const Input& in, state< Node >& /*unused*/, States&&... st ) noexcept( noexcept( Control< Rule >::success( in, st... ) ) ) + { + Control< Rule >::success( in, st... ); + } + + template< typename Input, typename... States > + static void failure( const Input& in, state< Node >& /*unused*/, States&&... st ) noexcept( noexcept( Control< Rule >::failure( in, st... ) ) ) + { + Control< Rule >::failure( in, st... ); + } + }; + + template< typename Node, template< typename... > class Selector, template< typename... > class Control > + template< typename Rule > + struct make_control< Node, Selector, Control >::state_handler< Rule, false, false > + : Control< Rule > + { + template< typename Input, typename... States > + static void start( const Input& in, state< Node >& state, States&&... st ) + { + Control< Rule >::start( in, st... ); + state.emplace_back(); + } + + template< typename Input, typename... States > + static void success( const Input& in, state< Node >& state, States&&... st ) + { + Control< Rule >::success( in, st... ); + auto n = std::move( state.back() ); + state.pop_back(); + for( auto& c : n->children ) { + state.back()->children.emplace_back( std::move( c ) ); } - assert( state.stack.size() == 1 ); - return std::move( state.back() ); } - template< typename Rule, - template< typename... > class Selector = internal::store_all, - template< typename... > class Action = nothing, - template< typename... > class Control = normal, - typename Input, - typename... States > - std::unique_ptr< node > parse( Input&& in, States&&... st ) + template< typename Input, typename... States > + static void failure( const Input& in, state< Node >& state, States&&... st ) noexcept( noexcept( Control< Rule >::failure( in, st... ) ) ) { - return parse< Rule, node, Selector, Action, Control >( in, st... ); + Control< Rule >::failure( in, st... ); + state.pop_back(); } + }; - } // namespace parse_tree + template< typename Node, template< typename... > class Selector, template< typename... > class Control > + template< typename Rule, bool B > + struct make_control< Node, Selector, Control >::state_handler< Rule, true, B > + : Control< Rule > + { + template< typename Input, typename... States > + static void start( const Input& in, state< Node >& state, States&&... st ) + { + Control< Rule >::start( in, st... ); + state.emplace_back(); + state.back()->template start< Rule >( in, st... ); + } - } // namespace TAO_PEGTL_NAMESPACE + template< typename Input, typename... States > + static void success( const Input& in, state< Node >& state, States&&... st ) + { + Control< Rule >::success( in, st... ); + auto n = std::move( state.back() ); + state.pop_back(); + n->template success< Rule >( in, st... ); + transform< Selector< Rule > >( n, st... ); + if( n ) { + state.back()->emplace_back( std::move( n ), st... ); + } + } + + template< typename Input, typename... States > + static void failure( const Input& in, state< Node >& state, States&&... st ) noexcept( noexcept( Control< Rule >::failure( in, st... ) ) && noexcept( std::declval< Node& >().template failure< Rule >( in, st... ) ) ) + { + Control< Rule >::failure( in, st... ); + state.back()->template failure< Rule >( in, st... ); + state.pop_back(); + } + }; + + template< typename > + using store_all = std::true_type; + + template< typename > + struct selector; + + template< typename T > + struct selector< std::tuple< T > > + { + using type = typename T::type; + }; + + template< typename... Ts > + struct selector< std::tuple< Ts... > > + { + static_assert( sizeof...( Ts ) == 0, "multiple matches found" ); + using type = std::false_type; + }; + + template< typename T > + using selector_t = typename selector< T >::type; + + template< typename Rule, typename Collection > + using select_tuple = std::conditional_t< Collection::template contains< Rule >, std::tuple< Collection >, std::tuple<> >; + + } // namespace internal + + template< typename Rule, typename... Collections > + using selector = internal::selector_t< decltype( std::tuple_cat( std::declval< internal::select_tuple< Rule, Collections > >()... ) ) >; + + template< typename Base > + struct apply + : std::true_type + { + template< typename... Rules > + struct on + { + using type = Base; + + template< typename Rule > + static constexpr bool contains = ( std::is_same_v< Rule, Rules > || ... ); + }; + }; + + struct store_content + : apply< store_content > + {}; + + // some nodes don't need to store their content + struct remove_content + : apply< remove_content > + { + template< typename Node, typename... States > + static void transform( std::unique_ptr< Node >& n, States&&... st ) noexcept( noexcept( n->Node::remove_content( st... ) ) ) + { + n->remove_content( st... ); + } + }; + + // if a node has only one child, replace the node with its child, otherwise remove content + struct fold_one + : apply< fold_one > + { + template< typename Node, typename... States > + static void transform( std::unique_ptr< Node >& n, States&&... st ) noexcept( noexcept( n->children.size(), n->Node::remove_content( st... ) ) ) + { + if( n->children.size() == 1 ) { + n = std::move( n->children.front() ); + } + else { + n->remove_content( st... ); + } + } + }; + + // if a node has no children, discard the node, otherwise remove content + struct discard_empty + : apply< discard_empty > + { + template< typename Node, typename... States > + static void transform( std::unique_ptr< Node >& n, States&&... st ) noexcept( noexcept( n->children.empty(), n->Node::remove_content( st... ) ) ) + { + if( n->children.empty() ) { + n.reset(); + } + else { + n->remove_content( st... ); + } + } + }; + + template< typename Rule, + typename Node, + template< typename... > class Selector = internal::store_all, + template< typename... > class Action = nothing, + template< typename... > class Control = normal, + typename Input, + typename... States > + [[nodiscard]] std::unique_ptr< Node > parse( Input&& in, States&&... st ) + { + internal::state< Node > state; + if( !TAO_PEGTL_NAMESPACE::parse< Rule, Action, internal::make_control< Node, Selector, Control >::template type >( in, st..., state ) ) { + return nullptr; + } + assert( state.stack.size() == 1 ); + return std::move( state.back() ); + } + + template< typename Rule, + template< typename... > class Selector = internal::store_all, + template< typename... > class Action = nothing, + template< typename... > class Control = normal, + typename Input, + typename... States > + [[nodiscard]] std::unique_ptr< node > parse( Input&& in, States&&... st ) + { + return parse< Rule, node, Selector, Action, Control >( in, st... ); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::parse_tree #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 new file mode 100644 index 000000000..e9f15892f --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/contrib/parse_tree_to_dot.hpp @@ -0,0 +1,48 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_PARSE_TREE_TO_DOT_HPP +#define TAO_PEGTL_CONTRIB_PARSE_TREE_TO_DOT_HPP + +#include <cassert> +#include <ostream> +#include <string> + +#include "parse_tree.hpp" + +namespace TAO_PEGTL_NAMESPACE::parse_tree +{ + namespace internal + { + void print_dot_node( std::ostream& os, const parse_tree::node& n, const std::string& s ) + { + if( n.has_content() ) { + os << " x" << &n << " [ label=\"" << s << "\\n\\\"" << n.string_view() << "\\\"\" ]\n"; + } + else { + os << " x" << &n << " [ label=\"" << s << "\" ]\n"; + } + if( !n.children.empty() ) { + os << " x" << &n << " -> { "; + for( auto& up : n.children ) { + os << "x" << up.get() << ( ( up == n.children.back() ) ? " }\n" : ", " ); + } + for( auto& up : n.children ) { + print_dot_node( os, *up, up->name() ); + } + } + } + + } // namespace internal + + void print_dot( std::ostream& os, const parse_tree::node& n ) + { + assert( n.is_root() ); + os << "digraph parse_tree\n{\n"; + internal::print_dot_node( os, n, "ROOT" ); + os << "}\n"; + } + +} // namespace TAO_PEGTL_NAMESPACE::parse_tree + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/contrib/raw_string.hpp b/packages/PEGTL/include/tao/pegtl/contrib/raw_string.hpp index 9936b8117..968ebc791 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_CONTRIB_RAW_STRING_HPP @@ -16,208 +16,210 @@ #include "../internal/eol.hpp" #include "../internal/must.hpp" #include "../internal/not_at.hpp" -#include "../internal/rule_conjunction.hpp" #include "../internal/seq.hpp" #include "../internal/skip_control.hpp" #include "../internal/star.hpp" #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace internal { - namespace internal + template< char Open, char Marker > + struct raw_string_open { - template< char Open, char Marker > - struct raw_string_open + using analyze_t = analysis::generic< analysis::rule_type::any >; + + template< apply_mode A, + rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, std::size_t& marker_size, States&&... /*unused*/ ) noexcept( noexcept( in.size( 0 ) ) ) { - using analyze_t = analysis::generic< analysis::rule_type::ANY >; - - template< apply_mode A, - rewind_mode, - template< typename... > class Action, - template< typename... > class Control, - typename Input > - static bool match( Input& in, std::size_t& marker_size ) noexcept( noexcept( in.size( 0 ) ) ) - { - if( in.empty() || ( in.peek_char( 0 ) != Open ) ) { - return false; - } - for( std::size_t i = 1; i < in.size( i + 1 ); ++i ) { - switch( const auto c = in.peek_char( i ) ) { - case Open: - marker_size = i + 1; - in.bump_in_this_line( marker_size ); - eol::match( in ); - return true; - case Marker: - break; - default: - return false; - } - } + if( in.empty() || ( in.peek_char( 0 ) != Open ) ) { return false; } - }; - - template< char Open, char Marker > - struct skip_control< raw_string_open< Open, Marker > > : std::true_type - { - }; - - template< char Marker, char Close > - struct at_raw_string_close - { - using analyze_t = analysis::generic< analysis::rule_type::OPT >; - - template< apply_mode A, - rewind_mode, - template< typename... > class Action, - template< typename... > class Control, - typename Input > - static bool match( Input& in, const std::size_t& marker_size ) noexcept( noexcept( in.size( 0 ) ) ) - { - if( in.size( marker_size ) < marker_size ) { - return false; - } - if( in.peek_char( 0 ) != Close ) { - return false; - } - if( in.peek_char( marker_size - 1 ) != Close ) { - return false; - } - for( std::size_t i = 0; i < ( marker_size - 2 ); ++i ) { - if( in.peek_char( i + 1 ) != Marker ) { + for( std::size_t i = 1; i < in.size( i + 1 ); ++i ) { + switch( const auto c = in.peek_char( i ) ) { + case Open: + marker_size = i + 1; + in.bump_in_this_line( marker_size ); + (void)eol::match( in ); + return true; + case Marker: + break; + default: return false; - } } - return true; } - }; + return false; + } + }; - template< char Marker, char Close > - struct skip_control< at_raw_string_close< Marker, Close > > : std::true_type - { - }; + template< char Open, char Marker > + inline constexpr bool skip_control< raw_string_open< Open, Marker > > = true; - template< typename Cond, typename... Rules > - struct raw_string_until; + template< char Marker, char Close > + struct at_raw_string_close + { + using analyze_t = analysis::generic< analysis::rule_type::opt >; - template< typename Cond > - struct raw_string_until< Cond > + template< apply_mode A, + rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, const std::size_t& marker_size, States&&... /*unused*/ ) noexcept( noexcept( in.size( 0 ) ) ) { - using analyze_t = analysis::generic< analysis::rule_type::SEQ, star< not_at< Cond >, not_at< eof >, bytes< 1 > >, Cond >; - - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, const std::size_t& marker_size, States&&... /*unused*/ ) - { - auto m = in.template mark< M >(); - - while( !Control< Cond >::template match< A, rewind_mode::REQUIRED, Action, Control >( in, marker_size ) ) { - if( in.empty() ) { - return false; - } - in.bump(); + if( in.size( marker_size ) < marker_size ) { + return false; + } + if( in.peek_char( 0 ) != Close ) { + return false; + } + if( in.peek_char( marker_size - 1 ) != Close ) { + return false; + } + for( std::size_t i = 0; i < ( marker_size - 2 ); ++i ) { + if( in.peek_char( i + 1 ) != Marker ) { + return false; } - return m( true ); } - }; + return true; + } + }; + + template< char Marker, char Close > + inline constexpr bool skip_control< at_raw_string_close< Marker, Close > > = true; + + template< typename Cond, typename... Rules > + struct raw_string_until; + + template< typename Cond > + struct raw_string_until< Cond > + { + using analyze_t = analysis::generic< analysis::rule_type::seq, star< not_at< Cond >, not_at< eof >, bytes< 1 > >, Cond >; - template< typename Cond, typename... Rules > - struct raw_string_until + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, const std::size_t& marker_size, States&&... st ) { - using analyze_t = analysis::generic< analysis::rule_type::SEQ, star< not_at< Cond >, not_at< eof >, Rules... >, Cond >; - - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, const std::size_t& marker_size, States&&... st ) - { - auto m = in.template mark< M >(); - using m_t = decltype( m ); - - while( !Control< Cond >::template match< A, rewind_mode::REQUIRED, Action, Control >( in, marker_size ) ) { - if( in.empty() || ( !rule_conjunction< Rules... >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ) ) { - return false; - } + auto m = in.template mark< M >(); + + while( !Control< Cond >::template match< A, rewind_mode::required, Action, Control >( in, marker_size, st... ) ) { + if( in.empty() ) { + return false; } - return m( true ); + in.bump(); } - }; + return m( true ); + } + }; - template< typename Cond, typename... Rules > - struct skip_control< raw_string_until< Cond, Rules... > > : std::true_type - { - }; - - } // namespace internal - - // raw_string matches Lua-style long literals. - // - // The following description was taken from the Lua documentation - // (see http://www.lua.org/docs.html): - // - // - An "opening long bracket of level n" is defined as an opening square - // bracket followed by n equal signs followed by another opening square - // bracket. So, an opening long bracket of level 0 is written as `[[`, - // an opening long bracket of level 1 is written as `[=[`, and so on. - // - A "closing long bracket" is defined similarly; for instance, a closing - // long bracket of level 4 is written as `]====]`. - // - A "long literal" starts with an opening long bracket of any level and - // ends at the first closing long bracket of the same level. It can - // contain any text except a closing bracket of the same level. - // - Literals in this bracketed form can run for several lines, do not - // interpret any escape sequences, and ignore long brackets of any other - // level. - // - For convenience, when the opening long bracket is immediately followed - // by a newline, the newline is not included in the string. - // - // Note that unlike Lua's long literal, a raw_string is customizable to use - // other characters than `[`, `=` and `]` for matching. Also note that Lua - // introduced newline-specific replacements in Lua 5.2, which we do not - // support on the grammar level. - - template< char Open, char Marker, char Close, typename... Contents > - struct raw_string + template< typename Cond, typename... Rules > + struct raw_string_until { - // This is used for binding the apply()-method and for error-reporting - // when a raw string is not closed properly or has invalid content. - struct content - : internal::raw_string_until< internal::at_raw_string_close< Marker, Close >, Contents... > - { - }; - - using analyze_t = typename internal::seq< internal::bytes< 1 >, content, internal::bytes< 1 > >::analyze_t; + using analyze_t = analysis::generic< analysis::rule_type::seq, star< not_at< Cond >, not_at< eof >, Rules... >, Cond >; template< apply_mode A, rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, + template< typename... > + class Action, + template< typename... > + class Control, typename Input, typename... States > - static bool match( Input& in, States&&... st ) + [[nodiscard]] static bool match( Input& in, const std::size_t& marker_size, States&&... st ) { - std::size_t marker_size; - if( internal::raw_string_open< Open, Marker >::template match< A, M, Action, Control >( in, marker_size ) ) { - internal::must< content >::template match< A, M, Action, Control >( in, marker_size, st... ); - in.bump_in_this_line( marker_size ); - return true; + auto m = in.template mark< M >(); + using m_t = decltype( m ); + + while( !Control< Cond >::template match< A, rewind_mode::required, Action, Control >( in, marker_size, st... ) ) { + if( in.empty() || !( Control< Rules >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) && ... ) ) { + return false; + } } - return false; + return m( true ); } }; - } // namespace TAO_PEGTL_NAMESPACE + template< typename Cond, typename... Rules > + inline constexpr bool skip_control< raw_string_until< Cond, Rules... > > = true; + + } // namespace internal + + // raw_string matches Lua-style long literals. + // + // The following description was taken from the Lua documentation + // (see http://www.lua.org/docs.html): + // + // - An "opening long bracket of level n" is defined as an opening square + // bracket followed by n equal signs followed by another opening square + // bracket. So, an opening long bracket of level 0 is written as `[[`, + // an opening long bracket of level 1 is written as `[=[`, and so on. + // - A "closing long bracket" is defined similarly; for instance, a closing + // long bracket of level 4 is written as `]====]`. + // - A "long literal" starts with an opening long bracket of any level and + // ends at the first closing long bracket of the same level. It can + // contain any text except a closing bracket of the same level. + // - Literals in this bracketed form can run for several lines, do not + // interpret any escape sequences, and ignore long brackets of any other + // level. + // - For convenience, when the opening long bracket is eagerly followed + // by a newline, the newline is not included in the string. + // + // Note that unlike Lua's long literal, a raw_string is customizable to use + // other characters than `[`, `=` and `]` for matching. Also note that Lua + // introduced newline-specific replacements in Lua 5.2, which we do not + // support on the grammar level. + + template< char Open, char Marker, char Close, typename... Contents > + struct raw_string + { + // This is used for binding the apply()-method and for error-reporting + // when a raw string is not closed properly or has invalid content. + struct content + : internal::raw_string_until< internal::at_raw_string_close< Marker, Close >, Contents... > + { + }; + + using analyze_t = typename internal::seq< internal::bytes< 1 >, content, internal::bytes< 1 > >::analyze_t; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + std::size_t marker_size; + if( internal::raw_string_open< Open, Marker >::template match< A, M, Action, Control >( in, marker_size, st... ) ) { + // TODO: Do not rely on must<> + (void)internal::must< content >::template match< A, M, Action, Control >( in, marker_size, st... ); + in.bump_in_this_line( marker_size ); + return true; + } + return false; + } + }; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif 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 99014d059..3f85f5817 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_CONTRIB_REP_ONE_MIN_MAX_HPP @@ -13,60 +13,50 @@ #include "../internal/bump_help.hpp" #include "../internal/skip_control.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace internal { - namespace internal + template< unsigned Min, unsigned Max, char C > + struct rep_one_min_max { - template< unsigned Min, unsigned Max, char C > - struct rep_one_min_max - { - using analyze_t = analysis::counted< analysis::rule_type::ANY, Min >; + using analyze_t = analysis::counted< analysis::rule_type::any, Min >; - static_assert( Min <= Max, "invalid rep_one_min_max rule (maximum number of repetitions smaller than minimum)" ); + static_assert( Min <= Max ); - template< typename Input > - static bool match( Input& in ) - { - const auto size = in.size( Max + 1 ); - if( size < Min ) { - return false; - } - std::size_t i = 0; - while( ( i < size ) && ( in.peek_char( i ) == C ) ) { - ++i; - } - if( ( Min <= i ) && ( i <= Max ) ) { - bump_help< result_on_found::SUCCESS, Input, char, C >( in, i ); - return true; - } + template< typename Input > + [[nodiscard]] static bool match( Input& in ) + { + const auto size = in.size( Max + 1 ); + if( size < Min ) { return false; } - }; + std::size_t i = 0; + while( ( i < size ) && ( in.peek_char( i ) == C ) ) { + ++i; + } + if( ( Min <= i ) && ( i <= Max ) ) { + bump_help< result_on_found::success, Input, char, C >( in, i ); + return true; + } + return false; + } + }; - template< unsigned Min, unsigned Max, char C > - struct skip_control< rep_one_min_max< Min, Max, C > > : std::true_type - { - }; + template< unsigned Min, unsigned Max, char C > + inline constexpr bool skip_control< rep_one_min_max< Min, Max, C > > = true; - } // namespace internal + } // namespace internal - inline namespace ascii + inline namespace ascii + { + template< unsigned Min, unsigned Max, char C > + struct rep_one_min_max : internal::rep_one_min_max< Min, Max, C > { - template< unsigned Min, unsigned Max, char C > - struct rep_one_min_max : internal::rep_one_min_max< Min, Max, C > - { - }; - - struct ellipsis : internal::rep_one_min_max< 3, 3, '.' > - { - }; - - } // namespace ascii + }; - } // namespace TAO_PEGTL_NAMESPACE + } // namespace ascii -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/contrib/rep_string.hpp b/packages/PEGTL/include/tao/pegtl/contrib/rep_string.hpp new file mode 100644 index 000000000..bd699ce8e --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/contrib/rep_string.hpp @@ -0,0 +1,44 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_CONTRIB_REP_STRING_HPP +#define TAO_PEGTL_CONTRIB_REP_STRING_HPP + +#include <cstddef> + +#include "../config.hpp" +#include "../internal/string.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + namespace internal + { + template< std::size_t, typename, char... > + struct make_rep_string; + + template< char... Ss, char... Cs > + struct make_rep_string< 0, string< Ss... >, Cs... > + { + using type = string< Ss... >; + }; + + template< std::size_t N, char... Ss, char... Cs > + struct make_rep_string< N, string< Ss... >, Cs... > + : make_rep_string< N - 1, string< Ss..., Cs... >, Cs... > + { + }; + + } // namespace internal + + inline namespace ascii + { + template< std::size_t N, char... Cs > + struct rep_string + : internal::make_rep_string< N, internal::string<>, Cs... >::type + {}; + + } // namespace ascii + +} // namespace TAO_PEGTL_NAMESPACE + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/contrib/to_string.hpp b/packages/PEGTL/include/tao/pegtl/contrib/to_string.hpp index ff60aa0aa..122ad57f3 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_CONTRIB_TO_STRING_HPP @@ -8,35 +8,31 @@ #include "../config.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace internal { - namespace internal - { - template< typename > - struct to_string; + template< typename > + struct to_string; - template< template< char... > class X, char... Cs > - struct to_string< X< Cs... > > + template< template< char... > class X, char... Cs > + struct to_string< X< Cs... > > + { + [[nodiscard]] static std::string get() { - static std::string get() - { - const char s[] = { Cs..., 0 }; - return std::string( s, sizeof...( Cs ) ); - } - }; + const char s[] = { Cs..., 0 }; // NOLINT + return std::string( s, sizeof...( Cs ) ); + } + }; - } // namespace internal + } // namespace internal - template< typename T > - std::string to_string() - { - return internal::to_string< T >::get(); - } - - } // namespace TAO_PEGTL_NAMESPACE + template< typename T > + [[nodiscard]] std::string to_string() + { + return internal::to_string< T >::get(); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/contrib/tracer.hpp b/packages/PEGTL/include/tao/pegtl/contrib/tracer.hpp index 05216f75b..3075b7467 100644 --- a/packages/PEGTL/include/tao/pegtl/contrib/tracer.hpp +++ b/packages/PEGTL/include/tao/pegtl/contrib/tracer.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_CONTRIB_TRACER_HPP @@ -15,101 +15,144 @@ #include "../internal/demangle.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace internal { - struct trace_state + template< typename Input > + void print_current( const Input& in ) { - unsigned rule = 0; - unsigned line = 0; - std::vector< unsigned > stack; - }; + if( in.empty() ) { + std::cerr << "<eof>"; + } + else { + const auto c = in.peek_uint8(); + switch( c ) { + case 0: + std::cerr << "<nul> = "; + break; + case 9: + std::cerr << "<ht> = "; + break; + case 10: + std::cerr << "<lf> = "; + break; + case 13: + std::cerr << "<cr> = "; + break; + default: + if( isprint( c ) ) { + std::cerr << '\'' << c << "' = "; + } + } + std::cerr << "(char)" << unsigned( c ); + } + } + } // namespace internal + + struct trace_state + { + unsigned rule = 0; + unsigned line = 0; + std::vector< unsigned > stack; + }; + + template< template< typename... > class Base > + struct trace + { template< typename Rule > - struct tracer - : normal< Rule > + struct control + : Base< Rule > { template< typename Input, typename... States > - static void start( const Input& in, States&&... /*unused*/ ) + static void start( const Input& in, States&&... st ) { - std::cerr << in.position() << " start " << internal::demangle< Rule >() << std::endl; + std::cerr << in.position() << " start " << internal::demangle< Rule >() << "; current "; + print_current( in ); + std::cerr << std::endl; + Base< Rule >::start( in, st... ); } - template< typename Input > - static void start( const Input& in, trace_state& ts ) + template< typename Input, typename... States > + static void start( const Input& in, trace_state& ts, States&&... st ) { - std::cerr << std::setw( 6 ) << ++ts.line << " " << std::setw( 6 ) << ++ts.rule << " " << in.position() << " start " << internal::demangle< Rule >() << std::endl; + std::cerr << std::setw( 6 ) << ++ts.line << " " << std::setw( 6 ) << ++ts.rule << " "; + start( in, st... ); ts.stack.push_back( ts.rule ); } template< typename Input, typename... States > - static void success( const Input& in, States&&... /*unused*/ ) + static void success( const Input& in, States&&... st ) { - std::cerr << in.position() << " success " << internal::demangle< Rule >() << std::endl; + std::cerr << in.position() << " success " << internal::demangle< Rule >() << "; next "; + print_current( in ); + std::cerr << std::endl; + Base< Rule >::success( in, st... ); } - template< typename Input > - static void success( const Input& in, trace_state& ts ) + template< typename Input, typename... States > + static void success( const Input& in, trace_state& ts, States&&... st ) { assert( !ts.stack.empty() ); - std::cerr << std::setw( 6 ) << ++ts.line << " " << std::setw( 6 ) << ts.stack.back() << " " << in.position() << " success " << internal::demangle< Rule >() << std::endl; + std::cerr << std::setw( 6 ) << ++ts.line << " " << std::setw( 6 ) << ts.stack.back() << " "; + success( in, st... ); ts.stack.pop_back(); } template< typename Input, typename... States > - static void failure( const Input& in, States&&... /*unused*/ ) + static void failure( const Input& in, States&&... st ) { std::cerr << in.position() << " failure " << internal::demangle< Rule >() << std::endl; + Base< Rule >::failure( in, st... ); } - template< typename Input > - static void failure( const Input& in, trace_state& ts ) + template< typename Input, typename... States > + static void failure( const Input& in, trace_state& ts, States&&... st ) { assert( !ts.stack.empty() ); - std::cerr << std::setw( 6 ) << ++ts.line << " " << std::setw( 6 ) << ts.stack.back() << " " << in.position() << " failure " << internal::demangle< Rule >() << std::endl; + std::cerr << std::setw( 6 ) << ++ts.line << " " << std::setw( 6 ) << ts.stack.back() << " "; + failure( in, st... ); ts.stack.pop_back(); } - template< template< typename... > class Action, typename Input, typename... States > - static auto apply0( const Input& /*unused*/, States&&... st ) - -> decltype( Action< Rule >::apply0( st... ) ) + template< template< typename... > class Action, typename Iterator, typename Input, typename... States > + static auto apply( const Iterator& begin, const Input& in, States&&... st ) + -> decltype( Base< Rule >::template apply< Action >( begin, in, st... ) ) { - std::cerr << "apply0 " << internal::demangle< Action< Rule > >() << std::endl; - return Action< Rule >::apply0( st... ); + std::cerr << in.position() << " apply " << internal::demangle< Rule >() << std::endl; + return Base< Rule >::template apply< Action >( begin, in, st... ); } - template< template< typename... > class Action, typename Input > - static auto apply0( const Input& /*unused*/, trace_state& ts ) - -> decltype( Action< Rule >::apply0( ts ) ) + template< template< typename... > class Action, typename Iterator, typename Input, typename... States > + static auto apply( const Iterator& begin, const Input& in, trace_state& ts, States&&... st ) + -> decltype( apply< Action >( begin, in, st... ) ) { - std::cerr << std::setw( 6 ) << ++ts.line << " " << internal::demangle< Action< Rule > >() << "::apply0()" << std::endl; - return Action< Rule >::apply0( ts ); + std::cerr << std::setw( 6 ) << ++ts.line << " "; + return apply< Action >( begin, in, st... ); } - template< template< typename... > class Action, typename Iterator, typename Input, typename... States > - static auto apply( const Iterator& begin, const Input& in, States&&... st ) - -> decltype( Action< Rule >::apply( std::declval< typename Input::action_t >(), st... ) ) + template< template< typename... > class Action, typename Input, typename... States > + static auto apply0( const Input& in, States&&... st ) + -> decltype( Base< Rule >::template apply0< Action >( in, st... ) ) { - std::cerr << "apply " << internal::demangle< Action< Rule > >() << std::endl; - using action_t = typename Input::action_t; - const action_t action_input( begin, in ); - return Action< Rule >::apply( action_input, st... ); + std::cerr << in.position() << " apply0 " << internal::demangle< Rule >() << std::endl; + return Base< Rule >::template apply0< Action >( in, st... ); } - template< template< typename... > class Action, typename Iterator, typename Input > - static auto apply( const Iterator& begin, const Input& in, trace_state& ts ) - -> decltype( Action< Rule >::apply( std::declval< typename Input::action_t >(), ts ) ) + template< template< typename... > class Action, typename Input, typename... States > + static auto apply0( const Input& in, trace_state& ts, States&&... st ) + -> decltype( apply0< Action >( in, st... ) ) { - std::cerr << std::setw( 6 ) << ++ts.line << " " << internal::demangle< Action< Rule > >() << "::apply()" << std::endl; - using action_t = typename Input::action_t; - const action_t action_input( begin, in ); - return Action< Rule >::apply( action_input, ts ); + std::cerr << std::setw( 6 ) << ++ts.line << " "; + return apply0< Action >( in, st... ); } }; + }; - } // namespace TAO_PEGTL_NAMESPACE + template< typename Rule > + using tracer = trace< normal >::control< Rule >; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/contrib/unescape.hpp b/packages/PEGTL/include/tao/pegtl/contrib/unescape.hpp index 704ede62a..ca3b57bcf 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_CONTRIB_UNESCAPE_HPP @@ -11,202 +11,189 @@ #include "../config.hpp" #include "../parse_error.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::unescape { - namespace TAO_PEGTL_NAMESPACE + // Utility functions for the unescape actions. + + [[nodiscard]] inline bool utf8_append_utf32( std::string& string, const unsigned utf32 ) { - namespace unescape - { - struct state - { - std::string unescaped; - }; - - // Utility functions for the unescape actions. - - inline bool utf8_append_utf32( std::string& string, const unsigned utf32 ) - { - if( utf32 <= 0x7f ) { - string += char( utf32 & 0xff ); - return true; - } - if( utf32 <= 0x7ff ) { - char tmp[] = { char( ( ( utf32 & 0x7c0 ) >> 6 ) | 0xc0 ), - char( ( ( utf32 & 0x03f ) ) | 0x80 ) }; - string.append( tmp, sizeof( tmp ) ); - return true; - } - if( utf32 <= 0xffff ) { - if( utf32 >= 0xd800 && utf32 <= 0xdfff ) { - // nope, this is a UTF-16 surrogate - return false; - } - char tmp[] = { char( ( ( utf32 & 0xf000 ) >> 12 ) | 0xe0 ), - char( ( ( utf32 & 0x0fc0 ) >> 6 ) | 0x80 ), - char( ( ( utf32 & 0x003f ) ) | 0x80 ) }; - string.append( tmp, sizeof( tmp ) ); - return true; - } - if( utf32 <= 0x10ffff ) { - char tmp[] = { char( ( ( utf32 & 0x1c0000 ) >> 18 ) | 0xf0 ), - char( ( ( utf32 & 0x03f000 ) >> 12 ) | 0x80 ), - char( ( ( utf32 & 0x000fc0 ) >> 6 ) | 0x80 ), - char( ( ( utf32 & 0x00003f ) ) | 0x80 ) }; - string.append( tmp, sizeof( tmp ) ); - return true; - } + if( utf32 <= 0x7f ) { + string += char( utf32 & 0xff ); + return true; + } + if( utf32 <= 0x7ff ) { + char tmp[] = { char( ( ( utf32 & 0x7c0 ) >> 6 ) | 0xc0 ), // NOLINT + char( ( ( utf32 & 0x03f ) ) | 0x80 ) }; + string.append( tmp, sizeof( tmp ) ); + return true; + } + if( utf32 <= 0xffff ) { + if( utf32 >= 0xd800 && utf32 <= 0xdfff ) { + // nope, this is a UTF-16 surrogate return false; } - - // This function MUST only be called for characters matching tao::TAO_PEGTL_NAMESPACE::ascii::xdigit! - template< typename I > - I unhex_char( const char c ) - { - switch( c ) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return I( c - '0' ); - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - return I( c - 'a' + 10 ); - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - return I( c - 'A' + 10 ); - } + char tmp[] = { char( ( ( utf32 & 0xf000 ) >> 12 ) | 0xe0 ), // NOLINT + char( ( ( utf32 & 0x0fc0 ) >> 6 ) | 0x80 ), + char( ( ( utf32 & 0x003f ) ) | 0x80 ) }; + string.append( tmp, sizeof( tmp ) ); + return true; + } + if( utf32 <= 0x10ffff ) { + char tmp[] = { char( ( ( utf32 & 0x1c0000 ) >> 18 ) | 0xf0 ), // NOLINT + char( ( ( utf32 & 0x03f000 ) >> 12 ) | 0x80 ), + char( ( ( utf32 & 0x000fc0 ) >> 6 ) | 0x80 ), + char( ( ( utf32 & 0x00003f ) ) | 0x80 ) }; + string.append( tmp, sizeof( tmp ) ); + return true; + } + return false; + } + + // This function MUST only be called for characters matching TAO_PEGTL_NAMESPACE::ascii::xdigit! + template< typename I > + [[nodiscard]] I unhex_char( const char c ) + { + switch( c ) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + return I( c - '0' ); + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + return I( c - 'a' + 10 ); + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + return I( c - 'A' + 10 ); + default: // LCOV_EXCL_LINE throw std::runtime_error( "invalid character in unhex" ); // NOLINT, LCOV_EXCL_LINE - } + } + } - template< typename I > - I unhex_string( const char* begin, const char* end ) - { - I r = 0; - while( begin != end ) { - r <<= 4; - r += unhex_char< I >( *begin++ ); - } - return r; - } + template< typename I > + [[nodiscard]] I unhex_string( const char* begin, const char* end ) + { + I r = 0; + while( begin != end ) { + r <<= 4; + r += unhex_char< I >( *begin++ ); + } + return r; + } - // Actions for common unescape situations. + // Actions for common unescape situations. - struct append_all - { - template< typename Input, typename State > - static void apply( const Input& in, State& st ) - { - st.unescaped.append( in.begin(), in.size() ); - } - }; - - // This action MUST be called for a character matching T which MUST be tao::TAO_PEGTL_NAMESPACE::one< ... >. - template< typename T, char... Rs > - struct unescape_c - { - template< typename Input, typename State > - static void apply( const Input& in, State& st ) - { - assert( in.size() == 1 ); - st.unescaped += apply_one( in, static_cast< const T* >( nullptr ) ); - } + struct append_all + { + template< typename Input > + static void apply( const Input& in, std::string& s ) + { + s.append( in.begin(), in.size() ); + } + }; - template< typename Input, char... Qs > - static char apply_one( const Input& in, const one< Qs... >* /*unused*/ ) - { - static_assert( sizeof...( Qs ) == sizeof...( Rs ), "size mismatch between escaped characters and their mappings" ); - return apply_two( in, { Qs... }, { Rs... } ); - } + // This action MUST be called for a character matching T which MUST be TAO_PEGTL_NAMESPACE::one< ... >. + template< typename T, char... Rs > + struct unescape_c + { + template< typename Input > + static void apply( const Input& in, std::string& s ) + { + assert( in.size() == 1 ); + s += apply_one( in, static_cast< const T* >( nullptr ) ); + } - template< typename Input > - static char apply_two( const Input& in, const std::initializer_list< char >& q, const std::initializer_list< char >& r ) - { - const char c = *in.begin(); - for( std::size_t i = 0; i < q.size(); ++i ) { - if( *( q.begin() + i ) == c ) { - return *( r.begin() + i ); - } - } - throw parse_error( "invalid character in unescape", in ); // NOLINT, LCOV_EXCL_LINE + template< typename Input, char... Qs > + [[nodiscard]] static char apply_one( const Input& in, const one< Qs... >* /*unused*/ ) + { + static_assert( sizeof...( Qs ) == sizeof...( Rs ), "size mismatch between escaped characters and their mappings" ); + return apply_two( in, { Qs... }, { Rs... } ); + } + + template< typename Input > + [[nodiscard]] static char apply_two( const Input& in, const std::initializer_list< char >& q, const std::initializer_list< char >& r ) + { + const char c = *in.begin(); + for( std::size_t i = 0; i < q.size(); ++i ) { + if( *( q.begin() + i ) == c ) { + return *( r.begin() + i ); } - }; - - // See src/example/pegtl/unescape.cpp for why the following two actions - // skip the first input character. They also MUST be called - // with non-empty matched inputs! - - struct unescape_u - { - template< typename Input, typename State > - static void apply( const Input& in, State& st ) - { - assert( !in.empty() ); // First character MUST be present, usually 'u' or 'U'. - if( !utf8_append_utf32( st.unescaped, unhex_string< unsigned >( in.begin() + 1, in.end() ) ) ) { - throw parse_error( "invalid escaped unicode code point", in ); + } + throw parse_error( "invalid character in unescape", in ); // NOLINT, LCOV_EXCL_LINE + } + }; + + // See src/example/pegtl/unescape.cpp for why the following two actions + // skip the first input character. They also MUST be called + // with non-empty matched inputs! + + struct unescape_u + { + template< typename Input > + static void apply( const Input& in, std::string& s ) + { + assert( !in.empty() ); // First character MUST be present, usually 'u' or 'U'. + if( !utf8_append_utf32( s, unhex_string< unsigned >( in.begin() + 1, in.end() ) ) ) { + throw parse_error( "invalid escaped unicode code point", in ); + } + } + }; + + struct unescape_x + { + template< typename Input > + static void apply( const Input& in, std::string& s ) + { + assert( !in.empty() ); // First character MUST be present, usually 'x'. + s += unhex_string< char >( in.begin() + 1, in.end() ); + } + }; + + // The unescape_j action is similar to unescape_u, however unlike + // unescape_u it + // (a) assumes exactly 4 hexdigits per escape sequence, + // (b) accepts multiple consecutive escaped 16-bit values. + // When applied to more than one escape sequence, unescape_j + // translates UTF-16 surrogate pairs in the input into a single + // UTF-8 sequence in s, as required for JSON by RFC 8259. + + struct unescape_j + { + template< typename Input > + static void apply( const Input& in, std::string& s ) + { + assert( ( ( in.size() + 1 ) % 6 ) == 0 ); // Expects multiple "\\u1234", starting with the first "u". + for( const char* b = in.begin() + 1; b < in.end(); b += 6 ) { + const auto c = unhex_string< unsigned >( b, b + 4 ); + if( ( 0xd800 <= c ) && ( c <= 0xdbff ) && ( b + 6 < in.end() ) ) { + const auto d = unhex_string< unsigned >( b + 6, b + 10 ); + if( ( 0xdc00 <= d ) && ( d <= 0xdfff ) ) { + b += 6; + (void)utf8_append_utf32( s, ( ( ( c & 0x03ff ) << 10 ) | ( d & 0x03ff ) ) + 0x10000 ); + continue; } } - }; - - struct unescape_x - { - template< typename Input, typename State > - static void apply( const Input& in, State& st ) - { - assert( !in.empty() ); // First character MUST be present, usually 'x'. - st.unescaped += unhex_string< char >( in.begin() + 1, in.end() ); + if( !utf8_append_utf32( s, c ) ) { + throw parse_error( "invalid escaped unicode code point", in ); } - }; - - // The unescape_j action is similar to unescape_u, however unlike - // unescape_u it - // (a) assumes exactly 4 hexdigits per escape sequence, - // (b) accepts multiple consecutive escaped 16-bit values. - // When applied to more than one escape sequence, unescape_j - // translates UTF-16 surrogate pairs in the input into a single - // UTF-8 sequence in st.unescaped, as required for JSON by RFC 8259. - - struct unescape_j - { - template< typename Input, typename State > - static void apply( const Input& in, State& st ) - { - assert( ( ( in.size() + 1 ) % 6 ) == 0 ); // Expects multiple "\\u1234", starting with the first "u". - for( const char* b = in.begin() + 1; b < in.end(); b += 6 ) { - const auto c = unhex_string< unsigned >( b, b + 4 ); - if( ( 0xd800 <= c ) && ( c <= 0xdbff ) && ( b + 6 < in.end() ) ) { - const auto d = unhex_string< unsigned >( b + 6, b + 10 ); - if( ( 0xdc00 <= d ) && ( d <= 0xdfff ) ) { - b += 6; - // note: no need to check the result code, as we are always >= 0x10000 and < 0x110000. - utf8_append_utf32( st.unescaped, ( ( ( c & 0x03ff ) << 10 ) | ( d & 0x03ff ) ) + 0x10000 ); - continue; - } - } - if( !utf8_append_utf32( st.unescaped, c ) ) { - throw parse_error( "invalid escaped unicode code point", in ); - } - } - } - }; - - } // namespace unescape - - } // namespace TAO_PEGTL_NAMESPACE + } + } + }; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::unescape #endif diff --git a/packages/PEGTL/include/tao/pegtl/contrib/uri.hpp b/packages/PEGTL/include/tao/pegtl/contrib/uri.hpp index 7f51fad79..06f5e7cf8 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_CONTRIB_URI_HPP @@ -11,105 +11,97 @@ #include "abnf.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::uri { - namespace TAO_PEGTL_NAMESPACE - { - namespace uri - { - // URI grammar according to RFC 3986. + // URI grammar according to RFC 3986. - // This grammar is a direct PEG translation of the original URI grammar. - // It should be considered experimental -- in case of any issues, in particular - // missing rules for attached actions, please contact the developers. + // This grammar is a direct PEG translation of the original URI grammar. + // It should be considered experimental -- in case of any issues, in particular + // missing rules for attached actions, please contact the developers. - // Note that this grammar has multiple top-level rules. + // Note that this grammar has multiple top-level rules. - using dot = one< '.' >; - using colon = one< ':' >; + using dot = one< '.' >; + using colon = one< ':' >; - // clang-format off - struct dec_octet : sor< one< '0' >, - rep_min_max< 1, 2, abnf::DIGIT >, - seq< one< '1' >, abnf::DIGIT, abnf::DIGIT >, - seq< one< '2' >, range< '0', '4' >, abnf::DIGIT >, - seq< string< '2', '5' >, range< '0', '5' > > > {}; + // clang-format off + struct dec_octet : sor< one< '0' >, + rep_min_max< 1, 2, abnf::DIGIT >, + seq< one< '1' >, abnf::DIGIT, abnf::DIGIT >, + seq< one< '2' >, range< '0', '4' >, abnf::DIGIT >, + seq< string< '2', '5' >, range< '0', '5' > > > {}; - struct IPv4address : seq< dec_octet, dot, dec_octet, dot, dec_octet, dot, dec_octet > {}; + struct IPv4address : seq< dec_octet, dot, dec_octet, dot, dec_octet, dot, dec_octet > {}; - struct h16 : rep_min_max< 1, 4, abnf::HEXDIG > {}; - struct ls32 : sor< seq< h16, colon, h16 >, IPv4address > {}; + struct h16 : rep_min_max< 1, 4, abnf::HEXDIG > {}; + struct ls32 : sor< seq< h16, colon, h16 >, IPv4address > {}; - struct dcolon : two< ':' > {}; + struct dcolon : two< ':' > {}; - struct IPv6address : sor< seq< rep< 6, h16, colon >, ls32 >, - seq< dcolon, rep< 5, h16, colon >, ls32 >, - seq< opt< h16 >, dcolon, rep< 4, h16, colon >, ls32 >, - seq< opt< h16, opt< colon, h16 > >, dcolon, rep< 3, h16, colon >, ls32 >, - seq< opt< h16, rep_opt< 2, colon, h16 > >, dcolon, rep< 2, h16, colon >, ls32 >, - seq< opt< h16, rep_opt< 3, colon, h16 > >, dcolon, h16, colon, ls32 >, - seq< opt< h16, rep_opt< 4, colon, h16 > >, dcolon, ls32 >, - seq< opt< h16, rep_opt< 5, colon, h16 > >, dcolon, h16 >, - seq< opt< h16, rep_opt< 6, colon, h16 > >, dcolon > > {}; + struct IPv6address : sor< seq< rep< 6, h16, colon >, ls32 >, + seq< dcolon, rep< 5, h16, colon >, ls32 >, + seq< opt< h16 >, dcolon, rep< 4, h16, colon >, ls32 >, + seq< opt< h16, opt< colon, h16 > >, dcolon, rep< 3, h16, colon >, ls32 >, + seq< opt< h16, rep_opt< 2, colon, h16 > >, dcolon, rep< 2, h16, colon >, ls32 >, + seq< opt< h16, rep_opt< 3, colon, h16 > >, dcolon, h16, colon, ls32 >, + seq< opt< h16, rep_opt< 4, colon, h16 > >, dcolon, ls32 >, + seq< opt< h16, rep_opt< 5, colon, h16 > >, dcolon, h16 >, + seq< opt< h16, rep_opt< 6, colon, h16 > >, dcolon > > {}; - struct gen_delims : one< ':', '/', '?', '#', '[', ']', '@' > {}; - struct sub_delims : one< '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=' > {}; + struct gen_delims : one< ':', '/', '?', '#', '[', ']', '@' > {}; + struct sub_delims : one< '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=' > {}; - struct unreserved : sor< abnf::ALPHA, abnf::DIGIT, one< '-', '.', '_', '~' > > {}; - struct reserved : sor< gen_delims, sub_delims > {}; + struct unreserved : sor< abnf::ALPHA, abnf::DIGIT, one< '-', '.', '_', '~' > > {}; + struct reserved : sor< gen_delims, sub_delims > {}; - struct IPvFuture : if_must< one< 'v' >, plus< abnf::HEXDIG >, dot, plus< sor< unreserved, sub_delims, colon > > > {}; + struct IPvFuture : if_must< one< 'v', 'V' >, plus< abnf::HEXDIG >, dot, plus< sor< unreserved, sub_delims, colon > > > {}; - struct IP_literal : if_must< one< '[' >, sor< IPvFuture, IPv6address >, one< ']' > > {}; + struct IP_literal : if_must< one< '[' >, sor< IPvFuture, IPv6address >, one< ']' > > {}; - struct pct_encoded : if_must< one< '%' >, abnf::HEXDIG, abnf::HEXDIG > {}; - struct pchar : sor< unreserved, pct_encoded, sub_delims, one< ':', '@' > > {}; + struct pct_encoded : if_must< one< '%' >, abnf::HEXDIG, abnf::HEXDIG > {}; + struct pchar : sor< unreserved, pct_encoded, sub_delims, one< ':', '@' > > {}; - struct query : star< sor< pchar, one< '/', '?' > > > {}; - struct fragment : star< sor< pchar, one< '/', '?' > > > {}; + struct query : star< sor< pchar, one< '/', '?' > > > {}; + struct fragment : star< sor< pchar, one< '/', '?' > > > {}; - struct segment : star< pchar > {}; - struct segment_nz : plus< pchar > {}; - struct segment_nz_nc : plus< sor< unreserved, pct_encoded, sub_delims, one< '@' > > > {}; // non-zero-length segment without any colon ":" + struct segment : star< pchar > {}; + struct segment_nz : plus< pchar > {}; + struct segment_nz_nc : plus< sor< unreserved, pct_encoded, sub_delims, one< '@' > > > {}; // non-zero-length segment without any colon ":" - struct path_abempty : star< one< '/' >, segment > {}; - struct path_absolute : seq< one< '/' >, opt< segment_nz, star< one< '/' >, segment > > > {}; - struct path_noscheme : seq< segment_nz_nc, star< one< '/' >, segment > > {}; - struct path_rootless : seq< segment_nz, star< one< '/' >, segment > > {}; - struct path_empty : success {}; + struct path_abempty : star< one< '/' >, segment > {}; + struct path_absolute : seq< one< '/' >, opt< segment_nz, star< one< '/' >, segment > > > {}; + struct path_noscheme : seq< segment_nz_nc, star< one< '/' >, segment > > {}; + struct path_rootless : seq< segment_nz, star< one< '/' >, segment > > {}; + struct path_empty : success {}; - struct path : sor< path_noscheme, // begins with a non-colon segment - path_rootless, // begins with a segment - path_absolute, // begins with "/" but not "//" - path_abempty > {}; // begins with "/" or is empty + struct path : sor< path_noscheme, // begins with a non-colon segment + path_rootless, // begins with a segment + path_absolute, // begins with "/" but not "//" + path_abempty > {}; // begins with "/" or is empty - struct reg_name : star< sor< unreserved, pct_encoded, sub_delims > > {}; + struct reg_name : star< sor< unreserved, pct_encoded, sub_delims > > {}; - struct port : star< abnf::DIGIT > {}; - struct host : sor< IP_literal, IPv4address, reg_name > {}; - struct userinfo : star< sor< unreserved, pct_encoded, sub_delims, colon > > {}; - struct opt_userinfo : opt< userinfo, one< '@' > > {}; - struct authority : seq< opt_userinfo, host, opt< colon, port > > {}; + struct port : star< abnf::DIGIT > {}; + struct host : sor< IP_literal, IPv4address, reg_name > {}; + struct userinfo : star< sor< unreserved, pct_encoded, sub_delims, colon > > {}; + struct opt_userinfo : opt< userinfo, one< '@' > > {}; + struct authority : seq< opt_userinfo, host, opt< colon, port > > {}; - struct scheme : seq< abnf::ALPHA, star< sor< abnf::ALPHA, abnf::DIGIT, one< '+', '-', '.' > > > > {}; + struct scheme : seq< abnf::ALPHA, star< sor< abnf::ALPHA, abnf::DIGIT, one< '+', '-', '.' > > > > {}; - using dslash = two< '/' >; - using opt_query = opt_must< one< '?' >, query >; - using opt_fragment = opt_must< one< '#' >, fragment >; + using dslash = two< '/' >; + using opt_query = opt_must< one< '?' >, query >; + using opt_fragment = opt_must< one< '#' >, fragment >; - struct hier_part : sor< if_must< dslash, authority, path_abempty >, path_rootless, path_absolute, path_empty > {}; - struct relative_part : sor< if_must< dslash, authority, path_abempty >, path_noscheme, path_absolute, path_empty > {}; - struct relative_ref : seq< relative_part, opt_query, opt_fragment > {}; + struct hier_part : sor< if_must< dslash, authority, path_abempty >, path_rootless, path_absolute, path_empty > {}; + struct relative_part : sor< if_must< dslash, authority, path_abempty >, path_noscheme, path_absolute, path_empty > {}; + struct relative_ref : seq< relative_part, opt_query, opt_fragment > {}; - struct URI : seq< scheme, one< ':' >, hier_part, opt_query, opt_fragment > {}; - struct URI_reference : sor< URI, relative_ref > {}; - struct absolute_URI : seq< scheme, one< ':' >, hier_part, opt_query > {}; - // clang-format on + struct URI : seq< scheme, one< ':' >, hier_part, opt_query, opt_fragment > {}; + struct URI_reference : sor< URI, relative_ref > {}; + struct absolute_URI : seq< scheme, one< ':' >, hier_part, opt_query > {}; + // clang-format on - } // namespace uri - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::uri #endif diff --git a/packages/PEGTL/include/tao/pegtl/cstream_input.hpp b/packages/PEGTL/include/tao/pegtl/cstream_input.hpp index 88c1a8ead..5a5aee72b 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_CSTREAM_INPUT_HPP @@ -12,28 +12,22 @@ #include "internal/cstream_reader.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + template< typename Eol = eol::lf_crlf, std::size_t Chunk = 64 > + struct cstream_input + : buffer_input< internal::cstream_reader, Eol, std::string, Chunk > { - template< typename Eol = eol::lf_crlf > - struct cstream_input - : buffer_input< internal::cstream_reader, Eol > + template< typename T > + cstream_input( std::FILE* in_stream, const std::size_t in_maximum, T&& in_source ) // NOLINT + : buffer_input< internal::cstream_reader, Eol, std::string, Chunk >( std::forward< T >( in_source ), in_maximum, in_stream ) { - template< typename T > - cstream_input( std::FILE* in_stream, const std::size_t in_maximum, T&& in_source ) - : buffer_input< internal::cstream_reader, Eol >( std::forward< T >( in_source ), in_maximum, in_stream ) - { - } - }; - -#ifdef __cpp_deduction_guides - template< typename... Ts > - cstream_input( Ts&&... )->cstream_input<>; -#endif + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template< typename... Ts > + cstream_input( Ts&&... )->cstream_input<>; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/disable_action.hpp b/packages/PEGTL/include/tao/pegtl/disable_action.hpp new file mode 100644 index 000000000..1832625ed --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/disable_action.hpp @@ -0,0 +1,35 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_DISABLE_ACTION_HPP +#define TAO_PEGTL_DISABLE_ACTION_HPP + +#include "apply_mode.hpp" +#include "config.hpp" +#include "match.hpp" +#include "nothing.hpp" +#include "rewind_mode.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + struct disable_action + : maybe_nothing + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + return TAO_PEGTL_NAMESPACE::match< Rule, apply_mode::nothing, M, Action, Control >( in, st... ); + } + }; + +} // namespace TAO_PEGTL_NAMESPACE + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/discard_input.hpp b/packages/PEGTL/include/tao/pegtl/discard_input.hpp new file mode 100644 index 000000000..18d3c996a --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/discard_input.hpp @@ -0,0 +1,37 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_DISCARD_INPUT_HPP +#define TAO_PEGTL_DISCARD_INPUT_HPP + +#include "apply_mode.hpp" +#include "config.hpp" +#include "match.hpp" +#include "nothing.hpp" +#include "rewind_mode.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + struct discard_input + : maybe_nothing + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + const bool result = TAO_PEGTL_NAMESPACE::match< Rule, apply_mode::nothing, M, Action, Control >( in, st... ); + in.discard(); + return result; + } + }; + +} // namespace TAO_PEGTL_NAMESPACE + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/discard_input_on_failure.hpp b/packages/PEGTL/include/tao/pegtl/discard_input_on_failure.hpp new file mode 100644 index 000000000..4f9c99b5e --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/discard_input_on_failure.hpp @@ -0,0 +1,39 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_DISCARD_INPUT_ON_FAILURE_HPP +#define TAO_PEGTL_DISCARD_INPUT_ON_FAILURE_HPP + +#include "apply_mode.hpp" +#include "config.hpp" +#include "match.hpp" +#include "nothing.hpp" +#include "rewind_mode.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + struct discard_input_on_failure + : maybe_nothing + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + const bool result = TAO_PEGTL_NAMESPACE::match< Rule, apply_mode::nothing, M, Action, Control >( in, st... ); + if( !result ) { + in.discard(); + } + return result; + } + }; + +} // namespace TAO_PEGTL_NAMESPACE + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/discard_input_on_success.hpp b/packages/PEGTL/include/tao/pegtl/discard_input_on_success.hpp new file mode 100644 index 000000000..b373d6860 --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/discard_input_on_success.hpp @@ -0,0 +1,39 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_DISCARD_INPUT_ON_SUCCESS_HPP +#define TAO_PEGTL_DISCARD_INPUT_ON_SUCCESS_HPP + +#include "apply_mode.hpp" +#include "config.hpp" +#include "match.hpp" +#include "nothing.hpp" +#include "rewind_mode.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + struct discard_input_on_success + : maybe_nothing + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + const bool result = TAO_PEGTL_NAMESPACE::match< Rule, apply_mode::nothing, M, Action, Control >( in, st... ); + if( result ) { + in.discard(); + } + return result; + } + }; + +} // namespace TAO_PEGTL_NAMESPACE + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/enable_action.hpp b/packages/PEGTL/include/tao/pegtl/enable_action.hpp new file mode 100644 index 000000000..f0a52e6bf --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/enable_action.hpp @@ -0,0 +1,35 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_ENABLE_ACTION_HPP +#define TAO_PEGTL_ENABLE_ACTION_HPP + +#include "apply_mode.hpp" +#include "config.hpp" +#include "match.hpp" +#include "nothing.hpp" +#include "rewind_mode.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + struct enable_action + : maybe_nothing + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + return TAO_PEGTL_NAMESPACE::match< Rule, apply_mode::action, M, Action, Control >( in, st... ); + } + }; + +} // namespace TAO_PEGTL_NAMESPACE + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/eol.hpp b/packages/PEGTL/include/tao/pegtl/eol.hpp index 29a8a8959..927cd3e53 100644 --- a/packages/PEGTL/include/tao/pegtl/eol.hpp +++ b/packages/PEGTL/include/tao/pegtl/eol.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_EOL_HPP @@ -14,28 +14,24 @@ #include "internal/lf_crlf_eol.hpp" #include "internal/lf_eol.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + inline namespace ascii { - inline namespace ascii + // this is both a rule and a pseudo-namespace for eol::cr, ... + struct eol : internal::eol { - // this is both a rule and a pseudo-namespace for eol::cr, ... - struct eol : internal::eol - { - // clang-format off - struct cr : internal::cr_eol {}; - struct cr_crlf : internal::cr_crlf_eol {}; - struct crlf : internal::crlf_eol {}; - struct lf : internal::lf_eol {}; - struct lf_crlf : internal::lf_crlf_eol {}; - // clang-format on - }; - - } // namespace ascii - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + // clang-format off + struct cr : internal::cr_eol {}; + struct cr_crlf : internal::cr_crlf_eol {}; + struct crlf : internal::crlf_eol {}; + struct lf : internal::lf_eol {}; + struct lf_crlf : internal::lf_crlf_eol {}; + // clang-format on + }; + + } // namespace ascii + +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/eol_pair.hpp b/packages/PEGTL/include/tao/pegtl/eol_pair.hpp index 384bea1e5..4c7f76c12 100644 --- a/packages/PEGTL/include/tao/pegtl/eol_pair.hpp +++ b/packages/PEGTL/include/tao/pegtl/eol_pair.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_EOL_PAIR_HPP @@ -9,14 +9,10 @@ #include "config.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE - { - using eol_pair = std::pair< bool, std::size_t >; + using eol_pair = std::pair< bool, std::size_t >; - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // 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 1959a095a..3c04e9aca 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_FILE_INPUT_HPP @@ -18,33 +18,27 @@ #include "read_input.hpp" #endif -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE - { #if defined( _POSIX_MAPPED_FILES ) || defined( _WIN32 ) - template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf > - struct file_input - : mmap_input< P, Eol > - { - using mmap_input< P, Eol >::mmap_input; - }; + template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > + struct file_input + : mmap_input< P, Eol > + { + using mmap_input< P, Eol >::mmap_input; + }; #else - template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf > - struct file_input - : read_input< P, Eol > - { - using read_input< P, Eol >::read_input; - }; -#endif - -#ifdef __cpp_deduction_guides - template< typename... Ts > - explicit file_input( Ts&&... )->file_input<>; + template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > + struct file_input + : read_input< P, Eol > + { + using read_input< P, Eol >::read_input; + }; #endif - } // namespace TAO_PEGTL_NAMESPACE + template< typename... Ts > + explicit file_input( Ts&&... )->file_input<>; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/input_error.hpp b/packages/PEGTL/include/tao/pegtl/input_error.hpp deleted file mode 100644 index eb302c9f7..000000000 --- a/packages/PEGTL/include/tao/pegtl/input_error.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INPUT_ERROR_HPP -#define TAO_PEGTL_INPUT_ERROR_HPP - -#include <cerrno> -#include <sstream> -#include <stdexcept> - -#include "config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - struct input_error - : std::runtime_error - { - input_error( const std::string& message, const int in_errorno ) - : std::runtime_error( message ), - errorno( in_errorno ) - { - } - - int errorno; - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#define TAO_PEGTL_INTERNAL_UNWRAP( ... ) __VA_ARGS__ - -#define TAO_PEGTL_THROW_INPUT_ERROR( MESSAGE ) \ - do { \ - const int errorno = errno; \ - std::ostringstream oss; \ - oss << "pegtl: " << TAO_PEGTL_INTERNAL_UNWRAP( MESSAGE ) << " errno " << errorno; \ - throw tao::TAO_PEGTL_NAMESPACE::input_error( oss.str(), errorno ); \ - } while( false ) - -#define TAO_PEGTL_THROW_INPUT_WIN32_ERROR( MESSAGE ) \ - do { \ - const int errorno = GetLastError(); \ - std::ostringstream oss; \ - oss << "pegtl: " << TAO_PEGTL_INTERNAL_UNWRAP( MESSAGE ) << " GetLastError() " << errorno; \ - throw tao::TAO_PEGTL_NAMESPACE::input_error( oss.str(), errorno ); \ - } while( false ) - -#endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/action.hpp b/packages/PEGTL/include/tao/pegtl/internal/action.hpp index b7a4f6ac1..c6cd4d1d3 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/action.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/action.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_ACTION_HPP @@ -15,38 +15,30 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< template< typename... > class Action, typename... Rules > + struct action { - namespace internal + using analyze_t = analysis::generic< analysis::rule_type::seq, Rules... >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) { - template< template< typename... > class Action, typename... Rules > - struct action - { - using analyze_t = analysis::generic< analysis::rule_type::SEQ, Rules... >; - - template< apply_mode A, - rewind_mode M, - template< typename... > class, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return duseltronik< seq< Rules... >, A, M, Action, Control >::match( in, st... ); - } - }; - - template< template< typename... > class Action, typename... Rules > - struct skip_control< action< Action, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + return duseltronik< seq< Rules... >, A, M, Action, Control >::match( in, st... ); + } + }; + + template< template< typename... > class Action, typename... Rules > + inline constexpr bool skip_control< action< Action, Rules... > > = true; + +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/action_input.hpp b/packages/PEGTL/include/tao/pegtl/internal/action_input.hpp index ec15ea109..84a97a3f6 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_ACTION_INPUT_HPP @@ -7,108 +7,101 @@ #include <cstddef> #include <cstdint> #include <string> +#include <string_view> #include "iterator.hpp" #include "../config.hpp" #include "../position.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename Input > + class action_input { - namespace internal + public: + using input_t = Input; + using iterator_t = typename Input::iterator_t; + + action_input( const iterator_t& in_begin, const Input& in_input ) noexcept + : m_begin( in_begin ), + m_input( in_input ) { - inline const char* begin_c_ptr( const char* p ) noexcept - { - return p; - } + } + + action_input( const action_input& ) = delete; + action_input( action_input&& ) = delete; + + ~action_input() = default; + + action_input& operator=( const action_input& ) = delete; + action_input& operator=( action_input&& ) = delete; + + [[nodiscard]] const iterator_t& iterator() const noexcept + { + return m_begin; + } - inline const char* begin_c_ptr( const iterator& it ) noexcept - { - return it.data; + [[nodiscard]] const Input& input() const noexcept + { + return m_input; + } + + [[nodiscard]] const char* begin() const noexcept + { + if constexpr( std::is_same_v< iterator_t, const char* > ) { + return iterator(); + } + else { // NOLINT + return iterator().data; } + } + + [[nodiscard]] const char* end() const noexcept + { + return input().current(); + } + + [[nodiscard]] bool empty() const noexcept + { + return begin() == end(); + } + + [[nodiscard]] std::size_t size() const noexcept + { + return std::size_t( end() - begin() ); + } + + [[nodiscard]] std::string string() const + { + return std::string( begin(), end() ); + } + + [[nodiscard]] std::string_view string_view() const noexcept + { + return std::string_view( begin(), size() ); + } + + [[nodiscard]] char peek_char( const std::size_t offset = 0 ) const noexcept + { + return begin()[ offset ]; + } + + [[nodiscard]] std::uint8_t peek_uint8( const std::size_t offset = 0 ) const noexcept + { + return static_cast< std::uint8_t >( peek_char( offset ) ); + } + + [[nodiscard]] TAO_PEGTL_NAMESPACE::position position() const + { + return input().position( iterator() ); // NOTE: Not efficient with lazy inputs. + } + + protected: + const iterator_t m_begin; + const Input& m_input; + }; - template< typename Input > - class action_input - { - public: - using input_t = Input; - using iterator_t = typename Input::iterator_t; - - action_input( const iterator_t& in_begin, const Input& in_input ) noexcept - : m_begin( in_begin ), - m_input( in_input ) - { - } - - action_input( const action_input& ) = delete; - action_input( action_input&& ) = delete; - - ~action_input() = default; - - action_input& operator=( const action_input& ) = delete; - action_input& operator=( action_input&& ) = delete; - - const iterator_t& iterator() const noexcept - { - return m_begin; - } - - const Input& input() const noexcept - { - return m_input; - } - - const char* begin() const noexcept - { - return begin_c_ptr( iterator() ); - } - - const char* end() const noexcept - { - return input().current(); - } - - bool empty() const noexcept - { - return begin() == end(); - } - - std::size_t size() const noexcept - { - return std::size_t( end() - begin() ); - } - - std::string string() const - { - return std::string( begin(), end() ); - } - - char peek_char( const std::size_t offset = 0 ) const noexcept - { - return begin()[ offset ]; - } - - std::uint8_t peek_byte( const std::size_t offset = 0 ) const noexcept - { - return static_cast< std::uint8_t >( peek_char( offset ) ); - } - - TAO_PEGTL_NAMESPACE::position position() const - { - return input().position( iterator() ); // NOTE: Not efficient with LAZY inputs. - } - - protected: - const iterator_t m_begin; - const Input& m_input; - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/alnum.hpp b/packages/PEGTL/include/tao/pegtl/internal/alnum.hpp index f42fa1a2a..459fd3aab 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/alnum.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/alnum.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_ALNUM_HPP @@ -9,18 +9,10 @@ #include "peek_char.hpp" #include "ranges.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - using alnum = ranges< peek_char, 'a', 'z', 'A', 'Z', '0', '9' >; + using alnum = ranges< peek_char, 'a', 'z', 'A', 'Z', '0', '9' >; - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/alpha.hpp b/packages/PEGTL/include/tao/pegtl/internal/alpha.hpp index b55d1ed63..ddc7cf5fb 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/alpha.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/alpha.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_ALPHA_HPP @@ -9,18 +9,10 @@ #include "peek_char.hpp" #include "ranges.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - using alpha = ranges< peek_char, 'a', 'z', 'A', 'Z' >; + using alpha = ranges< peek_char, 'a', 'z', 'A', 'Z' >; - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/always_false.hpp b/packages/PEGTL/include/tao/pegtl/internal/always_false.hpp new file mode 100644 index 000000000..339ab498b --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/internal/always_false.hpp @@ -0,0 +1,21 @@ +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_ALWAYS_FALSE_HPP +#define TAO_PEGTL_INTERNAL_ALWAYS_FALSE_HPP + +#include "../config.hpp" + +#include <type_traits> + +namespace TAO_PEGTL_NAMESPACE::internal +{ + template< typename... > + struct always_false + : std::false_type + { + }; + +} // namespace TAO_PEGTL_NAMESPACE::internal + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/any.hpp b/packages/PEGTL/include/tao/pegtl/internal/any.hpp index 4c962d747..e20c55bc5 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/any.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/any.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_ANY_HPP @@ -11,58 +11,48 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Peek > - struct any; - - template<> - struct any< peek_char > - { - using analyze_t = analysis::generic< analysis::rule_type::ANY >; + template< typename Peek > + struct any; - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( in.empty() ) ) - { - if( !in.empty() ) { - in.bump(); - return true; - } - return false; - } - }; + template<> + struct any< peek_char > + { + using analyze_t = analysis::generic< analysis::rule_type::any >; - template< typename Peek > - struct any - { - using analyze_t = analysis::generic< analysis::rule_type::ANY >; + template< typename Input > + [[nodiscard]] static bool match( Input& in ) noexcept( noexcept( in.empty() ) ) + { + if( !in.empty() ) { + in.bump(); + return true; + } + return false; + } + }; + + template< typename Peek > + struct any + { + using analyze_t = analysis::generic< analysis::rule_type::any >; - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( in.empty() ) ) - { - if( !in.empty() ) { - if( const auto t = Peek::peek( in ) ) { - in.bump( t.size ); - return true; - } - } - return false; + template< typename Input > + [[nodiscard]] static bool match( Input& in ) noexcept( noexcept( in.size( Peek::max_input_size ) ) ) + { + if( const std::size_t s = in.size( Peek::max_input_size ); s >= Peek::min_input_size ) { + if( const auto t = Peek::peek( in, s ) ) { + in.bump( t.size ); + return true; } - }; - - template< typename Peek > - struct skip_control< any< Peek > > : std::true_type - { - }; - - } // namespace internal + } + return false; + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template< typename Peek > + inline constexpr bool skip_control< any< Peek > > = true; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/apply.hpp b/packages/PEGTL/include/tao/pegtl/internal/apply.hpp index 7954f2fab..11616fcad 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/apply.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/apply.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_APPLY_HPP @@ -13,80 +13,41 @@ #include "../apply_mode.hpp" #include "../rewind_mode.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename... Actions > + struct apply { - namespace internal + using analyze_t = analysis::counted< analysis::rule_type::any, 0 >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) { - template< apply_mode A, typename... Actions > - struct apply_impl; - - template<> - struct apply_impl< apply_mode::ACTION > - { - template< typename Input, typename... States > - static bool match( Input& /*unused*/, States&&... /*unused*/ ) - { - return true; - } - }; - - template< typename... Actions > - struct apply_impl< apply_mode::ACTION, Actions... > - { - template< typename Input, typename... States > - static bool match( Input& in, States&&... st ) - { - using action_t = typename Input::action_t; - const action_t i2( in.iterator(), in ); // No data -- range is from begin to begin. -#ifdef __cpp_fold_expressions - return ( apply_single< Actions >::match( i2, st... ) && ... ); -#else - bool result = true; - using swallow = bool[]; - (void)swallow{ result = result && apply_single< Actions >::match( i2, st... )... }; - return result; + if constexpr( ( A == apply_mode::action ) && ( sizeof...( Actions ) > 0 ) ) { + using action_t = typename Input::action_t; + const action_t i2( in.iterator(), in ); // No data -- range is from begin to begin. + return ( apply_single< Actions >::match( i2, st... ) && ... ); + } + else { // NOLINT +#if defined( _MSC_VER ) + (void)in; + (void)( (void)st, ... ); #endif - } - }; - - template< typename... Actions > - struct apply_impl< apply_mode::NOTHING, Actions... > - { - template< typename Input, typename... States > - static bool match( Input& /*unused*/, States&&... /*unused*/ ) - { - return true; - } - }; - - template< typename... Actions > - struct apply - { - using analyze_t = analysis::counted< analysis::rule_type::ANY, 0 >; - - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return apply_impl< A, Actions... >::match( in, st... ); - } - }; - - template< typename... Actions > - struct skip_control< apply< Actions... > > : std::true_type - { - }; - - } // namespace internal + return true; + } + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template< typename... Actions > + inline constexpr bool skip_control< apply< Actions... > > = true; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/apply0.hpp b/packages/PEGTL/include/tao/pegtl/internal/apply0.hpp index 5a13f6d67..417ed7a61 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/apply0.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/apply0.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_APPLY0_HPP @@ -13,78 +13,38 @@ #include "../apply_mode.hpp" #include "../rewind_mode.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename... Actions > + struct apply0 { - namespace internal + using analyze_t = analysis::counted< analysis::rule_type::any, 0 >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& /*unused*/, States&&... st ) { - template< apply_mode A, typename... Actions > - struct apply0_impl; - - template<> - struct apply0_impl< apply_mode::ACTION > - { - template< typename... States > - static bool match( States&&... /*unused*/ ) noexcept - { - return true; - } - }; - - template< typename... Actions > - struct apply0_impl< apply_mode::ACTION, Actions... > - { - template< typename... States > - static bool match( States&&... st ) - { -#ifdef __cpp_fold_expressions - return ( apply0_single< Actions >::match( st... ) && ... ); -#else - bool result = true; - using swallow = bool[]; - (void)swallow{ result = result && apply0_single< Actions >::match( st... )... }; - return result; + if constexpr( A == apply_mode::action ) { + return ( apply0_single< Actions >::match( st... ) && ... ); + } + else { // NOLINT +#if defined( _MSC_VER ) + (void)( (void)st, ... ); #endif - } - }; - - template< typename... Actions > - struct apply0_impl< apply_mode::NOTHING, Actions... > - { - template< typename... States > - static bool match( States&&... /*unused*/ ) noexcept - { - return true; - } - }; - - template< typename... Actions > - struct apply0 - { - using analyze_t = analysis::counted< analysis::rule_type::ANY, 0 >; - - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& /*unused*/, States&&... st ) - { - return apply0_impl< A, Actions... >::match( st... ); - } - }; - - template< typename... Actions > - struct skip_control< apply0< Actions... > > : std::true_type - { - }; - - } // namespace internal + return true; + } + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template< typename... Actions > + inline constexpr bool skip_control< apply0< Actions... > > = true; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/apply0_single.hpp b/packages/PEGTL/include/tao/pegtl/internal/apply0_single.hpp index 06bae4f28..73a6f1ac0 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/apply0_single.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/apply0_single.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_APPLY0_SINGLE_HPP @@ -8,35 +8,27 @@ #include <type_traits> -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename Action > + struct apply0_single { - namespace internal + template< typename... States > + [[nodiscard]] static auto match( States&&... st ) noexcept( noexcept( Action::apply0( st... ) ) ) + -> std::enable_if_t< std::is_same_v< decltype( Action::apply0( st... ) ), void >, bool > { - template< typename Action > - struct apply0_single - { - template< typename... States > - static auto match( States&&... st ) - -> typename std::enable_if< std::is_same< decltype( Action::apply0( st... ) ), void >::value, bool >::type - { - Action::apply0( st... ); - return true; - } + Action::apply0( st... ); + return true; + } - template< typename... States > - static auto match( States&&... st ) - -> typename std::enable_if< std::is_same< decltype( Action::apply0( st... ) ), bool >::value, bool >::type - { - return Action::apply0( st... ); - } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE + template< typename... States > + [[nodiscard]] static auto match( States&&... st ) noexcept( noexcept( Action::apply0( st... ) ) ) + -> std::enable_if_t< std::is_same_v< decltype( Action::apply0( st... ) ), bool >, bool > + { + return Action::apply0( st... ); + } + }; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/apply_single.hpp b/packages/PEGTL/include/tao/pegtl/internal/apply_single.hpp index 990723432..85dc0b598 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/apply_single.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/apply_single.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_APPLY_SINGLE_HPP @@ -8,35 +8,27 @@ #include <type_traits> -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename Action > + struct apply_single { - namespace internal + template< typename Input, typename... States > + [[nodiscard]] static auto match( const Input& in, States&&... st ) noexcept( noexcept( Action::apply( in, st... ) ) ) + -> std::enable_if_t< std::is_same_v< decltype( Action::apply( in, st... ) ), void >, bool > { - template< typename Action > - struct apply_single - { - template< typename Input, typename... States > - static auto match( const Input& i2, States&&... st ) - -> typename std::enable_if< std::is_same< decltype( Action::apply( i2, st... ) ), void >::value, bool >::type - { - Action::apply( i2, st... ); - return true; - } + Action::apply( in, st... ); + return true; + } - template< typename Input, typename... States > - static auto match( const Input& i2, States&&... st ) - -> typename std::enable_if< std::is_same< decltype( Action::apply( i2, st... ) ), bool >::value, bool >::type - { - return Action::apply( i2, st... ); - } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE + template< typename Input, typename... States > + [[nodiscard]] static auto match( const Input& in, States&&... st ) noexcept( noexcept( Action::apply( in, st... ) ) ) + -> std::enable_if_t< std::is_same_v< decltype( Action::apply( in, st... ) ), bool >, bool > + { + return Action::apply( in, st... ); + } + }; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/at.hpp b/packages/PEGTL/include/tao/pegtl/internal/at.hpp index b4997c9c7..e46a85750 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/at.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/at.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_AT_HPP @@ -6,7 +6,6 @@ #include "../config.hpp" -#include "rule_conjunction.hpp" #include "skip_control.hpp" #include "trivial.hpp" @@ -15,48 +14,40 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename... Rules > + struct at; + + template<> + struct at<> + : trivial< true > + { + }; + + template< typename... Rules > + struct at { - namespace internal + using analyze_t = analysis::generic< analysis::rule_type::opt, Rules... >; + + template< apply_mode, + rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) { - template< typename... Rules > - struct at; - - template<> - struct at<> - : trivial< true > - { - }; - - template< typename... Rules > - struct at - { - using analyze_t = analysis::generic< analysis::rule_type::OPT, Rules... >; - - template< apply_mode, - rewind_mode, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - const auto m = in.template mark< rewind_mode::REQUIRED >(); - return rule_conjunction< Rules... >::template match< apply_mode::NOTHING, rewind_mode::ACTIVE, Action, Control >( in, st... ); - } - }; - - template< typename... Rules > - struct skip_control< at< Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + const auto m = in.template mark< rewind_mode::required >(); + return ( Control< Rules >::template match< apply_mode::nothing, rewind_mode::active, Action, Control >( in, st... ) && ... ); + } + }; + + template< typename... Rules > + inline constexpr bool skip_control< at< Rules... > > = true; + +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/bof.hpp b/packages/PEGTL/include/tao/pegtl/internal/bof.hpp index b6c9c2177..53b8e59c4 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/bof.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/bof.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_BOF_HPP @@ -10,32 +10,22 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + struct bof { - namespace internal - { - struct bof - { - using analyze_t = analysis::generic< analysis::rule_type::OPT >; - - template< typename Input > - static bool match( Input& in ) noexcept - { - return in.byte() == 0; - } - }; + using analyze_t = analysis::generic< analysis::rule_type::opt >; - template<> - struct skip_control< bof > : std::true_type - { - }; - - } // namespace internal + template< typename Input > + [[nodiscard]] static bool match( Input& in ) noexcept + { + return in.byte() == 0; + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template<> + inline constexpr bool skip_control< bof > = true; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/bol.hpp b/packages/PEGTL/include/tao/pegtl/internal/bol.hpp index dda317929..e58d239f3 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/bol.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/bol.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_BOL_HPP @@ -10,32 +10,22 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + struct bol { - namespace internal - { - struct bol - { - using analyze_t = analysis::generic< analysis::rule_type::OPT >; - - template< typename Input > - static bool match( Input& in ) noexcept - { - return in.byte_in_line() == 0; - } - }; + using analyze_t = analysis::generic< analysis::rule_type::opt >; - template<> - struct skip_control< bol > : std::true_type - { - }; - - } // namespace internal + template< typename Input > + [[nodiscard]] static bool match( Input& in ) noexcept + { + return in.byte_in_line() == 0; + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template<> + inline constexpr bool skip_control< bol > = true; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/bump.hpp b/packages/PEGTL/include/tao/pegtl/internal/bump.hpp new file mode 100644 index 000000000..293b1bbfd --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/internal/bump.hpp @@ -0,0 +1,45 @@ +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_BUMP_HPP +#define TAO_PEGTL_INTERNAL_BUMP_HPP + +#include "../config.hpp" + +#include "iterator.hpp" + +namespace TAO_PEGTL_NAMESPACE::internal +{ + inline void bump( iterator& iter, const std::size_t count, const int ch ) noexcept + { + for( std::size_t i = 0; i < count; ++i ) { + if( iter.data[ i ] == ch ) { + ++iter.line; + iter.byte_in_line = 0; + } + else { + ++iter.byte_in_line; + } + } + iter.byte += count; + iter.data += count; + } + + inline void bump_in_this_line( iterator& iter, const std::size_t count ) noexcept + { + iter.data += count; + iter.byte += count; + iter.byte_in_line += count; + } + + inline void bump_to_next_line( iterator& iter, const std::size_t count ) noexcept + { + ++iter.line; + iter.byte += count; + iter.byte_in_line = 0; + iter.data += count; + } + +} // namespace TAO_PEGTL_NAMESPACE::internal + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/bump_help.hpp b/packages/PEGTL/include/tao/pegtl/internal/bump_help.hpp index b09f2edac..37b60cd2f 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_BUMP_HELP_HPP @@ -11,53 +11,19 @@ #include "result_on_found.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< result_on_found R, typename Input, typename Char, Char... Cs > + void bump_help( Input& in, const std::size_t count ) noexcept { - namespace internal - { - template< bool > - struct bump_impl; - - template<> - struct bump_impl< true > - { - template< typename Input > - static void bump( Input& in, const std::size_t count ) noexcept - { - in.bump( count ); - } - }; - - template<> - struct bump_impl< false > - { - template< typename Input > - static void bump( Input& in, const std::size_t count ) noexcept - { - in.bump_in_this_line( count ); - } - }; - - template< bool... > - struct bool_list - { - }; - - template< bool... Bs > - using bool_and = std::is_same< bool_list< Bs..., true >, bool_list< true, Bs... > >; - - template< result_on_found R, typename Input, typename Char, Char... Cs > - void bump_help( Input& in, const std::size_t count ) noexcept - { - bump_impl< bool_and< ( Cs != Input::eol_t::ch )... >::value != bool( R ) >::bump( in, count ); - } - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + if constexpr( ( ( Cs != Input::eol_t::ch ) && ... ) != bool( R ) ) { + in.bump( count ); + } + else { + in.bump_in_this_line( count ); + } + } + +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/bump_impl.hpp b/packages/PEGTL/include/tao/pegtl/internal/bump_impl.hpp deleted file mode 100644 index ffd904d46..000000000 --- a/packages/PEGTL/include/tao/pegtl/internal/bump_impl.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_BUMP_IMPL_HPP -#define TAO_PEGTL_INTERNAL_BUMP_IMPL_HPP - -#include "../config.hpp" - -#include "iterator.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - inline void bump( iterator& iter, const std::size_t count, const int ch ) noexcept - { - for( std::size_t i = 0; i < count; ++i ) { - if( iter.data[ i ] == ch ) { - ++iter.line; - iter.byte_in_line = 0; - } - else { - ++iter.byte_in_line; - } - } - iter.byte += count; - iter.data += count; - } - - inline void bump_in_this_line( iterator& iter, const std::size_t count ) noexcept - { - iter.data += count; - iter.byte += count; - iter.byte_in_line += count; - } - - inline void bump_to_next_line( iterator& iter, const std::size_t count ) noexcept - { - ++iter.line; - iter.byte += count; - iter.byte_in_line = 0; - iter.data += count; - } - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/bytes.hpp b/packages/PEGTL/include/tao/pegtl/internal/bytes.hpp index 789224c33..9289d0f42 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/bytes.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/bytes.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_BYTES_HPP @@ -10,37 +10,27 @@ #include "../analysis/counted.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< unsigned Num > + struct bytes { - namespace internal + using analyze_t = analysis::counted< analysis::rule_type::any, Num >; + + template< typename Input > + [[nodiscard]] static bool match( Input& in ) noexcept( noexcept( in.size( 0 ) ) ) { - template< unsigned Num > - struct bytes - { - using analyze_t = analysis::counted< analysis::rule_type::ANY, Num >; - - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( in.size( 0 ) ) ) - { - if( in.size( Num ) >= Num ) { - in.bump( Num ); - return true; - } - return false; - } - }; - - template< unsigned Num > - struct skip_control< bytes< Num > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + if( in.size( Num ) >= Num ) { + in.bump( Num ); + return true; + } + return false; + } + }; + + template< unsigned Num > + inline constexpr bool skip_control< bytes< Num > > = true; + +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/conditional.hpp b/packages/PEGTL/include/tao/pegtl/internal/conditional.hpp deleted file mode 100644 index dbf356da1..000000000 --- a/packages/PEGTL/include/tao/pegtl/internal/conditional.hpp +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_CONDITIONAL_HPP -#define TAO_PEGTL_INTERNAL_CONDITIONAL_HPP - -#include "../config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< bool > - struct conditional; - - template<> - struct conditional< true > - { - template< typename T, typename > - using type = T; - }; - - template<> - struct conditional< false > - { - template< typename, typename T > - using type = T; - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/control.hpp b/packages/PEGTL/include/tao/pegtl/internal/control.hpp index 88cc5a18a..afc30a675 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/control.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/control.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_CONTROL_HPP @@ -15,38 +15,30 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< template< typename... > class Control, typename... Rules > + struct control { - namespace internal + using analyze_t = analysis::generic< analysis::rule_type::seq, Rules... >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) { - template< template< typename... > class Control, typename... Rules > - struct control - { - using analyze_t = analysis::generic< analysis::rule_type::SEQ, Rules... >; - - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return duseltronik< seq< Rules... >, A, M, Action, Control >::match( in, st... ); - } - }; - - template< template< typename... > class Control, typename... Rules > - struct skip_control< control< Control, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + return duseltronik< seq< Rules... >, A, M, Action, Control >::match( in, st... ); + } + }; + + template< template< typename... > class Control, typename... Rules > + inline constexpr bool skip_control< control< Control, Rules... > > = true; + +} // namespace TAO_PEGTL_NAMESPACE::internal #endif 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 8b83e2480..ff902142c 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/cr_crlf_eol.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/cr_crlf_eol.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_CR_CRLF_EOL_HPP @@ -7,34 +7,26 @@ #include "../config.hpp" #include "../eol_pair.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + struct cr_crlf_eol { - namespace internal - { - struct cr_crlf_eol - { - static constexpr int ch = '\r'; + static constexpr int ch = '\r'; - template< typename Input > - static eol_pair match( Input& in ) noexcept( noexcept( in.size( 2 ) ) ) - { - eol_pair p = { false, in.size( 2 ) }; - if( p.second ) { - if( in.peek_char() == '\r' ) { - in.bump_to_next_line( 1 + ( ( p.second > 1 ) && ( in.peek_char( 1 ) == '\n' ) ) ); - p.first = true; - } - } - return p; + template< typename Input > + [[nodiscard]] static eol_pair match( Input& in ) noexcept( noexcept( in.size( 2 ) ) ) + { + eol_pair p = { false, in.size( 2 ) }; + if( p.second ) { + if( in.peek_char() == '\r' ) { + in.bump_to_next_line( 1 + ( ( p.second > 1 ) && ( in.peek_char( 1 ) == '\n' ) ) ); + p.first = true; } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE + } + return p; + } + }; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/cr_eol.hpp b/packages/PEGTL/include/tao/pegtl/internal/cr_eol.hpp index ad2bb5e71..cf7d7e07f 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/cr_eol.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/cr_eol.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_CR_EOL_HPP @@ -7,34 +7,26 @@ #include "../config.hpp" #include "../eol_pair.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + struct cr_eol { - namespace internal - { - struct cr_eol - { - static constexpr int ch = '\r'; + static constexpr int ch = '\r'; - template< typename Input > - static eol_pair match( Input& in ) noexcept( noexcept( in.size( 1 ) ) ) - { - eol_pair p = { false, in.size( 1 ) }; - if( p.second ) { - if( in.peek_char() == '\r' ) { - in.bump_to_next_line(); - p.first = true; - } - } - return p; + template< typename Input > + [[nodiscard]] static eol_pair match( Input& in ) noexcept( noexcept( in.size( 1 ) ) ) + { + eol_pair p = { false, in.size( 1 ) }; + if( p.second ) { + if( in.peek_char() == '\r' ) { + in.bump_to_next_line(); + p.first = true; } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE + } + return p; + } + }; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/crlf_eol.hpp b/packages/PEGTL/include/tao/pegtl/internal/crlf_eol.hpp index 308eca99f..017076f6d 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/crlf_eol.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/crlf_eol.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_CRLF_EOL_HPP @@ -7,34 +7,26 @@ #include "../config.hpp" #include "../eol_pair.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + struct crlf_eol { - namespace internal - { - struct crlf_eol - { - static constexpr int ch = '\n'; + static constexpr int ch = '\n'; - template< typename Input > - static eol_pair match( Input& in ) noexcept( noexcept( in.size( 2 ) ) ) - { - eol_pair p = { false, in.size( 2 ) }; - if( p.second > 1 ) { - if( ( in.peek_char() == '\r' ) && ( in.peek_char( 1 ) == '\n' ) ) { - in.bump_to_next_line( 2 ); - p.first = true; - } - } - return p; + template< typename Input > + [[nodiscard]] static eol_pair match( Input& in ) noexcept( noexcept( in.size( 2 ) ) ) + { + eol_pair p = { false, in.size( 2 ) }; + if( p.second > 1 ) { + if( ( in.peek_char() == '\r' ) && ( in.peek_char( 1 ) == '\n' ) ) { + in.bump_to_next_line( 2 ); + p.first = true; } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE + } + return p; + } + }; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/cstream_reader.hpp b/packages/PEGTL/include/tao/pegtl/internal/cstream_reader.hpp index 756bc546d..1d436eaf5 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_CSTREAM_READER_HPP @@ -8,43 +8,42 @@ #include <cstddef> #include <cstdio> +#include <system_error> + #include "../config.hpp" -#include "../input_error.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + struct cstream_reader { - namespace internal + explicit cstream_reader( std::FILE* s ) noexcept + : m_cstream( s ) + { + assert( m_cstream != nullptr ); + } + + [[nodiscard]] std::size_t operator()( char* buffer, const std::size_t length ) { - struct cstream_reader - { - explicit cstream_reader( std::FILE* s ) noexcept - : m_cstream( s ) - { - assert( m_cstream != nullptr ); - } - - std::size_t operator()( char* buffer, const std::size_t length ) - { - if( const auto r = std::fread( buffer, 1, length, m_cstream ) ) { - return r; - } - if( std::feof( m_cstream ) != 0 ) { - return 0; - } - // Please contact us if you know how to provoke the following exception. - // The example on cppreference.com doesn't work, at least not on macOS. - TAO_PEGTL_THROW_INPUT_ERROR( "error in fread() from cstream" ); // LCOV_EXCL_LINE - } - - std::FILE* m_cstream; - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + if( const auto r = std::fread( buffer, 1, length, m_cstream ) ) { + return r; + } + if( std::feof( m_cstream ) != 0 ) { + return 0; + } + + // Please contact us if you know how to provoke the following exception. + // The example on cppreference.com doesn't work, at least not on macOS. + + // LCOV_EXCL_START + const auto ec = std::ferror( m_cstream ); + assert( ec != 0 ); + throw std::system_error( ec, std::system_category(), "fread() failed" ); + // LCOV_EXCL_STOP + } + + std::FILE* m_cstream; + }; + +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/cstring_reader.hpp b/packages/PEGTL/include/tao/pegtl/internal/cstring_reader.hpp index e74592134..a1f2db454 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_CSTRING_READER_HPP @@ -8,42 +8,33 @@ #include <cstddef> #include "../config.hpp" -#include "../input_error.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + struct cstring_reader { - namespace internal + explicit cstring_reader( const char* zero_terminated ) noexcept + : m_cstring( zero_terminated ) { - struct cstring_reader - { - explicit cstring_reader( const char* zero_terminated ) noexcept - : m_cstring( zero_terminated ) - { - assert( m_cstring != nullptr ); - } - - std::size_t operator()( char* buffer, const std::size_t length ) noexcept - { - std::size_t i = 0; - char c; - - while( ( i < length ) && ( ( c = m_cstring[ i ] ) != 0 ) ) { - *buffer++ = c; - ++i; - } - m_cstring += i; - return i; - } - - const char* m_cstring; - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + assert( m_cstring != nullptr ); + } + + [[nodiscard]] std::size_t operator()( char* buffer, const std::size_t length ) noexcept + { + std::size_t i = 0; + char c; + + while( ( i < length ) && ( ( c = m_cstring[ i ] ) != 0 ) ) { + *buffer++ = c; + ++i; + } + m_cstring += i; + return i; + } + + const char* m_cstring; + }; + +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/demangle.hpp b/packages/PEGTL/include/tao/pegtl/internal/demangle.hpp index 9795f71dc..07e55b837 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/demangle.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/demangle.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_DEMANGLE_HPP @@ -9,34 +9,20 @@ #include "../config.hpp" -#if defined( __GLIBCXX__ ) +#if defined( __GLIBCXX__ ) || ( defined( __has_include ) && __has_include( <cxxabi.h> ) ) #include "demangle_cxxabi.hpp" -#elif defined( __has_include ) -#if __has_include( <cxxabi.h> ) -#include "demangle_cxxabi.hpp" -#else -#include "demangle_nop.hpp" -#endif #else #include "demangle_nop.hpp" #endif -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename T > + [[nodiscard]] std::string demangle() { - namespace internal - { - template< typename T > - std::string demangle() - { - return demangle( typeid( T ).name() ); - } - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE + return demangle( typeid( T ).name() ); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/demangle_cxxabi.hpp b/packages/PEGTL/include/tao/pegtl/internal/demangle_cxxabi.hpp index e5ecbf908..a7e5bc7bb 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/demangle_cxxabi.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/demangle_cxxabi.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_DEMANGLE_CXXABI_HPP @@ -13,29 +13,21 @@ #include "demangle_sanitise.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + [[nodiscard]] inline std::string demangle( const char* symbol ) { - namespace internal - { - inline std::string demangle( const char* symbol ) - { - const std::unique_ptr< char, decltype( &std::free ) > demangled( abi::__cxa_demangle( symbol, nullptr, nullptr, nullptr ), &std::free ); - if( !demangled ) { - return symbol; - } - std::string result( demangled.get() ); -#ifdef TAO_PEGTL_PRETTY_DEMANGLE - demangle_sanitise_chars( result ); // LCOV_EXCL_LINE + const std::unique_ptr< char, decltype( &std::free ) > demangled( abi::__cxa_demangle( symbol, nullptr, nullptr, nullptr ), &std::free ); + if( !demangled ) { + return symbol; + } + std::string result( demangled.get() ); +#if defined( TAO_PEGTL_PRETTY_DEMANGLE ) + demangle_sanitise_chars( result ); // LCOV_EXCL_LINE #endif - return result; - } + return result; + } - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/demangle_nop.hpp b/packages/PEGTL/include/tao/pegtl/internal/demangle_nop.hpp index fe72b88b3..b178f040c 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/demangle_nop.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/demangle_nop.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_DEMANGLE_NOP_HPP @@ -8,21 +8,13 @@ #include "../config.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + [[nodiscard]] inline std::string demangle( const char* symbol ) { - namespace internal - { - inline std::string demangle( const char* symbol ) - { - return symbol; - } + return symbol; + } - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/demangle_sanitise.hpp b/packages/PEGTL/include/tao/pegtl/internal/demangle_sanitise.hpp index 7dfb59956..47f7549c6 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/demangle_sanitise.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/demangle_sanitise.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_DEMANGLE_SANITISE_HPP @@ -8,41 +8,33 @@ #include "../config.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + inline void demangle_sanitise_chars( std::string& s ) { - namespace internal - { - inline void demangle_sanitise_chars( std::string& s ) - { - std::string::size_type p; - while( ( p = s.find( "(char)" ) ) != std::string::npos ) { - int c = 0; - std::string::size_type q; - for( q = p + 6; ( q < s.size() ) && ( s[ q ] >= '0' ) && ( s[ q ] <= '9' ); ++q ) { - c *= 10; - c += s[ q ] - '0'; - } - if( c == '\'' ) { - s.replace( p, q - p, "'\\''" ); - } - else if( c == '\\' ) { - s.replace( p, q - p, "'\\\\'" ); - } - else if( ( c < 32 ) || ( c > 126 ) ) { - s.replace( p, 6, std::string() ); - } - else { - s.replace( p, q - p, std::string( 1, '\'' ) + char( c ) + '\'' ); - } - } + std::string::size_type p; + while( ( p = s.find( "(char)" ) ) != std::string::npos ) { + int c = 0; + std::string::size_type q; + for( q = p + 6; ( q < s.size() ) && ( s[ q ] >= '0' ) && ( s[ q ] <= '9' ); ++q ) { + c *= 10; + c += s[ q ] - '0'; } + if( c == '\'' ) { + s.replace( p, q - p, "'\\''" ); + } + else if( c == '\\' ) { + s.replace( p, q - p, "'\\\\'" ); + } + else if( ( c < 32 ) || ( c > 126 ) ) { + s.replace( p, 6, std::string() ); + } + else { + s.replace( p, q - p, std::string( 1, '\'' ) + char( c ) + '\'' ); + } + } + } - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/disable.hpp b/packages/PEGTL/include/tao/pegtl/internal/disable.hpp index 90ae99b31..10e878d31 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/disable.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/disable.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_DISABLE_HPP @@ -15,38 +15,30 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename... Rules > + struct disable { - namespace internal + using analyze_t = analysis::generic< analysis::rule_type::seq, Rules... >; + + template< apply_mode, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) { - template< typename... Rules > - struct disable - { - using analyze_t = analysis::generic< analysis::rule_type::SEQ, Rules... >; - - template< apply_mode, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return duseltronik< seq< Rules... >, apply_mode::NOTHING, M, Action, Control >::match( in, st... ); - } - }; - - template< typename... Rules > - struct skip_control< disable< Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + return duseltronik< seq< Rules... >, apply_mode::nothing, M, Action, Control >::match( in, st... ); + } + }; + + template< typename... Rules > + inline constexpr bool skip_control< disable< Rules... > > = true; + +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/discard.hpp b/packages/PEGTL/include/tao/pegtl/internal/discard.hpp index 89cb2f16c..ffd5ff431 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/discard.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/discard.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_DISCARD_HPP @@ -10,34 +10,24 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + struct discard { - namespace internal - { - struct discard - { - using analyze_t = analysis::generic< analysis::rule_type::OPT >; - - template< typename Input > - static bool match( Input& in ) noexcept - { - static_assert( noexcept( in.discard() ), "an input's discard()-method must be noexcept" ); - in.discard(); - return true; - } - }; + using analyze_t = analysis::generic< analysis::rule_type::opt >; - template<> - struct skip_control< discard > : std::true_type - { - }; - - } // namespace internal + template< typename Input > + [[nodiscard]] static bool match( Input& in ) noexcept + { + static_assert( noexcept( in.discard() ) ); + in.discard(); + return true; + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template<> + inline constexpr bool skip_control< discard > = true; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/dusel_mode.hpp b/packages/PEGTL/include/tao/pegtl/internal/dusel_mode.hpp index 9fc7a58d6..3a40eba3a 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/dusel_mode.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/dusel_mode.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_DUSEL_MODE_HPP @@ -6,22 +6,18 @@ #include "../config.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + enum class dusel_mode : char { - enum class dusel_mode : char - { - NOTHING = 0, - CONTROL = 1, - CONTROL_AND_APPLY_VOID = 2, - CONTROL_AND_APPLY_BOOL = 3, - CONTROL_AND_APPLY0_VOID = 4, - CONTROL_AND_APPLY0_BOOL = 5 - }; + nothing = 0, + control = 1, + control_and_apply_void = 2, + control_and_apply_bool = 3, + control_and_apply0_void = 4, + control_and_apply0_bool = 5 + }; - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/duseltronik.hpp b/packages/PEGTL/include/tao/pegtl/internal/duseltronik.hpp index 20099a477..6f1ca814e 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/duseltronik.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/duseltronik.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_DUSELTRONIK_HPP @@ -10,165 +10,169 @@ #include "dusel_mode.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + dusel_mode = dusel_mode::nothing > + struct duseltronik; + + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control > + struct duseltronik< Rule, A, M, Action, Control, dusel_mode::nothing > { - namespace internal + template< typename Input, typename... States > + [[nodiscard]] static auto match( Input& in, States&&... st ) + -> decltype( Rule::template match< A, M, Action, Control >( in, st... ) ) { - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - dusel_mode = dusel_mode::NOTHING > - struct duseltronik; - - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control > - struct duseltronik< Rule, A, M, Action, Control, dusel_mode::NOTHING > - { - template< typename Input, typename... States > - static auto match( Input& in, States&&... st ) - -> decltype( Rule::template match< A, M, Action, Control >( in, st... ), true ) - { - return Rule::template match< A, M, Action, Control >( in, st... ); - } + return Rule::template match< A, M, Action, Control >( in, st... ); + } - // NOTE: The additional "int = 0" is a work-around for missing expression SFINAE in VS2015. + template< typename Input, typename... States, int = 1 > + [[nodiscard]] static auto match( Input& in, States&&... /*unused*/ ) + -> decltype( Rule::match( in ) ) + { + return Rule::match( in ); + } + }; + + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control > + struct duseltronik< Rule, A, M, Action, Control, dusel_mode::control > + { + template< typename Input, typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + Control< Rule >::start( static_cast< const Input& >( in ), st... ); + + if( duseltronik< Rule, A, M, Action, Control, dusel_mode::nothing >::match( in, st... ) ) { + Control< Rule >::success( static_cast< const Input& >( in ), st... ); + return true; + } + Control< Rule >::failure( static_cast< const Input& >( in ), st... ); + return false; + } + }; + + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control > + struct duseltronik< Rule, A, M, Action, Control, dusel_mode::control_and_apply_void > + { + template< typename Input, typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + auto m = in.template mark< rewind_mode::required >(); + + Control< Rule >::start( static_cast< const Input& >( in ), st... ); + + if( duseltronik< Rule, A, rewind_mode::active, Action, Control, dusel_mode::nothing >::match( in, st... ) ) { + Control< Rule >::template apply< Action >( m.iterator(), static_cast< const Input& >( in ), st... ); + Control< Rule >::success( static_cast< const Input& >( in ), st... ); + return m( true ); + } + Control< Rule >::failure( static_cast< const Input& >( in ), st... ); + return false; + } + }; + + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control > + struct duseltronik< Rule, A, M, Action, Control, dusel_mode::control_and_apply_bool > + { + template< typename Input, typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + auto m = in.template mark< rewind_mode::required >(); - template< typename Input, typename... States, int = 0 > - static auto match( Input& in, States&&... /*unused*/ ) - -> decltype( Rule::match( in ), true ) - { - return Rule::match( in ); - } - }; - - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control > - struct duseltronik< Rule, A, M, Action, Control, dusel_mode::CONTROL > - { - template< typename Input, typename... States > - static bool match( Input& in, States&&... st ) - { - Control< Rule >::start( static_cast< const Input& >( in ), st... ); - - if( duseltronik< Rule, A, M, Action, Control, dusel_mode::NOTHING >::match( in, st... ) ) { - Control< Rule >::success( static_cast< const Input& >( in ), st... ); - return true; - } - Control< Rule >::failure( static_cast< const Input& >( in ), st... ); - return false; - } - }; - - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control > - struct duseltronik< Rule, A, M, Action, Control, dusel_mode::CONTROL_AND_APPLY_VOID > - { - template< typename Input, typename... States > - static bool match( Input& in, States&&... st ) - { - auto m = in.template mark< rewind_mode::REQUIRED >(); - - Control< Rule >::start( static_cast< const Input& >( in ), st... ); - - if( duseltronik< Rule, A, rewind_mode::ACTIVE, Action, Control, dusel_mode::NOTHING >::match( in, st... ) ) { - Control< Rule >::template apply< Action >( m.iterator(), static_cast< const Input& >( in ), st... ); - Control< Rule >::success( static_cast< const Input& >( in ), st... ); - return m( true ); - } - Control< Rule >::failure( static_cast< const Input& >( in ), st... ); - return false; - } - }; - - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control > - struct duseltronik< Rule, A, M, Action, Control, dusel_mode::CONTROL_AND_APPLY_BOOL > - { - template< typename Input, typename... States > - static bool match( Input& in, States&&... st ) - { - auto m = in.template mark< rewind_mode::REQUIRED >(); - - Control< Rule >::start( static_cast< const Input& >( in ), st... ); - - if( duseltronik< Rule, A, rewind_mode::ACTIVE, Action, Control, dusel_mode::NOTHING >::match( in, st... ) ) { - if( Control< Rule >::template apply< Action >( m.iterator(), static_cast< const Input& >( in ), st... ) ) { - Control< Rule >::success( static_cast< const Input& >( in ), st... ); - return m( true ); - } - } - Control< Rule >::failure( static_cast< const Input& >( in ), st... ); - return false; - } - }; - - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control > - struct duseltronik< Rule, A, M, Action, Control, dusel_mode::CONTROL_AND_APPLY0_VOID > - { - template< typename Input, typename... States > - static bool match( Input& in, States&&... st ) - { - Control< Rule >::start( static_cast< const Input& >( in ), st... ); - - if( duseltronik< Rule, A, M, Action, Control, dusel_mode::NOTHING >::match( in, st... ) ) { - Control< Rule >::template apply0< Action >( static_cast< const Input& >( in ), st... ); - Control< Rule >::success( static_cast< const Input& >( in ), st... ); - return true; - } - Control< Rule >::failure( static_cast< const Input& >( in ), st... ); - return false; - } - }; - - template< typename Rule, - apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control > - struct duseltronik< Rule, A, M, Action, Control, dusel_mode::CONTROL_AND_APPLY0_BOOL > - { - template< typename Input, typename... States > - static bool match( Input& in, States&&... st ) - { - auto m = in.template mark< rewind_mode::REQUIRED >(); - - Control< Rule >::start( static_cast< const Input& >( in ), st... ); - - if( duseltronik< Rule, A, rewind_mode::ACTIVE, Action, Control, dusel_mode::NOTHING >::match( in, st... ) ) { - if( Control< Rule >::template apply0< Action >( static_cast< const Input& >( in ), st... ) ) { - Control< Rule >::success( static_cast< const Input& >( in ), st... ); - return m( true ); - } - } - Control< Rule >::failure( static_cast< const Input& >( in ), st... ); - return false; + Control< Rule >::start( static_cast< const Input& >( in ), st... ); + + if( duseltronik< Rule, A, rewind_mode::active, Action, Control, dusel_mode::nothing >::match( in, st... ) ) { + if( Control< Rule >::template apply< Action >( m.iterator(), static_cast< const Input& >( in ), st... ) ) { + Control< Rule >::success( static_cast< const Input& >( in ), st... ); + return m( true ); } - }; + } + Control< Rule >::failure( static_cast< const Input& >( in ), st... ); + return false; + } + }; + + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control > + struct duseltronik< Rule, A, M, Action, Control, dusel_mode::control_and_apply0_void > + { + template< typename Input, typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + Control< Rule >::start( static_cast< const Input& >( in ), st... ); + + if( duseltronik< Rule, A, M, Action, Control, dusel_mode::nothing >::match( in, st... ) ) { + Control< Rule >::template apply0< Action >( static_cast< const Input& >( in ), st... ); + Control< Rule >::success( static_cast< const Input& >( in ), st... ); + return true; + } + Control< Rule >::failure( static_cast< const Input& >( in ), st... ); + return false; + } + }; + + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control > + struct duseltronik< Rule, A, M, Action, Control, dusel_mode::control_and_apply0_bool > + { + template< typename Input, typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + auto m = in.template mark< rewind_mode::required >(); - } // namespace internal + Control< Rule >::start( static_cast< const Input& >( in ), st... ); - } // namespace TAO_PEGTL_NAMESPACE + if( duseltronik< Rule, A, rewind_mode::active, Action, Control, dusel_mode::nothing >::match( in, st... ) ) { + if( Control< Rule >::template apply0< Action >( static_cast< const Input& >( in ), st... ) ) { + Control< Rule >::success( static_cast< const Input& >( in ), st... ); + return m( true ); + } + } + Control< Rule >::failure( static_cast< const Input& >( in ), st... ); + return false; + } + }; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/enable.hpp b/packages/PEGTL/include/tao/pegtl/internal/enable.hpp index da490c6ef..7da5fb80e 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/enable.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/enable.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_ENABLE_HPP @@ -15,38 +15,30 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename... Rules > + struct enable { - namespace internal + using analyze_t = analysis::generic< analysis::rule_type::seq, Rules... >; + + template< apply_mode, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) { - template< typename... Rules > - struct enable - { - using analyze_t = analysis::generic< analysis::rule_type::SEQ, Rules... >; - - template< apply_mode, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return duseltronik< seq< Rules... >, apply_mode::ACTION, M, Action, Control >::match( in, st... ); - } - }; - - template< typename... Rules > - struct skip_control< enable< Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + return duseltronik< seq< Rules... >, apply_mode::action, M, Action, Control >::match( in, st... ); + } + }; + + template< typename... Rules > + inline constexpr bool skip_control< enable< Rules... > > = true; + +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/endian.hpp b/packages/PEGTL/include/tao/pegtl/internal/endian.hpp index b70775cc7..733248ec8 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/endian.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/endian.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_ENDIAN_HPP @@ -15,56 +15,48 @@ #include "endian_gcc.hpp" #endif -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename N > + [[nodiscard]] N h_to_be( const N n ) noexcept { - namespace internal - { - template< typename N > - N h_to_be( const N n ) noexcept - { - return N( to_and_from_be< sizeof( N ) >::convert( n ) ); - } + return N( to_and_from_be< sizeof( N ) >::convert( n ) ); + } - template< typename N > - N be_to_h( const N n ) noexcept - { - return h_to_be( n ); - } - - template< typename N > - N be_to_h( const void* p ) noexcept - { - N n; - std::memcpy( &n, p, sizeof( n ) ); - return internal::be_to_h( n ); - } - - template< typename N > - N h_to_le( const N n ) noexcept - { - return N( to_and_from_le< sizeof( N ) >::convert( n ) ); - } + template< typename N > + [[nodiscard]] N be_to_h( const N n ) noexcept + { + return h_to_be( n ); + } - template< typename N > - N le_to_h( const N n ) noexcept - { - return h_to_le( n ); - } + template< typename N > + [[nodiscard]] N be_to_h( const void* p ) noexcept + { + N n; + std::memcpy( &n, p, sizeof( n ) ); + return internal::be_to_h( n ); + } - template< typename N > - N le_to_h( const void* p ) noexcept - { - N n; - std::memcpy( &n, p, sizeof( n ) ); - return internal::le_to_h( n ); - } + template< typename N > + [[nodiscard]] N h_to_le( const N n ) noexcept + { + return N( to_and_from_le< sizeof( N ) >::convert( n ) ); + } - } // namespace internal + template< typename N > + [[nodiscard]] N le_to_h( const N n ) noexcept + { + return h_to_le( n ); + } - } // namespace TAO_PEGTL_NAMESPACE + template< typename N > + [[nodiscard]] N le_to_h( const void* p ) noexcept + { + N n; + std::memcpy( &n, p, sizeof( n ) ); + return internal::le_to_h( n ); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/endian_gcc.hpp b/packages/PEGTL/include/tao/pegtl/internal/endian_gcc.hpp index a8c514f8d..0079e3de5 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/endian_gcc.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/endian_gcc.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_ENDIAN_GCC_HPP @@ -7,103 +7,98 @@ #include <cstdint> #include <cstring> -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE +#if !defined( __BYTE_ORDER__ ) +#error No byte order defined! +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + + template< unsigned S > + struct to_and_from_be { - namespace internal + template< typename T > + [[nodiscard]] static T convert( const T n ) noexcept { + return n; + } + }; -#if not defined( __BYTE_ORDER__ ) -#error No byte order defined! -#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + template< unsigned S > + struct to_and_from_le; + + template<> + struct to_and_from_le< 1 > + { + [[nodiscard]] static std::uint8_t convert( const std::uint8_t n ) noexcept + { + return n; + } + + [[nodiscard]] static std::int8_t convert( const std::int8_t n ) noexcept + { + return n; + } + }; - template< unsigned S > - struct to_and_from_be - { - template< typename T > - static T convert( const T n ) noexcept - { - return n; - } - }; - - template< unsigned S > - struct to_and_from_le; - - template<> - struct to_and_from_le< 1 > - { - static std::uint8_t convert( const std::uint8_t n ) noexcept - { - return n; - } - - static std::int8_t convert( const std::int8_t n ) noexcept - { - return n; - } - }; - - template<> - struct to_and_from_le< 2 > - { - static std::int16_t convert( const std::int16_t n ) noexcept - { - return __builtin_bswap16( n ); - } - - static std::uint16_t convert( const std::uint16_t n ) noexcept - { - return __builtin_bswap16( n ); - } - }; - - template<> - struct to_and_from_le< 4 > - { - static float convert( float n ) noexcept - { - std::uint32_t u; - std::memcpy( &u, &n, 4 ); - u = convert( u ); - std::memcpy( &n, &u, 4 ); - return n; - } - - static std::int32_t convert( const std::int32_t n ) noexcept - { - return __builtin_bswap32( n ); - } - - static std::uint32_t convert( const std::uint32_t n ) noexcept - { - return __builtin_bswap32( n ); - } - }; - - template<> - struct to_and_from_le< 8 > - { - static double convert( double n ) noexcept - { - std::uint64_t u; - std::memcpy( &u, &n, 8 ); - u = convert( u ); - std::memcpy( &n, &u, 8 ); - return n; - } - - static std::int64_t convert( const std::int64_t n ) noexcept - { - return __builtin_bswap64( n ); - } - - static std::uint64_t convert( const std::uint64_t n ) noexcept - { - return __builtin_bswap64( n ); - } - }; + template<> + struct to_and_from_le< 2 > + { + [[nodiscard]] static std::int16_t convert( const std::int16_t n ) noexcept + { + return __builtin_bswap16( n ); + } + + [[nodiscard]] static std::uint16_t convert( const std::uint16_t n ) noexcept + { + return __builtin_bswap16( n ); + } + }; + + template<> + struct to_and_from_le< 4 > + { + [[nodiscard]] static float convert( float n ) noexcept + { + std::uint32_t u; + std::memcpy( &u, &n, 4 ); + u = convert( u ); + std::memcpy( &n, &u, 4 ); + return n; + } + + [[nodiscard]] static std::int32_t convert( const std::int32_t n ) noexcept + { + return __builtin_bswap32( n ); + } + + [[nodiscard]] static std::uint32_t convert( const std::uint32_t n ) noexcept + { + return __builtin_bswap32( n ); + } + }; + + template<> + struct to_and_from_le< 8 > + { + [[nodiscard]] static double convert( double n ) noexcept + { + std::uint64_t u; + std::memcpy( &u, &n, 8 ); + u = convert( u ); + std::memcpy( &n, &u, 8 ); + return n; + } + + [[nodiscard]] static std::int64_t convert( const std::int64_t n ) noexcept + { + return __builtin_bswap64( n ); + } + + [[nodiscard]] static std::uint64_t convert( const std::uint64_t n ) noexcept + { + return __builtin_bswap64( n ); + } + }; #define TAO_PEGTL_NATIVE_ORDER be #define TAO_PEGTL_NATIVE_UTF16 utf16_be @@ -111,92 +106,92 @@ namespace tao #elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ - template< unsigned S > - struct to_and_from_le - { - template< typename T > - static T convert( const T n ) noexcept - { - return n; - } - }; - - template< unsigned S > - struct to_and_from_be; - - template<> - struct to_and_from_be< 1 > - { - static std::int8_t convert( const std::int8_t n ) noexcept - { - return n; - } - - static std::uint8_t convert( const std::uint8_t n ) noexcept - { - return n; - } - }; - - template<> - struct to_and_from_be< 2 > - { - static std::int16_t convert( const std::int16_t n ) noexcept - { - return __builtin_bswap16( n ); - } - - static std::uint16_t convert( const std::uint16_t n ) noexcept - { - return __builtin_bswap16( n ); - } - }; - - template<> - struct to_and_from_be< 4 > - { - static float convert( float n ) noexcept - { - std::uint32_t u; - std::memcpy( &u, &n, 4 ); - u = convert( u ); - std::memcpy( &n, &u, 4 ); - return n; - } - - static std::int32_t convert( const std::int32_t n ) noexcept - { - return __builtin_bswap32( n ); - } - - static std::uint32_t convert( const std::uint32_t n ) noexcept - { - return __builtin_bswap32( n ); - } - }; - - template<> - struct to_and_from_be< 8 > - { - static double convert( double n ) noexcept - { - std::uint64_t u; - std::memcpy( &u, &n, 8 ); - u = convert( u ); - std::memcpy( &n, &u, 8 ); - return n; - } - - static std::uint64_t convert( const std::uint64_t n ) noexcept - { - return __builtin_bswap64( n ); - } - - static std::int64_t convert( const std::int64_t n ) noexcept - { - return __builtin_bswap64( n ); - } - }; + template< unsigned S > + struct to_and_from_le + { + template< typename T > + [[nodiscard]] static T convert( const T n ) noexcept + { + return n; + } + }; + + template< unsigned S > + struct to_and_from_be; + + template<> + struct to_and_from_be< 1 > + { + [[nodiscard]] static std::int8_t convert( const std::int8_t n ) noexcept + { + return n; + } + + [[nodiscard]] static std::uint8_t convert( const std::uint8_t n ) noexcept + { + return n; + } + }; + + template<> + struct to_and_from_be< 2 > + { + [[nodiscard]] static std::int16_t convert( const std::int16_t n ) noexcept + { + return __builtin_bswap16( n ); + } + + [[nodiscard]] static std::uint16_t convert( const std::uint16_t n ) noexcept + { + return __builtin_bswap16( n ); + } + }; + + template<> + struct to_and_from_be< 4 > + { + [[nodiscard]] static float convert( float n ) noexcept + { + std::uint32_t u; + std::memcpy( &u, &n, 4 ); + u = convert( u ); + std::memcpy( &n, &u, 4 ); + return n; + } + + [[nodiscard]] static std::int32_t convert( const std::int32_t n ) noexcept + { + return __builtin_bswap32( n ); + } + + [[nodiscard]] static std::uint32_t convert( const std::uint32_t n ) noexcept + { + return __builtin_bswap32( n ); + } + }; + + template<> + struct to_and_from_be< 8 > + { + [[nodiscard]] static double convert( double n ) noexcept + { + std::uint64_t u; + std::memcpy( &u, &n, 8 ); + u = convert( u ); + std::memcpy( &n, &u, 8 ); + return n; + } + + [[nodiscard]] static std::uint64_t convert( const std::uint64_t n ) noexcept + { + return __builtin_bswap64( n ); + } + + [[nodiscard]] static std::int64_t convert( const std::int64_t n ) noexcept + { + return __builtin_bswap64( n ); + } + }; #define TAO_PEGTL_NATIVE_ORDER le #define TAO_PEGTL_NATIVE_UTF16 utf16_le @@ -206,10 +201,6 @@ namespace tao #error Unknown host byte order! #endif - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/endian_win.hpp b/packages/PEGTL/include/tao/pegtl/internal/endian_win.hpp index 6b89f5f9d..63e92ff2d 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/endian_win.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/endian_win.hpp @@ -1,115 +1,106 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_ENDIAN_WIN_HPP #define TAO_PEGTL_INTERNAL_ENDIAN_WIN_HPP #include <cstdint> +#include <cstdlib> #include <cstring> -#include <stdlib.h> - -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< unsigned S > + struct to_and_from_le + { + template< typename T > + [[nodiscard]] static T convert( const T t ) noexcept + { + return t; + } + }; + + template< unsigned S > + struct to_and_from_be; + + template<> + struct to_and_from_be< 1 > + { + [[nodiscard]] static std::int8_t convert( const std::int8_t n ) noexcept + { + return n; + } + + [[nodiscard]] static std::uint8_t convert( const std::uint8_t n ) noexcept + { + return n; + } + }; + + template<> + struct to_and_from_be< 2 > + { + [[nodiscard]] static std::int16_t convert( const std::int16_t n ) noexcept + { + return std::int16_t( _byteswap_ushort( std::uint16_t( n ) ) ); + } + + [[nodiscard]] static std::uint16_t convert( const std::uint16_t n ) noexcept + { + return _byteswap_ushort( n ); + } + }; + + template<> + struct to_and_from_be< 4 > { - namespace internal + [[nodiscard]] static float convert( float n ) noexcept { - template< unsigned S > - struct to_and_from_le - { - template< typename T > - static T convert( const T t ) noexcept - { - return t; - } - }; - - template< unsigned S > - struct to_and_from_be; - - template<> - struct to_and_from_be< 1 > - { - static std::int8_t convert( const std::int8_t n ) noexcept - { - return n; - } - - static std::uint8_t convert( const std::uint8_t n ) noexcept - { - return n; - } - }; - - template<> - struct to_and_from_be< 2 > - { - static std::int16_t convert( const std::int16_t n ) noexcept - { - return std::int16_t( _byteswap_ushort( std::uint16_t( n ) ) ); - } - - static std::uint16_t convert( const std::uint16_t n ) noexcept - { - return _byteswap_ushort( n ); - } - }; - - template<> - struct to_and_from_be< 4 > - { - static float convert( float n ) noexcept - { - std::uint32_t u; - std::memcpy( &u, &n, 4 ); - u = convert( u ); - std::memcpy( &n, &u, 4 ); - return n; - } - - static std::int32_t convert( const std::int32_t n ) noexcept - { - return std::int32_t( _byteswap_ulong( std::uint32_t( n ) ) ); - } - - static std::uint32_t convert( const std::uint32_t n ) noexcept - { - return _byteswap_ulong( n ); - } - }; - - template<> - struct to_and_from_be< 8 > - { - static double convert( double n ) noexcept - { - std::uint64_t u; - std::memcpy( &u, &n, 8 ); - u = convert( u ); - std::memcpy( &n, &u, 8 ); - return n; - } - - static std::int64_t convert( const std::int64_t n ) noexcept - { - return std::int64_t( _byteswap_uint64( std::uint64_t( n ) ) ); - } - - static std::uint64_t convert( const std::uint64_t n ) noexcept - { - return _byteswap_uint64( n ); - } - }; + std::uint32_t u; + std::memcpy( &u, &n, 4 ); + u = convert( u ); + std::memcpy( &n, &u, 4 ); + return n; + } + + [[nodiscard]] static std::int32_t convert( const std::int32_t n ) noexcept + { + return std::int32_t( _byteswap_ulong( std::uint32_t( n ) ) ); + } + + [[nodiscard]] static std::uint32_t convert( const std::uint32_t n ) noexcept + { + return _byteswap_ulong( n ); + } + }; + + template<> + struct to_and_from_be< 8 > + { + [[nodiscard]] static double convert( double n ) noexcept + { + std::uint64_t u; + std::memcpy( &u, &n, 8 ); + u = convert( u ); + std::memcpy( &n, &u, 8 ); + return n; + } + + [[nodiscard]] static std::int64_t convert( const std::int64_t n ) noexcept + { + return std::int64_t( _byteswap_uint64( std::uint64_t( n ) ) ); + } + + [[nodiscard]] static std::uint64_t convert( const std::uint64_t n ) noexcept + { + return _byteswap_uint64( n ); + } + }; #define TAO_PEGTL_NATIVE_ORDER le #define TAO_PEGTL_NATIVE_UTF16 utf16_le #define TAO_PEGTL_NATIVE_UTF32 utf32_le - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/eof.hpp b/packages/PEGTL/include/tao/pegtl/internal/eof.hpp index 51ac283ca..bce5fe267 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/eof.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/eof.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_EOF_HPP @@ -10,32 +10,22 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + struct eof { - namespace internal - { - struct eof - { - using analyze_t = analysis::generic< analysis::rule_type::OPT >; - - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( in.empty() ) ) - { - return in.empty(); - } - }; + using analyze_t = analysis::generic< analysis::rule_type::opt >; - template<> - struct skip_control< eof > : std::true_type - { - }; - - } // namespace internal + template< typename Input > + [[nodiscard]] static bool match( Input& in ) noexcept( noexcept( in.empty() ) ) + { + return in.empty(); + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template<> + inline constexpr bool skip_control< eof > = true; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/eol.hpp b/packages/PEGTL/include/tao/pegtl/internal/eol.hpp index 9aae616a7..d764bccc0 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/eol.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/eol.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_EOL_HPP @@ -10,32 +10,22 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + struct eol { - namespace internal - { - struct eol - { - using analyze_t = analysis::generic< analysis::rule_type::ANY >; - - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( Input::eol_t::match( in ) ) ) - { - return Input::eol_t::match( in ).first; - } - }; + using analyze_t = analysis::generic< analysis::rule_type::any >; - template<> - struct skip_control< eol > : std::true_type - { - }; - - } // namespace internal + template< typename Input > + [[nodiscard]] static bool match( Input& in ) noexcept( noexcept( Input::eol_t::match( in ) ) ) + { + return Input::eol_t::match( in ).first; + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template<> + inline constexpr bool skip_control< eol > = true; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/eolf.hpp b/packages/PEGTL/include/tao/pegtl/internal/eolf.hpp index 777b814b8..6e9299686 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/eolf.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/eolf.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_EOLF_HPP @@ -10,33 +10,23 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + struct eolf { - namespace internal - { - struct eolf - { - using analyze_t = analysis::generic< analysis::rule_type::OPT >; - - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( Input::eol_t::match( in ) ) ) - { - const auto p = Input::eol_t::match( in ); - return p.first || ( !p.second ); - } - }; + using analyze_t = analysis::generic< analysis::rule_type::opt >; - template<> - struct skip_control< eolf > : std::true_type - { - }; - - } // namespace internal + template< typename Input > + [[nodiscard]] static bool match( Input& in ) noexcept( noexcept( Input::eol_t::match( in ) ) ) + { + const auto p = Input::eol_t::match( in ); + return p.first || ( !p.second ); + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template<> + inline constexpr bool skip_control< eolf > = true; -} // namespace tao +} // 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/file_mapper_posix.hpp index ef7ad8ee0..b639f052e 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/file_mapper_posix.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/file_mapper_posix.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_FILE_MAPPER_POSIX_HPP @@ -7,89 +7,77 @@ #include <sys/mman.h> #include <unistd.h> +#include <system_error> + #include "../config.hpp" #include "file_opener.hpp" -#include "../input_error.hpp" - -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + class file_mapper { - namespace internal + public: + explicit file_mapper( const char* filename ) + : file_mapper( file_opener( filename ) ) + { + } + + explicit file_mapper( const file_opener& reader ) + : m_size( reader.size() ), + m_data( static_cast< const char* >( ::mmap( nullptr, m_size, PROT_READ, MAP_PRIVATE, reader.m_fd, 0 ) ) ) { - class file_mapper - { - public: - explicit file_mapper( const char* filename ) - : file_mapper( file_opener( filename ) ) - { - } - - explicit file_mapper( const file_opener& 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 ) ) { - TAO_PEGTL_THROW_INPUT_ERROR( "unable to mmap() file " << reader.m_source << " descriptor " << reader.m_fd ); - } - } - - file_mapper( const file_mapper& ) = delete; - file_mapper( file_mapper&& ) = delete; - - ~file_mapper() noexcept - { - // Legacy C interface requires pointer-to-mutable but does not write through the pointer. - ::munmap( const_cast< char* >( m_data ), m_size ); // NOLINT - } - - void operator=( const file_mapper& ) = delete; - void operator=( file_mapper&& ) = delete; - - bool empty() const noexcept - { - return m_size == 0; - } - - std::size_t size() const noexcept - { - return m_size; - } - - using iterator = const char*; - using const_iterator = const char*; - - iterator data() const noexcept - { - return m_data; - } - - iterator begin() const noexcept - { - return m_data; - } - - iterator end() const noexcept - { - return m_data + m_size; - } - - std::string string() const - { - return std::string( m_data, m_size ); - } - - private: - const std::size_t m_size; - const char* const m_data; - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + if( ( m_size != 0 ) && ( intptr_t( m_data ) == -1 ) ) { + const auto ec = errno; + throw std::system_error( ec, std::system_category(), reader.m_source ); + } + } + + file_mapper( const file_mapper& ) = delete; + file_mapper( file_mapper&& ) = delete; + + ~file_mapper() noexcept + { + // Legacy C interface requires pointer-to-mutable but does not write through the pointer. + ::munmap( const_cast< char* >( m_data ), m_size ); // NOLINT + } + + void operator=( const file_mapper& ) = delete; + void operator=( file_mapper&& ) = delete; + + [[nodiscard]] bool empty() const noexcept + { + return m_size == 0; + } + + [[nodiscard]] std::size_t size() const noexcept + { + return m_size; + } + + using iterator = const char*; + using const_iterator = const char*; + + [[nodiscard]] iterator data() const noexcept + { + return m_data; + } + + [[nodiscard]] iterator begin() const noexcept + { + return m_data; + } + + [[nodiscard]] iterator end() const noexcept + { + return m_data + m_size; + } + + private: + const std::size_t m_size; + const char* const m_data; + }; + +} // 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/file_mapper_win32.hpp index 0f4d8f2b6..a705da097 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/file_mapper_win32.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/file_mapper_win32.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_FILE_MAPPER_WIN32_HPP @@ -10,8 +10,8 @@ #endif #if !defined( WIN32_LEAN_AND_MEAN ) -#define WIN32_MEAN_AND_LEAN -#define TAO_PEGTL_WIN32_MEAN_AND_LEAN_WAS_DEFINED +#define WIN32_LEAN_AND_MEAN +#define TAO_PEGTL_WIN32_LEAN_AND_MEAN_WAS_DEFINED #endif #include <windows.h> @@ -21,192 +21,199 @@ #undef TAO_PEGTL_NOMINMAX_WAS_DEFINED #endif -#if defined( TAO_PEGTL_WIN32_MEAN_AND_LEAN_WAS_DEFINED ) -#undef WIN32_MEAN_AND_LEAN -#undef TAO_PEGTL_WIN32_MEAN_AND_LEAN_WAS_DEFINED +#if defined( TAO_PEGTL_WIN32_LEAN_AND_MEAN_WAS_DEFINED ) +#undef WIN32_LEAN_AND_MEAN +#undef TAO_PEGTL_WIN32_LEAN_AND_MEAN_WAS_DEFINED #endif +#include <system_error> + #include "../config.hpp" -#include "../input_error.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + struct win32_file_opener + { + explicit win32_file_opener( const char* filename ) + : m_source( filename ), + m_handle( open() ) + { + } + + win32_file_opener( const win32_file_opener& ) = delete; + win32_file_opener( win32_file_opener&& ) = delete; + + ~win32_file_opener() noexcept + { + ::CloseHandle( m_handle ); + } + + void operator=( const win32_file_opener& ) = delete; + void operator=( win32_file_opener&& ) = delete; + + [[nodiscard]] std::size_t size() const + { + LARGE_INTEGER size; + if( !::GetFileSizeEx( m_handle, &size ) ) { + const auto ec = ::GetLastError(); + throw std::system_error( ec, std::system_category(), std::string( "GetFileSizeEx(): " ) + m_source ); + } + return std::size_t( size.QuadPart ); + } + + const char* const m_source; + const HANDLE m_handle; + + private: + [[nodiscard]] HANDLE open() const + { + SetLastError( 0 ); + std::wstring ws( m_source, m_source + strlen( m_source ) ); + +#if( _WIN32_WINNT >= 0x0602 ) + const HANDLE handle = ::CreateFile2( ws.c_str(), + GENERIC_READ, + FILE_SHARE_READ, + OPEN_EXISTING, + nullptr ); + if( handle != INVALID_HANDLE_VALUE ) { + return handle; + } + const auto ec = ::GetLastError(); + throw std::system_error( ec, std::system_category(), std::string( "CreateFile2(): " ) + m_source ); +#else + const HANDLE handle = ::CreateFileW( ws.c_str(), + GENERIC_READ, + FILE_SHARE_READ, + nullptr, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + nullptr ); + if( handle != INVALID_HANDLE_VALUE ) { + return handle; + } + const auto ec = ::GetLastError(); + throw std::system_error( ec, std::system_category(), std::string( "CreateFileW(): " ) + m_source ); +#endif + } + }; + + struct win32_file_mapper + { + explicit win32_file_mapper( const char* filename ) + : win32_file_mapper( win32_file_opener( filename ) ) + { + } + + explicit win32_file_mapper( const win32_file_opener& reader ) + : m_size( reader.size() ), + m_handle( open( reader ) ) + { + } + + win32_file_mapper( const win32_file_mapper& ) = delete; + win32_file_mapper( win32_file_mapper&& ) = delete; + + ~win32_file_mapper() noexcept + { + ::CloseHandle( m_handle ); + } + + void operator=( const win32_file_mapper& ) = delete; + void operator=( win32_file_mapper&& ) = delete; + + const size_t m_size; + const HANDLE m_handle; + + private: + [[nodiscard]] HANDLE open( const win32_file_opener& reader ) const + { + const uint64_t file_size = reader.size(); + SetLastError( 0 ); + // Use `CreateFileMappingW` because a) we're not specifying a + // mapping name, so the character type is of no consequence, and + // b) it's defined in `memoryapi.h`, unlike + // `CreateFileMappingA`(?!) + const HANDLE handle = ::CreateFileMappingW( reader.m_handle, + nullptr, + PAGE_READONLY, + DWORD( file_size >> 32 ), + DWORD( file_size & 0xffffffff ), + nullptr ); + if( handle != NULL || file_size == 0 ) { + return handle; + } + const auto ec = ::GetLastError(); + throw std::system_error( ec, std::system_category(), std::string( "CreateFileMappingW(): " ) + reader.m_source ); + } + }; + + class file_mapper { - namespace internal - { - struct win32_file_opener - { - explicit win32_file_opener( const char* filename ) - : m_source( filename ), - m_handle( open() ) - { - } - - win32_file_opener( const win32_file_opener& ) = delete; - win32_file_opener( win32_file_opener&& ) = delete; - - ~win32_file_opener() noexcept - { - ::CloseHandle( m_handle ); - } - - void operator=( const win32_file_opener& ) = delete; - void operator=( win32_file_opener&& ) = delete; - - std::size_t size() const - { - LARGE_INTEGER size; - if( !::GetFileSizeEx( m_handle, &size ) ) { - TAO_PEGTL_THROW_INPUT_WIN32_ERROR( "unable to GetFileSizeEx() file " << m_source << " handle " << m_handle ); - } - return std::size_t( size.QuadPart ); - } - - const char* const m_source; - const HANDLE m_handle; - - private: - HANDLE open() const - { - SetLastError( 0 ); - const HANDLE handle = ::CreateFileA( m_source, - GENERIC_READ, - FILE_SHARE_READ, - nullptr, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - nullptr ); - if( handle != INVALID_HANDLE_VALUE ) { - return handle; - } - TAO_PEGTL_THROW_INPUT_WIN32_ERROR( "unable to CreateFileA() file " << m_source << " for reading" ); - } - }; - - struct win32_file_mapper - { - explicit win32_file_mapper( const char* filename ) - : win32_file_mapper( win32_file_opener( filename ) ) - { - } - - explicit win32_file_mapper( const win32_file_opener& reader ) - : m_size( reader.size() ), - m_handle( open( reader ) ) - { - } - - win32_file_mapper( const win32_file_mapper& ) = delete; - win32_file_mapper( win32_file_mapper&& ) = delete; - - ~win32_file_mapper() noexcept - { - ::CloseHandle( m_handle ); - } - - void operator=( const win32_file_mapper& ) = delete; - void operator=( win32_file_mapper&& ) = delete; - - const size_t m_size; - const HANDLE m_handle; - - private: - HANDLE open( const win32_file_opener& reader ) const - { - const uint64_t file_size = reader.size(); - SetLastError( 0 ); - // Use `CreateFileMappingW` because a) we're not specifying a - // mapping name, so the character type is of no consequence, and - // b) it's defined in `memoryapi.h`, unlike - // `CreateFileMappingA`(?!) - const HANDLE handle = ::CreateFileMappingW( reader.m_handle, - nullptr, - PAGE_READONLY, - DWORD( file_size >> 32 ), - DWORD( file_size & 0xffffffff ), - nullptr ); - if( handle != NULL || file_size == 0 ) { - return handle; - } - TAO_PEGTL_THROW_INPUT_WIN32_ERROR( "unable to CreateFileMappingW() file " << reader.m_source << " for reading" ); - } - }; - - class file_mapper - { - public: - explicit file_mapper( const char* filename ) - : file_mapper( win32_file_mapper( filename ) ) - { - } - - explicit file_mapper( const win32_file_mapper& mapper ) - : m_size( mapper.m_size ), - m_data( static_cast< const char* const >(::MapViewOfFile( mapper.m_handle, - FILE_MAP_READ, - 0, - 0, - 0 ) ) ) - { - if( ( m_size != 0 ) && ( intptr_t( m_data ) == 0 ) ) { - TAO_PEGTL_THROW_INPUT_WIN32_ERROR( "unable to MapViewOfFile() file mapping object with handle " << mapper.m_handle ); - } - } - - file_mapper( const file_mapper& ) = delete; - file_mapper( file_mapper&& ) = delete; - - ~file_mapper() noexcept - { - ::UnmapViewOfFile( LPCVOID( m_data ) ); - } - - void operator=( const file_mapper& ) = delete; - void operator=( file_mapper&& ) = delete; - - bool empty() const noexcept - { - return m_size == 0; - } - - std::size_t size() const noexcept - { - return m_size; - } - - using iterator = const char*; - using const_iterator = const char*; - - iterator data() const noexcept - { - return m_data; - } - - iterator begin() const noexcept - { - return m_data; - } - - iterator end() const noexcept - { - return m_data + m_size; - } - - std::string string() const - { - return std::string( m_data, m_size ); - } - - private: - const std::size_t m_size; - const char* const m_data; - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + public: + explicit file_mapper( const char* filename ) + : file_mapper( win32_file_mapper( filename ) ) + { + } + + explicit file_mapper( const win32_file_mapper& mapper ) + : m_size( mapper.m_size ), + m_data( static_cast< const char* >( ::MapViewOfFile( mapper.m_handle, + FILE_MAP_READ, + 0, + 0, + 0 ) ) ) + { + if( ( m_size != 0 ) && ( intptr_t( m_data ) == 0 ) ) { + const auto ec = ::GetLastError(); + throw std::system_error( ec, std::system_category(), "MapViewOfFile()" ); + } + } + + file_mapper( const file_mapper& ) = delete; + file_mapper( file_mapper&& ) = delete; + + ~file_mapper() noexcept + { + ::UnmapViewOfFile( LPCVOID( m_data ) ); + } + + void operator=( const file_mapper& ) = delete; + void operator=( file_mapper&& ) = delete; + + [[nodiscard]] bool empty() const noexcept + { + return m_size == 0; + } + + [[nodiscard]] std::size_t size() const noexcept + { + return m_size; + } + + using iterator = const char*; + using const_iterator = const char*; + + [[nodiscard]] iterator data() const noexcept + { + return m_data; + } + + [[nodiscard]] iterator begin() const noexcept + { + return m_data; + } + + [[nodiscard]] iterator end() const noexcept + { + return m_data + m_size; + } + + private: + const std::size_t m_size; + const char* const m_data; + }; + +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/file_opener.hpp b/packages/PEGTL/include/tao/pegtl/internal/file_opener.hpp index 478f5fcb9..3ab1be783 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/file_opener.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/file_opener.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_FILE_OPENER_HPP @@ -9,70 +9,64 @@ #include <sys/types.h> #include <unistd.h> +#include <system_error> #include <utility> #include "../config.hpp" -#include "../input_error.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + struct file_opener { - namespace internal + explicit file_opener( const char* filename ) + : m_source( filename ), + m_fd( open() ) { - struct file_opener - { - explicit file_opener( const char* filename ) - : m_source( filename ), - m_fd( open() ) - { - } + } - file_opener( const file_opener& ) = delete; - file_opener( file_opener&& ) = delete; + file_opener( const file_opener& ) = delete; + file_opener( file_opener&& ) = delete; - ~file_opener() noexcept - { - ::close( m_fd ); - } + ~file_opener() noexcept + { + ::close( m_fd ); + } - void operator=( const file_opener& ) = delete; - void operator=( file_opener&& ) = delete; + void operator=( const file_opener& ) = delete; + void operator=( file_opener&& ) = delete; - std::size_t size() const - { - struct stat st; // NOLINT - errno = 0; - if(::fstat( m_fd, &st ) < 0 ) { - TAO_PEGTL_THROW_INPUT_ERROR( "unable to fstat() file " << m_source << " descriptor " << m_fd ); - } - return std::size_t( st.st_size ); - } + [[nodiscard]] std::size_t size() const + { + struct stat st; // NOLINT + errno = 0; + if( ::fstat( m_fd, &st ) < 0 ) { + const auto ec = errno; + throw std::system_error( ec, std::system_category(), m_source ); + } + return std::size_t( st.st_size ); + } - const char* const m_source; - const int m_fd; + const char* const m_source; + const int m_fd; - private: - int open() const - { - errno = 0; - const int fd = ::open( m_source, // NOLINT - O_RDONLY -#ifdef O_CLOEXEC - | O_CLOEXEC + private: + [[nodiscard]] int open() const + { + errno = 0; + const int fd = ::open( m_source, // NOLINT + O_RDONLY +#if defined( O_CLOEXEC ) + | O_CLOEXEC #endif - ); - if( fd >= 0 ) { - return fd; - } - TAO_PEGTL_THROW_INPUT_ERROR( "unable to open() file " << m_source << " for reading" ); - } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE + ); + if( fd >= 0 ) { + return fd; + } + const auto ec = errno; + throw std::system_error( ec, std::system_category(), m_source ); + } + }; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/file_reader.hpp b/packages/PEGTL/include/tao/pegtl/internal/file_reader.hpp index 6d95f8b1f..5b48f4bb0 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/file_reader.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/file_reader.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_FILE_READER_HPP @@ -7,103 +7,108 @@ #include <cstdio> #include <memory> #include <string> +#include <system_error> #include <utility> #include "../config.hpp" -#include "../input_error.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + [[nodiscard]] inline std::FILE* file_open( const char* filename ) { - namespace internal - { - inline std::FILE* file_open( const char* filename ) - { - errno = 0; + errno = 0; #if defined( _MSC_VER ) - std::FILE* file; - if(::fopen_s( &file, filename, "rb" ) == 0 ) + std::FILE* file; + if( ::fopen_s( &file, filename, "rb" ) == 0 ) #elif defined( __MINGW32__ ) - if( auto* file = std::fopen( filename, "rb" ) ) // NOLINT(cppcoreguidelines-owning-memory) + if( auto* file = std::fopen( filename, "rb" ) ) // NOLINT(cppcoreguidelines-owning-memory) #else - if( auto* file = std::fopen( filename, "rbe" ) ) // NOLINT(cppcoreguidelines-owning-memory) + if( auto* file = std::fopen( filename, "rbe" ) ) // NOLINT(cppcoreguidelines-owning-memory) #endif - { - return file; - } - TAO_PEGTL_THROW_INPUT_ERROR( "unable to fopen() file " << filename << " for reading" ); - } - - struct file_close - { - void operator()( FILE* f ) const noexcept - { - std::fclose( f ); // NOLINT(cppcoreguidelines-owning-memory) - } - }; - - class file_reader - { - public: - explicit file_reader( const char* filename ) - : m_source( filename ), - m_file( file_open( m_source ) ) - { - } + { + return file; + } + const auto ec = errno; + throw std::system_error( ec, std::system_category(), filename ); + } - file_reader( FILE* file, const char* filename ) noexcept - : m_source( filename ), - m_file( file ) - { - } + struct file_close + { + void operator()( FILE* f ) const noexcept + { + std::fclose( f ); // NOLINT(cppcoreguidelines-owning-memory) + } + }; - file_reader( const file_reader& ) = delete; - file_reader( file_reader&& ) = delete; + class file_reader + { + public: + explicit file_reader( const char* filename ) + : m_source( filename ), + m_file( file_open( m_source ) ) + { + } - ~file_reader() = default; + file_reader( FILE* file, const char* filename ) noexcept + : m_source( filename ), + m_file( file ) + { + } - void operator=( const file_reader& ) = delete; - void operator=( file_reader&& ) = delete; + file_reader( const file_reader& ) = delete; + file_reader( file_reader&& ) = delete; - std::size_t size() const - { - errno = 0; - if( std::fseek( m_file.get(), 0, SEEK_END ) != 0 ) { - TAO_PEGTL_THROW_INPUT_ERROR( "unable to fseek() to end of file " << m_source ); // LCOV_EXCL_LINE - } - errno = 0; - const auto s = std::ftell( m_file.get() ); - if( s < 0 ) { - TAO_PEGTL_THROW_INPUT_ERROR( "unable to ftell() file size of file " << m_source ); // LCOV_EXCL_LINE - } - errno = 0; - if( std::fseek( m_file.get(), 0, SEEK_SET ) != 0 ) { - TAO_PEGTL_THROW_INPUT_ERROR( "unable to fseek() to beginning of file " << m_source ); // LCOV_EXCL_LINE - } - return std::size_t( s ); - } + ~file_reader() = default; - std::string read() const - { - std::string nrv; - nrv.resize( size() ); - errno = 0; - if( !nrv.empty() && ( std::fread( &nrv[ 0 ], nrv.size(), 1, m_file.get() ) != 1 ) ) { - TAO_PEGTL_THROW_INPUT_ERROR( "unable to fread() file " << m_source << " size " << nrv.size() ); // LCOV_EXCL_LINE - } - return nrv; - } + void operator=( const file_reader& ) = delete; + void operator=( file_reader&& ) = delete; - private: - const char* const m_source; - const std::unique_ptr< std::FILE, file_close > m_file; - }; + [[nodiscard]] std::size_t size() const + { + errno = 0; + if( std::fseek( m_file.get(), 0, SEEK_END ) != 0 ) { + // LCOV_EXCL_START + const auto ec = errno; + throw std::system_error( ec, std::system_category(), m_source ); + // LCOV_EXCL_STOP + } + errno = 0; + const auto s = std::ftell( m_file.get() ); + if( s < 0 ) { + // LCOV_EXCL_START + const auto ec = errno; + throw std::system_error( ec, std::system_category(), m_source ); + // LCOV_EXCL_STOP + } + errno = 0; + if( std::fseek( m_file.get(), 0, SEEK_SET ) != 0 ) { + // LCOV_EXCL_START + const auto ec = errno; + throw std::system_error( ec, std::system_category(), m_source ); + // LCOV_EXCL_STOP + } + return std::size_t( s ); + } - } // namespace internal + [[nodiscard]] std::string read() const + { + std::string nrv; + nrv.resize( size() ); + errno = 0; + if( !nrv.empty() && ( std::fread( &nrv[ 0 ], nrv.size(), 1, m_file.get() ) != 1 ) ) { + // LCOV_EXCL_START + const auto ec = errno; + throw std::system_error( ec, std::system_category(), m_source ); + // LCOV_EXCL_STOP + } + return nrv; + } - } // namespace TAO_PEGTL_NAMESPACE + private: + const char* const m_source; + const std::unique_ptr< std::FILE, file_close > m_file; + }; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/has_apply.hpp b/packages/PEGTL/include/tao/pegtl/internal/has_apply.hpp index 4a4f8db28..2c91aed89 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_HAS_APPLY_HPP @@ -8,26 +8,18 @@ #include "../config.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename, typename, typename... > - struct has_apply : std::false_type - { - }; + template< typename, typename, template< typename... > class, typename... > + struct has_apply + : std::false_type + {}; - template< typename A, typename... S > - struct has_apply< A, decltype( A::apply( std::declval< S >()... ) ), S... > : std::true_type - { - }; + template< typename C, template< typename... > class Action, typename... S > + struct has_apply< C, decltype( C::template apply< Action >( std::declval< S >()... ) ), Action, S... > + : std::true_type + {}; - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/has_apply0.hpp b/packages/PEGTL/include/tao/pegtl/internal/has_apply0.hpp index 6b1e486d9..b2319e8ce 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_HAS_APPLY0_HPP @@ -8,26 +8,18 @@ #include "../config.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename, typename, typename... > - struct has_apply0 : std::false_type - { - }; + template< typename, typename, template< typename... > class, typename... > + struct has_apply0 + : std::false_type + {}; - template< typename A, typename... S > - struct has_apply0< A, decltype( A::apply0( std::declval< S >()... ) ), S... > : std::true_type - { - }; + template< typename C, template< typename... > class Action, typename... S > + struct has_apply0< C, decltype( C::template apply0< Action >( std::declval< S >()... ) ), Action, S... > + : std::true_type + {}; - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // 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 new file mode 100644 index 000000000..08186d622 --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/internal/has_match.hpp @@ -0,0 +1,56 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_HAS_MATCH_HPP +#define TAO_PEGTL_INTERNAL_HAS_MATCH_HPP + +#include <type_traits> +#include <utility> + +#include "../apply_mode.hpp" +#include "../config.hpp" +#include "../rewind_mode.hpp" + +namespace TAO_PEGTL_NAMESPACE::internal +{ + template< typename, + typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + struct has_match + : std::false_type + {}; + + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + struct has_match< decltype( (void)Action< Rule >::template match< Rule, A, M, Action, Control >( std::declval< Input& >(), std::declval< States&& >()... ), void() ), Rule, A, M, Action, Control, Input, States... > + : std::true_type + {}; + + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + inline constexpr bool has_match_v = has_match< void, Rule, A, M, Action, Control, Input, States... >::value; + +} // namespace TAO_PEGTL_NAMESPACE::internal + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/identifier.hpp b/packages/PEGTL/include/tao/pegtl/internal/identifier.hpp index 59f62188f..ce666df2b 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/identifier.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/identifier.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_IDENTIFIER_HPP @@ -11,20 +11,12 @@ #include "seq.hpp" #include "star.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - using identifier_first = ranges< peek_char, 'a', 'z', 'A', 'Z', '_' >; - using identifier_other = ranges< peek_char, 'a', 'z', 'A', 'Z', '0', '9', '_' >; - using identifier = seq< identifier_first, star< identifier_other > >; + using identifier_first = ranges< peek_char, 'a', 'z', 'A', 'Z', '_' >; + using identifier_other = ranges< peek_char, 'a', 'z', 'A', 'Z', '0', '9', '_' >; + using identifier = seq< identifier_first, star< identifier_other > >; - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/if_apply.hpp b/packages/PEGTL/include/tao/pegtl/internal/if_apply.hpp index 58d0e97ab..342d94447 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/if_apply.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/if_apply.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_IF_APPLY_HPP @@ -13,98 +13,41 @@ #include "../apply_mode.hpp" #include "../rewind_mode.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename Rule, typename... Actions > + struct if_apply { - namespace internal + using analyze_t = typename Rule::analyze_t; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) { - template< apply_mode A, typename Rule, typename... Actions > - struct if_apply_impl; - - template< typename Rule > - struct if_apply_impl< apply_mode::ACTION, Rule > - { - template< rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return Control< Rule >::template match< apply_mode::ACTION, M, Action, Control >( in, st... ); - } - }; - - template< typename Rule, typename... Actions > - struct if_apply_impl< apply_mode::ACTION, Rule, Actions... > - { - template< rewind_mode, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - using action_t = typename Input::action_t; - - auto m = in.template mark< 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 ); -#ifdef __cpp_fold_expressions - return m( ( apply_single< Actions >::match( i2, st... ) && ... ) ); -#else - bool result = true; - using swallow = bool[]; - (void)swallow{ result = result && apply_single< Actions >::match( i2, st... )... }; - return m( result ); -#endif - } - return false; - } - }; - - template< typename Rule, typename... Actions > - struct if_apply_impl< apply_mode::NOTHING, Rule, Actions... > - { - template< rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return Control< Rule >::template match< apply_mode::NOTHING, M, Action, Control >( in, st... ); + if constexpr( ( A == apply_mode::action ) && ( sizeof...( Actions ) != 0 ) ) { + using action_t = typename Input::action_t; + auto m = in.template mark< 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 ); + return m( ( apply_single< Actions >::match( i2, st... ) && ... ) ); } - }; - - template< typename Rule, typename... Actions > - struct if_apply - { - using analyze_t = typename Rule::analyze_t; - - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return if_apply_impl< A, Rule, Actions... >::template match< M, Action, Control >( in, st... ); - } - }; - - template< typename Rule, typename... Actions > - struct skip_control< if_apply< Rule, Actions... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + return false; + } + else { // NOLINT + return Control< Rule >::template match< A, M, Action, Control >( in, st... ); + } + } + }; + + template< typename Rule, typename... Actions > + inline constexpr bool skip_control< if_apply< Rule, Actions... > > = true; + +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/if_must.hpp b/packages/PEGTL/include/tao/pegtl/internal/if_must.hpp index f81fee47b..8b4bf328d 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_IF_MUST_HPP @@ -7,7 +7,6 @@ #include "../config.hpp" #include "must.hpp" -#include "rule_conjunction.hpp" #include "skip_control.hpp" #include "trivial.hpp" @@ -16,42 +15,34 @@ #include "../analysis/counted.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< bool Default, typename Cond, typename... Rules > + struct if_must { - namespace internal + using analyze_t = analysis::counted< analysis::rule_type::seq, Default ? 0 : 1, Cond, must< Rules... > >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) { - template< bool Default, typename Cond, typename... Rules > - struct if_must - { - using analyze_t = analysis::counted< analysis::rule_type::SEQ, Default ? 0 : 1, Cond, must< Rules... > >; - - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - if( Control< Cond >::template match< A, M, Action, Control >( in, st... ) ) { - rule_conjunction< must< Rules >... >::template match< A, M, Action, Control >( in, st... ); - return true; - } - return Default; - } - }; - - template< bool Default, typename Cond, typename... Rules > - struct skip_control< if_must< Default, Cond, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + if( Control< Cond >::template match< A, M, Action, Control >( in, st... ) ) { + (void)( Control< must< Rules > >::template match< A, M, Action, Control >( in, st... ) && ... ); + return true; + } + return Default; + } + }; + + template< bool Default, typename Cond, typename... Rules > + inline constexpr bool skip_control< if_must< Default, Cond, Rules... > > = true; + +} // namespace TAO_PEGTL_NAMESPACE::internal #endif 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 f049bcbfd..932ed2ac1 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_IF_MUST_ELSE_HPP @@ -9,19 +9,11 @@ #include "if_then_else.hpp" #include "must.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Cond, typename Then, typename Else > - using if_must_else = if_then_else< Cond, must< Then >, must< Else > >; + template< typename Cond, typename Then, typename Else > + using if_must_else = if_then_else< Cond, must< Then >, must< Else > >; - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif 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 5e851d839..88a889311 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/if_then_else.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/if_then_else.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_IF_THEN_ELSE_HPP @@ -16,44 +16,36 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename Cond, typename Then, typename Else > + struct if_then_else { - namespace internal + using analyze_t = analysis::generic< analysis::rule_type::sor, seq< Cond, Then >, seq< not_at< Cond >, Else > >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) { - template< typename Cond, typename Then, typename Else > - struct if_then_else - { - using analyze_t = analysis::generic< analysis::rule_type::SOR, seq< Cond, Then >, seq< not_at< Cond >, Else > >; - - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - auto m = in.template mark< M >(); - using m_t = decltype( m ); - - if( Control< Cond >::template match< A, rewind_mode::REQUIRED, Action, Control >( in, st... ) ) { - return m( Control< Then >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ); - } - return m( Control< Else >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ); - } - }; - - template< typename Cond, typename Then, typename Else > - struct skip_control< if_then_else< Cond, Then, Else > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + auto m = in.template mark< M >(); + using m_t = decltype( m ); + + if( Control< Cond >::template match< A, rewind_mode::required, Action, Control >( in, st... ) ) { + return m( Control< Then >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ); + } + return m( Control< Else >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ); + } + }; + + template< typename Cond, typename Then, typename Else > + inline constexpr bool skip_control< if_then_else< Cond, Then, Else > > = true; + +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/input_pair.hpp b/packages/PEGTL/include/tao/pegtl/internal/input_pair.hpp index 362b07c18..976e3eb53 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/input_pair.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/input_pair.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_INPUT_PAIR_HPP @@ -8,30 +8,22 @@ #include "../config.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename Data > + struct input_pair { - namespace internal - { - template< typename Data > - struct input_pair - { - Data data; - std::uint8_t size; - - using data_t = Data; + Data data; + std::uint8_t size; - explicit operator bool() const noexcept - { - return size > 0; - } - }; + using data_t = Data; - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE + explicit operator bool() const noexcept + { + return size > 0; + } + }; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/integer_sequence.hpp b/packages/PEGTL/include/tao/pegtl/internal/integer_sequence.hpp deleted file mode 100644 index 29aeff69d..000000000 --- a/packages/PEGTL/include/tao/pegtl/internal/integer_sequence.hpp +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_INTEGER_SEQUENCE_HPP -#define TAO_PEGTL_INTERNAL_INTEGER_SEQUENCE_HPP - -#include <cstddef> -#include <type_traits> -#include <utility> - -#include "../config.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename T, T... Ns > - struct integer_sequence - { - using value_type = T; - - static constexpr std::size_t size() noexcept - { - return sizeof...( Ns ); - } - }; - - template< std::size_t... Ns > - using index_sequence = integer_sequence< std::size_t, Ns... >; - - template< bool V, bool E > - struct generate_sequence; - - template<> - struct generate_sequence< false, true > - { - template< typename T, T M, T N, std::size_t S, T... Ns > - using f = integer_sequence< T, Ns... >; - }; - - template<> - struct generate_sequence< true, true > - { - template< typename T, T M, T N, std::size_t S, T... Ns > - using f = integer_sequence< T, Ns..., S >; - }; - - template<> - struct generate_sequence< false, false > - { - template< typename T, T M, T N, std::size_t S, T... Ns > - using f = typename generate_sequence< ( N & ( M / 2 ) ) != 0, ( M / 2 ) == 0 >::template f< T, M / 2, N, 2 * S, Ns..., ( Ns + S )... >; - }; - - template<> - struct generate_sequence< true, false > - { - template< typename T, T M, T N, std::size_t S, T... Ns > - using f = typename generate_sequence< ( N & ( M / 2 ) ) != 0, ( M / 2 ) == 0 >::template f< T, M / 2, N, 2 * S + 1, Ns..., ( Ns + S )..., 2 * S >; - }; - - template< typename T, T N > - struct memoize_sequence - { - static_assert( N < T( 1 << 20 ), "N too large" ); - using type = typename generate_sequence< false, false >::template f< T, ( N < T( 1 << 1 ) ) ? T( 1 << 1 ) : ( N < T( 1 << 2 ) ) ? T( 1 << 2 ) : ( N < T( 1 << 3 ) ) ? T( 1 << 3 ) : ( N < T( 1 << 4 ) ) ? T( 1 << 4 ) : ( N < T( 1 << 5 ) ) ? T( 1 << 5 ) : ( N < T( 1 << 6 ) ) ? T( 1 << 6 ) : ( N < T( 1 << 7 ) ) ? T( 1 << 7 ) : ( N < T( 1 << 8 ) ) ? T( 1 << 8 ) : ( N < T( 1 << 9 ) ) ? T( 1 << 9 ) : ( N < T( 1 << 10 ) ) ? T( 1 << 10 ) : ( N < T( 1 << 11 ) ) ? T( 1 << 11 ) : ( N < T( 1 << 12 ) ) ? T( 1 << 12 ) : ( N < T( 1 << 13 ) ) ? T( 1 << 13 ) : ( N < T( 1 << 14 ) ) ? T( 1 << 14 ) : ( N < T( 1 << 15 ) ) ? T( 1 << 15 ) : ( N < T( 1 << 16 ) ) ? T( 1 << 16 ) : ( N < T( 1 << 17 ) ) ? T( 1 << 17 ) : ( N < T( 1 << 18 ) ) ? T( 1 << 18 ) : ( N < T( 1 << 19 ) ) ? T( 1 << 19 ) : T( 1 << 20 ), N, 0 >; - }; - - template< typename T, T N > - using make_integer_sequence = typename memoize_sequence< T, N >::type; - - template< std::size_t N > - using make_index_sequence = make_integer_sequence< std::size_t, N >; - - template< typename... Ts > - using index_sequence_for = make_index_sequence< sizeof...( Ts ) >; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/istream_reader.hpp b/packages/PEGTL/include/tao/pegtl/internal/istream_reader.hpp index 592c15e6a..b928a48a1 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/istream_reader.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/istream_reader.hpp @@ -1,47 +1,40 @@ -// Copyright (c) 2016-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_ISTREAM_READER_HPP #define TAO_PEGTL_INTERNAL_ISTREAM_READER_HPP #include <istream> +#include <system_error> #include "../config.hpp" -#include "../input_error.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + struct istream_reader { - namespace internal + explicit istream_reader( std::istream& s ) noexcept + : m_istream( s ) { - struct istream_reader - { - explicit istream_reader( std::istream& s ) noexcept - : m_istream( s ) - { - } - - std::size_t operator()( char* buffer, const std::size_t length ) - { - m_istream.read( buffer, std::streamsize( length ) ); - - if( const auto r = m_istream.gcount() ) { - return std::size_t( r ); - } - if( m_istream.eof() ) { - return 0; - } - TAO_PEGTL_THROW_INPUT_ERROR( "error in istream.read()" ); - } - - std::istream& m_istream; - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + } + + [[nodiscard]] std::size_t operator()( char* buffer, const std::size_t length ) + { + m_istream.read( buffer, std::streamsize( length ) ); + + if( const auto r = m_istream.gcount() ) { + return std::size_t( r ); + } + if( m_istream.eof() ) { + return 0; + } + const auto ec = errno; + throw std::system_error( ec, std::system_category(), "std::istream::read() failed" ); + } + + std::istream& m_istream; + }; + +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/istring.hpp b/packages/PEGTL/include/tao/pegtl/internal/istring.hpp index 5c8c4ab3a..4e9ce895d 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_ISTRING_HPP @@ -15,93 +15,58 @@ #include "../analysis/counted.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< char C > - using is_alpha = std::integral_constant< bool, ( ( 'a' <= C ) && ( C <= 'z' ) ) || ( ( 'A' <= C ) && ( C <= 'Z' ) ) >; + template< char C > + inline constexpr bool is_alpha = ( ( 'a' <= C ) && ( C <= 'z' ) ) || ( ( 'A' <= C ) && ( C <= 'Z' ) ); - template< char C, bool A = is_alpha< C >::value > - struct ichar_equal; + template< char C > + [[nodiscard]] bool ichar_equal( const char c ) noexcept + { + if constexpr( is_alpha< C > ) { + return ( C | 0x20 ) == ( c | 0x20 ); + } + else { // NOLINT + return c == C; + } + } + + template< char... Cs > + [[nodiscard]] bool istring_equal( const char* r ) noexcept + { + return ( ichar_equal< Cs >( *r++ ) && ... ); + } - template< char C > - struct ichar_equal< C, true > - { - static bool match( const char c ) noexcept - { - return ( C | 0x20 ) == ( c | 0x20 ); - } - }; + template< char... Cs > + struct istring; - template< char C > - struct ichar_equal< C, false > - { - static bool match( const char c ) noexcept - { - return c == C; - } - }; + template<> + struct istring<> + : trivial< true > + { + }; - template< char... Cs > - struct istring_equal; + template< char... Cs > + struct istring + { + using analyze_t = analysis::counted< analysis::rule_type::any, sizeof...( Cs ) >; - template<> - struct istring_equal<> - { - static bool match( const char* /*unused*/ ) noexcept - { + template< typename Input > + [[nodiscard]] static bool match( Input& in ) noexcept( noexcept( in.size( 0 ) ) ) + { + if( in.size( sizeof...( Cs ) ) >= sizeof...( Cs ) ) { + if( istring_equal< Cs... >( in.current() ) ) { + bump_help< result_on_found::success, Input, char, Cs... >( in, sizeof...( Cs ) ); return true; } - }; - - template< char C, char... Cs > - struct istring_equal< C, Cs... > - { - static bool match( const char* r ) noexcept - { - return ichar_equal< C >::match( *r ) && istring_equal< Cs... >::match( r + 1 ); - } - }; - - template< char... Cs > - struct istring; - - template<> - struct istring<> - : trivial< true > - { - }; - - template< char... Cs > - struct istring - { - using analyze_t = analysis::counted< analysis::rule_type::ANY, sizeof...( Cs ) >; - - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( in.size( 0 ) ) ) - { - if( in.size( sizeof...( Cs ) ) >= sizeof...( Cs ) ) { - if( istring_equal< Cs... >::match( in.current() ) ) { - bump_help< result_on_found::SUCCESS, Input, char, Cs... >( in, sizeof...( Cs ) ); - return true; - } - } - return false; - } - }; - - template< char... Cs > - struct skip_control< istring< Cs... > > : std::true_type - { - }; - - } // namespace internal + } + return false; + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template< char... Cs > + inline constexpr bool skip_control< istring< Cs... > > = true; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/iterator.hpp b/packages/PEGTL/include/tao/pegtl/internal/iterator.hpp index 4bc46f398..490a8c733 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/iterator.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/iterator.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_ITERATOR_HPP @@ -8,53 +8,45 @@ #include "../config.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + struct iterator { - namespace internal - { - struct iterator - { - iterator() noexcept = default; - - explicit iterator( 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_byte_in_line ) noexcept - : data( in_data ), - byte( in_byte ), - line( in_line ), - byte_in_line( in_byte_in_line ) - { - } + iterator() noexcept = default; - iterator( const iterator& ) = default; - iterator( iterator&& ) = default; + explicit iterator( const char* in_data ) noexcept + : data( in_data ) + { + } - ~iterator() = default; + iterator( const char* in_data, const std::size_t in_byte, const std::size_t in_line, const std::size_t in_byte_in_line ) noexcept + : data( in_data ), + byte( in_byte ), + line( in_line ), + byte_in_line( in_byte_in_line ) + { + } - iterator& operator=( const iterator& ) = default; - iterator& operator=( iterator&& ) = default; + iterator( const iterator& ) = default; + iterator( iterator&& ) = default; - void reset() noexcept - { - *this = iterator(); - } + ~iterator() = default; - const char* data = nullptr; + iterator& operator=( const iterator& ) = default; + iterator& operator=( iterator&& ) = default; - std::size_t byte = 0; - std::size_t line = 1; - std::size_t byte_in_line = 0; - }; + void reset() noexcept + { + *this = iterator(); + } - } // namespace internal + const char* data = nullptr; - } // namespace TAO_PEGTL_NAMESPACE + std::size_t byte = 0; + std::size_t line = 1; + std::size_t byte_in_line = 0; + }; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif 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 27a47c4ca..d510f9c2f 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/lf_crlf_eol.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/lf_crlf_eol.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_LF_CRLF_EOL_HPP @@ -7,39 +7,31 @@ #include "../config.hpp" #include "../eol_pair.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + struct lf_crlf_eol { - namespace internal - { - struct lf_crlf_eol - { - static constexpr int ch = '\n'; + static constexpr int ch = '\n'; - template< typename Input > - static eol_pair match( Input& in ) noexcept( noexcept( in.size( 2 ) ) ) - { - eol_pair p = { false, in.size( 2 ) }; - if( p.second ) { - const auto a = in.peek_char(); - if( a == '\n' ) { - in.bump_to_next_line(); - p.first = true; - } - else if( ( a == '\r' ) && ( p.second > 1 ) && ( in.peek_char( 1 ) == '\n' ) ) { - in.bump_to_next_line( 2 ); - p.first = true; - } - } - return p; + template< typename Input > + [[nodiscard]] static eol_pair match( Input& in ) noexcept( noexcept( in.size( 2 ) ) ) + { + eol_pair p = { false, in.size( 2 ) }; + if( p.second ) { + const auto a = in.peek_char(); + if( a == '\n' ) { + in.bump_to_next_line(); + p.first = true; } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE + else if( ( a == '\r' ) && ( p.second > 1 ) && ( in.peek_char( 1 ) == '\n' ) ) { + in.bump_to_next_line( 2 ); + p.first = true; + } + } + return p; + } + }; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/lf_eol.hpp b/packages/PEGTL/include/tao/pegtl/internal/lf_eol.hpp index 0104126d5..439ba51d0 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/lf_eol.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/lf_eol.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_LF_EOL_HPP @@ -7,34 +7,26 @@ #include "../config.hpp" #include "../eol_pair.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + struct lf_eol { - namespace internal - { - struct lf_eol - { - static constexpr int ch = '\n'; + static constexpr int ch = '\n'; - template< typename Input > - static eol_pair match( Input& in ) noexcept( noexcept( in.size( 1 ) ) ) - { - eol_pair p = { false, in.size( 1 ) }; - if( p.second ) { - if( in.peek_char() == '\n' ) { - in.bump_to_next_line(); - p.first = true; - } - } - return p; + template< typename Input > + [[nodiscard]] static eol_pair match( Input& in ) noexcept( noexcept( in.size( 1 ) ) ) + { + eol_pair p = { false, in.size( 1 ) }; + if( p.second ) { + if( in.peek_char() == '\n' ) { + in.bump_to_next_line(); + p.first = true; } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE + } + return p; + } + }; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/list.hpp b/packages/PEGTL/include/tao/pegtl/internal/list.hpp index 7068d9cec..83d87de1f 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/list.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/list.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_LIST_HPP @@ -9,19 +9,11 @@ #include "seq.hpp" #include "star.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Rule, typename Sep > - using list = seq< Rule, star< Sep, Rule > >; + template< typename Rule, typename Sep > + using list = seq< Rule, star< Sep, Rule > >; - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/list_must.hpp b/packages/PEGTL/include/tao/pegtl/internal/list_must.hpp index c473f2daa..2c5a617cc 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_LIST_MUST_HPP @@ -10,19 +10,11 @@ #include "seq.hpp" #include "star.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Rule, typename Sep > - using list_must = seq< Rule, star< Sep, must< Rule > > >; + template< typename Rule, typename Sep > + using list_must = seq< Rule, star< Sep, must< Rule > > >; - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/list_tail.hpp b/packages/PEGTL/include/tao/pegtl/internal/list_tail.hpp index e651df80b..26b16c395 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/list_tail.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/list_tail.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_LIST_TAIL_HPP @@ -10,19 +10,11 @@ #include "opt.hpp" #include "seq.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Rule, typename Sep > - using list_tail = seq< list< Rule, Sep >, opt< Sep > >; + template< typename Rule, typename Sep > + using list_tail = seq< list< Rule, Sep >, opt< Sep > >; - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif 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 291bcadef..28f2f4394 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/list_tail_pad.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/list_tail_pad.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_LIST_TAIL_PAD_HPP @@ -12,19 +12,11 @@ #include "seq.hpp" #include "star.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Rule, typename Sep, typename Pad > - using list_tail_pad = seq< list< Rule, pad< Sep, Pad > >, opt< star< Pad >, Sep > >; + template< typename Rule, typename Sep, typename Pad > + using list_tail_pad = seq< list< Rule, pad< Sep, Pad > >, opt< star< Pad >, Sep > >; - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/marker.hpp b/packages/PEGTL/include/tao/pegtl/internal/marker.hpp index c11ad49be..2834be372 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/marker.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/marker.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_MARKER_HPP @@ -7,93 +7,76 @@ #include "../config.hpp" #include "../rewind_mode.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename Iterator, rewind_mode M > + class marker { - namespace internal + public: + static constexpr rewind_mode next_rewind_mode = M; + + explicit marker( const Iterator& /*unused*/ ) noexcept + { + } + + marker( const marker& ) = delete; + marker( marker&& ) = delete; + + ~marker() = default; + + void operator=( const marker& ) = delete; + void operator=( marker&& ) = delete; + + [[nodiscard]] bool operator()( const bool result ) const noexcept + { + return result; + } + }; + + template< typename Iterator > + class 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 ) { - template< typename Iterator, rewind_mode M > - class marker - { - public: - static constexpr rewind_mode next_rewind_mode = M; - - explicit marker( const Iterator& /*unused*/ ) noexcept - { - } - - marker( const marker& ) = delete; - - marker( marker&& /*unused*/ ) noexcept - { - } - - ~marker() = default; - - void operator=( const marker& ) = delete; - void operator=( marker&& ) = delete; - - bool operator()( const bool result ) const noexcept - { - return result; - } - }; - - template< typename Iterator > - class 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&& i ) noexcept - : m_saved( i.m_saved ), - m_input( i.m_input ) - { - i.m_input = nullptr; - } - - ~marker() noexcept - { - if( m_input != nullptr ) { - ( *m_input ) = m_saved; - } - } - - void operator=( const marker& ) = delete; - void operator=( marker&& ) = delete; - - bool operator()( const bool result ) noexcept - { - if( result ) { - m_input = nullptr; - return true; - } - return false; - } - - const Iterator& iterator() const noexcept - { - return m_saved; - } - - private: - const Iterator m_saved; - Iterator* m_input; - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + } + + marker( const marker& ) = delete; + marker( marker&& ) = delete; + + ~marker() noexcept + { + if( m_input != nullptr ) { + ( *m_input ) = m_saved; + } + } + + void operator=( const marker& ) = delete; + void 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 deleted file mode 100644 index 9481c827b..000000000 --- a/packages/PEGTL/include/tao/pegtl/internal/minus.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 2016-2018 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_MINUS_HPP -#define TAO_PEGTL_INTERNAL_MINUS_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" - -#include "../apply_mode.hpp" -#include "../memory_input.hpp" -#include "../rewind_mode.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - inline const char* source_pointer( const char* source ) noexcept - { - return source; - } - - inline const char* source_pointer( const std::string& source ) noexcept - { - return source.c_str(); - } - - template< typename R, typename S > - struct minus - { - using analyze_t = typename R::analyze_t; // NOTE: S is currently ignored for analyze(). - - template< apply_mode A, - rewind_mode, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - auto m = in.template mark< rewind_mode::REQUIRED >(); - - if( !Control< R >::template match< A, rewind_mode::ACTIVE, Action, Control >( in, st... ) ) { - return false; - } - memory_input< tracking_mode::LAZY, typename Input::eol_t, const char* > i2( m.iterator(), in.current(), source_pointer( in.source() ) ); - - if( !Control< S >::template match< apply_mode::NOTHING, rewind_mode::ACTIVE, Action, Control >( i2, st... ) ) { - return m( true ); - } - return m( !i2.empty() ); - } - }; - - template< typename R, typename S > - struct skip_control< minus< R, S > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/missing_apply.hpp b/packages/PEGTL/include/tao/pegtl/internal/missing_apply.hpp new file mode 100644 index 000000000..c4e33d16e --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/internal/missing_apply.hpp @@ -0,0 +1,25 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_MISSING_APPLY_HPP +#define TAO_PEGTL_INTERNAL_MISSING_APPLY_HPP + +#include "../config.hpp" +#include "../rewind_mode.hpp" + +namespace TAO_PEGTL_NAMESPACE::internal +{ + template< typename Control, + template< typename... > + class Action, + typename Input, + typename... States > + void missing_apply( Input& in, States&&... st ) + { + auto m = in.template mark< rewind_mode::required >(); + (void)Control::template apply< Action >( m.iterator(), in, st... ); + } + +} // namespace TAO_PEGTL_NAMESPACE::internal + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/missing_apply0.hpp b/packages/PEGTL/include/tao/pegtl/internal/missing_apply0.hpp new file mode 100644 index 000000000..db58f5d6f --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/internal/missing_apply0.hpp @@ -0,0 +1,23 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_MISSING_APPLY0_HPP +#define TAO_PEGTL_INTERNAL_MISSING_APPLY0_HPP + +#include "../config.hpp" + +namespace TAO_PEGTL_NAMESPACE::internal +{ + template< typename Control, + template< typename... > + class Action, + typename Input, + typename... States > + void missing_apply0( Input& in, States&&... st ) + { + (void)Control::template apply0< Action >( in, st... ); + } + +} // 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 9f37243ef..f4e090216 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_MUST_HPP @@ -7,7 +7,6 @@ #include "../config.hpp" #include "raise.hpp" -#include "rule_conjunction.hpp" #include "skip_control.hpp" #include "../apply_mode.hpp" @@ -15,65 +14,59 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + // The general case applies must<> to each of the + // rules in the 'Rules' parameter pack individually. + + template< typename... Rules > + struct must { - namespace internal + using analyze_t = analysis::generic< analysis::rule_type::seq, Rules... >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) { - // The general case applies must<> to each of the - // rules in the 'Rules' parameter pack individually. - - template< typename... Rules > - struct must - { - using analyze_t = analysis::generic< analysis::rule_type::SEQ, Rules... >; - - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return rule_conjunction< must< Rules >... >::template match< A, M, Action, Control >( in, st... ); - } - }; - - // While in theory the implementation for a single rule could - // be simplified to must< Rule > = sor< Rule, raise< Rule > >, this - // would result in some unnecessary run-time overhead. + return ( Control< must< Rules > >::template match< A, M, Action, Control >( in, st... ) && ... ); + } + }; - template< typename Rule > - struct must< Rule > - { - using analyze_t = typename Rule::analyze_t; + // While in theory the implementation for a single rule could + // be simplified to must< Rule > = sor< Rule, raise< Rule > >, this + // would result in some unnecessary run-time overhead. - template< apply_mode A, - rewind_mode, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - if( !Control< Rule >::template match< A, rewind_mode::DONTCARE, Action, Control >( in, st... ) ) { - raise< Rule >::template match< A, rewind_mode::DONTCARE, Action, Control >( in, st... ); - } - return true; - } - }; - - template< typename... Rules > - struct skip_control< must< Rules... > > : std::true_type - { - }; - - } // namespace internal + template< typename Rule > + struct must< Rule > + { + using analyze_t = typename Rule::analyze_t; + + template< apply_mode A, + rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + if( !Control< Rule >::template match< A, rewind_mode::dontcare, Action, Control >( in, st... ) ) { + (void)raise< Rule >::template match< A, rewind_mode::dontcare, Action, Control >( in, st... ); + } + return true; + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template< typename... Rules > + inline constexpr bool skip_control< must< Rules... > > = true; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/not_at.hpp b/packages/PEGTL/include/tao/pegtl/internal/not_at.hpp index d47932079..0ab7fcf84 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/not_at.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/not_at.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_NOT_AT_HPP @@ -6,7 +6,6 @@ #include "../config.hpp" -#include "rule_conjunction.hpp" #include "skip_control.hpp" #include "trivial.hpp" @@ -15,48 +14,40 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename... Rules > + struct not_at; + + template<> + struct not_at<> + : trivial< false > + { + }; + + template< typename... Rules > + struct not_at { - namespace internal + using analyze_t = analysis::generic< analysis::rule_type::opt, Rules... >; + + template< apply_mode, + rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) { - template< typename... Rules > - struct not_at; - - template<> - struct not_at<> - : trivial< false > - { - }; - - template< typename... Rules > - struct not_at - { - using analyze_t = analysis::generic< analysis::rule_type::OPT, Rules... >; - - template< apply_mode, - rewind_mode, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - const auto m = in.template mark< rewind_mode::REQUIRED >(); - return !rule_conjunction< Rules... >::template match< apply_mode::NOTHING, rewind_mode::ACTIVE, Action, Control >( in, st... ); - } - }; - - template< typename... Rules > - struct skip_control< not_at< Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + const auto m = in.template mark< rewind_mode::required >(); + return !( Control< Rules >::template match< apply_mode::nothing, rewind_mode::active, Action, Control >( in, st... ) && ... ); + } + }; + + template< typename... Rules > + inline constexpr bool skip_control< not_at< Rules... > > = true; + +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/one.hpp b/packages/PEGTL/include/tao/pegtl/internal/one.hpp index 8d29d5118..451140d03 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_ONE_HPP @@ -15,67 +15,57 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename Char > + [[nodiscard]] bool contains( const Char c, const std::initializer_list< Char >& l ) noexcept { - namespace internal - { - template< typename Char > - bool contains( const Char c, const std::initializer_list< Char >& l ) noexcept - { - return std::find( l.begin(), l.end(), c ) != l.end(); - } + return std::find( l.begin(), l.end(), c ) != l.end(); + } - template< result_on_found R, typename Peek, typename Peek::data_t... Cs > - struct one - { - using analyze_t = analysis::generic< analysis::rule_type::ANY >; + template< result_on_found R, typename Peek, typename Peek::data_t... Cs > + struct one + { + using analyze_t = analysis::generic< analysis::rule_type::any >; - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( in.empty() ) ) - { - if( !in.empty() ) { - if( const auto t = Peek::peek( in ) ) { - if( contains( t.data, { Cs... } ) == bool( R ) ) { - bump_help< R, Input, typename Peek::data_t, Cs... >( in, t.size ); - return true; - } - } + template< typename Input > + [[nodiscard]] static bool match( Input& in ) noexcept( noexcept( in.size( Peek::max_input_size ) ) ) + { + if( const std::size_t s = in.size( Peek::max_input_size ); s >= Peek::min_input_size ) { + if( const auto t = Peek::peek( in, s ) ) { + if( contains( t.data, { Cs... } ) == bool( R ) ) { + bump_help< R, Input, typename Peek::data_t, Cs... >( in, t.size ); + return true; } - return false; } - }; + } + return false; + } + }; - template< result_on_found R, typename Peek, typename Peek::data_t C > - struct one< R, Peek, C > - { - using analyze_t = analysis::generic< analysis::rule_type::ANY >; + template< result_on_found R, typename Peek, typename Peek::data_t C > + struct one< R, Peek, C > + { + using analyze_t = analysis::generic< analysis::rule_type::any >; - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( in.empty() ) ) - { - if( !in.empty() ) { - if( const auto t = Peek::peek( in ) ) { - if( ( t.data == C ) == bool( R ) ) { - bump_help< R, Input, typename Peek::data_t, C >( in, t.size ); - return true; - } - } + template< typename Input > + [[nodiscard]] static bool match( Input& in ) noexcept( noexcept( in.size( Peek::max_input_size ) ) ) + { + if( const std::size_t s = in.size( Peek::max_input_size ); s >= Peek::min_input_size ) { + if( const auto t = Peek::peek( in, s ) ) { + if( ( t.data == C ) == bool( R ) ) { + bump_help< R, Input, typename Peek::data_t, C >( in, t.size ); + return true; } - return false; } - }; - - template< result_on_found R, typename Peek, typename Peek::data_t... Cs > - struct skip_control< one< R, Peek, Cs... > > : std::true_type - { - }; - - } // namespace internal + } + return false; + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template< result_on_found R, typename Peek, typename Peek::data_t... Cs > + inline constexpr bool skip_control< one< R, Peek, Cs... > > = true; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/opt.hpp b/packages/PEGTL/include/tao/pegtl/internal/opt.hpp index f27046a47..df6da2d22 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/opt.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/opt.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_OPT_HPP @@ -18,48 +18,40 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename... Rules > - struct opt; - - template<> - struct opt<> - : trivial< true > - { - }; - - template< typename... Rules > - struct opt - { - using analyze_t = analysis::generic< analysis::rule_type::OPT, Rules... >; + template< typename... Rules > + struct opt; - template< apply_mode A, - rewind_mode, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - duseltronik< seq< Rules... >, A, rewind_mode::REQUIRED, Action, Control >::match( in, st... ); - return true; - } - }; - - template< typename... Rules > - struct skip_control< opt< Rules... > > : std::true_type - { - }; + template<> + struct opt<> + : trivial< true > + { + }; - } // namespace internal + template< typename... Rules > + struct opt + { + using analyze_t = analysis::generic< analysis::rule_type::opt, Rules... >; + + template< apply_mode A, + rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + (void)duseltronik< seq< Rules... >, A, rewind_mode::required, Action, Control >::match( in, st... ); + return true; + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template< typename... Rules > + inline constexpr bool skip_control< opt< Rules... > > = true; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/pad.hpp b/packages/PEGTL/include/tao/pegtl/internal/pad.hpp index 8aa586d54..db23e38a4 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/pad.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/pad.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_PAD_HPP @@ -9,19 +9,11 @@ #include "seq.hpp" #include "star.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Rule, typename Pad1, typename Pad2 = Pad1 > - using pad = seq< star< Pad1 >, Rule, star< Pad2 > >; + template< typename Rule, typename Pad1, typename Pad2 = Pad1 > + using pad = seq< star< Pad1 >, Rule, star< Pad2 > >; - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // 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 bdd0f6693..2a14a5354 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/pad_opt.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/pad_opt.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_PAD_OPT_HPP @@ -10,19 +10,11 @@ #include "seq.hpp" #include "star.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Rule, typename Pad > - using pad_opt = seq< star< Pad >, opt< Rule, star< Pad > > >; + template< typename Rule, typename Pad > + using pad_opt = seq< star< Pad >, opt< Rule, star< Pad > > >; - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/peek_char.hpp b/packages/PEGTL/include/tao/pegtl/internal/peek_char.hpp index f7eaf907e..8383698d4 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_PEEK_CHAR_HPP @@ -10,28 +10,23 @@ #include "input_pair.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + struct peek_char { - namespace internal - { - struct peek_char - { - using data_t = char; - using pair_t = input_pair< char >; - - template< typename Input > - static pair_t peek( Input& in, const std::size_t o = 0 ) noexcept( noexcept( in.Input::peek_char( 0 ) ) ) - { - return { in.peek_char( o ), 1 }; - } - }; + using data_t = char; + using pair_t = input_pair< char >; - } // namespace internal + static constexpr std::size_t min_input_size = 1; + static constexpr std::size_t max_input_size = 1; - } // namespace TAO_PEGTL_NAMESPACE + template< typename Input > + [[nodiscard]] static pair_t peek( const Input& in, const std::size_t /*unused*/ = 1 ) noexcept + { + return { in.peek_char(), 1 }; + } + }; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/peek_mask_uint.hpp b/packages/PEGTL/include/tao/pegtl/internal/peek_mask_uint.hpp index b5709d6a7..d99addf78 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/peek_mask_uint.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/peek_mask_uint.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_PEEK_MASK_UINT_HPP @@ -12,52 +12,43 @@ #include "input_pair.hpp" #include "read_uint.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename R, typename R::type M > + struct peek_mask_uint_impl { - namespace internal - { - template< typename R, typename R::type M > - struct peek_mask_uint_impl - { - using data_t = typename R::type; - using pair_t = input_pair< data_t >; - - template< typename Input > - static pair_t peek( Input& in ) noexcept( noexcept( in.size( sizeof( data_t ) ) ) ) - { - const std::size_t s = in.size( sizeof( data_t ) ); - if( s >= sizeof( data_t ) ) { - const data_t data = R::read( in.current() ) & M; - return { data, sizeof( data_t ) }; - } - return { 0, 0 }; - } - }; + using data_t = typename R::type; + using pair_t = input_pair< data_t >; - template< std::uint16_t M > - using peek_mask_uint16_be = peek_mask_uint_impl< read_uint16_be, M >; + static constexpr std::size_t min_input_size = sizeof( data_t ); + static constexpr std::size_t max_input_size = sizeof( data_t ); - template< std::uint16_t M > - using peek_mask_uint16_le = peek_mask_uint_impl< read_uint16_le, M >; + template< typename Input > + [[nodiscard]] static pair_t peek( const Input& in, const std::size_t /*unused*/ ) noexcept + { + const data_t data = R::read( in.current() ) & M; + return { data, sizeof( data_t ) }; + } + }; - template< std::uint32_t M > - using peek_mask_uint32_be = peek_mask_uint_impl< read_uint32_be, M >; + template< std::uint16_t M > + using peek_mask_uint16_be = peek_mask_uint_impl< read_uint16_be, M >; - template< std::uint32_t M > - using peek_mask_uint32_le = peek_mask_uint_impl< read_uint32_le, M >; + template< std::uint16_t M > + using peek_mask_uint16_le = peek_mask_uint_impl< read_uint16_le, M >; - template< std::uint64_t M > - using peek_mask_uint64_be = peek_mask_uint_impl< read_uint64_be, M >; + template< std::uint32_t M > + using peek_mask_uint32_be = peek_mask_uint_impl< read_uint32_be, M >; - template< std::uint64_t M > - using peek_mask_uint64_le = peek_mask_uint_impl< read_uint64_le, M >; + template< std::uint32_t M > + using peek_mask_uint32_le = peek_mask_uint_impl< read_uint32_le, M >; - } // namespace internal + template< std::uint64_t M > + using peek_mask_uint64_be = peek_mask_uint_impl< read_uint64_be, M >; - } // namespace TAO_PEGTL_NAMESPACE + template< std::uint64_t M > + using peek_mask_uint64_le = peek_mask_uint_impl< read_uint64_le, M >; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/peek_mask_uint8.hpp b/packages/PEGTL/include/tao/pegtl/internal/peek_mask_uint8.hpp index 8711918e7..ef50097e4 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/peek_mask_uint8.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/peek_mask_uint8.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_PEEK_MASK_UINT8_HPP @@ -11,29 +11,24 @@ #include "input_pair.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< std::uint8_t M > + struct peek_mask_uint8 { - namespace internal - { - template< std::uint8_t M > - struct peek_mask_uint8 - { - using data_t = std::uint8_t; - using pair_t = input_pair< std::uint8_t >; - - template< typename Input > - static pair_t peek( Input& in, const std::size_t o = 0 ) noexcept( noexcept( in.peek_byte( 0 ) ) ) - { - return { std::uint8_t( in.peek_byte( o ) & M ), 1 }; - } - }; + using data_t = std::uint8_t; + using pair_t = input_pair< std::uint8_t >; - } // namespace internal + static constexpr std::size_t min_input_size = 1; + static constexpr std::size_t max_input_size = 1; - } // namespace TAO_PEGTL_NAMESPACE + template< typename Input > + [[nodiscard]] static pair_t peek( const Input& in, const std::size_t /*unused*/ = 1 ) noexcept + { + return { std::uint8_t( in.peek_uint8() & M ), 1 }; + } + }; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/peek_uint.hpp b/packages/PEGTL/include/tao/pegtl/internal/peek_uint.hpp index 4a0fd8901..83b3eaad5 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/peek_uint.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/peek_uint.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_PEEK_UINT_HPP @@ -12,43 +12,34 @@ #include "input_pair.hpp" #include "read_uint.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename R > + struct peek_uint_impl { - namespace internal + using data_t = typename R::type; + using pair_t = input_pair< data_t >; + + static constexpr std::size_t min_input_size = sizeof( data_t ); + static constexpr std::size_t max_input_size = sizeof( data_t ); + + template< typename Input > + [[nodiscard]] static pair_t peek( const Input& in, const std::size_t /*unused*/ ) noexcept { - template< typename R > - struct peek_uint_impl - { - using data_t = typename R::type; - using pair_t = input_pair< data_t >; - - template< typename Input > - static pair_t peek( Input& in ) noexcept( noexcept( in.size( sizeof( data_t ) ) ) ) - { - const std::size_t s = in.size( sizeof( data_t ) ); - if( s >= sizeof( data_t ) ) { - const data_t data = R::read( in.current() ); - return { data, sizeof( data_t ) }; - } - return { 0, 0 }; - } - }; - - using peek_uint16_be = peek_uint_impl< read_uint16_be >; - using peek_uint16_le = peek_uint_impl< read_uint16_le >; - - using peek_uint32_be = peek_uint_impl< read_uint32_be >; - using peek_uint32_le = peek_uint_impl< read_uint32_le >; - - using peek_uint64_be = peek_uint_impl< read_uint64_be >; - using peek_uint64_le = peek_uint_impl< read_uint64_le >; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + const data_t data = R::read( in.current() ); + return { data, sizeof( data_t ) }; + } + }; + + using peek_uint16_be = peek_uint_impl< read_uint16_be >; + using peek_uint16_le = peek_uint_impl< read_uint16_le >; + + using peek_uint32_be = peek_uint_impl< read_uint32_be >; + using peek_uint32_le = peek_uint_impl< read_uint32_le >; + + using peek_uint64_be = peek_uint_impl< read_uint64_be >; + using peek_uint64_le = peek_uint_impl< read_uint64_le >; + +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/peek_uint8.hpp b/packages/PEGTL/include/tao/pegtl/internal/peek_uint8.hpp index aebe1b22e..d5f78af62 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/peek_uint8.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/peek_uint8.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_PEEK_UINT8_HPP @@ -11,28 +11,23 @@ #include "input_pair.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + struct peek_uint8 { - namespace internal - { - struct peek_uint8 - { - using data_t = std::uint8_t; - using pair_t = input_pair< std::uint8_t >; - - template< typename Input > - static pair_t peek( Input& in, const std::size_t o = 0 ) noexcept( noexcept( in.peek_byte( 0 ) ) ) - { - return { in.peek_byte( o ), 1 }; - } - }; + using data_t = std::uint8_t; + using pair_t = input_pair< std::uint8_t >; - } // namespace internal + static constexpr std::size_t min_input_size = 1; + static constexpr std::size_t max_input_size = 1; - } // namespace TAO_PEGTL_NAMESPACE + template< typename Input > + [[nodiscard]] static pair_t peek( const Input& in, const std::size_t /*unused*/ = 1 ) noexcept + { + return { in.peek_uint8(), 1 }; + } + }; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/peek_utf16.hpp b/packages/PEGTL/include/tao/pegtl/internal/peek_utf16.hpp index 8d88e42e0..4552c64f6 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/peek_utf16.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/peek_utf16.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_PEEK_UTF16_HPP @@ -11,53 +11,44 @@ #include "input_pair.hpp" #include "read_uint.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename R > + struct peek_utf16_impl { - namespace internal + using data_t = char32_t; + using pair_t = input_pair< char32_t >; + + using short_t = std::make_unsigned< char16_t >::type; + + static_assert( sizeof( short_t ) == 2 ); + static_assert( sizeof( char16_t ) == 2 ); + + static constexpr std::size_t min_input_size = 2; + static constexpr std::size_t max_input_size = 4; + + template< typename Input > + [[nodiscard]] static pair_t peek( const Input& in, const std::size_t s ) noexcept { - template< typename R > - struct peek_utf16_impl - { - using data_t = char32_t; - using pair_t = input_pair< char32_t >; - - using short_t = std::make_unsigned< char16_t >::type; - - static_assert( sizeof( short_t ) == 2, "expected size 2 for 16bit value" ); - static_assert( sizeof( char16_t ) == 2, "expected size 2 for 16bit value" ); - - template< typename Input > - static pair_t peek( Input& in ) noexcept( noexcept( in.size( 4 ) ) ) - { - const std::size_t s = in.size( 4 ); - if( s < 2 ) { - return { 0, 0 }; - } - const char32_t t = R::read( in.current() ); - if( ( t < 0xd800 ) || ( t > 0xdfff ) ) { - return { t, 2 }; - } - if( ( t >= 0xdc00 ) || ( s < 4 ) ) { - return { 0, 0 }; - } - const char32_t u = R::read( in.current() + 2 ); - if( ( u >= 0xdc00 ) && ( u <= 0xdfff ) ) { - const auto cp = ( ( ( t & 0x03ff ) << 10 ) | ( u & 0x03ff ) ) + 0x10000; - return { cp, 4 }; - } - return { 0, 0 }; - } - }; - - using peek_utf16_be = peek_utf16_impl< read_uint16_be >; - using peek_utf16_le = peek_utf16_impl< read_uint16_le >; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + const char32_t t = R::read( in.current() ); + if( ( t < 0xd800 ) || ( t > 0xdfff ) ) { + return { t, 2 }; + } + if( ( t >= 0xdc00 ) || ( s < 4 ) ) { + return { 0, 0 }; + } + const char32_t u = R::read( in.current() + 2 ); + if( ( u >= 0xdc00 ) && ( u <= 0xdfff ) ) { + const auto cp = ( ( ( t & 0x03ff ) << 10 ) | ( u & 0x03ff ) ) + 0x10000; + return { cp, 4 }; + } + return { 0, 0 }; + } + }; + + using peek_utf16_be = peek_utf16_impl< read_uint16_be >; + using peek_utf16_le = peek_utf16_impl< read_uint16_le >; + +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/peek_utf32.hpp b/packages/PEGTL/include/tao/pegtl/internal/peek_utf32.hpp index 7d720b125..293d38fba 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/peek_utf32.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/peek_utf32.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_PEEK_UTF32_HPP @@ -11,41 +11,33 @@ #include "input_pair.hpp" #include "read_uint.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename R > + struct peek_utf32_impl { - namespace internal + using data_t = char32_t; + using pair_t = input_pair< char32_t >; + + static_assert( sizeof( char32_t ) == 4 ); + + static constexpr std::size_t min_input_size = 4; + static constexpr std::size_t max_input_size = 4; + + template< typename Input > + [[nodiscard]] static pair_t peek( const Input& in, const std::size_t /*unused*/ ) noexcept { - template< typename R > - struct peek_utf32_impl - { - using data_t = char32_t; - using pair_t = input_pair< char32_t >; - - static_assert( sizeof( char32_t ) == 4, "expected size 4 for 32bit value" ); - - template< typename Input > - static pair_t peek( Input& in ) noexcept( noexcept( in.size( 4 ) ) ) - { - const std::size_t s = in.size( 4 ); - if( s >= 4 ) { - const char32_t t = R::read( in.current() ); - if( ( 0 <= t ) && ( t <= 0x10ffff ) && !( t >= 0xd800 && t <= 0xdfff ) ) { - return { t, 4 }; - } - } - return { 0, 0 }; - } - }; - - using peek_utf32_be = peek_utf32_impl< read_uint32_be >; - using peek_utf32_le = peek_utf32_impl< read_uint32_le >; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + const char32_t t = R::read( in.current() ); + if( ( 0 <= t ) && ( t <= 0x10ffff ) && !( t >= 0xd800 && t <= 0xdfff ) ) { + return { t, 4 }; + } + return { 0, 0 }; + } + }; + + using peek_utf32_be = peek_utf32_impl< read_uint32_be >; + using peek_utf32_le = peek_utf32_impl< read_uint32_le >; + +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/peek_utf8.hpp b/packages/PEGTL/include/tao/pegtl/internal/peek_utf8.hpp index 2b11f7533..aa8a617b7 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/peek_utf8.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/peek_utf8.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_PEEK_UTF8_HPP @@ -8,81 +8,83 @@ #include "input_pair.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + struct peek_utf8 { - namespace internal + using data_t = char32_t; + using pair_t = input_pair< char32_t >; + + static constexpr std::size_t min_input_size = 1; + static constexpr std::size_t max_input_size = 4; + + template< typename Input > + [[nodiscard]] static pair_t peek( const Input& in, const std::size_t s ) noexcept { - struct peek_utf8 - { - using data_t = char32_t; - using pair_t = input_pair< char32_t >; + char32_t c0 = in.peek_uint8(); - template< typename Input > - static pair_t peek( Input& in ) noexcept( noexcept( in.size( 4 ) ) ) - { - char32_t c0 = in.peek_byte(); + if( ( c0 & 0x80 ) == 0 ) { + return { c0, 1 }; + } + return peek_impl( in, c0, s ); + } - if( ( c0 & 0x80 ) == 0 ) { - return { c0, 1 }; - } - if( ( c0 & 0xE0 ) == 0xC0 ) { - if( in.size( 2 ) >= 2 ) { - const char32_t c1 = in.peek_byte( 1 ); - if( ( c1 & 0xC0 ) == 0x80 ) { - c0 &= 0x1F; - c0 <<= 6; - c0 |= ( c1 & 0x3F ); - if( c0 >= 0x80 ) { - return { c0, 2 }; - } - } + private: + template< typename Input > + [[nodiscard]] static pair_t peek_impl( const Input& in, char32_t c0, const std::size_t s ) noexcept + { + if( ( c0 & 0xE0 ) == 0xC0 ) { + if( s >= 2 ) { + const char32_t c1 = in.peek_uint8( 1 ); + if( ( c1 & 0xC0 ) == 0x80 ) { + c0 &= 0x1F; + c0 <<= 6; + c0 |= ( c1 & 0x3F ); + if( c0 >= 0x80 ) { + return { c0, 2 }; } } - else if( ( c0 & 0xF0 ) == 0xE0 ) { - if( in.size( 3 ) >= 3 ) { - const char32_t c1 = in.peek_byte( 1 ); - const char32_t c2 = in.peek_byte( 2 ); - if( ( ( c1 & 0xC0 ) == 0x80 ) && ( ( c2 & 0xC0 ) == 0x80 ) ) { - c0 &= 0x0F; - c0 <<= 6; - c0 |= ( c1 & 0x3F ); - c0 <<= 6; - c0 |= ( c2 & 0x3F ); - if( c0 >= 0x800 && !( c0 >= 0xD800 && c0 <= 0xDFFF ) ) { - return { c0, 3 }; - } - } + } + } + else if( ( c0 & 0xF0 ) == 0xE0 ) { + if( s >= 3 ) { + const char32_t c1 = in.peek_uint8( 1 ); + const char32_t c2 = in.peek_uint8( 2 ); + if( ( ( c1 & 0xC0 ) == 0x80 ) && ( ( c2 & 0xC0 ) == 0x80 ) ) { + c0 &= 0x0F; + c0 <<= 6; + c0 |= ( c1 & 0x3F ); + c0 <<= 6; + c0 |= ( c2 & 0x3F ); + if( c0 >= 0x800 && !( c0 >= 0xD800 && c0 <= 0xDFFF ) ) { + return { c0, 3 }; } } - else if( ( c0 & 0xF8 ) == 0xF0 ) { - if( in.size( 4 ) >= 4 ) { - const char32_t c1 = in.peek_byte( 1 ); - const char32_t c2 = in.peek_byte( 2 ); - const char32_t c3 = in.peek_byte( 3 ); - if( ( ( c1 & 0xC0 ) == 0x80 ) && ( ( c2 & 0xC0 ) == 0x80 ) && ( ( c3 & 0xC0 ) == 0x80 ) ) { - c0 &= 0x07; - c0 <<= 6; - c0 |= ( c1 & 0x3F ); - c0 <<= 6; - c0 |= ( c2 & 0x3F ); - c0 <<= 6; - c0 |= ( c3 & 0x3F ); - if( c0 >= 0x10000 && c0 <= 0x10FFFF ) { - return { c0, 4 }; - } - } + } + } + else if( ( c0 & 0xF8 ) == 0xF0 ) { + if( s >= 4 ) { + const char32_t c1 = in.peek_uint8( 1 ); + const char32_t c2 = in.peek_uint8( 2 ); + const char32_t c3 = in.peek_uint8( 3 ); + if( ( ( c1 & 0xC0 ) == 0x80 ) && ( ( c2 & 0xC0 ) == 0x80 ) && ( ( c3 & 0xC0 ) == 0x80 ) ) { + c0 &= 0x07; + c0 <<= 6; + c0 |= ( c1 & 0x3F ); + c0 <<= 6; + c0 |= ( c2 & 0x3F ); + c0 <<= 6; + c0 |= ( c3 & 0x3F ); + if( c0 >= 0x10000 && c0 <= 0x10FFFF ) { + return { c0, 4 }; } } - return { 0, 0 }; } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE + } + return { 0, 0 }; + } + }; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/pegtl_string.hpp b/packages/PEGTL/include/tao/pegtl/internal/pegtl_string.hpp index 5928d7330..b523d66ca 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_PEGTL_STRING_HPP @@ -10,66 +10,58 @@ #include "../ascii.hpp" #include "../config.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + // Inspired by https://github.com/irrequietus/typestring + // Rewritten and reduced to what is needed for the PEGTL + // and to work with Visual Studio 2015. + + template< typename, typename, typename, typename, typename, typename, typename, typename > + struct string_join; + + template< template< char... > class S, char... C0s, char... C1s, char... C2s, char... C3s, char... C4s, char... C5s, char... C6s, char... C7s > + struct string_join< S< C0s... >, S< C1s... >, S< C2s... >, S< C3s... >, S< C4s... >, S< C5s... >, S< C6s... >, S< C7s... > > + { + using type = S< C0s..., C1s..., C2s..., C3s..., C4s..., C5s..., C6s..., C7s... >; + }; + + template< template< char... > class S, char, bool > + struct string_at + { + using type = S<>; + }; + + template< template< char... > class S, char C > + struct string_at< S, C, true > + { + using type = S< C >; + }; + + template< typename T, std::size_t S > + struct string_max_length { - // Inspired by https://github.com/irrequietus/typestring - // Rewritten and reduced to what is needed for the PEGTL - // and to work with Visual Studio 2015. - - namespace internal - { - template< typename, typename, typename, typename, typename, typename, typename, typename > - struct string_join; - - template< template< char... > class S, char... C0s, char... C1s, char... C2s, char... C3s, char... C4s, char... C5s, char... C6s, char... C7s > - struct string_join< S< C0s... >, S< C1s... >, S< C2s... >, S< C3s... >, S< C4s... >, S< C5s... >, S< C6s... >, S< C7s... > > - { - using type = S< C0s..., C1s..., C2s..., C3s..., C4s..., C5s..., C6s..., C7s... >; - }; - - template< template< char... > class S, char, bool > - struct string_at - { - using type = S<>; - }; - - template< template< char... > class S, char C > - struct string_at< S, C, true > - { - using type = S< C >; - }; - - template< typename T, std::size_t S > - struct string_max_length - { - static_assert( S <= 512, "String longer than 512 (excluding terminating \\0)!" ); - using type = T; - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + static_assert( S <= 512, "String longer than 512 (excluding terminating \\0)!" ); + using type = T; + }; + +} // namespace TAO_PEGTL_NAMESPACE::internal #define TAO_PEGTL_INTERNAL_EMPTY() #define TAO_PEGTL_INTERNAL_DEFER( X ) X TAO_PEGTL_INTERNAL_EMPTY() #define TAO_PEGTL_INTERNAL_EXPAND( ... ) __VA_ARGS__ #define TAO_PEGTL_INTERNAL_STRING_AT( S, x, n ) \ - tao::TAO_PEGTL_NAMESPACE::internal::string_at< S, ( 0##n < sizeof( x ) ) ? ( x )[ 0##n ] : 0, ( 0##n < sizeof( x ) - 1 ) >::type - -#define TAO_PEGTL_INTERNAL_JOIN_8( M, S, x, n ) \ - tao::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 ) ) ? ( x )[ 0##n ] : 0, ( 0##n < sizeof( x ) - 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 ) @@ -84,20 +76,15 @@ namespace tao TAO_PEGTL_INTERNAL_EXPAND( \ TAO_PEGTL_INTERNAL_EXPAND( \ TAO_PEGTL_INTERNAL_EXPAND( \ - tao::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::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::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::TAO_PEGTL_NAMESPACE::ascii::keyword, x ) - -// Compatibility, remove with 3.0 -#define TAOCPP_PEGTL_STRING( x ) TAO_PEGTL_STRING( x ) -#define TAOCPP_PEGTL_ISTRING( x ) TAO_PEGTL_ISTRING( x ) -#define TAOCPP_PEGTL_KEYWORD( x ) TAO_PEGTL_KEYWORD( x ) + TAO_PEGTL_INTERNAL_STRING( TAO_PEGTL_NAMESPACE::ascii::keyword, x ) #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/plus.hpp b/packages/PEGTL/include/tao/pegtl/internal/plus.hpp index 5ebd23bf1..815d2beab 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/plus.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/plus.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_PLUS_HPP @@ -19,43 +19,35 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + // While plus<> could easily be implemented with + // seq< Rule, Rules ..., star< Rule, Rules ... > > we + // provide an explicit implementation to optimise away + // the otherwise created input mark. + + template< typename Rule, typename... Rules > + struct plus { - namespace internal + using analyze_t = analysis::generic< analysis::rule_type::seq, Rule, Rules..., opt< plus > >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) { - // While plus<> could easily be implemented with - // seq< Rule, Rules ..., star< Rule, Rules ... > > we - // provide an explicit implementation to optimise away - // the otherwise created input mark. - - template< typename Rule, typename... Rules > - struct plus - { - using analyze_t = analysis::generic< analysis::rule_type::SEQ, Rule, Rules..., opt< plus > >; - - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return seq< Rule, Rules... >::template match< A, M, Action, Control >( in, st... ) && star< Rule, Rules... >::template match< A, M, Action, Control >( in, st... ); - } - }; - - template< typename Rule, typename... Rules > - struct skip_control< plus< Rule, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + return seq< Rule, Rules... >::template match< A, M, Action, Control >( in, st... ) && star< Rule, Rules... >::template match< A, M, Action, Control >( in, st... ); + } + }; + + template< typename Rule, typename... Rules > + inline constexpr bool skip_control< plus< Rule, Rules... > > = true; + +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/raise.hpp b/packages/PEGTL/include/tao/pegtl/internal/raise.hpp index 7a76dd2b8..356ffcbd7 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_RAISE_HPP @@ -16,46 +16,38 @@ #include "../apply_mode.hpp" #include "../rewind_mode.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename T > + struct raise { - namespace internal - { - template< typename T > - struct raise - { - using analyze_t = analysis::generic< analysis::rule_type::ANY >; + using analyze_t = analysis::generic< analysis::rule_type::any >; -#ifdef _MSC_VER +#if defined( _MSC_VER ) #pragma warning( push ) #pragma warning( disable : 4702 ) #endif - template< apply_mode, - rewind_mode, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - Control< T >::raise( static_cast< const Input& >( in ), st... ); - throw std::logic_error( "code should be unreachable: Control< T >::raise() did not throw an exception" ); // NOLINT, LCOV_EXCL_LINE -#ifdef _MSC_VER + template< apply_mode, + rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + Control< T >::raise( static_cast< const Input& >( in ), st... ); + throw std::logic_error( "code should be unreachable: Control< T >::raise() did not throw an exception" ); // NOLINT, LCOV_EXCL_LINE +#if defined( _MSC_VER ) #pragma warning( pop ) #endif - } - }; - - template< typename T > - struct skip_control< raise< T > > : std::true_type - { - }; - - } // namespace internal + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template< typename T > + inline constexpr bool skip_control< raise< T > > = true; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/range.hpp b/packages/PEGTL/include/tao/pegtl/internal/range.hpp index 3964463ec..2780377bb 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/range.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/range.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_RANGE_HPP @@ -6,55 +6,46 @@ #include "../config.hpp" -#include "bump_help.hpp" #include "result_on_found.hpp" #include "skip_control.hpp" #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< result_on_found R, typename Peek, typename Peek::data_t Lo, typename Peek::data_t Hi > + struct range { - namespace internal + static_assert( Lo <= Hi, "invalid range detected" ); + + using analyze_t = analysis::generic< analysis::rule_type::any >; + + template< int Eol > + static constexpr bool can_match_eol = ( ( ( Lo <= Eol ) && ( Eol <= Hi ) ) == bool( R ) ); + + template< typename Input > + [[nodiscard]] static bool match( Input& in ) noexcept( noexcept( in.size( Peek::max_input_size ) ) ) { - template< result_on_found R, typename Peek, typename Peek::data_t Lo, typename Peek::data_t Hi > - struct range - { - static_assert( Lo <= Hi, "invalid range detected" ); - - using analyze_t = analysis::generic< analysis::rule_type::ANY >; - - template< int Eol > - struct can_match_eol - { - static constexpr bool value = ( ( ( Lo <= Eol ) && ( Eol <= Hi ) ) == bool( R ) ); - }; - - template< typename Input > - static bool match( Input& in ) - { - if( !in.empty() ) { - if( const auto t = Peek::peek( in ) ) { - if( ( ( Lo <= t.data ) && ( t.data <= Hi ) ) == bool( R ) ) { - bump_impl< can_match_eol< Input::eol_t::ch >::value >::bump( in, t.size ); - return true; - } + if( const std::size_t s = in.size( Peek::max_input_size ); s >= Peek::min_input_size ) { + if( const auto t = Peek::peek( in, s ) ) { + if( ( ( Lo <= t.data ) && ( t.data <= Hi ) ) == bool( R ) ) { + if constexpr( can_match_eol< Input::eol_t::ch > ) { + in.bump( t.size ); } + else { + in.bump_in_this_line( t.size ); + } + return true; } - return false; } - }; - - template< result_on_found R, typename Peek, typename Peek::data_t Lo, typename Peek::data_t Hi > - struct skip_control< range< R, Peek, Lo, Hi > > : std::true_type - { - }; - - } // namespace internal + } + return false; + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template< result_on_found R, typename Peek, typename Peek::data_t Lo, typename Peek::data_t Hi > + inline constexpr bool skip_control< range< R, Peek, Lo, Hi > > = true; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/ranges.hpp b/packages/PEGTL/include/tao/pegtl/internal/ranges.hpp index d91f433dd..f815aceb6 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/ranges.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/ranges.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_RANGES_HPP @@ -6,97 +6,88 @@ #include "../config.hpp" -#include "bump_help.hpp" #include "range.hpp" #include "skip_control.hpp" #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< int Eol, typename Char, Char... Cs > + struct ranges_impl; + + template< int Eol, typename Char > + struct ranges_impl< Eol, Char > { - namespace internal + static constexpr bool can_match_eol = false; + + [[nodiscard]] static bool match( const Char /*unused*/ ) noexcept { - template< int Eol, typename Char, Char... Cs > - struct ranges_impl; + return false; + } + }; - template< int Eol, typename Char > - struct ranges_impl< Eol, Char > - { - static constexpr bool can_match_eol = false; + template< int Eol, typename Char, Char Eq > + struct ranges_impl< Eol, Char, Eq > + { + static constexpr bool can_match_eol = ( Eq == Eol ); - static bool match( const Char /*unused*/ ) noexcept - { - return false; - } - }; + [[nodiscard]] static bool match( const Char c ) noexcept + { + return c == Eq; + } + }; - template< int Eol, typename Char, Char Eq > - struct ranges_impl< Eol, Char, Eq > - { - static constexpr bool can_match_eol = ( Eq == Eol ); + template< int Eol, typename Char, Char Lo, Char Hi, Char... Cs > + struct ranges_impl< Eol, Char, Lo, Hi, Cs... > + { + static_assert( Lo <= Hi, "invalid range detected" ); - static bool match( const Char c ) noexcept - { - return c == Eq; - } - }; + static constexpr bool can_match_eol = ( ( ( Lo <= Eol ) && ( Eol <= Hi ) ) || ranges_impl< Eol, Char, Cs... >::can_match_eol ); - template< int Eol, typename Char, Char Lo, Char Hi, Char... Cs > - struct ranges_impl< Eol, Char, Lo, Hi, Cs... > - { - static_assert( Lo <= Hi, "invalid range detected" ); + [[nodiscard]] static bool match( const Char c ) noexcept + { + return ( ( Lo <= c ) && ( c <= Hi ) ) || ranges_impl< Eol, Char, Cs... >::match( c ); + } + }; - static constexpr bool can_match_eol = ( ( ( Lo <= Eol ) && ( Eol <= Hi ) ) || ranges_impl< Eol, Char, Cs... >::can_match_eol ); + template< typename Peek, typename Peek::data_t... Cs > + struct ranges + { + using analyze_t = analysis::generic< analysis::rule_type::any >; - static bool match( const Char c ) noexcept - { - return ( ( Lo <= c ) && ( c <= Hi ) ) || ranges_impl< Eol, Char, Cs... >::match( c ); - } - }; - - template< typename Peek, typename Peek::data_t... Cs > - struct ranges - { - using analyze_t = analysis::generic< analysis::rule_type::ANY >; - - template< int Eol > - struct can_match_eol - { - static constexpr bool value = ranges_impl< Eol, typename Peek::data_t, Cs... >::can_match_eol; - }; - - template< typename Input > - static bool match( Input& in ) - { - if( !in.empty() ) { - if( const auto t = Peek::peek( in ) ) { - if( ranges_impl< Input::eol_t::ch, typename Peek::data_t, Cs... >::match( t.data ) ) { - bump_impl< can_match_eol< Input::eol_t::ch >::value >::bump( in, t.size ); - return true; - } + template< int Eol > + static constexpr bool can_match_eol = ranges_impl< Eol, typename Peek::data_t, Cs... >::can_match_eol; + + template< typename Input > + [[nodiscard]] static bool match( Input& in ) noexcept( noexcept( in.size( Peek::max_input_size ) ) ) + { + if( const std::size_t s = in.size( Peek::max_input_size ); s >= Peek::min_input_size ) { + if( const auto t = Peek::peek( in, s ) ) { + if( ranges_impl< Input::eol_t::ch, typename Peek::data_t, Cs... >::match( t.data ) ) { + if constexpr( can_match_eol< Input::eol_t::ch > ) { + in.bump( t.size ); + } + else { + in.bump_in_this_line( t.size ); } + return true; } - return false; } - }; - - template< typename Peek, typename Peek::data_t Lo, typename Peek::data_t Hi > - struct ranges< Peek, Lo, Hi > - : range< result_on_found::SUCCESS, Peek, Lo, Hi > - { - }; - - template< typename Peek, typename Peek::data_t... Cs > - struct skip_control< ranges< Peek, Cs... > > : std::true_type - { - }; - - } // namespace internal + } + return false; + } + }; + + template< typename Peek, typename Peek::data_t Lo, typename Peek::data_t Hi > + struct ranges< Peek, Lo, Hi > + : range< result_on_found::success, Peek, Lo, Hi > + { + }; - } // namespace TAO_PEGTL_NAMESPACE + template< typename Peek, typename Peek::data_t... Cs > + inline constexpr bool skip_control< ranges< Peek, Cs... > > = true; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/read_uint.hpp b/packages/PEGTL/include/tao/pegtl/internal/read_uint.hpp index 6e9d3aeb6..96fbcc73d 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/read_uint.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/read_uint.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_READ_UINT_HPP @@ -10,76 +10,68 @@ #include "endian.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + struct read_uint16_be { - namespace internal + using type = std::uint16_t; + + [[nodiscard]] static std::uint16_t read( const void* d ) noexcept + { + return be_to_h< std::uint16_t >( d ); + } + }; + + struct read_uint16_le + { + using type = std::uint16_t; + + [[nodiscard]] static std::uint16_t read( const void* d ) noexcept + { + return le_to_h< std::uint16_t >( d ); + } + }; + + struct read_uint32_be + { + using type = std::uint32_t; + + [[nodiscard]] static std::uint32_t read( const void* d ) noexcept + { + return be_to_h< std::uint32_t >( d ); + } + }; + + struct read_uint32_le + { + using type = std::uint32_t; + + [[nodiscard]] static std::uint32_t read( const void* d ) noexcept + { + return le_to_h< std::uint32_t >( d ); + } + }; + + struct read_uint64_be + { + using type = std::uint64_t; + + [[nodiscard]] static std::uint64_t read( const void* d ) noexcept { - struct read_uint16_be - { - using type = std::uint16_t; - - static std::uint16_t read( const void* d ) noexcept - { - return be_to_h< std::uint16_t >( d ); - } - }; - - struct read_uint16_le - { - using type = std::uint16_t; - - static std::uint16_t read( const void* d ) noexcept - { - return le_to_h< std::uint16_t >( d ); - } - }; - - struct read_uint32_be - { - using type = std::uint32_t; - - static std::uint32_t read( const void* d ) noexcept - { - return be_to_h< std::uint32_t >( d ); - } - }; - - struct read_uint32_le - { - using type = std::uint32_t; - - static std::uint32_t read( const void* d ) noexcept - { - return le_to_h< std::uint32_t >( d ); - } - }; - - struct read_uint64_be - { - using type = std::uint64_t; - - static std::uint64_t read( const void* d ) noexcept - { - return be_to_h< std::uint64_t >( d ); - } - }; - - struct read_uint64_le - { - using type = std::uint64_t; - - static std::uint64_t read( const void* d ) noexcept - { - return le_to_h< std::uint64_t >( d ); - } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + return be_to_h< std::uint64_t >( d ); + } + }; + + struct read_uint64_le + { + using type = std::uint64_t; + + [[nodiscard]] static std::uint64_t read( const void* d ) noexcept + { + return le_to_h< std::uint64_t >( d ); + } + }; + +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/rematch.hpp b/packages/PEGTL/include/tao/pegtl/internal/rematch.hpp new file mode 100644 index 000000000..5d713266b --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/internal/rematch.hpp @@ -0,0 +1,69 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_INTERNAL_REMATCH_HPP +#define TAO_PEGTL_INTERNAL_REMATCH_HPP + +#include "../config.hpp" + +#include "skip_control.hpp" + +#include "../apply_mode.hpp" +#include "../memory_input.hpp" +#include "../rewind_mode.hpp" + +namespace TAO_PEGTL_NAMESPACE::internal +{ + template< typename Head, typename... Rules > + struct rematch; + + template< typename Head > + struct rematch< Head > + { + using analyze_t = typename Head::analyze_t; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + return Control< Head >::template match< A, M, Action, Control >( in, st... ); + } + }; + + template< typename Head, typename Rule, typename... Rules > + struct rematch< Head, Rule, Rules... > + { + using analyze_t = typename Head::analyze_t; // NOTE: Rule and Rules are ignored for analyze(). + + template< apply_mode A, + rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + auto m = in.template mark< rewind_mode::required >(); + + if( Control< Head >::template match< A, rewind_mode::active, Action, Control >( in, st... ) ) { + memory_input< Input::tracking_mode_v, typename Input::eol_t, typename Input::source_t > i2( m.iterator(), 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; + } + }; + + template< typename Head, typename... Rules > + inline constexpr bool skip_control< rematch< Head, Rules... > > = true; + +} // namespace TAO_PEGTL_NAMESPACE::internal + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/rep.hpp b/packages/PEGTL/include/tao/pegtl/internal/rep.hpp index 1e7e600da..782929da7 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/rep.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/rep.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_REP_HPP @@ -6,7 +6,6 @@ #include "../config.hpp" -#include "rule_conjunction.hpp" #include "skip_control.hpp" #include "trivial.hpp" @@ -15,61 +14,53 @@ #include "../analysis/counted.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< unsigned Num, typename... Rules > - struct rep; - - template< unsigned Num > - struct rep< Num > - : trivial< true > - { - }; + template< unsigned Num, typename... Rules > + struct rep; - template< typename Rule, typename... Rules > - struct rep< 0, Rule, Rules... > - : trivial< true > - { - }; + template< unsigned Num > + struct rep< Num > + : trivial< true > + { + }; - template< unsigned Num, typename... Rules > - struct rep - { - using analyze_t = analysis::counted< analysis::rule_type::SEQ, Num, Rules... >; + template< typename Rule, typename... Rules > + struct rep< 0, Rule, Rules... > + : trivial< true > + { + }; - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - auto m = in.template mark< M >(); - using m_t = decltype( m ); + template< unsigned Num, typename... Rules > + struct rep + { + using analyze_t = analysis::counted< analysis::rule_type::seq, Num, Rules... >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + auto m = in.template mark< M >(); + using m_t = decltype( m ); - for( unsigned i = 0; i != Num; ++i ) { - if( !rule_conjunction< Rules... >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ) { - return false; - } - } - return m( true ); + for( unsigned i = 0; i != Num; ++i ) { + if( !( Control< Rules >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) && ... ) ) { + return false; } - }; - - template< unsigned Num, typename... Rules > - struct skip_control< rep< Num, Rules... > > : std::true_type - { - }; - - } // namespace internal + } + return m( true ); + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template< unsigned Num, typename... Rules > + inline constexpr bool skip_control< rep< Num, Rules... > > = true; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/rep_min.hpp b/packages/PEGTL/include/tao/pegtl/internal/rep_min.hpp index f48b542a6..fe6f6a772 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/rep_min.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/rep_min.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_REP_MIN_HPP @@ -10,19 +10,11 @@ #include "seq.hpp" #include "star.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< unsigned Min, typename Rule, typename... Rules > - using rep_min = seq< rep< Min, Rule, Rules... >, star< Rule, Rules... > >; + template< unsigned Min, typename Rule, typename... Rules > + using rep_min = seq< rep< Min, Rule, Rules... >, star< Rule, Rules... > >; - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif 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 d50a47f35..6264dd175 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_REP_MIN_MAX_HPP @@ -10,7 +10,6 @@ #include "duseltronik.hpp" #include "not_at.hpp" -#include "rule_conjunction.hpp" #include "seq.hpp" #include "skip_control.hpp" #include "trivial.hpp" @@ -20,69 +19,61 @@ #include "../analysis/counted.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< unsigned Min, unsigned Max, typename... Rules > + struct rep_min_max; + + template< unsigned Min, unsigned Max > + struct rep_min_max< Min, Max > + : trivial< false > { - namespace internal - { - template< unsigned Min, unsigned Max, typename... Rules > - struct rep_min_max; - - template< unsigned Min, unsigned Max > - struct rep_min_max< Min, Max > - : trivial< false > - { - static_assert( Min <= Max, "invalid rep_min_max rule (maximum number of repetitions smaller than minimum)" ); - }; - - template< typename Rule, typename... Rules > - struct rep_min_max< 0, 0, Rule, Rules... > - : not_at< Rule, Rules... > - { - }; - - template< unsigned Min, unsigned Max, typename... Rules > - struct rep_min_max - { - using analyze_t = analysis::counted< analysis::rule_type::SEQ, Min, Rules... >; - - static_assert( Min <= Max, "invalid rep_min_max rule (maximum number of repetitions smaller than minimum)" ); - - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - auto m = in.template mark< M >(); - using m_t = decltype( m ); - - for( unsigned i = 0; i != Min; ++i ) { - if( !rule_conjunction< Rules... >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ) { - return false; - } - } - for( unsigned i = Min; i != Max; ++i ) { - if( !duseltronik< seq< Rules... >, A, rewind_mode::REQUIRED, Action, Control >::match( in, st... ) ) { - return m( true ); - } - } - return m( duseltronik< not_at< Rules... >, A, m_t::next_rewind_mode, Action, Control >::match( in, st... ) ); // NOTE that not_at<> will always rewind. - } - }; + static_assert( Min <= Max ); + }; - template< unsigned Min, unsigned Max, typename... Rules > - struct skip_control< rep_min_max< Min, Max, Rules... > > : std::true_type - { - }; + template< typename Rule, typename... Rules > + struct rep_min_max< 0, 0, Rule, Rules... > + : not_at< Rule, Rules... > + { + }; - } // namespace internal + template< unsigned Min, unsigned Max, typename... Rules > + struct rep_min_max + { + using analyze_t = analysis::counted< analysis::rule_type::seq, Min, Rules... >; + + static_assert( Min <= Max ); + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + auto m = in.template mark< M >(); + using m_t = decltype( m ); + + for( unsigned i = 0; i != Min; ++i ) { + if( !( Control< Rules >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) && ... ) ) { + return false; + } + } + for( unsigned i = Min; i != Max; ++i ) { + if( !duseltronik< seq< Rules... >, A, rewind_mode::required, Action, Control >::match( in, st... ) ) { + return m( true ); + } + } + return m( duseltronik< not_at< Rules... >, A, m_t::next_rewind_mode, Action, Control >::match( in, st... ) ); // NOTE that not_at<> will always rewind. + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template< unsigned Min, unsigned Max, typename... Rules > + inline constexpr bool skip_control< rep_min_max< Min, Max, Rules... > > = true; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/rep_opt.hpp b/packages/PEGTL/include/tao/pegtl/internal/rep_opt.hpp index 3553f8967..4df310d24 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/rep_opt.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/rep_opt.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_REP_OPT_HPP @@ -15,40 +15,32 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< unsigned Max, typename... Rules > + struct rep_opt { - namespace internal + using analyze_t = analysis::generic< analysis::rule_type::opt, Rules... >; + + template< apply_mode A, + rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) { - template< unsigned Max, typename... Rules > - struct rep_opt - { - using analyze_t = analysis::generic< analysis::rule_type::OPT, Rules... >; - - template< apply_mode A, - rewind_mode, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - for( unsigned i = 0; ( i != Max ) && duseltronik< seq< Rules... >, A, rewind_mode::REQUIRED, Action, Control >::match( in, st... ); ++i ) { - } - return true; - } - }; - - template< unsigned Max, typename... Rules > - struct skip_control< rep_opt< Max, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + for( unsigned i = 0; ( i != Max ) && duseltronik< seq< Rules... >, A, rewind_mode::required, Action, Control >::match( in, st... ); ++i ) { + } + return true; + } + }; + + template< unsigned Max, typename... Rules > + inline constexpr bool skip_control< rep_opt< Max, Rules... > > = true; + +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/require.hpp b/packages/PEGTL/include/tao/pegtl/internal/require.hpp index f03821e46..b746feff0 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/require.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/require.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_REQUIRE_HPP @@ -11,42 +11,32 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< unsigned Amount > - struct require; - - template<> - struct require< 0 > - : trivial< true > - { - }; - - template< unsigned Amount > - struct require - { - using analyze_t = analysis::generic< analysis::rule_type::OPT >; + template< unsigned Amount > + struct require; - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( in.size( 0 ) ) ) - { - return in.size( Amount ) >= Amount; - } - }; + template<> + struct require< 0 > + : trivial< true > + { + }; - template< unsigned Amount > - struct skip_control< require< Amount > > : std::true_type - { - }; + template< unsigned Amount > + struct require + { + using analyze_t = analysis::generic< analysis::rule_type::opt >; - } // namespace internal + template< typename Input > + [[nodiscard]] static bool match( Input& in ) noexcept( noexcept( in.size( 0 ) ) ) + { + return in.size( Amount ) >= Amount; + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template< unsigned Amount > + inline constexpr bool skip_control< require< Amount > > = true; -} // namespace tao +} // 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 13ec9891c..e2ed0a63b 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_RESULT_ON_FOUND_HPP @@ -6,22 +6,14 @@ #include "../config.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + enum class result_on_found : bool { - namespace internal - { - enum class result_on_found : bool - { - SUCCESS = true, - FAILURE = false - }; + success = true, + failure = false + }; - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/rule_conjunction.hpp b/packages/PEGTL/include/tao/pegtl/internal/rule_conjunction.hpp deleted file mode 100644 index d4dd3d171..000000000 --- a/packages/PEGTL/include/tao/pegtl/internal/rule_conjunction.hpp +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_RULE_CONJUNCTION_HPP -#define TAO_PEGTL_INTERNAL_RULE_CONJUNCTION_HPP - -#include "../apply_mode.hpp" -#include "../config.hpp" -#include "../rewind_mode.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename... Rules > - struct rule_conjunction; - - template<> - struct rule_conjunction<> - { - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& /*unused*/, States&&... /*unused*/ ) noexcept - { - return true; - } - }; - - template< typename... Rules > - struct rule_conjunction - { - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { -#ifdef __cpp_fold_expressions - return ( Control< Rules >::template match< A, M, Action, Control >( in, st... ) && ... ); -#else - bool result = true; - using swallow = bool[]; - (void)swallow{ result = result && Control< Rules >::template match< A, M, Action, Control >( in, st... )... }; - return result; -#endif - } - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/rules.hpp b/packages/PEGTL/include/tao/pegtl/internal/rules.hpp index 6f72c0e5c..613c4eacd 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_RULES_HPP @@ -31,7 +31,6 @@ #include "list_must.hpp" #include "list_tail.hpp" #include "list_tail_pad.hpp" -#include "minus.hpp" #include "must.hpp" #include "not_at.hpp" #include "one.hpp" @@ -42,6 +41,7 @@ #include "raise.hpp" #include "range.hpp" #include "ranges.hpp" +#include "rematch.hpp" #include "rep.hpp" #include "rep_min.hpp" #include "rep_min_max.hpp" @@ -54,10 +54,8 @@ #include "star_must.hpp" #include "state.hpp" #include "string.hpp" -#include "three.hpp" #include "trivial.hpp" #include "try_catch_type.hpp" -#include "two.hpp" #include "until.hpp" #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/seq.hpp b/packages/PEGTL/include/tao/pegtl/internal/seq.hpp index 4c751c406..eccf791e7 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/seq.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/seq.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_SEQ_HPP @@ -6,7 +6,6 @@ #include "../config.hpp" -#include "rule_conjunction.hpp" #include "skip_control.hpp" #include "trivial.hpp" @@ -15,66 +14,60 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename... Rules > - struct seq; - - template<> - struct seq<> - : trivial< true > - { - }; - - template< typename Rule > - struct seq< Rule > - { - using analyze_t = typename Rule::analyze_t; - - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - return Control< Rule >::template match< A, M, Action, Control >( in, st... ); - } - }; - - template< typename... Rules > - struct seq - { - using analyze_t = analysis::generic< analysis::rule_type::SEQ, Rules... >; + template< typename... Rules > + struct seq; - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - auto m = in.template mark< M >(); - using m_t = decltype( m ); - return m( rule_conjunction< Rules... >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ); - } - }; + template<> + struct seq<> + : trivial< true > + { + }; - template< typename... Rules > - struct skip_control< seq< Rules... > > : std::true_type - { - }; + template< typename Rule > + struct seq< Rule > + { + using analyze_t = typename Rule::analyze_t; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + return Control< Rule >::template match< A, M, Action, Control >( in, st... ); + } + }; - } // namespace internal + template< typename... Rules > + struct seq + { + using analyze_t = analysis::generic< analysis::rule_type::seq, Rules... >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + auto m = in.template mark< M >(); + using m_t = decltype( m ); + return m( ( Control< Rules >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) && ... ) ); + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template< typename... Rules > + inline constexpr bool skip_control< seq< Rules... > > = true; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/skip_control.hpp b/packages/PEGTL/include/tao/pegtl/internal/skip_control.hpp index 29ce86f07..a3b770463 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/skip_control.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/skip_control.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_SKIP_CONTROL_HPP @@ -8,28 +8,18 @@ #include "../config.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - // This class is a simple tagging mechanism. - // By default, skip_control< Rule >::value - // is 'false'. Each internal (!) rule that should - // be hidden from the control and action class' - // callbacks simply specializes skip_control<> - // to return 'true' for the above expression. + // This class is a simple tagging mechanism. + // By default, skip_control< Rule > is 'false'. + // Each internal (!) rule that should be hidden + // from the control and action class' callbacks + // simply specializes skip_control<> to return + // 'true' for the above expression. - template< typename Rule > - struct skip_control : std::false_type - { - }; + template< typename Rule > + inline constexpr bool skip_control = false; - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/sor.hpp b/packages/PEGTL/include/tao/pegtl/internal/sor.hpp index 3108a649d..b43a96527 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/sor.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/sor.hpp @@ -1,12 +1,13 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_SOR_HPP #define TAO_PEGTL_INTERNAL_SOR_HPP +#include <utility> + #include "../config.hpp" -#include "integer_sequence.hpp" #include "skip_control.hpp" #include "trivial.hpp" @@ -15,60 +16,45 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename... Rules > - struct sor; - - template<> - struct sor<> - : trivial< false > - { - }; - - template< typename... Rules > - struct sor - : sor< index_sequence_for< Rules... >, Rules... > - { - }; - - template< std::size_t... Indices, typename... Rules > - struct sor< index_sequence< Indices... >, Rules... > - { - using analyze_t = analysis::generic< analysis::rule_type::SOR, Rules... >; + template< typename... Rules > + struct sor; - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { -#ifdef __cpp_fold_expressions - return ( Control< Rules >::template match < A, ( Indices == ( sizeof...( Rules ) - 1 ) ) ? M : rewind_mode::REQUIRED, Action, Control > ( in, st... ) || ... ); -#else - bool result = false; - using swallow = bool[]; - (void)swallow{ result = result || Control< Rules >::template match < A, ( Indices == ( sizeof...( Rules ) - 1 ) ) ? M : rewind_mode::REQUIRED, Action, Control > ( in, st... )... }; - return result; -#endif - } - }; + template<> + struct sor<> + : trivial< false > + { + }; - template< typename... Rules > - struct skip_control< sor< Rules... > > : std::true_type - { - }; + template< typename... Rules > + struct sor + : sor< std::index_sequence_for< Rules... >, Rules... > + { + }; - } // namespace internal + template< std::size_t... Indices, typename... Rules > + struct sor< std::index_sequence< Indices... >, Rules... > + { + using analyze_t = analysis::generic< analysis::rule_type::sor, Rules... >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + return ( Control< Rules >::template match< A, ( ( Indices == ( sizeof...( Rules ) - 1 ) ) ? M : rewind_mode::required ), Action, Control >( in, st... ) || ... ); + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template< typename... Rules > + inline constexpr bool skip_control< sor< Rules... > > = true; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/star.hpp b/packages/PEGTL/include/tao/pegtl/internal/star.hpp index cfa3c8a56..e785fa73f 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/star.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/star.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_STAR_HPP @@ -8,7 +8,6 @@ #include "../config.hpp" -#include "duseltronik.hpp" #include "seq.hpp" #include "skip_control.hpp" @@ -17,40 +16,32 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename Rule, typename... Rules > + struct star { - namespace internal + using analyze_t = analysis::generic< analysis::rule_type::opt, Rule, Rules..., star >; + + template< apply_mode A, + rewind_mode, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) { - template< typename Rule, typename... Rules > - struct star - { - using analyze_t = analysis::generic< analysis::rule_type::OPT, Rule, Rules..., star >; - - template< apply_mode A, - rewind_mode, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - while( seq< Rule, Rules... >::template match< A, rewind_mode::REQUIRED, Action, Control >( in, st... ) ) { - } - return true; - } - }; - - template< typename Rule, typename... Rules > - struct skip_control< star< Rule, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + while( seq< Rule, Rules... >::template match< A, rewind_mode::required, Action, Control >( in, st... ) ) { + } + return true; + } + }; + + template< typename Rule, typename... Rules > + inline constexpr bool skip_control< star< Rule, Rules... > > = true; + +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/star_must.hpp b/packages/PEGTL/include/tao/pegtl/internal/star_must.hpp index 41b06575f..9852828f4 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_STAR_MUST_HPP @@ -9,19 +9,11 @@ #include "if_must.hpp" #include "star.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Cond, typename... Rules > - using star_must = star< if_must< false, Cond, Rules... > >; + template< typename Cond, typename... Rules > + using star_must = star< if_must< false, Cond, Rules... > >; - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // 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 0d8b92afb..76c0f6f4f 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/state.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/state.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_STATE_HPP @@ -15,71 +15,35 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename State, typename... Rules > + struct state { - namespace internal + using analyze_t = analysis::generic< analysis::rule_type::seq, Rules... >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) { - template< typename State, typename... Rules > - struct state - { - using analyze_t = analysis::generic< analysis::rule_type::SEQ, Rules... >; - - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static auto success( State& s, const Input& in, States&&... st ) - -> decltype( s.template success< A, M, Action, Control >( in, st... ), void() ) - { - s.template success< A, M, Action, Control >( in, st... ); - } - - // NOTE: The additional "int = 0" is a work-around for missing expression SFINAE in VS2015. - - template< apply_mode, - rewind_mode, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States, - int = 0 > - static auto success( State& s, const Input& in, States&&... st ) - -> decltype( s.success( in, st... ), void() ) - { - s.success( in, st... ); - } - - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - State s( static_cast< const Input& >( in ), st... ); - - if( duseltronik< seq< Rules... >, A, M, Action, Control >::match( in, s ) ) { - success< A, M, Action, Control >( s, in, st... ); - return true; - } - return false; - } - }; - - template< typename State, typename... Rules > - struct skip_control< state< State, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + State s( static_cast< const Input& >( in ), st... ); + if( duseltronik< seq< Rules... >, A, M, Action, Control >::match( in, s ) ) { + s.success( static_cast< const Input& >( in ), st... ); + return true; + } + return false; + } + }; + + template< typename State, typename... Rules > + inline constexpr bool skip_control< state< State, Rules... > > = true; + +} // 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 49cdf8f3b..9ff22d054 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_STRING_HPP @@ -16,53 +16,43 @@ #include "../analysis/counted.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + [[nodiscard]] inline bool unsafe_equals( const char* s, const std::initializer_list< char >& l ) noexcept { - namespace internal - { - inline bool unsafe_equals( const char* s, const std::initializer_list< char >& l ) noexcept - { - return std::memcmp( s, &*l.begin(), l.size() ) == 0; - } + return std::memcmp( s, &*l.begin(), l.size() ) == 0; + } - template< char... Cs > - struct string; + template< char... Cs > + struct string; - template<> - struct string<> - : trivial< true > - { - }; + template<> + struct string<> + : trivial< true > + { + }; - template< char... Cs > - struct string - { - using analyze_t = analysis::counted< analysis::rule_type::ANY, sizeof...( Cs ) >; + template< char... Cs > + struct string + { + using analyze_t = analysis::counted< analysis::rule_type::any, sizeof...( Cs ) >; - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( in.size( 0 ) ) ) - { - if( in.size( sizeof...( Cs ) ) >= sizeof...( Cs ) ) { - if( unsafe_equals( in.current(), { Cs... } ) ) { - bump_help< result_on_found::SUCCESS, Input, char, Cs... >( in, sizeof...( Cs ) ); - return true; - } - } - return false; + template< typename Input > + [[nodiscard]] static bool match( Input& in ) noexcept( noexcept( in.size( 0 ) ) ) + { + if( in.size( sizeof...( Cs ) ) >= sizeof...( Cs ) ) { + if( unsafe_equals( in.current(), { Cs... } ) ) { + bump_help< result_on_found::success, Input, char, Cs... >( in, sizeof...( Cs ) ); + return true; } - }; - - template< char... Cs > - struct skip_control< string< Cs... > > : std::true_type - { - }; - - } // namespace internal + } + return false; + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template< char... Cs > + inline constexpr bool skip_control< string< Cs... > > = true; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/three.hpp b/packages/PEGTL/include/tao/pegtl/internal/three.hpp deleted file mode 100644 index bd6fe525d..000000000 --- a/packages/PEGTL/include/tao/pegtl/internal/three.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_THREE_HPP -#define TAO_PEGTL_INTERNAL_THREE_HPP - -#include <utility> - -#include "../config.hpp" - -#include "bump_help.hpp" -#include "result_on_found.hpp" -#include "skip_control.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< char C > - struct three - { - using analyze_t = analysis::generic< analysis::rule_type::ANY >; - - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( in.size( 3 ) ) ) - { - if( in.size( 3 ) >= 3 ) { - if( ( in.peek_char( 0 ) == C ) && ( in.peek_char( 1 ) == C ) && ( in.peek_char( 2 ) == C ) ) { - bump_help< result_on_found::SUCCESS, Input, char, C >( in, 3 ); - return true; - } - } - return false; - } - }; - - template< char C > - struct skip_control< three< C > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/trivial.hpp b/packages/PEGTL/include/tao/pegtl/internal/trivial.hpp index 38479d273..0fa6bb017 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/trivial.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/trivial.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_TRIVIAL_HPP @@ -10,33 +10,23 @@ #include "../analysis/counted.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< bool Result > + struct trivial { - namespace internal - { - template< bool Result > - struct trivial - { - using analyze_t = analysis::counted< analysis::rule_type::ANY, unsigned( !Result ) >; - - template< typename Input > - static bool match( Input& /*unused*/ ) noexcept - { - return Result; - } - }; + using analyze_t = analysis::counted< analysis::rule_type::any, unsigned( !Result ) >; - template< bool Result > - struct skip_control< trivial< Result > > : std::true_type - { - }; - - } // namespace internal + template< typename Input > + [[nodiscard]] static bool match( Input& /*unused*/ ) noexcept + { + return Result; + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template< bool Result > + inline constexpr bool skip_control< trivial< Result > > = true; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::internal #endif 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 e70e432ef..eca0db691 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_TRY_CATCH_TYPE_HPP @@ -18,55 +18,47 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Exception, typename... Rules > - struct try_catch_type; - - template< typename Exception > - struct try_catch_type< Exception > - : trivial< true > - { - }; - - template< typename Exception, typename... Rules > - struct try_catch_type - { - using analyze_t = analysis::generic< analysis::rule_type::SEQ, Rules... >; - - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - auto m = in.template mark< M >(); - using m_t = decltype( m ); - - try { - return m( duseltronik< seq< Rules... >, A, m_t::next_rewind_mode, Action, Control >::match( in, st... ) ); - } - catch( const Exception& ) { - return false; - } - } - }; + template< typename Exception, typename... Rules > + struct try_catch_type; - template< typename Exception, typename... Rules > - struct skip_control< try_catch_type< Exception, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE + template< typename Exception > + struct try_catch_type< Exception > + : trivial< true > + { + }; -} // namespace tao + template< typename Exception, typename... Rules > + struct try_catch_type + { + using analyze_t = analysis::generic< analysis::rule_type::seq, Rules... >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + auto m = in.template mark< M >(); + using m_t = decltype( m ); + + try { + return m( duseltronik< seq< Rules... >, A, m_t::next_rewind_mode, Action, Control >::match( in, st... ) ); + } + catch( const Exception& ) { + return false; + } + } + }; + + template< typename Exception, typename... Rules > + inline constexpr bool skip_control< try_catch_type< Exception, Rules... > > = true; + +} // namespace TAO_PEGTL_NAMESPACE::internal #endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/two.hpp b/packages/PEGTL/include/tao/pegtl/internal/two.hpp deleted file mode 100644 index 69eaf4b65..000000000 --- a/packages/PEGTL/include/tao/pegtl/internal/two.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAO_PEGTL_INTERNAL_TWO_HPP -#define TAO_PEGTL_INTERNAL_TWO_HPP - -#include <utility> - -#include "../config.hpp" - -#include "bump_help.hpp" -#include "result_on_found.hpp" -#include "skip_control.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAO_PEGTL_NAMESPACE - { - namespace internal - { - template< char C > - struct two - { - using analyze_t = analysis::generic< analysis::rule_type::ANY >; - - template< typename Input > - static bool match( Input& in ) noexcept( noexcept( in.size( 2 ) ) ) - { - if( in.size( 2 ) >= 2 ) { - if( ( in.peek_char( 0 ) == C ) && ( in.peek_char( 1 ) == C ) ) { - bump_help< result_on_found::SUCCESS, Input, char, C >( in, 2 ); - return true; - } - } - return false; - } - }; - - template< char C > - struct skip_control< two< C > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/packages/PEGTL/include/tao/pegtl/internal/until.hpp b/packages/PEGTL/include/tao/pegtl/internal/until.hpp index c6a002ee8..c48b6dd32 100644 --- a/packages/PEGTL/include/tao/pegtl/internal/until.hpp +++ b/packages/PEGTL/include/tao/pegtl/internal/until.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_INTERNAL_UNTIL_HPP @@ -9,7 +9,6 @@ #include "bytes.hpp" #include "eof.hpp" #include "not_at.hpp" -#include "rule_conjunction.hpp" #include "skip_control.hpp" #include "star.hpp" @@ -18,74 +17,68 @@ #include "../analysis/generic.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::internal { - namespace TAO_PEGTL_NAMESPACE + template< typename Cond, typename... Rules > + struct until; + + template< typename Cond > + struct until< Cond > { - namespace internal + using analyze_t = analysis::generic< analysis::rule_type::seq, star< not_at< Cond >, not_at< eof >, bytes< 1 > >, Cond >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) { - template< typename Cond, typename... Rules > - struct until; - - template< typename Cond > - struct until< Cond > - { - using analyze_t = analysis::generic< analysis::rule_type::SEQ, star< not_at< Cond >, not_at< eof >, bytes< 1 > >, Cond >; - - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - auto m = in.template mark< M >(); + auto m = in.template mark< M >(); - while( !Control< Cond >::template match< A, rewind_mode::REQUIRED, Action, Control >( in, st... ) ) { - if( in.empty() ) { - return false; - } - in.bump(); - } - return m( true ); + while( !Control< Cond >::template match< A, rewind_mode::required, Action, Control >( in, st... ) ) { + if( in.empty() ) { + return false; } - }; - - template< typename Cond, typename... Rules > - struct until - { - using analyze_t = analysis::generic< analysis::rule_type::SEQ, star< not_at< Cond >, not_at< eof >, Rules... >, Cond >; - - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - auto m = in.template mark< M >(); - using m_t = decltype( m ); + in.bump(); + } + return m( true ); + } + }; + + template< typename Cond, typename... Rules > + struct until + { + using analyze_t = analysis::generic< analysis::rule_type::seq, star< not_at< Cond >, not_at< eof >, Rules... >, Cond >; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + auto m = in.template mark< M >(); + using m_t = decltype( m ); - while( !Control< Cond >::template match< A, rewind_mode::REQUIRED, Action, Control >( in, st... ) ) { - if( !rule_conjunction< Rules... >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ) { - return false; - } - } - return m( true ); + while( !Control< Cond >::template match< A, rewind_mode::required, Action, Control >( in, st... ) ) { + if( !( Control< Rules >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) && ... ) ) { + return false; } - }; - - template< typename Cond, typename... Rules > - struct skip_control< until< Cond, Rules... > > : std::true_type - { - }; - - } // namespace internal + } + return m( true ); + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template< typename Cond, typename... Rules > + inline constexpr bool skip_control< until< Cond, Rules... > > = true; -} // namespace tao +} // 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 f598753b2..55f559e24 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_ISTREAM_INPUT_HPP @@ -12,28 +12,22 @@ #include "internal/istream_reader.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + template< typename Eol = eol::lf_crlf, std::size_t Chunk = 64 > + struct istream_input + : buffer_input< internal::istream_reader, Eol, std::string, Chunk > { - template< typename Eol = eol::lf_crlf > - struct istream_input - : buffer_input< internal::istream_reader, Eol > + template< typename T > + istream_input( std::istream& in_stream, const std::size_t in_maximum, T&& in_source ) // NOLINT + : buffer_input< internal::istream_reader, Eol, std::string, Chunk >( std::forward< T >( in_source ), in_maximum, in_stream ) { - template< typename T > - istream_input( std::istream& in_stream, const std::size_t in_maximum, T&& in_source ) - : buffer_input< internal::istream_reader, Eol >( std::forward< T >( in_source ), in_maximum, in_stream ) - { - } - }; - -#ifdef __cpp_deduction_guides - template< typename... Ts > - istream_input( Ts&&... )->istream_input<>; -#endif + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template< typename... Ts > + istream_input( Ts&&... )->istream_input<>; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/match.hpp b/packages/PEGTL/include/tao/pegtl/match.hpp new file mode 100644 index 000000000..74058f997 --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/match.hpp @@ -0,0 +1,73 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_MATCH_HPP +#define TAO_PEGTL_MATCH_HPP + +#include <type_traits> + +#include "apply_mode.hpp" +#include "config.hpp" +#include "nothing.hpp" +#include "require_apply.hpp" +#include "require_apply0.hpp" +#include "rewind_mode.hpp" + +#include "internal/dusel_mode.hpp" +#include "internal/duseltronik.hpp" +#include "internal/has_apply.hpp" +#include "internal/has_apply0.hpp" +#include "internal/missing_apply.hpp" +#include "internal/missing_apply0.hpp" +#include "internal/skip_control.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] bool match( Input& in, States&&... st ) + { + constexpr bool enable_control = !internal::skip_control< Rule >; + constexpr bool enable_action = enable_control && ( A == apply_mode::action ); + + using iterator_t = typename Input::iterator_t; + constexpr bool has_apply_void = enable_action && internal::has_apply< Control< Rule >, void, Action, const iterator_t&, const Input&, States... >::value; + constexpr bool has_apply_bool = enable_action && internal::has_apply< Control< Rule >, bool, Action, const iterator_t&, const Input&, States... >::value; + 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 Input&, States... >::value; + constexpr bool has_apply0_bool = enable_action && internal::has_apply0< Control< Rule >, bool, Action, const Input&, States... >::value; + constexpr bool has_apply0 = has_apply0_void || has_apply0_bool; + + static_assert( !( has_apply && has_apply0 ), "both apply() and apply0() defined" ); + + constexpr bool is_nothing = std::is_base_of_v< nothing< Rule >, Action< Rule > >; + static_assert( !( has_apply && is_nothing ), "unexpected apply() defined" ); + static_assert( !( has_apply0 && is_nothing ), "unexpected apply0() defined" ); + + if constexpr( !has_apply && std::is_base_of_v< require_apply, Action< Rule > > ) { + internal::missing_apply< Control< Rule >, Action >( in, st... ); + } + + if constexpr( !has_apply0 && std::is_base_of_v< require_apply0, Action< Rule > > ) { + internal::missing_apply0< Control< Rule >, Action >( in, st... ); + } + + constexpr bool validate_nothing = std::is_base_of_v< maybe_nothing, Action< void > >; + 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 auto mode = static_cast< internal::dusel_mode >( enable_control + has_apply_void + 2 * has_apply_bool + 3 * has_apply0_void + 4 * has_apply0_bool ); + return internal::duseltronik< Rule, A, M, Action, Control, mode >::match( in, st... ); + } + +} // namespace TAO_PEGTL_NAMESPACE + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/memory_input.hpp b/packages/PEGTL/include/tao/pegtl/memory_input.hpp index 021b21142..1380d9a79 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_MEMORY_INPUT_HPP @@ -8,6 +8,7 @@ #include <cstdint> #include <cstring> #include <string> +#include <string_view> #include <type_traits> #include <utility> @@ -20,347 +21,361 @@ #include "internal/action_input.hpp" #include "internal/at.hpp" -#include "internal/bump_impl.hpp" +#include "internal/bump.hpp" #include "internal/eolf.hpp" #include "internal/iterator.hpp" #include "internal/marker.hpp" #include "internal/until.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace internal { - namespace internal - { - template< tracking_mode, typename Eol, typename Source > - class memory_input_base; + template< tracking_mode, typename Eol, typename Source > + class memory_input_base; - template< typename Eol, typename Source > - class memory_input_base< tracking_mode::IMMEDIATE, Eol, Source > - { - public: - using iterator_t = internal::iterator; - - template< typename T > - memory_input_base( const iterator_t& in_begin, const char* in_end, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value ) - : m_begin( in_begin.data ), - m_current( in_begin ), - m_end( in_end ), - m_source( std::forward< T >( in_source ) ) - { - } - - template< typename T > - memory_input_base( const char* in_begin, const char* in_end, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value ) - : m_begin( in_begin ), - m_current( in_begin ), - m_end( in_end ), - m_source( std::forward< T >( in_source ) ) - { - } - - memory_input_base( const memory_input_base& ) = delete; - memory_input_base( memory_input_base&& ) = delete; - - ~memory_input_base() = default; - - memory_input_base operator=( const memory_input_base& ) = delete; - memory_input_base operator=( memory_input_base&& ) = delete; - - const char* current() const noexcept - { - return m_current.data; - } - - const char* begin() const noexcept - { - return m_begin; - } - - const char* end( const std::size_t /*unused*/ = 0 ) const noexcept - { - return m_end; - } - - std::size_t byte() const noexcept - { - return m_current.byte; - } - - std::size_t line() const noexcept - { - return m_current.line; - } - - std::size_t byte_in_line() const noexcept - { - return m_current.byte_in_line; - } - - void bump( const std::size_t in_count = 1 ) noexcept - { - internal::bump( m_current, in_count, Eol::ch ); - } - - void bump_in_this_line( const std::size_t in_count = 1 ) noexcept - { - internal::bump_in_this_line( m_current, in_count ); - } - - void bump_to_next_line( const std::size_t in_count = 1 ) noexcept - { - internal::bump_to_next_line( m_current, in_count ); - } - - TAO_PEGTL_NAMESPACE::position position( const iterator_t& it ) const - { - return TAO_PEGTL_NAMESPACE::position( it, m_source ); - } - - void restart( const std::size_t in_byte = 0, const std::size_t in_line = 1, const std::size_t in_byte_in_line = 0 ) - { - m_current.data = m_begin; - m_current.byte = in_byte; - m_current.line = in_line; - m_current.byte_in_line = in_byte_in_line; - } - - protected: - const char* const m_begin; - iterator_t m_current; - const char* const m_end; - const Source m_source; - }; - - template< typename Eol, typename Source > - class memory_input_base< tracking_mode::LAZY, Eol, Source > - { - public: - using iterator_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< Source, T&& >::value ) - : m_begin( in_begin ), - m_current( in_begin.data ), - m_end( in_end ), - m_source( std::forward< T >( in_source ) ) - { - } - - template< typename T > - memory_input_base( const char* in_begin, const char* in_end, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value ) - : m_begin( in_begin ), - m_current( in_begin ), - m_end( in_end ), - m_source( std::forward< T >( in_source ) ) - { - } - - memory_input_base( const memory_input_base& ) = delete; - memory_input_base( memory_input_base&& ) = delete; - - ~memory_input_base() = default; - - memory_input_base operator=( const memory_input_base& ) = delete; - memory_input_base operator=( memory_input_base&& ) = delete; - - const char* current() const noexcept - { - return m_current; - } - - const char* begin() const noexcept - { - return m_begin.data; - } - - const char* end( const std::size_t /*unused*/ = 0 ) const noexcept - { - return m_end; - } - - std::size_t byte() const noexcept - { - return std::size_t( current() - m_begin.data ); - } - - void bump( const std::size_t in_count = 1 ) noexcept - { - m_current += in_count; - } - - void bump_in_this_line( const std::size_t in_count = 1 ) noexcept - { - m_current += in_count; - } - - void bump_to_next_line( const std::size_t in_count = 1 ) noexcept - { - m_current += in_count; - } - - TAO_PEGTL_NAMESPACE::position position( const iterator_t it ) const - { - internal::iterator c( m_begin ); - internal::bump( c, std::size_t( it - m_begin.data ), Eol::ch ); - return TAO_PEGTL_NAMESPACE::position( c, m_source ); - } - - void restart() - { - m_current = m_begin.data; - } - - protected: - const internal::iterator m_begin; - iterator_t m_current; - const char* const m_end; - const Source m_source; - }; - - } // namespace internal - - template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf, typename Source = std::string > - class memory_input - : public internal::memory_input_base< P, Eol, Source > + template< typename Eol, typename Source > + class memory_input_base< tracking_mode::eager, Eol, Source > { public: - static constexpr tracking_mode tracking_mode_v = P; + using iterator_t = internal::iterator; + + 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&& > ) + : m_begin( in_begin.data ), + m_current( in_begin ), + m_end( in_end ), + m_source( std::forward< T >( in_source ) ) + { + } - using eol_t = Eol; - using source_t = Source; + template< typename T > + memory_input_base( const char* 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 ), + m_end( in_end ), + m_source( std::forward< T >( in_source ) ) + { + } - using typename internal::memory_input_base< P, Eol, Source >::iterator_t; + memory_input_base( const memory_input_base& ) = delete; + memory_input_base( memory_input_base&& ) = delete; - using action_t = internal::action_input< memory_input >; + ~memory_input_base() = default; - using internal::memory_input_base< P, Eol, Source >::memory_input_base; + memory_input_base operator=( const memory_input_base& ) = delete; + memory_input_base operator=( memory_input_base&& ) = delete; - template< typename T > - memory_input( const char* in_begin, const std::size_t in_size, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value ) - : memory_input( in_begin, in_begin + in_size, std::forward< T >( in_source ) ) + [[nodiscard]] const char* current() const noexcept { + return m_current.data; } - template< typename T > - memory_input( const std::string& in_string, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value ) - : memory_input( in_string.data(), in_string.size(), std::forward< T >( in_source ) ) + [[nodiscard]] const char* begin() const noexcept { + return m_begin; } - template< typename T > - memory_input( std::string&&, T&& ) = delete; + [[nodiscard]] const char* end( const std::size_t /*unused*/ = 0 ) const noexcept + { + return m_end; + } - template< typename T > - memory_input( const char* in_begin, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value ) - : memory_input( in_begin, std::strlen( in_begin ), std::forward< T >( in_source ) ) + [[nodiscard]] std::size_t byte() const noexcept { + return m_current.byte; } - template< typename T > - memory_input( const char* in_begin, const char* in_end, T&& in_source, const std::size_t in_byte, const std::size_t in_line, const std::size_t in_byte_in_line ) noexcept( std::is_nothrow_constructible< Source, T&& >::value ) - : memory_input( { in_begin, in_byte, in_line, in_byte_in_line }, in_end, std::forward< T >( in_source ) ) + [[nodiscard]] std::size_t line() const noexcept { + return m_current.line; } - memory_input( const memory_input& ) = delete; - memory_input( memory_input&& ) = delete; + [[nodiscard]] std::size_t byte_in_line() const noexcept + { + return m_current.byte_in_line; + } - ~memory_input() = default; + void bump( const std::size_t in_count = 1 ) noexcept + { + internal::bump( m_current, in_count, Eol::ch ); + } - memory_input operator=( const memory_input& ) = delete; - memory_input operator=( memory_input&& ) = delete; + void bump_in_this_line( const std::size_t in_count = 1 ) noexcept + { + internal::bump_in_this_line( m_current, in_count ); + } - const Source& source() const noexcept + void bump_to_next_line( const std::size_t in_count = 1 ) noexcept { - return this->m_source; + internal::bump_to_next_line( m_current, in_count ); } - bool empty() const noexcept + [[nodiscard]] TAO_PEGTL_NAMESPACE::position position( const iterator_t& it ) const { - return this->current() == this->end(); + return TAO_PEGTL_NAMESPACE::position( it, m_source ); } - std::size_t size( const std::size_t /*unused*/ = 0 ) const noexcept + void restart( const std::size_t in_byte = 0, const std::size_t in_line = 1, const std::size_t in_byte_in_line = 0 ) { - return std::size_t( this->end() - this->current() ); + m_current.data = m_begin; + m_current.byte = in_byte; + m_current.line = in_line; + m_current.byte_in_line = in_byte_in_line; } - char peek_char( const std::size_t offset = 0 ) const noexcept + template< rewind_mode M > + void restart( const internal::marker< iterator_t, M >& m ) { - return this->current()[ offset ]; + m_current.data = m.iterator().data; + m_current.byte = m.iterator().byte; + m_current.line = m.iterator().line; + m_current.byte_in_line = m.iterator().byte_in_line; } - std::uint8_t peek_byte( const std::size_t offset = 0 ) const noexcept + protected: + const char* const m_begin; + iterator_t m_current; + const char* const m_end; + const Source m_source; + }; + + template< typename Eol, typename Source > + class memory_input_base< tracking_mode::lazy, Eol, Source > + { + public: + using iterator_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&& > ) + : m_begin( in_begin ), + m_current( in_begin.data ), + m_end( in_end ), + m_source( std::forward< T >( in_source ) ) { - return static_cast< std::uint8_t >( peek_char( offset ) ); } - iterator_t& iterator() noexcept + template< typename T > + memory_input_base( const char* 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 ), + m_end( in_end ), + m_source( std::forward< T >( in_source ) ) { - return this->m_current; } - const iterator_t& iterator() const noexcept + memory_input_base( const memory_input_base& ) = delete; + memory_input_base( memory_input_base&& ) = delete; + + ~memory_input_base() = default; + + memory_input_base operator=( const memory_input_base& ) = delete; + memory_input_base operator=( memory_input_base&& ) = delete; + + [[nodiscard]] const char* current() const noexcept { - return this->m_current; + return m_current; } - using internal::memory_input_base< P, Eol, Source >::position; + [[nodiscard]] const char* begin() const noexcept + { + return m_begin.data; + } - TAO_PEGTL_NAMESPACE::position position() const + [[nodiscard]] const char* end( const std::size_t /*unused*/ = 0 ) const noexcept { - return position( iterator() ); + return m_end; } - void discard() const noexcept + [[nodiscard]] std::size_t byte() const noexcept { + return std::size_t( current() - m_begin.data ); } - void require( const std::size_t /*unused*/ ) const noexcept + void bump( const std::size_t in_count = 1 ) noexcept { + m_current += in_count; } - template< rewind_mode M > - internal::marker< iterator_t, M > mark() noexcept + void bump_in_this_line( const std::size_t in_count = 1 ) noexcept { - return internal::marker< iterator_t, M >( iterator() ); + m_current += in_count; } - const char* at( const TAO_PEGTL_NAMESPACE::position& p ) const noexcept + void bump_to_next_line( const std::size_t in_count = 1 ) noexcept { - return this->begin() + p.byte; + m_current += in_count; } - const char* begin_of_line( const TAO_PEGTL_NAMESPACE::position& p ) const noexcept + [[nodiscard]] TAO_PEGTL_NAMESPACE::position position( const iterator_t it ) const { - return at( p ) - p.byte_in_line; + internal::iterator c( m_begin ); + internal::bump( c, std::size_t( it - m_begin.data ), Eol::ch ); + return TAO_PEGTL_NAMESPACE::position( c, m_source ); } - const char* end_of_line( const TAO_PEGTL_NAMESPACE::position& p ) const noexcept + void restart() { - using input_t = memory_input< tracking_mode::LAZY, Eol, const char* >; - input_t in( at( p ), this->end(), "" ); - using grammar = internal::until< internal::at< internal::eolf > >; - normal< grammar >::match< apply_mode::NOTHING, rewind_mode::DONTCARE, nothing, normal >( in ); - return in.current(); + m_current = m_begin.data; } - std::string line_as_string( const TAO_PEGTL_NAMESPACE::position& p ) const + template< rewind_mode M > + void restart( const internal::marker< iterator_t, M >& m ) { - return std::string( begin_of_line( p ), end_of_line( p ) ); + m_current = m.iterator(); } - void* internal_state = nullptr; + protected: + const internal::iterator m_begin; + iterator_t m_current; + const char* const m_end; + const Source m_source; }; -#ifdef __cpp_deduction_guides - template< typename... Ts > - memory_input( Ts&&... )->memory_input<>; -#endif + } // namespace internal + + template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf, typename Source = std::string > + class memory_input + : public internal::memory_input_base< P, Eol, Source > + { + public: + static constexpr tracking_mode tracking_mode_v = P; + + using eol_t = Eol; + using source_t = Source; + + using typename internal::memory_input_base< P, Eol, Source >::iterator_t; + + using action_t = internal::action_input< memory_input >; + + using internal::memory_input_base< P, Eol, Source >::memory_input_base; + + template< typename T > + memory_input( const char* in_begin, const std::size_t in_size, T&& in_source ) noexcept( std::is_nothrow_constructible_v< Source, T&& > ) // NOLINT + : memory_input( in_begin, in_begin + in_size, std::forward< T >( in_source ) ) + { + } + + template< typename T > + memory_input( const std::string& in_string, T&& in_source ) noexcept( std::is_nothrow_constructible_v< Source, T&& > ) + : memory_input( in_string.data(), in_string.size(), std::forward< T >( in_source ) ) + { + } + + template< typename T > + memory_input( const std::string_view in_string, T&& in_source ) noexcept( std::is_nothrow_constructible_v< Source, T&& > ) // NOLINT + : memory_input( in_string.data(), in_string.size(), std::forward< T >( in_source ) ) + { + } + + template< typename T > + memory_input( std::string&&, T&& ) = delete; + + template< typename T > + memory_input( const char* in_begin, T&& in_source ) noexcept( std::is_nothrow_constructible_v< Source, T&& > ) + : memory_input( in_begin, std::strlen( in_begin ), std::forward< T >( in_source ) ) + { + } + + template< typename T > + memory_input( const char* in_begin, const char* in_end, T&& in_source, const std::size_t in_byte, const std::size_t in_line, const std::size_t in_byte_in_line ) noexcept( std::is_nothrow_constructible_v< Source, T&& > ) // NOLINT + : memory_input( { in_begin, in_byte, in_line, in_byte_in_line }, in_end, std::forward< T >( in_source ) ) + { + } + + memory_input( const memory_input& ) = delete; + memory_input( memory_input&& ) = delete; + + ~memory_input() = default; + + memory_input operator=( const memory_input& ) = delete; + memory_input operator=( memory_input&& ) = delete; + + [[nodiscard]] const Source& source() const noexcept + { + return this->m_source; + } + + [[nodiscard]] bool empty() const noexcept + { + return this->current() == this->end(); + } + + [[nodiscard]] std::size_t size( const std::size_t /*unused*/ = 0 ) const noexcept + { + return std::size_t( this->end() - this->current() ); + } + + [[nodiscard]] char peek_char( const std::size_t offset = 0 ) const noexcept + { + return this->current()[ offset ]; + } + + [[nodiscard]] std::uint8_t peek_uint8( const std::size_t offset = 0 ) const noexcept + { + return static_cast< std::uint8_t >( peek_char( offset ) ); + } + + [[nodiscard]] iterator_t& iterator() noexcept + { + return this->m_current; + } + + [[nodiscard]] const iterator_t& iterator() const noexcept + { + return this->m_current; + } + + using internal::memory_input_base< P, Eol, Source >::position; + + [[nodiscard]] TAO_PEGTL_NAMESPACE::position position() const + { + return position( iterator() ); + } + + void discard() const noexcept + { + } + + void require( const std::size_t /*unused*/ ) const noexcept + { + } + + template< rewind_mode M > + [[nodiscard]] internal::marker< iterator_t, M > mark() noexcept + { + return internal::marker< iterator_t, M >( iterator() ); + } + + [[nodiscard]] const char* at( const TAO_PEGTL_NAMESPACE::position& p ) const noexcept + { + return this->begin() + p.byte; + } + + [[nodiscard]] const char* begin_of_line( const TAO_PEGTL_NAMESPACE::position& p ) const noexcept + { + return at( p ) - p.byte_in_line; + } + + [[nodiscard]] const char* end_of_line( const TAO_PEGTL_NAMESPACE::position& p ) const noexcept + { + using input_t = memory_input< tracking_mode::lazy, Eol, const char* >; + input_t in( at( p ), this->end(), "" ); + using grammar = internal::until< internal::at< internal::eolf > >; + (void)normal< grammar >::match< apply_mode::nothing, rewind_mode::dontcare, nothing, normal >( in ); + return in.current(); + } + + [[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, end_of_line( p ) - b ); + } + }; - } // namespace TAO_PEGTL_NAMESPACE + template< typename... Ts > + memory_input( Ts&&... )->memory_input<>; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/mmap_input.hpp b/packages/PEGTL/include/tao/pegtl/mmap_input.hpp index 92c38f697..1b9d067d2 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_MMAP_INPUT_HPP @@ -23,63 +23,57 @@ #else #endif -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace internal { - namespace internal + struct mmap_holder { - struct mmap_holder - { - const std::string filename; - const file_mapper data; + const std::string filename; + const file_mapper data; - template< typename T > - explicit mmap_holder( T&& in_filename ) - : filename( std::forward< T >( in_filename ) ), - data( filename.c_str() ) - { - } + template< typename T > + explicit mmap_holder( T&& in_filename ) + : filename( std::forward< T >( in_filename ) ), + data( filename.c_str() ) + { + } - mmap_holder( const mmap_holder& ) = delete; - mmap_holder( mmap_holder&& ) = delete; + mmap_holder( const mmap_holder& ) = delete; + mmap_holder( mmap_holder&& ) = delete; - ~mmap_holder() = default; + ~mmap_holder() = default; - void operator=( const mmap_holder& ) = delete; - void operator=( mmap_holder&& ) = delete; - }; + void operator=( const mmap_holder& ) = delete; + void operator=( mmap_holder&& ) = delete; + }; - } // namespace internal + } // namespace internal - template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf > - struct mmap_input - : private internal::mmap_holder, - public memory_input< P, Eol, const char* > + template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > + struct mmap_input + : private internal::mmap_holder, + public memory_input< P, Eol, const char* > + { + template< typename T > + explicit mmap_input( T&& in_filename ) + : internal::mmap_holder( std::forward< T >( in_filename ) ), + memory_input< P, Eol, const char* >( data.begin(), data.end(), filename.c_str() ) { - template< typename T > - explicit mmap_input( T&& in_filename ) - : internal::mmap_holder( std::forward< T >( in_filename ) ), - memory_input< P, Eol, const char* >( data.begin(), data.end(), filename.c_str() ) - { - } + } - mmap_input( const mmap_input& ) = delete; - mmap_input( mmap_input&& ) = delete; + mmap_input( const mmap_input& ) = delete; + mmap_input( mmap_input&& ) = delete; - ~mmap_input() = default; + ~mmap_input() = default; - void operator=( const mmap_input& ) = delete; - void operator=( mmap_input&& ) = delete; - }; - -#ifdef __cpp_deduction_guides - template< typename... Ts > - explicit mmap_input( Ts&&... )->mmap_input<>; -#endif + void operator=( const mmap_input& ) = delete; + void operator=( mmap_input&& ) = delete; + }; - } // namespace TAO_PEGTL_NAMESPACE + template< typename... Ts > + explicit mmap_input( Ts&&... )->mmap_input<>; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/normal.hpp b/packages/PEGTL/include/tao/pegtl/normal.hpp index 8f7949aae..b7b323534 100644 --- a/packages/PEGTL/include/tao/pegtl/normal.hpp +++ b/packages/PEGTL/include/tao/pegtl/normal.hpp @@ -1,90 +1,86 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_NORMAL_HPP #define TAO_PEGTL_NORMAL_HPP +#include <type_traits> #include <utility> #include "apply_mode.hpp" #include "config.hpp" -#include "nothing.hpp" +#include "match.hpp" #include "parse_error.hpp" #include "rewind_mode.hpp" #include "internal/demangle.hpp" -#include "internal/dusel_mode.hpp" -#include "internal/duseltronik.hpp" -#include "internal/has_apply.hpp" -#include "internal/has_apply0.hpp" -#include "internal/skip_control.hpp" +#include "internal/has_match.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + template< typename Rule > + struct normal { - template< typename Rule > - struct normal + template< typename Input, typename... States > + static void start( const Input& /*unused*/, States&&... /*unused*/ ) noexcept { - template< typename Input, typename... States > - static void start( const Input& /*unused*/, States&&... /*unused*/ ) noexcept - { - } + } - template< typename Input, typename... States > - static void success( const Input& /*unused*/, States&&... /*unused*/ ) noexcept - { - } + template< typename Input, typename... States > + static void success( const Input& /*unused*/, States&&... /*unused*/ ) noexcept + { + } - template< typename Input, typename... States > - static void failure( const Input& /*unused*/, States&&... /*unused*/ ) noexcept - { - } + template< typename Input, typename... States > + static void failure( const Input& /*unused*/, States&&... /*unused*/ ) noexcept + { + } - template< typename Input, typename... States > - static void raise( const Input& in, States&&... /*unused*/ ) - { - throw parse_error( "parse error matching " + internal::demangle< Rule >(), in ); - } + template< typename Input, typename... States > + static void raise( const Input& in, States&&... /*unused*/ ) + { + throw parse_error( "parse error matching " + internal::demangle< Rule >(), in ); + } - template< template< typename... > class Action, typename Input, typename... States > - static auto apply0( const Input& /*unused*/, States&&... st ) - -> decltype( Action< Rule >::apply0( st... ) ) - { - return Action< Rule >::apply0( st... ); - } + template< template< typename... > class Action, + typename Iterator, + typename Input, + typename... States > + static auto apply( const Iterator& begin, const Input& in, States&&... st ) noexcept( noexcept( Action< Rule >::apply( std::declval< const typename Input::action_t& >(), st... ) ) ) + -> decltype( Action< Rule >::apply( std::declval< const typename Input::action_t& >(), st... ) ) + { + const typename Input::action_t action_input( begin, in ); + return Action< Rule >::apply( action_input, st... ); + } - template< template< typename... > class Action, typename Iterator, typename Input, typename... States > - static auto apply( const Iterator& begin, const Input& in, States&&... st ) - -> decltype( Action< Rule >::apply( std::declval< typename Input::action_t >(), st... ) ) - { - const typename Input::action_t action_input( begin, in ); - return Action< Rule >::apply( action_input, st... ); - } + template< template< typename... > class Action, + typename Input, + typename... States > + static auto apply0( const Input& /*unused*/, States&&... st ) noexcept( noexcept( Action< Rule >::apply0( st... ) ) ) + -> decltype( Action< Rule >::apply0( st... ) ) + { + return Action< Rule >::apply0( st... ); + } - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - constexpr char use_control = !internal::skip_control< Rule >::value; - constexpr char use_action = use_control && ( A == apply_mode::ACTION ) && ( !is_nothing< Action, Rule >::value ); - constexpr char use_apply_void = use_action && internal::has_apply< Action< Rule >, void, typename Input::action_t, States... >::value; - constexpr char use_apply_bool = use_action && internal::has_apply< Action< Rule >, bool, typename Input::action_t, States... >::value; - constexpr char use_apply0_void = use_action && internal::has_apply0< Action< Rule >, void, States... >::value; - constexpr char use_apply0_bool = use_action && internal::has_apply0< Action< Rule >, bool, States... >::value; - static_assert( !use_action || use_apply_bool || use_apply_void || use_apply0_bool || use_apply0_void, "actions not disabled but no apply() or apply0() found" ); - static_assert( use_apply_void + use_apply_bool + use_apply0_void + use_apply0_bool < 2, "both apply() and apply0() defined" ); - constexpr auto mode = static_cast< dusel_mode >( use_control + use_apply_void + 2 * use_apply_bool + 3 * use_apply0_void + 4 * use_apply0_bool ); - return internal::duseltronik< Rule, A, M, Action, Control, mode >::match( in, st... ); + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... st ) + { + if constexpr( internal::has_match_v< Rule, A, M, Action, Control, Input, States... > ) { + return Action< Rule >::template match< Rule, A, M, Action, Control >( in, st... ); } - }; - - } // namespace TAO_PEGTL_NAMESPACE + else { // NOLINT + return TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in, st... ); + } + } + }; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/nothing.hpp b/packages/PEGTL/include/tao/pegtl/nothing.hpp index 9d2ae16c3..20c23c2b9 100644 --- a/packages/PEGTL/include/tao/pegtl/nothing.hpp +++ b/packages/PEGTL/include/tao/pegtl/nothing.hpp @@ -1,27 +1,20 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_NOTHING_HPP #define TAO_PEGTL_NOTHING_HPP -#include <type_traits> - #include "config.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + template< typename Rule > + struct nothing { - template< typename Rule > - struct nothing - { - }; - - template< template< typename... > class Action, typename Rule > - using is_nothing = std::is_base_of< nothing< Rule >, Action< Rule > >; + }; - } // namespace TAO_PEGTL_NAMESPACE + using maybe_nothing = nothing< void >; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/parse.hpp b/packages/PEGTL/include/tao/pegtl/parse.hpp index 1f3254964..d566eaecc 100644 --- a/packages/PEGTL/include/tao/pegtl/parse.hpp +++ b/packages/PEGTL/include/tao/pegtl/parse.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_PARSE_HPP @@ -15,70 +15,39 @@ #include "internal/action_input.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + 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, + typename Input, + typename... States > + bool parse( Input&& in, States&&... st ) { - namespace internal - { - template< typename From > - struct copy_internals - { - template< typename To > - static void apply( const From& from, To& to ) noexcept - { - assert( to.internal_state == nullptr ); - to.internal_state = from.internal_state; - } - }; - - template< typename Input > - struct copy_internals< action_input< Input > > - { - template< typename To > - static void apply( const action_input< Input >& from, To& to ) noexcept - { - assert( to.internal_state == nullptr ); - to.internal_state = from.input().internal_state; - } - }; - - } // namespace internal - - 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, - typename Input, - typename... States > - bool parse( Input&& in, States&&... st ) - { - return Control< Rule >::template match< A, M, Action, Control >( in, st... ); + return Control< Rule >::template match< A, M, Action, Control >( in, st... ); + } + + 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, + typename Outer, + typename Input, + typename... States > + bool parse_nested( const Outer& oi, Input&& in, States&&... st ) + { + try { + return parse< Rule, Action, Control, A, M >( in, st... ); } - - 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, - typename Outer, - typename Input, - typename... States > - bool parse_nested( const Outer& oi, Input&& in, States&&... st ) - { - try { - internal::copy_internals< Outer >::apply( oi, in ); - return parse< Rule, Action, Control, A, M >( in, st... ); - } - catch( parse_error& e ) { - e.positions.push_back( oi.position() ); - throw; - } + catch( parse_error& e ) { + e.positions.push_back( oi.position() ); + throw; } + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/parse_error.hpp b/packages/PEGTL/include/tao/pegtl/parse_error.hpp index 4d62811f2..eee0ec686 100644 --- a/packages/PEGTL/include/tao/pegtl/parse_error.hpp +++ b/packages/PEGTL/include/tao/pegtl/parse_error.hpp @@ -1,45 +1,76 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_PARSE_ERROR_HPP #define TAO_PEGTL_PARSE_ERROR_HPP +#include <ostream> +#include <sstream> #include <stdexcept> +#include <string> +#include <utility> #include <vector> #include "config.hpp" #include "position.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + struct parse_error + : public std::runtime_error { - struct parse_error - : public std::runtime_error + template< typename Msg > + parse_error( Msg&& msg, const std::vector< position >& in_positions ) + : std::runtime_error( std::forward< Msg >( msg ) ), + positions( in_positions ) { - parse_error( const std::string& msg, std::vector< position >&& in_positions ) - : std::runtime_error( msg ), - positions( std::move( in_positions ) ) - { - } - - template< typename Input > - parse_error( const std::string& msg, const Input& in ) - : parse_error( msg, in.position() ) - { - } - - parse_error( const std::string& msg, const position& pos ) - : std::runtime_error( to_string( pos ) + ": " + msg ), - positions( 1, pos ) - { - } - - std::vector< position > positions; - }; - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + } + + template< typename Msg > + parse_error( Msg&& msg, std::vector< position >&& in_positions ) + : std::runtime_error( std::forward< Msg >( msg ) ), + positions( std::move( in_positions ) ) + { + } + + template< typename Msg > + parse_error( Msg&& msg, const position& pos ) + : std::runtime_error( std::forward< Msg >( msg ) ), + positions( 1, pos ) + { + } + + template< typename Msg > + parse_error( Msg&& msg, position&& pos ) + : std::runtime_error( std::forward< Msg >( msg ) ) + { + positions.emplace_back( std::move( pos ) ); + } + + template< typename Msg, typename Input > + parse_error( Msg&& msg, const Input& in ) + : parse_error( std::forward< Msg >( msg ), in.position() ) + { + } + + std::vector< position > positions; + }; + + inline std::ostream& operator<<( std::ostream& o, const parse_error& e ) + { + for( auto it = e.positions.rbegin(); it != e.positions.rend(); ++it ) { + o << *it << ": "; + } + return o << e.what(); + } + + [[nodiscard]] inline std::string to_string( const parse_error& e ) + { + std::ostringstream o; + o << e; + return o.str(); + } + +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/position.hpp b/packages/PEGTL/include/tao/pegtl/position.hpp index a7fe2b38f..c14446f73 100644 --- a/packages/PEGTL/include/tao/pegtl/position.hpp +++ b/packages/PEGTL/include/tao/pegtl/position.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_POSITION_HPP @@ -14,41 +14,37 @@ #include "internal/iterator.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + struct position { - struct position + template< typename T > + position( const internal::iterator& in_iter, T&& in_source ) + : byte( in_iter.byte ), + line( in_iter.line ), + byte_in_line( in_iter.byte_in_line ), + source( std::forward< T >( in_source ) ) { - template< typename T > - position( const internal::iterator& in_iter, T&& in_source ) - : byte( in_iter.byte ), - line( in_iter.line ), - byte_in_line( in_iter.byte_in_line ), - source( std::forward< T >( in_source ) ) - { - } - - std::size_t byte; - std::size_t line; - std::size_t byte_in_line; - std::string source; - }; - - inline std::ostream& operator<<( std::ostream& o, const position& p ) - { - return o << p.source << ':' << p.line << ':' << p.byte_in_line << '(' << p.byte << ')'; } - inline std::string to_string( const position& p ) - { - std::ostringstream o; - o << p; - return o.str(); - } + std::size_t byte; + std::size_t line; + std::size_t byte_in_line; + std::string source; + }; - } // namespace TAO_PEGTL_NAMESPACE + inline std::ostream& operator<<( std::ostream& o, const position& p ) + { + return o << p.source << ':' << p.line << ':' << p.byte_in_line << '(' << p.byte << ')'; + } + + [[nodiscard]] inline std::string to_string( const position& p ) + { + std::ostringstream o; + o << p; + return o.str(); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/read_input.hpp b/packages/PEGTL/include/tao/pegtl/read_input.hpp index 8d7eb0481..72be702fd 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_READ_INPUT_HPP @@ -13,68 +13,62 @@ #include "internal/file_reader.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace internal { - namespace internal + struct filename_holder { - struct filename_holder - { - const std::string filename; + const std::string filename; - template< typename T > - explicit filename_holder( T&& in_filename ) - : filename( std::forward< T >( in_filename ) ) - { - } + template< typename T > + explicit filename_holder( T&& in_filename ) + : filename( std::forward< T >( in_filename ) ) + { + } - filename_holder( const filename_holder& ) = delete; - filename_holder( filename_holder&& ) = delete; + filename_holder( const filename_holder& ) = delete; + filename_holder( filename_holder&& ) = delete; - ~filename_holder() = default; + ~filename_holder() = default; - void operator=( const filename_holder& ) = delete; - void operator=( filename_holder&& ) = delete; - }; + void operator=( const filename_holder& ) = delete; + void operator=( filename_holder&& ) = delete; + }; - } // namespace internal + } // namespace internal - template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf > - struct read_input - : private internal::filename_holder, - public string_input< P, Eol, const char* > + template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > + struct read_input + : private internal::filename_holder, + public string_input< P, Eol, const char* > + { + template< typename T > + explicit read_input( T&& in_filename ) + : internal::filename_holder( std::forward< T >( in_filename ) ), + string_input< P, Eol, const char* >( internal::file_reader( filename.c_str() ).read(), filename.c_str() ) { - template< typename T > - explicit read_input( T&& in_filename ) - : internal::filename_holder( std::forward< T >( in_filename ) ), - string_input< P, Eol, const char* >( internal::file_reader( filename.c_str() ).read(), filename.c_str() ) - { - } - - template< typename T > - read_input( FILE* in_file, T&& in_filename ) - : internal::filename_holder( std::forward< T >( in_filename ) ), - string_input< P, Eol, const char* >( internal::file_reader( in_file, filename.c_str() ).read(), filename.c_str() ) - { - } + } - read_input( const read_input& ) = delete; - read_input( read_input&& ) = delete; + template< typename T > + read_input( FILE* in_file, T&& in_filename ) + : internal::filename_holder( std::forward< T >( in_filename ) ), + string_input< P, Eol, const char* >( internal::file_reader( in_file, filename.c_str() ).read(), filename.c_str() ) + { + } - ~read_input() = default; + read_input( const read_input& ) = delete; + read_input( read_input&& ) = delete; - void operator=( const read_input& ) = delete; - void operator=( read_input&& ) = delete; - }; + ~read_input() = default; -#ifdef __cpp_deduction_guides - template< typename... Ts > - explicit read_input( Ts&&... )->read_input<>; -#endif + void operator=( const read_input& ) = delete; + void operator=( read_input&& ) = delete; + }; - } // namespace TAO_PEGTL_NAMESPACE + template< typename... Ts > + explicit read_input( Ts&&... )->read_input<>; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/require_apply.hpp b/packages/PEGTL/include/tao/pegtl/require_apply.hpp new file mode 100644 index 000000000..66d46715d --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/require_apply.hpp @@ -0,0 +1,16 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_REQUIRE_APPLY_HPP +#define TAO_PEGTL_REQUIRE_APPLY_HPP + +#include "config.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + struct require_apply + {}; + +} // namespace TAO_PEGTL_NAMESPACE + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/require_apply0.hpp b/packages/PEGTL/include/tao/pegtl/require_apply0.hpp new file mode 100644 index 000000000..af95110b3 --- /dev/null +++ b/packages/PEGTL/include/tao/pegtl/require_apply0.hpp @@ -0,0 +1,16 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#ifndef TAO_PEGTL_REQUIRE_APPLY0_HPP +#define TAO_PEGTL_REQUIRE_APPLY0_HPP + +#include "config.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + struct require_apply0 + {}; + +} // namespace TAO_PEGTL_NAMESPACE + +#endif diff --git a/packages/PEGTL/include/tao/pegtl/rewind_mode.hpp b/packages/PEGTL/include/tao/pegtl/rewind_mode.hpp index c12fddc88..0d9ad32c0 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_REWIND_MODE_HPP @@ -6,19 +6,15 @@ #include "config.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + enum class rewind_mode : char { - enum class rewind_mode : char - { - ACTIVE, - REQUIRED, - DONTCARE - }; + active, + required, + dontcare + }; - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/rules.hpp b/packages/PEGTL/include/tao/pegtl/rules.hpp index 53364a40c..7ec5b8494 100644 --- a/packages/PEGTL/include/tao/pegtl/rules.hpp +++ b/packages/PEGTL/include/tao/pegtl/rules.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_RULES_HPP @@ -9,62 +9,59 @@ #include "internal/rules.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE - { - // clang-format off - template< typename... Actions > struct apply : internal::apply< Actions... > {}; - template< typename... Actions > struct apply0 : internal::apply0< Actions... > {}; - template< template< typename... > class Action, typename... Rules > struct action : internal::action< Action, Rules... > {}; - template< typename... Rules > struct at : internal::at< Rules... > {}; - struct bof : internal::bof {}; - struct bol : internal::bol {}; - template< unsigned Num > struct bytes : internal::bytes< Num > {}; - template< template< typename... > class Control, typename... Rules > struct control : internal::control< Control, Rules... > {}; - template< typename... Rules > struct disable : internal::disable< Rules... > {}; - struct discard : internal::discard {}; - template< typename... Rules > struct enable : internal::enable< Rules... > {}; - struct eof : internal::eof {}; - struct failure : internal::trivial< false > {}; - template< typename Rule, typename... Actions > struct if_apply : internal::if_apply< Rule, Actions... > {}; - template< typename Cond, typename... Thens > struct if_must : internal::if_must< false, Cond, Thens... > {}; - template< typename Cond, typename Then, typename Else > struct if_must_else : internal::if_must_else< Cond, Then, Else > {}; - template< typename Cond, typename Then, typename Else > struct if_then_else : internal::if_then_else< Cond, Then, Else > {}; - template< typename Rule, typename Sep, typename Pad = void > struct list : internal::list< Rule, internal::pad< Sep, Pad > > {}; - template< typename Rule, typename Sep > struct list< Rule, Sep, void > : internal::list< Rule, Sep > {}; - template< typename Rule, typename Sep, typename Pad = void > struct list_must : internal::list_must< Rule, internal::pad< Sep, Pad > > {}; - template< typename Rule, typename Sep > struct list_must< Rule, Sep, void > : internal::list_must< Rule, Sep > {}; - template< typename Rule, typename Sep, typename Pad = void > struct list_tail : internal::list_tail_pad< Rule, Sep, Pad > {}; - template< typename Rule, typename Sep > struct list_tail< Rule, Sep, void > : internal::list_tail< Rule, Sep > {}; - template< typename M, typename S > struct minus : internal::minus< M, S > {}; - template< typename... Rules > struct must : internal::must< Rules... > {}; - template< typename... Rules > struct not_at : internal::not_at< Rules... > {}; - template< typename... Rules > struct opt : internal::opt< Rules... > {}; - template< typename Cond, typename... Rules > struct opt_must : internal::if_must< true, Cond, 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 plus : internal::plus< Rule, Rules... > {}; - template< typename Exception > struct raise : internal::raise< Exception > {}; - template< unsigned Num, typename... Rules > struct rep : internal::rep< Num, Rules... > {}; - template< unsigned Max, typename... Rules > struct rep_max : internal::rep_min_max< 0, Max, Rules... > {}; - template< unsigned Min, typename Rule, typename... Rules > struct rep_min : internal::rep_min< Min, Rule, Rules... > {}; - template< unsigned Min, unsigned Max, typename... Rules > struct rep_min_max : internal::rep_min_max< Min, Max, Rules... > {}; - template< unsigned Max, typename... Rules > struct rep_opt : internal::rep_opt< Max, Rules... > {}; - template< unsigned Amount > struct require : internal::require< Amount > {}; - 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 Cond, typename... Rules > struct star_must : internal::star_must< Cond, Rules... > {}; - template< typename State, typename... Rules > struct state : internal::state< State, Rules... > {}; - struct success : internal::trivial< true > {}; - template< typename... Rules > struct try_catch : internal::try_catch_type< parse_error, Rules... > {}; - template< typename Exception, typename... Rules > struct try_catch_type : internal::try_catch_type< Exception, Rules... > {}; - template< typename Cond, typename... Rules > struct until : internal::until< Cond, Rules... > {}; - // clang-format on + // clang-format off + template< typename... Actions > struct apply : internal::apply< Actions... > {}; + template< typename... Actions > struct apply0 : internal::apply0< Actions... > {}; + template< template< typename... > class Action, typename... Rules > struct action : internal::action< Action, Rules... > {}; + template< typename... Rules > struct at : internal::at< Rules... > {}; + struct bof : internal::bof {}; + struct bol : internal::bol {}; + template< unsigned Num > struct bytes : internal::bytes< Num > {}; + template< template< typename... > class Control, typename... Rules > struct control : internal::control< Control, Rules... > {}; + template< typename... Rules > struct disable : internal::disable< Rules... > {}; + struct discard : internal::discard {}; + template< typename... Rules > struct enable : internal::enable< Rules... > {}; + struct eof : internal::eof {}; + struct failure : internal::trivial< false > {}; + template< typename Rule, typename... Actions > struct if_apply : internal::if_apply< Rule, Actions... > {}; + template< typename Cond, typename... Thens > struct if_must : internal::if_must< false, Cond, Thens... > {}; + template< typename Cond, typename Then, typename Else > struct if_must_else : internal::if_must_else< Cond, Then, Else > {}; + template< typename Cond, typename Then, typename Else > struct if_then_else : internal::if_then_else< Cond, Then, Else > {}; + template< typename Rule, typename Sep, typename Pad = void > struct list : internal::list< Rule, internal::pad< Sep, Pad > > {}; + template< typename Rule, typename Sep > struct list< Rule, Sep, void > : internal::list< Rule, Sep > {}; + template< typename Rule, typename Sep, typename Pad = void > struct list_must : internal::list_must< Rule, internal::pad< Sep, Pad > > {}; + template< typename Rule, typename Sep > struct list_must< Rule, Sep, void > : internal::list_must< Rule, Sep > {}; + template< typename Rule, typename Sep, typename Pad = void > struct list_tail : internal::list_tail_pad< Rule, Sep, Pad > {}; + template< typename Rule, typename Sep > struct list_tail< Rule, Sep, void > : internal::list_tail< Rule, Sep > {}; + template< typename M, typename S > struct minus : internal::rematch< M, internal::not_at< S, internal::eof > > {}; + template< typename... Rules > struct must : internal::must< Rules... > {}; + template< typename... Rules > struct not_at : internal::not_at< Rules... > {}; + template< typename... Rules > struct opt : internal::opt< Rules... > {}; + template< typename Cond, typename... Rules > struct opt_must : internal::if_must< true, Cond, 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 plus : internal::plus< Rule, Rules... > {}; + template< typename Exception > struct raise : internal::raise< Exception > {}; + template< typename Head, typename... Rules > struct rematch : internal::rematch< Head, Rules... > {}; + template< unsigned Num, typename... Rules > struct rep : internal::rep< Num, Rules... > {}; + template< unsigned Max, typename... Rules > struct rep_max : internal::rep_min_max< 0, Max, Rules... > {}; + template< unsigned Min, typename Rule, typename... Rules > struct rep_min : internal::rep_min< Min, Rule, Rules... > {}; + template< unsigned Min, unsigned Max, typename... Rules > struct rep_min_max : internal::rep_min_max< Min, Max, Rules... > {}; + template< unsigned Max, typename... Rules > struct rep_opt : internal::rep_opt< Max, Rules... > {}; + template< unsigned Amount > struct require : internal::require< Amount > {}; + 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 Cond, typename... Rules > struct star_must : internal::star_must< Cond, Rules... > {}; + template< typename State, typename... Rules > struct state : internal::state< State, Rules... > {}; + struct success : internal::trivial< true > {}; + template< typename... Rules > struct try_catch : internal::try_catch_type< parse_error, Rules... > {}; + template< typename Exception, typename... Rules > struct try_catch_type : internal::try_catch_type< Exception, Rules... > {}; + template< typename Cond, typename... Rules > struct until : internal::until< Cond, Rules... > {}; + // clang-format on - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/string_input.hpp b/packages/PEGTL/include/tao/pegtl/string_input.hpp index ebce2361f..f1b59b128 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_STRING_INPUT_HPP @@ -12,61 +12,55 @@ #include "memory_input.hpp" #include "tracking_mode.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace internal { - namespace internal + struct string_holder { - struct string_holder - { - const std::string data; + const std::string data; - template< typename T > - explicit string_holder( T&& in_data ) - : data( std::forward< T >( in_data ) ) - { - } + template< typename T > + explicit string_holder( T&& in_data ) + : data( std::forward< T >( in_data ) ) + { + } - string_holder( const string_holder& ) = delete; - string_holder( string_holder&& ) = delete; + string_holder( const string_holder& ) = delete; + string_holder( string_holder&& ) = delete; - ~string_holder() = default; + ~string_holder() = default; - void operator=( const string_holder& ) = delete; - void operator=( string_holder&& ) = delete; - }; + void operator=( const string_holder& ) = delete; + void operator=( string_holder&& ) = delete; + }; - } // namespace internal + } // namespace internal - template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf, typename Source = std::string > - struct string_input - : private internal::string_holder, - public memory_input< P, Eol, Source > + template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf, typename Source = std::string > + struct string_input + : private internal::string_holder, + public memory_input< P, Eol, Source > + { + template< typename V, typename T, typename... Ts > + explicit string_input( V&& in_data, T&& in_source, Ts&&... ts ) + : internal::string_holder( std::forward< V >( in_data ) ), + memory_input< P, Eol, Source >( data.data(), data.size(), std::forward< T >( in_source ), std::forward< Ts >( ts )... ) { - template< typename V, typename T, typename... Ts > - explicit string_input( V&& in_data, T&& in_source, Ts&&... ts ) - : internal::string_holder( std::forward< V >( in_data ) ), - memory_input< P, Eol, Source >( data.data(), data.size(), std::forward< T >( in_source ), std::forward< Ts >( ts )... ) - { - } + } - string_input( const string_input& ) = delete; - string_input( string_input&& ) = delete; + string_input( const string_input& ) = delete; + string_input( string_input&& ) = delete; - ~string_input() = default; + ~string_input() = default; - void operator=( const string_input& ) = delete; - void operator=( string_input&& ) = delete; - }; - -#ifdef __cpp_deduction_guides - template< typename... Ts > - explicit string_input( Ts&&... )->string_input<>; -#endif + void operator=( const string_input& ) = delete; + void operator=( string_input&& ) = delete; + }; - } // namespace TAO_PEGTL_NAMESPACE + template< typename... Ts > + explicit string_input( Ts&&... )->string_input<>; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/tracking_mode.hpp b/packages/PEGTL/include/tao/pegtl/tracking_mode.hpp index c470042d5..ba58b5c07 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_TRACKING_MODE_HPP @@ -6,18 +6,14 @@ #include "config.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + enum class tracking_mode : bool { - enum class tracking_mode : bool - { - IMMEDIATE, - LAZY - }; + eager, + lazy + }; - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/uint16.hpp b/packages/PEGTL/include/tao/pegtl/uint16.hpp index d913ed2f6..80be64908 100644 --- a/packages/PEGTL/include/tao/pegtl/uint16.hpp +++ b/packages/PEGTL/include/tao/pegtl/uint16.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_UINT16_HPP @@ -11,56 +11,52 @@ #include "internal/result_on_found.hpp" #include "internal/rules.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace uint16_be { - namespace uint16_be - { - // clang-format off - struct any : internal::any< internal::peek_uint16_be > {}; - - template< std::uint16_t... Cs > struct not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_uint16_be, Cs... > {}; - template< std::uint16_t Lo, std::uint16_t Hi > struct not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_uint16_be, Lo, Hi > {}; - template< std::uint16_t... Cs > struct one : internal::one< internal::result_on_found::SUCCESS, internal::peek_uint16_be, Cs... > {}; - template< std::uint16_t Lo, std::uint16_t Hi > struct range : internal::range< internal::result_on_found::SUCCESS, internal::peek_uint16_be, Lo, Hi > {}; - template< std::uint16_t... Cs > struct ranges : internal::ranges< internal::peek_uint16_be, Cs... > {}; - template< std::uint16_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_uint16_be, Cs >... > {}; - - template< std::uint16_t M, std::uint16_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_mask_uint16_be< M >, Cs... > {}; - template< std::uint16_t M, std::uint16_t Lo, std::uint16_t Hi > struct mask_not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_mask_uint16_be< M >, Lo, Hi > {}; - template< std::uint16_t M, std::uint16_t... Cs > struct mask_one : internal::one< internal::result_on_found::SUCCESS, internal::peek_mask_uint16_be< M >, Cs... > {}; - template< std::uint16_t M, std::uint16_t Lo, std::uint16_t Hi > struct mask_range : internal::range< internal::result_on_found::SUCCESS, internal::peek_mask_uint16_be< M >, Lo, Hi > {}; - template< std::uint16_t M, std::uint16_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint16_be< M >, Cs... > {}; - template< std::uint16_t M, std::uint16_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_mask_uint16_be< M >, Cs >... > {}; - // clang-format on - - } // namespace uint16_be - - namespace uint16_le - { - // clang-format off - struct any : internal::any< internal::peek_uint16_le > {}; - - template< std::uint16_t... Cs > struct not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_uint16_le, Cs... > {}; - template< std::uint16_t Lo, std::uint16_t Hi > struct not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_uint16_le, Lo, Hi > {}; - template< std::uint16_t... Cs > struct one : internal::one< internal::result_on_found::SUCCESS, internal::peek_uint16_le, Cs... > {}; - template< std::uint16_t Lo, std::uint16_t Hi > struct range : internal::range< internal::result_on_found::SUCCESS, internal::peek_uint16_le, Lo, Hi > {}; - template< std::uint16_t... Cs > struct ranges : internal::ranges< internal::peek_uint16_le, Cs... > {}; - template< std::uint16_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_uint16_le, Cs >... > {}; - - template< std::uint16_t M, std::uint16_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_mask_uint16_le< M >, Cs... > {}; - template< std::uint16_t M, std::uint16_t Lo, std::uint16_t Hi > struct mask_not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_mask_uint16_le< M >, Lo, Hi > {}; - template< std::uint16_t M, std::uint16_t... Cs > struct mask_one : internal::one< internal::result_on_found::SUCCESS, internal::peek_mask_uint16_le< M >, Cs... > {}; - template< std::uint16_t M, std::uint16_t Lo, std::uint16_t Hi > struct mask_range : internal::range< internal::result_on_found::SUCCESS, internal::peek_mask_uint16_le< M >, Lo, Hi > {}; - template< std::uint16_t M, std::uint16_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint16_le< M >, Cs... > {}; - template< std::uint16_t M, std::uint16_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_mask_uint16_le< M >, Cs >... > {}; - // clang-format on - - } // namespace uint16_le - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + // clang-format off + struct any : internal::any< internal::peek_uint16_be > {}; + + template< std::uint16_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint16_be, Cs... > {}; + template< std::uint16_t Lo, std::uint16_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint16_be, Lo, Hi > {}; + template< std::uint16_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint16_be, Cs... > {}; + template< std::uint16_t Lo, std::uint16_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint16_be, Lo, Hi > {}; + template< std::uint16_t... Cs > struct ranges : internal::ranges< internal::peek_uint16_be, Cs... > {}; + template< std::uint16_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint16_be, Cs >... > {}; + + template< std::uint16_t M, std::uint16_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint16_be< M >, Cs... > {}; + template< std::uint16_t M, std::uint16_t Lo, std::uint16_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint16_be< M >, Lo, Hi > {}; + template< std::uint16_t M, std::uint16_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint16_be< M >, Cs... > {}; + template< std::uint16_t M, std::uint16_t Lo, std::uint16_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint16_be< M >, Lo, Hi > {}; + template< std::uint16_t M, std::uint16_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint16_be< M >, Cs... > {}; + template< std::uint16_t M, std::uint16_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint16_be< M >, Cs >... > {}; + // clang-format on + + } // namespace uint16_be + + namespace uint16_le + { + // clang-format off + struct any : internal::any< internal::peek_uint16_le > {}; + + template< std::uint16_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint16_le, Cs... > {}; + template< std::uint16_t Lo, std::uint16_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint16_le, Lo, Hi > {}; + template< std::uint16_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint16_le, Cs... > {}; + template< std::uint16_t Lo, std::uint16_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint16_le, Lo, Hi > {}; + template< std::uint16_t... Cs > struct ranges : internal::ranges< internal::peek_uint16_le, Cs... > {}; + template< std::uint16_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint16_le, Cs >... > {}; + + template< std::uint16_t M, std::uint16_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint16_le< M >, Cs... > {}; + template< std::uint16_t M, std::uint16_t Lo, std::uint16_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint16_le< M >, Lo, Hi > {}; + template< std::uint16_t M, std::uint16_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint16_le< M >, Cs... > {}; + template< std::uint16_t M, std::uint16_t Lo, std::uint16_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint16_le< M >, Lo, Hi > {}; + template< std::uint16_t M, std::uint16_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint16_le< M >, Cs... > {}; + template< std::uint16_t M, std::uint16_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint16_le< M >, Cs >... > {}; + // clang-format on + + } // namespace uint16_le + +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/uint32.hpp b/packages/PEGTL/include/tao/pegtl/uint32.hpp index 12f5617ce..60d85cf9d 100644 --- a/packages/PEGTL/include/tao/pegtl/uint32.hpp +++ b/packages/PEGTL/include/tao/pegtl/uint32.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_UINT32_HPP @@ -11,56 +11,52 @@ #include "internal/result_on_found.hpp" #include "internal/rules.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace uint32_be { - namespace uint32_be - { - // clang-format off - struct any : internal::any< internal::peek_uint32_be > {}; - - template< std::uint32_t... Cs > struct not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_uint32_be, Cs... > {}; - template< std::uint32_t Lo, std::uint32_t Hi > struct not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_uint32_be, Lo, Hi > {}; - template< std::uint32_t... Cs > struct one : internal::one< internal::result_on_found::SUCCESS, internal::peek_uint32_be, Cs... > {}; - template< std::uint32_t Lo, std::uint32_t Hi > struct range : internal::range< internal::result_on_found::SUCCESS, internal::peek_uint32_be, Lo, Hi > {}; - template< std::uint32_t... Cs > struct ranges : internal::ranges< internal::peek_uint32_be, Cs... > {}; - template< std::uint32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_uint32_be, Cs >... > {}; - - template< std::uint32_t M, std::uint32_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_mask_uint32_be< M >, Cs... > {}; - template< std::uint32_t M, std::uint32_t Lo, std::uint32_t Hi > struct mask_not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_mask_uint32_be< M >, Lo, Hi > {}; - template< std::uint32_t M, std::uint32_t... Cs > struct mask_one : internal::one< internal::result_on_found::SUCCESS, internal::peek_mask_uint32_be< M >, Cs... > {}; - template< std::uint32_t M, std::uint32_t Lo, std::uint32_t Hi > struct mask_range : internal::range< internal::result_on_found::SUCCESS, internal::peek_mask_uint32_be< M >, Lo, Hi > {}; - template< std::uint32_t M, std::uint32_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint32_be< M >, Cs... > {}; - template< std::uint32_t M, std::uint32_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_mask_uint32_be< M >, Cs >... > {}; - // clang-format on - - } // namespace uint32_be - - namespace uint32_le - { - // clang-format off - struct any : internal::any< internal::peek_uint32_le > {}; - - template< std::uint32_t... Cs > struct not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_uint32_le, Cs... > {}; - template< std::uint32_t Lo, std::uint32_t Hi > struct not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_uint32_le, Lo, Hi > {}; - template< std::uint32_t... Cs > struct one : internal::one< internal::result_on_found::SUCCESS, internal::peek_uint32_le, Cs... > {}; - template< std::uint32_t Lo, std::uint32_t Hi > struct range : internal::range< internal::result_on_found::SUCCESS, internal::peek_uint32_le, Lo, Hi > {}; - template< std::uint32_t... Cs > struct ranges : internal::ranges< internal::peek_uint32_le, Cs... > {}; - template< std::uint32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_uint32_le, Cs >... > {}; - - template< std::uint32_t M, std::uint32_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_mask_uint32_le< M >, Cs... > {}; - template< std::uint32_t M, std::uint32_t Lo, std::uint32_t Hi > struct mask_not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_mask_uint32_le< M >, Lo, Hi > {}; - template< std::uint32_t M, std::uint32_t... Cs > struct mask_one : internal::one< internal::result_on_found::SUCCESS, internal::peek_mask_uint32_le< M >, Cs... > {}; - template< std::uint32_t M, std::uint32_t Lo, std::uint32_t Hi > struct mask_range : internal::range< internal::result_on_found::SUCCESS, internal::peek_mask_uint32_le< M >, Lo, Hi > {}; - template< std::uint32_t M, std::uint32_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint32_le< M >, Cs... > {}; - template< std::uint32_t M, std::uint32_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_mask_uint32_le< M >, Cs >... > {}; - // clang-format on - - } // namespace uint32_le - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + // clang-format off + struct any : internal::any< internal::peek_uint32_be > {}; + + template< std::uint32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint32_be, Cs... > {}; + template< std::uint32_t Lo, std::uint32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint32_be, Lo, Hi > {}; + template< std::uint32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint32_be, Cs... > {}; + template< std::uint32_t Lo, std::uint32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint32_be, Lo, Hi > {}; + template< std::uint32_t... Cs > struct ranges : internal::ranges< internal::peek_uint32_be, Cs... > {}; + template< std::uint32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint32_be, Cs >... > {}; + + template< std::uint32_t M, std::uint32_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint32_be< M >, Cs... > {}; + template< std::uint32_t M, std::uint32_t Lo, std::uint32_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint32_be< M >, Lo, Hi > {}; + template< std::uint32_t M, std::uint32_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint32_be< M >, Cs... > {}; + template< std::uint32_t M, std::uint32_t Lo, std::uint32_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint32_be< M >, Lo, Hi > {}; + template< std::uint32_t M, std::uint32_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint32_be< M >, Cs... > {}; + template< std::uint32_t M, std::uint32_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint32_be< M >, Cs >... > {}; + // clang-format on + + } // namespace uint32_be + + namespace uint32_le + { + // clang-format off + struct any : internal::any< internal::peek_uint32_le > {}; + + template< std::uint32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint32_le, Cs... > {}; + template< std::uint32_t Lo, std::uint32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint32_le, Lo, Hi > {}; + template< std::uint32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint32_le, Cs... > {}; + template< std::uint32_t Lo, std::uint32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint32_le, Lo, Hi > {}; + template< std::uint32_t... Cs > struct ranges : internal::ranges< internal::peek_uint32_le, Cs... > {}; + template< std::uint32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint32_le, Cs >... > {}; + + template< std::uint32_t M, std::uint32_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint32_le< M >, Cs... > {}; + template< std::uint32_t M, std::uint32_t Lo, std::uint32_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint32_le< M >, Lo, Hi > {}; + template< std::uint32_t M, std::uint32_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint32_le< M >, Cs... > {}; + template< std::uint32_t M, std::uint32_t Lo, std::uint32_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint32_le< M >, Lo, Hi > {}; + template< std::uint32_t M, std::uint32_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint32_le< M >, Cs... > {}; + template< std::uint32_t M, std::uint32_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint32_le< M >, Cs >... > {}; + // clang-format on + + } // namespace uint32_le + +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/uint64.hpp b/packages/PEGTL/include/tao/pegtl/uint64.hpp index f6d2f7c49..5507c5be7 100644 --- a/packages/PEGTL/include/tao/pegtl/uint64.hpp +++ b/packages/PEGTL/include/tao/pegtl/uint64.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_UINT64_HPP @@ -11,57 +11,53 @@ #include "internal/result_on_found.hpp" #include "internal/rules.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace uint64_be { - namespace uint64_be - { - // clang-format off - struct any : internal::any< internal::peek_uint64_be > {}; + // clang-format off + struct any : internal::any< internal::peek_uint64_be > {}; - template< std::uint64_t... Cs > struct not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_uint64_be, Cs... > {}; - template< std::uint64_t Lo, std::uint64_t Hi > struct not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_uint64_be, Lo, Hi > {}; - template< std::uint64_t... Cs > struct one : internal::one< internal::result_on_found::SUCCESS, internal::peek_uint64_be, Cs... > {}; - template< std::uint64_t Lo, std::uint64_t Hi > struct range : internal::range< internal::result_on_found::SUCCESS, internal::peek_uint64_be, Lo, Hi > {}; - template< std::uint64_t... Cs > struct ranges : internal::ranges< internal::peek_uint64_be, Cs... > {}; - template< std::uint64_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_uint64_be, Cs >... > {}; + template< std::uint64_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint64_be, Cs... > {}; + template< std::uint64_t Lo, std::uint64_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint64_be, Lo, Hi > {}; + template< std::uint64_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint64_be, Cs... > {}; + template< std::uint64_t Lo, std::uint64_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint64_be, Lo, Hi > {}; + template< std::uint64_t... Cs > struct ranges : internal::ranges< internal::peek_uint64_be, Cs... > {}; + template< std::uint64_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint64_be, Cs >... > {}; - template< std::uint64_t M, std::uint64_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_mask_uint64_be< M >, Cs... > {}; - template< std::uint64_t M, std::uint64_t Lo, std::uint64_t Hi > struct mask_not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_mask_uint64_be< M >, Lo, Hi > {}; - template< std::uint64_t M, std::uint64_t... Cs > struct mask_one : internal::one< internal::result_on_found::SUCCESS, internal::peek_mask_uint64_be< M >, Cs... > {}; - template< std::uint64_t M, std::uint64_t Lo, std::uint64_t Hi > struct mask_range : internal::range< internal::result_on_found::SUCCESS, internal::peek_mask_uint64_be< M >, Lo, Hi > {}; - template< std::uint64_t M, std::uint64_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint64_be< M >, Cs... > {}; - template< std::uint64_t M, std::uint64_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_mask_uint64_be< M >, Cs >... > {}; - // clang-format on + template< std::uint64_t M, std::uint64_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint64_be< M >, Cs... > {}; + template< std::uint64_t M, std::uint64_t Lo, std::uint64_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint64_be< M >, Lo, Hi > {}; + template< std::uint64_t M, std::uint64_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint64_be< M >, Cs... > {}; + template< std::uint64_t M, std::uint64_t Lo, std::uint64_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint64_be< M >, Lo, Hi > {}; + template< std::uint64_t M, std::uint64_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint64_be< M >, Cs... > {}; + template< std::uint64_t M, std::uint64_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint64_be< M >, Cs >... > {}; + // clang-format on - } // namespace uint64_be + } // namespace uint64_be - namespace uint64_le - { - // clang-format off - struct any : internal::any< internal::peek_uint64_le > {}; - - template< std::uint64_t... Cs > struct not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_uint64_le, Cs... > {}; - template< std::uint64_t Lo, std::uint64_t Hi > struct not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_uint64_le, Lo, Hi > {}; - template< std::uint64_t... Cs > struct one : internal::one< internal::result_on_found::SUCCESS, internal::peek_uint64_le, Cs... > {}; - template< std::uint64_t Lo, std::uint64_t Hi > struct range : internal::range< internal::result_on_found::SUCCESS, internal::peek_uint64_le, Lo, Hi > {}; - template< std::uint64_t... Cs > struct ranges : internal::ranges< internal::peek_uint64_le, Cs... > {}; - template< std::uint64_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_uint64_le, Cs >... > {}; - - template< std::uint64_t M, std::uint64_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_mask_uint64_le< M >, Cs... > {}; - template< std::uint64_t M, std::uint64_t Lo, std::uint64_t Hi > struct mask_not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_mask_uint64_le< M >, Lo, Hi > {}; - template< std::uint64_t M, std::uint64_t... Cs > struct mask_one : internal::one< internal::result_on_found::SUCCESS, internal::peek_mask_uint64_le< M >, Cs... > {}; - template< std::uint64_t M, std::uint64_t Lo, std::uint64_t Hi > struct mask_range : internal::range< internal::result_on_found::SUCCESS, internal::peek_mask_uint64_le< M >, Lo, Hi > {}; - template< std::uint64_t M, std::uint64_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint64_le< M >, Cs... > {}; - template< std::uint64_t M, std::uint64_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_mask_uint64_le< M >, Cs >... > {}; - // clang-format on - - } // namespace uint64_le - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + namespace uint64_le + { + // clang-format off + struct any : internal::any< internal::peek_uint64_le > {}; + + template< std::uint64_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint64_le, Cs... > {}; + template< std::uint64_t Lo, std::uint64_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint64_le, Lo, Hi > {}; + template< std::uint64_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint64_le, Cs... > {}; + template< std::uint64_t Lo, std::uint64_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint64_le, Lo, Hi > {}; + template< std::uint64_t... Cs > struct ranges : internal::ranges< internal::peek_uint64_le, Cs... > {}; + template< std::uint64_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint64_le, Cs >... > {}; + + template< std::uint64_t M, std::uint64_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint64_le< M >, Cs... > {}; + template< std::uint64_t M, std::uint64_t Lo, std::uint64_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint64_le< M >, Lo, Hi > {}; + template< std::uint64_t M, std::uint64_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint64_le< M >, Cs... > {}; + template< std::uint64_t M, std::uint64_t Lo, std::uint64_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint64_le< M >, Lo, Hi > {}; + template< std::uint64_t M, std::uint64_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint64_le< M >, Cs... > {}; + template< std::uint64_t M, std::uint64_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint64_le< M >, Cs >... > {}; + // clang-format on + + } // namespace uint64_le + +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/uint8.hpp b/packages/PEGTL/include/tao/pegtl/uint8.hpp index 694c40b30..122502656 100644 --- a/packages/PEGTL/include/tao/pegtl/uint8.hpp +++ b/packages/PEGTL/include/tao/pegtl/uint8.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_UINT8_HPP @@ -11,34 +11,26 @@ #include "internal/result_on_found.hpp" #include "internal/rules.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::uint8 { - namespace TAO_PEGTL_NAMESPACE - { - namespace uint8 - { - // clang-format off - struct any : internal::any< internal::peek_uint8 > {}; - - template< std::uint8_t... Cs > struct not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_uint8, Cs... > {}; - template< std::uint8_t Lo, std::uint8_t Hi > struct not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_uint8, Lo, Hi > {}; - template< std::uint8_t... Cs > struct one : internal::one< internal::result_on_found::SUCCESS, internal::peek_uint8, Cs... > {}; - template< std::uint8_t Lo, std::uint8_t Hi > struct range : internal::range< internal::result_on_found::SUCCESS, internal::peek_uint8, Lo, Hi > {}; - template< std::uint8_t... Cs > struct ranges : internal::ranges< internal::peek_uint8, Cs... > {}; - template< std::uint8_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_uint8, Cs >... > {}; - - template< std::uint8_t M, std::uint8_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_mask_uint8< M >, Cs... > {}; - template< std::uint8_t M, std::uint8_t Lo, std::uint8_t Hi > struct mask_not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_mask_uint8< M >, Lo, Hi > {}; - template< std::uint8_t M, std::uint8_t... Cs > struct mask_one : internal::one< internal::result_on_found::SUCCESS, internal::peek_mask_uint8< M >, Cs... > {}; - template< std::uint8_t M, std::uint8_t Lo, std::uint8_t Hi > struct mask_range : internal::range< internal::result_on_found::SUCCESS, internal::peek_mask_uint8< M >, Lo, Hi > {}; - template< std::uint8_t M, std::uint8_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint8< M >, Cs... > {}; - template< std::uint8_t M, std::uint8_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_mask_uint8< M >, Cs >... > {}; - // clang-format on - - } // namespace uint8 - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + // clang-format off + struct any : internal::any< internal::peek_uint8 > {}; + + template< std::uint8_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_uint8, Cs... > {}; + template< std::uint8_t Lo, std::uint8_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_uint8, Lo, Hi > {}; + template< std::uint8_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_uint8, Cs... > {}; + template< std::uint8_t Lo, std::uint8_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_uint8, Lo, Hi > {}; + template< std::uint8_t... Cs > struct ranges : internal::ranges< internal::peek_uint8, Cs... > {}; + template< std::uint8_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_uint8, Cs >... > {}; + + template< std::uint8_t M, std::uint8_t... Cs > struct mask_not_one : internal::one< internal::result_on_found::failure, internal::peek_mask_uint8< M >, Cs... > {}; + template< std::uint8_t M, std::uint8_t Lo, std::uint8_t Hi > struct mask_not_range : internal::range< internal::result_on_found::failure, internal::peek_mask_uint8< M >, Lo, Hi > {}; + template< std::uint8_t M, std::uint8_t... Cs > struct mask_one : internal::one< internal::result_on_found::success, internal::peek_mask_uint8< M >, Cs... > {}; + template< std::uint8_t M, std::uint8_t Lo, std::uint8_t Hi > struct mask_range : internal::range< internal::result_on_found::success, internal::peek_mask_uint8< M >, Lo, Hi > {}; + template< std::uint8_t M, std::uint8_t... Cs > struct mask_ranges : internal::ranges< internal::peek_mask_uint8< M >, Cs... > {}; + template< std::uint8_t M, std::uint8_t... Cs > struct mask_string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_mask_uint8< M >, Cs >... > {}; + // clang-format on + +} // namespace TAO_PEGTL_NAMESPACE::uint8 #endif diff --git a/packages/PEGTL/include/tao/pegtl/utf16.hpp b/packages/PEGTL/include/tao/pegtl/utf16.hpp index cb475971f..186d1e8e7 100644 --- a/packages/PEGTL/include/tao/pegtl/utf16.hpp +++ b/packages/PEGTL/include/tao/pegtl/utf16.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_UTF16_HPP @@ -10,44 +10,40 @@ #include "internal/result_on_found.hpp" #include "internal/rules.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace utf16_be { - namespace utf16_be - { - // clang-format off - struct any : internal::any< internal::peek_utf16_be > {}; - struct bom : internal::one< internal::result_on_found::SUCCESS, internal::peek_utf16_be, 0xfeff > {}; - template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_utf16_be, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_utf16_be, Lo, Hi > {}; - template< char32_t... Cs > struct one : internal::one< internal::result_on_found::SUCCESS, internal::peek_utf16_be, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::SUCCESS, internal::peek_utf16_be, Lo, Hi > {}; - template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf16_be, Cs... > {}; - template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_utf16_be, Cs >... > {}; - // clang-format on - - } // namespace utf16_be - - namespace utf16_le - { - // clang-format off - struct any : internal::any< internal::peek_utf16_le > {}; - struct bom : internal::one< internal::result_on_found::SUCCESS, internal::peek_utf16_le, 0xfeff > {}; - template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_utf16_le, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_utf16_le, Lo, Hi > {}; - template< char32_t... Cs > struct one : internal::one< internal::result_on_found::SUCCESS, internal::peek_utf16_le, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::SUCCESS, internal::peek_utf16_le, Lo, Hi > {}; - template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf16_le, Cs... > {}; - template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_utf16_le, Cs >... > {}; - // clang-format on - - } // namespace utf16_le - - namespace utf16 = TAO_PEGTL_NATIVE_UTF16; // NOLINT(misc-unused-alias-decls) - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + // clang-format off + struct any : internal::any< internal::peek_utf16_be > {}; + struct bom : internal::one< internal::result_on_found::success, internal::peek_utf16_be, 0xfeff > {}; + template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_utf16_be, Cs... > {}; + template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_utf16_be, Lo, Hi > {}; + template< char32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_utf16_be, Cs... > {}; + template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_utf16_be, Lo, Hi > {}; + template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf16_be, Cs... > {}; + template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_utf16_be, Cs >... > {}; + // clang-format on + + } // namespace utf16_be + + namespace utf16_le + { + // clang-format off + struct any : internal::any< internal::peek_utf16_le > {}; + struct bom : internal::one< internal::result_on_found::success, internal::peek_utf16_le, 0xfeff > {}; + template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_utf16_le, Cs... > {}; + template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_utf16_le, Lo, Hi > {}; + template< char32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_utf16_le, Cs... > {}; + template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_utf16_le, Lo, Hi > {}; + template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf16_le, Cs... > {}; + template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_utf16_le, Cs >... > {}; + // clang-format on + + } // namespace utf16_le + + namespace utf16 = TAO_PEGTL_NATIVE_UTF16; // NOLINT(misc-unused-alias-decls) + +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/utf32.hpp b/packages/PEGTL/include/tao/pegtl/utf32.hpp index 34e102f74..591a4cd20 100644 --- a/packages/PEGTL/include/tao/pegtl/utf32.hpp +++ b/packages/PEGTL/include/tao/pegtl/utf32.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_UTF32_HPP @@ -10,44 +10,40 @@ #include "internal/result_on_found.hpp" #include "internal/rules.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace utf32_be { - namespace utf32_be - { - // clang-format off - struct any : internal::any< internal::peek_utf32_be > {}; - struct bom : internal::one< internal::result_on_found::SUCCESS, internal::peek_utf32_be, 0xfeff > {}; - template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_utf32_be, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_utf32_be, Lo, Hi > {}; - template< char32_t... Cs > struct one : internal::one< internal::result_on_found::SUCCESS, internal::peek_utf32_be, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::SUCCESS, internal::peek_utf32_be, Lo, Hi > {}; - template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf32_be, Cs... > {}; - template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_utf32_be, Cs >... > {}; - // clang-format on - - } // namespace utf32_be - - namespace utf32_le - { - // clang-format off - struct any : internal::any< internal::peek_utf32_le > {}; - struct bom : internal::one< internal::result_on_found::SUCCESS, internal::peek_utf32_le, 0xfeff > {}; - template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_utf32_le, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_utf32_le, Lo, Hi > {}; - template< char32_t... Cs > struct one : internal::one< internal::result_on_found::SUCCESS, internal::peek_utf32_le, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::SUCCESS, internal::peek_utf32_le, Lo, Hi > {}; - template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf32_le, Cs... > {}; - template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_utf32_le, Cs >... > {}; - // clang-format on - - } // namespace utf32_le - - namespace utf32 = TAO_PEGTL_NATIVE_UTF32; // NOLINT(misc-unused-alias-decls) - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + // clang-format off + struct any : internal::any< internal::peek_utf32_be > {}; + struct bom : internal::one< internal::result_on_found::success, internal::peek_utf32_be, 0xfeff > {}; + template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_utf32_be, Cs... > {}; + template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_utf32_be, Lo, Hi > {}; + template< char32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_utf32_be, Cs... > {}; + template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_utf32_be, Lo, Hi > {}; + template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf32_be, Cs... > {}; + template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_utf32_be, Cs >... > {}; + // clang-format on + + } // namespace utf32_be + + namespace utf32_le + { + // clang-format off + struct any : internal::any< internal::peek_utf32_le > {}; + struct bom : internal::one< internal::result_on_found::success, internal::peek_utf32_le, 0xfeff > {}; + template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_utf32_le, Cs... > {}; + template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_utf32_le, Lo, Hi > {}; + template< char32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_utf32_le, Cs... > {}; + template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_utf32_le, Lo, Hi > {}; + template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf32_le, Cs... > {}; + template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_utf32_le, Cs >... > {}; + // clang-format on + + } // namespace utf32_le + + namespace utf32 = TAO_PEGTL_NATIVE_UTF32; // NOLINT(misc-unused-alias-decls) + +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/include/tao/pegtl/utf8.hpp b/packages/PEGTL/include/tao/pegtl/utf8.hpp index c76e83e3a..0f3cb4aea 100644 --- a/packages/PEGTL/include/tao/pegtl/utf8.hpp +++ b/packages/PEGTL/include/tao/pegtl/utf8.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_UTF8_HPP @@ -10,27 +10,19 @@ #include "internal/result_on_found.hpp" #include "internal/rules.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE::utf8 { - namespace TAO_PEGTL_NAMESPACE - { - namespace utf8 - { - // clang-format off - struct any : internal::any< internal::peek_utf8 > {}; - struct bom : internal::one< internal::result_on_found::SUCCESS, internal::peek_utf8, 0xfeff > {}; - template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_utf8, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_utf8, Lo, Hi > {}; - template< char32_t... Cs > struct one : internal::one< internal::result_on_found::SUCCESS, internal::peek_utf8, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::SUCCESS, internal::peek_utf8, Lo, Hi > {}; - template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf8, Cs... > {}; - template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_utf8, Cs >... > {}; - // clang-format on - - } // namespace utf8 - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + // clang-format off + struct any : internal::any< internal::peek_utf8 > {}; + struct bom : internal::one< internal::result_on_found::success, internal::peek_utf8, 0xfeff > {}; + template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::failure, internal::peek_utf8, Cs... > {}; + template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::failure, internal::peek_utf8, Lo, Hi > {}; + template< char32_t... Cs > struct one : internal::one< internal::result_on_found::success, internal::peek_utf8, Cs... > {}; + template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::success, internal::peek_utf8, Lo, Hi > {}; + template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf8, Cs... > {}; + template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::success, internal::peek_utf8, Cs >... > {}; + // clang-format on + +} // namespace TAO_PEGTL_NAMESPACE::utf8 #endif diff --git a/packages/PEGTL/include/tao/pegtl/version.hpp b/packages/PEGTL/include/tao/pegtl/version.hpp index 491c38b7f..6a11e3e0e 100644 --- a/packages/PEGTL/include/tao/pegtl/version.hpp +++ b/packages/PEGTL/include/tao/pegtl/version.hpp @@ -1,19 +1,13 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_VERSION_HPP #define TAO_PEGTL_VERSION_HPP -#define TAO_PEGTL_VERSION "2.7.1" +#define TAO_PEGTL_VERSION "3.0.0" -#define TAO_PEGTL_VERSION_MAJOR 2 -#define TAO_PEGTL_VERSION_MINOR 7 -#define TAO_PEGTL_VERSION_PATCH 1 - -// Compatibility, remove with 3.0 -#define TAOCPP_PEGTL_VERSION TAO_PEGTL_VERSION -#define TAOCPP_PEGTL_VERSION_MAJOR TAO_PEGTL_VERSION_MAJOR -#define TAOCPP_PEGTL_VERSION_MINOR TAO_PEGTL_VERSION_MINOR -#define TAOCPP_PEGTL_VERSION_PATCH TAO_PEGTL_VERSION_PATCH +#define TAO_PEGTL_VERSION_MAJOR 3 +#define TAO_PEGTL_VERSION_MINOR 0 +#define TAO_PEGTL_VERSION_PATCH 0 #endif diff --git a/packages/PEGTL/src/example/pegtl/CMakeLists.txt b/packages/PEGTL/src/example/pegtl/CMakeLists.txt index c904012ef..2fed9a883 100644 --- a/packages/PEGTL/src/example/pegtl/CMakeLists.txt +++ b/packages/PEGTL/src/example/pegtl/CMakeLists.txt @@ -1,6 +1,6 @@ -cmake_minimum_required (VERSION 3.3.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.8.0 FATAL_ERROR) -set (example_sources +set(example_sources abnf2pegtl.cpp analyze.cpp calculator.cpp @@ -10,13 +10,13 @@ set (example_sources dynamic_match.cpp hello_world.cpp indent_aware.cpp - json_build_one.cpp - json_build_two.cpp + json_build.cpp json_count.cpp json_parse.cpp lua53_parse.cpp modulus_match.cpp parse_tree.cpp + parse_tree_user_state.cpp proto3.cpp recover.cpp s_expression.cpp @@ -27,34 +27,33 @@ set (example_sources uri_trace.cpp ) -# file (GLOB ...) is used to validate the above list of test_sources -file (GLOB glob_example_sources RELATIVE ${CMAKE_CURRENT_LIST_DIR} *.cpp) +# file(GLOB ...) is used to validate the above list of test_sources +file(GLOB glob_example_sources RELATIVE ${CMAKE_CURRENT_LIST_DIR} *.cpp) -foreach (examplesourcefile ${example_sources}) - if (${examplesourcefile} IN_LIST glob_example_sources) - list (REMOVE_ITEM glob_example_sources ${examplesourcefile}) - else () - message (SEND_ERROR "File ${examplesourcefile} is missing from src/example/pegtl") - endif () +foreach(examplesourcefile ${example_sources}) + if(${examplesourcefile} IN_LIST glob_example_sources) + list(REMOVE_ITEM glob_example_sources ${examplesourcefile}) + else() + message(SEND_ERROR "File ${examplesourcefile} is missing from src/example/pegtl") + endif() - get_filename_component (exename ${examplesourcefile} NAME_WE) - set (exename "pegtl-example-${exename}") - add_executable (${exename} ${examplesourcefile}) - target_link_libraries (${exename} PRIVATE taocpp::pegtl) - set_target_properties (${exename} PROPERTIES - CXX_STANDARD 11 + get_filename_component(exename pegtl-example-${examplesourcefile} NAME_WE) + add_executable(${exename} ${examplesourcefile}) + target_link_libraries(${exename} PRIVATE taocpp::pegtl) + set_target_properties(${exename} PROPERTIES + CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF ) - if (MSVC) - target_compile_options (${exename} PRIVATE /W4 /WX /utf-8) - else () - target_compile_options (${exename} PRIVATE -pedantic -Wall -Wextra -Wshadow -Werror) - endif () -endforeach (examplesourcefile) + if(MSVC) + target_compile_options(${exename} PRIVATE /W4 /WX /utf-8) + else() + target_compile_options(${exename} PRIVATE -pedantic -Wall -Wextra -Wshadow -Werror) + endif() +endforeach(examplesourcefile) -if (glob_example_sources) - foreach (ignored_source_file ${glob_example_sources}) - message (SEND_ERROR "File ${ignored_source_file} in src/example/pegtl is ignored") - endforeach (ignored_source_file) -endif () +if(glob_example_sources) + foreach(ignored_source_file ${glob_example_sources}) + message(SEND_ERROR "File ${ignored_source_file} in src/example/pegtl is ignored") + endforeach(ignored_source_file) +endif() diff --git a/packages/PEGTL/src/example/pegtl/abnf2pegtl.cpp b/packages/PEGTL/src/example/pegtl/abnf2pegtl.cpp index 6251172ae..4e019eccb 100644 --- a/packages/PEGTL/src/example/pegtl/abnf2pegtl.cpp +++ b/packages/PEGTL/src/example/pegtl/abnf2pegtl.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <algorithm> @@ -28,672 +28,670 @@ #include <tao/pegtl/contrib/abnf.hpp> #include <tao/pegtl/contrib/parse_tree.hpp> -namespace tao +namespace TAO_PEGTL_NAMESPACE::abnf { - namespace TAO_PEGTL_NAMESPACE + using node_ptr = std::unique_ptr< parse_tree::node >; + + namespace { - namespace abnf + std::string prefix = "tao::pegtl::"; // NOLINT + + std::set< std::string > keywords = { // NOLINT + "alignas", + "alignof", + "and", + "and_eq", + "asm", + "auto", + "bitand", + "bitor", + "bool", + "break", + "case", + "catch", + "char", + "char16_t", + "char32_t", + "class", + "compl", + "const", + "constexpr", + "const_cast", + "continue", + "decltype", + "default", + "delete", + "do", + "double", + "dynamic_cast", + "else", + "enum", + "explicit", + "export", + "extern", + "false", + "float", + "for", + "friend", + "goto", + "if", + "inline", + "int", + "long", + "mutable", + "namespace", + "new", + "noexcept", + "not", + "not_eq", + "nullptr", + "operator", + "or", + "or_eq", + "private", + "protected", + "public", + "register", + "reinterpret_cast", + "return", + "short", + "signed", + "sizeof", + "static", + "static_assert", + "static_cast", + "struct", + "switch", + "template", + "this", + "thread_local", + "throw", + "true", + "try", + "typedef", + "typeid", + "typename", + "union", + "unsigned", + "using", + "virtual", + "void", + "volatile", + "wchar_t", + "while", + "xor", + "xor_eq" + }; + + using rules_t = std::vector< std::string >; + rules_t rules_defined; // NOLINT + rules_t rules; // NOLINT + + // clang-format off + struct one_tag {}; + struct string_tag {}; + struct istring_tag {}; + // clang-format on + + rules_t::reverse_iterator find_rule( rules_t& r, const std::string& v, const rules_t::reverse_iterator& rbegin ) { - using node_ptr = std::unique_ptr< parse_tree::node >; + return std::find_if( rbegin, r.rend(), [&]( const rules_t::value_type& p ) { return TAO_PEGTL_STRCASECMP( p.c_str(), v.c_str() ) == 0; } ); + } - namespace - { - std::string prefix = "tao::pegtl::"; // NOLINT - - std::set< std::string > keywords = { // NOLINT - "alignas", - "alignof", - "and", - "and_eq", - "asm", - "auto", - "bitand", - "bitor", - "bool", - "break", - "case", - "catch", - "char", - "char16_t", - "char32_t", - "class", - "compl", - "const", - "constexpr", - "const_cast", - "continue", - "decltype", - "default", - "delete", - "do", - "double", - "dynamic_cast", - "else", - "enum", - "explicit", - "export", - "extern", - "false", - "float", - "for", - "friend", - "goto", - "if", - "inline", - "int", - "long", - "mutable", - "namespace", - "new", - "noexcept", - "not", - "not_eq", - "nullptr", - "operator", - "or", - "or_eq", - "private", - "protected", - "public", - "register", - "reinterpret_cast", - "return", - "short", - "signed", - "sizeof", - "static", - "static_assert", - "static_cast", - "struct", - "switch", - "template", - "this", - "thread_local", - "throw", - "true", - "try", - "typedef", - "typeid", - "typename", - "union", - "unsigned", - "using", - "virtual", - "void", - "volatile", - "wchar_t", - "while", - "xor", - "xor_eq" - }; - - using rules_t = std::vector< std::string >; - rules_t rules_defined; // NOLINT - rules_t rules; // NOLINT - - // clang-format off - struct one_tag {}; - struct string_tag {}; - struct istring_tag {}; - // clang-format on - - rules_t::reverse_iterator find_rule( rules_t& r, const std::string& v, const rules_t::reverse_iterator& rbegin ) - { - return std::find_if( rbegin, r.rend(), [&]( const rules_t::value_type& p ) { return TAO_PEGTL_STRCASECMP( p.c_str(), v.c_str() ) == 0; } ); - } + rules_t::reverse_iterator find_rule( rules_t& r, const std::string& v ) + { + return find_rule( r, v, r.rbegin() ); + } - rules_t::reverse_iterator find_rule( rules_t& r, const std::string& v ) - { - return find_rule( r, v, r.rbegin() ); - } + bool append_char( std::string& s, const char c ) + { + if( !s.empty() ) { + s += ", "; + } + s += '\''; + if( c == '\'' || c == '\\' ) { + s += '\\'; + } + s += c; + s += '\''; + return std::isalpha( c ) != 0; + } - bool append_char( std::string& s, const char c ) - { - if( !s.empty() ) { - s += ", "; - } - s += '\''; - if( c == '\'' || c == '\\' ) { - s += '\\'; - } - s += c; - s += '\''; - return std::isalpha( c ) != 0; - } + std::string remove_leading_zeroes( const std::string& v ) + { + const auto pos = v.find_first_not_of( '0' ); + if( pos == std::string::npos ) { + return ""; + } + return v.substr( pos ); + } - std::string remove_leading_zeroes( const std::string& v ) - { - const auto pos = v.find_first_not_of( '0' ); - if( pos == std::string::npos ) { - return ""; - } - return v.substr( pos ); - } + void shift( internal::iterator& it, int delta ) + { + it.data += delta; + it.byte += delta; + it.byte_in_line += delta; + } - void shift( internal::iterator& it, int delta ) - { - it.data += delta; - it.byte += delta; - it.byte_in_line += delta; - } + } // namespace - } // namespace + namespace grammar + { + // ABNF grammar according to RFC 5234, updated by RFC 7405, with + // the following differences: + // + // To form a C++ identifier from a rulename, all minuses are + // replaced with underscores. + // + // As C++ identifiers are case-sensitive, we remember the "correct" + // spelling from the first occurrence of a rulename, all other + // occurrences are automatically changed to that. + // + // Certain rulenames are reserved as their equivalent C++ identifier is + // reserved as a keyword, an alternative token, by the standard or + // for other, special reasons. + // + // When using numerical values (num-val, repeat), the values + // must be in the range of the corresponding C++ data type. + // + // Remember we are defining a PEG, not a CFG. Simply copying some + // ABNF from somewhere might lead to surprising results as the + // alternations are now sequential, using the sor<> rule. + // + // PEG also require two extensions: the and-predicate and the + // not-predicate. They are expressed by '&' and '!' respectively, + // being allowed (optionally, only one of them) before the + // repetition. You can use braces for more complex expressions. + // + // Finally, instead of the pre-defined CRLF sequence, we accept + // any type of line ending as a convenience extension: + + // clang-format off + struct CRLF : sor< abnf::CRLF, CR, LF > {}; + + // The rest is according to the RFC(s): + struct comment_cont : until< CRLF, sor< WSP, VCHAR > > {}; + struct comment : if_must< one< ';' >, comment_cont > {}; + struct c_nl : sor< comment, CRLF > {}; + struct c_wsp : sor< WSP, seq< c_nl, WSP > > {}; + + struct rulename : seq< ALPHA, star< ranges< 'a', 'z', 'A', 'Z', '0', '9', '-' > > > {}; + + struct quoted_string_cont : until< DQUOTE, print > {}; + struct quoted_string : if_must< DQUOTE, quoted_string_cont > {}; + struct case_insensitive_string : seq< opt< istring< '%', 'i' > >, quoted_string > {}; + struct case_sensitive_string : seq< istring< '%', 's' >, quoted_string > {}; + struct char_val : sor< case_insensitive_string, case_sensitive_string > {}; + + struct prose_val_cont : until< one< '>' >, print > {}; + struct prose_val : if_must< one< '<' >, prose_val_cont > {}; + + template< char First, typename Digit > + struct gen_val + { + struct value : plus< Digit > {}; + struct range : if_must< one< '-' >, value > {}; + struct next_value : must< value > {}; + struct type : seq< istring< First >, must< value >, sor< range, star< one< '.' >, next_value > > > {}; + }; - namespace grammar - { - // ABNF grammar according to RFC 5234, updated by RFC 7405, with - // the following differences: - // - // To form a C++ identifier from a rulename, all minuses are - // replaced with underscores. - // - // As C++ identifiers are case-sensitive, we remember the "correct" - // spelling from the first occurrence of a rulename, all other - // occurrences are automatically changed to that. - // - // Certain rulenames are reserved as their equivalent C++ identifier is - // reserved as a keyword, an alternative token, by the standard or - // for other, special reasons. - // - // When using numerical values (num-val, repeat), the values - // must be in the range of the corresponsing C++ data type. - // - // Remember we are defining a PEG, not a CFG. Simply copying some - // ABNF from somewhere might lead to surprising results as the - // alternations are now sequential, using the sor<> rule. - // - // PEG also require two extensions: the and-predicate and the - // not-predicate. They are expressed by '&' and '!' respectively, - // being allowed (optionally, only one of them) before the - // repetition. You can use braces for more complex expressions. - // - // Finally, instead of the pre-defined CRLF sequence, we accept - // any type of line ending as a convencience extension: - - // clang-format off - struct CRLF : sor< abnf::CRLF, CR, LF > {}; - - // The rest is according to the RFC(s): - struct comment_cont : until< CRLF, sor< WSP, VCHAR > > {}; - struct comment : if_must< one< ';' >, comment_cont > {}; - struct c_nl : sor< comment, CRLF > {}; - struct c_wsp : sor< WSP, seq< c_nl, WSP > > {}; - - struct rulename : seq< ALPHA, star< ranges< 'a', 'z', 'A', 'Z', '0', '9', '-' > > > {}; - - struct quoted_string_cont : until< DQUOTE, print > {}; - struct quoted_string : if_must< DQUOTE, quoted_string_cont > {}; - struct case_insensitive_string : seq< opt< istring< '%', 'i' > >, quoted_string > {}; - struct case_sensitive_string : seq< istring< '%', 's' >, quoted_string > {}; - struct char_val : sor< case_insensitive_string, case_sensitive_string > {}; - - struct prose_val_cont : until< one< '>' >, print > {}; - struct prose_val : if_must< one< '<' >, prose_val_cont > {}; - - template< char First, typename Digit > - struct gen_val - { - struct value : plus< Digit > {}; - struct range : if_must< one< '-' >, value > {}; - struct next_value : must< value > {}; - struct type : seq< istring< First >, must< value >, sor< range, star< one< '.' >, next_value > > > {}; - }; - - using hex_val = gen_val< 'x', HEXDIG >; - using dec_val = gen_val< 'd', DIGIT >; - using bin_val = gen_val< 'b', BIT >; - - struct num_val_choice : sor< bin_val::type, dec_val::type, hex_val::type > {}; - struct num_val : if_must< one< '%' >, num_val_choice > {}; - - struct alternation; - struct option_close : one< ']' > {}; - struct option : seq< one< '[' >, pad< must< alternation >, c_wsp >, must< option_close > > {}; - struct group_close : one< ')' > {}; - struct group : seq< one< '(' >, pad< must< alternation >, c_wsp >, must< group_close > > {}; - struct element : sor< rulename, group, option, char_val, num_val, prose_val > {}; - - struct repeat : sor< seq< star< DIGIT >, one< '*' >, star< DIGIT > >, plus< DIGIT > > {}; - struct repetition : seq< opt< repeat >, element > {}; - - struct and_predicate : if_must< one< '&' >, repetition > {}; - struct not_predicate : if_must< one< '!' >, repetition > {}; - struct predicate : sor< and_predicate, not_predicate, repetition > {}; - - struct concatenation : list< predicate, plus< c_wsp > > {}; - struct alternation : list_must< concatenation, pad< one< '/' >, c_wsp > > {}; - - struct defined_as_op : sor< string< '=', '/' >, one< '=' > > {}; - struct defined_as : pad< defined_as_op, c_wsp > {}; - struct rule : seq< if_must< rulename, defined_as, alternation >, star< c_wsp >, must< c_nl > > {}; - struct rulelist : until< eof, sor< seq< star< c_wsp >, c_nl >, must< rule > > > {}; - - // end of grammar - - template< typename Rule > - struct error_control : normal< Rule > - { - static const std::string error_message; - - template< typename Input, typename... States > - static void raise( const Input& in, States&&... /*unused*/ ) - { - throw parse_error( error_message, in ); - } - }; - - template<> const std::string error_control< comment_cont >::error_message = "unterminated comment"; // NOLINT - - template<> const std::string error_control< quoted_string_cont >::error_message = "unterminated string (missing '\"')"; // NOLINT - template<> const std::string error_control< prose_val_cont >::error_message = "unterminated prose description (missing '>')"; // NOLINT - - template<> const std::string error_control< hex_val::value >::error_message = "expected hexadecimal value"; // NOLINT - template<> const std::string error_control< dec_val::value >::error_message = "expected decimal value"; // NOLINT - template<> const std::string error_control< bin_val::value >::error_message = "expected binary value"; // NOLINT - template<> const std::string error_control< num_val_choice >::error_message = "expected base specifier (one of 'bBdDxX')"; // NOLINT - - template<> const std::string error_control< option_close >::error_message = "unterminated option (missing ']')"; // NOLINT - template<> const std::string error_control< group_close >::error_message = "unterminated group (missing ')')"; // NOLINT - - template<> const std::string error_control< repetition >::error_message = "expected element"; // NOLINT - template<> const std::string error_control< concatenation >::error_message = "expected element"; // NOLINT - template<> const std::string error_control< alternation >::error_message = "expected element"; // NOLINT - - template<> const std::string error_control< defined_as >::error_message = "expected '=' or '=/'"; // NOLINT - template<> const std::string error_control< c_nl >::error_message = "unterminated rule"; // NOLINT - template<> const std::string error_control< rule >::error_message = "expected rule"; // NOLINT - // clang-format on - - } // namespace grammar - - template< typename Rule > - struct selector - : parse_tree::selector< - Rule, - parse_tree::apply_store_content::to< - grammar::rulename, - grammar::prose_val, - grammar::hex_val::value, - grammar::dec_val::value, - grammar::bin_val::value, - grammar::hex_val::range, - grammar::dec_val::range, - grammar::bin_val::range, - grammar::hex_val::type, - grammar::dec_val::type, - grammar::bin_val::type, - grammar::repeat, - grammar::defined_as_op >, - parse_tree::apply_remove_content::to< - grammar::option, - grammar::and_predicate, - grammar::not_predicate, - grammar::rule >, - parse_tree::apply_fold_one::to< - grammar::alternation, - grammar::group, - grammar::repetition, - grammar::concatenation > > - { - }; + using hex_val = gen_val< 'x', HEXDIG >; + using dec_val = gen_val< 'd', DIGIT >; + using bin_val = gen_val< 'b', BIT >; - template<> - struct selector< grammar::quoted_string > : std::true_type - { - static void transform( node_ptr& n ) - { - shift( n->m_begin, 1 ); - shift( n->m_end, -1 ); - - const std::string content = n->content(); - for( const auto c : content ) { - if( std::isalpha( c ) != 0 ) { - n->id = &typeid( istring_tag ); - return; - } - } - if( content.size() == 1 ) { - n->id = &typeid( one_tag ); - } - else { - n->id = &typeid( string_tag ); - } - } - }; + struct num_val_choice : sor< bin_val::type, dec_val::type, hex_val::type > {}; + struct num_val : if_must< one< '%' >, num_val_choice > {}; - template<> - struct selector< grammar::case_sensitive_string > : std::true_type - { - static void transform( node_ptr& n ) - { - n = std::move( n->children.back() ); - if( n->content().size() == 1 ) { - n->id = &typeid( one_tag ); - } - else { - n->id = &typeid( string_tag ); - } - } - }; + struct alternation; + struct option_close : one< ']' > {}; + struct option : seq< one< '[' >, pad< must< alternation >, c_wsp >, must< option_close > > {}; + struct group_close : one< ')' > {}; + struct group : seq< one< '(' >, pad< must< alternation >, c_wsp >, must< group_close > > {}; + struct element : sor< rulename, group, option, char_val, num_val, prose_val > {}; - std::string to_string( const node_ptr& n ); - std::string to_string( const std::vector< node_ptr >& v ); + struct repeat : sor< seq< star< DIGIT >, one< '*' >, star< DIGIT > >, plus< DIGIT > > {}; + struct repetition : seq< opt< repeat >, element > {}; - std::string to_string_unwrap_seq( const node_ptr& n ) + struct and_predicate : if_must< one< '&' >, repetition > {}; + struct not_predicate : if_must< one< '!' >, repetition > {}; + struct predicate : sor< and_predicate, not_predicate, repetition > {}; + + struct concatenation : list< predicate, plus< c_wsp > > {}; + struct alternation : list_must< concatenation, pad< one< '/' >, c_wsp > > {}; + + struct defined_as_op : sor< string< '=', '/' >, one< '=' > > {}; + struct defined_as : pad< defined_as_op, c_wsp > {}; + struct rule : seq< if_must< rulename, defined_as, alternation >, star< c_wsp >, must< c_nl > > {}; + struct rulelist : until< eof, sor< seq< star< c_wsp >, c_nl >, must< rule > > > {}; + + // end of grammar + + template< typename Rule > + struct error_control : normal< Rule > + { + static const std::string error_message; + + template< typename Input, typename... States > + static void raise( const Input& in, States&&... /*unused*/ ) { - if( n->is< grammar::group >() || n->is< grammar::concatenation >() ) { - return to_string( n->children ); - } - return to_string( n ); + throw parse_error( error_message, in ); } + }; + + template<> const std::string error_control< comment_cont >::error_message = "unterminated comment"; // NOLINT + + template<> const std::string error_control< quoted_string_cont >::error_message = "unterminated string (missing '\"')"; // NOLINT + template<> const std::string error_control< prose_val_cont >::error_message = "unterminated prose description (missing '>')"; // NOLINT + + template<> const std::string error_control< hex_val::value >::error_message = "expected hexadecimal value"; // NOLINT + template<> const std::string error_control< dec_val::value >::error_message = "expected decimal value"; // NOLINT + template<> const std::string error_control< bin_val::value >::error_message = "expected binary value"; // NOLINT + template<> const std::string error_control< num_val_choice >::error_message = "expected base specifier (one of 'bBdDxX')"; // NOLINT + + template<> const std::string error_control< option_close >::error_message = "unterminated option (missing ']')"; // NOLINT + template<> const std::string error_control< group_close >::error_message = "unterminated group (missing ')')"; // NOLINT + + template<> const std::string error_control< repetition >::error_message = "expected element"; // NOLINT + template<> const std::string error_control< concatenation >::error_message = "expected element"; // NOLINT + template<> const std::string error_control< alternation >::error_message = "expected element"; // NOLINT + + template<> const std::string error_control< defined_as >::error_message = "expected '=' or '=/'"; // NOLINT + template<> const std::string error_control< c_nl >::error_message = "unterminated rule"; // NOLINT + template<> const std::string error_control< rule >::error_message = "expected rule"; // NOLINT + // clang-format on + + } // namespace grammar + + template< typename Rule > + struct selector + : parse_tree::selector< + Rule, + parse_tree::store_content::on< + grammar::rulename, + grammar::prose_val, + grammar::hex_val::value, + grammar::dec_val::value, + grammar::bin_val::value, + grammar::hex_val::range, + grammar::dec_val::range, + grammar::bin_val::range, + grammar::hex_val::type, + grammar::dec_val::type, + grammar::bin_val::type, + grammar::repeat, + grammar::defined_as_op >, + parse_tree::remove_content::on< + grammar::option, + grammar::and_predicate, + grammar::not_predicate, + grammar::rule >, + parse_tree::fold_one::on< + grammar::alternation, + grammar::group, + grammar::repetition, + grammar::concatenation > > + { + }; - namespace - { - std::string get_rulename( const node_ptr& n ) - { - assert( n->is< grammar::rulename >() ); - std::string v = n->content(); - std::replace( v.begin(), v.end(), '-', '_' ); - return v; + template<> + struct selector< grammar::quoted_string > : std::true_type + { + template< typename... States > + static void transform( node_ptr& n ) + { + shift( n->m_begin, 1 ); + shift( n->m_end, -1 ); + + const auto content = n->string_view(); + for( const auto c : content ) { + if( std::isalpha( c ) != 0 ) { + n->id = typeid( istring_tag ); + return; } + } + if( content.size() == 1 ) { + n->id = typeid( one_tag ); + } + else { + n->id = typeid( string_tag ); + } + } + }; - std::string get_rulename( const node_ptr& n, const bool print_forward_declarations ) - { - std::string v = get_rulename( n ); - const auto it = find_rule( rules, v ); - if( it != rules.rend() ) { - return *it; - } - if( keywords.count( v ) != 0 || v.find( "__" ) != std::string::npos ) { - throw parse_error( '\'' + n->content() + "' is a reserved rulename", n->begin() ); // NOLINT - } - if( print_forward_declarations && find_rule( rules_defined, v ) != rules_defined.rend() ) { - std::cout << "struct " << v << ";\n"; - } - rules.push_back( v ); - return v; - } + template<> + struct selector< grammar::case_sensitive_string > : std::true_type + { + template< typename... States > + static void transform( node_ptr& n ) + { + n = std::move( n->children.back() ); + if( n->string_view().size() == 1 ) { + n->id = typeid( one_tag ); + } + else { + n->id = typeid( string_tag ); + } + } + }; - template< typename T > - std::string gen_val( const node_ptr& n ) - { - if( n->children.size() == 2 ) { - if( n->children.back()->is< T >() ) { - return prefix + "range< " + to_string( n->children.front() ) + ", " + to_string( n->children.back()->children.front() ) + " >"; - } - } - if( n->children.size() == 1 ) { - return prefix + "one< " + to_string( n->children ) + " >"; - } - return prefix + "string< " + to_string( n->children ) + " >"; - } + std::string to_string( const node_ptr& n ); + std::string to_string( const std::vector< node_ptr >& v ); - struct ccmp - { - bool operator()( const std::string& lhs, const std::string& rhs ) const noexcept - { - return TAO_PEGTL_STRCASECMP( lhs.c_str(), rhs.c_str() ) < 0; - } - }; + std::string to_string_unwrap_seq( const node_ptr& n ) + { + if( n->is< grammar::group >() || n->is< grammar::concatenation >() ) { + return to_string( n->children ); + } + return to_string( n ); + } - std::map< std::string, parse_tree::node*, ccmp > previous_rules; // NOLINT + namespace + { + std::string get_rulename( const node_ptr& n ) + { + assert( n->is< grammar::rulename >() ); + std::string v = n->string(); + std::replace( v.begin(), v.end(), '-', '_' ); + return v; + } - } // namespace + std::string get_rulename( const node_ptr& n, const bool print_forward_declarations ) + { + std::string v = get_rulename( n ); + const auto it = find_rule( rules, v ); + if( it != rules.rend() ) { + return *it; + } + if( keywords.count( v ) != 0 || v.find( "__" ) != std::string::npos ) { + throw parse_error( '\'' + n->string() + "' is a reserved rulename", n->begin() ); // NOLINT + } + if( print_forward_declarations && find_rule( rules_defined, v ) != rules_defined.rend() ) { + std::cout << "struct " << v << ";\n"; + } + rules.push_back( v ); + return v; + } - template<> - struct selector< grammar::rule > : std::true_type - { - static void transform( node_ptr& n ) - { - const auto rname = get_rulename( n->children.front() ); - assert( n->children.at( 1 )->is< grammar::defined_as_op >() ); - const auto op = n->children.at( 1 )->content(); - // when we insert a normal rule, we need to check for duplicates - if( op == "=" ) { - if( !previous_rules.insert( { rname, n.get() } ).second ) { - throw parse_error( "rule '" + rname + "' is already defined", n->begin() ); // NOLINT - } - } - // if it is an "incremental alternation", we need to consolidate the assigned alternations - else if( op == "=/" ) { - const auto p = previous_rules.find( rname ); - if( p == previous_rules.end() ) { - throw parse_error( "incremental alternation '" + rname + "' without previous rule definition", n->begin() ); // NOLINT - } - auto& previous = p->second->children.back(); - - // if the previous rule does not assign an alternation, create an intermediate alternation and move its assignee into it. - if( !previous->is< abnf::grammar::alternation >() ) { - node_ptr s( new parse_tree::node ); - s->id = &typeid( abnf::grammar::alternation ); - s->source = previous->source; - s->m_begin = previous->m_begin; - s->m_end = previous->m_end; - s->children.emplace_back( std::move( previous ) ); - previous = std::move( s ); - } - - // append all new options to the previous rule's assignee (which always is an alternation now) - previous->m_end = n->children.back()->m_end; - - // if the new rule itself contains an alternation, append the individual entries... - if( n->children.back()->is< abnf::grammar::alternation >() ) { - for( auto& e : n->children.back()->children ) { - previous->children.emplace_back( std::move( e ) ); - } - } - // ...otherwise add the node itself as another option. - else { - previous->children.emplace_back( std::move( n->children.back() ) ); - } - n.reset(); - } - else { - throw parse_error( "invalid operator '" + op + "', this should not happen!", n->begin() ); // NOLINT - } + template< typename T > + std::string gen_val( const node_ptr& n ) + { + if( n->children.size() == 2 ) { + if( n->children.back()->is< T >() ) { + return prefix + "range< " + to_string( n->children.front() ) + ", " + to_string( n->children.back()->children.front() ) + " >"; } - }; + } + if( n->children.size() == 1 ) { + return prefix + "one< " + to_string( n->children ) + " >"; + } + return prefix + "string< " + to_string( n->children ) + " >"; + } - struct stringifier + struct ccmp + { + bool operator()( const std::string& lhs, const std::string& rhs ) const noexcept { - using function_t = std::string ( * )( const node_ptr& n ); - function_t default_ = nullptr; + return TAO_PEGTL_STRCASECMP( lhs.c_str(), rhs.c_str() ) < 0; + } + }; + + std::map< std::string, parse_tree::node*, ccmp > previous_rules; // NOLINT - std::map< const std::type_info*, function_t > map_; + } // namespace - template< typename T > - void add( const function_t& f ) - { - map_.insert( { &typeid( T ), f } ); + template<> + struct selector< grammar::rule > : std::true_type + { + template< typename... States > + static void transform( node_ptr& n ) + { + const auto rname = get_rulename( n->children.front() ); + assert( n->children.at( 1 )->is< grammar::defined_as_op >() ); + const auto op = n->children.at( 1 )->string(); + // when we insert a normal rule, we need to check for duplicates + if( op == "=" ) { + if( !previous_rules.insert( { rname, n.get() } ).second ) { + throw parse_error( "rule '" + rname + "' is already defined", n->begin() ); // NOLINT + } + } + // if it is an "incremental alternation", we need to consolidate the assigned alternations + else if( op == "=/" ) { + const auto p = previous_rules.find( rname ); + if( p == previous_rules.end() ) { + throw parse_error( "incremental alternation '" + rname + "' without previous rule definition", n->begin() ); // NOLINT } + auto& previous = p->second->children.back(); + + // if the previous rule does not assign an alternation, create an intermediate alternation and move its assignee into it. + if( !previous->is< abnf::grammar::alternation >() ) { + auto s = std::make_unique< parse_tree::node >(); + s->id = typeid( abnf::grammar::alternation ); + s->source = previous->source; + s->m_begin = previous->m_begin; + s->m_end = previous->m_end; + s->children.emplace_back( std::move( previous ) ); + previous = std::move( s ); + } + + // append all new options to the previous rule's assignee (which always is an alternation now) + previous->m_end = n->children.back()->m_end; - std::string operator()( const node_ptr& n ) const - { - const auto it = map_.find( n->id ); - if( it != map_.end() ) { - return it->second( n ); + // if the new rule itself contains an alternation, append the individual entries... + if( n->children.back()->is< abnf::grammar::alternation >() ) { + for( auto& e : n->children.back()->children ) { + previous->children.emplace_back( std::move( e ) ); } - return default_( n ); } - }; + // ...otherwise add the node itself as another option. + else { + previous->children.emplace_back( std::move( n->children.back() ) ); + } + n.reset(); + } + else { + throw parse_error( "invalid operator '" + op + "', this should not happen!", n->begin() ); // NOLINT + } + } + }; - stringifier make_stringifier() - { - stringifier nrv; - nrv.default_ = []( const node_ptr& n ) -> std::string { - throw parse_error( "missing to_string() for " + n->name(), n->begin() ); // NOLINT - }; - - nrv.add< grammar::rulename >( []( const node_ptr& n ) { return get_rulename( n, true ); } ); - - nrv.add< grammar::rule >( []( const node_ptr& n ) { - return "struct " + get_rulename( n->children.front(), false ) + " : " + to_string( n->children.back() ) + " {};"; - } ); - - nrv.add< string_tag >( []( const node_ptr& n ) { - const std::string content = n->content(); - std::string s; - for( const auto c : content ) { - append_char( s, c ); - } - return prefix + "string< " + s + " >"; - } ); - - nrv.add< istring_tag >( []( const node_ptr& n ) { - const std::string content = n->content(); - std::string s; - for( const auto c : content ) { - append_char( s, c ); - } - return prefix + "istring< " + s + " >"; - } ); - - nrv.add< one_tag >( []( const node_ptr& n ) { - const std::string content = n->content(); - std::string s; - for( const auto c : content ) { - append_char( s, c ); - } - return prefix + "one< " + s + " >"; - } ); - - nrv.add< grammar::hex_val::value >( []( const node_ptr& n ) { return "0x" + n->content(); } ); - nrv.add< grammar::dec_val::value >( []( const node_ptr& n ) { return n->content(); } ); - nrv.add< grammar::bin_val::value >( []( const node_ptr& n ) { - unsigned long long v = 0; - const char* p = n->m_begin.data; - // TODO: Detect overflow - do { - v <<= 1; - v |= ( *p++ & 1 ); - } while( p != n->m_end.data ); - std::ostringstream o; - o << v; - return o.str(); - } ); - - nrv.add< grammar::hex_val::type >( []( const node_ptr& n ) { return gen_val< grammar::hex_val::range >( n ); } ); - nrv.add< grammar::dec_val::type >( []( const node_ptr& n ) { return gen_val< grammar::dec_val::range >( n ); } ); - nrv.add< grammar::bin_val::type >( []( const node_ptr& n ) { return gen_val< grammar::bin_val::range >( n ); } ); - - nrv.add< grammar::alternation >( []( const node_ptr& n ) { return prefix + "sor< " + to_string( n->children ) + " >"; } ); - nrv.add< grammar::option >( []( const node_ptr& n ) { return prefix + "opt< " + to_string( n->children ) + " >"; } ); - nrv.add< grammar::group >( []( const node_ptr& n ) { return prefix + "seq< " + to_string( n->children ) + " >"; } ); - - nrv.add< grammar::prose_val >( []( const node_ptr& n ) { return "/* " + n->content() + " */"; } ); - - nrv.add< grammar::and_predicate >( []( const node_ptr& n ) { - assert( n->children.size() == 1 ); - return prefix + "at< " + to_string_unwrap_seq( n->children.front() ) + " >"; - } ); - - nrv.add< grammar::not_predicate >( []( const node_ptr& n ) { - assert( n->children.size() == 1 ); - return prefix + "not_at< " + to_string_unwrap_seq( n->children.front() ) + " >"; - } ); - - nrv.add< grammar::concatenation >( []( const node_ptr& n ) { - assert( !n->children.empty() ); - return prefix + "seq< " + to_string( n->children ) + " >"; - } ); - - nrv.add< grammar::repetition >( []( const node_ptr& n ) -> std::string { - assert( n->children.size() == 2 ); - const auto content = to_string_unwrap_seq( n->children.back() ); - const auto rep = n->children.front()->content(); - const auto star = rep.find( '*' ); - if( star == std::string::npos ) { - const auto v = remove_leading_zeroes( rep ); - if( v.empty() ) { - throw parse_error( "repetition of zero not allowed", n->begin() ); // NOLINT - } - return prefix + "rep< " + v + ", " + content + " >"; - } - const auto min = remove_leading_zeroes( rep.substr( 0, star ) ); - const auto max = remove_leading_zeroes( rep.substr( star + 1 ) ); - if( ( star != rep.size() - 1 ) && max.empty() ) { - throw parse_error( "repetition maximum of zero not allowed", n->begin() ); // NOLINT - } - if( min.empty() && max.empty() ) { - return prefix + "star< " + content + " >"; - } - if( !min.empty() && max.empty() ) { - if( min == "1" ) { - return prefix + "plus< " + content + " >"; - } - return prefix + "rep_min< " + min + ", " + content + " >"; - } - if( min.empty() && !max.empty() ) { - if( max == "1" ) { - return prefix + "opt< " + content + " >"; - } - return prefix + "rep_max< " + max + ", " + content + " >"; - } - unsigned long long min_val; - unsigned long long max_val; - { - std::stringstream s; - s.str( min ); - s >> min_val; - s.clear(); - s.str( max ); - s >> max_val; - } - if( min_val > max_val ) { - throw parse_error( "repetition minimum which is greater than the repetition maximum not allowed", n->begin() ); // NOLINT - } - if( ( min_val == 1 ) && ( max_val == 1 ) ) { - // note: content can not be used here! - return to_string( n->children.back() ); - } - const auto min_element = ( min_val == 1 ) ? content : ( prefix + "rep< " + min + ", " + content + " >" ); - if( min_val == max_val ) { - return min_element; - } - std::ostringstream os; - os << ( max_val - min_val ); - const auto max_element = prefix + ( ( max_val - min_val == 1 ) ? "opt< " : ( "rep_opt< " + os.str() + ", " ) ) + content + " >"; - return prefix + "seq< " + min_element + ", " + max_element + " >"; - } ); + struct stringifier + { + using function_t = std::string ( * )( const node_ptr& n ); + function_t default_ = nullptr; - return nrv; - } + std::map< std::type_index, function_t > map_; - std::string to_string( const node_ptr& n ) - { - static stringifier s = make_stringifier(); - return s( n ); + template< typename T > + void add( const function_t& f ) + { + map_.insert( { typeid( T ), f } ); + } + + std::string operator()( const node_ptr& n ) const + { + const auto it = map_.find( n->id ); + if( it != map_.end() ) { + return it->second( n ); } + return default_( n ); + } + }; - std::string to_string( const std::vector< node_ptr >& v ) - { - std::string result; - for( const auto& c : v ) { - if( !result.empty() ) { - result += ", "; - } - result += to_string( c ); + stringifier make_stringifier() + { + stringifier nrv; + nrv.default_ = []( const node_ptr& n ) -> std::string { + throw parse_error( "missing to_string() for " + n->name(), n->begin() ); // NOLINT + }; + + nrv.add< grammar::rulename >( []( const node_ptr& n ) { return get_rulename( n, true ); } ); + + nrv.add< grammar::rule >( []( const node_ptr& n ) { + return "struct " + get_rulename( n->children.front(), false ) + " : " + to_string( n->children.back() ) + " {};"; + } ); + + nrv.add< string_tag >( []( const node_ptr& n ) { + const auto content = n->string_view(); + std::string s; + for( const auto c : content ) { + append_char( s, c ); + } + return prefix + "string< " + s + " >"; + } ); + + nrv.add< istring_tag >( []( const node_ptr& n ) { + const auto content = n->string_view(); + std::string s; + for( const auto c : content ) { + append_char( s, c ); + } + return prefix + "istring< " + s + " >"; + } ); + + nrv.add< one_tag >( []( const node_ptr& n ) { + const auto content = n->string_view(); + std::string s; + for( const auto c : content ) { + append_char( s, c ); + } + return prefix + "one< " + s + " >"; + } ); + + nrv.add< grammar::hex_val::value >( []( const node_ptr& n ) { return "0x" + n->string(); } ); + nrv.add< grammar::dec_val::value >( []( const node_ptr& n ) { return n->string(); } ); + nrv.add< grammar::bin_val::value >( []( const node_ptr& n ) { + unsigned long long v = 0; + const char* p = n->m_begin.data; + // TODO: Detect overflow + do { + v <<= 1; + v |= ( *p++ & 1 ); + } while( p != n->m_end.data ); + std::ostringstream o; + o << v; + return o.str(); + } ); + + nrv.add< grammar::hex_val::type >( []( const node_ptr& n ) { return gen_val< grammar::hex_val::range >( n ); } ); + nrv.add< grammar::dec_val::type >( []( const node_ptr& n ) { return gen_val< grammar::dec_val::range >( n ); } ); + nrv.add< grammar::bin_val::type >( []( const node_ptr& n ) { return gen_val< grammar::bin_val::range >( n ); } ); + + nrv.add< grammar::alternation >( []( const node_ptr& n ) { return prefix + "sor< " + to_string( n->children ) + " >"; } ); + nrv.add< grammar::option >( []( const node_ptr& n ) { return prefix + "opt< " + to_string( n->children ) + " >"; } ); + nrv.add< grammar::group >( []( const node_ptr& n ) { return prefix + "seq< " + to_string( n->children ) + " >"; } ); + + nrv.add< grammar::prose_val >( []( const node_ptr& n ) { return "/* " + n->string() + " */"; } ); + + nrv.add< grammar::and_predicate >( []( const node_ptr& n ) { + assert( n->children.size() == 1 ); + return prefix + "at< " + to_string_unwrap_seq( n->children.front() ) + " >"; + } ); + + nrv.add< grammar::not_predicate >( []( const node_ptr& n ) { + assert( n->children.size() == 1 ); + return prefix + "not_at< " + to_string_unwrap_seq( n->children.front() ) + " >"; + } ); + + nrv.add< grammar::concatenation >( []( const node_ptr& n ) { + assert( !n->children.empty() ); + return prefix + "seq< " + to_string( n->children ) + " >"; + } ); + + nrv.add< grammar::repetition >( []( const node_ptr& n ) -> std::string { + assert( n->children.size() == 2 ); + const auto content = to_string_unwrap_seq( n->children.back() ); + const auto rep = n->children.front()->string(); + const auto star = rep.find( '*' ); + if( star == std::string::npos ) { + const auto v = remove_leading_zeroes( rep ); + if( v.empty() ) { + throw parse_error( "repetition of zero not allowed", n->begin() ); // NOLINT + } + return prefix + "rep< " + v + ", " + content + " >"; + } + const auto min = remove_leading_zeroes( rep.substr( 0, star ) ); + const auto max = remove_leading_zeroes( rep.substr( star + 1 ) ); + if( ( star != rep.size() - 1 ) && max.empty() ) { + throw parse_error( "repetition maximum of zero not allowed", n->begin() ); // NOLINT + } + if( min.empty() && max.empty() ) { + return prefix + "star< " + content + " >"; + } + if( !min.empty() && max.empty() ) { + if( min == "1" ) { + return prefix + "plus< " + content + " >"; + } + return prefix + "rep_min< " + min + ", " + content + " >"; + } + if( min.empty() && !max.empty() ) { + if( max == "1" ) { + return prefix + "opt< " + content + " >"; } - return result; + return prefix + "rep_max< " + max + ", " + content + " >"; + } + unsigned long long min_val; + unsigned long long max_val; + { + std::stringstream s; + s.str( min ); + s >> min_val; + s.clear(); + s.str( max ); + s >> max_val; } + if( min_val > max_val ) { + throw parse_error( "repetition minimum which is greater than the repetition maximum not allowed", n->begin() ); // NOLINT + } + if( ( min_val == 1 ) && ( max_val == 1 ) ) { + // note: content can not be used here! + return to_string( n->children.back() ); + } + const auto min_element = ( min_val == 1 ) ? content : ( prefix + "rep< " + min + ", " + content + " >" ); + if( min_val == max_val ) { + return min_element; + } + std::ostringstream os; + os << ( max_val - min_val ); + const auto max_element = prefix + ( ( max_val - min_val == 1 ) ? "opt< " : ( "rep_opt< " + os.str() + ", " ) ) + content + " >"; + return prefix + "seq< " + min_element + ", " + max_element + " >"; + } ); + + return nrv; + } - } // namespace abnf + std::string to_string( const node_ptr& n ) + { + static stringifier s = make_stringifier(); + return s( n ); + } - } // namespace TAO_PEGTL_NAMESPACE + std::string to_string( const std::vector< node_ptr >& v ) + { + std::string result; + for( const auto& c : v ) { + if( !result.empty() ) { + result += ", "; + } + result += to_string( c ); + } + return result; + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::abnf int main( int argc, char** argv ) { - using namespace tao::TAO_PEGTL_NAMESPACE; // NOLINT + using namespace TAO_PEGTL_NAMESPACE; // NOLINT if( argc != 2 ) { - analyze< abnf::grammar::rulelist >(); std::cerr << "Usage: " << argv[ 0 ] << " SOURCE" << std::endl; return 1; } - file_input<> in( argv[ 1 ] ); + if( analyze< abnf::grammar::rulelist >() != 0 ) { + return 2; + } + + file_input in( argv[ 1 ] ); try { const auto root = parse_tree::parse< abnf::grammar::rulelist, abnf::selector, nothing, abnf::grammar::error_control >( in ); @@ -708,7 +706,7 @@ int main( int argc, char** argv ) catch( const parse_error& e ) { const auto p = e.positions.front(); std::cerr << e.what() << std::endl - << in.line_as_string( p ) << std::endl + << in.line_at( p ) << std::endl << std::string( p.byte_in_line, ' ' ) << '^' << std::endl; } diff --git a/packages/PEGTL/src/example/pegtl/analyze.cpp b/packages/PEGTL/src/example/pegtl/analyze.cpp index 98ad12e7a..ecccbef9b 100644 --- a/packages/PEGTL/src/example/pegtl/analyze.cpp +++ b/packages/PEGTL/src/example/pegtl/analyze.cpp @@ -1,10 +1,10 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <tao/pegtl.hpp> #include <tao/pegtl/analyze.hpp> -using namespace tao::TAO_PEGTL_NAMESPACE; // NOLINT +using namespace TAO_PEGTL_NAMESPACE; // NOLINT struct bar; diff --git a/packages/PEGTL/src/example/pegtl/calculator.cpp b/packages/PEGTL/src/example/pegtl/calculator.cpp index 5404848ed..b841e327a 100644 --- a/packages/PEGTL/src/example/pegtl/calculator.cpp +++ b/packages/PEGTL/src/example/pegtl/calculator.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <cassert> @@ -15,7 +15,7 @@ #include <tao/pegtl/analyze.hpp> -namespace pegtl = tao::TAO_PEGTL_NAMESPACE; +namespace pegtl = TAO_PEGTL_NAMESPACE; namespace calculator { @@ -168,10 +168,10 @@ namespace calculator void insert( const std::string& name, const order p, const std::function< long( long, long ) >& f ) { assert( !name.empty() ); - m_ops.insert( { name, { p, f } } ); + m_ops.emplace( name, op{ p, f } ); } - const std::map< std::string, op >& ops() const + [[nodiscard]] const std::map< std::string, op >& ops() const noexcept { return m_ops; } @@ -188,8 +188,7 @@ namespace calculator struct comment : if_must< one< '#' >, until< eolf > > - { - }; + {}; // The calculator ignores all spaces and comments; space is a pegtl rule // that matches the usual ascii characters ' ', '\t', '\n' etc. In other @@ -197,8 +196,7 @@ namespace calculator struct ignored : sor< space, comment > - { - }; + {}; // Since the binary operators are taken from a runtime data structure // (rather than hard-coding them into the grammar), we need a custom @@ -207,14 +205,17 @@ namespace calculator struct infix { - using analyze_t = analysis::generic< analysis::rule_type::ANY >; + using analyze_t = analysis::generic< analysis::rule_type::any >; template< apply_mode, rewind_mode, - template< typename... > class Action, - template< typename... > class Control, - typename Input > - static bool match( Input& in, const operators& b, stacks& s ) + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, const operators& b, stacks& s, States&&... /*unused*/ ) { // Look for the longest match of the input against the operators in the operator map. @@ -246,12 +247,11 @@ namespace calculator } }; - // A number is a non-empty sequence of digits preceeded by an optional sign. + // A number is a non-empty sequence of digits preceded by an optional sign. struct number : seq< opt< one< '+', '-' > >, plus< digit > > - { - }; + {}; struct expression; @@ -260,45 +260,37 @@ namespace calculator struct bracket : if_must< one< '(' >, expression, one< ')' > > - { - }; + {}; // An atomic expression, i.e. one without operators, is either a number or // a bracketed expression. struct atomic : sor< number, bracket > - { - }; + {}; // An expression is a non-empty list of atomic expressions where each pair // of atomic expressions is separated by an infix operator and we allow - // the rule ignored as padding (before and after every singlar expression). + // the rule ignored as padding (before and after every single expression). struct expression : list< atomic, infix, ignored > - { - }; + {}; // The top-level grammar allows one expression and then expects eof. struct grammar : must< expression, eof > - { - }; + {}; // After the grammar we proceed with the additional actions that are // required to let our calculator actually do something. - // The base-case of the class template for the actions must derive from - // pegtl::nothing (or, alternatively, define an action that does something - // sensible for all rules for which no specialisation exists). + // The base-case of the class template for the actions, does nothing. template< typename Rule > struct action - : pegtl::nothing< Rule > - { - }; + {}; // This action will be called when the number rule matches; it converts the // matched portion of the input to a long and pushes it onto the operand @@ -310,8 +302,7 @@ namespace calculator template< typename Input > static void apply( const Input& in, const operators& /*unused*/, stacks& s ) { - std::stringstream ss; - ss.str( in.string() ); + std::stringstream ss( in.string() ); long v; ss >> v; s.push( v ); @@ -345,7 +336,9 @@ int main( int argc, char** argv ) { // Check the grammar for some possible issues. - pegtl::analyze< calculator::grammar >(); + if( pegtl::analyze< calculator::grammar >() != 0 ) { + return 1; + } // The objects required as state by the actions. @@ -355,7 +348,7 @@ int main( int argc, char** argv ) for( int i = 1; i < argc; ++i ) { // Parse and process the command-line arguments as calculator expressions... - pegtl::argv_input<> in( argv, i ); + pegtl::argv_input in( argv, i ); pegtl::parse< calculator::grammar, calculator::action >( in, b, s ); // ...and print the respective results to std::cout. diff --git a/packages/PEGTL/src/example/pegtl/chomsky_hierarchy.cpp b/packages/PEGTL/src/example/pegtl/chomsky_hierarchy.cpp index f60bb2c24..cfda74747 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 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <cassert> @@ -8,7 +8,7 @@ #include <tao/pegtl.hpp> -namespace pegtl = tao::TAO_PEGTL_NAMESPACE; +namespace pegtl = TAO_PEGTL_NAMESPACE; namespace example { @@ -42,10 +42,13 @@ namespace example { template< pegtl::apply_mode, pegtl::rewind_mode, - template< typename... > class Action, - template< typename... > class Control, - typename Input > - static bool match( Input& in, std::size_t& count ) + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, std::size_t& count, States&&... /*unused*/ ) { if( in.size( count ) >= count ) { for( std::size_t i = 0; i < count; ++i ) { @@ -67,7 +70,6 @@ namespace example template< typename Rule > struct action_2_with_state - : pegtl::nothing< Rule > { }; @@ -112,7 +114,7 @@ namespace example int main( int argc, char** argv ) { for( int i = 1; i < argc; ++i ) { - pegtl::argv_input<> in( argv, i ); + pegtl::argv_input in( argv, i ); const auto r3 = pegtl::parse< pegtl::seq< example::type_3, pegtl::eof > >( in ); in.restart(); const auto r2r = pegtl::parse< pegtl::seq< example::type_2_recursive, pegtl::eof > >( in ); diff --git a/packages/PEGTL/src/example/pegtl/csv1.cpp b/packages/PEGTL/src/example/pegtl/csv1.cpp index 109203c1d..f17c73936 100644 --- a/packages/PEGTL/src/example/pegtl/csv1.cpp +++ b/packages/PEGTL/src/example/pegtl/csv1.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <cassert> @@ -10,7 +10,7 @@ #include <tao/pegtl.hpp> -namespace pegtl = tao::TAO_PEGTL_NAMESPACE; +namespace pegtl = TAO_PEGTL_NAMESPACE; namespace csv1 { @@ -45,9 +45,7 @@ namespace csv1 template< typename Rule > struct action - : pegtl::nothing< Rule > - { - }; + {}; template<> struct action< value > @@ -56,8 +54,7 @@ namespace csv1 static void apply( const Input& in, result_data& data ) { assert( !data.empty() ); - std::stringstream ss; - ss << in.string(); + std::stringstream ss( in.string() ); unsigned long v; ss >> v; data.back().push_back( v ); @@ -93,7 +90,7 @@ namespace csv1 int main( int argc, char** argv ) { for( int i = 1; i < argc; ++i ) { - pegtl::file_input<> in( argv[ i ] ); + pegtl::file_input in( argv[ i ] ); csv1::result_data data; pegtl::parse< pegtl::must< csv1::file >, csv1::action, csv1::control >( in, data ); for( const auto& line : data ) { diff --git a/packages/PEGTL/src/example/pegtl/csv2.cpp b/packages/PEGTL/src/example/pegtl/csv2.cpp index 4da6dd15f..dcc2a06a2 100644 --- a/packages/PEGTL/src/example/pegtl/csv2.cpp +++ b/packages/PEGTL/src/example/pegtl/csv2.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2016-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <iostream> @@ -6,7 +6,7 @@ #include <tao/pegtl.hpp> -namespace pegtl = tao::TAO_PEGTL_NAMESPACE; +namespace pegtl = TAO_PEGTL_NAMESPACE; namespace csv2 { @@ -28,7 +28,7 @@ namespace csv2 struct quoted_value : pegtl::if_must< pegtl::one< '"' >, string_without< '"' >, pegtl::one< '"' > > {}; struct value : pegtl::sor< quoted_value, plain_value > {}; template< unsigned N > struct line : pegtl::seq< value, pegtl::rep< N - 1, pegtl::one< ',' >, value >, pegtl::eol > {}; - template< unsigned N > struct file : pegtl::until< pegtl::eof, line< N > > { static_assert( N, "N must be positive" ); }; + template< unsigned N > struct file : pegtl::until< pegtl::eof, line< N > > { static_assert( N != 0 ); }; // clang-format on // Meta-programming helper: @@ -85,9 +85,8 @@ namespace csv2 // Action class to fill in the above data structure: template< typename Rule > - struct action : pegtl::nothing< Rule > - { - }; + struct action + {}; template<> struct action< plain_value > @@ -102,8 +101,7 @@ namespace csv2 template<> struct action< string_without< '"' > > : action< plain_value > - { - }; + {}; template< unsigned N > struct action< line< N > > @@ -173,7 +171,7 @@ namespace csv2 int main( int argc, char** argv ) { for( int i = 1; i < argc; ++i ) { - pegtl::file_input<> in( argv[ i ] ); + pegtl::file_input in( argv[ i ] ); constexpr unsigned number_of_columns = 3; csv2::result_data< number_of_columns > data; pegtl::parse< pegtl::must< csv2::file< number_of_columns > >, csv2::action >( in, data ); diff --git a/packages/PEGTL/src/example/pegtl/double.hpp b/packages/PEGTL/src/example/pegtl/double.hpp index 336da79f3..02eb25944 100644 --- a/packages/PEGTL/src/example/pegtl/double.hpp +++ b/packages/PEGTL/src/example/pegtl/double.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_SRC_EXAMPLES_PEGTL_DOUBLE_HPP // NOLINT @@ -11,7 +11,7 @@ namespace double_ // A grammar for doubles suitable for std::stod without locale support. // See also: http://en.cppreference.com/w/cpp/string/basic_string/stof - using namespace tao::TAO_PEGTL_NAMESPACE; // NOLINT + using namespace TAO_PEGTL_NAMESPACE; // NOLINT // clang-format off struct plus_minus : opt< one< '+', '-' > > {}; diff --git a/packages/PEGTL/src/example/pegtl/dynamic_match.cpp b/packages/PEGTL/src/example/pegtl/dynamic_match.cpp index 990f2d324..55495006b 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <cstring> @@ -8,28 +8,29 @@ #include <tao/pegtl.hpp> -namespace pegtl = tao::TAO_PEGTL_NAMESPACE; +namespace pegtl = TAO_PEGTL_NAMESPACE; namespace dynamic { struct long_literal_id : pegtl::plus< pegtl::not_one< '[' > > - { - }; + {}; struct long_literal_open : pegtl::seq< pegtl::one< '[' >, long_literal_id, pegtl::one< '[' > > - { - }; + {}; struct long_literal_mark { template< pegtl::apply_mode, pegtl::rewind_mode, - template< typename... > class Action, - template< typename... > class Control, - typename Input > - static bool match( Input& in, const std::string& id, const std::string& /*unused*/ ) + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, const std::string& id, const std::string& /*unused*/, States&&... /*unused*/ ) { if( in.size( id.size() ) >= id.size() ) { if( std::memcmp( in.current(), id.data(), id.size() ) == 0 ) { @@ -43,24 +44,19 @@ namespace dynamic struct long_literal_close : pegtl::seq< pegtl::one< ']' >, long_literal_mark, pegtl::one< ']' > > - { - }; + {}; struct long_literal_body : pegtl::any - { - }; + {}; struct grammar : pegtl::if_must< long_literal_open, pegtl::until< long_literal_close, long_literal_body >, pegtl::eof > - { - }; + {}; template< typename Rule > struct action - : pegtl::nothing< Rule > - { - }; + {}; template<> struct action< long_literal_id > @@ -90,7 +86,7 @@ int main( int argc, char** argv ) std::string id; std::string body; - pegtl::argv_input<> in( argv, 1 ); + pegtl::argv_input in( argv, 1 ); pegtl::parse< dynamic::grammar, dynamic::action >( in, id, body ); std::cout << "long literal id was: " << id << std::endl; diff --git a/packages/PEGTL/src/example/pegtl/hello_world.cpp b/packages/PEGTL/src/example/pegtl/hello_world.cpp index 8a9aacb2f..18a6ae2b3 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <iostream> @@ -6,7 +6,7 @@ #include <tao/pegtl.hpp> -namespace pegtl = tao::TAO_PEGTL_NAMESPACE; +namespace pegtl = TAO_PEGTL_NAMESPACE; namespace hello { @@ -18,9 +18,7 @@ namespace hello template< typename Rule > struct action - : pegtl::nothing< Rule > - { - }; + {}; template<> struct action< name > @@ -39,7 +37,7 @@ int main( int argc, char** argv ) if( argc > 1 ) { std::string name; - pegtl::argv_input<> in( argv, 1 ); + pegtl::argv_input in( argv, 1 ); pegtl::parse< hello::grammar, hello::action >( in, name ); std::cout << "Good bye, " << name << "!" << std::endl; diff --git a/packages/PEGTL/src/example/pegtl/indent_aware.cpp b/packages/PEGTL/src/example/pegtl/indent_aware.cpp index ef979d1b5..1d504a82a 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 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <cassert> @@ -7,7 +7,7 @@ #include <tao/pegtl.hpp> -namespace pegtl = tao::TAO_PEGTL_NAMESPACE; +namespace pegtl = TAO_PEGTL_NAMESPACE; /* @@ -73,10 +73,10 @@ namespace example enum class type { - DEF, - IF, - ELSE, - LET + def, + if_, + else_, + let }; struct entry @@ -84,8 +84,7 @@ namespace example entry( const std::size_t i, const example::type t ) : indent( i ), type( t ) - { - } + {} std::size_t indent; example::type type; @@ -101,9 +100,7 @@ namespace example template< typename Rule > struct action - : pegtl::nothing< Rule > - { - }; + {}; template<> struct action< co > @@ -119,7 +116,7 @@ namespace example { static void apply0( state& s ) { - s.stack.emplace_back( s.current_indent, type::DEF ); + s.stack.emplace_back( s.current_indent, type::def ); } }; @@ -128,7 +125,7 @@ namespace example { static void apply0( state& s ) { - s.stack.emplace_back( s.current_indent, type::IF ); + s.stack.emplace_back( s.current_indent, type::if_ ); } }; @@ -139,10 +136,10 @@ namespace example static void apply( const Input& in, state& s ) { assert( !s.stack.empty() ); - if( ( s.stack.back().type != type::IF ) || ( s.stack.back().indent != s.current_indent ) ) { + if( ( s.stack.back().type != type::if_ ) || ( s.stack.back().indent != s.current_indent ) ) { throw pegtl::parse_error( "expected previous 'if' on same indent as current 'else'", in ); // NOLINT } - s.stack.back().type = type::ELSE; + s.stack.back().type = type::else_; } }; @@ -151,7 +148,7 @@ namespace example { static void apply0( state& s ) { - s.stack.emplace_back( s.current_indent, type::LET ); + s.stack.emplace_back( s.current_indent, type::let ); } }; @@ -209,7 +206,7 @@ namespace example int main( int argc, char** argv ) { for( int i = 1; i < argc; ++i ) { - pegtl::file_input<> in( argv[ i ] ); + pegtl::file_input in( argv[ i ] ); example::state is; pegtl::parse< example::grammar, example::action >( in, is ); } diff --git a/packages/PEGTL/src/example/pegtl/json_build_two.cpp b/packages/PEGTL/src/example/pegtl/json_build.cpp similarity index 59% rename from packages/PEGTL/src/example/pegtl/json_build_two.cpp rename to packages/PEGTL/src/example/pegtl/json_build.cpp index 67de229cc..7d7b9dc77 100644 --- a/packages/PEGTL/src/example/pegtl/json_build_two.cpp +++ b/packages/PEGTL/src/example/pegtl/json_build.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <cassert> @@ -6,18 +6,19 @@ #include <vector> #include <tao/pegtl.hpp> -#include <tao/pegtl/contrib/changes.hpp> #include <tao/pegtl/contrib/json.hpp> #include "json_classes.hpp" #include "json_errors.hpp" #include "json_unescape.hpp" +namespace pegtl = TAO_PEGTL_NAMESPACE; + namespace examples { // State class that stores the result of a JSON parsing run -- a single JSON object. - // The other members are used temporarily, at the end of a (successful) parsing run - // they are expected to be empty. + // The other members are used temporarily, at the end of a (successful) parsing run. + // They are expected to be empty. struct json_state { @@ -27,20 +28,15 @@ namespace examples std::vector< std::shared_ptr< object_json > > objects; }; - // Action and Control classes - - template< typename Rule > - struct action : unescape_action< Rule > // Inherit from json_unescape.hpp. - { - }; + // Action class template< typename Rule > - struct control : errors< Rule > // Inherit from json_errors.hpp. + struct action { }; template<> - struct action< tao::TAO_PEGTL_NAMESPACE::json::null > + struct action< pegtl::json::null > { static void apply0( json_state& state ) { @@ -49,7 +45,7 @@ namespace examples }; template<> - struct action< tao::TAO_PEGTL_NAMESPACE::json::true_ > + struct action< pegtl::json::true_ > { static void apply0( json_state& state ) { @@ -58,7 +54,7 @@ namespace examples }; template<> - struct action< tao::TAO_PEGTL_NAMESPACE::json::false_ > + struct action< pegtl::json::false_ > { static void apply0( json_state& state ) { @@ -67,38 +63,31 @@ namespace examples }; template<> - struct action< tao::TAO_PEGTL_NAMESPACE::json::number > + struct action< pegtl::json::number > { template< typename Input > static void apply( const Input& in, json_state& state ) { - std::stringstream ss; - ss << in.string(); + std::stringstream ss( in.string() ); long double v; ss >> v; // NOTE: not quite correct for JSON but we'll use it for this simple example. state.result = std::make_shared< number_json >( v ); } }; - // To parse a string, we change the state to decouple string parsing/unescaping - - struct string_state - : public unescape_state_base + template<> + struct action< pegtl::json::string::content > + : json_unescape { - void success( json_state& state ) + template< typename Input > + static void success( const Input& /*unused*/, std::string& s, json_state& state ) { - state.result = std::make_shared< string_json >( unescaped ); + state.result = std::make_shared< string_json >( std::move( s ) ); } }; template<> - struct control< tao::TAO_PEGTL_NAMESPACE::json::string::content > - : tao::TAO_PEGTL_NAMESPACE::change_state< tao::TAO_PEGTL_NAMESPACE::json::string::content, string_state, errors > - { - }; - - template<> - struct action< tao::TAO_PEGTL_NAMESPACE::json::array::begin > + struct action< pegtl::json::array::begin > { static void apply0( json_state& state ) { @@ -107,7 +96,7 @@ namespace examples }; template<> - struct action< tao::TAO_PEGTL_NAMESPACE::json::array::element > + struct action< pegtl::json::array::element > { static void apply0( json_state& state ) { @@ -116,7 +105,7 @@ namespace examples }; template<> - struct action< tao::TAO_PEGTL_NAMESPACE::json::array::end > + struct action< pegtl::json::array::end > { static void apply0( json_state& state ) { @@ -126,7 +115,7 @@ namespace examples }; template<> - struct action< tao::TAO_PEGTL_NAMESPACE::json::object::begin > + struct action< pegtl::json::object::begin > { static void apply0( json_state& state ) { @@ -136,22 +125,19 @@ namespace examples // To parse a key, we change the state to decouple string parsing/unescaping - struct key_state : unescape_state_base + template<> + struct action< pegtl::json::key::content > + : json_unescape { - void success( json_state& state ) + template< typename Input > + static void success( const Input& /*unused*/, std::string& s, json_state& state ) { - state.keys.push_back( std::move( unescaped ) ); + state.keys.push_back( std::move( s ) ); } }; template<> - struct control< tao::TAO_PEGTL_NAMESPACE::json::key::content > - : tao::TAO_PEGTL_NAMESPACE::change_state< tao::TAO_PEGTL_NAMESPACE::json::key::content, key_state, errors > - { - }; - - template<> - struct action< tao::TAO_PEGTL_NAMESPACE::json::object::element > + struct action< pegtl::json::object::element > { static void apply0( json_state& state ) { @@ -161,7 +147,7 @@ namespace examples }; template<> - struct action< tao::TAO_PEGTL_NAMESPACE::json::object::end > + struct action< pegtl::json::object::end > { static void apply0( json_state& state ) { @@ -170,7 +156,7 @@ namespace examples } }; - using grammar = tao::TAO_PEGTL_NAMESPACE::must< tao::TAO_PEGTL_NAMESPACE::json::text, tao::TAO_PEGTL_NAMESPACE::eof >; + using grammar = pegtl::must< pegtl::json::text, pegtl::eof >; } // namespace examples @@ -181,8 +167,8 @@ int main( int argc, char** argv ) } else { examples::json_state state; - tao::TAO_PEGTL_NAMESPACE::file_input<> in( argv[ 1 ] ); - tao::TAO_PEGTL_NAMESPACE::parse< examples::grammar, examples::action, examples::control >( in, state ); + pegtl::file_input in( argv[ 1 ] ); + pegtl::parse< examples::grammar, examples::action, examples::errors >( in, state ); assert( state.keys.empty() ); assert( state.arrays.empty() ); assert( state.objects.empty() ); diff --git a/packages/PEGTL/src/example/pegtl/json_build_one.cpp b/packages/PEGTL/src/example/pegtl/json_build_one.cpp deleted file mode 100644 index 17db35a74..000000000 --- a/packages/PEGTL/src/example/pegtl/json_build_one.cpp +++ /dev/null @@ -1,192 +0,0 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#include <cassert> -#include <sstream> - -#include <tao/pegtl.hpp> -#include <tao/pegtl/contrib/changes.hpp> -#include <tao/pegtl/contrib/json.hpp> - -#include "json_classes.hpp" -#include "json_errors.hpp" -#include "json_unescape.hpp" - -namespace examples -{ - // Basic state class that stores the result of a JSON parsing run -- a single JSON object. - - struct result_state - { - result_state() = default; - result_state( const result_state& ) = delete; - result_state( result_state&& ) = delete; - - ~result_state() = default; - - void operator=( const result_state& ) = delete; - void operator=( result_state&& ) = delete; - - std::shared_ptr< json_base > result; - }; - - // Action class for the simple cases... - - template< typename Rule > - struct value_action - : unescape_action< Rule > - { - }; - - struct string_state - : public unescape_state_base - { - void success( result_state& result ) - { - result.result = std::make_shared< string_json >( std::move( unescaped ) ); - } - }; - - template<> - struct value_action< tao::TAO_PEGTL_NAMESPACE::json::null > - { - static void apply0( result_state& result ) - { - result.result = std::make_shared< null_json >(); - } - }; - - template<> - struct value_action< tao::TAO_PEGTL_NAMESPACE::json::true_ > - { - static void apply0( result_state& result ) - { - result.result = std::make_shared< boolean_json >( true ); - } - }; - - template<> - struct value_action< tao::TAO_PEGTL_NAMESPACE::json::false_ > - { - static void apply0( result_state& result ) - { - result.result = std::make_shared< boolean_json >( false ); - } - }; - - template<> - struct value_action< tao::TAO_PEGTL_NAMESPACE::json::number > - { - template< typename Input > - static void apply( const Input& in, result_state& result ) - { - std::stringstream ss; - ss << in.string(); - long double v; - ss >> v; // NOTE: not quite correct for JSON but we'll use it for this simple example. - result.result = std::make_shared< number_json >( v ); - } - }; - - // State and action classes to accumulate the data for a JSON array. - - struct array_state - : public result_state - { - std::shared_ptr< array_json > array = std::make_shared< array_json >(); - - void push_back() - { - array->data.push_back( std::move( result ) ); - result.reset(); - } - - void success( result_state& in_result ) - { - if( this->result ) { - push_back(); - } - in_result.result = array; - } - }; - - template< typename Rule > - struct array_action - : tao::TAO_PEGTL_NAMESPACE::nothing< Rule > - { - }; - - template<> - struct array_action< tao::TAO_PEGTL_NAMESPACE::json::value_separator > - { - static void apply0( array_state& result ) - { - result.push_back(); - } - }; - - // State and action classes to accumulate the data for a JSON object. - - struct object_state - : public result_state - { - std::string unescaped; - std::shared_ptr< object_json > object = std::make_shared< object_json >(); - - void insert() - { - object->data.insert( std::make_pair( std::move( unescaped ), std::move( result ) ) ); - unescaped.clear(); - result.reset(); - } - - void success( result_state& in_result ) - { - if( this->result ) { - insert(); - } - in_result.result = object; - } - }; - - template< typename Rule > - struct object_action - : unescape_action< Rule > - { - }; - - template<> - struct object_action< tao::TAO_PEGTL_NAMESPACE::json::value_separator > - { - static void apply0( object_state& result ) - { - result.insert(); - } - }; - - // Put together a control class that changes the actions and states as required. - - // clang-format off - template< typename Rule > struct control : errors< Rule > {}; // Inherit from json_errors.hpp. - - template<> struct control< tao::TAO_PEGTL_NAMESPACE::json::value > : tao::TAO_PEGTL_NAMESPACE::change_action< tao::TAO_PEGTL_NAMESPACE::json::value, value_action, errors > {}; - template<> struct control< tao::TAO_PEGTL_NAMESPACE::json::string::content > : tao::TAO_PEGTL_NAMESPACE::change_state< tao::TAO_PEGTL_NAMESPACE::json::string::content, string_state, errors > {}; - template<> struct control< tao::TAO_PEGTL_NAMESPACE::json::array::content > : tao::TAO_PEGTL_NAMESPACE::change_state_and_action< tao::TAO_PEGTL_NAMESPACE::json::array::content, array_state, array_action, errors > {}; - template<> struct control< tao::TAO_PEGTL_NAMESPACE::json::object::content > : tao::TAO_PEGTL_NAMESPACE::change_state_and_action< tao::TAO_PEGTL_NAMESPACE::json::object::content, object_state, object_action, errors > {}; - - struct grammar : tao::TAO_PEGTL_NAMESPACE::must< tao::TAO_PEGTL_NAMESPACE::json::text, tao::TAO_PEGTL_NAMESPACE::eof > {}; - // clang-format on - -} // namespace examples - -int main( int argc, char** argv ) -{ - for( int i = 1; i < argc; ++i ) { - examples::result_state result; - tao::TAO_PEGTL_NAMESPACE::file_input<> in( argv[ i ] ); - tao::TAO_PEGTL_NAMESPACE::parse< examples::grammar, tao::TAO_PEGTL_NAMESPACE::nothing, examples::control >( in, result ); - assert( result.result ); - std::cout << result.result << std::endl; - } - return 0; -} diff --git a/packages/PEGTL/src/example/pegtl/json_classes.hpp b/packages/PEGTL/src/example/pegtl/json_classes.hpp index 1d09e1fb7..0e5567e95 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_SRC_EXAMPLES_PEGTL_JSON_CLASSES_HPP // NOLINT @@ -14,12 +14,12 @@ namespace examples { enum class json_type { - ARRAY, - BOOLEAN, - NULL_, - NUMBER, - OBJECT, - STRING + array, + boolean, + null, + number, + object, + string }; class json_base @@ -59,7 +59,7 @@ namespace examples : public json_base { array_json() - : json_base( json_type::ARRAY ) + : json_base( json_type::array ) { } @@ -83,7 +83,7 @@ namespace examples : public json_base { explicit boolean_json( const bool in_data ) - : json_base( json_type::BOOLEAN ), + : json_base( json_type::boolean ), data( in_data ) { } @@ -100,7 +100,7 @@ namespace examples : public json_base { null_json() - : json_base( json_type::NULL_ ) + : json_base( json_type::null ) { } @@ -114,7 +114,7 @@ namespace examples : public json_base { explicit number_json( const long double in_data ) - : json_base( json_type::NUMBER ), + : json_base( json_type::number ), data( in_data ) { } @@ -179,7 +179,7 @@ namespace examples : public json_base { explicit string_json( const std::string& in_data ) // NOLINT - : json_base( json_type::STRING ), + : json_base( json_type::string ), data( in_data ) { } @@ -196,7 +196,7 @@ namespace examples : public json_base { object_json() - : json_base( json_type::OBJECT ) + : json_base( json_type::object ) { } diff --git a/packages/PEGTL/src/example/pegtl/json_count.cpp b/packages/PEGTL/src/example/pegtl/json_count.cpp index ce8f26a6c..7b6cd295b 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <iomanip> @@ -11,7 +11,7 @@ #include <tao/pegtl/contrib/json.hpp> #include <tao/pegtl/file_input.hpp> -using namespace tao::TAO_PEGTL_NAMESPACE; // NOLINT +using namespace TAO_PEGTL_NAMESPACE; // NOLINT using grammar = must< json::text, eof >; int main( int argc, char** argv ) @@ -19,10 +19,10 @@ int main( int argc, char** argv ) counter_state cs; for( int i = 1; i < argc; ++i ) { - file_input<> in( argv[ i ] ); + file_input in( argv[ i ] ); parse< grammar, nothing, counter >( in, cs ); } - std::cout << std::right << std::setw( 72 ) << "RULE NAME" << std::left << " START SUCCESS FAILURE" << std::endl; + std::cout << std::right << std::setw( 72 ) << "RULE NAME" << std::left << " START success FAILURE" << std::endl; for( const auto& j : cs.counts ) { std::cout << std::right << std::setw( 72 ) << j.first << " " << std::setw( 8 ) << j.second.start << " " << std::setw( 8 ) << j.second.success << " " << std::setw( 8 ) << j.second.failure << std::endl; } diff --git a/packages/PEGTL/src/example/pegtl/json_errors.hpp b/packages/PEGTL/src/example/pegtl/json_errors.hpp index 77668ea0a..07067cf3e 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_SRC_EXAMPLES_PEGTL_JSON_ERRORS_HPP // NOLINT @@ -7,24 +7,26 @@ #include <tao/pegtl.hpp> #include <tao/pegtl/contrib/json.hpp> +namespace pegtl = TAO_PEGTL_NAMESPACE; + namespace examples { // This file shows how to throw exceptions with // custom error messages for parse errors. A custom // control class is created that delegates everything - // to the PEGTL default control class tao::TAO_PEGTL_NAMESPACE::normal<> + // to the PEGTL default control class TAO_PEGTL_NAMESPACE::normal<> // except for the throwing of exceptions: template< typename Rule > struct errors - : public tao::TAO_PEGTL_NAMESPACE::normal< Rule > + : public pegtl::normal< Rule > { static const std::string error_message; template< typename Input, typename... States > static void raise( const Input& in, States&&... /*unused*/ ) { - throw tao::TAO_PEGTL_NAMESPACE::parse_error( error_message, in ); + throw pegtl::parse_error( error_message, in ); } }; @@ -32,23 +34,23 @@ namespace examples // member are then used in the exception messages: // clang-format off - template<> const std::string errors< tao::TAO_PEGTL_NAMESPACE::json::text >::error_message = "no valid JSON"; // NOLINT - - template<> const std::string errors< tao::TAO_PEGTL_NAMESPACE::json::end_array >::error_message = "incomplete array, expected ']'"; // NOLINT - template<> const std::string errors< tao::TAO_PEGTL_NAMESPACE::json::end_object >::error_message = "incomplete object, expected '}'"; // NOLINT - template<> const std::string errors< tao::TAO_PEGTL_NAMESPACE::json::member >::error_message = "expected member"; // NOLINT - template<> const std::string errors< tao::TAO_PEGTL_NAMESPACE::json::name_separator >::error_message = "expected ':'"; // NOLINT - template<> const std::string errors< tao::TAO_PEGTL_NAMESPACE::json::array_element >::error_message = "expected value"; // NOLINT - template<> const std::string errors< tao::TAO_PEGTL_NAMESPACE::json::value >::error_message = "expected value"; // NOLINT - - template<> const std::string errors< tao::TAO_PEGTL_NAMESPACE::json::digits >::error_message = "expected at least one digit"; // NOLINT - template<> const std::string errors< tao::TAO_PEGTL_NAMESPACE::json::xdigit >::error_message = "incomplete universal character name"; // NOLINT - template<> const std::string errors< tao::TAO_PEGTL_NAMESPACE::json::escaped >::error_message = "unknown escape sequence"; // NOLINT - template<> const std::string errors< tao::TAO_PEGTL_NAMESPACE::json::char_ >::error_message = "invalid character in string"; // NOLINT - template<> const std::string errors< tao::TAO_PEGTL_NAMESPACE::json::string::content >::error_message = "unterminated string"; // NOLINT - template<> const std::string errors< tao::TAO_PEGTL_NAMESPACE::json::key::content >::error_message = "unterminated key"; // NOLINT - - template<> const std::string errors< tao::TAO_PEGTL_NAMESPACE::eof >::error_message = "unexpected character after JSON value"; // NOLINT + template<> inline const std::string errors< pegtl::json::text >::error_message = "no valid JSON"; // NOLINT + + template<> inline const std::string errors< pegtl::json::end_array >::error_message = "incomplete array, expected ']'"; // NOLINT + template<> inline const std::string errors< pegtl::json::end_object >::error_message = "incomplete object, expected '}'"; // NOLINT + template<> inline const std::string errors< pegtl::json::member >::error_message = "expected member"; // NOLINT + template<> inline const std::string errors< pegtl::json::name_separator >::error_message = "expected ':'"; // NOLINT + template<> inline const std::string errors< pegtl::json::array_element >::error_message = "expected value"; // NOLINT + template<> inline const std::string errors< pegtl::json::value >::error_message = "expected value"; // NOLINT + + template<> inline const std::string errors< pegtl::json::digits >::error_message = "expected at least one digit"; // NOLINT + template<> inline const std::string errors< pegtl::json::xdigit >::error_message = "incomplete universal character name"; // NOLINT + template<> inline const std::string errors< pegtl::json::escaped >::error_message = "unknown escape sequence"; // NOLINT + template<> inline const std::string errors< pegtl::json::char_ >::error_message = "invalid character in string"; // NOLINT + template<> inline const std::string errors< pegtl::json::string::content >::error_message = "unterminated string"; // NOLINT + template<> inline const std::string errors< pegtl::json::key::content >::error_message = "unterminated key"; // NOLINT + + template<> inline const std::string errors< pegtl::eof >::error_message = "unexpected character after JSON value"; // NOLINT // clang-format on // The raise()-function-template is instantiated exactly diff --git a/packages/PEGTL/src/example/pegtl/json_parse.cpp b/packages/PEGTL/src/example/pegtl/json_parse.cpp index 7b41924d7..65f62b21a 100644 --- a/packages/PEGTL/src/example/pegtl/json_parse.cpp +++ b/packages/PEGTL/src/example/pegtl/json_parse.cpp @@ -1,17 +1,17 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <tao/pegtl.hpp> #include "json_errors.hpp" -using namespace tao::TAO_PEGTL_NAMESPACE; // NOLINT +using namespace TAO_PEGTL_NAMESPACE; // NOLINT using grammar = must< json::text, eof >; int main( int argc, char** argv ) { for( int i = 1; i < argc; ++i ) { - argv_input<> in( argv, i ); + argv_input in( argv, i ); parse< grammar, nothing, examples::errors >( in ); } return 0; diff --git a/packages/PEGTL/src/example/pegtl/json_unescape.hpp b/packages/PEGTL/src/example/pegtl/json_unescape.hpp index 2f067b6cd..09be84f2c 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_SRC_EXAMPLES_PEGTL_JSON_UNESCAPE_HPP // NOLINT @@ -6,42 +6,24 @@ #include <string> -#include <tao/pegtl.hpp> +#include <tao/pegtl/change_action_and_states.hpp> #include <tao/pegtl/contrib/json.hpp> #include <tao/pegtl/contrib/unescape.hpp> namespace examples { - // State base class to store an unescaped string - - struct unescape_state_base - { - unescape_state_base() = default; - - unescape_state_base( const unescape_state_base& ) = delete; - unescape_state_base( unescape_state_base&& ) = delete; - - ~unescape_state_base() = default; - - void operator=( const unescape_state_base& ) = delete; - void operator=( unescape_state_base&& ) = delete; - - std::string unescaped; - }; - // Action class for parsing literal strings, uses the PEGTL unescape utilities, cf. unescape.cpp. - template< typename Rule, template< typename... > class Base = tao::TAO_PEGTL_NAMESPACE::nothing > - struct unescape_action : Base< Rule > - { - }; - // clang-format off - template<> struct unescape_action< tao::TAO_PEGTL_NAMESPACE::json::unicode > : tao::TAO_PEGTL_NAMESPACE::unescape::unescape_j {}; - template<> struct unescape_action< tao::TAO_PEGTL_NAMESPACE::json::escaped_char > : tao::TAO_PEGTL_NAMESPACE::unescape::unescape_c< tao::TAO_PEGTL_NAMESPACE::json::escaped_char, '"', '\\', '/', '\b', '\f', '\n', '\r', '\t' > {}; - template<> struct unescape_action< tao::TAO_PEGTL_NAMESPACE::json::unescaped > : tao::TAO_PEGTL_NAMESPACE::unescape::append_all {}; + 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 {}; // clang-format on + using json_unescape = tao::pegtl::change_action_and_states< json_unescape_action, std::string >; + } // namespace examples #endif diff --git a/packages/PEGTL/src/example/pegtl/lua53_parse.cpp b/packages/PEGTL/src/example/pegtl/lua53_parse.cpp index dcb48f378..70449f4fe 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <tao/pegtl.hpp> @@ -89,7 +89,7 @@ namespace lua53 // comments). In some places, where it is more efficient, // right padding is used. - namespace pegtl = tao::TAO_PEGTL_NAMESPACE; + namespace pegtl = TAO_PEGTL_NAMESPACE; // clang-format off struct short_comment : pegtl::until< pegtl::eolf > {}; @@ -159,8 +159,6 @@ namespace lua53 template< typename R > struct pad : pegtl::pad< R, sep > {}; - struct three_dots : pegtl::three< '.' > {}; - struct name : pegtl::seq< pegtl::not_at< keyword >, pegtl::identifier > {}; struct single : pegtl::one< 'a', 'b', 'f', 'n', 'r', 't', 'v', '\\', '"', '\'', '0', '\n' > {}; @@ -216,8 +214,8 @@ namespace lua53 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 : pegtl::seq< name_list, pegtl::opt_must< pad< pegtl::one< ',' > >, three_dots > > {}; - struct parameter_list : pegtl::sor< three_dots, 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 : 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 > {}; @@ -257,7 +255,7 @@ namespace lua53 struct expr_twelve : pegtl::sor< key_nil, key_true, key_false, - three_dots, + pegtl::ellipsis, numeral, literal_string, function_literal, @@ -337,11 +335,13 @@ namespace lua53 int main( int argc, char** argv ) { - tao::TAO_PEGTL_NAMESPACE::analyze< lua53::grammar >(); + if( TAO_PEGTL_NAMESPACE::analyze< lua53::grammar >() != 0 ) { + return 1; + } for( int i = 1; i < argc; ++i ) { - tao::TAO_PEGTL_NAMESPACE::file_input<> in( argv[ i ] ); - tao::TAO_PEGTL_NAMESPACE::parse< lua53::grammar >( in ); + TAO_PEGTL_NAMESPACE::file_input in( argv[ i ] ); + TAO_PEGTL_NAMESPACE::parse< lua53::grammar >( in ); } return 0; } diff --git a/packages/PEGTL/src/example/pegtl/modulus_match.cpp b/packages/PEGTL/src/example/pegtl/modulus_match.cpp index 6d7e4e972..76c8394d7 100644 --- a/packages/PEGTL/src/example/pegtl/modulus_match.cpp +++ b/packages/PEGTL/src/example/pegtl/modulus_match.cpp @@ -1,16 +1,16 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <tao/pegtl.hpp> -using namespace tao::TAO_PEGTL_NAMESPACE; // NOLINT +using namespace TAO_PEGTL_NAMESPACE; // NOLINT namespace modulus { template< unsigned M, unsigned R = 0 > struct my_rule { - using analyze_t = analysis::generic< analysis::rule_type::ANY >; + using analyze_t = analysis::generic< analysis::rule_type::any >; static_assert( M > 1, "Modulus must be greater than 1" ); static_assert( R < M, "Remainder must be less than modulus" ); @@ -38,7 +38,7 @@ namespace modulus int main( int argc, char** argv ) { if( argc > 1 ) { - argv_input<> in( argv, 1 ); + argv_input in( argv, 1 ); parse< modulus::grammar >( in ); } return 0; diff --git a/packages/PEGTL/src/example/pegtl/parse_tree.cpp b/packages/PEGTL/src/example/pegtl/parse_tree.cpp index 424a3b40e..3e5f6ee74 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <iostream> @@ -7,8 +7,9 @@ #include <tao/pegtl.hpp> #include <tao/pegtl/contrib/parse_tree.hpp> +#include <tao/pegtl/contrib/parse_tree_to_dot.hpp> -using namespace tao::TAO_PEGTL_NAMESPACE; // NOLINT +using namespace TAO_PEGTL_NAMESPACE; // NOLINT namespace example { @@ -32,10 +33,12 @@ namespace example struct product : list_must< value, sor< multiply, divide > > {}; struct expression : list_must< product, sor< plus, minus > > {}; - struct grammar : seq< expression, eof > {}; + struct grammar : must< expression, eof > {}; + // clang-format on // after a node is stored successfully, you can add an optional transformer like this: - struct rearrange : std::true_type + struct rearrange + : parse_tree::apply< rearrange > // allows bulk selection, see selector<...> { // recursively rearrange nodes. the basic principle is: // @@ -52,7 +55,8 @@ namespace example // if only one child is left for LHS..., replace the PROD/EXPR with the child directly. // otherwise, perform the above transformation, then apply it recursively until LHS... // becomes a single child, which then replaces the parent node and the recursion ends. - static void transform( std::unique_ptr< parse_tree::node >& n ) + template< typename... States > + static void transform( std::unique_ptr< parse_tree::node >& n, States&&... st ) { if( n->children.size() == 1 ) { n = std::move( n->children.back() ); @@ -67,7 +71,7 @@ namespace example o->children.emplace_back( std::move( n ) ); o->children.emplace_back( std::move( r ) ); n = std::move( o ); - transform( n->children.front() ); + transform( n->children.front(), st... ); } } }; @@ -77,60 +81,42 @@ namespace example template< typename Rule > using selector = parse_tree::selector< Rule, - parse_tree::apply_store_content::to< + parse_tree::store_content::on< integer, variable >, - parse_tree::apply_remove_content::to< + parse_tree::remove_content::on< plus, minus, multiply, divide >, - parse_tree::apply< rearrange >::to< + rearrange::on< product, expression > >; - // debugging/show result: - - void print_node( const parse_tree::node& n, const std::string& s = "" ) - { - // detect the root node: - if( n.is_root() ) { - std::cout << "ROOT" << std::endl; - } - else { - if( n.has_content() ) { - std::cout << s << n.name() << " \"" << n.content() << "\" at " << n.begin() << " to " << n.end() << std::endl; - } - else { - std::cout << s << n.name() << " at " << n.begin() << std::endl; - } - } - // print all child nodes - if( !n.children.empty() ) { - const auto s2 = s + " "; - for( auto& up : n.children ) { - print_node( *up, s2 ); - } - } - } - } // namespace example int main( int argc, char** argv ) { - for( int i = 1; i < argc; ++i ) { - try { - argv_input<> in( argv, i ); - if( const auto root = parse_tree::parse< example::grammar, example::selector >( in ) ) { - example::print_node( *root ); - } - else { - std::cout << "PARSE FAILED" << std::endl; - } - } - catch( const std::exception& e ) { - std::cout << "PARSE FAILED WITH EXCEPTION: " << e.what() << std::endl; - } + if( argc != 2 ) { + std::cerr << "Usage: " << argv[ 0 ] << " EXPR\n" + << "Generate a 'dot' file from expression.\n\n" + << "Example: " << argv[ 0 ] << " \"(2*a + 3*b) / (4*n)\" | dot -Tpng -o parse_tree.png\n"; + return 1; + } + argv_input in( argv, 1 ); + try { + const auto root = parse_tree::parse< example::grammar, example::selector >( in ); + parse_tree::print_dot( std::cout, *root ); + return 0; + } + catch( const parse_error& e ) { + const auto p = e.positions.front(); + std::cerr << e.what() << std::endl + << in.line_at( p ) << std::endl + << std::string( p.byte_in_line, ' ' ) << '^' << std::endl; + } + catch( const std::exception& e ) { + std::cerr << e.what() << std::endl; } - return 0; + return 1; } diff --git a/packages/PEGTL/src/example/pegtl/parse_tree_user_state.cpp b/packages/PEGTL/src/example/pegtl/parse_tree_user_state.cpp new file mode 100644 index 000000000..6b207c062 --- /dev/null +++ b/packages/PEGTL/src/example/pegtl/parse_tree_user_state.cpp @@ -0,0 +1,37 @@ +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#include <type_traits> + +#include <tao/pegtl.hpp> +#include <tao/pegtl/contrib/parse_tree.hpp> + +using namespace TAO_PEGTL_NAMESPACE; // NOLINT + +template< typename > +using selector = std::true_type; + +struct user_state +{}; + +template< typename Rule > +struct work +{}; + +template<> +struct work< success > +{ + template< typename Input > + static void apply( const Input& /*unused*/, user_state& /*unused*/ ) + {} +}; + +int main() +{ + memory_input input( "", "dummy" ); + + user_state state; + auto root = parse_tree::parse< success, selector, work >( input, state ); + + return 0; +} diff --git a/packages/PEGTL/src/example/pegtl/proto3.cpp b/packages/PEGTL/src/example/pegtl/proto3.cpp index b871ef480..a1b6f281b 100644 --- a/packages/PEGTL/src/example/pegtl/proto3.cpp +++ b/packages/PEGTL/src/example/pegtl/proto3.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #define TAO_PEGTL_PRETTY_DEMANGLE 1 @@ -6,140 +6,134 @@ #include <tao/pegtl.hpp> #include <tao/pegtl/analyze.hpp> -namespace tao +namespace TAO_PEGTL_NAMESPACE::proto3 { - namespace TAO_PEGTL_NAMESPACE - { - namespace proto3 - { - // clang-format off - - struct comment : seq< two< '/' >, until< eolf > > {}; - struct sp : sor< space, comment > {}; - struct sps : star< sp > {}; - - struct comma : one< ',' > {}; - struct dot : one< '.' > {}; - struct equ : one< '=' > {}; - struct semi : one< ';' > {}; - - struct option; - struct message; - - struct odigit : range< '0', '7' > {}; - - struct ident_first : ranges< 'a', 'z', 'A', 'Z' > {}; // NOTE: Yes, no '_'. - struct ident_other : ranges< 'a', 'z', 'A', 'Z', '0', '9', '_' > {}; - struct ident : seq< ident_first, star< ident_other > > {}; - struct full_ident : list_must< ident, dot > {}; + // clang-format off + + struct comment : seq< two< '/' >, until< eolf > > {}; + struct sp : sor< space, comment > {}; + struct sps : star< sp > {}; + + struct comma : one< ',' > {}; + struct dot : one< '.' > {}; + struct equ : one< '=' > {}; + struct semi : one< ';' > {}; + + struct option; + struct message; - struct oct_lit : seq< one< '0' >, star< odigit > > {}; - struct hex_lit : seq< one< '0' >, one< 'x', 'X' >, plus< xdigit > > {}; - struct dec_lit : seq< range< '1', '9' >, star< digit > > {}; - struct int_lit : sor< dec_lit, hex_lit, oct_lit > {}; + struct odigit : range< '0', '7' > {}; - struct hex_escape : if_must< one< 'x', 'X' >, xdigit, xdigit > {}; - struct oct_escape : if_must< odigit, odigit, odigit > {}; - struct char_escape : one< 'a', 'b', 'f', 'n', 'r', 't', 'v', '\\', '\'', '"' > {}; - struct escape : if_must< one< '\\' >, hex_escape, oct_escape, char_escape > {}; - struct char_value : sor< escape, not_one< '\n', '\0' > > {}; // NOTE: No need to exclude '\' from not_one<>, see escape rule. - template< char Q > - struct str_impl : if_must< one< Q >, until< one< Q >, char_value > > {}; - struct str_lit : sor< str_impl< '\'' >, str_impl< '"' > > {}; + struct ident_first : ranges< 'a', 'z', 'A', 'Z' > {}; // NOTE: Yes, no '_'. + struct ident_other : ranges< 'a', 'z', 'A', 'Z', '0', '9', '_' > {}; + struct ident : seq< ident_first, star< ident_other > > {}; + struct full_ident : list_must< ident, dot > {}; - struct bool_lit : seq< sor< string< 't', 'r', 'u', 'e' >, string< 'f', 'a', 'l', 's', 'e' > >, not_at< ident_other > > {}; + struct oct_lit : seq< one< '0' >, star< odigit > > {}; + struct hex_lit : seq< one< '0' >, one< 'x', 'X' >, plus< xdigit > > {}; + struct dec_lit : seq< range< '1', '9' >, star< digit > > {}; + struct int_lit : sor< dec_lit, hex_lit, oct_lit > {}; - struct sign : one< '+', '-' > {}; - struct constant : sor< bool_lit, full_ident, seq< opt< sign >, int_lit >, str_lit > {}; // TODO: Needs sps after sign? + struct hex_escape : if_must< one< 'x', 'X' >, xdigit, xdigit > {}; + struct oct_escape : if_must< odigit, odigit, odigit > {}; + struct char_escape : one< 'a', 'b', 'f', 'n', 'r', 't', 'v', '\\', '\'', '"' > {}; + struct escape : if_must< one< '\\' >, hex_escape, oct_escape, char_escape > {}; + struct char_value : sor< escape, not_one< '\n', '\0' > > {}; // NOTE: No need to exclude '\' from not_one<>, see escape rule. + template< char Q > + struct str_impl : if_must< one< Q >, until< one< Q >, char_value > > {}; + struct str_lit : sor< str_impl< '\'' >, str_impl< '"' > > {}; - struct option_name : seq< sor< ident, if_must< one< '(' >, full_ident, one< ')' > > >, star_must< dot, ident > > {}; - struct option : if_must< string< 'o', 'p', 't', 'i', 'o', 'n' >, sps, option_name, sps, equ, sps, constant, sps, semi, sps > {}; + struct bool_lit : seq< sor< string< 't', 'r', 'u', 'e' >, string< 'f', 'a', 'l', 's', 'e' > >, not_at< ident_other > > {}; - struct bool_type : string< 'b', 'o', 'o', 'l' > {}; - struct bytes_type : string< 'b', 'y', 't', 'e', 's' > {}; - struct double_type : string< 'd', 'o', 'u', 'b', 'l', 'e' > {}; - struct float_type : string< 'f', 'l', 'o', 'a', 't' > {}; - struct string_type : string< 's', 't', 'r', 'i', 'n', 'g' > {}; + struct sign : one< '+', '-' > {}; + struct constant : sor< bool_lit, full_ident, seq< opt< sign >, int_lit >, str_lit > {}; // TODO: Needs sps after sign? - struct int32_type : string< 'i', 'n', 't', '3', '2' > {}; - struct int64_type : string< 'i', 'n', 't', '6', '4' > {}; - struct sint32_type : string< 's', 'i', 'n', 't', '3', '2' > {}; - struct sint64_type : string< 's', 'i', 'n', 't', '6', '4' > {}; - struct uint32_type : string< 'u', 'i', 'n', 't', '3', '2' > {}; - struct uint64_type : string< 'u', 'i', 'n', 't', '6', '4' > {}; - struct fixed32_type : string< 'f', 'i', 'x', 'e', 'd', '3', '2' > {}; - struct fixed64_type : string< 'f', 'i', 'x', 'e', 'd', '6', '4' > {}; - struct sfixed32_type : string< 's', 'f', 'i', 'x', 'e', 'd', '3', '2' > {}; - struct sfixed64_type : string< 's', 'f', 'i', 'x', 'e', 'd', '6', '4' > {}; + struct option_name : seq< sor< ident, if_must< one< '(' >, full_ident, one< ')' > > >, star_must< dot, ident > > {}; + struct option : if_must< string< 'o', 'p', 't', 'i', 'o', 'n' >, sps, option_name, sps, equ, sps, constant, sps, semi, sps > {}; - struct builtin_type : seq< sor< bool_type, bytes_type, double_type, float_type, string_type, int32_type, int64_type, sint32_type, sint64_type, uint32_type, uint64_type, fixed32_type, fixed64_type, sfixed32_type, sfixed64_type >, not_at< ident_other > > {}; + struct bool_type : string< 'b', 'o', 'o', 'l' > {}; + struct bytes_type : string< 'b', 'y', 't', 'e', 's' > {}; + struct double_type : string< 'd', 'o', 'u', 'b', 'l', 'e' > {}; + struct float_type : string< 'f', 'l', 'o', 'a', 't' > {}; + struct string_type : string< 's', 't', 'r', 'i', 'n', 'g' > {}; - struct defined_type : seq< opt< dot >, full_ident > {}; // NOTE: This replaces both message_type and enum_type -- they have the same syntax. + struct int32_type : string< 'i', 'n', 't', '3', '2' > {}; + struct int64_type : string< 'i', 'n', 't', '6', '4' > {}; + struct sint32_type : string< 's', 'i', 'n', 't', '3', '2' > {}; + struct sint64_type : string< 's', 'i', 'n', 't', '6', '4' > {}; + struct uint32_type : string< 'u', 'i', 'n', 't', '3', '2' > {}; + struct uint64_type : string< 'u', 'i', 'n', 't', '6', '4' > {}; + struct fixed32_type : string< 'f', 'i', 'x', 'e', 'd', '3', '2' > {}; + struct fixed64_type : string< 'f', 'i', 'x', 'e', 'd', '6', '4' > {}; + struct sfixed32_type : string< 's', 'f', 'i', 'x', 'e', 'd', '3', '2' > {}; + struct sfixed64_type : string< 's', 'f', 'i', 'x', 'e', 'd', '6', '4' > {}; - struct type : sor< builtin_type, defined_type > {}; + struct builtin_type : seq< sor< bool_type, bytes_type, double_type, float_type, string_type, int32_type, int64_type, sint32_type, sint64_type, uint32_type, uint64_type, fixed32_type, fixed64_type, sfixed32_type, sfixed64_type >, not_at< ident_other > > {}; - struct field_option : if_must< option_name, sps, equ, sps, constant > {}; - struct field_options : if_must< one< '[' >, sps, list< field_option, comma, sp >, sps, one< ']' > > {}; - struct field_name : ident {}; - struct field_number : int_lit {}; - struct field : seq< opt< string< 'r', 'e', 'p', 'e', 'a', 't', 'e', 'd' >, sps >, type, sps, field_name, sps, equ, sps, field_number, sps, opt< field_options, sps >, semi > {}; + struct defined_type : seq< opt< dot >, full_ident > {}; // NOTE: This replaces both message_type and enum_type -- they have the same syntax. - struct oneof_name : ident {}; - struct oneof_field : if_must< type, sps, field_name, sps, equ, sps, field_number, sps, opt< field_options, sps >, semi > {}; - struct oneof_body : sor< oneof_field, semi > {}; - struct oneof : if_must< string< 'o', 'n', 'e', 'o', 'f' >, sps, oneof_name, sps, one< '{' >, sps, until< one< '}' >, oneof_body, sps >, sps > {}; + struct type : sor< builtin_type, defined_type > {}; - struct key_type : seq< sor< bool_type, string_type, int32_type, int64_type, sint32_type, sint64_type, uint32_type, uint64_type, fixed32_type, fixed64_type, sfixed32_type, sfixed64_type >, not_at< ident_other > > {}; - struct map_name : ident {}; - struct map_field : if_must< string< 'm', 'a', 'p' >, sps, one< '<' >, sps, key_type, sps, comma, sps, type, sps, one< '>' >, sps, map_name, sps, equ, sps, field_number, sps, opt< field_options, sps >, semi > {}; + struct field_option : if_must< option_name, sps, equ, sps, constant > {}; + struct field_options : if_must< one< '[' >, sps, list< field_option, comma, sp >, sps, one< ']' > > {}; + struct field_name : ident {}; + struct field_number : int_lit {}; + struct field : seq< opt< string< 'r', 'e', 'p', 'e', 'a', 't', 'e', 'd' >, sps >, type, sps, field_name, sps, equ, sps, field_number, sps, opt< field_options, sps >, semi > {}; - struct range : if_must< int_lit, sps, string< 't', 'o' >, sps, sor< int_lit, string< 'm', 'a', 'x' > > > {}; - struct ranges : list_must< range, comma, sp > {}; - struct field_names : list_must< field_name, comma, sp > {}; - struct reserved : if_must< string< 'r', 'e', 's', 'e', 'r', 'v', 'e', 'd' >, sps, sor< ranges, field_names >, sps, semi > {}; + struct oneof_name : ident {}; + struct oneof_field : if_must< type, sps, field_name, sps, equ, sps, field_number, sps, opt< field_options, sps >, semi > {}; + struct oneof_body : sor< oneof_field, semi > {}; + struct oneof : if_must< string< 'o', 'n', 'e', 'o', 'f' >, sps, oneof_name, sps, one< '{' >, sps, until< one< '}' >, oneof_body, sps >, sps > {}; - struct enum_name : ident {}; - struct enum_value_option : seq< option_name, sps, equ, sps, constant > {}; - struct enum_field : seq< ident, sps, equ, sps, int_lit, sps, opt_must< one< '[' >, sps, list_must< enum_value_option, comma, sp >, sps, one< ']' >, sps >, semi > {}; - struct enum_body : if_must< one< '{' >, sps, star< sor< option, enum_field, semi >, sps >, one< '}' > > {}; - struct enum_ : if_must< string< 'e', 'n', 'u', 'm' >, sps, enum_name, sps, enum_body > {}; + struct key_type : seq< sor< bool_type, string_type, int32_type, int64_type, sint32_type, sint64_type, uint32_type, uint64_type, fixed32_type, fixed64_type, sfixed32_type, sfixed64_type >, not_at< ident_other > > {}; + struct map_name : ident {}; + struct map_field : if_must< string< 'm', 'a', 'p' >, sps, one< '<' >, sps, key_type, sps, comma, sps, type, sps, one< '>' >, sps, map_name, sps, equ, sps, field_number, sps, opt< field_options, sps >, semi > {}; - struct message_thing : sor< field, enum_, message, option, oneof, map_field, reserved, semi > {}; - struct message : if_must< string< 'm', 'e', 's', 's', 'a', 'g', 'e' >, sps, ident, sps, one< '{' >, sps, star< message_thing, sps >, one< '}' >, sps > {}; + struct range : if_must< int_lit, sps, string< 't', 'o' >, sps, sor< int_lit, string< 'm', 'a', 'x' > > > {}; + struct ranges : list_must< range, comma, sp > {}; + struct field_names : list_must< field_name, comma, sp > {}; + struct reserved : if_must< string< 'r', 'e', 's', 'e', 'r', 'v', 'e', 'd' >, sps, sor< ranges, field_names >, sps, semi > {}; - struct package : if_must< string< 'p', 'a', 'c', 'k', 'a', 'g', 'e' >, sps, full_ident, sps, semi, sps > {}; + struct enum_name : ident {}; + struct enum_value_option : seq< option_name, sps, equ, sps, constant > {}; + struct enum_field : seq< ident, sps, equ, sps, int_lit, sps, opt_must< one< '[' >, sps, list_must< enum_value_option, comma, sp >, sps, one< ']' >, sps >, semi > {}; + struct enum_body : if_must< one< '{' >, sps, star< sor< option, enum_field, semi >, sps >, one< '}' > > {}; + struct enum_ : if_must< string< 'e', 'n', 'u', 'm' >, sps, enum_name, sps, enum_body > {}; - struct import_option : opt< sor< string< 'w', 'e', 'a', 'k' >, string< 'p', 'u', 'b', 'l', 'i', 'c' > > > {}; - struct import : if_must< string< 'i', 'm', 'p', 'o', 'r', 't' >, sps, import_option, sps, str_lit, sps, semi, sps > {}; + struct message_thing : sor< field, enum_, message, option, oneof, map_field, reserved, semi > {}; + struct message : if_must< string< 'm', 'e', 's', 's', 'a', 'g', 'e' >, sps, ident, sps, one< '{' >, sps, star< message_thing, sps >, one< '}' >, sps > {}; - struct rpc_name : ident {}; - struct rpc_type : if_must< one< '(' >, sps, opt< string< 's', 't', 'r', 'e', 'a', 'm' >, sps >, defined_type, sps, one< ')' > > {}; - struct rpc_options : if_must< one< '{' >, sps, star< sor< option, semi >, sps >, one< '}' > > {}; - struct rpc : if_must< string< 'r', 'p', 'c' >, sps, rpc_name, sps, rpc_type, sps, string< 'r', 'e', 't', 'u', 'r', 'n', 's' >, sps, rpc_type, sor< semi, rpc_options > > {}; - struct service_name : ident {}; - struct service : if_must< string< 's', 'e', 'r', 'v', 'i', 'c', 'e' >, sps, service_name, sps, one< '{' >, sps, list_must< sor< option, rpc, semi >, comma, sp >, sps, one< '}' > > {}; + struct package : if_must< string< 'p', 'a', 'c', 'k', 'a', 'g', 'e' >, sps, full_ident, sps, semi, sps > {}; - struct body : sor< import, package, option, message, enum_, service, semi > {}; + struct import_option : opt< sor< string< 'w', 'e', 'a', 'k' >, string< 'p', 'u', 'b', 'l', 'i', 'c' > > > {}; + struct import : if_must< string< 'i', 'm', 'p', 'o', 'r', 't' >, sps, import_option, sps, str_lit, sps, semi, sps > {}; - struct head : if_must< string< 's', 'y', 'n', 't', 'a', 'x' >, sps, equ, sps, string< '"', 'p', 'r', 'o', 't', 'o', '3', '"' >, sps, semi > {}; - struct proto : must< sps, head, sps, star< body, sps >, eof > {}; + struct rpc_name : ident {}; + struct rpc_type : if_must< one< '(' >, sps, opt< string< 's', 't', 'r', 'e', 'a', 'm' >, sps >, defined_type, sps, one< ')' > > {}; + struct rpc_options : if_must< one< '{' >, sps, star< sor< option, semi >, sps >, one< '}' > > {}; + struct rpc : if_must< string< 'r', 'p', 'c' >, sps, rpc_name, sps, rpc_type, sps, string< 'r', 'e', 't', 'u', 'r', 'n', 's' >, sps, rpc_type, sor< semi, rpc_options > > {}; + struct service_name : ident {}; + struct service : if_must< string< 's', 'e', 'r', 'v', 'i', 'c', 'e' >, sps, service_name, sps, one< '{' >, sps, list_must< sor< option, rpc, semi >, comma, sp >, sps, one< '}' > > {}; - // clang-format on + struct body : sor< import, package, option, message, enum_, service, semi > {}; - } // namespace proto3 + struct head : if_must< string< 's', 'y', 'n', 't', 'a', 'x' >, sps, equ, sps, string< '"', 'p', 'r', 'o', 't', 'o', '3', '"' >, sps, semi > {}; + struct proto : must< sps, head, sps, star< body, sps >, eof > {}; - } // namespace TAO_PEGTL_NAMESPACE + // clang-format on -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE::proto3 int main( int argc, char** argv ) { - using namespace tao::TAO_PEGTL_NAMESPACE; // NOLINT + using namespace TAO_PEGTL_NAMESPACE; // NOLINT - analyze< proto3::proto >(); + if( analyze< proto3::proto >() != 0 ) { + return 1; + } for( int i = 1; i < argc; ++i ) { - file_input<> in( argv[ i ] ); + file_input in( argv[ i ] ); parse< proto3::proto >( in ); } return 0; diff --git a/packages/PEGTL/src/example/pegtl/recover.cpp b/packages/PEGTL/src/example/pegtl/recover.cpp index bb1a56cf5..c39dcc117 100644 --- a/packages/PEGTL/src/example/pegtl/recover.cpp +++ b/packages/PEGTL/src/example/pegtl/recover.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ // This is a small experiment with a grammar that can recover from errors. @@ -16,7 +16,7 @@ #include <tao/pegtl.hpp> -using namespace tao::TAO_PEGTL_NAMESPACE; // NOLINT +using namespace TAO_PEGTL_NAMESPACE; // NOLINT // clang-format off @@ -47,9 +47,7 @@ struct my_grammar : star< not_at< eof >, recoverable_expr > {}; template< typename Rule > struct my_action - : nothing< Rule > -{ -}; +{}; template< typename T > struct my_action< skipping< T > > @@ -113,7 +111,7 @@ struct my_control int main( int argc, char** argv ) { for( int i = 1; i < argc; ++i ) { - argv_input<> in( argv, i ); + argv_input in( argv, i ); bool error = false; parse< my_grammar, my_action, my_control >( in, error ); } diff --git a/packages/PEGTL/src/example/pegtl/s_expression.cpp b/packages/PEGTL/src/example/pegtl/s_expression.cpp index e47b76528..c99311f8d 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <iostream> @@ -6,79 +6,40 @@ #include <tao/pegtl.hpp> #include <tao/pegtl/analyze.hpp> -using namespace tao::TAO_PEGTL_NAMESPACE; // NOLINT +using namespace TAO_PEGTL_NAMESPACE; // NOLINT namespace sexpr { - struct hash_comment - : until< eolf > - { - }; + // clang-format off + struct hash_comment : until< eolf > {}; struct list; + struct list_comment : if_must< at< one< '(' > >, disable< list > > {}; - struct list_comment - : if_must< at< one< '(' > >, disable< list > > - { - }; - - struct read_include - : seq< one< ' ' >, one< '"' >, plus< not_one< '"' > >, one< '"' > > - { - }; + struct read_include : seq< one< ' ' >, one< '"' >, plus< not_one< '"' > >, one< '"' > > {}; + struct hash_include : if_must< string< 'i', 'n', 'c', 'l', 'u', 'd', 'e' >, read_include > {}; - struct hash_include - : if_must< string< 'i', 'n', 'c', 'l', 'u', 'd', 'e' >, read_include > - { - }; - - struct hashed - : if_must< one< '#' >, sor< hash_include, list_comment, hash_comment > > - { - }; - - struct number - : plus< digit > - { - }; + struct hashed : if_must< one< '#' >, sor< hash_include, list_comment, hash_comment > > {}; - struct symbol - : identifier - { - }; + struct number : plus< digit > {}; + struct symbol : identifier {}; - struct atom - : sor< number, symbol > - { - }; + struct atom : sor< number, symbol > {}; struct anything; - struct list - : if_must< one< '(' >, until< one< ')' >, anything > > - { - }; + struct list : if_must< one< '(' >, until< one< ')' >, anything > > {}; - struct normal - : sor< atom, list > - { - }; + struct normal : sor< atom, list > {}; - struct anything - : sor< space, hashed, normal > - { - }; + struct anything : sor< space, hashed, normal > {}; - struct main - : until< eof, must< anything > > - { - }; + struct main : until< eof, must< anything > > {}; + // clang-format on template< typename Rule > struct action - : nothing< Rule > - { - }; + {}; template<> struct action< plus< not_one< '"' > > > @@ -103,7 +64,7 @@ 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...) - file_input<> i2( fn ); + file_input i2( fn ); parse_nested< main, sexpr::action >( in, i2, f2 ); } }; @@ -112,11 +73,13 @@ namespace sexpr int main( int argc, char** argv ) { - analyze< sexpr::main >(); + if( analyze< sexpr::main >() != 0 ) { + return 1; + } for( int i = 1; i < argc; ++i ) { std::string fn; - argv_input<> in( argv, i ); + argv_input in( argv, i ); parse< sexpr::main, sexpr::action >( in, fn ); } return 0; diff --git a/packages/PEGTL/src/example/pegtl/sum.cpp b/packages/PEGTL/src/example/pegtl/sum.cpp index ef3440db4..25b2484f5 100644 --- a/packages/PEGTL/src/example/pegtl/sum.cpp +++ b/packages/PEGTL/src/example/pegtl/sum.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <cstdlib> @@ -8,7 +8,7 @@ #include <tao/pegtl.hpp> -using namespace tao::TAO_PEGTL_NAMESPACE; // NOLINT +using namespace TAO_PEGTL_NAMESPACE; // NOLINT #include "double.hpp" @@ -16,24 +16,19 @@ namespace sum { struct padded_double : pad< double_::grammar, space > - { - }; + {}; struct double_list : list< padded_double, one< ',' > > - { - }; + {}; struct grammar : seq< double_list, eof > - { - }; + {}; template< typename Rule > struct action - : nothing< Rule > - { - }; + {}; template<> struct action< double_::grammar > @@ -42,8 +37,7 @@ namespace sum static void apply( const Input& in, double& sum ) { // assume all values will fit into a C++ double - std::stringstream ss; - ss << in.string(); + std::stringstream ss( in.string() ); double v; ss >> v; sum += v; @@ -65,7 +59,7 @@ int main() break; } double d = 0.0; - memory_input<> in( str, "std::cin" ); + memory_input in( str, "std::cin" ); if( parse< sum::grammar, sum::action >( in, d ) ) { std::cout << "parsing OK; sum = " << d << std::endl; } diff --git a/packages/PEGTL/src/example/pegtl/symbol_table.cpp b/packages/PEGTL/src/example/pegtl/symbol_table.cpp index 4f51b1688..fce5d6e1a 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 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <cstring> @@ -10,7 +10,7 @@ #include <tao/pegtl/contrib/integer.hpp> -namespace pegtl = tao::TAO_PEGTL_NAMESPACE; +namespace pegtl = TAO_PEGTL_NAMESPACE; namespace example { @@ -43,9 +43,7 @@ namespace example template< typename Rule > struct action - : pegtl::nothing< Rule > - { - }; + {}; template<> struct action< value > @@ -70,7 +68,7 @@ namespace example template< typename Input > static void apply( const Input& in, state& st ) { - if( !st.symbol_table.insert( { st.temporary, 0 } ).second ) { + if( !st.symbol_table.emplace( st.temporary, 0 ).second ) { throw pegtl::parse_error( "duplicate symbol " + st.temporary, in ); // NOLINT } } @@ -95,7 +93,7 @@ namespace example int main( int argc, char** argv ) { for( int i = 1; i < argc; ++i ) { - pegtl::file_input<> in( argv[ i ] ); + pegtl::file_input in( argv[ i ] ); example::state st; pegtl::parse< example::grammar, example::action >( in, st ); for( const auto& j : st.symbol_table ) { diff --git a/packages/PEGTL/src/example/pegtl/unescape.cpp b/packages/PEGTL/src/example/pegtl/unescape.cpp index fca7a66c2..69705ca34 100644 --- a/packages/PEGTL/src/example/pegtl/unescape.cpp +++ b/packages/PEGTL/src/example/pegtl/unescape.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <iostream> @@ -7,14 +7,14 @@ #include <tao/pegtl/contrib/unescape.hpp> -using namespace tao::TAO_PEGTL_NAMESPACE; // NOLINT +using namespace TAO_PEGTL_NAMESPACE; // NOLINT namespace example { // Grammar for string literals with some escape sequences from the C language: // - \x followed by two hex-digits to insert any byte value. // - \u followed by four hex-digits to insert a Unicode code point. - // - \U followed by eight hex-digits to insert any Unicdoe code points. + // - \U followed by eight hex-digits to insert any Unicode code points. // - A backslash followed by one of the characters listed in the grammar below. // clang-format off @@ -37,7 +37,7 @@ namespace example // produce a UTF-8 encoded result string where all escape sequences are // replaced with their intended meaning. - template< typename Rule > struct action : nothing< Rule > {}; + template< typename Rule > struct action {}; template<> struct action< utf8::range< 0x20, 0x10FFFF > > : unescape::append_all {}; template<> struct action< escaped_x > : unescape::unescape_x {}; @@ -51,10 +51,10 @@ namespace example int main( int argc, char** argv ) { for( int i = 1; i < argc; ++i ) { - unescape::state s; - argv_input<> in( argv, i ); + std::string s; + argv_input in( argv, i ); parse< example::padded, example::action >( in, s ); - std::cout << "argv[ " << i << " ] = " << s.unescaped << std::endl; + std::cout << "argv[ " << i << " ] = " << s << std::endl; } return 0; } diff --git a/packages/PEGTL/src/example/pegtl/uri.cpp b/packages/PEGTL/src/example/pegtl/uri.cpp index 21f51b78b..f504b68cf 100644 --- a/packages/PEGTL/src/example/pegtl/uri.cpp +++ b/packages/PEGTL/src/example/pegtl/uri.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <tao/pegtl.hpp> @@ -6,7 +6,7 @@ #include <iostream> -namespace pegtl = tao::TAO_PEGTL_NAMESPACE; +namespace pegtl = TAO_PEGTL_NAMESPACE; struct URI { @@ -35,7 +35,7 @@ namespace uri }; // clang-format off - template< typename Rule > struct action : tao::pegtl::nothing< Rule > {}; + template< typename Rule > struct action {}; template<> struct action< pegtl::uri::scheme > : bind< &URI::scheme > {}; template<> struct action< pegtl::uri::authority > : bind< &URI::authority > {}; @@ -67,7 +67,7 @@ namespace uri URI::URI( const std::string& uri ) { using grammar = pegtl::must< pegtl::uri::URI >; - pegtl::memory_input<> input( uri, "uri" ); + pegtl::memory_input input( uri, "uri" ); pegtl::parse< grammar, uri::action >( input, *this ); } diff --git a/packages/PEGTL/src/example/pegtl/uri_trace.cpp b/packages/PEGTL/src/example/pegtl/uri_trace.cpp index b1c43e3d9..1d09e9fa5 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <iostream> @@ -7,7 +7,7 @@ #include <tao/pegtl/contrib/tracer.hpp> #include <tao/pegtl/contrib/uri.hpp> -namespace pegtl = tao::TAO_PEGTL_NAMESPACE; +namespace pegtl = TAO_PEGTL_NAMESPACE; using grammar = pegtl::must< pegtl::uri::URI >; @@ -15,7 +15,7 @@ int main( int argc, char** argv ) { for( int i = 1; i < argc; ++i ) { std::cout << "Parsing " << argv[ i ] << std::endl; - pegtl::argv_input<> in( argv, i ); + pegtl::argv_input in( argv, i ); pegtl::parse< grammar, pegtl::nothing, pegtl::tracer >( in ); } return 0; diff --git a/packages/PEGTL/src/test/pegtl/CMakeLists.txt b/packages/PEGTL/src/test/pegtl/CMakeLists.txt index f2c45acd0..fda805afb 100644 --- a/packages/PEGTL/src/test/pegtl/CMakeLists.txt +++ b/packages/PEGTL/src/test/pegtl/CMakeLists.txt @@ -1,6 +1,8 @@ -cmake_minimum_required (VERSION 3.3.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.8.0 FATAL_ERROR) -set (test_sources +set(test_sources + action_enable.cpp + action_match.cpp actions_one.cpp actions_three.cpp actions_two.cpp @@ -17,11 +19,17 @@ set (test_sources ascii_string.cpp ascii_three.cpp ascii_two.cpp + buffer_input.cpp + change_action_and_state.cpp + change_action_and_states.cpp + change_state.cpp + change_states.cpp contrib_alphabet.cpp contrib_integer.cpp contrib_if_then.cpp contrib_json.cpp contrib_parse_tree.cpp + contrib_partial_trace.cpp contrib_raw_string.cpp contrib_rep_one_min_max.cpp contrib_to_string.cpp @@ -30,6 +38,7 @@ set (test_sources contrib_uri.cpp data_cstring.cpp demangle.cpp + discard_input.cpp file_cstream.cpp file_file.cpp file_istream.cpp @@ -67,6 +76,7 @@ set (test_sources rule_pad.cpp rule_pad_opt.cpp rule_plus.cpp + rule_rematch.cpp rule_rep.cpp rule_rep_max.cpp rule_rep_min.cpp @@ -91,39 +101,38 @@ set (test_sources utf8_general.cpp ) -# file (GLOB ...) is used to validate the above list of test_sources -file (GLOB glob_test_sources RELATIVE ${CMAKE_CURRENT_LIST_DIR} *.cpp) +# file(GLOB ...) is used to validate the above list of test_sources +file(GLOB glob_test_sources RELATIVE ${CMAKE_CURRENT_LIST_DIR} *.cpp) -foreach (testsourcefile ${test_sources}) - if (${testsourcefile} IN_LIST glob_test_sources) - list (REMOVE_ITEM glob_test_sources ${testsourcefile}) - else () - message (SEND_ERROR "File ${testsourcefile} is missing from src/test/pegtl") - endif () +foreach(testsourcefile ${test_sources}) + if(${testsourcefile} IN_LIST glob_test_sources) + list(REMOVE_ITEM glob_test_sources ${testsourcefile}) + else() + message(SEND_ERROR "File ${testsourcefile} is missing from src/test/pegtl") + endif() - get_filename_component (exename ${testsourcefile} NAME_WE) - set (exename "pegtl-test-${exename}") - add_executable (${exename} ${testsourcefile}) - target_link_libraries (${exename} PRIVATE taocpp::pegtl) - set_target_properties (${exename} PROPERTIES - CXX_STANDARD 11 + get_filename_component(exename pegtl-test-${testsourcefile} NAME_WE) + add_executable(${exename} ${testsourcefile}) + target_link_libraries(${exename} PRIVATE taocpp::pegtl) + set_target_properties(${exename} PROPERTIES + CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF ) - if (MSVC) - target_compile_options (${exename} PRIVATE /W4 /WX /utf-8) - else () - target_compile_options (${exename} PRIVATE -pedantic -Wall -Wextra -Wshadow -Werror) - endif () - if (ANDROID) - add_test (NAME ${exename} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../.. COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} "-DTEST_RESOURCES=src/test/pegtl/data;src/test/pegtl/file_data.txt;Makefile" -DTEST_RESOURCES_DIR=${CMAKE_CURRENT_SOURCE_DIR}/../../.. -DUNITTEST=${CMAKE_CURRENT_BINARY_DIR}/${exename} -DTEST_PARAMETER=-all -P ${CMAKE_CURRENT_SOURCE_DIR}/ExecuteOnAndroid.cmake) - else () - add_test (NAME ${exename} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../.. COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${exename}) - endif () -endforeach (testsourcefile) + if(MSVC) + target_compile_options(${exename} PRIVATE /W4 /WX /utf-8) + else() + target_compile_options(${exename} PRIVATE -pedantic -Wall -Wextra -Wshadow -Werror) + endif() + if(ANDROID) + add_test(NAME ${exename} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../.. COMMAND ${CMAKE_COMMAND} -DANDROID_NDK=${ANDROID_NDK} "-DTEST_RESOURCES=src/test/pegtl/data;src/test/pegtl/file_data.txt;Makefile" -DTEST_RESOURCES_DIR=${CMAKE_CURRENT_SOURCE_DIR}/../../.. -DUNITTEST=${CMAKE_CURRENT_BINARY_DIR}/${exename} -DTEST_PARAMETER=-all -P ${CMAKE_CURRENT_SOURCE_DIR}/ExecuteOnAndroid.cmake) + else() + add_test(NAME ${exename} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../.. COMMAND ${exename}) + endif() +endforeach(testsourcefile) -if (glob_test_sources) - foreach (ignored_source_file ${glob_test_sources}) - message (SEND_ERROR "File ${ignored_source_file} in src/test/pegtl is ignored") - endforeach (ignored_source_file) -endif () +if(glob_test_sources) + foreach(ignored_source_file ${glob_test_sources}) + message(SEND_ERROR "File ${ignored_source_file} in src/test/pegtl is ignored") + endforeach(ignored_source_file) +endif() diff --git a/packages/PEGTL/src/test/pegtl/action_enable.cpp b/packages/PEGTL/src/test/pegtl/action_enable.cpp new file mode 100644 index 000000000..89890bac3 --- /dev/null +++ b/packages/PEGTL/src/test/pegtl/action_enable.cpp @@ -0,0 +1,64 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#include "test.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + // clang-format off + struct A : one< 'a' > {}; + struct B : one< 'b' > {}; + struct C : one< 'c' > {}; + struct BCB : seq< B, C, B > {}; + struct ABCBA : seq< A, BCB, A > {}; + // clang-format on + + template< typename > + struct my_action + {}; + + template<> + struct my_action< A > + { + static void apply0( int& a, int& /*b*/, int& /*c*/ ) + { + ++a; + } + }; + + template<> + struct my_action< B > + : disable_action + { + static void apply0( int& /*a*/, int& b, int& /*c*/ ) + { + ++b; + } + }; + + template<> + struct my_action< C > + : enable_action + { + static void apply0( int& /*a*/, int& /*b*/, int& c ) + { + ++c; + } + }; + + void unit_test() + { + memory_input<> in( "abcba", "" ); + int a = 0; + int b = 0; + int c = 0; + const auto result = parse< ABCBA, my_action >( in, a, b, c ); + TAO_PEGTL_TEST_ASSERT( result ); + TAO_PEGTL_TEST_ASSERT( a == 2 ); + TAO_PEGTL_TEST_ASSERT( b == 0 ); + TAO_PEGTL_TEST_ASSERT( c == 1 ); + } + +} // namespace TAO_PEGTL_NAMESPACE + +#include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/action_match.cpp b/packages/PEGTL/src/test/pegtl/action_match.cpp new file mode 100644 index 000000000..dfb60c6f4 --- /dev/null +++ b/packages/PEGTL/src/test/pegtl/action_match.cpp @@ -0,0 +1,116 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#include "test.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + struct remove_state + { + template< typename Rule, + apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + [[nodiscard]] static bool match( Input& in, States&&... /*unused*/ ) + { + return TAO_PEGTL_NAMESPACE::match< Rule, A, M, Action, Control >( in ); + } + }; + + // further generic helpers could be build, e.g. + // + // - change_control + // - remove prefix/suffix from input (e.g. remove surrounding quotes) + // - replace the input completely? + // - append states + // - prepend states + // - ... + + std::size_t global_state = 0; + + struct state_one + { + std::size_t byte_in_line_a; + std::size_t byte_in_line_b; + }; + + // clang-format off + struct grammar_inner : one< 'a' > {}; + struct grammar_one_c : seq< grammar_inner > {}; + struct grammar_one_b : seq< grammar_inner, grammar_one_c > {}; + struct grammar_one_a : seq< grammar_inner, grammar_one_b, eof > {}; + // clang-format on + + template< typename Rule > + struct action_one_b + {}; + + template< typename Rule > + struct action_one_t + {}; + + template< typename Rule > + struct action_one_a + {}; + + template<> + struct action_one_b< grammar_one_c > + : remove_state + {}; + + template<> + struct action_one_b< grammar_inner > + { + // used inside of remove_state + template< typename Input > + static void apply( const Input& /*unused*/ ) + { + ++global_state; + } + + // used outside of remove_state + template< typename Input > + static void apply( const Input& in, state_one& state ) + { + state.byte_in_line_b += in.input().byte(); + } + }; + + template<> + struct action_one_t< grammar_one_b > + : change_action< action_one_b > + {}; + + template<> + struct action_one_a< grammar_one_b > + : change_action< action_one_t > + {}; + + template<> + struct action_one_a< grammar_inner > + { + template< typename Input > + static void apply( const Input& in, state_one& state ) + { + state.byte_in_line_a += in.input().byte(); + } + }; + + void unit_test() + { + state_one state{ 0, 0 }; + bool parse_result = parse< grammar_one_a, action_one_a >( memory_input( "aaa", __FUNCTION__ ), state ); + TAO_PEGTL_TEST_ASSERT( parse_result ); + TAO_PEGTL_TEST_ASSERT( state.byte_in_line_a == 1 ); + TAO_PEGTL_TEST_ASSERT( state.byte_in_line_b == 2 ); + TAO_PEGTL_TEST_ASSERT( global_state == 1 ); + } + +} // namespace TAO_PEGTL_NAMESPACE + +#include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/actions_one.cpp b/packages/PEGTL/src/test/pegtl/actions_one.cpp index eb964a008..9577fae8a 100644 --- a/packages/PEGTL/src/test/pegtl/actions_one.cpp +++ b/packages/PEGTL/src/test/pegtl/actions_one.cpp @@ -1,90 +1,102 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" -namespace tao +#include <string> +#include <utility> +#include <vector> + +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + std::vector< std::pair< std::string, std::string > > applied; // NOLINT + + namespace test1 { - namespace test1 + struct fiz : if_must< at< one< 'a' > >, two< 'a' > > { - struct fiz : if_must< at< one< 'a' > >, two< 'a' > > - { - }; - - struct foo : sor< fiz, one< 'b' > > - { - }; - - struct bar : until< eof, foo > - { - }; - - void test_result() - { - TAO_PEGTL_TEST_ASSERT( applied.size() == 10 ); - - TAO_PEGTL_TEST_ASSERT( applied[ 0 ].first == internal::demangle< one< 'b' > >() ); - TAO_PEGTL_TEST_ASSERT( applied[ 1 ].first == internal::demangle< foo >() ); - TAO_PEGTL_TEST_ASSERT( applied[ 2 ].first == internal::demangle< at< one< 'a' > > >() ); - TAO_PEGTL_TEST_ASSERT( applied[ 3 ].first == internal::demangle< two< 'a' > >() ); - TAO_PEGTL_TEST_ASSERT( applied[ 4 ].first == internal::demangle< fiz >() ); - TAO_PEGTL_TEST_ASSERT( applied[ 5 ].first == internal::demangle< foo >() ); - TAO_PEGTL_TEST_ASSERT( applied[ 6 ].first == internal::demangle< one< 'b' > >() ); - TAO_PEGTL_TEST_ASSERT( applied[ 7 ].first == internal::demangle< foo >() ); - TAO_PEGTL_TEST_ASSERT( applied[ 8 ].first == internal::demangle< eof >() ); - TAO_PEGTL_TEST_ASSERT( applied[ 9 ].first == internal::demangle< bar >() ); - - TAO_PEGTL_TEST_ASSERT( applied[ 0 ].second == "b" ); - TAO_PEGTL_TEST_ASSERT( applied[ 1 ].second == "b" ); - TAO_PEGTL_TEST_ASSERT( applied[ 2 ].second.empty() ); - TAO_PEGTL_TEST_ASSERT( applied[ 3 ].second == "aa" ); - TAO_PEGTL_TEST_ASSERT( applied[ 4 ].second == "aa" ); - TAO_PEGTL_TEST_ASSERT( applied[ 5 ].second == "aa" ); - TAO_PEGTL_TEST_ASSERT( applied[ 6 ].second == "b" ); - TAO_PEGTL_TEST_ASSERT( applied[ 7 ].second == "b" ); - TAO_PEGTL_TEST_ASSERT( applied[ 8 ].second.empty() ); - TAO_PEGTL_TEST_ASSERT( applied[ 9 ].second == "baab" ); - } - - } // namespace test1 - - void unit_test() + }; + + struct foo : sor< fiz, one< 'b' > > { - parse< disable< test1::bar >, test_action >( memory_input<>( "baab", __FUNCTION__ ) ); - TAO_PEGTL_TEST_ASSERT( applied.size() == 1 ); + }; - TAO_PEGTL_TEST_ASSERT( applied[ 0 ].first == internal::demangle< disable< test1::bar > >() ); - TAO_PEGTL_TEST_ASSERT( applied[ 0 ].second == "baab" ); + struct bar : until< eof, foo > + { + }; - applied.clear(); + void test_result() + { + TAO_PEGTL_TEST_ASSERT( applied.size() == 10 ); + + TAO_PEGTL_TEST_ASSERT( applied[ 0 ].first == internal::demangle< one< 'b' > >() ); + TAO_PEGTL_TEST_ASSERT( applied[ 1 ].first == internal::demangle< foo >() ); + TAO_PEGTL_TEST_ASSERT( applied[ 2 ].first == internal::demangle< at< one< 'a' > > >() ); + TAO_PEGTL_TEST_ASSERT( applied[ 3 ].first == internal::demangle< two< 'a' > >() ); + TAO_PEGTL_TEST_ASSERT( applied[ 4 ].first == internal::demangle< fiz >() ); + TAO_PEGTL_TEST_ASSERT( applied[ 5 ].first == internal::demangle< foo >() ); + TAO_PEGTL_TEST_ASSERT( applied[ 6 ].first == internal::demangle< one< 'b' > >() ); + TAO_PEGTL_TEST_ASSERT( applied[ 7 ].first == internal::demangle< foo >() ); + TAO_PEGTL_TEST_ASSERT( applied[ 8 ].first == internal::demangle< eof >() ); + TAO_PEGTL_TEST_ASSERT( applied[ 9 ].first == internal::demangle< bar >() ); + + TAO_PEGTL_TEST_ASSERT( applied[ 0 ].second == "b" ); + TAO_PEGTL_TEST_ASSERT( applied[ 1 ].second == "b" ); + TAO_PEGTL_TEST_ASSERT( applied[ 2 ].second.empty() ); + TAO_PEGTL_TEST_ASSERT( applied[ 3 ].second == "aa" ); + TAO_PEGTL_TEST_ASSERT( applied[ 4 ].second == "aa" ); + TAO_PEGTL_TEST_ASSERT( applied[ 5 ].second == "aa" ); + TAO_PEGTL_TEST_ASSERT( applied[ 6 ].second == "b" ); + TAO_PEGTL_TEST_ASSERT( applied[ 7 ].second == "b" ); + TAO_PEGTL_TEST_ASSERT( applied[ 8 ].second.empty() ); + TAO_PEGTL_TEST_ASSERT( applied[ 9 ].second == "baab" ); + } - parse< at< action< test_action, test1::bar > > >( memory_input<>( "baab", __FUNCTION__ ) ); + } // namespace test1 - TAO_PEGTL_TEST_ASSERT( applied.empty() ); + template< typename Rule > + struct test_action + { + template< typename Input > + static void apply( const Input& in ) + { + applied.emplace_back( internal::demangle< Rule >(), in.string() ); + } + }; + + void unit_test() + { + parse< disable< test1::bar >, test_action >( memory_input( "baab", __FUNCTION__ ) ); + TAO_PEGTL_TEST_ASSERT( applied.size() == 1 ); - applied.clear(); + TAO_PEGTL_TEST_ASSERT( applied[ 0 ].first == internal::demangle< disable< test1::bar > >() ); + TAO_PEGTL_TEST_ASSERT( applied[ 0 ].second == "baab" ); - parse< test1::bar, test_action >( memory_input<>( "baab", __FUNCTION__ ) ); + applied.clear(); - test1::test_result(); + parse< at< action< test_action, test1::bar > > >( memory_input( "baab", __FUNCTION__ ) ); - applied.clear(); + TAO_PEGTL_TEST_ASSERT( applied.empty() ); - parse< action< test_action, test1::bar > >( memory_input<>( "baab", __FUNCTION__ ) ); + applied.clear(); - test1::test_result(); + parse< test1::bar, test_action >( memory_input( "baab", __FUNCTION__ ) ); - applied.clear(); + test1::test_result(); - parse< disable< enable< action< test_action, test1::bar > > > >( memory_input<>( "baab", __FUNCTION__ ) ); + applied.clear(); - test1::test_result(); - } + parse< action< test_action, test1::bar > >( memory_input( "baab", __FUNCTION__ ) ); + + test1::test_result(); + + applied.clear(); + + parse< disable< enable< action< test_action, test1::bar > > > >( memory_input( "baab", __FUNCTION__ ) ); - } // namespace TAO_PEGTL_NAMESPACE + test1::test_result(); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/actions_three.cpp b/packages/PEGTL/src/test/pegtl/actions_three.cpp index 378025cc7..be49391fe 100644 --- a/packages/PEGTL/src/test/pegtl/actions_three.cpp +++ b/packages/PEGTL/src/test/pegtl/actions_three.cpp @@ -1,102 +1,95 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace test1 { - namespace test1 - { - bool apply_result; - - struct grammar - : test_rule< 2, apply_mode::ACTION, rewind_mode::ACTIVE, any > - { - }; + bool apply_result; - template< typename Rule > - struct apply_bool_action : nothing< Rule > - { - }; + struct grammar + : test_rule< 2, apply_mode::action, rewind_mode::active, any > + {}; - template<> - struct apply_bool_action< grammar > - { - template< typename Input > - static bool apply( const Input& /*unused*/ ) - { - return apply_result; - } - }; + template< typename Rule > + struct apply_bool_action + {}; - void apply_bool_true() - { - apply_result = true; - memory_input<> in( "ab", __FUNCTION__ ); - const auto result = parse< grammar, apply_bool_action >( in ); - TAO_PEGTL_TEST_ASSERT( result ); - TAO_PEGTL_TEST_ASSERT( in.size() == 1 ); - TAO_PEGTL_TEST_ASSERT( in.peek_char() == 'b' ); - } - - void apply_bool_false() + template<> + struct apply_bool_action< grammar > + { + template< typename Input > + static bool apply( const Input& /*unused*/ ) { - apply_result = false; - memory_input<> in( "ab", __FUNCTION__ ); - const auto result = parse< grammar, apply_bool_action >( in ); - TAO_PEGTL_TEST_ASSERT( !result ); - TAO_PEGTL_TEST_ASSERT( in.size() == 2 ); - TAO_PEGTL_TEST_ASSERT( in.peek_char() == 'a' ); + return apply_result; } + }; - template< typename Rule > - struct apply0_bool_action : nothing< Rule > - { - }; + void apply_bool_true() + { + apply_result = true; + memory_input in( "ab", __FUNCTION__ ); + const auto result = parse< grammar, apply_bool_action >( in ); + TAO_PEGTL_TEST_ASSERT( result ); + TAO_PEGTL_TEST_ASSERT( in.size() == 1 ); + TAO_PEGTL_TEST_ASSERT( in.peek_char() == 'b' ); + } - template<> - struct apply0_bool_action< grammar > - { - static bool apply0() - { - return apply_result; - } - }; + void apply_bool_false() + { + apply_result = false; + memory_input in( "ab", __FUNCTION__ ); + const auto result = parse< grammar, apply_bool_action >( in ); + TAO_PEGTL_TEST_ASSERT( !result ); + TAO_PEGTL_TEST_ASSERT( in.size() == 2 ); + TAO_PEGTL_TEST_ASSERT( in.peek_char() == 'a' ); + } - void apply0_bool_true() - { - apply_result = true; - memory_input<> in( "ab", __FUNCTION__ ); - const auto result = parse< grammar, apply0_bool_action >( in ); - TAO_PEGTL_TEST_ASSERT( result ); - TAO_PEGTL_TEST_ASSERT( in.size() == 1 ); - TAO_PEGTL_TEST_ASSERT( in.peek_char() == 'b' ); - } + template< typename Rule > + struct apply0_bool_action + {}; - void apply0_bool_false() + template<> + struct apply0_bool_action< grammar > + { + static bool apply0() { - apply_result = false; - memory_input<> in( "ab", __FUNCTION__ ); - const auto result = parse< grammar, apply0_bool_action >( in ); - TAO_PEGTL_TEST_ASSERT( !result ); - TAO_PEGTL_TEST_ASSERT( in.size() == 2 ); - TAO_PEGTL_TEST_ASSERT( in.peek_char() == 'a' ); + return apply_result; } + }; - } // namespace test1 + void apply0_bool_true() + { + apply_result = true; + memory_input in( "ab", __FUNCTION__ ); + const auto result = parse< grammar, apply0_bool_action >( in ); + TAO_PEGTL_TEST_ASSERT( result ); + TAO_PEGTL_TEST_ASSERT( in.size() == 1 ); + TAO_PEGTL_TEST_ASSERT( in.peek_char() == 'b' ); + } - void unit_test() + void apply0_bool_false() { - test1::apply_bool_true(); - test1::apply_bool_false(); - test1::apply0_bool_true(); - test1::apply0_bool_false(); + apply_result = false; + memory_input in( "ab", __FUNCTION__ ); + const auto result = parse< grammar, apply0_bool_action >( in ); + TAO_PEGTL_TEST_ASSERT( !result ); + TAO_PEGTL_TEST_ASSERT( in.size() == 2 ); + TAO_PEGTL_TEST_ASSERT( in.peek_char() == 'a' ); } - } // namespace TAO_PEGTL_NAMESPACE + } // namespace test1 + + void unit_test() + { + test1::apply_bool_true(); + test1::apply_bool_false(); + test1::apply0_bool_true(); + test1::apply0_bool_false(); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/actions_two.cpp b/packages/PEGTL/src/test/pegtl/actions_two.cpp index d5d5b6be2..0d4475a41 100644 --- a/packages/PEGTL/src/test/pegtl/actions_two.cpp +++ b/packages/PEGTL/src/test/pegtl/actions_two.cpp @@ -1,141 +1,133 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace test1 { - namespace test1 + struct state1 { - struct state1 - { - char c; - - template< typename Input > - state1( const Input& /*unused*/, std::string& /*unused*/ ) - : c() - { - } - - template< typename Input > - void success( const Input& /*unused*/, std::string& s ) const - { - s += c; - } - }; - - struct fobble : sor< state< state1, alpha >, digit > - { - }; + char c; - struct fibble : until< eof, fobble > + template< typename Input > + state1( const Input& /*unused*/, std::string& /*unused*/ ) + : c() { - }; + } - template< typename Rule > - struct action1 : nothing< Rule > + template< typename Input > + void success( const Input& /*unused*/, std::string& s ) const { - }; + s += c; + } + }; - template<> - struct action1< alpha > - { - template< typename Input > - static void apply( const Input& in, state1& s ) - { - assert( in.size() == 1 ); - s.c = in.begin()[ 0 ]; - } - }; - - void state_test() + struct fobble : sor< state< state1, alpha >, digit > + {}; + + struct fibble : until< eof, fobble > + {}; + + template< typename Rule > + struct action1 + {}; + + template<> + struct action1< alpha > + { + template< typename Input > + static void apply( const Input& in, state1& s ) { - std::string result; - memory_input<> in( "dk41sk41xk3", __FUNCTION__ ); - parse< fibble, action1 >( in, result ); - TAO_PEGTL_TEST_ASSERT( result == "dkskxk" ); + assert( in.size() == 1 ); + s.c = in.begin()[ 0 ]; } + }; - template< typename Rule > - struct action0 : nothing< Rule > - { - }; + void state_test() + { + std::string result; + memory_input in( "dk41sk41xk3", __FUNCTION__ ); + parse< fibble, action1 >( in, result ); + TAO_PEGTL_TEST_ASSERT( result == "dkskxk" ); + } - static int i0 = 0; + template< typename Rule > + struct action0 + {}; - template<> - struct action0< alpha > - { - static void apply0() - { - ++i0; - } - }; - - template<> - struct action0< digit > + static int i0 = 0; + + template<> + struct action0< alpha > + { + static void apply0() { - static void apply0( std::string& s ) - { - s += '0'; - } - }; + ++i0; + } + }; - void apply0_test() + template<> + struct action0< digit > + { + static void apply0( std::string& s ) { - memory_input<> ina( "abcdefgh", __FUNCTION__ ); - parse< star< alpha >, action0 >( ina ); - TAO_PEGTL_TEST_ASSERT( i0 == 8 ); - std::string s0; - memory_input<> ind( "12345678", __FUNCTION__ ); - parse< star< digit >, action0 >( ind, s0 ); - TAO_PEGTL_TEST_ASSERT( s0 == "00000000" ); + s += '0'; } + }; + + void apply0_test() + { + memory_input ina( "abcdefgh", __FUNCTION__ ); + parse< star< alpha >, action0 >( ina ); + TAO_PEGTL_TEST_ASSERT( i0 == 8 ); + std::string s0; + memory_input ind( "12345678", __FUNCTION__ ); + parse< star< digit >, action0 >( ind, s0 ); + TAO_PEGTL_TEST_ASSERT( s0 == "00000000" ); + } - const std::size_t count_byte = 12345; - const std::size_t count_line = 42; - const std::size_t count_byte_in_line = 12; + const std::size_t count_byte = 12345; + const std::size_t count_line = 42; + const std::size_t count_byte_in_line = 12; - const char* count_source = "count_source"; + const char* count_source = "count_source"; - template< typename Rule > - struct count_action - { - template< typename Input > - static void apply( const Input& 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().byte_in_line == count_byte_in_line ); - 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() ); - TAO_PEGTL_TEST_ASSERT( in.peek_char() == 'f' ); - TAO_PEGTL_TEST_ASSERT( in.peek_byte() == static_cast< unsigned char >( 'f' ) ); - } - }; - - void count_test() + template< typename Rule > + struct count_action + { + template< typename Input > + static void apply( const Input& in ) { - const char* foo = "f"; - memory_input<> in( foo, foo + 1, count_source, count_byte, count_line, count_byte_in_line ); - const auto result = parse< must< alpha >, count_action >( in ); - TAO_PEGTL_TEST_ASSERT( result ); + TAO_PEGTL_TEST_ASSERT( in.iterator().byte == count_byte ); + TAO_PEGTL_TEST_ASSERT( in.iterator().line == count_line ); + TAO_PEGTL_TEST_ASSERT( in.iterator().byte_in_line == count_byte_in_line ); + 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() ); + TAO_PEGTL_TEST_ASSERT( in.peek_char() == 'f' ); + TAO_PEGTL_TEST_ASSERT( in.peek_uint8() == static_cast< unsigned char >( 'f' ) ); } + }; - } // namespace test1 - - void unit_test() + void count_test() { - test1::state_test(); - test1::apply0_test(); - test1::count_test(); + const char* foo = "f"; + memory_input in( foo, foo + 1, count_source, count_byte, count_line, count_byte_in_line ); + const auto result = parse< must< alpha >, count_action >( in ); + TAO_PEGTL_TEST_ASSERT( result ); } - } // namespace TAO_PEGTL_NAMESPACE + } // namespace test1 + + void unit_test() + { + test1::state_test(); + test1::apply0_test(); + test1::count_test(); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/analyze_cycles.cpp b/packages/PEGTL/src/test/pegtl/analyze_cycles.cpp index 1625b3e82..099fcc4c6 100644 --- a/packages/PEGTL/src/test/pegtl/analyze_cycles.cpp +++ b/packages/PEGTL/src/test/pegtl/analyze_cycles.cpp @@ -1,311 +1,307 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + template< typename... Rules > + struct any_seq + : public seq< Rules... > { - template< typename... Rules > - struct any_seq - : public seq< Rules... > - { - using analyze_t = analysis::generic< analysis::rule_type::ANY, Rules... >; - }; + using analyze_t = analysis::generic< analysis::rule_type::any, Rules... >; + }; - void unit_test() - { - verify_analyze< eof >( __LINE__, __FILE__, false, false ); - verify_analyze< eolf >( __LINE__, __FILE__, false, false ); - verify_analyze< success >( __LINE__, __FILE__, false, false ); - verify_analyze< failure >( __LINE__, __FILE__, true, false ); - { - struct tst : star< tst > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, true ); - } - { - struct tst : plus< tst > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, true ); - } - { - struct tst : seq< eof, at< digit >, tst > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, true ); // This is a false positive. - } - { - struct tst : sor< digit, seq< at< digit >, tst > > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, true ); // This is a false positive. - } - { - struct tst : sor< digit, seq< opt< digit >, tst > > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, true ); - } - { - struct tst : sor< digit, tst > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, true ); - } - { - struct tst : at< any > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, false ); - } - { - struct tst : at< tst > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, true ); - } - { - struct tst : at< any, tst > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, false ); - } - { - struct tst : not_at< any > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, false ); - } - { - struct tst : opt< tst > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, true ); - } - { - struct tst : opt< any, tst > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, false ); - } - { - struct rec : sor< seq< rec, alpha >, alpha > - { - }; - verify_analyze< rec >( __LINE__, __FILE__, true, true ); - } - { - struct bar; - struct foo : seq< digit, bar > - { - }; - struct bar : plus< foo > - { - }; - verify_analyze< seq< any, bar > >( __LINE__, __FILE__, true, false ); - } - { - struct bar; - struct foo : seq< bar, digit > - { - }; - struct bar : plus< foo > - { - }; - verify_analyze< seq< bar, any > >( __LINE__, __FILE__, true, true ); - } - { - struct bar; - struct foo : sor< digit, bar > - { - }; - struct bar : plus< foo > - { - }; - verify_analyze< bar >( __LINE__, __FILE__, false, true ); - verify_analyze< foo >( __LINE__, __FILE__, false, true ); - verify_analyze< sor< any, bar > >( __LINE__, __FILE__, false, true ); - } - { - // Excerpt from the Lua 5.3 grammar: - // prefixexp ::= var | functioncall | ‘(’ exp ‘)’ - // functioncall ::= prefixexp args | prefixexp ‘:’ Name args - // var ::= Name | prefixexp ‘[’ exp ‘]’ | prefixexp ‘.’ Name - // Simplified version, equivalent regarding consumption of input: - struct var; - struct fun; - struct exp : sor< var, fun, seq< any, exp, any > > - { - }; - struct fun : seq< exp, any > - { - }; - struct var : sor< any, seq< exp, any, exp >, seq< exp, any > > - { - }; - verify_analyze< exp >( __LINE__, __FILE__, true, true ); - verify_analyze< fun >( __LINE__, __FILE__, true, true ); - verify_analyze< var >( __LINE__, __FILE__, true, true ); - } - { - struct exp : sor< exp, seq< any, exp > > - { - }; - verify_analyze< exp >( __LINE__, __FILE__, false, true ); - } - { - struct tst : until< any > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, true, false ); - } - { - struct tst : until< star< any > > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, false ); - } - { - struct tst : until< any, star< any > > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, true, true ); - } - { - struct tst : until< star< any >, star< any > > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, true ); - } - { - struct tst : until< star< any >, star< any > > - { - }; - verify_analyze< any_seq< tst > >( __LINE__, __FILE__, true, true ); - } - { - struct tst : until< any, any > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, true, false ); - } - { - struct tst : until< star< any >, any > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, false ); - } - { - struct tst : plus< plus< any > > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, true, false ); - } - { - struct tst : star< star< any > > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, true ); - } - { - struct tst : plus< star< any > > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, true ); - } - { - struct tst : plus< opt< any > > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, true ); - } - { - struct tst : star< opt< any > > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, true ); - } - { - struct tst : star< plus< opt< any > > > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, true ); - } - { - struct tst : list< any, any > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, true, false ); - } - { - struct tst : list< star< any >, any > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, false ); - } - { - struct tst : list< any, opt< any > > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, true, false ); - } - { - struct tst : list< star< any >, opt< any > > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, true ); - } - { - struct tst : list_must< any, any > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, true, false ); - } - { - struct tst : list_must< star< any >, any > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, false ); - } - { - struct tst : list_must< any, opt< any > > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, true, false ); - } - { - struct tst : list_must< star< any >, opt< any > > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, true ); - } - { - struct tst : plus< pad_opt< alpha, digit > > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, true ); - } - { - struct tst : rep< 42, opt< alpha > > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, false ); - } - { - struct tst : rep_min< 42, opt< alpha > > - { - }; - verify_analyze< tst >( __LINE__, __FILE__, false, true ); - } + void unit_test() + { + verify_analyze< eof >( __LINE__, __FILE__, false, false ); + verify_analyze< eolf >( __LINE__, __FILE__, false, false ); + verify_analyze< success >( __LINE__, __FILE__, false, false ); + verify_analyze< failure >( __LINE__, __FILE__, true, false ); + { + struct tst : star< tst > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, true ); } + { + struct tst : plus< tst > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, true ); + } + { + struct tst : seq< eof, at< digit >, tst > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, true ); // This is a false positive. + } + { + struct tst : sor< digit, seq< at< digit >, tst > > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, true ); // This is a false positive. + } + { + struct tst : sor< digit, seq< opt< digit >, tst > > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, true ); + } + { + struct tst : sor< digit, tst > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, true ); + } + { + struct tst : at< any > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, false ); + } + { + struct tst : at< tst > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, true ); + } + { + struct tst : at< any, tst > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, false ); + } + { + struct tst : not_at< any > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, false ); + } + { + struct tst : opt< tst > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, true ); + } + { + struct tst : opt< any, tst > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, false ); + } + { + struct rec : sor< seq< rec, alpha >, alpha > + { + }; + verify_analyze< rec >( __LINE__, __FILE__, true, true ); + } + { + struct bar; + struct foo : seq< digit, bar > + { + }; + struct bar : plus< foo > + { + }; + verify_analyze< seq< any, bar > >( __LINE__, __FILE__, true, false ); + } + { + struct bar; + struct foo : seq< bar, digit > + { + }; + struct bar : plus< foo > + { + }; + verify_analyze< seq< bar, any > >( __LINE__, __FILE__, true, true ); + } + { + struct bar; + struct foo : sor< digit, bar > + { + }; + struct bar : plus< foo > + { + }; + verify_analyze< bar >( __LINE__, __FILE__, false, true ); + verify_analyze< foo >( __LINE__, __FILE__, false, true ); + verify_analyze< sor< any, bar > >( __LINE__, __FILE__, false, true ); + } + { + // Excerpt from the Lua 5.3 grammar: + // prefixexp ::= var | functioncall | ‘(’ exp ‘)’ + // functioncall ::= prefixexp args | prefixexp ‘:’ Name args + // var ::= Name | prefixexp ‘[’ exp ‘]’ | prefixexp ‘.’ Name + // Simplified version, equivalent regarding consumption of input: + struct var; + struct fun; + struct exp : sor< var, fun, seq< any, exp, any > > + { + }; + struct fun : seq< exp, any > + { + }; + struct var : sor< any, seq< exp, any, exp >, seq< exp, any > > + { + }; + verify_analyze< exp >( __LINE__, __FILE__, true, true ); + verify_analyze< fun >( __LINE__, __FILE__, true, true ); + verify_analyze< var >( __LINE__, __FILE__, true, true ); + } + { + struct exp : sor< exp, seq< any, exp > > + { + }; + verify_analyze< exp >( __LINE__, __FILE__, false, true ); + } + { + struct tst : until< any > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, true, false ); + } + { + struct tst : until< star< any > > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, false ); + } + { + struct tst : until< any, star< any > > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, true, true ); + } + { + struct tst : until< star< any >, star< any > > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, true ); + } + { + struct tst : until< star< any >, star< any > > + { + }; + verify_analyze< any_seq< tst > >( __LINE__, __FILE__, true, true ); + } + { + struct tst : until< any, any > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, true, false ); + } + { + struct tst : until< star< any >, any > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, false ); + } + { + struct tst : plus< plus< any > > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, true, false ); + } + { + struct tst : star< star< any > > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, true ); + } + { + struct tst : plus< star< any > > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, true ); + } + { + struct tst : plus< opt< any > > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, true ); + } + { + struct tst : star< opt< any > > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, true ); + } + { + struct tst : star< plus< opt< any > > > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, true ); + } + { + struct tst : list< any, any > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, true, false ); + } + { + struct tst : list< star< any >, any > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, false ); + } + { + struct tst : list< any, opt< any > > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, true, false ); + } + { + struct tst : list< star< any >, opt< any > > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, true ); + } + { + struct tst : list_must< any, any > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, true, false ); + } + { + struct tst : list_must< star< any >, any > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, false ); + } + { + struct tst : list_must< any, opt< any > > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, true, false ); + } + { + struct tst : list_must< star< any >, opt< any > > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, true ); + } + { + struct tst : plus< pad_opt< alpha, digit > > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, true ); + } + { + struct tst : rep< 42, opt< alpha > > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, false ); + } + { + struct tst : rep_min< 42, opt< alpha > > + { + }; + verify_analyze< tst >( __LINE__, __FILE__, false, true ); + } + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/argv_input.cpp b/packages/PEGTL/src/test/pegtl/argv_input.cpp index 0755211af..da27be5de 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <cstring> @@ -7,23 +7,19 @@ #include <tao/pegtl.hpp> -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - char data[ 12 ]; - std::memcpy( data, "foo\0bar\0baz", 12 ); - char* argv[] = { data, data + 4, data + 8 }; - argv_input<> in( argv, 1 ); - TAO_PEGTL_TEST_ASSERT( in.source() == "argv[1]" ); - const auto result = parse< string< 'b', 'a', 'r' > >( in ); - TAO_PEGTL_TEST_ASSERT( result ); - } + char data[ 12 ]; // NOLINT + std::memcpy( data, "foo\0bar\0baz", 12 ); + char* argv[] = { data, data + 4, data + 8 }; // NOLINT + argv_input in( argv, 1 ); + TAO_PEGTL_TEST_ASSERT( in.source() == "argv[1]" ); + const auto result = parse< string< 'b', 'a', 'r' > >( in ); + TAO_PEGTL_TEST_ASSERT( result ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/ascii_classes.cpp b/packages/PEGTL/src/test/pegtl/ascii_classes.cpp index 406b56735..a16a70d0b 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" @@ -6,114 +6,110 @@ #include "verify_char.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< alnum >( __LINE__, __FILE__, true, false ); - verify_analyze< alpha >( __LINE__, __FILE__, true, false ); - verify_analyze< any >( __LINE__, __FILE__, true, false ); - verify_analyze< blank >( __LINE__, __FILE__, true, false ); - verify_analyze< digit >( __LINE__, __FILE__, true, false ); - verify_analyze< eol >( __LINE__, __FILE__, true, false ); - verify_analyze< identifier_first >( __LINE__, __FILE__, true, false ); - verify_analyze< identifier_other >( __LINE__, __FILE__, true, false ); - verify_analyze< lower >( __LINE__, __FILE__, true, false ); - verify_analyze< nul >( __LINE__, __FILE__, true, false ); - verify_analyze< print >( __LINE__, __FILE__, true, false ); - verify_analyze< seven >( __LINE__, __FILE__, true, false ); - verify_analyze< space >( __LINE__, __FILE__, true, false ); - verify_analyze< upper >( __LINE__, __FILE__, true, false ); - verify_analyze< xdigit >( __LINE__, __FILE__, true, false ); - - verify_analyze< not_one< 'a' > >( __LINE__, __FILE__, true, false ); - verify_analyze< not_one< 'a', 'z' > >( __LINE__, __FILE__, true, false ); - verify_analyze< not_range< 'a', 'z' > >( __LINE__, __FILE__, true, false ); - verify_analyze< one< 'a' > >( __LINE__, __FILE__, true, false ); - verify_analyze< one< 'a', 'z' > >( __LINE__, __FILE__, true, false ); - verify_analyze< range< 'a', 'z' > >( __LINE__, __FILE__, true, false ); - verify_analyze< ranges< 'a', 'z' > >( __LINE__, __FILE__, true, false ); - verify_analyze< ranges< 'a', 'z', '4' > >( __LINE__, __FILE__, true, false ); - - verify_rule< alnum >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< alpha >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< any >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< blank >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< digit >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< eol >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< identifier_first >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< identifier_other >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< lower >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< nul >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< print >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< seven >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< space >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< upper >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< xdigit >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - - verify_rule< not_one< 'a' > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< not_one< 'a', 'z' > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< not_range< 'a', 'z' > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< one< 'a' > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< one< 'a', 'z' > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< range< 'a', 'z' > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< ranges< 'a', 'z' > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< ranges< 'a', 'z', '4' > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - - for( int i = -100; i < 200; ++i ) { - const auto c = char( i ); - - const bool is_blank = ( c == ' ' ) || ( c == '\t' ); - const bool is_digit = ( '0' <= c ) && ( c <= '9' ); - const bool is_lower = ( 'a' <= c ) && ( c <= 'z' ); - const bool is_print = ( ( ' ' <= c ) && ( c <= 126 ) ); - const bool is_seven = ( ( i >= 0 ) && ( i <= 127 ) ); - const bool is_space = ( c == '\n' ) || ( c == '\r' ) || ( c == '\v' ) || ( c == '\f' ); - const bool is_upper = ( 'A' <= c ) && ( c <= 'Z' ); - const bool is_xalpha = ( ( 'a' <= c ) && ( c <= 'f' ) ) || ( ( 'A' <= c ) && ( c <= 'F' ) ); - - const bool is_newline = ( c == '\n' ); - - const bool is_ident_first = ( c == '_' ) || is_lower || is_upper; - const bool is_ident_other = is_ident_first || is_digit; - - verify_char< alnum >( __LINE__, __FILE__, c, is_lower || is_upper || is_digit ); - verify_char< alpha >( __LINE__, __FILE__, c, is_lower || is_upper ); - verify_char< any >( __LINE__, __FILE__, c, true ); - verify_char< blank >( __LINE__, __FILE__, c, is_blank ); - verify_char< digit >( __LINE__, __FILE__, c, is_digit ); - verify_char< eol >( __LINE__, __FILE__, c, is_newline ); - verify_char< identifier_first >( __LINE__, __FILE__, c, is_ident_first ); - verify_char< identifier_other >( __LINE__, __FILE__, c, is_ident_other ); - verify_char< lower >( __LINE__, __FILE__, c, is_lower ); - verify_char< nul >( __LINE__, __FILE__, c, c == 0 ); - verify_char< print >( __LINE__, __FILE__, c, is_print ); - verify_char< seven >( __LINE__, __FILE__, c, is_seven ); - verify_char< space >( __LINE__, __FILE__, c, is_blank || is_space ); - verify_char< upper >( __LINE__, __FILE__, c, is_upper ); - verify_char< xdigit >( __LINE__, __FILE__, c, is_digit || is_xalpha ); - - const bool is_one = ( c == '#' ) || ( c == 'a' ) || ( c == ' ' ); - const bool is_range = ( 20 <= c ) && ( c <= 120 ); - const bool is_ranges = is_range || ( c == 3 ); - - verify_char< not_one< 'P' > >( __LINE__, __FILE__, c, c != 'P' ); - verify_char< not_one< 'a', '#', ' ' > >( __LINE__, __FILE__, c, !is_one ); - verify_char< not_range< 20, 120 > >( __LINE__, __FILE__, c, !is_range ); - verify_char< one< 'T' > >( __LINE__, __FILE__, c, c == 'T' ); - verify_char< one< 'a', '#', ' ' > >( __LINE__, __FILE__, c, is_one ); - verify_char< range< 20, 120 > >( __LINE__, __FILE__, c, is_range ); - verify_char< ranges< 20, 120 > >( __LINE__, __FILE__, c, is_range ); - verify_char< ranges< 20, 120, 3 > >( __LINE__, __FILE__, c, is_ranges ); - - verify_char< eolf >( __LINE__, __FILE__, c, is_newline ); - } + verify_analyze< alnum >( __LINE__, __FILE__, true, false ); + verify_analyze< alpha >( __LINE__, __FILE__, true, false ); + verify_analyze< any >( __LINE__, __FILE__, true, false ); + verify_analyze< blank >( __LINE__, __FILE__, true, false ); + verify_analyze< digit >( __LINE__, __FILE__, true, false ); + verify_analyze< eol >( __LINE__, __FILE__, true, false ); + verify_analyze< identifier_first >( __LINE__, __FILE__, true, false ); + verify_analyze< identifier_other >( __LINE__, __FILE__, true, false ); + verify_analyze< lower >( __LINE__, __FILE__, true, false ); + verify_analyze< nul >( __LINE__, __FILE__, true, false ); + verify_analyze< print >( __LINE__, __FILE__, true, false ); + verify_analyze< seven >( __LINE__, __FILE__, true, false ); + verify_analyze< space >( __LINE__, __FILE__, true, false ); + verify_analyze< upper >( __LINE__, __FILE__, true, false ); + verify_analyze< xdigit >( __LINE__, __FILE__, true, false ); + + verify_analyze< not_one< 'a' > >( __LINE__, __FILE__, true, false ); + verify_analyze< not_one< 'a', 'z' > >( __LINE__, __FILE__, true, false ); + verify_analyze< not_range< 'a', 'z' > >( __LINE__, __FILE__, true, false ); + verify_analyze< one< 'a' > >( __LINE__, __FILE__, true, false ); + verify_analyze< one< 'a', 'z' > >( __LINE__, __FILE__, true, false ); + verify_analyze< range< 'a', 'z' > >( __LINE__, __FILE__, true, false ); + verify_analyze< ranges< 'a', 'z' > >( __LINE__, __FILE__, true, false ); + verify_analyze< ranges< 'a', 'z', '4' > >( __LINE__, __FILE__, true, false ); + + verify_rule< alnum >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< alpha >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< any >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< blank >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< digit >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< eol >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< identifier_first >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< identifier_other >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< lower >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< nul >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< print >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< seven >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< space >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< upper >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< xdigit >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + + verify_rule< not_one< 'a' > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< not_one< 'a', 'z' > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< not_range< 'a', 'z' > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< one< 'a' > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< one< 'a', 'z' > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< range< 'a', 'z' > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< ranges< 'a', 'z' > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< ranges< 'a', 'z', '4' > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + + for( int i = -100; i < 200; ++i ) { + const auto c = char( i ); + + const bool is_blank = ( c == ' ' ) || ( c == '\t' ); + const bool is_digit = ( '0' <= c ) && ( c <= '9' ); + const bool is_lower = ( 'a' <= c ) && ( c <= 'z' ); + const bool is_print = ( ( ' ' <= c ) && ( c <= 126 ) ); + const bool is_seven = ( ( i >= 0 ) && ( i <= 127 ) ); + const bool is_space = ( c == '\n' ) || ( c == '\r' ) || ( c == '\v' ) || ( c == '\f' ); + const bool is_upper = ( 'A' <= c ) && ( c <= 'Z' ); + const bool is_xalpha = ( ( 'a' <= c ) && ( c <= 'f' ) ) || ( ( 'A' <= c ) && ( c <= 'F' ) ); + + const bool is_newline = ( c == '\n' ); + + const bool is_ident_first = ( c == '_' ) || is_lower || is_upper; + const bool is_ident_other = is_ident_first || is_digit; + + verify_char< alnum >( __LINE__, __FILE__, c, is_lower || is_upper || is_digit ); + verify_char< alpha >( __LINE__, __FILE__, c, is_lower || is_upper ); + verify_char< any >( __LINE__, __FILE__, c, true ); + verify_char< blank >( __LINE__, __FILE__, c, is_blank ); + verify_char< digit >( __LINE__, __FILE__, c, is_digit ); + verify_char< eol >( __LINE__, __FILE__, c, is_newline ); + verify_char< identifier_first >( __LINE__, __FILE__, c, is_ident_first ); + verify_char< identifier_other >( __LINE__, __FILE__, c, is_ident_other ); + verify_char< lower >( __LINE__, __FILE__, c, is_lower ); + verify_char< nul >( __LINE__, __FILE__, c, c == 0 ); + verify_char< print >( __LINE__, __FILE__, c, is_print ); + verify_char< seven >( __LINE__, __FILE__, c, is_seven ); + verify_char< space >( __LINE__, __FILE__, c, is_blank || is_space ); + verify_char< upper >( __LINE__, __FILE__, c, is_upper ); + verify_char< xdigit >( __LINE__, __FILE__, c, is_digit || is_xalpha ); + + const bool is_one = ( c == '#' ) || ( c == 'a' ) || ( c == ' ' ); + const bool is_range = ( 20 <= c ) && ( c <= 120 ); + const bool is_ranges = is_range || ( c == 3 ); + + verify_char< not_one< 'P' > >( __LINE__, __FILE__, c, c != 'P' ); + verify_char< not_one< 'a', '#', ' ' > >( __LINE__, __FILE__, c, !is_one ); + verify_char< not_range< 20, 120 > >( __LINE__, __FILE__, c, !is_range ); + verify_char< one< 'T' > >( __LINE__, __FILE__, c, c == 'T' ); + verify_char< one< 'a', '#', ' ' > >( __LINE__, __FILE__, c, is_one ); + verify_char< range< 20, 120 > >( __LINE__, __FILE__, c, is_range ); + verify_char< ranges< 20, 120 > >( __LINE__, __FILE__, c, is_range ); + verify_char< ranges< 20, 120, 3 > >( __LINE__, __FILE__, c, is_ranges ); + + verify_char< eolf >( __LINE__, __FILE__, c, is_newline ); } + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/ascii_eol.cpp b/packages/PEGTL/src/test/pegtl/ascii_eol.cpp index b5808c4cd..d84eef09d 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" @@ -6,87 +6,83 @@ #include "verify_char.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< eol >( __LINE__, __FILE__, true, false ); + verify_analyze< eol >( __LINE__, __FILE__, true, false ); - verify_rule< eol >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); + verify_rule< eol >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); - for( char i = 1; i < 127; ++i ) { - verify_char< eol >( __LINE__, __FILE__, i, ( i == '\n' ) ? result_type::SUCCESS : result_type::LOCAL_FAILURE ); - } - verify_rule< eol, eol::lf >( __LINE__, __FILE__, " ", result_type::LOCAL_FAILURE, 1 ); - verify_rule< eol, eol::lf >( __LINE__, __FILE__, "\r", result_type::LOCAL_FAILURE, 1 ); - verify_rule< eol, eol::lf >( __LINE__, __FILE__, "\n", result_type::SUCCESS, 0 ); - verify_rule< eol, eol::lf >( __LINE__, __FILE__, "\r\n", result_type::LOCAL_FAILURE, 2 ); - verify_rule< eol, eol::lf >( __LINE__, __FILE__, "\n\r", result_type::SUCCESS, 1 ); - verify_rule< eol, eol::lf >( __LINE__, __FILE__, "\n\r\n", result_type::SUCCESS, 2 ); - verify_rule< eol, eol::lf >( __LINE__, __FILE__, "\n\r\r", result_type::SUCCESS, 2 ); - verify_rule< eol, eol::lf >( __LINE__, __FILE__, "\na", result_type::SUCCESS, 1 ); - verify_rule< eol, eol::lf >( __LINE__, __FILE__, "\ra", result_type::LOCAL_FAILURE, 2 ); - verify_rule< eol, eol::lf >( __LINE__, __FILE__, "\r\na", result_type::LOCAL_FAILURE, 3 ); - verify_rule< eol, eol::lf >( __LINE__, __FILE__, "\r\n\r", result_type::LOCAL_FAILURE, 3 ); - verify_rule< eol, eol::lf >( __LINE__, __FILE__, "\r\n\n", result_type::LOCAL_FAILURE, 3 ); - - verify_rule< eol, eol::cr >( __LINE__, __FILE__, " ", result_type::LOCAL_FAILURE, 1 ); - verify_rule< eol, eol::cr >( __LINE__, __FILE__, "\r", result_type::SUCCESS, 0 ); - verify_rule< eol, eol::cr >( __LINE__, __FILE__, "\n", result_type::LOCAL_FAILURE, 1 ); - verify_rule< eol, eol::cr >( __LINE__, __FILE__, "\r\n", result_type::SUCCESS, 1 ); - verify_rule< eol, eol::cr >( __LINE__, __FILE__, "\n\r", result_type::LOCAL_FAILURE, 2 ); - verify_rule< eol, eol::cr >( __LINE__, __FILE__, "\n\r\n", result_type::LOCAL_FAILURE, 3 ); - verify_rule< eol, eol::cr >( __LINE__, __FILE__, "\n\r\r", result_type::LOCAL_FAILURE, 3 ); - verify_rule< eol, eol::cr >( __LINE__, __FILE__, "\na", result_type::LOCAL_FAILURE, 2 ); - verify_rule< eol, eol::cr >( __LINE__, __FILE__, "\ra", result_type::SUCCESS, 1 ); - verify_rule< eol, eol::cr >( __LINE__, __FILE__, "\r\na", result_type::SUCCESS, 2 ); - verify_rule< eol, eol::cr >( __LINE__, __FILE__, "\r\n\r", result_type::SUCCESS, 2 ); - verify_rule< eol, eol::cr >( __LINE__, __FILE__, "\r\n\n", result_type::SUCCESS, 2 ); + for( char i = 1; i < 127; ++i ) { + verify_char< eol >( __LINE__, __FILE__, i, ( i == '\n' ) ? result_type::success : result_type::local_failure ); + } + verify_rule< eol, eol::lf >( __LINE__, __FILE__, " ", result_type::local_failure, 1 ); + verify_rule< eol, eol::lf >( __LINE__, __FILE__, "\r", result_type::local_failure, 1 ); + verify_rule< eol, eol::lf >( __LINE__, __FILE__, "\n", result_type::success, 0 ); + verify_rule< eol, eol::lf >( __LINE__, __FILE__, "\r\n", result_type::local_failure, 2 ); + verify_rule< eol, eol::lf >( __LINE__, __FILE__, "\n\r", result_type::success, 1 ); + verify_rule< eol, eol::lf >( __LINE__, __FILE__, "\n\r\n", result_type::success, 2 ); + verify_rule< eol, eol::lf >( __LINE__, __FILE__, "\n\r\r", result_type::success, 2 ); + verify_rule< eol, eol::lf >( __LINE__, __FILE__, "\na", result_type::success, 1 ); + verify_rule< eol, eol::lf >( __LINE__, __FILE__, "\ra", result_type::local_failure, 2 ); + verify_rule< eol, eol::lf >( __LINE__, __FILE__, "\r\na", result_type::local_failure, 3 ); + verify_rule< eol, eol::lf >( __LINE__, __FILE__, "\r\n\r", result_type::local_failure, 3 ); + verify_rule< eol, eol::lf >( __LINE__, __FILE__, "\r\n\n", result_type::local_failure, 3 ); - verify_rule< eol, eol::crlf >( __LINE__, __FILE__, " ", result_type::LOCAL_FAILURE, 1 ); - verify_rule< eol, eol::crlf >( __LINE__, __FILE__, "\r", result_type::LOCAL_FAILURE, 1 ); - verify_rule< eol, eol::crlf >( __LINE__, __FILE__, "\n", result_type::LOCAL_FAILURE, 1 ); - verify_rule< eol, eol::crlf >( __LINE__, __FILE__, "\r\n", result_type::SUCCESS, 0 ); - verify_rule< eol, eol::crlf >( __LINE__, __FILE__, "\n\r", result_type::LOCAL_FAILURE, 2 ); - verify_rule< eol, eol::crlf >( __LINE__, __FILE__, "\n\r\n", result_type::LOCAL_FAILURE, 3 ); - verify_rule< eol, eol::crlf >( __LINE__, __FILE__, "\n\r\r", result_type::LOCAL_FAILURE, 3 ); - verify_rule< eol, eol::crlf >( __LINE__, __FILE__, "\na", result_type::LOCAL_FAILURE, 2 ); - verify_rule< eol, eol::crlf >( __LINE__, __FILE__, "\ra", result_type::LOCAL_FAILURE, 2 ); - verify_rule< eol, eol::crlf >( __LINE__, __FILE__, "\r\na", result_type::SUCCESS, 1 ); - verify_rule< eol, eol::crlf >( __LINE__, __FILE__, "\r\n\r", result_type::SUCCESS, 1 ); - verify_rule< eol, eol::crlf >( __LINE__, __FILE__, "\r\n\n", result_type::SUCCESS, 1 ); + verify_rule< eol, eol::cr >( __LINE__, __FILE__, " ", result_type::local_failure, 1 ); + verify_rule< eol, eol::cr >( __LINE__, __FILE__, "\r", result_type::success, 0 ); + verify_rule< eol, eol::cr >( __LINE__, __FILE__, "\n", result_type::local_failure, 1 ); + verify_rule< eol, eol::cr >( __LINE__, __FILE__, "\r\n", result_type::success, 1 ); + verify_rule< eol, eol::cr >( __LINE__, __FILE__, "\n\r", result_type::local_failure, 2 ); + verify_rule< eol, eol::cr >( __LINE__, __FILE__, "\n\r\n", result_type::local_failure, 3 ); + verify_rule< eol, eol::cr >( __LINE__, __FILE__, "\n\r\r", result_type::local_failure, 3 ); + verify_rule< eol, eol::cr >( __LINE__, __FILE__, "\na", result_type::local_failure, 2 ); + verify_rule< eol, eol::cr >( __LINE__, __FILE__, "\ra", result_type::success, 1 ); + verify_rule< eol, eol::cr >( __LINE__, __FILE__, "\r\na", result_type::success, 2 ); + verify_rule< eol, eol::cr >( __LINE__, __FILE__, "\r\n\r", result_type::success, 2 ); + verify_rule< eol, eol::cr >( __LINE__, __FILE__, "\r\n\n", result_type::success, 2 ); - verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, " ", result_type::LOCAL_FAILURE, 1 ); - verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, "\r", result_type::LOCAL_FAILURE, 1 ); - verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, "\n", result_type::SUCCESS, 0 ); - verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, "\r\n", result_type::SUCCESS, 0 ); - verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, "\n\r", result_type::SUCCESS, 1 ); - verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, "\n\r\n", result_type::SUCCESS, 2 ); - verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, "\n\r\r", result_type::SUCCESS, 2 ); - verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, "\na", result_type::SUCCESS, 1 ); - verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, "\ra", result_type::LOCAL_FAILURE, 2 ); - verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, "\r\na", result_type::SUCCESS, 1 ); - verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, "\r\n\r", result_type::SUCCESS, 1 ); - verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, "\r\n\n", result_type::SUCCESS, 1 ); + verify_rule< eol, eol::crlf >( __LINE__, __FILE__, " ", result_type::local_failure, 1 ); + verify_rule< eol, eol::crlf >( __LINE__, __FILE__, "\r", result_type::local_failure, 1 ); + verify_rule< eol, eol::crlf >( __LINE__, __FILE__, "\n", result_type::local_failure, 1 ); + verify_rule< eol, eol::crlf >( __LINE__, __FILE__, "\r\n", result_type::success, 0 ); + verify_rule< eol, eol::crlf >( __LINE__, __FILE__, "\n\r", result_type::local_failure, 2 ); + verify_rule< eol, eol::crlf >( __LINE__, __FILE__, "\n\r\n", result_type::local_failure, 3 ); + verify_rule< eol, eol::crlf >( __LINE__, __FILE__, "\n\r\r", result_type::local_failure, 3 ); + verify_rule< eol, eol::crlf >( __LINE__, __FILE__, "\na", result_type::local_failure, 2 ); + verify_rule< eol, eol::crlf >( __LINE__, __FILE__, "\ra", result_type::local_failure, 2 ); + verify_rule< eol, eol::crlf >( __LINE__, __FILE__, "\r\na", result_type::success, 1 ); + verify_rule< eol, eol::crlf >( __LINE__, __FILE__, "\r\n\r", result_type::success, 1 ); + verify_rule< eol, eol::crlf >( __LINE__, __FILE__, "\r\n\n", result_type::success, 1 ); - verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, " ", result_type::LOCAL_FAILURE, 1 ); - verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, "\r", result_type::SUCCESS, 0 ); - verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, "\n", result_type::LOCAL_FAILURE, 1 ); - verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, "\r\n", result_type::SUCCESS, 0 ); - verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, "\n\r", result_type::LOCAL_FAILURE, 2 ); - verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, "\n\r\n", result_type::LOCAL_FAILURE, 3 ); - verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, "\n\r\r", result_type::LOCAL_FAILURE, 3 ); - verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, "\na", result_type::LOCAL_FAILURE, 2 ); - verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, "\ra", result_type::SUCCESS, 1 ); - verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, "\r\na", result_type::SUCCESS, 1 ); - verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, "\r\n\r", result_type::SUCCESS, 1 ); - verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, "\r\n\n", result_type::SUCCESS, 1 ); - } + verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, " ", result_type::local_failure, 1 ); + verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, "\r", result_type::local_failure, 1 ); + verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, "\n", result_type::success, 0 ); + verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, "\r\n", result_type::success, 0 ); + verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, "\n\r", result_type::success, 1 ); + verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, "\n\r\n", result_type::success, 2 ); + verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, "\n\r\r", result_type::success, 2 ); + verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, "\na", result_type::success, 1 ); + verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, "\ra", result_type::local_failure, 2 ); + verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, "\r\na", result_type::success, 1 ); + verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, "\r\n\r", result_type::success, 1 ); + verify_rule< eol, eol::lf_crlf >( __LINE__, __FILE__, "\r\n\n", result_type::success, 1 ); - } // namespace TAO_PEGTL_NAMESPACE + verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, " ", result_type::local_failure, 1 ); + verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, "\r", result_type::success, 0 ); + verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, "\n", result_type::local_failure, 1 ); + verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, "\r\n", result_type::success, 0 ); + verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, "\n\r", result_type::local_failure, 2 ); + verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, "\n\r\n", result_type::local_failure, 3 ); + verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, "\n\r\r", result_type::local_failure, 3 ); + verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, "\na", result_type::local_failure, 2 ); + verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, "\ra", result_type::success, 1 ); + verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, "\r\na", result_type::success, 1 ); + verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, "\r\n\r", result_type::success, 1 ); + verify_rule< eol, eol::cr_crlf >( __LINE__, __FILE__, "\r\n\n", result_type::success, 1 ); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/ascii_eolf.cpp b/packages/PEGTL/src/test/pegtl/ascii_eolf.cpp index 53baa0d86..7b94b2475 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" @@ -6,87 +6,83 @@ #include "verify_char.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< eolf >( __LINE__, __FILE__, false, false ); + verify_analyze< eolf >( __LINE__, __FILE__, false, false ); - verify_rule< eolf >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); + verify_rule< eolf >( __LINE__, __FILE__, "", result_type::success, 0 ); - for( char i = 1; i < 127; ++i ) { - verify_char< eolf >( __LINE__, __FILE__, i, ( i == '\n' ) ? result_type::SUCCESS : result_type::LOCAL_FAILURE ); - } - verify_rule< eolf, eol::lf >( __LINE__, __FILE__, " ", result_type::LOCAL_FAILURE, 1 ); - verify_rule< eolf, eol::lf >( __LINE__, __FILE__, "\r", result_type::LOCAL_FAILURE, 1 ); - verify_rule< eolf, eol::lf >( __LINE__, __FILE__, "\n", result_type::SUCCESS, 0 ); - verify_rule< eolf, eol::lf >( __LINE__, __FILE__, "\r\n", result_type::LOCAL_FAILURE, 2 ); - verify_rule< eolf, eol::lf >( __LINE__, __FILE__, "\n\r", result_type::SUCCESS, 1 ); - verify_rule< eolf, eol::lf >( __LINE__, __FILE__, "\n\r\n", result_type::SUCCESS, 2 ); - verify_rule< eolf, eol::lf >( __LINE__, __FILE__, "\n\r\r", result_type::SUCCESS, 2 ); - verify_rule< eolf, eol::lf >( __LINE__, __FILE__, "\na", result_type::SUCCESS, 1 ); - verify_rule< eolf, eol::lf >( __LINE__, __FILE__, "\ra", result_type::LOCAL_FAILURE, 2 ); - verify_rule< eolf, eol::lf >( __LINE__, __FILE__, "\r\na", result_type::LOCAL_FAILURE, 3 ); - verify_rule< eolf, eol::lf >( __LINE__, __FILE__, "\r\n\r", result_type::LOCAL_FAILURE, 3 ); - verify_rule< eolf, eol::lf >( __LINE__, __FILE__, "\r\n\n", result_type::LOCAL_FAILURE, 3 ); - - verify_rule< eolf, eol::cr >( __LINE__, __FILE__, " ", result_type::LOCAL_FAILURE, 1 ); - verify_rule< eolf, eol::cr >( __LINE__, __FILE__, "\r", result_type::SUCCESS, 0 ); - verify_rule< eolf, eol::cr >( __LINE__, __FILE__, "\n", result_type::LOCAL_FAILURE, 1 ); - verify_rule< eolf, eol::cr >( __LINE__, __FILE__, "\r\n", result_type::SUCCESS, 1 ); - verify_rule< eolf, eol::cr >( __LINE__, __FILE__, "\n\r", result_type::LOCAL_FAILURE, 2 ); - verify_rule< eolf, eol::cr >( __LINE__, __FILE__, "\n\r\n", result_type::LOCAL_FAILURE, 3 ); - verify_rule< eolf, eol::cr >( __LINE__, __FILE__, "\n\r\r", result_type::LOCAL_FAILURE, 3 ); - verify_rule< eolf, eol::cr >( __LINE__, __FILE__, "\na", result_type::LOCAL_FAILURE, 2 ); - verify_rule< eolf, eol::cr >( __LINE__, __FILE__, "\ra", result_type::SUCCESS, 1 ); - verify_rule< eolf, eol::cr >( __LINE__, __FILE__, "\r\na", result_type::SUCCESS, 2 ); - verify_rule< eolf, eol::cr >( __LINE__, __FILE__, "\r\n\r", result_type::SUCCESS, 2 ); - verify_rule< eolf, eol::cr >( __LINE__, __FILE__, "\r\n\n", result_type::SUCCESS, 2 ); + for( char i = 1; i < 127; ++i ) { + verify_char< eolf >( __LINE__, __FILE__, i, ( i == '\n' ) ? result_type::success : result_type::local_failure ); + } + verify_rule< eolf, eol::lf >( __LINE__, __FILE__, " ", result_type::local_failure, 1 ); + verify_rule< eolf, eol::lf >( __LINE__, __FILE__, "\r", result_type::local_failure, 1 ); + verify_rule< eolf, eol::lf >( __LINE__, __FILE__, "\n", result_type::success, 0 ); + verify_rule< eolf, eol::lf >( __LINE__, __FILE__, "\r\n", result_type::local_failure, 2 ); + verify_rule< eolf, eol::lf >( __LINE__, __FILE__, "\n\r", result_type::success, 1 ); + verify_rule< eolf, eol::lf >( __LINE__, __FILE__, "\n\r\n", result_type::success, 2 ); + verify_rule< eolf, eol::lf >( __LINE__, __FILE__, "\n\r\r", result_type::success, 2 ); + verify_rule< eolf, eol::lf >( __LINE__, __FILE__, "\na", result_type::success, 1 ); + verify_rule< eolf, eol::lf >( __LINE__, __FILE__, "\ra", result_type::local_failure, 2 ); + verify_rule< eolf, eol::lf >( __LINE__, __FILE__, "\r\na", result_type::local_failure, 3 ); + verify_rule< eolf, eol::lf >( __LINE__, __FILE__, "\r\n\r", result_type::local_failure, 3 ); + verify_rule< eolf, eol::lf >( __LINE__, __FILE__, "\r\n\n", result_type::local_failure, 3 ); - verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, " ", result_type::LOCAL_FAILURE, 1 ); - verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, "\r", result_type::LOCAL_FAILURE, 1 ); - verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, "\n", result_type::LOCAL_FAILURE, 1 ); - verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, "\r\n", result_type::SUCCESS, 0 ); - verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, "\n\r", result_type::LOCAL_FAILURE, 2 ); - verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, "\n\r\n", result_type::LOCAL_FAILURE, 3 ); - verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, "\n\r\r", result_type::LOCAL_FAILURE, 3 ); - verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, "\na", result_type::LOCAL_FAILURE, 2 ); - verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, "\ra", result_type::LOCAL_FAILURE, 2 ); - verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, "\r\na", result_type::SUCCESS, 1 ); - verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, "\r\n\r", result_type::SUCCESS, 1 ); - verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, "\r\n\n", result_type::SUCCESS, 1 ); + verify_rule< eolf, eol::cr >( __LINE__, __FILE__, " ", result_type::local_failure, 1 ); + verify_rule< eolf, eol::cr >( __LINE__, __FILE__, "\r", result_type::success, 0 ); + verify_rule< eolf, eol::cr >( __LINE__, __FILE__, "\n", result_type::local_failure, 1 ); + verify_rule< eolf, eol::cr >( __LINE__, __FILE__, "\r\n", result_type::success, 1 ); + verify_rule< eolf, eol::cr >( __LINE__, __FILE__, "\n\r", result_type::local_failure, 2 ); + verify_rule< eolf, eol::cr >( __LINE__, __FILE__, "\n\r\n", result_type::local_failure, 3 ); + verify_rule< eolf, eol::cr >( __LINE__, __FILE__, "\n\r\r", result_type::local_failure, 3 ); + verify_rule< eolf, eol::cr >( __LINE__, __FILE__, "\na", result_type::local_failure, 2 ); + verify_rule< eolf, eol::cr >( __LINE__, __FILE__, "\ra", result_type::success, 1 ); + verify_rule< eolf, eol::cr >( __LINE__, __FILE__, "\r\na", result_type::success, 2 ); + verify_rule< eolf, eol::cr >( __LINE__, __FILE__, "\r\n\r", result_type::success, 2 ); + verify_rule< eolf, eol::cr >( __LINE__, __FILE__, "\r\n\n", result_type::success, 2 ); - verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, " ", result_type::LOCAL_FAILURE, 1 ); - verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, "\r", result_type::LOCAL_FAILURE, 1 ); - verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, "\n", result_type::SUCCESS, 0 ); - verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, "\r\n", result_type::SUCCESS, 0 ); - verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, "\n\r", result_type::SUCCESS, 1 ); - verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, "\n\r\n", result_type::SUCCESS, 2 ); - verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, "\n\r\r", result_type::SUCCESS, 2 ); - verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, "\na", result_type::SUCCESS, 1 ); - verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, "\ra", result_type::LOCAL_FAILURE, 2 ); - verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, "\r\na", result_type::SUCCESS, 1 ); - verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, "\r\n\r", result_type::SUCCESS, 1 ); - verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, "\r\n\n", result_type::SUCCESS, 1 ); + verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, " ", result_type::local_failure, 1 ); + verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, "\r", result_type::local_failure, 1 ); + verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, "\n", result_type::local_failure, 1 ); + verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, "\r\n", result_type::success, 0 ); + verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, "\n\r", result_type::local_failure, 2 ); + verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, "\n\r\n", result_type::local_failure, 3 ); + verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, "\n\r\r", result_type::local_failure, 3 ); + verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, "\na", result_type::local_failure, 2 ); + verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, "\ra", result_type::local_failure, 2 ); + verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, "\r\na", result_type::success, 1 ); + verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, "\r\n\r", result_type::success, 1 ); + verify_rule< eolf, eol::crlf >( __LINE__, __FILE__, "\r\n\n", result_type::success, 1 ); - verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, " ", result_type::LOCAL_FAILURE, 1 ); - verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, "\r", result_type::SUCCESS, 0 ); - verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, "\n", result_type::LOCAL_FAILURE, 1 ); - verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, "\r\n", result_type::SUCCESS, 0 ); - verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, "\n\r", result_type::LOCAL_FAILURE, 2 ); - verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, "\n\r\n", result_type::LOCAL_FAILURE, 3 ); - verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, "\n\r\r", result_type::LOCAL_FAILURE, 3 ); - verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, "\na", result_type::LOCAL_FAILURE, 2 ); - verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, "\ra", result_type::SUCCESS, 1 ); - verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, "\r\na", result_type::SUCCESS, 1 ); - verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, "\r\n\r", result_type::SUCCESS, 1 ); - verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, "\r\n\n", result_type::SUCCESS, 1 ); - } + verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, " ", result_type::local_failure, 1 ); + verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, "\r", result_type::local_failure, 1 ); + verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, "\n", result_type::success, 0 ); + verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, "\r\n", result_type::success, 0 ); + verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, "\n\r", result_type::success, 1 ); + verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, "\n\r\n", result_type::success, 2 ); + verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, "\n\r\r", result_type::success, 2 ); + verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, "\na", result_type::success, 1 ); + verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, "\ra", result_type::local_failure, 2 ); + verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, "\r\na", result_type::success, 1 ); + verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, "\r\n\r", result_type::success, 1 ); + verify_rule< eolf, eol::lf_crlf >( __LINE__, __FILE__, "\r\n\n", result_type::success, 1 ); - } // namespace TAO_PEGTL_NAMESPACE + verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, " ", result_type::local_failure, 1 ); + verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, "\r", result_type::success, 0 ); + verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, "\n", result_type::local_failure, 1 ); + verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, "\r\n", result_type::success, 0 ); + verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, "\n\r", result_type::local_failure, 2 ); + verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, "\n\r\n", result_type::local_failure, 3 ); + verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, "\n\r\r", result_type::local_failure, 3 ); + verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, "\na", result_type::local_failure, 2 ); + verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, "\ra", result_type::success, 1 ); + verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, "\r\na", result_type::success, 1 ); + verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, "\r\n\r", result_type::success, 1 ); + verify_rule< eolf, eol::cr_crlf >( __LINE__, __FILE__, "\r\n\n", result_type::success, 1 ); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/ascii_forty_two.cpp b/packages/PEGTL/src/test/pegtl/ascii_forty_two.cpp index 258feea7b..4e79fdd9d 100644 --- a/packages/PEGTL/src/test/pegtl/ascii_forty_two.cpp +++ b/packages/PEGTL/src/test/pegtl/ascii_forty_two.cpp @@ -1,42 +1,38 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< forty_two< 'a' > >( __LINE__, __FILE__, true, false ); - verify_analyze< forty_two< 'a', 'z' > >( __LINE__, __FILE__, true, false ); + verify_analyze< forty_two< 'a' > >( __LINE__, __FILE__, true, false ); + verify_analyze< forty_two< 'a', 'z' > >( __LINE__, __FILE__, true, false ); - for( std::size_t i = 0; i < 42; ++i ) { - 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, 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, 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, i - 42 ); - } - verify_rule< forty_two< 'a', 'z' > >( __LINE__, __FILE__, "azzaazaazaaazzzaaaazzaaazzaazazzzaazzazaza", result_type::SUCCESS ); + for( std::size_t i = 0; i < 42; ++i ) { + 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, 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, 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, i - 42 ); + } + verify_rule< forty_two< 'a', 'z' > >( __LINE__, __FILE__, "azzaazaazaaazzzaaaazzaaazzaazazzzaazzazaza", result_type::success ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/ascii_identifier.cpp b/packages/PEGTL/src/test/pegtl/ascii_identifier.cpp index d384fde2d..059b98bc4 100644 --- a/packages/PEGTL/src/test/pegtl/ascii_identifier.cpp +++ b/packages/PEGTL/src/test/pegtl/ascii_identifier.cpp @@ -1,35 +1,31 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< identifier >( __LINE__, __FILE__, true, false ); + verify_analyze< identifier >( __LINE__, __FILE__, true, false ); - verify_rule< identifier >( __LINE__, __FILE__, "_", result_type::SUCCESS, 0 ); - verify_rule< identifier >( __LINE__, __FILE__, "_a", result_type::SUCCESS, 0 ); - verify_rule< identifier >( __LINE__, __FILE__, "_1", result_type::SUCCESS, 0 ); - verify_rule< identifier >( __LINE__, __FILE__, "_123", result_type::SUCCESS, 0 ); - verify_rule< identifier >( __LINE__, __FILE__, "_1a", result_type::SUCCESS, 0 ); - verify_rule< identifier >( __LINE__, __FILE__, "_a1", result_type::SUCCESS, 0 ); - verify_rule< identifier >( __LINE__, __FILE__, "_fro_bble", result_type::SUCCESS, 0 ); - verify_rule< identifier >( __LINE__, __FILE__, "f_o_o42", result_type::SUCCESS, 0 ); - verify_rule< identifier >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< identifier >( __LINE__, __FILE__, "1", result_type::LOCAL_FAILURE, 1 ); - verify_rule< identifier >( __LINE__, __FILE__, " ", result_type::LOCAL_FAILURE, 1 ); - verify_rule< identifier >( __LINE__, __FILE__, " _", result_type::LOCAL_FAILURE, 2 ); - verify_rule< identifier >( __LINE__, __FILE__, " a", result_type::LOCAL_FAILURE, 2 ); - } + verify_rule< identifier >( __LINE__, __FILE__, "_", result_type::success, 0 ); + verify_rule< identifier >( __LINE__, __FILE__, "_a", result_type::success, 0 ); + verify_rule< identifier >( __LINE__, __FILE__, "_1", result_type::success, 0 ); + verify_rule< identifier >( __LINE__, __FILE__, "_123", result_type::success, 0 ); + verify_rule< identifier >( __LINE__, __FILE__, "_1a", result_type::success, 0 ); + verify_rule< identifier >( __LINE__, __FILE__, "_a1", result_type::success, 0 ); + verify_rule< identifier >( __LINE__, __FILE__, "_fro_bble", result_type::success, 0 ); + verify_rule< identifier >( __LINE__, __FILE__, "f_o_o42", result_type::success, 0 ); + verify_rule< identifier >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< identifier >( __LINE__, __FILE__, "1", result_type::local_failure, 1 ); + verify_rule< identifier >( __LINE__, __FILE__, " ", result_type::local_failure, 1 ); + verify_rule< identifier >( __LINE__, __FILE__, " _", result_type::local_failure, 2 ); + verify_rule< identifier >( __LINE__, __FILE__, " a", result_type::local_failure, 2 ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/ascii_istring.cpp b/packages/PEGTL/src/test/pegtl/ascii_istring.cpp index 054c1aa3f..06816ae85 100644 --- a/packages/PEGTL/src/test/pegtl/ascii_istring.cpp +++ b/packages/PEGTL/src/test/pegtl/ascii_istring.cpp @@ -1,46 +1,42 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< istring<> >( __LINE__, __FILE__, false, false ); - verify_analyze< istring< 1 > >( __LINE__, __FILE__, true, false ); - verify_analyze< istring< 1, 2 > >( __LINE__, __FILE__, true, false ); - verify_analyze< istring< 1, 2, 3, 4 > >( __LINE__, __FILE__, true, false ); - verify_analyze< istring< 1, 2, 3, 4, 5, 6, 7 > >( __LINE__, __FILE__, true, false ); + verify_analyze< istring<> >( __LINE__, __FILE__, false, false ); + verify_analyze< istring< 1 > >( __LINE__, __FILE__, true, false ); + verify_analyze< istring< 1, 2 > >( __LINE__, __FILE__, true, false ); + verify_analyze< istring< 1, 2, 3, 4 > >( __LINE__, __FILE__, true, false ); + verify_analyze< istring< 1, 2, 3, 4, 5, 6, 7 > >( __LINE__, __FILE__, true, false ); - verify_rule< istring<> >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "a", result_type::LOCAL_FAILURE, 1 ); - verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "b", result_type::LOCAL_FAILURE, 1 ); - verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "c", result_type::LOCAL_FAILURE, 1 ); - verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "aa", result_type::LOCAL_FAILURE, 2 ); - verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "aB", result_type::SUCCESS, 0 ); - verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "AB", result_type::SUCCESS, 0 ); - verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "Ab", result_type::SUCCESS, 0 ); - verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "ac", result_type::LOCAL_FAILURE, 2 ); - verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "ba", result_type::LOCAL_FAILURE, 2 ); - verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "bb", result_type::LOCAL_FAILURE, 2 ); - verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "aab", result_type::LOCAL_FAILURE, 3 ); - verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "aab", result_type::LOCAL_FAILURE, 3 ); - verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "ab", result_type::SUCCESS, 0 ); - verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "aba", result_type::SUCCESS, 1 ); - verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "Abb", result_type::SUCCESS, 1 ); - verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "abc", result_type::SUCCESS, 1 ); - verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "aBab", result_type::SUCCESS, 2 ); - verify_rule< istring< 'a', '0' > >( __LINE__, __FILE__, "a0A0", result_type::SUCCESS, 2 ); - } + verify_rule< istring<> >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "a", result_type::local_failure, 1 ); + verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "b", result_type::local_failure, 1 ); + verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "c", result_type::local_failure, 1 ); + verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "aa", result_type::local_failure, 2 ); + verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "aB", result_type::success, 0 ); + verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "AB", result_type::success, 0 ); + verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "Ab", result_type::success, 0 ); + verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "ac", result_type::local_failure, 2 ); + verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "ba", result_type::local_failure, 2 ); + verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "bb", result_type::local_failure, 2 ); + verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "aab", result_type::local_failure, 3 ); + verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "aab", result_type::local_failure, 3 ); + verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "ab", result_type::success, 0 ); + verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "aba", result_type::success, 1 ); + verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "Abb", result_type::success, 1 ); + verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "abc", result_type::success, 1 ); + verify_rule< istring< 'a', 'b' > >( __LINE__, __FILE__, "aBab", result_type::success, 2 ); + verify_rule< istring< 'a', '0' > >( __LINE__, __FILE__, "a0A0", result_type::success, 2 ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/ascii_keyword.cpp b/packages/PEGTL/src/test/pegtl/ascii_keyword.cpp index 55f17b61b..023e3e16d 100644 --- a/packages/PEGTL/src/test/pegtl/ascii_keyword.cpp +++ b/packages/PEGTL/src/test/pegtl/ascii_keyword.cpp @@ -1,33 +1,29 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, true, false ); + verify_analyze< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, true, false ); - verify_rule< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, "foo", result_type::SUCCESS, 0 ); - verify_rule< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, "foo ", result_type::SUCCESS, 1 ); - verify_rule< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, "foo foo", result_type::SUCCESS, 4 ); - verify_rule< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, "FOO", result_type::LOCAL_FAILURE, 3 ); - verify_rule< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, "f", result_type::LOCAL_FAILURE, 1 ); - verify_rule< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, "fo", result_type::LOCAL_FAILURE, 2 ); - verify_rule< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, " foo", result_type::LOCAL_FAILURE, 4 ); - verify_rule< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, "foo_", result_type::LOCAL_FAILURE, 4 ); - verify_rule< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, "foo1", result_type::LOCAL_FAILURE, 4 ); - verify_rule< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, "fooa", result_type::LOCAL_FAILURE, 4 ); - } + verify_rule< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, "foo", result_type::success, 0 ); + verify_rule< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, "foo ", result_type::success, 1 ); + verify_rule< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, "foo foo", result_type::success, 4 ); + verify_rule< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, "FOO", result_type::local_failure, 3 ); + verify_rule< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, "f", result_type::local_failure, 1 ); + verify_rule< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, "fo", result_type::local_failure, 2 ); + verify_rule< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, " foo", result_type::local_failure, 4 ); + verify_rule< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, "foo_", result_type::local_failure, 4 ); + verify_rule< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, "foo1", result_type::local_failure, 4 ); + verify_rule< keyword< 'f', 'o', 'o' > >( __LINE__, __FILE__, "fooa", result_type::local_failure, 4 ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/ascii_shebang.cpp b/packages/PEGTL/src/test/pegtl/ascii_shebang.cpp index e03e9b8e3..004852cf7 100644 --- a/packages/PEGTL/src/test/pegtl/ascii_shebang.cpp +++ b/packages/PEGTL/src/test/pegtl/ascii_shebang.cpp @@ -1,37 +1,33 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< shebang >( __LINE__, __FILE__, true, false ); + verify_analyze< shebang >( __LINE__, __FILE__, true, false ); - verify_rule< shebang >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< shebang >( __LINE__, __FILE__, "#", result_type::LOCAL_FAILURE, 1 ); - verify_rule< shebang >( __LINE__, __FILE__, "!", result_type::LOCAL_FAILURE, 1 ); - verify_rule< shebang >( __LINE__, __FILE__, "!#", result_type::LOCAL_FAILURE, 2 ); - verify_rule< shebang >( __LINE__, __FILE__, "# ", result_type::LOCAL_FAILURE, 3 ); - verify_rule< shebang >( __LINE__, __FILE__, "! ", result_type::LOCAL_FAILURE, 3 ); - verify_rule< shebang >( __LINE__, __FILE__, "## ", result_type::LOCAL_FAILURE, 3 ); - verify_rule< shebang >( __LINE__, __FILE__, "!! ", result_type::LOCAL_FAILURE, 3 ); - verify_rule< shebang >( __LINE__, __FILE__, "#!", result_type::SUCCESS, 0 ); - verify_rule< shebang >( __LINE__, __FILE__, "#! ", result_type::SUCCESS, 0 ); - verify_rule< shebang >( __LINE__, __FILE__, "#!/bin/bash", result_type::SUCCESS, 0 ); - verify_rule< shebang >( __LINE__, __FILE__, "#!/bin/bash\n", result_type::SUCCESS, 0 ); - verify_rule< shebang >( __LINE__, __FILE__, "#!/bin/bash\n#!/b", result_type::SUCCESS, 4 ); - verify_rule< shebang >( __LINE__, __FILE__, "#!\n", result_type::SUCCESS, 0 ); - verify_rule< shebang >( __LINE__, __FILE__, "#!\n ", result_type::SUCCESS, 1 ); - } + verify_rule< shebang >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< shebang >( __LINE__, __FILE__, "#", result_type::local_failure, 1 ); + verify_rule< shebang >( __LINE__, __FILE__, "!", result_type::local_failure, 1 ); + verify_rule< shebang >( __LINE__, __FILE__, "!#", result_type::local_failure, 2 ); + verify_rule< shebang >( __LINE__, __FILE__, "# ", result_type::local_failure, 3 ); + verify_rule< shebang >( __LINE__, __FILE__, "! ", result_type::local_failure, 3 ); + verify_rule< shebang >( __LINE__, __FILE__, "## ", result_type::local_failure, 3 ); + verify_rule< shebang >( __LINE__, __FILE__, "!! ", result_type::local_failure, 3 ); + verify_rule< shebang >( __LINE__, __FILE__, "#!", result_type::success, 0 ); + verify_rule< shebang >( __LINE__, __FILE__, "#! ", result_type::success, 0 ); + verify_rule< shebang >( __LINE__, __FILE__, "#!/bin/bash", result_type::success, 0 ); + verify_rule< shebang >( __LINE__, __FILE__, "#!/bin/bash\n", result_type::success, 0 ); + verify_rule< shebang >( __LINE__, __FILE__, "#!/bin/bash\n#!/b", result_type::success, 4 ); + verify_rule< shebang >( __LINE__, __FILE__, "#!\n", result_type::success, 0 ); + verify_rule< shebang >( __LINE__, __FILE__, "#!\n ", result_type::success, 1 ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/ascii_string.cpp b/packages/PEGTL/src/test/pegtl/ascii_string.cpp index 89796aaab..a35950391 100644 --- a/packages/PEGTL/src/test/pegtl/ascii_string.cpp +++ b/packages/PEGTL/src/test/pegtl/ascii_string.cpp @@ -1,45 +1,41 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< string<> >( __LINE__, __FILE__, false, false ); - verify_analyze< string< 1 > >( __LINE__, __FILE__, true, false ); - verify_analyze< string< 1, 2 > >( __LINE__, __FILE__, true, false ); - verify_analyze< string< 1, 2, 3, 4 > >( __LINE__, __FILE__, true, false ); - verify_analyze< string< 1, 2, 3, 4, 5, 6, 7 > >( __LINE__, __FILE__, true, false ); + verify_analyze< string<> >( __LINE__, __FILE__, false, false ); + verify_analyze< string< 1 > >( __LINE__, __FILE__, true, false ); + verify_analyze< string< 1, 2 > >( __LINE__, __FILE__, true, false ); + verify_analyze< string< 1, 2, 3, 4 > >( __LINE__, __FILE__, true, false ); + verify_analyze< string< 1, 2, 3, 4, 5, 6, 7 > >( __LINE__, __FILE__, true, false ); - verify_rule< string<> >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "a", result_type::LOCAL_FAILURE, 1 ); - verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "b", result_type::LOCAL_FAILURE, 1 ); - verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "c", result_type::LOCAL_FAILURE, 1 ); - verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "aa", result_type::LOCAL_FAILURE, 2 ); - verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "aB", result_type::LOCAL_FAILURE, 2 ); - verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "AB", result_type::LOCAL_FAILURE, 2 ); - verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "Ab", result_type::LOCAL_FAILURE, 2 ); - verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "ac", result_type::LOCAL_FAILURE, 2 ); - verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "ba", result_type::LOCAL_FAILURE, 2 ); - verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "bb", result_type::LOCAL_FAILURE, 2 ); - verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "aab", result_type::LOCAL_FAILURE, 3 ); - verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "aab", result_type::LOCAL_FAILURE, 3 ); - verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "ab", result_type::SUCCESS, 0 ); - verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "aba", result_type::SUCCESS, 1 ); - verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "abb", result_type::SUCCESS, 1 ); - verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "abc", result_type::SUCCESS, 1 ); - verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "abab", result_type::SUCCESS, 2 ); - } + verify_rule< string<> >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "a", result_type::local_failure, 1 ); + verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "b", result_type::local_failure, 1 ); + verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "c", result_type::local_failure, 1 ); + verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "aa", result_type::local_failure, 2 ); + verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "aB", result_type::local_failure, 2 ); + verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "AB", result_type::local_failure, 2 ); + verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "Ab", result_type::local_failure, 2 ); + verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "ac", result_type::local_failure, 2 ); + verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "ba", result_type::local_failure, 2 ); + verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "bb", result_type::local_failure, 2 ); + verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "aab", result_type::local_failure, 3 ); + verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "aab", result_type::local_failure, 3 ); + verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "ab", result_type::success, 0 ); + verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "aba", result_type::success, 1 ); + verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "abb", result_type::success, 1 ); + verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "abc", result_type::success, 1 ); + verify_rule< string< 'a', 'b' > >( __LINE__, __FILE__, "abab", result_type::success, 2 ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/ascii_three.cpp b/packages/PEGTL/src/test/pegtl/ascii_three.cpp index a71d3598b..7ee53f663 100644 --- a/packages/PEGTL/src/test/pegtl/ascii_three.cpp +++ b/packages/PEGTL/src/test/pegtl/ascii_three.cpp @@ -1,31 +1,27 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< three< 'a' > >( __LINE__, __FILE__, true, false ); + verify_analyze< three< 'a' > >( __LINE__, __FILE__, true, false ); - verify_rule< three< 'a' > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< three< 'a' > >( __LINE__, __FILE__, "a", result_type::LOCAL_FAILURE ); - verify_rule< three< 'a' > >( __LINE__, __FILE__, "aa", result_type::LOCAL_FAILURE ); - verify_rule< three< 'a' > >( __LINE__, __FILE__, "ab", result_type::LOCAL_FAILURE ); - verify_rule< three< 'a' > >( __LINE__, __FILE__, "aab", result_type::LOCAL_FAILURE ); - verify_rule< three< 'a' > >( __LINE__, __FILE__, "aaa", result_type::SUCCESS ); - verify_rule< three< 'a' > >( __LINE__, __FILE__, "aaaa", result_type::SUCCESS, 1 ); - verify_rule< three< 'a' > >( __LINE__, __FILE__, "aaaaa", result_type::SUCCESS, 2 ); - verify_rule< three< 'a' > >( __LINE__, __FILE__, "aaaaaa", result_type::SUCCESS, 3 ); - } + verify_rule< three< 'a' > >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< three< 'a' > >( __LINE__, __FILE__, "a", result_type::local_failure ); + verify_rule< three< 'a' > >( __LINE__, __FILE__, "aa", result_type::local_failure ); + verify_rule< three< 'a' > >( __LINE__, __FILE__, "ab", result_type::local_failure ); + verify_rule< three< 'a' > >( __LINE__, __FILE__, "aab", result_type::local_failure ); + verify_rule< three< 'a' > >( __LINE__, __FILE__, "aaa", result_type::success ); + verify_rule< three< 'a' > >( __LINE__, __FILE__, "aaaa", result_type::success, 1 ); + verify_rule< three< 'a' > >( __LINE__, __FILE__, "aaaaa", result_type::success, 2 ); + verify_rule< three< 'a' > >( __LINE__, __FILE__, "aaaaaa", result_type::success, 3 ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/ascii_two.cpp b/packages/PEGTL/src/test/pegtl/ascii_two.cpp index f547ca044..5bd48d650 100644 --- a/packages/PEGTL/src/test/pegtl/ascii_two.cpp +++ b/packages/PEGTL/src/test/pegtl/ascii_two.cpp @@ -1,28 +1,24 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< two< 'a' > >( __LINE__, __FILE__, true, false ); + verify_analyze< two< 'a' > >( __LINE__, __FILE__, true, false ); - verify_rule< two< 'a' > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< two< 'a' > >( __LINE__, __FILE__, "a", result_type::LOCAL_FAILURE ); - verify_rule< two< 'a' > >( __LINE__, __FILE__, "ab", result_type::LOCAL_FAILURE ); - verify_rule< two< 'a' > >( __LINE__, __FILE__, "aa", result_type::SUCCESS ); - verify_rule< two< 'a' > >( __LINE__, __FILE__, "aaa", result_type::SUCCESS, 1 ); - verify_rule< two< 'a' > >( __LINE__, __FILE__, "aaaa", result_type::SUCCESS, 2 ); - } + verify_rule< two< 'a' > >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< two< 'a' > >( __LINE__, __FILE__, "a", result_type::local_failure ); + verify_rule< two< 'a' > >( __LINE__, __FILE__, "ab", result_type::local_failure ); + verify_rule< two< 'a' > >( __LINE__, __FILE__, "aa", result_type::success ); + verify_rule< two< 'a' > >( __LINE__, __FILE__, "aaa", result_type::success, 1 ); + verify_rule< two< 'a' > >( __LINE__, __FILE__, "aaaa", result_type::success, 2 ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/buffer_input.cpp b/packages/PEGTL/src/test/pegtl/buffer_input.cpp new file mode 100644 index 000000000..752aa7251 --- /dev/null +++ b/packages/PEGTL/src/test/pegtl/buffer_input.cpp @@ -0,0 +1,41 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#include <string> + +#include "test.hpp" + +#include <tao/pegtl/internal/cstring_reader.hpp> + +namespace TAO_PEGTL_NAMESPACE +{ + template< typename Rule, template< typename... > class Action = nothing > + bool parse_cstring( const char* string, const char* source, const std::size_t maximum ) + { + buffer_input< internal::cstring_reader > in( source, maximum, string ); + return parse< Rule, Action >( in ); + } + + void unit_test() + { + static constexpr std::size_t chunk_size = buffer_input< internal::cstring_reader >::chunk_size; + + static_assert( chunk_size >= 2 ); + TAO_PEGTL_TEST_ASSERT( parse_cstring< seq< string< 'a', 'b', 'c' >, eof > >( "abc", TAO_TEST_LINE, 1 ) ); + TAO_PEGTL_TEST_ASSERT( parse_cstring< seq< string< 'a', 'b', 'c' >, eof > >( "abc", TAO_TEST_LINE, 128 ) ); + + // We need one extra byte in the buffer so that eof calling in.empty() calling in.require( 1 ) does not throw a "require beyond end of buffer" exception. + TAO_PEGTL_TEST_THROWS( parse_cstring< seq< rep< chunk_size + 2, one< 'a' > >, eof > >( std::string( std::size_t( chunk_size + 2 ), 'a' ).c_str(), TAO_TEST_LINE, 2 ) ); + TAO_PEGTL_TEST_ASSERT( parse_cstring< seq< rep< chunk_size + 2, one< 'a' > >, eof > >( std::string( std::size_t( chunk_size + 2 ), 'a' ).c_str(), TAO_TEST_LINE, 3 ) ); + + TAO_PEGTL_TEST_ASSERT( parse_cstring< rep< chunk_size + 9, one< 'a' > > >( std::string( std::size_t( chunk_size + 9 ), 'a' ).c_str(), TAO_TEST_LINE, 9 ) ); + TAO_PEGTL_TEST_ASSERT( parse_cstring< rep< chunk_size + 9, one< 'a' > > >( std::string( std::size_t( chunk_size + 10 ), 'a' ).c_str(), TAO_TEST_LINE, 9 ) ); + TAO_PEGTL_TEST_THROWS( parse_cstring< rep< chunk_size + 10, one< 'a' > > >( std::string( std::size_t( chunk_size + 10 ), 'a' ).c_str(), TAO_TEST_LINE, 9 ) ); + TAO_PEGTL_TEST_THROWS( parse_cstring< rep< chunk_size + 10, one< 'a' > > >( std::string( std::size_t( chunk_size + 11 ), 'a' ).c_str(), TAO_TEST_LINE, 9 ) ); + TAO_PEGTL_TEST_THROWS( parse_cstring< seq< rep< chunk_size + 10, one< 'a' > >, eof > >( std::string( std::size_t( chunk_size + 10 ), 'a' ).c_str(), TAO_TEST_LINE, 9 ) ); + TAO_PEGTL_TEST_THROWS( parse_cstring< seq< rep< chunk_size + 10, one< 'a' > >, eof > >( std::string( std::size_t( chunk_size + 10 ), 'a' ).c_str(), TAO_TEST_LINE, 10 ) ); + } + +} // namespace TAO_PEGTL_NAMESPACE + +#include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/change_action_and_state.cpp b/packages/PEGTL/src/test/pegtl/change_action_and_state.cpp new file mode 100644 index 000000000..52cbaf735 --- /dev/null +++ b/packages/PEGTL/src/test/pegtl/change_action_and_state.cpp @@ -0,0 +1,122 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#include "test.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + // clang-format off + struct A : one< 'a' > {}; + struct B : one< 'b' > {}; + struct AB : seq< A, B > {}; + // clang-format on + + template< typename > + struct my_action_1 + {}; + + template< typename > + struct my_action_2 + {}; + + template<> + struct my_action_1< A > + { + static void apply0( int& c ) + { + if( c != 0 ) { + throw std::runtime_error( "fail1" ); + } + c = 1; + } + }; + + struct S + { + int v = 0; + + template< typename Input > + explicit S( const Input& /*unused*/, int& c ) + { + if( c == 5 ) { + v = 6; + } + else { + if( c != 1 ) { + throw std::runtime_error( "fail2" ); + } + v = 2; + } + } + + template< typename Input > + void success( const Input& /*unused*/, int& c ) + { + if( v != 3 ) { + throw std::runtime_error( "fail3" ); + } + c = 4; + } + }; + + template<> + struct my_action_1< B > + : change_action_and_state< my_action_2, S > + {}; + + template<> + struct my_action_2< A > + { + static void apply0( S& /*s*/ ) + { + throw std::runtime_error( "fail4" ); + } + }; + + template<> + struct my_action_2< B > + { + static void apply0( S& s ) + { + if( s.v != 2 ) { + throw std::runtime_error( "fail5" ); + } + s.v = 3; + } + }; + + void unit_test() + { + { + memory_input in( "ab", "" ); + int c = 0; + const auto result = parse< AB, my_action_1 >( in, c ); + TAO_PEGTL_TEST_ASSERT( result ); + TAO_PEGTL_TEST_ASSERT( c == 4 ); + } + { + memory_input in( "a", "" ); + int c = 0; + const auto result = parse< AB, my_action_1 >( in, c ); + TAO_PEGTL_TEST_ASSERT( !result ); + TAO_PEGTL_TEST_ASSERT( c == 1 ); + } + { + memory_input in( "b", "" ); + int c = 0; + const auto result = parse< AB, my_action_1 >( in, c ); + TAO_PEGTL_TEST_ASSERT( !result ); + TAO_PEGTL_TEST_ASSERT( c == 0 ); + } + { + memory_input in( "ab", "" ); + int c = 5; + const auto result = parse< disable< AB >, my_action_1 >( in, c ); + TAO_PEGTL_TEST_ASSERT( result ); + TAO_PEGTL_TEST_ASSERT( c == 5 ); + } + } + +} // namespace TAO_PEGTL_NAMESPACE + +#include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/change_action_and_states.cpp b/packages/PEGTL/src/test/pegtl/change_action_and_states.cpp new file mode 100644 index 000000000..38b889f2c --- /dev/null +++ b/packages/PEGTL/src/test/pegtl/change_action_and_states.cpp @@ -0,0 +1,112 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#include "test.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + // clang-format off + struct A : one< 'a' > {}; + struct B : one< 'b' > {}; + struct AB : seq< A, B > {}; + // clang-format on + + template< typename > + struct my_action_1 + {}; + + template< typename > + struct my_action_2 + {}; + + template<> + struct my_action_1< A > + { + static void apply0( int& c ) + { + if( c != 0 ) { + throw std::runtime_error( "fail1" ); + } + c = 1; + } + }; + + template<> + struct my_action_1< B > + : change_action_and_states< my_action_2, int > + { + // not called because my_action_2 is active + static void apply0( int& /*v*/ ) + { + throw std::runtime_error( "fail2" ); + } + + template< typename Input > + static void success( const Input& /*unused*/, int& v, int& c ) + { + if( v != 2 ) { + throw std::runtime_error( "fail3" ); + } + if( c != 1 ) { + throw std::runtime_error( "fail4" ); + } + c = 3; + } + }; + + template<> + struct my_action_2< A > + { + static void apply0( int& /*c*/ ) + { + throw std::runtime_error( "fail5" ); + } + }; + + template<> + struct my_action_2< B > + { + static void apply0( int& v ) + { + if( v != 0 ) { + throw std::runtime_error( "fail6" ); + } + v = 2; + } + }; + + void unit_test() + { + { + memory_input in( "ab", "" ); + int c = 0; + const auto result = parse< AB, my_action_1 >( in, c ); + TAO_PEGTL_TEST_ASSERT( result ); + TAO_PEGTL_TEST_ASSERT( c == 3 ); + } + { + memory_input in( "a", "" ); + int c = 0; + const auto result = parse< AB, my_action_1 >( in, c ); + TAO_PEGTL_TEST_ASSERT( !result ); + TAO_PEGTL_TEST_ASSERT( c == 1 ); + } + { + memory_input in( "b", "" ); + int c = 0; + const auto result = parse< AB, my_action_1 >( in, c ); + TAO_PEGTL_TEST_ASSERT( !result ); + TAO_PEGTL_TEST_ASSERT( c == 0 ); + } + { + memory_input in( "ab", "" ); + int c = 5; + const auto result = parse< disable< AB >, my_action_1 >( in, c ); + TAO_PEGTL_TEST_ASSERT( result ); + TAO_PEGTL_TEST_ASSERT( c == 5 ); + } + } + +} // namespace TAO_PEGTL_NAMESPACE + +#include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/change_state.cpp b/packages/PEGTL/src/test/pegtl/change_state.cpp new file mode 100644 index 000000000..32e3da708 --- /dev/null +++ b/packages/PEGTL/src/test/pegtl/change_state.cpp @@ -0,0 +1,105 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#include "test.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + // clang-format off + struct A : one< 'a' > {}; + struct B : one< 'b' > {}; + struct AB : seq< A, B > {}; + // clang-format on + + template< typename > + struct my_action + {}; + + template<> + struct my_action< A > + { + static void apply0( int& c ) + { + if( c != 0 ) { + throw std::runtime_error( "fail1" ); + } + c = 1; + } + }; + + struct S + { + int v = 0; + + template< typename Input > + explicit S( const Input& /*unused*/, int& c ) + { + if( c == 5 ) { + v = 6; + } + else { + if( c != 1 ) { + throw std::runtime_error( "fail2" ); + } + v = 2; + } + } + + template< typename Input > + void success( const Input& /*unused*/, int& c ) + { + if( v != 3 ) { + throw std::runtime_error( "fail3" ); + } + c = 4; + } + }; + + template<> + struct my_action< B > + : change_state< S > + { + static void apply0( S& s ) + { + if( s.v != 2 ) { + throw std::runtime_error( "fail4" ); + } + s.v = 3; + } + }; + + void unit_test() + { + { + memory_input in( "ab", "" ); + int c = 0; + const auto result = parse< AB, my_action >( in, c ); + TAO_PEGTL_TEST_ASSERT( result ); + TAO_PEGTL_TEST_ASSERT( c == 4 ); + } + { + memory_input in( "a", "" ); + int c = 0; + const auto result = parse< AB, my_action >( in, c ); + TAO_PEGTL_TEST_ASSERT( !result ); + TAO_PEGTL_TEST_ASSERT( c == 1 ); + } + { + memory_input in( "b", "" ); + int c = 0; + const auto result = parse< AB, my_action >( in, c ); + TAO_PEGTL_TEST_ASSERT( !result ); + TAO_PEGTL_TEST_ASSERT( c == 0 ); + } + { + memory_input in( "ab", "" ); + int c = 5; + const auto result = parse< disable< AB >, my_action >( in, c ); + TAO_PEGTL_TEST_ASSERT( result ); + TAO_PEGTL_TEST_ASSERT( c == 5 ); + } + } + +} // namespace TAO_PEGTL_NAMESPACE + +#include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/change_states.cpp b/packages/PEGTL/src/test/pegtl/change_states.cpp new file mode 100644 index 000000000..0cdeb2d9a --- /dev/null +++ b/packages/PEGTL/src/test/pegtl/change_states.cpp @@ -0,0 +1,89 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#include "test.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + // clang-format off + struct A : one< 'a' > {}; + struct B : one< 'b' > {}; + struct AB : seq< A, B > {}; + // clang-format on + + template< typename > + struct my_action + {}; + + template<> + struct my_action< A > + { + static void apply0( int& c ) + { + if( c != 0 ) { + throw std::runtime_error( "fail1" ); + } + c = 1; + } + }; + + template<> + struct my_action< B > + : change_states< int > + { + static void apply0( int& v ) + { + if( v != 0 ) { + throw std::runtime_error( "fail2" ); + } + v = 2; + } + + template< typename Input > + static void success( const Input& /*unused*/, int& v, int& c ) + { + if( v != 2 ) { + throw std::runtime_error( "fail3" ); + } + if( c != 1 ) { + throw std::runtime_error( "fail4" ); + } + c = 3; + } + }; + + void unit_test() + { + { + memory_input in( "ab", "" ); + int c = 0; + const auto result = parse< AB, my_action >( in, c ); + TAO_PEGTL_TEST_ASSERT( result ); + TAO_PEGTL_TEST_ASSERT( c == 3 ); + } + { + memory_input in( "a", "" ); + int c = 0; + const auto result = parse< AB, my_action >( in, c ); + TAO_PEGTL_TEST_ASSERT( !result ); + TAO_PEGTL_TEST_ASSERT( c == 1 ); + } + { + memory_input in( "b", "" ); + int c = 0; + const auto result = parse< AB, my_action >( in, c ); + TAO_PEGTL_TEST_ASSERT( !result ); + TAO_PEGTL_TEST_ASSERT( c == 0 ); + } + { + memory_input in( "ab", "" ); + int c = 5; + const auto result = parse< disable< AB >, my_action >( in, c ); + TAO_PEGTL_TEST_ASSERT( result ); + TAO_PEGTL_TEST_ASSERT( c == 5 ); + } + } + +} // namespace TAO_PEGTL_NAMESPACE + +#include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/contrib_alphabet.cpp b/packages/PEGTL/src/test/pegtl/contrib_alphabet.cpp index 1d12656af..4d0e8c35a 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_alphabet.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_alphabet.cpp @@ -1,73 +1,69 @@ -// Copyright (c) 2015-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include <tao/pegtl/contrib/alphabet.hpp> -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - static_assert( alphabet::a == 'a', "a" ); - static_assert( alphabet::b == 'b', "b" ); - static_assert( alphabet::c == 'c', "c" ); - static_assert( alphabet::d == 'd', "d" ); - static_assert( alphabet::e == 'e', "e" ); - static_assert( alphabet::f == 'f', "f" ); - static_assert( alphabet::g == 'g', "g" ); - static_assert( alphabet::h == 'h', "h" ); - static_assert( alphabet::i == 'i', "i" ); - static_assert( alphabet::j == 'j', "j" ); - static_assert( alphabet::k == 'k', "k" ); - static_assert( alphabet::l == 'l', "l" ); - static_assert( alphabet::m == 'm', "m" ); - static_assert( alphabet::n == 'n', "n" ); - static_assert( alphabet::o == 'o', "o" ); - static_assert( alphabet::p == 'p', "p" ); - static_assert( alphabet::q == 'q', "q" ); - static_assert( alphabet::r == 'r', "r" ); - static_assert( alphabet::s == 's', "s" ); - static_assert( alphabet::t == 't', "t" ); - static_assert( alphabet::u == 'u', "u" ); - static_assert( alphabet::v == 'v', "v" ); - static_assert( alphabet::w == 'w', "w" ); - static_assert( alphabet::x == 'x', "x" ); - static_assert( alphabet::y == 'y', "y" ); - static_assert( alphabet::z == 'z', "z" ); + static_assert( alphabet::a == 'a' ); + static_assert( alphabet::b == 'b' ); + static_assert( alphabet::c == 'c' ); + static_assert( alphabet::d == 'd' ); + static_assert( alphabet::e == 'e' ); + static_assert( alphabet::f == 'f' ); + static_assert( alphabet::g == 'g' ); + static_assert( alphabet::h == 'h' ); + static_assert( alphabet::i == 'i' ); + static_assert( alphabet::j == 'j' ); + static_assert( alphabet::k == 'k' ); + static_assert( alphabet::l == 'l' ); + static_assert( alphabet::m == 'm' ); + static_assert( alphabet::n == 'n' ); + static_assert( alphabet::o == 'o' ); + static_assert( alphabet::p == 'p' ); + static_assert( alphabet::q == 'q' ); + static_assert( alphabet::r == 'r' ); + static_assert( alphabet::s == 's' ); + static_assert( alphabet::t == 't' ); + static_assert( alphabet::u == 'u' ); + static_assert( alphabet::v == 'v' ); + static_assert( alphabet::w == 'w' ); + static_assert( alphabet::x == 'x' ); + static_assert( alphabet::y == 'y' ); + static_assert( alphabet::z == 'z' ); - static_assert( alphabet::A == 'A', "A" ); - static_assert( alphabet::B == 'B', "B" ); - static_assert( alphabet::C == 'C', "C" ); - static_assert( alphabet::D == 'D', "D" ); - static_assert( alphabet::E == 'E', "E" ); - static_assert( alphabet::F == 'F', "F" ); - static_assert( alphabet::G == 'G', "G" ); - static_assert( alphabet::H == 'H', "H" ); - static_assert( alphabet::I == 'I', "I" ); - static_assert( alphabet::J == 'J', "J" ); - static_assert( alphabet::K == 'K', "K" ); - static_assert( alphabet::L == 'L', "L" ); - static_assert( alphabet::M == 'M', "M" ); - static_assert( alphabet::N == 'N', "N" ); - static_assert( alphabet::O == 'O', "O" ); - static_assert( alphabet::P == 'P', "P" ); - static_assert( alphabet::Q == 'Q', "Q" ); - static_assert( alphabet::R == 'R', "R" ); - static_assert( alphabet::S == 'S', "S" ); - static_assert( alphabet::T == 'T', "T" ); - static_assert( alphabet::U == 'U', "U" ); - static_assert( alphabet::V == 'V', "V" ); - static_assert( alphabet::W == 'W', "W" ); - static_assert( alphabet::X == 'X', "X" ); - static_assert( alphabet::Y == 'Y', "Y" ); - static_assert( alphabet::Z == 'Z', "Z" ); - } + static_assert( alphabet::A == 'A' ); + static_assert( alphabet::B == 'B' ); + static_assert( alphabet::C == 'C' ); + static_assert( alphabet::D == 'D' ); + static_assert( alphabet::E == 'E' ); + static_assert( alphabet::F == 'F' ); + static_assert( alphabet::G == 'G' ); + static_assert( alphabet::H == 'H' ); + static_assert( alphabet::I == 'I' ); + static_assert( alphabet::J == 'J' ); + static_assert( alphabet::K == 'K' ); + static_assert( alphabet::L == 'L' ); + static_assert( alphabet::M == 'M' ); + static_assert( alphabet::N == 'N' ); + static_assert( alphabet::O == 'O' ); + static_assert( alphabet::P == 'P' ); + static_assert( alphabet::Q == 'Q' ); + static_assert( alphabet::R == 'R' ); + static_assert( alphabet::S == 'S' ); + static_assert( alphabet::T == 'T' ); + static_assert( alphabet::U == 'U' ); + static_assert( alphabet::V == 'V' ); + static_assert( alphabet::W == 'W' ); + static_assert( alphabet::X == 'X' ); + static_assert( alphabet::Y == 'Y' ); + static_assert( alphabet::Z == 'Z' ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/contrib_if_then.cpp b/packages/PEGTL/src/test/pegtl/contrib_if_then.cpp index 8af618797..36199ecf4 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 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" @@ -6,26 +6,23 @@ #include <tao/pegtl/contrib/if_then.hpp> -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - // clang-format off - using grammar = - if_then< one< 'a' >, one< 'b' >, one< 'c' > >:: - else_if_then< one< 'a' >, one< 'b' > >:: - else_then< one< 'c' > >; + // clang-format off + using grammar = + if_then< one< 'a' >, one< 'b' >, one< 'c' > >:: + else_if_then< one< 'a' >, one< 'b' > >:: + else_then< one< 'c' > >; - verify_rule< grammar >( __LINE__, __FILE__, "abc", result_type::SUCCESS, 0 ); - verify_rule< grammar >( __LINE__, __FILE__, "abcd", result_type::SUCCESS, 1 ); - verify_rule< grammar >( __LINE__, __FILE__, "ab", result_type::LOCAL_FAILURE, 2 ); - verify_rule< grammar >( __LINE__, __FILE__, "c", result_type::SUCCESS, 0 ); - } + verify_rule< grammar >( __LINE__, __FILE__, "abc", result_type::success, 0 ); + verify_rule< grammar >( __LINE__, __FILE__, "abcd", result_type::success, 1 ); + verify_rule< grammar >( __LINE__, __FILE__, "ab", result_type::local_failure, 2 ); + verify_rule< grammar >( __LINE__, __FILE__, "c", result_type::success, 0 ); + // clang-format on + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/contrib_integer.cpp b/packages/PEGTL/src/test/pegtl/contrib_integer.cpp index ba5104f59..a6f3d9a52 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 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <limits> @@ -8,143 +8,135 @@ #include <tao/pegtl/contrib/integer.hpp> -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + template< typename I > + struct int_state { - template< typename I > - struct int_state - { - I converted = 55; - }; - - template< typename Rule > - struct int_action - : nothing< Rule > - { - }; - - template<> - struct int_action< integer::signed_rule > - : integer::signed_action - { - }; - - template<> - struct int_action< integer::unsigned_rule > - : integer::unsigned_action - { - }; - - template< typename S > - void test_signed( const std::string& i, const S s ) - { - int_state< S > st; - memory_input<> in( i, __FUNCTION__ ); - parse< must< integer::signed_rule, eof >, int_action >( in, st ); - TAO_PEGTL_TEST_ASSERT( st.converted == s ); - } - - template< typename S > - void test_signed( const std::string& i ) - { - int_state< S > st; - memory_input<> in( i, __FUNCTION__ ); - TAO_PEGTL_TEST_THROWS( parse< must< integer::signed_rule, eof >, int_action >( in, st ) ); - } - - template< typename S > - std::string lexical_cast( const S s ) - { - std::ostringstream o; - o << s; - return o.str(); - } - - template< typename S > - void test_signed( const S s ) - { - int_state< S > st; - const auto i = lexical_cast( s ); - memory_input<> in( i, __FUNCTION__ ); - parse< must< integer::signed_rule, eof >, int_action >( in, st ); - TAO_PEGTL_TEST_ASSERT( st.converted == s ); - } - - template< typename S > - void test_unsigned( const std::string& i, const S s ) - { - int_state< S > st; - memory_input<> in( i, __FUNCTION__ ); - parse< must< integer::unsigned_rule, eof >, int_action >( in, st ); - TAO_PEGTL_TEST_ASSERT( st.converted == s ); - } - - template< typename S > - void test_unsigned( const std::string& i ) - { - int_state< S > st; - memory_input<> in( i, __FUNCTION__ ); - TAO_PEGTL_TEST_THROWS( parse< must< integer::unsigned_rule, eof >, int_action >( in, st ) ); - } - - template< typename S > - void test_unsigned( const S s ) - { - int_state< S > st; - const auto i = lexical_cast( s ); - memory_input<> in( i, __FUNCTION__ ); - parse< must< integer::unsigned_rule, eof >, int_action >( in, st ); - TAO_PEGTL_TEST_ASSERT( st.converted == s ); - } - - void unit_test() - { - test_signed< signed char >( "--0" ); - test_signed< signed char >( "++0" ); - test_signed< signed char >( "-+0" ); - - test_signed< signed char >( "0", 0 ); - test_signed< signed char >( "+0", 0 ); - test_signed< signed char >( "-0", 0 ); - test_signed< signed char >( "000", 0 ); - test_signed< signed char >( "+000", 0 ); - test_signed< signed char >( "-000", 0 ); - - test_signed< signed char >( "127", 127 ); - - test_signed< signed char >( "-1", -1 ); - test_signed< signed char >( "-001", -1 ); - - test_signed< signed char >( "-127", -127 ); - test_signed< signed char >( "-128", -128 ); - - test_signed< signed char >( "128" ); - test_signed< signed char >( "-129" ); - test_signed< signed char >( "00128" ); - test_signed< signed char >( "-00129" ); - - test_unsigned< unsigned char >( "-0" ); - test_unsigned< unsigned char >( "+1" ); - - test_unsigned< unsigned char >( "0", 0 ); - test_unsigned< unsigned char >( "000", 0 ); - test_unsigned< unsigned char >( "0", 0 ); - test_unsigned< unsigned char >( "255", 255 ); - test_unsigned< unsigned char >( "000255", 255 ); - test_unsigned< unsigned char >( "256" ); - test_unsigned< unsigned char >( "000256" ); - - test_signed< signed long long >( "0", 0 ); - test_signed< signed long long >( std::numeric_limits< signed long long >::max() ); - test_signed< signed long long >( std::numeric_limits< signed long long >::min() ); - - test_unsigned< unsigned long long >( "0", 0 ); - test_unsigned< unsigned long long >( std::numeric_limits< unsigned long long >::max() ); - } - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + I converted = 55; + }; + + template< typename Rule > + struct int_action + {}; + + template<> + struct int_action< integer::signed_rule > + : integer::signed_action + {}; + + template<> + struct int_action< integer::unsigned_rule > + : integer::unsigned_action + {}; + + template< typename S > + void test_signed( const std::string& i, const S s ) + { + int_state< S > st; + memory_input in( i, __FUNCTION__ ); + parse< must< integer::signed_rule, eof >, int_action >( in, st ); + TAO_PEGTL_TEST_ASSERT( st.converted == s ); + } + + template< typename S > + void test_signed( const std::string& i ) + { + int_state< S > st; + memory_input in( i, __FUNCTION__ ); + TAO_PEGTL_TEST_THROWS( parse< must< integer::signed_rule, eof >, int_action >( in, st ) ); + } + + template< typename S > + std::string lexical_cast( const S s ) + { + std::ostringstream o; + o << s; + return o.str(); + } + + template< typename S > + void test_signed( const S s ) + { + int_state< S > st; + const auto i = lexical_cast( s ); + memory_input in( i, __FUNCTION__ ); + parse< must< integer::signed_rule, eof >, int_action >( in, st ); + TAO_PEGTL_TEST_ASSERT( st.converted == s ); + } + + template< typename S > + void test_unsigned( const std::string& i, const S s ) + { + int_state< S > st; + memory_input in( i, __FUNCTION__ ); + parse< must< integer::unsigned_rule, eof >, int_action >( in, st ); + TAO_PEGTL_TEST_ASSERT( st.converted == s ); + } + + template< typename S > + void test_unsigned( const std::string& i ) + { + int_state< S > st; + memory_input in( i, __FUNCTION__ ); + TAO_PEGTL_TEST_THROWS( parse< must< integer::unsigned_rule, eof >, int_action >( in, st ) ); + } + + template< typename S > + void test_unsigned( const S s ) + { + int_state< S > st; + const auto i = lexical_cast( s ); + memory_input in( i, __FUNCTION__ ); + parse< must< integer::unsigned_rule, eof >, int_action >( in, st ); + TAO_PEGTL_TEST_ASSERT( st.converted == s ); + } + + void unit_test() + { + test_signed< signed char >( "--0" ); + test_signed< signed char >( "++0" ); + test_signed< signed char >( "-+0" ); + + test_signed< signed char >( "0", 0 ); + test_signed< signed char >( "+0", 0 ); + test_signed< signed char >( "-0", 0 ); + test_signed< signed char >( "000", 0 ); + test_signed< signed char >( "+000", 0 ); + test_signed< signed char >( "-000", 0 ); + + test_signed< signed char >( "127", 127 ); + + test_signed< signed char >( "-1", -1 ); + test_signed< signed char >( "-001", -1 ); + + test_signed< signed char >( "-127", -127 ); + test_signed< signed char >( "-128", -128 ); + + test_signed< signed char >( "128" ); + test_signed< signed char >( "-129" ); + test_signed< signed char >( "00128" ); + test_signed< signed char >( "-00129" ); + + test_unsigned< unsigned char >( "-0" ); + test_unsigned< unsigned char >( "+1" ); + + test_unsigned< unsigned char >( "0", 0 ); + test_unsigned< unsigned char >( "000", 0 ); + test_unsigned< unsigned char >( "0", 0 ); + test_unsigned< unsigned char >( "255", 255 ); + test_unsigned< unsigned char >( "000255", 255 ); + test_unsigned< unsigned char >( "256" ); + test_unsigned< unsigned char >( "000256" ); + + test_signed< signed long long >( "0", 0 ); + test_signed< signed long long >( ( std::numeric_limits< signed long long >::max )() ); + test_signed< signed long long >( ( std::numeric_limits< signed long long >::min )() ); + + test_unsigned< unsigned long long >( "0", 0 ); + test_unsigned< unsigned long long >( ( std::numeric_limits< unsigned long long >::max )() ); + } + +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/contrib_json.cpp b/packages/PEGTL/src/test/pegtl/contrib_json.cpp index 5688748f4..d438385ae 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" @@ -9,133 +9,129 @@ #include <tao/pegtl/analyze.hpp> #include <tao/pegtl/contrib/json.hpp> -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + template< typename Rule > + void verify_file_fail( const std::size_t line, const char* file, const std::string& s ) { - template< typename Rule > - void verify_file_fail( const std::size_t line, const char* file, const std::string& s ) - { - file_input<> in( s ); - try { - parse< Rule >( in ); - TAO_PEGTL_TEST_FAILED( "expected exception" ); - } - catch( ... ) { - } + file_input in( s ); + try { + parse< Rule >( in ); + TAO_PEGTL_TEST_FAILED( "expected exception" ); } + catch( ... ) { + } + } - using GRAMMAR = must< json::text, eof >; - - void unit_test() - { - verify_analyze< GRAMMAR >( __LINE__, __FILE__, true, false ); + using GRAMMAR = must< json::text, eof >; - verify_rule< GRAMMAR >( __LINE__, __FILE__, "[]", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "{}", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, " [ ] ", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, " { } ", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, " [ ] ", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, " { } ", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "[[{}],[],{}]", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "[ null, true, false, 0, 1, 2, 123, 1.23, 0.12, -1, -0, -1.23, \"\", \"abc\" ]", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\b\"]", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\f\"]", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\n\"]", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\r\"]", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\t\"]", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\/\"]", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\\\\"]", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\\"\"]", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\u002C\"]", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\u002c\"]", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"ab\\u002Ccd\"]", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"ab\\u002ccd\"]", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\uD834\\uDD1E\"]", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\uD834\"]", result_type::SUCCESS, 0 ); // unfortunately, this is valid for the grammar... - verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\uDD1E\"]", result_type::SUCCESS, 0 ); // ...although both inputs are invalid in unicode. - verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\xC3\x84\"]", result_type::SUCCESS, 0 ); // German a-umlaut - verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\xF4\x8F\xBF\xBF\"]", result_type::SUCCESS, 0 ); // largest allowed codepoint U+10FFFF - verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\U0010FFFF\"]", result_type::SUCCESS, 0 ); // largest allowed codepoint U+10FFFF + void unit_test() + { + verify_analyze< GRAMMAR >( __LINE__, __FILE__, true, false ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, "" ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, " " ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, " " ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, "[" ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, "]" ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, " [" ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, " ]" ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, "[ " ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, "] " ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, " [ " ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, " ] " ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\\a\"]" ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\\c\"]" ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\\d\"]" ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\\e\"]" ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\\v\"]" ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\\'\"]" ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\b\"]" ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\f\"]" ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\n\"]" ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\r\"]" ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\t\"]" ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\\\"]" ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\\\\\\\"]" ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\\u12\"]" ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\xFF\"]" ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\xF4\x90\x80\x80\"]" ); - verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\xF7\xBF\xBF\xBF\"]" ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "[]", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "{}", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, " [ ] ", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, " { } ", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, " [ ] ", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, " { } ", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "[[{}],[],{}]", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "[ null, true, false, 0, 1, 2, 123, 1.23, 0.12, -1, -0, -1.23, \"\", \"abc\" ]", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\b\"]", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\f\"]", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\n\"]", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\r\"]", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\t\"]", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\/\"]", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\\\\"]", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\\"\"]", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\u002C\"]", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\u002c\"]", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"ab\\u002Ccd\"]", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"ab\\u002ccd\"]", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\uD834\\uDD1E\"]", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\uD834\"]", result_type::success, 0 ); // unfortunately, this is valid for the grammar... + verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\\uDD1E\"]", result_type::success, 0 ); // ...although both inputs are invalid in unicode. + verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\xC3\x84\"]", result_type::success, 0 ); // German a-umlaut + verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\xF4\x8F\xBF\xBF\"]", result_type::success, 0 ); // largest allowed codepoint U+10FFFF + verify_rule< GRAMMAR >( __LINE__, __FILE__, "[\"\U0010FFFF\"]", result_type::success, 0 ); // largest allowed codepoint U+10FFFF - TAO_PEGTL_TEST_ASSERT( parse< GRAMMAR >( file_input<>( "src/test/pegtl/data/pass1.json" ) ) ); - TAO_PEGTL_TEST_ASSERT( parse< GRAMMAR >( file_input<>( "src/test/pegtl/data/pass2.json" ) ) ); - TAO_PEGTL_TEST_ASSERT( parse< GRAMMAR >( file_input<>( "src/test/pegtl/data/pass3.json" ) ) ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, "" ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, " " ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, " " ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, "[" ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, "]" ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, " [" ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, " ]" ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, "[ " ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, "] " ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, " [ " ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, " ] " ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\\a\"]" ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\\c\"]" ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\\d\"]" ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\\e\"]" ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\\v\"]" ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\\'\"]" ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\b\"]" ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\f\"]" ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\n\"]" ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\r\"]" ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\t\"]" ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\\\"]" ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\\\\\\\"]" ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\\u12\"]" ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\xFF\"]" ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\xF4\x90\x80\x80\"]" ); + verify_fail< GRAMMAR >( __LINE__, __FILE__, "[\"\xF7\xBF\xBF\xBF\"]" ); - TAO_PEGTL_TEST_ASSERT( parse< GRAMMAR >( file_input<>( "src/test/pegtl/data/blns.json" ) ) ); + TAO_PEGTL_TEST_ASSERT( parse< GRAMMAR >( file_input( "src/test/pegtl/data/pass1.json" ) ) ); + TAO_PEGTL_TEST_ASSERT( parse< GRAMMAR >( file_input( "src/test/pegtl/data/pass2.json" ) ) ); + TAO_PEGTL_TEST_ASSERT( parse< GRAMMAR >( file_input( "src/test/pegtl/data/pass3.json" ) ) ); - // verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail1.json" ); // disabled as it is valid now - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail2.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail3.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail4.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail5.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail6.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail7.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail8.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail9.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail10.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail11.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail12.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail13.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail14.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail15.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail16.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail17.json" ); - // verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail18.json" ); // disabled as deep nesting is allowed - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail19.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail20.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail21.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail22.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail23.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail24.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail25.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail26.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail27.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail28.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail29.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail30.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail31.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail32.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail33.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail34.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail35.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail36.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail37.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail38.json" ); - verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail39.json" ); - } + TAO_PEGTL_TEST_ASSERT( parse< GRAMMAR >( file_input( "src/test/pegtl/data/blns.json" ) ) ); - } // namespace TAO_PEGTL_NAMESPACE + // verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail1.json" ); // disabled as it is valid now + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail2.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail3.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail4.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail5.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail6.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail7.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail8.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail9.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail10.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail11.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail12.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail13.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail14.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail15.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail16.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail17.json" ); + // verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail18.json" ); // disabled as deep nesting is allowed + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail19.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail20.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail21.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail22.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail23.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail24.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail25.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail26.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail27.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail28.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail29.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail30.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail31.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail32.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail33.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail34.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail35.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail36.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail37.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail38.json" ); + verify_file_fail< GRAMMAR >( __LINE__, __FILE__, "src/test/pegtl/data/fail39.json" ); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/contrib_parse_tree.cpp b/packages/PEGTL/src/test/pegtl/contrib_parse_tree.cpp index 984f4506c..2df7a9b30 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_parse_tree.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_parse_tree.cpp @@ -1,60 +1,56 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include <tao/pegtl/contrib/parse_tree.hpp> -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + // clang-format off + struct A : one< 'a' > {}; + struct B : one< 'b' > {}; + struct C : one< 'c' > {}; + + struct D : sor< seq< A, B >, seq< A, C > > {}; + // clang-format on + + template< typename Rule > + struct selector + : parse_tree::selector< Rule, parse_tree::store_content::on< A, B, C, D > > { - // clang-format off - struct A : one< 'a' > {}; - struct B : one< 'b' > {}; - struct C : one< 'c' > {}; - - struct D : sor< seq< A, B >, seq< A, C > > {}; - // clang-format on - - template< typename Rule > - struct selector - : parse_tree::selector< Rule, parse_tree::apply_store_content::to< A, B, C, D > > - { - }; - - void unit_test() - { - memory_input<> in( "ac", "input" ); - const auto r = parse_tree::parse< D, selector >( in ); - TAO_PEGTL_TEST_ASSERT( r->is_root() ); - TAO_PEGTL_TEST_ASSERT( !r->has_content() ); - TAO_PEGTL_TEST_ASSERT( r->children.size() == 1 ); - - const auto& d = r->children.front(); - TAO_PEGTL_TEST_ASSERT( !d->is_root() ); - TAO_PEGTL_TEST_ASSERT( d->id == &typeid( D ) ); - TAO_PEGTL_TEST_ASSERT( d->is< D >() ); + }; + + void unit_test() + { + memory_input in( "ac", "input" ); + const auto r = parse_tree::parse< D, selector >( in ); + TAO_PEGTL_TEST_ASSERT( r->is_root() ); + TAO_PEGTL_TEST_ASSERT( !r->has_content() ); + TAO_PEGTL_TEST_ASSERT( r->children.size() == 1 ); + + const auto& d = r->children.front(); + TAO_PEGTL_TEST_ASSERT( !d->is_root() ); + TAO_PEGTL_TEST_ASSERT( d->id == typeid( D ) ); + TAO_PEGTL_TEST_ASSERT( d->is< D >() ); #if !defined( _MSC_VER ) - TAO_PEGTL_TEST_ASSERT( d->name() == "tao::pegtl::D" ); + TAO_PEGTL_TEST_ASSERT( d->name() == "tao::pegtl::D" ); #endif - TAO_PEGTL_TEST_ASSERT( d->has_content() ); - TAO_PEGTL_TEST_ASSERT( d->begin().byte == 0 ); - TAO_PEGTL_TEST_ASSERT( d->end().byte == 2 ); - TAO_PEGTL_TEST_ASSERT( d->content() == "ac" ); - - TAO_PEGTL_TEST_ASSERT( d->children.size() == 2 ); - TAO_PEGTL_TEST_ASSERT( d->children.front()->is< A >() ); - TAO_PEGTL_TEST_ASSERT( d->children.back()->is< C >() ); + TAO_PEGTL_TEST_ASSERT( d->has_content() ); + TAO_PEGTL_TEST_ASSERT( d->begin().byte == 0 ); + TAO_PEGTL_TEST_ASSERT( d->end().byte == 2 ); + TAO_PEGTL_TEST_ASSERT( d->string_view() == "ac" ); - memory_input<> in2( "x", "input" ); - const auto r2 = parse_tree::parse< D, selector >( in2 ); - TAO_PEGTL_TEST_ASSERT( !r2 ); - } + TAO_PEGTL_TEST_ASSERT( d->children.size() == 2 ); + TAO_PEGTL_TEST_ASSERT( d->children.front()->is< A >() ); + TAO_PEGTL_TEST_ASSERT( d->children.back()->is< C >() ); - } // namespace TAO_PEGTL_NAMESPACE + memory_input in2( "x", "input" ); + const auto r2 = parse_tree::parse< D, selector >( in2 ); + TAO_PEGTL_TEST_ASSERT( !r2 ); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/contrib_partial_trace.cpp b/packages/PEGTL/src/test/pegtl/contrib_partial_trace.cpp new file mode 100644 index 000000000..f4d82a1d7 --- /dev/null +++ b/packages/PEGTL/src/test/pegtl/contrib_partial_trace.cpp @@ -0,0 +1,28 @@ +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#include "test.hpp" + +#include <tao/pegtl/contrib/tracer.hpp> + +namespace TAO_PEGTL_NAMESPACE +{ + // clang-format off + struct inner : seq< one< 'a' >, sor< one< 'b' >, one< 'c' > > > {}; + struct outer : seq< one< 'x' >, inner, one< 'y' > > {}; + + // how to run a tracer on a *part* of the grammar: + template< typename > struct partial_action {}; + template<> struct partial_action< inner > : change_control< tracer > {}; + // clang-format on + + void unit_test() + { + memory_input in( "xacy", "trace test please ignore" ); + const auto result = parse< outer, partial_action >( in ); + TAO_PEGTL_TEST_ASSERT( result ); + } + +} // namespace TAO_PEGTL_NAMESPACE + +#include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/contrib_raw_string.cpp b/packages/PEGTL/src/test/pegtl/contrib_raw_string.cpp index fd17847ce..6c41cfca3 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" @@ -6,132 +6,124 @@ #include <tao/pegtl/contrib/raw_string.hpp> -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE - { - std::string content; // NOLINT - - using rstring = raw_string< '[', '=', ']' >; - using qstring = raw_string< '[', '=', ']', alpha, digit >; + std::string content; // NOLINT - template< typename Rule > - struct raction - : nothing< Rule > - { - }; + using rstring = raw_string< '[', '=', ']' >; + using qstring = raw_string< '[', '=', ']', alpha, digit >; - template<> - struct raction< rstring::content > - { - template< typename Input, typename... States > - static void apply( const Input& in, const States&... /*unused*/ ) - { - content.assign( in.begin(), in.end() ); - } - }; - - template< typename Rule > - struct qaction - : nothing< Rule > - { - }; + template< typename Rule > + struct raction + {}; - template<> - struct qaction< qstring::content > - { - template< typename Input, typename... States > - static void apply( const Input& in, const States&... /*unused*/ ) - { - content.assign( in.begin(), in.end() ); - } - }; - - struct rgrammar - : must< rstring, eof > + template<> + struct raction< rstring::content > + { + template< typename Input, typename... States > + static void apply( const Input& in, const States&... /*unused*/ ) { - }; + content.assign( in.begin(), in.end() ); + } + }; - struct qgrammar - : must< qstring, eof > - { - }; + template< typename Rule > + struct qaction + {}; - template< typename Rule, template< typename > class Action, unsigned M, unsigned N > - void verify_data( const std::size_t line, const char* file, const char ( &m )[ M ], const char ( &n )[ N ] ) + template<> + struct qaction< qstring::content > + { + template< typename Input, typename... States > + static void apply( const Input& in, const States&... /*unused*/ ) { - content.clear(); - memory_input<> in( m, m + M - 1, file, 0, line, 0 ); - const auto r = parse< Rule, Action >( in ); - if( ( !r ) || ( content != std::string( n, N - 1 ) ) ) { - TAO_PEGTL_TEST_FAILED( "input data [ '" << m << "' ] expected success with [ '" << n << "' ] but got [ '" << content << "' ] result [ " << r << " ]" ); - } - content.clear(); - memory_input< tracking_mode::LAZY > in2( m, m + M - 1, file, 0, line, 0 ); - const auto r2 = parse< Rule, Action >( in2 ); - if( ( !r2 ) || ( content != std::string( n, N - 1 ) ) ) { - TAO_PEGTL_TEST_FAILED( "input data [ '" << m << "' ] with tracking_mode::LAZY expected success with [ '" << n << "' ] but got [ '" << content << "' ] result [ " << r2 << " ]" ); - } + content.assign( in.begin(), in.end() ); } + }; - void unit_test() - { - verify_data< rgrammar, raction >( __LINE__, __FILE__, "[[]]", "" ); - verify_data< rgrammar, raction >( __LINE__, __FILE__, "[[foo]]", "foo" ); - verify_data< rgrammar, raction >( __LINE__, __FILE__, "[===[foo]===]", "foo" ); - verify_data< rgrammar, raction >( __LINE__, __FILE__, "[===[\nfoo]===]", "foo" ); - verify_data< rgrammar, raction >( __LINE__, __FILE__, "[===[\r\nfoo]===]", "foo" ); - verify_data< rgrammar, raction >( __LINE__, __FILE__, "[===[\0\0\0]===]", "\0\0\0" ); - - verify_data< qgrammar, qaction >( __LINE__, __FILE__, "[[]]", "" ); - verify_data< qgrammar, qaction >( __LINE__, __FILE__, "[[a1]]", "a1" ); - verify_data< qgrammar, qaction >( __LINE__, __FILE__, "[===[a1]===]", "a1" ); - verify_data< qgrammar, qaction >( __LINE__, __FILE__, "[===[\na1]===]", "a1" ); - verify_data< qgrammar, qaction >( __LINE__, __FILE__, "[===[\r\na1]===]", "a1" ); - verify_data< qgrammar, qaction >( __LINE__, __FILE__, "[===[a0a1a2a3]===]", "a0a1a2a3" ); - - verify_fail< rgrammar >( __LINE__, __FILE__, "" ); - verify_fail< rgrammar >( __LINE__, __FILE__, "[" ); - verify_fail< rgrammar >( __LINE__, __FILE__, "[=" ); - verify_fail< rgrammar >( __LINE__, __FILE__, "[=[" ); - verify_fail< rgrammar >( __LINE__, __FILE__, "[=[]=" ); - verify_fail< rgrammar >( __LINE__, __FILE__, "[=[]]" ); - verify_fail< rgrammar >( __LINE__, __FILE__, "[]" ); - verify_fail< rgrammar >( __LINE__, __FILE__, "[[]] " ); - verify_fail< rgrammar >( __LINE__, __FILE__, " [[]]" ); - verify_fail< rgrammar >( __LINE__, __FILE__, "[=[]-]" ); - verify_fail< rgrammar >( __LINE__, __FILE__, "[-[]=]" ); - verify_fail< rgrammar >( __LINE__, __FILE__, "[-[]-]" ); - verify_fail< rgrammar >( __LINE__, __FILE__, "[===[]====]" ); - verify_fail< rgrammar >( __LINE__, __FILE__, "[====[]===]" ); - - verify_fail< qgrammar >( __LINE__, __FILE__, "" ); - verify_fail< qgrammar >( __LINE__, __FILE__, "[" ); - verify_fail< qgrammar >( __LINE__, __FILE__, "[=" ); - verify_fail< qgrammar >( __LINE__, __FILE__, "[=[" ); - verify_fail< qgrammar >( __LINE__, __FILE__, "[=[]=" ); - verify_fail< qgrammar >( __LINE__, __FILE__, "[=[]]" ); - verify_fail< qgrammar >( __LINE__, __FILE__, "[]" ); - verify_fail< qgrammar >( __LINE__, __FILE__, "[[]] " ); - verify_fail< qgrammar >( __LINE__, __FILE__, " [[]]" ); - verify_fail< qgrammar >( __LINE__, __FILE__, "[=[]-]" ); - verify_fail< qgrammar >( __LINE__, __FILE__, "[-[]=]" ); - verify_fail< qgrammar >( __LINE__, __FILE__, "[-[]-]" ); - verify_fail< qgrammar >( __LINE__, __FILE__, "[===[]====]" ); - verify_fail< qgrammar >( __LINE__, __FILE__, "[====[]===]" ); - - verify_fail< qgrammar >( __LINE__, __FILE__, "[=[-]=]" ); - verify_fail< qgrammar >( __LINE__, __FILE__, "[=[1]=]" ); - verify_fail< qgrammar >( __LINE__, __FILE__, "[=[a]=]" ); - verify_fail< qgrammar >( __LINE__, __FILE__, "[=[a+]=]" ); - verify_fail< qgrammar >( __LINE__, __FILE__, "[=[aa]=]" ); - verify_fail< qgrammar >( __LINE__, __FILE__, "[=[11]=]" ); - verify_fail< qgrammar >( __LINE__, __FILE__, "[=[a1a]=]" ); - verify_fail< qgrammar >( __LINE__, __FILE__, "[=[a1aa]=]" ); - } + struct rgrammar + : must< rstring, eof > + { + }; - } // namespace TAO_PEGTL_NAMESPACE + struct qgrammar + : must< qstring, eof > + { + }; -} // namespace tao + template< typename Rule, template< typename > class Action, unsigned M, unsigned N > + void verify_data( const std::size_t line, const char* file, const char ( &m )[ M ], const char ( &n )[ N ] ) // NOLINT + { + content.clear(); + memory_input in( m, m + M - 1, file, 0, line, 0 ); + const auto r = parse< Rule, Action >( in ); + if( ( !r ) || ( content != std::string_view( n, N - 1 ) ) ) { + TAO_PEGTL_TEST_FAILED( "input data [ '" << m << "' ] expected success with [ '" << n << "' ] but got [ '" << content << "' ] result [ " << r << " ]" ); + } + content.clear(); + memory_input< tracking_mode::lazy > in2( m, m + M - 1, file, 0, line, 0 ); + const auto r2 = parse< Rule, Action >( in2 ); + if( ( !r2 ) || ( content != std::string_view( n, N - 1 ) ) ) { + TAO_PEGTL_TEST_FAILED( "input data [ '" << m << "' ] with tracking_mode::lazy expected success with [ '" << n << "' ] but got [ '" << content << "' ] result [ " << r2 << " ]" ); + } + } + + void unit_test() + { + verify_data< rgrammar, raction >( __LINE__, __FILE__, "[[]]", "" ); + verify_data< rgrammar, raction >( __LINE__, __FILE__, "[[foo]]", "foo" ); + verify_data< rgrammar, raction >( __LINE__, __FILE__, "[===[foo]===]", "foo" ); + verify_data< rgrammar, raction >( __LINE__, __FILE__, "[===[\nfoo]===]", "foo" ); + verify_data< rgrammar, raction >( __LINE__, __FILE__, "[===[\r\nfoo]===]", "foo" ); + verify_data< rgrammar, raction >( __LINE__, __FILE__, "[===[\0\0\0]===]", "\0\0\0" ); + + verify_data< qgrammar, qaction >( __LINE__, __FILE__, "[[]]", "" ); + verify_data< qgrammar, qaction >( __LINE__, __FILE__, "[[a1]]", "a1" ); + verify_data< qgrammar, qaction >( __LINE__, __FILE__, "[===[a1]===]", "a1" ); + verify_data< qgrammar, qaction >( __LINE__, __FILE__, "[===[\na1]===]", "a1" ); + verify_data< qgrammar, qaction >( __LINE__, __FILE__, "[===[\r\na1]===]", "a1" ); + verify_data< qgrammar, qaction >( __LINE__, __FILE__, "[===[a0a1a2a3]===]", "a0a1a2a3" ); + + verify_fail< rgrammar >( __LINE__, __FILE__, "" ); + verify_fail< rgrammar >( __LINE__, __FILE__, "[" ); + verify_fail< rgrammar >( __LINE__, __FILE__, "[=" ); + verify_fail< rgrammar >( __LINE__, __FILE__, "[=[" ); + verify_fail< rgrammar >( __LINE__, __FILE__, "[=[]=" ); + verify_fail< rgrammar >( __LINE__, __FILE__, "[=[]]" ); + verify_fail< rgrammar >( __LINE__, __FILE__, "[]" ); + verify_fail< rgrammar >( __LINE__, __FILE__, "[[]] " ); + verify_fail< rgrammar >( __LINE__, __FILE__, " [[]]" ); + verify_fail< rgrammar >( __LINE__, __FILE__, "[=[]-]" ); + verify_fail< rgrammar >( __LINE__, __FILE__, "[-[]=]" ); + verify_fail< rgrammar >( __LINE__, __FILE__, "[-[]-]" ); + verify_fail< rgrammar >( __LINE__, __FILE__, "[===[]====]" ); + verify_fail< rgrammar >( __LINE__, __FILE__, "[====[]===]" ); + + verify_fail< qgrammar >( __LINE__, __FILE__, "" ); + verify_fail< qgrammar >( __LINE__, __FILE__, "[" ); + verify_fail< qgrammar >( __LINE__, __FILE__, "[=" ); + verify_fail< qgrammar >( __LINE__, __FILE__, "[=[" ); + verify_fail< qgrammar >( __LINE__, __FILE__, "[=[]=" ); + verify_fail< qgrammar >( __LINE__, __FILE__, "[=[]]" ); + verify_fail< qgrammar >( __LINE__, __FILE__, "[]" ); + verify_fail< qgrammar >( __LINE__, __FILE__, "[[]] " ); + verify_fail< qgrammar >( __LINE__, __FILE__, " [[]]" ); + verify_fail< qgrammar >( __LINE__, __FILE__, "[=[]-]" ); + verify_fail< qgrammar >( __LINE__, __FILE__, "[-[]=]" ); + verify_fail< qgrammar >( __LINE__, __FILE__, "[-[]-]" ); + verify_fail< qgrammar >( __LINE__, __FILE__, "[===[]====]" ); + verify_fail< qgrammar >( __LINE__, __FILE__, "[====[]===]" ); + + verify_fail< qgrammar >( __LINE__, __FILE__, "[=[-]=]" ); + verify_fail< qgrammar >( __LINE__, __FILE__, "[=[1]=]" ); + verify_fail< qgrammar >( __LINE__, __FILE__, "[=[a]=]" ); + verify_fail< qgrammar >( __LINE__, __FILE__, "[=[a+]=]" ); + verify_fail< qgrammar >( __LINE__, __FILE__, "[=[aa]=]" ); + verify_fail< qgrammar >( __LINE__, __FILE__, "[=[11]=]" ); + verify_fail< qgrammar >( __LINE__, __FILE__, "[=[a1a]=]" ); + verify_fail< qgrammar >( __LINE__, __FILE__, "[=[a1aa]=]" ); + } + +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" 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 2243f9d48..ebfb08680 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" @@ -7,35 +7,31 @@ #include <tao/pegtl/contrib/rep_one_min_max.hpp> -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< ellipsis >( __LINE__, __FILE__, true, false ); - - verify_analyze< rep_one_min_max< 0, 1, '+' > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep_one_min_max< 1, 1, '+' > >( __LINE__, __FILE__, true, false ); - - verify_rule< ellipsis >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< ellipsis >( __LINE__, __FILE__, ".", result_type::LOCAL_FAILURE, 1 ); - verify_rule< ellipsis >( __LINE__, __FILE__, "..", result_type::LOCAL_FAILURE, 2 ); - verify_rule< ellipsis >( __LINE__, __FILE__, "....", result_type::LOCAL_FAILURE, 4 ); - verify_rule< ellipsis >( __LINE__, __FILE__, "...", result_type::SUCCESS, 0 ); - verify_rule< ellipsis >( __LINE__, __FILE__, "... ", result_type::SUCCESS, 1 ); - verify_rule< ellipsis >( __LINE__, __FILE__, "...+", result_type::SUCCESS, 1 ); - verify_rule< ellipsis >( __LINE__, __FILE__, "...a", result_type::SUCCESS, 1 ); - - verify_rule< rep_one_min_max< 0, 2, '+' > >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - verify_rule< rep_one_min_max< 0, 2, '+' > >( __LINE__, __FILE__, "-", result_type::SUCCESS, 1 ); - verify_rule< rep_one_min_max< 0, 2, '+' > >( __LINE__, __FILE__, "+-", result_type::SUCCESS, 1 ); - verify_rule< rep_one_min_max< 0, 2, '+' > >( __LINE__, __FILE__, "++-", result_type::SUCCESS, 1 ); - verify_rule< rep_one_min_max< 0, 2, '+' > >( __LINE__, __FILE__, "+++", result_type::LOCAL_FAILURE, 3 ); - } - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + verify_analyze< rep_one_min_max< 3, 3, '.' > >( __LINE__, __FILE__, true, false ); + + verify_analyze< rep_one_min_max< 0, 1, '+' > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep_one_min_max< 1, 1, '+' > >( __LINE__, __FILE__, true, false ); + + verify_rule< rep_one_min_max< 3, 3, '.' > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< rep_one_min_max< 3, 3, '.' > >( __LINE__, __FILE__, ".", result_type::local_failure, 1 ); + verify_rule< rep_one_min_max< 3, 3, '.' > >( __LINE__, __FILE__, "..", result_type::local_failure, 2 ); + verify_rule< rep_one_min_max< 3, 3, '.' > >( __LINE__, __FILE__, "....", result_type::local_failure, 4 ); + verify_rule< rep_one_min_max< 3, 3, '.' > >( __LINE__, __FILE__, "...", result_type::success, 0 ); + verify_rule< rep_one_min_max< 3, 3, '.' > >( __LINE__, __FILE__, "... ", result_type::success, 1 ); + verify_rule< rep_one_min_max< 3, 3, '.' > >( __LINE__, __FILE__, "...+", result_type::success, 1 ); + verify_rule< rep_one_min_max< 3, 3, '.' > >( __LINE__, __FILE__, "...a", result_type::success, 1 ); + + verify_rule< rep_one_min_max< 0, 2, '+' > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< rep_one_min_max< 0, 2, '+' > >( __LINE__, __FILE__, "-", result_type::success, 1 ); + verify_rule< rep_one_min_max< 0, 2, '+' > >( __LINE__, __FILE__, "+-", result_type::success, 1 ); + verify_rule< rep_one_min_max< 0, 2, '+' > >( __LINE__, __FILE__, "++-", result_type::success, 1 ); + verify_rule< rep_one_min_max< 0, 2, '+' > >( __LINE__, __FILE__, "+++", result_type::local_failure, 3 ); + } + +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/contrib_to_string.cpp b/packages/PEGTL/src/test/pegtl/contrib_to_string.cpp index 2c92b9659..55f9d2749 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" @@ -6,32 +6,28 @@ #include <tao/pegtl.hpp> #include <tao/pegtl/contrib/to_string.hpp> -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - TAO_PEGTL_TEST_ASSERT( to_string< string<> >().empty() ); - TAO_PEGTL_TEST_ASSERT( ( to_string< string< 'a', 'b', 'c' > >() == "abc" ) ); + TAO_PEGTL_TEST_ASSERT( to_string< string<> >().empty() ); + TAO_PEGTL_TEST_ASSERT( ( to_string< string< 'a', 'b', 'c' > >() == "abc" ) ); - TAO_PEGTL_TEST_ASSERT( to_string< istring<> >().empty() ); - TAO_PEGTL_TEST_ASSERT( ( to_string< istring< 'a', 'b', 'c' > >() == "abc" ) ); + TAO_PEGTL_TEST_ASSERT( to_string< istring<> >().empty() ); + TAO_PEGTL_TEST_ASSERT( ( to_string< istring< 'a', 'b', 'c' > >() == "abc" ) ); - TAO_PEGTL_TEST_ASSERT( to_string< TAO_PEGTL_STRING( "" ) >().empty() ); - TAO_PEGTL_TEST_ASSERT( to_string< TAO_PEGTL_STRING( "abc" ) >() == "abc" ); - TAO_PEGTL_TEST_ASSERT( to_string< TAO_PEGTL_STRING( "AbC" ) >() == "AbC" ); - TAO_PEGTL_TEST_ASSERT( to_string< TAO_PEGTL_STRING( "abc" ) >() != "AbC" ); - TAO_PEGTL_TEST_ASSERT( to_string< TAO_PEGTL_ISTRING( "abc" ) >() == "abc" ); - TAO_PEGTL_TEST_ASSERT( to_string< TAO_PEGTL_ISTRING( "AbC" ) >() == "AbC" ); - TAO_PEGTL_TEST_ASSERT( to_string< TAO_PEGTL_ISTRING( "abc" ) >() != "AbC" ); + TAO_PEGTL_TEST_ASSERT( to_string< TAO_PEGTL_STRING( "" ) >().empty() ); + TAO_PEGTL_TEST_ASSERT( to_string< TAO_PEGTL_STRING( "abc" ) >() == "abc" ); + TAO_PEGTL_TEST_ASSERT( to_string< TAO_PEGTL_STRING( "AbC" ) >() == "AbC" ); + TAO_PEGTL_TEST_ASSERT( to_string< TAO_PEGTL_STRING( "abc" ) >() != "AbC" ); + TAO_PEGTL_TEST_ASSERT( to_string< TAO_PEGTL_ISTRING( "abc" ) >() == "abc" ); + TAO_PEGTL_TEST_ASSERT( to_string< TAO_PEGTL_ISTRING( "AbC" ) >() == "AbC" ); + TAO_PEGTL_TEST_ASSERT( to_string< TAO_PEGTL_ISTRING( "abc" ) >() != "AbC" ); - // to_string does *not* care about the outer class template - TAO_PEGTL_TEST_ASSERT( ( to_string< one< 'a', 'b', 'c' > >() == "abc" ) ); - } + // to_string does *not* care about the outer class template + TAO_PEGTL_TEST_ASSERT( ( to_string< one< 'a', 'b', 'c' > >() == "abc" ) ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/contrib_tracer.cpp b/packages/PEGTL/src/test/pegtl/contrib_tracer.cpp index 429631650..1d8ac5010 100644 --- a/packages/PEGTL/src/test/pegtl/contrib_tracer.cpp +++ b/packages/PEGTL/src/test/pegtl/contrib_tracer.cpp @@ -1,81 +1,90 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include <tao/pegtl/contrib/tracer.hpp> -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE - { - using GRAMMAR = sor< failure, one< 'a' > >; + using GRAMMAR = sor< failure, one< 'a' > >; + using GRAMMAR2 = seq< one< 'a' >, any, any, any, any, one< 'b' >, eof >; - template< typename Rule > - struct tracer_action - : nothing< Rule > - { - }; + template< typename Rule > + struct tracer_action + {}; - unsigned a0 = 0; - unsigned a = 0; + unsigned a0 = 0; + unsigned a = 0; - template<> - struct tracer_action< one< 'a' > > + template<> + struct tracer_action< one< 'a' > > + { + template< typename... Ts > + static void apply0( Ts&&... /*unused*/ ) { - template< typename... Ts > - static void apply0( Ts&&... /*unused*/ ) - { - ++a0; - } - }; + ++a0; + } + }; - template<> - struct tracer_action< GRAMMAR > + template<> + struct tracer_action< GRAMMAR > + { + template< typename... Ts > + static void apply( Ts&&... /*unused*/ ) { - template< typename... Ts > - static void apply( Ts&&... /*unused*/ ) - { - ++a; - } - }; + ++a; + } + }; - void unit_test() + void unit_test() + { { - { - memory_input<> in( "ab", "trace test please ignore" ); - const auto result = parse< GRAMMAR, nothing, tracer >( in ); - TAO_PEGTL_TEST_ASSERT( result ); - TAO_PEGTL_TEST_ASSERT( a0 == 0 ); - TAO_PEGTL_TEST_ASSERT( a == 0 ); - } - { - memory_input<> in( "ab", "trace test please ignore" ); - const auto result = parse< GRAMMAR, tracer_action, tracer >( in ); - TAO_PEGTL_TEST_ASSERT( result ); - TAO_PEGTL_TEST_ASSERT( a0 == 1 ); - TAO_PEGTL_TEST_ASSERT( a == 1 ); - } - { - trace_state ts; - memory_input<> in( "ab", "trace test please ignore" ); - const auto result = parse< GRAMMAR, nothing, tracer >( in, ts ); - TAO_PEGTL_TEST_ASSERT( result ); - TAO_PEGTL_TEST_ASSERT( a0 == 1 ); - TAO_PEGTL_TEST_ASSERT( a == 1 ); - } - { - trace_state ts; - memory_input<> in( "ab", "trace test please ignore" ); - const auto result = parse< GRAMMAR, tracer_action, tracer >( in, ts ); - TAO_PEGTL_TEST_ASSERT( result ); - TAO_PEGTL_TEST_ASSERT( a0 == 2 ); - TAO_PEGTL_TEST_ASSERT( a == 2 ); - } + memory_input in( "ab", "trace test please ignore" ); + const auto result = parse< GRAMMAR, nothing, tracer >( in ); + TAO_PEGTL_TEST_ASSERT( result ); + TAO_PEGTL_TEST_ASSERT( a0 == 0 ); + TAO_PEGTL_TEST_ASSERT( a == 0 ); } + { + memory_input in( "ab", "trace test please ignore" ); + const auto result = parse< GRAMMAR, tracer_action, tracer >( in ); + TAO_PEGTL_TEST_ASSERT( result ); + TAO_PEGTL_TEST_ASSERT( a0 == 1 ); + TAO_PEGTL_TEST_ASSERT( a == 1 ); + } + { + trace_state ts; + memory_input in( "ab", "trace test please ignore" ); + const auto result = parse< GRAMMAR, nothing, tracer >( in, ts ); + TAO_PEGTL_TEST_ASSERT( result ); + TAO_PEGTL_TEST_ASSERT( a0 == 1 ); + TAO_PEGTL_TEST_ASSERT( a == 1 ); + } + { + trace_state ts; + memory_input in( "ab", "trace test please ignore" ); + const auto result = parse< GRAMMAR, tracer_action, tracer >( in, ts ); + TAO_PEGTL_TEST_ASSERT( result ); + TAO_PEGTL_TEST_ASSERT( a0 == 2 ); + TAO_PEGTL_TEST_ASSERT( a == 2 ); + } + { + trace_state ts; + memory_input in( "a\r\n\t\0b", 6, "trace test please ignore" ); + const auto result = parse< GRAMMAR2, nothing, tracer >( in, ts ); + TAO_PEGTL_TEST_ASSERT( result ); + TAO_PEGTL_TEST_ASSERT( a0 == 2 ); + TAO_PEGTL_TEST_ASSERT( a == 2 ); + } + { + trace_state ts; + memory_input in( "a\r\n\t\0b", 6, "trace test please ignore" ); + const auto result = parse< GRAMMAR2, tracer_action, tracer >( in, ts ); + TAO_PEGTL_TEST_ASSERT( result ); + } + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/contrib_unescape.cpp b/packages/PEGTL/src/test/pegtl/contrib_unescape.cpp index 254afe523..f31754192 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" @@ -6,116 +6,112 @@ #include <tao/pegtl/contrib/unescape.hpp> -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + // clang-format off + struct escaped_c : one< '"', '\\', 't' > {}; + struct escaped_u : seq< one< 'u' >, rep< 4, must< xdigit > > > {}; + struct escaped_U : seq< one< 'U' >, rep< 8, must< xdigit > > > {}; + struct escaped_j : list< seq< one< 'j' >, rep< 4, must< xdigit > > >, one< '\\' > > {}; + struct escaped_x : seq< one< 'x' >, rep< 2, must< xdigit > > > {}; + struct escaped : sor< escaped_c, escaped_u, escaped_U, escaped_j, escaped_x > {}; + struct character : if_then_else< one< '\\' >, must< escaped >, utf8::any > {}; + struct unstring : until< eof, character > {}; + + template< typename Rule > struct unaction {}; + + template<> struct unaction< escaped_c > : unescape::unescape_c< escaped_c, '"', '\\', '\t' > {}; + template<> struct unaction< escaped_u > : unescape::unescape_u {}; + template<> struct unaction< escaped_U > : unescape::unescape_u {}; + template<> struct unaction< escaped_j > : unescape::unescape_j {}; + template<> struct unaction< escaped_x > : unescape::unescape_x {}; + template<> struct unaction< utf8::any > : unescape::append_all {}; + // clang-format on + + template< unsigned M, unsigned N > + void verify_data( const char ( &m )[ M ], const char ( &n )[ N ] ) // NOLINT { - // clang-format off - struct escaped_c : one< '"', '\\', 't' > {}; - struct escaped_u : seq< one< 'u' >, rep< 4, must< xdigit > > > {}; - struct escaped_U : seq< one< 'U' >, rep< 8, must< xdigit > > > {}; - struct escaped_j : list< seq< one< 'j' >, rep< 4, must< xdigit > > >, one< '\\' > > {}; - struct escaped_x : seq< one< 'x' >, rep< 2, must< xdigit > > > {}; - struct escaped : sor< escaped_c, escaped_u, escaped_U, escaped_j, escaped_x > {}; - struct character : if_then_else< one< '\\' >, must< escaped >, utf8::any > {}; - struct unstring : until< eof, character > {}; - - template< typename Rule > struct unaction : nothing< Rule > {}; - - template<> struct unaction< escaped_c > : unescape::unescape_c< escaped_c, '"', '\\', '\t' > {}; - template<> struct unaction< escaped_u > : unescape::unescape_u {}; - template<> struct unaction< escaped_U > : unescape::unescape_u {}; - template<> struct unaction< escaped_j > : unescape::unescape_j {}; - template<> struct unaction< escaped_x > : unescape::unescape_x {}; - template<> struct unaction< utf8::any > : unescape::append_all {}; - // clang-format on - - template< unsigned M, unsigned N > - void verify_data( const char ( &m )[ M ], const char ( &n )[ N ] ) - { - unescape::state st; - memory_input<> in( m, M - 1, __FUNCTION__ ); - parse< unstring, unaction >( in, st ); - if( st.unescaped != std::string( n, N - 1 ) ) { - throw std::runtime_error( "test failed!" ); // NOLINT - } + std::string s; + memory_input in( m, M - 1, __FUNCTION__ ); + parse< unstring, unaction >( in, s ); + if( s != std::string( n, N - 1 ) ) { + throw std::runtime_error( "test failed!" ); // NOLINT } + } - void unit_test() - { - verify_data( "\\t", "\t" ); - verify_data( "\\\\", "\\" ); - verify_data( "abc", "abc" ); - verify_data( "\\\"foo\\\"", "\"foo\"" ); - verify_data( "\\x20", " " ); - verify_data( "\\x30", "0" ); - verify_data( "\\x2000", " 00" ); - verify_data( "\\u0020", " " ); - verify_data( "\\u0020\\u0020", " " ); - verify_data( "\\u00e4", "\xc3\xa4" ); - verify_data( "\\u00E4", "\xC3\xA4" ); - verify_data( "\\u20ac", "\xe2\x82\xac" ); - - TAO_PEGTL_TEST_THROWS( verify_data( "\\ud800", "" ) ); - TAO_PEGTL_TEST_THROWS( verify_data( "\\ud800X", "" ) ); - TAO_PEGTL_TEST_THROWS( verify_data( "\\ud800\\u0020", "" ) ); - TAO_PEGTL_TEST_THROWS( verify_data( "\\ud800\\udc00", "" ) ); // unescape_u does not support surrogate pairs. - TAO_PEGTL_TEST_THROWS( verify_data( "\\udc00\\ud800", "" ) ); - - verify_data( "\\j0020", " " ); - verify_data( "\\j0020\\j0020", " " ); - verify_data( "\\j20ac", "\xe2\x82\xac" ); - - verify_data( "\\jd800\\jdc00", "\xf0\x90\x80\x80" ); // unescape_j does support proper surrogate pairs. - - TAO_PEGTL_TEST_THROWS( verify_data( "\\jd800", "" ) ); - TAO_PEGTL_TEST_THROWS( verify_data( "\\jd800X", "" ) ); - TAO_PEGTL_TEST_THROWS( verify_data( "\\jd800\\j0020", "" ) ); - TAO_PEGTL_TEST_THROWS( verify_data( "\\jdc00\\jd800", "" ) ); - - verify_data( "\\j0000\\u0000\x00", "\x00\x00\x00" ); - - unescape::state st; - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\\\\\", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\x", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\xx", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\xa", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\x1", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\x1h", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "a\\", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "a\\x", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "a\\xx", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "a\\xa", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "a\\x1", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "a\\x1h", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\a", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\_", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\z", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\1", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\a00", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\_1111", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\z22222222", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\13333333333333333", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\u", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\uu", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\uuuu", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\u123", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\u999", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\u444h", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\j", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\ju", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\juuu", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\j123", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\j999", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\j444h", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\U00110000", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\U80000000", st ); - verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\Uffffffff", st ); - } - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + void unit_test() + { + verify_data( "\\t", "\t" ); + verify_data( "\\\\", "\\" ); + verify_data( "abc", "abc" ); + verify_data( "\\\"foo\\\"", "\"foo\"" ); + verify_data( "\\x20", " " ); + verify_data( "\\x30", "0" ); + verify_data( "\\x2000", " 00" ); + verify_data( "\\u0020", " " ); + verify_data( "\\u0020\\u0020", " " ); + verify_data( "\\u00e4", "\xc3\xa4" ); + verify_data( "\\u00E4", "\xC3\xA4" ); + verify_data( "\\u20ac", "\xe2\x82\xac" ); + + TAO_PEGTL_TEST_THROWS( verify_data( "\\ud800", "" ) ); + TAO_PEGTL_TEST_THROWS( verify_data( "\\ud800X", "" ) ); + TAO_PEGTL_TEST_THROWS( verify_data( "\\ud800\\u0020", "" ) ); + TAO_PEGTL_TEST_THROWS( verify_data( "\\ud800\\udc00", "" ) ); // unescape_u does not support surrogate pairs. + TAO_PEGTL_TEST_THROWS( verify_data( "\\udc00\\ud800", "" ) ); + + verify_data( "\\j0020", " " ); + verify_data( "\\j0020\\j0020", " " ); + verify_data( "\\j20ac", "\xe2\x82\xac" ); + + verify_data( "\\jd800\\jdc00", "\xf0\x90\x80\x80" ); // unescape_j does support proper surrogate pairs. + + TAO_PEGTL_TEST_THROWS( verify_data( "\\jd800", "" ) ); + TAO_PEGTL_TEST_THROWS( verify_data( "\\jd800X", "" ) ); + TAO_PEGTL_TEST_THROWS( verify_data( "\\jd800\\j0020", "" ) ); + TAO_PEGTL_TEST_THROWS( verify_data( "\\jdc00\\jd800", "" ) ); + + verify_data( "\\j0000\\u0000\x00", "\x00\x00\x00" ); + + std::string s; + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\\\\\", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\x", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\xx", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\xa", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\x1", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\x1h", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "a\\", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "a\\x", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "a\\xx", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "a\\xa", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "a\\x1", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "a\\x1h", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\a", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\_", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\z", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\1", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\a00", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\_1111", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\z22222222", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\13333333333333333", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\u", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\uu", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\uuuu", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\u123", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\u999", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\u444h", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\j", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\ju", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\juuu", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\j123", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\j999", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\j444h", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\U00110000", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\U80000000", s ); + verify_fail< unstring, unaction >( __LINE__, __FILE__, "\\Uffffffff", s ); + } + +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/contrib_uri.cpp b/packages/PEGTL/src/test/pegtl/contrib_uri.cpp index 7d502a843..e9317f8ce 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" @@ -8,39 +8,35 @@ #include <tao/pegtl/contrib/uri.hpp> -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + using GRAMMAR = must< uri::URI, eof >; + + void unit_test() { - using GRAMMAR = must< uri::URI, eof >; - - void unit_test() - { - verify_analyze< GRAMMAR >( __LINE__, __FILE__, true, false ); - - verify_rule< GRAMMAR >( __LINE__, __FILE__, "http://de.wikipedia.org/wiki/Uniform_Resource_Identifier", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "ftp://ftp.is.co.za/rfc/rfc1808.txt", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "file:///C:/Users/Benutzer/Desktop/Uniform%20Resource%20Identifier.html", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "file:///etc/fstab", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "geo:48.33,14.122;u=22.5", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "ldap://[2001:db8::7]/c=GB?objectClass?one", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "gopher://gopher.floodgap.com", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "mailto:John.Doe@example.com", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "sip:911@pbx.mycompany.com", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "news:comp.infosystems.www.servers.unix", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "data:text/plain;charset=iso-8859-7,%be%fa%be", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "tel:+1-816-555-1212", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "telnet://192.0.2.16:80/", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "urn:oasis:names:specification:docbook:dtd:xml:4.1.2", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "git://github.com/rails/rails.git", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "crid://broadcaster.com/movies/BestActionMovieEver", result_type::SUCCESS, 0 ); - verify_rule< GRAMMAR >( __LINE__, __FILE__, "http://nobody:password@example.org:8080/cgi-bin/script.php?action=submit&pageid=86392001#section_2", result_type::SUCCESS, 0 ); - - verify_fail< GRAMMAR >( __LINE__, __FILE__, "" ); - } - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + verify_analyze< GRAMMAR >( __LINE__, __FILE__, true, false ); + + verify_rule< GRAMMAR >( __LINE__, __FILE__, "http://de.wikipedia.org/wiki/Uniform_Resource_Identifier", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "ftp://ftp.is.co.za/rfc/rfc1808.txt", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "file:///C:/Users/Benutzer/Desktop/Uniform%20Resource%20Identifier.html", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "file:///etc/fstab", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "geo:48.33,14.122;u=22.5", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "ldap://[2001:db8::7]/c=GB?objectClass?one", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "gopher://gopher.floodgap.com", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "mailto:John.Doe@example.com", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "sip:911@pbx.mycompany.com", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "news:comp.infosystems.www.servers.unix", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "data:text/plain;charset=iso-8859-7,%be%fa%be", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "tel:+1-816-555-1212", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "telnet://192.0.2.16:80/", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "urn:oasis:names:specification:docbook:dtd:xml:4.1.2", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "git://github.com/rails/rails.git", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "crid://broadcaster.com/movies/BestActionMovieEver", result_type::success, 0 ); + verify_rule< GRAMMAR >( __LINE__, __FILE__, "http://nobody:password@example.org:8080/cgi-bin/script.php?action=submit&pageid=86392001#section_2", result_type::success, 0 ); + + verify_fail< GRAMMAR >( __LINE__, __FILE__, "" ); + } + +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/data/blns.json b/packages/PEGTL/src/test/pegtl/data/blns.json old mode 100755 new mode 100644 diff --git a/packages/PEGTL/src/test/pegtl/data_cstring.cpp b/packages/PEGTL/src/test/pegtl/data_cstring.cpp index 978a1af36..9828c35f5 100644 --- a/packages/PEGTL/src/test/pegtl/data_cstring.cpp +++ b/packages/PEGTL/src/test/pegtl/data_cstring.cpp @@ -1,37 +1,31 @@ -// Copyright (c) 2016-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include <tao/pegtl/internal/cstring_reader.hpp> -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + template< typename Rule, + template< typename... > class Action = nothing, + template< typename... > class Control = normal > + bool parse_cstring( const char* string, const char* source, const std::size_t maximum ) { - template< typename Rule, - template< typename... > class Action = nothing, - template< typename... > class Control = normal, - typename... States > - bool parse_cstring( const char* string, const char* source, const std::size_t maximum, States&&... st ) - { - buffer_input< internal::cstring_reader > in( source, maximum, string ); - return parse< Rule, Action, Control >( in, st... ); - } + buffer_input< internal::cstring_reader > in( source, maximum, string ); + return parse< Rule, Action, Control >( in ); + } - struct test_grammar : seq< string< 'a', 'b' >, discard, string< 'c', 'd' >, discard, any, any, discard, eof > - { - }; - - void unit_test() - { - const char* test_data = "abcdef"; - TAO_PEGTL_TEST_ASSERT( parse_cstring< test_grammar >( test_data, "test data", 2 ) ); - TAO_PEGTL_TEST_ASSERT( !parse_cstring< test_grammar >( test_data, "test data", 1 ) ); - } + struct test_grammar : seq< string< 'a', 'b', 'c', 'd', 'e', 'f' >, not_at< any >, eof > + { + }; - } // namespace TAO_PEGTL_NAMESPACE + void unit_test() + { + TAO_PEGTL_TEST_ASSERT( parse_cstring< test_grammar >( "abcdef", "test data", 10 ) ); + TAO_PEGTL_TEST_ASSERT( parse_cstring< test_grammar >( "abcdef\0g", "test data", 10 ) ); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/demangle.cpp b/packages/PEGTL/src/test/pegtl/demangle.cpp index 526724dc8..a83296d59 100644 --- a/packages/PEGTL/src/test/pegtl/demangle.cpp +++ b/packages/PEGTL/src/test/pegtl/demangle.cpp @@ -1,39 +1,35 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include <tao/pegtl/internal/demangle_sanitise.hpp> -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void test_chars( std::string a, const std::string& b ) { - void test_chars( std::string a, const std::string& b ) - { - internal::demangle_sanitise_chars( a ); - TAO_PEGTL_TEST_ASSERT( a == b ); - } + internal::demangle_sanitise_chars( a ); + TAO_PEGTL_TEST_ASSERT( a == b ); + } - void unit_test() - { - const std::string s = "something that can't be demangled"; - const std::string a = internal::demangle( s.c_str() ); - TAO_PEGTL_TEST_ASSERT( a == s ); - const std::string b = internal::demangle< std::string >(); - (void)b; // Not standardised. - - test_chars( "zzz(char)1xxx", "zzz1xxx" ); - test_chars( "zzz(char)32xxx", "zzz' 'xxx" ); - test_chars( "zzz(char)48xxx", "zzz'0'xxx" ); - test_chars( "zzz(char)39xxx", "zzz'\\''xxx" ); - test_chars( "zzz(char)92xxx", "zzz'\\\\'xxx" ); - test_chars( "frobnicate<> (char)1 (char)32 (char)48 ***", "frobnicate<> 1 ' ' '0' ***" ); - test_chars( "tao::pegtl::internal::until<tao::pegtl::at<tao::pegtl::ascii::one<(char)34> >", "tao::pegtl::internal::until<tao::pegtl::at<tao::pegtl::ascii::one<'\"'> >" ); - } - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + void unit_test() + { + const std::string s = "something that can't be demangled"; + const std::string a = internal::demangle( s.c_str() ); + TAO_PEGTL_TEST_ASSERT( a == s ); + const std::string b = internal::demangle< std::string >(); + (void)b; // Not standardised. + + test_chars( "zzz(char)1xxx", "zzz1xxx" ); + test_chars( "zzz(char)32xxx", "zzz' 'xxx" ); + test_chars( "zzz(char)48xxx", "zzz'0'xxx" ); + test_chars( "zzz(char)39xxx", "zzz'\\''xxx" ); + test_chars( "zzz(char)92xxx", "zzz'\\\\'xxx" ); + test_chars( "frobnicate<> (char)1 (char)32 (char)48 ***", "frobnicate<> 1 ' ' '0' ***" ); + test_chars( "tao::pegtl::internal::until<tao::pegtl::at<tao::pegtl::ascii::one<(char)34> >", "tao::pegtl::internal::until<tao::pegtl::at<tao::pegtl::ascii::one<'\"'> >" ); + } + +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/discard_input.cpp b/packages/PEGTL/src/test/pegtl/discard_input.cpp new file mode 100644 index 000000000..b693db506 --- /dev/null +++ b/packages/PEGTL/src/test/pegtl/discard_input.cpp @@ -0,0 +1,56 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#include <string> + +#include "test.hpp" + +#include <tao/pegtl/internal/cstring_reader.hpp> + +namespace TAO_PEGTL_NAMESPACE +{ + template< typename Rule, template< typename... > class Action > + bool parse_cstring( const char* string, const char* source, const std::size_t maximum ) + { + buffer_input< internal::cstring_reader, eol::lf_crlf, const char*, 1 > in( source, maximum, string ); + return parse< Rule, Action >( in ); + } + + // clang-format off + struct n : one< 'n' > {}; + struct a : one< 'a' > {}; + struct f : one< 'f' > {}; + struct s : one< 's' > {}; + + template< typename Rule > struct my_action {}; + template<> struct my_action< a > : discard_input {}; + template<> struct my_action< f > : discard_input_on_failure {}; + template<> struct my_action< s > : discard_input_on_success {}; + // clang-format on + + void unit_test() + { + TAO_PEGTL_TEST_THROWS( parse_cstring< rep< 4, sor< n, n > >, my_action >( "nnnn", TAO_TEST_LINE, 2 ) ); + TAO_PEGTL_TEST_ASSERT( parse_cstring< rep< 4, sor< a, n > >, my_action >( "nnnn", TAO_TEST_LINE, 2 ) ); + TAO_PEGTL_TEST_ASSERT( parse_cstring< rep< 4, sor< f, n > >, my_action >( "nnnn", TAO_TEST_LINE, 2 ) ); + TAO_PEGTL_TEST_THROWS( parse_cstring< rep< 4, sor< s, n > >, my_action >( "nnnn", TAO_TEST_LINE, 2 ) ); + + TAO_PEGTL_TEST_ASSERT( parse_cstring< rep< 4, sor< n, a > >, my_action >( "aaaa", TAO_TEST_LINE, 2 ) ); + TAO_PEGTL_TEST_ASSERT( parse_cstring< rep< 4, sor< a, a > >, my_action >( "aaaa", TAO_TEST_LINE, 2 ) ); + TAO_PEGTL_TEST_ASSERT( parse_cstring< rep< 4, sor< f, a > >, my_action >( "aaaa", TAO_TEST_LINE, 2 ) ); + TAO_PEGTL_TEST_ASSERT( parse_cstring< rep< 4, sor< s, a > >, my_action >( "aaaa", TAO_TEST_LINE, 2 ) ); + + TAO_PEGTL_TEST_THROWS( parse_cstring< rep< 4, sor< n, f > >, my_action >( "ffff", TAO_TEST_LINE, 2 ) ); + TAO_PEGTL_TEST_ASSERT( parse_cstring< rep< 4, sor< a, f > >, my_action >( "ffff", TAO_TEST_LINE, 2 ) ); + TAO_PEGTL_TEST_THROWS( parse_cstring< rep< 4, sor< f, f > >, my_action >( "ffff", TAO_TEST_LINE, 2 ) ); + TAO_PEGTL_TEST_THROWS( parse_cstring< rep< 4, sor< s, f > >, my_action >( "ffff", TAO_TEST_LINE, 2 ) ); + + TAO_PEGTL_TEST_ASSERT( parse_cstring< rep< 4, sor< n, s > >, my_action >( "ssss", TAO_TEST_LINE, 2 ) ); + TAO_PEGTL_TEST_ASSERT( parse_cstring< rep< 4, sor< a, s > >, my_action >( "ssss", TAO_TEST_LINE, 2 ) ); + TAO_PEGTL_TEST_ASSERT( parse_cstring< rep< 4, sor< f, s > >, my_action >( "ssss", TAO_TEST_LINE, 2 ) ); + TAO_PEGTL_TEST_ASSERT( parse_cstring< rep< 4, sor< s, s > >, my_action >( "ssss", TAO_TEST_LINE, 2 ) ); + } + +} // namespace TAO_PEGTL_NAMESPACE + +#include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/file_cstream.cpp b/packages/PEGTL/src/test/pegtl/file_cstream.cpp index e06b6e2d2..0560a33e9 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <clocale> @@ -6,34 +6,30 @@ #include "test.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + struct file_content : seq< TAO_PEGTL_STRING( "dummy content" ), eol, discard > { - struct file_content : seq< TAO_PEGTL_STRING( "dummy content" ), eol, discard > - { - }; + }; - struct file_grammar : seq< rep_min_max< 11, 11, file_content >, eof > - { - }; + struct file_grammar : seq< rep_min_max< 11, 11, file_content >, eof > + { + }; - void unit_test() - { - const char* const filename = "src/test/pegtl/file_data.txt"; + void unit_test() + { + const char* const filename = "src/test/pegtl/file_data.txt"; #if defined( _MSC_VER ) - std::FILE* stream; - ::fopen_s( &stream, filename, "rb" ); // NOLINT + std::FILE* stream; + ::fopen_s( &stream, filename, "rb" ); // NOLINT #else - std::FILE* stream = std::fopen( filename, "rb" ); // NOLINT + std::FILE* stream = std::fopen( filename, "rb" ); // NOLINT #endif - TAO_PEGTL_TEST_ASSERT( stream != nullptr ); - TAO_PEGTL_TEST_ASSERT( parse< file_grammar >( cstream_input<>( stream, 16, filename ) ) ); - std::fclose( stream ); // NOLINT(cppcoreguidelines-owning-memory) - } - - } // namespace TAO_PEGTL_NAMESPACE + TAO_PEGTL_TEST_ASSERT( stream != nullptr ); + TAO_PEGTL_TEST_ASSERT( parse< file_grammar >( cstream_input( stream, 16, filename ) ) ); + std::fclose( stream ); // NOLINT(cppcoreguidelines-owning-memory) + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/file_file.cpp b/packages/PEGTL/src/test/pegtl/file_file.cpp index 73af0546e..4e7da9535 100644 --- a/packages/PEGTL/src/test/pegtl/file_file.cpp +++ b/packages/PEGTL/src/test/pegtl/file_file.cpp @@ -1,20 +1,16 @@ -// Copyright (c) 2015-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_file.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_file< file_input<> >(); - } + verify_file< file_input<> >(); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/file_istream.cpp b/packages/PEGTL/src/test/pegtl/file_istream.cpp index b1938e439..b4862f25f 100644 --- a/packages/PEGTL/src/test/pegtl/file_istream.cpp +++ b/packages/PEGTL/src/test/pegtl/file_istream.cpp @@ -1,40 +1,41 @@ -// Copyright (c) 2016-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ +#include <cerrno> #include <fstream> #include "test.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + struct file_content : seq< TAO_PEGTL_STRING( "dummy content" ), eol, discard > { - struct file_content : seq< TAO_PEGTL_STRING( "dummy content" ), eol, discard > - { - }; + }; - struct file_grammar : seq< rep_min_max< 11, 11, file_content >, eof > - { - }; + struct file_grammar : seq< rep_min_max< 11, 11, file_content >, eof > + { + }; - void unit_test() + void unit_test() + { { + const char* filename = "src/test/pegtl/no_such_file.txt"; try { - const char* filename = "src/test/pegtl/no_such_file.txt"; std::ifstream stream( filename ); - parse< file_grammar >( istream_input<>( stream, 16, filename ) ); + parse< file_grammar >( istream_input( stream, 16, filename ) ); TAO_PEGTL_TEST_ASSERT( false ); } - catch( const input_error& e ) { - TAO_PEGTL_TEST_ASSERT( std::string( e.what() ).find( "error in istream.read()" ) != std::string::npos ); + catch( const std::system_error& e ) { + TAO_PEGTL_TEST_ASSERT( e.code().category() == std::system_category() ); + TAO_PEGTL_TEST_ASSERT( e.code().value() == ENOENT ); } - const char* filename = "src/test/pegtl/file_data.txt"; - std::ifstream stream( filename ); - TAO_PEGTL_TEST_ASSERT( parse< file_grammar >( istream_input<>( stream, 16, filename ) ) ); } - } // namespace TAO_PEGTL_NAMESPACE + const char* filename = "src/test/pegtl/file_data.txt"; + std::ifstream stream( filename ); + TAO_PEGTL_TEST_ASSERT( parse< file_grammar >( istream_input( stream, 16, filename ) ) ); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/file_mmap.cpp b/packages/PEGTL/src/test/pegtl/file_mmap.cpp index 4320bb005..c7297c187 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ // this include gives us _POSIX_MAPPED_FILES to test and mmap_input<> if it is set @@ -9,18 +9,14 @@ #include "test.hpp" #include "verify_file.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_file< mmap_input<> >(); - } + verify_file< mmap_input<> >(); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/file_read.cpp b/packages/PEGTL/src/test/pegtl/file_read.cpp index 2178cacbc..85bd80d53 100644 --- a/packages/PEGTL/src/test/pegtl/file_read.cpp +++ b/packages/PEGTL/src/test/pegtl/file_read.cpp @@ -1,36 +1,32 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_file.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + template< tracking_mode P = tracking_mode::eager, typename Eol = eol::lf_crlf > + struct open_input + : public read_input< P, Eol > { - template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf > - struct open_input - : public read_input< P, Eol > + explicit open_input( const char* in_filename ) + : read_input< P, Eol >( internal::file_open( in_filename ), in_filename ) { - explicit open_input( const char* in_filename ) - : read_input< P, Eol >( internal::file_open( in_filename ), in_filename ) - { - } - - explicit open_input( const std::string& in_filename ) - : open_input( in_filename.c_str() ) - { - } - }; + } - void unit_test() + explicit open_input( const std::string& in_filename ) + : open_input( in_filename.c_str() ) { - verify_file< read_input<> >(); - verify_file< open_input<> >(); } + }; - } // namespace TAO_PEGTL_NAMESPACE + void unit_test() + { + verify_file< read_input<> >(); + verify_file< open_input<> >(); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/internal_endian.cpp b/packages/PEGTL/src/test/pegtl/internal_endian.cpp index 1b0629421..0dcfa983f 100644 --- a/packages/PEGTL/src/test/pegtl/internal_endian.cpp +++ b/packages/PEGTL/src/test/pegtl/internal_endian.cpp @@ -1,86 +1,82 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <tao/pegtl/internal/endian.hpp> #include "test.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::int8_t( 0x7a ) ) == std::int8_t( 0x7a ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::uint8_t( 0x7a ) ) == std::uint8_t( 0x7a ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::int8_t( 0x7a ) ) == std::int8_t( 0x7a ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::uint8_t( 0x7a ) ) == std::uint8_t( 0x7a ) ); - TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::int8_t( 0x7a ) ) == std::int8_t( 0x7a ) ); - TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::uint8_t( 0x7a ) ) == std::uint8_t( 0x7a ) ); - TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::int8_t( 0x7a ) ) == std::int8_t( 0x7a ) ); - TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::uint8_t( 0x7a ) ) == std::uint8_t( 0x7a ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::int8_t( 0x7a ) ) == std::int8_t( 0x7a ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::uint8_t( 0x7a ) ) == std::uint8_t( 0x7a ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::int8_t( 0x7a ) ) == std::int8_t( 0x7a ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::uint8_t( 0x7a ) ) == std::uint8_t( 0x7a ) ); + TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::int8_t( 0x7a ) ) == std::int8_t( 0x7a ) ); + TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::uint8_t( 0x7a ) ) == std::uint8_t( 0x7a ) ); + TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::int8_t( 0x7a ) ) == std::int8_t( 0x7a ) ); + TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::uint8_t( 0x7a ) ) == std::uint8_t( 0x7a ) ); - const std::uint16_t a = 1; - if( *static_cast< const std::uint8_t* >( static_cast< const void* >( &a ) ) != 1 ) { - TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::int16_t( 0x7a39 ) ) == std::int16_t( 0x7a39 ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::uint16_t( 0x7a39 ) ) == std::uint16_t( 0x7a39 ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::int16_t( 0x7a39 ) ) == std::int16_t( 0x397a ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::uint16_t( 0x7a39 ) ) == std::uint16_t( 0x397a ) ); - TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::int16_t( 0x7a39 ) ) == std::int16_t( 0x7a39 ) ); - TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::uint16_t( 0x7a39 ) ) == std::uint16_t( 0x7a39 ) ); - TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::int16_t( 0x7a39 ) ) == std::int16_t( 0x397a ) ); - TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::uint16_t( 0x7a39 ) ) == std::uint16_t( 0x397a ) ); + const std::uint16_t a = 1; + if( *static_cast< const std::uint8_t* >( static_cast< const void* >( &a ) ) != 1 ) { + TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::int16_t( 0x7a39 ) ) == std::int16_t( 0x7a39 ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::uint16_t( 0x7a39 ) ) == std::uint16_t( 0x7a39 ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::int16_t( 0x7a39 ) ) == std::int16_t( 0x397a ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::uint16_t( 0x7a39 ) ) == std::uint16_t( 0x397a ) ); + TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::int16_t( 0x7a39 ) ) == std::int16_t( 0x7a39 ) ); + TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::uint16_t( 0x7a39 ) ) == std::uint16_t( 0x7a39 ) ); + TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::int16_t( 0x7a39 ) ) == std::int16_t( 0x397a ) ); + TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::uint16_t( 0x7a39 ) ) == std::uint16_t( 0x397a ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::int32_t( 0x7a391f2b ) ) == std::int32_t( 0x7a391f2b ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::uint32_t( 0x7a391f2b ) ) == std::uint32_t( 0x7a391f2b ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::int32_t( 0x7a391f2b ) ) == std::int32_t( 0x2b1f397a ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::uint32_t( 0x7a391f2b ) ) == std::uint32_t( 0x2b1f397a ) ); - TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::int32_t( 0x7a391f2b ) ) == std::int32_t( 0x7a391f2b ) ); - TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::uint32_t( 0x7a391f2b ) ) == std::uint32_t( 0x7a391f2b ) ); - TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::int32_t( 0x7a391f2b ) ) == std::int32_t( 0x2b1f397a ) ); - TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::uint32_t( 0x7a391f2b ) ) == std::uint32_t( 0x2b1f397a ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::int32_t( 0x7a391f2b ) ) == std::int32_t( 0x7a391f2b ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::uint32_t( 0x7a391f2b ) ) == std::uint32_t( 0x7a391f2b ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::int32_t( 0x7a391f2b ) ) == std::int32_t( 0x2b1f397a ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::uint32_t( 0x7a391f2b ) ) == std::uint32_t( 0x2b1f397a ) ); + TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::int32_t( 0x7a391f2b ) ) == std::int32_t( 0x7a391f2b ) ); + TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::uint32_t( 0x7a391f2b ) ) == std::uint32_t( 0x7a391f2b ) ); + TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::int32_t( 0x7a391f2b ) ) == std::int32_t( 0x2b1f397a ) ); + TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::uint32_t( 0x7a391f2b ) ) == std::uint32_t( 0x2b1f397a ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::int64_t( 0x7a391f2b33445567 ) ) == std::int64_t( 0x7a391f2b33445567 ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::uint64_t( 0x7a391f2b33445567 ) ) == std::uint64_t( 0x7a391f2b33445567 ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::int64_t( 0x7a391f2b33445567 ) ) == std::int64_t( 0x675544332b1f397a ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::uint64_t( 0x7a391f2b33445567 ) ) == std::uint64_t( 0x675544332b1f397a ) ); - TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::int64_t( 0x7a391f2b33445567 ) ) == std::int64_t( 0x7a391f2b33445567 ) ); - TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::uint64_t( 0x7a391f2b33445567 ) ) == std::uint64_t( 0x7a391f2b33445567 ) ); - TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::int64_t( 0x7a391f2b33445567 ) ) == std::int64_t( 0x675544332b1f397a ) ); - TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::uint64_t( 0x7a391f2b33445567 ) ) == std::uint64_t( 0x675544332b1f397a ) ); - } - else { - TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::int16_t( 0x7a39 ) ) == std::int16_t( 0x7a39 ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::uint16_t( 0x7a39 ) ) == std::uint16_t( 0x7a39 ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::int16_t( 0x7a39 ) ) == std::int16_t( 0x397a ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::uint16_t( 0x7a39 ) ) == std::uint16_t( 0x397a ) ); - TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::int16_t( 0x7a39 ) ) == std::int16_t( 0x7a39 ) ); - TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::uint16_t( 0x7a39 ) ) == std::uint16_t( 0x7a39 ) ); - TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::int16_t( 0x7a39 ) ) == std::int16_t( 0x397a ) ); - TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::uint16_t( 0x7a39 ) ) == std::uint16_t( 0x397a ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::int64_t( 0x7a391f2b33445567 ) ) == std::int64_t( 0x7a391f2b33445567 ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::uint64_t( 0x7a391f2b33445567 ) ) == std::uint64_t( 0x7a391f2b33445567 ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::int64_t( 0x7a391f2b33445567 ) ) == std::int64_t( 0x675544332b1f397a ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::uint64_t( 0x7a391f2b33445567 ) ) == std::uint64_t( 0x675544332b1f397a ) ); + TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::int64_t( 0x7a391f2b33445567 ) ) == std::int64_t( 0x7a391f2b33445567 ) ); + TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::uint64_t( 0x7a391f2b33445567 ) ) == std::uint64_t( 0x7a391f2b33445567 ) ); + TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::int64_t( 0x7a391f2b33445567 ) ) == std::int64_t( 0x675544332b1f397a ) ); + TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::uint64_t( 0x7a391f2b33445567 ) ) == std::uint64_t( 0x675544332b1f397a ) ); + } + else { + TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::int16_t( 0x7a39 ) ) == std::int16_t( 0x7a39 ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::uint16_t( 0x7a39 ) ) == std::uint16_t( 0x7a39 ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::int16_t( 0x7a39 ) ) == std::int16_t( 0x397a ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::uint16_t( 0x7a39 ) ) == std::uint16_t( 0x397a ) ); + TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::int16_t( 0x7a39 ) ) == std::int16_t( 0x7a39 ) ); + TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::uint16_t( 0x7a39 ) ) == std::uint16_t( 0x7a39 ) ); + TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::int16_t( 0x7a39 ) ) == std::int16_t( 0x397a ) ); + TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::uint16_t( 0x7a39 ) ) == std::uint16_t( 0x397a ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::int32_t( 0x7a391f2b ) ) == std::int32_t( 0x7a391f2b ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::uint32_t( 0x7a391f2b ) ) == std::uint32_t( 0x7a391f2b ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::int32_t( 0x7a391f2b ) ) == std::int32_t( 0x2b1f397a ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::uint32_t( 0x7a391f2b ) ) == std::uint32_t( 0x2b1f397a ) ); - TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::int32_t( 0x7a391f2b ) ) == std::int32_t( 0x7a391f2b ) ); - TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::uint32_t( 0x7a391f2b ) ) == std::uint32_t( 0x7a391f2b ) ); - TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::int32_t( 0x7a391f2b ) ) == std::int32_t( 0x2b1f397a ) ); - TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::uint32_t( 0x7a391f2b ) ) == std::uint32_t( 0x2b1f397a ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::int32_t( 0x7a391f2b ) ) == std::int32_t( 0x7a391f2b ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::uint32_t( 0x7a391f2b ) ) == std::uint32_t( 0x7a391f2b ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::int32_t( 0x7a391f2b ) ) == std::int32_t( 0x2b1f397a ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::uint32_t( 0x7a391f2b ) ) == std::uint32_t( 0x2b1f397a ) ); + TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::int32_t( 0x7a391f2b ) ) == std::int32_t( 0x7a391f2b ) ); + TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::uint32_t( 0x7a391f2b ) ) == std::uint32_t( 0x7a391f2b ) ); + TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::int32_t( 0x7a391f2b ) ) == std::int32_t( 0x2b1f397a ) ); + TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::uint32_t( 0x7a391f2b ) ) == std::uint32_t( 0x2b1f397a ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::int64_t( 0x7a391f2b33445567 ) ) == std::int64_t( 0x7a391f2b33445567 ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::uint64_t( 0x7a391f2b33445567 ) ) == std::uint64_t( 0x7a391f2b33445567 ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::int64_t( 0x7a391f2b33445567 ) ) == std::int64_t( 0x675544332b1f397a ) ); - TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::uint64_t( 0x7a391f2b33445567 ) ) == std::uint64_t( 0x675544332b1f397a ) ); - TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::int64_t( 0x7a391f2b33445567 ) ) == std::int64_t( 0x7a391f2b33445567 ) ); - TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::uint64_t( 0x7a391f2b33445567 ) ) == std::uint64_t( 0x7a391f2b33445567 ) ); - TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::int64_t( 0x7a391f2b33445567 ) ) == std::int64_t( 0x675544332b1f397a ) ); - TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::uint64_t( 0x7a391f2b33445567 ) ) == std::uint64_t( 0x675544332b1f397a ) ); - } + TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::int64_t( 0x7a391f2b33445567 ) ) == std::int64_t( 0x7a391f2b33445567 ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_le( std::uint64_t( 0x7a391f2b33445567 ) ) == std::uint64_t( 0x7a391f2b33445567 ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::int64_t( 0x7a391f2b33445567 ) ) == std::int64_t( 0x675544332b1f397a ) ); + TAO_PEGTL_TEST_ASSERT( internal::h_to_be( std::uint64_t( 0x7a391f2b33445567 ) ) == std::uint64_t( 0x675544332b1f397a ) ); + TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::int64_t( 0x7a391f2b33445567 ) ) == std::int64_t( 0x7a391f2b33445567 ) ); + TAO_PEGTL_TEST_ASSERT( internal::le_to_h( std::uint64_t( 0x7a391f2b33445567 ) ) == std::uint64_t( 0x7a391f2b33445567 ) ); + TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::int64_t( 0x7a391f2b33445567 ) ) == std::int64_t( 0x675544332b1f397a ) ); + TAO_PEGTL_TEST_ASSERT( internal::be_to_h( std::uint64_t( 0x7a391f2b33445567 ) ) == std::uint64_t( 0x675544332b1f397a ) ); } + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/internal_file_mapper.cpp b/packages/PEGTL/src/test/pegtl/internal_file_mapper.cpp index 5e6eb95c0..be408e037 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <tao/pegtl/file_input.hpp> @@ -7,28 +7,24 @@ #include "test.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - try { - internal::file_mapper dummy( "include" ); - std::cerr << "pegtl: unit test failed for [ internal::file_mapper ]" << std::endl; - ++failed; - } - catch( const input_error& ) { - } - catch( ... ) { - std::cerr << "pegtl: unit test failed for [ internal::file_mapper ] with unexpected exception" << std::endl; - ++failed; - } + try { + internal::file_mapper dummy( "include" ); + std::cerr << "pegtl: unit test failed for [ internal::file_mapper ]" << std::endl; + ++failed; } + catch( const std::system_error& e ) { + } + catch( ... ) { + std::cerr << "pegtl: unit test failed for [ internal::file_mapper ] with unexpected exception" << std::endl; + ++failed; + } + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/internal_file_opener.cpp b/packages/PEGTL/src/test/pegtl/internal_file_opener.cpp index a0641b8a5..aa1134b5a 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <tao/pegtl/file_input.hpp> @@ -7,26 +7,23 @@ #include "test.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - const internal::file_opener fo( "Makefile" ); - ::close( fo.m_fd ); // Provoke exception, nobody would normally do this. - try { - fo.size(); - std::cerr << "pegtl: unit test failed for [ internal::file_opener ] " << std::endl; - ++failed; - } - catch( const std::exception& ) { - } - } + const internal::file_opener fo( "Makefile" ); + ::close( fo.m_fd ); // Provoke exception, nobody would normally do this. + try { + (void)fo.size(); // expected to throw - } // namespace TAO_PEGTL_NAMESPACE + std::cerr << "pegtl: unit test failed for [ internal::file_opener ] " << std::endl; + ++failed; + } + catch( const std::exception& ) { + } + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/main.hpp b/packages/PEGTL/src/test/pegtl/main.hpp index 92a79e4fc..c72e13b03 100644 --- a/packages/PEGTL/src/test/pegtl/main.hpp +++ b/packages/PEGTL/src/test/pegtl/main.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_SRC_TEST_PEGTL_MAIN_HPP // NOLINT @@ -9,12 +9,12 @@ int main( int /*unused*/, char** argv ) { - tao::TAO_PEGTL_NAMESPACE::unit_test(); + TAO_PEGTL_NAMESPACE::unit_test(); - if( tao::TAO_PEGTL_NAMESPACE::failed != 0 ) { - std::cerr << "pegtl: unit test " << argv[ 0 ] << " failed " << tao::TAO_PEGTL_NAMESPACE::failed << std::endl; + if( TAO_PEGTL_NAMESPACE::failed != 0 ) { + std::cerr << "pegtl: unit test " << argv[ 0 ] << " failed " << TAO_PEGTL_NAMESPACE::failed << std::endl; } - return ( tao::TAO_PEGTL_NAMESPACE::failed == 0 ) ? EXIT_SUCCESS : EXIT_FAILURE; + return ( TAO_PEGTL_NAMESPACE::failed == 0 ) ? EXIT_SUCCESS : EXIT_FAILURE; } #endif diff --git a/packages/PEGTL/src/test/pegtl/pegtl_string_t.cpp b/packages/PEGTL/src/test/pegtl/pegtl_string_t.cpp index f8bde77e2..0a7c58439 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <type_traits> @@ -14,26 +14,25 @@ namespace test { }; - struct foobar : tao::TAO_PEGTL_NAMESPACE::sor< TAO_PEGTL_STRING( "foo" ), TAO_PEGTL_STRING( "bar" ) > + struct foobar : TAO_PEGTL_NAMESPACE::sor< TAO_PEGTL_STRING( "foo" ), TAO_PEGTL_STRING( "bar" ) > { }; - static_assert( std::is_same< TAO_PEGTL_STRING( "Hello" ), tao::TAO_PEGTL_NAMESPACE::string< 'H', 'e', 'l', 'l', 'o' > >::value, "TAO_PEGTL_STRING broken" ); - static_assert( !std::is_same< TAO_PEGTL_ISTRING( "Hello" ), tao::TAO_PEGTL_NAMESPACE::string< 'H', 'e', 'l', 'l', 'o' > >::value, "TAO_PEGTL_ISTRING broken" ); - static_assert( std::is_same< TAO_PEGTL_ISTRING( "Hello" ), tao::TAO_PEGTL_NAMESPACE::istring< 'H', 'e', 'l', 'l', 'o' > >::value, "TAO_PEGTL_ISTRING broken" ); + static_assert( std::is_same_v< TAO_PEGTL_STRING( "Hello" ), TAO_PEGTL_NAMESPACE::string< 'H', 'e', 'l', 'l', 'o' > > ); + static_assert( !std::is_same_v< TAO_PEGTL_ISTRING( "Hello" ), TAO_PEGTL_NAMESPACE::string< 'H', 'e', 'l', 'l', 'o' > > ); + static_assert( std::is_same_v< TAO_PEGTL_ISTRING( "Hello" ), TAO_PEGTL_NAMESPACE::istring< 'H', 'e', 'l', 'l', 'o' > > ); - static_assert( std::is_same< TAO_PEGTL_KEYWORD( "private" ), tao::TAO_PEGTL_NAMESPACE::keyword< 'p', 'r', 'i', 'v', 'a', 't', 'e' > >::value, "TAO_PEGTL_KEYWORD broken" ); + static_assert( std::is_same_v< TAO_PEGTL_KEYWORD( "private" ), TAO_PEGTL_NAMESPACE::keyword< 'p', 'r', 'i', 'v', 'a', 't', 'e' > > ); // Strings may even contain embedded nulls - static_assert( std::is_same< TAO_PEGTL_STRING( "Hello, w\0rld!" ), tao::TAO_PEGTL_NAMESPACE::string< 'H', 'e', 'l', 'l', 'o', ',', ' ', 'w', 0, 'r', 'l', 'd', '!' > >::value, "TAO_PEGTL_STRING broken" ); + static_assert( std::is_same_v< TAO_PEGTL_STRING( "Hello, w\0rld!" ), TAO_PEGTL_NAMESPACE::string< 'H', 'e', 'l', 'l', 'o', ',', ' ', 'w', 0, 'r', 'l', 'd', '!' > > ); // The strings currently have a maximum length of 512 characters. - using namespace tao::TAO_PEGTL_NAMESPACE::alphabet; // NOLINT - static_assert( std::is_same< TAO_PEGTL_STRING( "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz" ), - tao::TAO_PEGTL_NAMESPACE::string< a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z > >::value, - "TAO_PEGTL_STRING broken" ); + using namespace TAO_PEGTL_NAMESPACE::alphabet; // NOLINT + static_assert( std::is_same_v< TAO_PEGTL_STRING( "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz" ), + TAO_PEGTL_NAMESPACE::string< a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z > > ); } // namespace test diff --git a/packages/PEGTL/src/test/pegtl/position.cpp b/packages/PEGTL/src/test/pegtl/position.cpp index 2aa309c32..1ea3ed240 100644 --- a/packages/PEGTL/src/test/pegtl/position.cpp +++ b/packages/PEGTL/src/test/pegtl/position.cpp @@ -1,182 +1,174 @@ -// Copyright (c) 2016-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include <tao/pegtl/internal/cstring_reader.hpp> -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + struct buffer_input_t + : buffer_input< internal::cstring_reader > { - struct buffer_input_t - : buffer_input< internal::cstring_reader > + buffer_input_t( const std::string& in_string, const std::string& in_source ) + : buffer_input< internal::cstring_reader >( in_source, 42, in_string.c_str() ) { - buffer_input_t( const std::string& in_string, const std::string& in_source ) - : buffer_input< internal::cstring_reader >( in_source, 42, in_string.c_str() ) - { - } - }; - - template< typename Rule, typename Input = memory_input<> > - void test_matches_lf() - { - static const std::string s1 = "\n"; + } + }; - Input i1( s1, __FUNCTION__ ); + template< typename Rule, typename Input = memory_input<> > + void test_matches_lf() + { + static const std::string s1 = "\n"; - TAO_PEGTL_TEST_ASSERT( parse< Rule >( i1 ) ); - TAO_PEGTL_TEST_ASSERT( i1.line() == 2 ); - TAO_PEGTL_TEST_ASSERT( i1.byte_in_line() == 0 ); - } + Input i1( s1, __FUNCTION__ ); - template< typename Rule, typename Input = memory_input<> > - void test_matches_other( const std::string& s2 ) - { - TAO_PEGTL_TEST_ASSERT( s2.size() == 1 ); + TAO_PEGTL_TEST_ASSERT( parse< Rule >( i1 ) ); + TAO_PEGTL_TEST_ASSERT( i1.line() == 2 ); + TAO_PEGTL_TEST_ASSERT( i1.byte_in_line() == 0 ); + } - Input i2( s2, __FUNCTION__ ); + template< typename Rule, typename Input = memory_input<> > + void test_matches_other( const std::string& s2 ) + { + TAO_PEGTL_TEST_ASSERT( s2.size() == 1 ); - TAO_PEGTL_TEST_ASSERT( parse< Rule >( i2 ) ); - TAO_PEGTL_TEST_ASSERT( i2.line() == 1 ); - TAO_PEGTL_TEST_ASSERT( i2.byte_in_line() == 1 ); - } + Input i2( s2, __FUNCTION__ ); - template< typename Rule, typename Input = memory_input<> > - void test_mismatch( const std::string& s3 ) - { - TAO_PEGTL_TEST_ASSERT( s3.size() == 1 ); + TAO_PEGTL_TEST_ASSERT( parse< Rule >( i2 ) ); + TAO_PEGTL_TEST_ASSERT( i2.line() == 1 ); + TAO_PEGTL_TEST_ASSERT( i2.byte_in_line() == 1 ); + } - Input i3( s3, __FUNCTION__ ); + template< typename Rule, typename Input = memory_input<> > + void test_mismatch( const std::string& s3 ) + { + TAO_PEGTL_TEST_ASSERT( s3.size() == 1 ); - TAO_PEGTL_TEST_ASSERT( !parse< Rule >( i3 ) ); - TAO_PEGTL_TEST_ASSERT( i3.line() == 1 ); - TAO_PEGTL_TEST_ASSERT( i3.byte_in_line() == 0 ); - } + Input i3( s3, __FUNCTION__ ); - struct outer_grammar - : must< two< 'a' >, two< 'b' >, two< 'c' >, eof > - { - }; + TAO_PEGTL_TEST_ASSERT( !parse< Rule >( i3 ) ); + TAO_PEGTL_TEST_ASSERT( i3.line() == 1 ); + TAO_PEGTL_TEST_ASSERT( i3.byte_in_line() == 0 ); + } - struct inner_grammar - : must< one< 'd' >, two< 'e' >, eof > - { - }; + struct outer_grammar + : must< two< 'a' >, two< 'b' >, two< 'c' >, eof > + {}; - template< typename Rule > - struct outer_action - : nothing< Rule > - { - }; + struct inner_grammar + : must< one< 'd' >, two< 'e' >, eof > + {}; - template<> - struct outer_action< two< 'b' > > - { - template< typename Input > - static void apply( const Input& oi ) - { - const auto p = oi.position(); - TAO_PEGTL_TEST_ASSERT( p.source == "outer" ); - TAO_PEGTL_TEST_ASSERT( p.byte == 2 ); - TAO_PEGTL_TEST_ASSERT( p.line == 1 ); - TAO_PEGTL_TEST_ASSERT( p.byte_in_line == 2 ); - memory_input<> in( "dFF", "inner" ); - parse_nested< inner_grammar >( oi, in ); - } - }; - - template< typename Input = memory_input<> > - void test_nested() - { - try { - memory_input<> oi( "aabbcc", "outer" ); - parse< outer_grammar, outer_action >( oi ); - } - catch( const parse_error& e ) { - TAO_PEGTL_TEST_ASSERT( e.positions.size() == 2 ); - TAO_PEGTL_TEST_ASSERT( e.positions[ 0 ].source == "inner" ); - TAO_PEGTL_TEST_ASSERT( e.positions[ 0 ].byte == 1 ); - TAO_PEGTL_TEST_ASSERT( e.positions[ 0 ].line == 1 ); - TAO_PEGTL_TEST_ASSERT( e.positions[ 0 ].byte_in_line == 1 ); - TAO_PEGTL_TEST_ASSERT( e.positions[ 1 ].source == "outer" ); - TAO_PEGTL_TEST_ASSERT( e.positions[ 1 ].byte == 2 ); - TAO_PEGTL_TEST_ASSERT( e.positions[ 1 ].line == 1 ); - TAO_PEGTL_TEST_ASSERT( e.positions[ 1 ].byte_in_line == 2 ); - } - } + template< typename Rule > + struct outer_action + {}; - void unit_test() + template<> + struct outer_action< two< 'b' > > + { + template< typename Input > + static void apply( const Input& oi ) { - test_matches_lf< any >(); - test_matches_lf< any, buffer_input_t >(); - test_matches_other< any >( " " ); - test_matches_other< any, buffer_input_t >( " " ); - - test_matches_lf< one< '\n' > >(); - test_matches_lf< one< '\n' >, buffer_input_t >(); - test_mismatch< one< '\n' > >( " " ); - test_mismatch< one< '\n' >, buffer_input_t >( " " ); - - test_matches_lf< one< ' ', '\n' > >(); - test_matches_lf< one< ' ', '\n' >, buffer_input_t >(); - test_matches_other< one< ' ', '\n' > >( " " ); - test_matches_other< one< ' ', '\n' >, buffer_input_t >( " " ); - - test_matches_lf< one< ' ', '\n', 'b' > >(); - test_matches_lf< one< ' ', '\n', 'b' >, buffer_input_t >(); - test_matches_other< one< ' ', '\n', 'b' > >( " " ); - test_matches_other< one< ' ', '\n', 'b' >, buffer_input_t >( " " ); - - test_matches_lf< string< '\n' > >(); - test_matches_lf< string< '\n' >, buffer_input_t >(); - test_mismatch< string< '\n' > >( " " ); - test_mismatch< string< '\n' >, buffer_input_t >( " " ); - - test_matches_other< string< ' ' > >( " " ); - test_matches_other< string< ' ' >, buffer_input_t >( " " ); - test_mismatch< string< ' ' > >( "\n" ); - test_mismatch< string< ' ' >, buffer_input_t >( "\n" ); - - test_matches_lf< range< 8, 33 > >(); - test_matches_lf< range< 8, 33 >, buffer_input_t >(); - test_matches_other< range< 8, 33 > >( " " ); - test_matches_other< range< 8, 33 >, buffer_input_t >( " " ); - - test_mismatch< range< 11, 30 > >( "\n" ); - test_mismatch< range< 11, 30 >, buffer_input_t >( "\n" ); - test_mismatch< range< 11, 30 > >( " " ); - test_mismatch< range< 11, 30 >, buffer_input_t >( " " ); - - test_matches_lf< not_range< 20, 30 > >(); - test_matches_lf< not_range< 20, 30 >, buffer_input_t >(); - test_matches_other< not_range< 20, 30 > >( " " ); - test_matches_other< not_range< 20, 30 >, buffer_input_t >( " " ); - - test_mismatch< not_range< 5, 35 > >( "\n" ); - test_mismatch< not_range< 5, 35 >, buffer_input_t >( "\n" ); - test_mismatch< not_range< 5, 35 > >( " " ); - test_mismatch< not_range< 5, 35 >, buffer_input_t >( " " ); - - test_matches_lf< ranges< 'a', 'z', 8, 33, 'A', 'Z' > >(); - test_matches_lf< ranges< 'a', 'z', 8, 33, 'A', 'Z' >, buffer_input_t >(); - test_matches_other< ranges< 'a', 'z', 8, 33, 'A', 'Z' > >( "N" ); - test_mismatch< ranges< 'a', 'z', 8, 33, 'A', 'Z' > >( "9" ); - test_mismatch< ranges< 'a', 'z', 8, 33, 'A', 'Z' >, buffer_input_t >( "9" ); - - test_matches_lf< ranges< 'a', 'z', 'A', 'Z', '\n' > >(); - test_matches_lf< ranges< 'a', 'z', 'A', 'Z', '\n' >, buffer_input_t >(); - test_matches_other< ranges< 'a', 'z', 'A', 'Z', '\n' > >( "P" ); - test_matches_other< ranges< 'a', 'z', 'A', 'Z', '\n' >, buffer_input_t >( "P" ); - test_mismatch< ranges< 'a', 'z', 'A', 'Z', '\n' > >( "8" ); - test_mismatch< ranges< 'a', 'z', 'A', 'Z', '\n' >, buffer_input_t >( "8" ); - - test_nested<>(); - test_nested< buffer_input_t >(); + const auto p = oi.position(); + TAO_PEGTL_TEST_ASSERT( p.source == "outer" ); + TAO_PEGTL_TEST_ASSERT( p.byte == 2 ); + TAO_PEGTL_TEST_ASSERT( p.line == 1 ); + TAO_PEGTL_TEST_ASSERT( p.byte_in_line == 2 ); + memory_input in( "dFF", "inner" ); + parse_nested< inner_grammar >( oi, in ); } + }; - } // namespace TAO_PEGTL_NAMESPACE + template< typename Input = memory_input<> > + void test_nested() + { + try { + memory_input oi( "aabbcc", "outer" ); + parse< outer_grammar, outer_action >( oi ); + } + catch( const parse_error& e ) { + TAO_PEGTL_TEST_ASSERT( e.positions.size() == 2 ); + TAO_PEGTL_TEST_ASSERT( e.positions[ 0 ].source == "inner" ); + TAO_PEGTL_TEST_ASSERT( e.positions[ 0 ].byte == 1 ); + TAO_PEGTL_TEST_ASSERT( e.positions[ 0 ].line == 1 ); + TAO_PEGTL_TEST_ASSERT( e.positions[ 0 ].byte_in_line == 1 ); + TAO_PEGTL_TEST_ASSERT( e.positions[ 1 ].source == "outer" ); + TAO_PEGTL_TEST_ASSERT( e.positions[ 1 ].byte == 2 ); + TAO_PEGTL_TEST_ASSERT( e.positions[ 1 ].line == 1 ); + TAO_PEGTL_TEST_ASSERT( e.positions[ 1 ].byte_in_line == 2 ); + } + } -} // namespace tao + void unit_test() + { + test_matches_lf< any >(); + test_matches_lf< any, buffer_input_t >(); + test_matches_other< any >( " " ); + test_matches_other< any, buffer_input_t >( " " ); + + test_matches_lf< one< '\n' > >(); + test_matches_lf< one< '\n' >, buffer_input_t >(); + test_mismatch< one< '\n' > >( " " ); + test_mismatch< one< '\n' >, buffer_input_t >( " " ); + + test_matches_lf< one< ' ', '\n' > >(); + test_matches_lf< one< ' ', '\n' >, buffer_input_t >(); + test_matches_other< one< ' ', '\n' > >( " " ); + test_matches_other< one< ' ', '\n' >, buffer_input_t >( " " ); + + test_matches_lf< one< ' ', '\n', 'b' > >(); + test_matches_lf< one< ' ', '\n', 'b' >, buffer_input_t >(); + test_matches_other< one< ' ', '\n', 'b' > >( " " ); + test_matches_other< one< ' ', '\n', 'b' >, buffer_input_t >( " " ); + + test_matches_lf< string< '\n' > >(); + test_matches_lf< string< '\n' >, buffer_input_t >(); + test_mismatch< string< '\n' > >( " " ); + test_mismatch< string< '\n' >, buffer_input_t >( " " ); + + test_matches_other< string< ' ' > >( " " ); + test_matches_other< string< ' ' >, buffer_input_t >( " " ); + test_mismatch< string< ' ' > >( "\n" ); + test_mismatch< string< ' ' >, buffer_input_t >( "\n" ); + + test_matches_lf< range< 8, 33 > >(); + test_matches_lf< range< 8, 33 >, buffer_input_t >(); + test_matches_other< range< 8, 33 > >( " " ); + test_matches_other< range< 8, 33 >, buffer_input_t >( " " ); + + test_mismatch< range< 11, 30 > >( "\n" ); + test_mismatch< range< 11, 30 >, buffer_input_t >( "\n" ); + test_mismatch< range< 11, 30 > >( " " ); + test_mismatch< range< 11, 30 >, buffer_input_t >( " " ); + + test_matches_lf< not_range< 20, 30 > >(); + test_matches_lf< not_range< 20, 30 >, buffer_input_t >(); + test_matches_other< not_range< 20, 30 > >( " " ); + test_matches_other< not_range< 20, 30 >, buffer_input_t >( " " ); + + test_mismatch< not_range< 5, 35 > >( "\n" ); + test_mismatch< not_range< 5, 35 >, buffer_input_t >( "\n" ); + test_mismatch< not_range< 5, 35 > >( " " ); + test_mismatch< not_range< 5, 35 >, buffer_input_t >( " " ); + + test_matches_lf< ranges< 'a', 'z', 8, 33, 'A', 'Z' > >(); + test_matches_lf< ranges< 'a', 'z', 8, 33, 'A', 'Z' >, buffer_input_t >(); + test_matches_other< ranges< 'a', 'z', 8, 33, 'A', 'Z' > >( "N" ); + test_mismatch< ranges< 'a', 'z', 8, 33, 'A', 'Z' > >( "9" ); + test_mismatch< ranges< 'a', 'z', 8, 33, 'A', 'Z' >, buffer_input_t >( "9" ); + + test_matches_lf< ranges< 'a', 'z', 'A', 'Z', '\n' > >(); + test_matches_lf< ranges< 'a', 'z', 'A', 'Z', '\n' >, buffer_input_t >(); + test_matches_other< ranges< 'a', 'z', 'A', 'Z', '\n' > >( "P" ); + test_matches_other< ranges< 'a', 'z', 'A', 'Z', '\n' >, buffer_input_t >( "P" ); + test_mismatch< ranges< 'a', 'z', 'A', 'Z', '\n' > >( "8" ); + test_mismatch< ranges< 'a', 'z', 'A', 'Z', '\n' >, buffer_input_t >( "8" ); + + test_nested<>(); + test_nested< buffer_input_t >(); + } + +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/result_type.hpp b/packages/PEGTL/src/test/pegtl/result_type.hpp index 804739134..1d5c89c4c 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_SRC_TEST_PEGTL_RESULT_TYPE_HPP // NOLINT @@ -8,32 +8,28 @@ #include <tao/pegtl/config.hpp> -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + enum class result_type { - enum class result_type - { - SUCCESS = 1, - LOCAL_FAILURE = 0, - GLOBAL_FAILURE = -1 - }; + success = 1, + local_failure = 0, + global_failure = -1 + }; - inline std::ostream& operator<<( std::ostream& o, const result_type t ) - { - switch( t ) { - case result_type::SUCCESS: - return o << "success"; - case result_type::LOCAL_FAILURE: - return o << "local failure"; - case result_type::GLOBAL_FAILURE: - return o << "global failure"; - } - return o << int( t ); + inline std::ostream& operator<<( std::ostream& o, const result_type t ) + { + switch( t ) { + case result_type::success: + return o << "success"; + case result_type::local_failure: + return o << "local failure"; + case result_type::global_failure: + return o << "global failure"; } + return o << int( t ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/src/test/pegtl/rule_action.cpp b/packages/PEGTL/src/test/pegtl/rule_action.cpp index 9c4dce78c..c7429f891 100644 --- a/packages/PEGTL/src/test/pegtl/rule_action.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_action.cpp @@ -1,23 +1,19 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_seqs.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE - { - template< typename... Rules > - using test_action_rule = action< nothing, Rules... >; - - void unit_test() - { - verify_seqs< test_action_rule >(); - } + template< typename... Rules > + using test_action_rule = action< nothing, Rules... >; - } // namespace TAO_PEGTL_NAMESPACE + void unit_test() + { + verify_seqs< test_action_rule >(); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_apply.cpp b/packages/PEGTL/src/test/pegtl/rule_apply.cpp index 4dab0a779..4f64066e6 100644 --- a/packages/PEGTL/src/test/pegtl/rule_apply.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_apply.cpp @@ -1,98 +1,94 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace test1 { - namespace test1 + struct action_a { - struct action_a + template< typename Input > + static void apply( const Input& /*unused*/, int& r, int& s ) { - template< typename Input > - static void apply( const Input& /*unused*/, int& r, int& s ) - { - TAO_PEGTL_TEST_ASSERT( !r ); - TAO_PEGTL_TEST_ASSERT( !s ); - r += 1; - } - }; + TAO_PEGTL_TEST_ASSERT( !r ); + TAO_PEGTL_TEST_ASSERT( !s ); + r += 1; + } + }; - struct action_b + struct action_b + { + template< typename Input > + static bool apply( const Input& /*unused*/, int& r, int& s ) { - template< typename Input > - static bool apply( const Input& /*unused*/, int& r, int& s ) - { - TAO_PEGTL_TEST_ASSERT( !s ); - TAO_PEGTL_TEST_ASSERT( r == 1 ); - s += 2; - return true; - } - }; + TAO_PEGTL_TEST_ASSERT( !s ); + TAO_PEGTL_TEST_ASSERT( r == 1 ); + s += 2; + return true; + } + }; - struct action2_a + struct action2_a + { + template< typename Input > + static void apply( const Input& /*unused*/, bool& state_b ) { - template< typename Input > - static void apply( const Input& /*unused*/, bool& state_b ) - { - TAO_PEGTL_TEST_ASSERT( !state_b ); - } - }; + TAO_PEGTL_TEST_ASSERT( !state_b ); + } + }; - struct action2_b + struct action2_b + { + template< typename Input > + static bool apply( const Input& /*unused*/, bool& state_b ) { - template< typename Input > - static bool apply( const Input& /*unused*/, bool& state_b ) - { - TAO_PEGTL_TEST_ASSERT( !state_b ); - state_b = true; - return false; - } - }; + TAO_PEGTL_TEST_ASSERT( !state_b ); + state_b = true; + return false; + } + }; - struct action2_c + struct action2_c + { + template< typename Input > + static void apply( const Input& /*unused*/, bool& /*unused*/ ) { - template< typename Input > - static void apply( const Input& /*unused*/, bool& /*unused*/ ) - { - TAO_PEGTL_TEST_ASSERT( false ); - } - }; + TAO_PEGTL_TEST_ASSERT( false ); + } + }; - } // namespace test1 + } // namespace test1 - void unit_test() - { - int state_r = 0; - int state_s = 0; - parse< must< apply< test1::action_a, test1::action_b > > >( memory_input<>( "", __FUNCTION__ ), state_r, state_s ); - TAO_PEGTL_TEST_ASSERT( state_r == 1 ); - TAO_PEGTL_TEST_ASSERT( state_s == 2 ); - parse< must< disable< apply< test1::action_a, test1::action_b > > > >( memory_input<>( "", __FUNCTION__ ), state_r, state_s ); - TAO_PEGTL_TEST_ASSERT( state_r == 1 ); - TAO_PEGTL_TEST_ASSERT( state_s == 2 ); + void unit_test() + { + int state_r = 0; + int state_s = 0; + parse< must< apply< test1::action_a, test1::action_b > > >( memory_input( "", __FUNCTION__ ), state_r, state_s ); + TAO_PEGTL_TEST_ASSERT( state_r == 1 ); + TAO_PEGTL_TEST_ASSERT( state_s == 2 ); + parse< must< disable< apply< test1::action_a, test1::action_b > > > >( memory_input( "", __FUNCTION__ ), state_r, state_s ); + TAO_PEGTL_TEST_ASSERT( state_r == 1 ); + TAO_PEGTL_TEST_ASSERT( state_s == 2 ); - bool state_b = false; - const bool result = parse< apply< test1::action2_a, test1::action2_b, test1::action2_c > >( memory_input<>( "", __FUNCTION__ ), state_b ); - TAO_PEGTL_TEST_ASSERT( !result ); - TAO_PEGTL_TEST_ASSERT( state_b ); + bool state_b = false; + const bool result = parse< apply< test1::action2_a, test1::action2_b, test1::action2_c > >( memory_input( "", __FUNCTION__ ), state_b ); + TAO_PEGTL_TEST_ASSERT( !result ); + TAO_PEGTL_TEST_ASSERT( state_b ); - verify_analyze< apply<> >( __LINE__, __FILE__, false, false ); + verify_analyze< apply<> >( __LINE__, __FILE__, false, false ); - verify_rule< apply<> >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); + verify_rule< apply<> >( __LINE__, __FILE__, "", result_type::success, 0 ); - for( char i = 1; i < 127; ++i ) { - char t[] = { i, 0 }; - verify_rule< apply<> >( __LINE__, __FILE__, std::string( t ), result_type::SUCCESS, 1 ); - } + for( char i = 1; i < 127; ++i ) { + char t[] = { i, 0 }; // NOLINT + verify_rule< apply<> >( __LINE__, __FILE__, std::string( t ), result_type::success, 1 ); } + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_apply0.cpp b/packages/PEGTL/src/test/pegtl/rule_apply0.cpp index 83dc519ce..e3b27ee2f 100644 --- a/packages/PEGTL/src/test/pegtl/rule_apply0.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_apply0.cpp @@ -1,93 +1,89 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace test1 { - namespace test1 + struct action_a { - struct action_a + static void apply0( int& r, int& s ) { - static void apply0( int& r, int& s ) - { - TAO_PEGTL_TEST_ASSERT( !r ); - TAO_PEGTL_TEST_ASSERT( !s ); - r += 1; - } - }; + TAO_PEGTL_TEST_ASSERT( !r ); + TAO_PEGTL_TEST_ASSERT( !s ); + r += 1; + } + }; - struct action_b + struct action_b + { + static bool apply0( int& r, int& s ) { - static bool apply0( int& r, int& s ) - { - TAO_PEGTL_TEST_ASSERT( !s ); - TAO_PEGTL_TEST_ASSERT( r == 1 ); - s += 2; - return true; - } - }; + TAO_PEGTL_TEST_ASSERT( !s ); + TAO_PEGTL_TEST_ASSERT( r == 1 ); + s += 2; + return true; + } + }; - struct action2_a + struct action2_a + { + static void apply0( bool& state_b ) { - static void apply0( bool& state_b ) - { - TAO_PEGTL_TEST_ASSERT( !state_b ); - } - }; + TAO_PEGTL_TEST_ASSERT( !state_b ); + } + }; - struct action2_b + struct action2_b + { + static bool apply0( bool& state_b ) { - static bool apply0( bool& state_b ) - { - TAO_PEGTL_TEST_ASSERT( !state_b ); - state_b = true; - return false; - } - }; + TAO_PEGTL_TEST_ASSERT( !state_b ); + state_b = true; + return false; + } + }; - struct action2_c + struct action2_c + { + static void apply0( bool& /*unused*/ ) { - static void apply0( bool& /*unused*/ ) - { - TAO_PEGTL_TEST_ASSERT( false ); - } - }; + TAO_PEGTL_TEST_ASSERT( false ); + } + }; - } // namespace test1 + } // namespace test1 - void unit_test() - { - int state_r = 0; - int state_s = 0; - parse< must< apply0< test1::action_a, test1::action_b > > >( memory_input<>( "", __FUNCTION__ ), state_r, state_s ); - TAO_PEGTL_TEST_ASSERT( state_r == 1 ); - TAO_PEGTL_TEST_ASSERT( state_s == 2 ); - parse< must< disable< apply< test1::action_a, test1::action_b > > > >( memory_input<>( "", __FUNCTION__ ), state_r, state_s ); - TAO_PEGTL_TEST_ASSERT( state_r == 1 ); - TAO_PEGTL_TEST_ASSERT( state_s == 2 ); + void unit_test() + { + int state_r = 0; + int state_s = 0; + parse< must< apply0< test1::action_a, test1::action_b > > >( memory_input( "", __FUNCTION__ ), state_r, state_s ); + TAO_PEGTL_TEST_ASSERT( state_r == 1 ); + TAO_PEGTL_TEST_ASSERT( state_s == 2 ); + parse< must< disable< apply< test1::action_a, test1::action_b > > > >( memory_input( "", __FUNCTION__ ), state_r, state_s ); + TAO_PEGTL_TEST_ASSERT( state_r == 1 ); + TAO_PEGTL_TEST_ASSERT( state_s == 2 ); - bool state_b = false; - const bool result = parse< apply0< test1::action2_a, test1::action2_b, test1::action2_c > >( memory_input<>( "", __FUNCTION__ ), state_b ); - TAO_PEGTL_TEST_ASSERT( !result ); - TAO_PEGTL_TEST_ASSERT( state_b ); + bool state_b = false; + const bool result = parse< apply0< test1::action2_a, test1::action2_b, test1::action2_c > >( memory_input( "", __FUNCTION__ ), state_b ); + TAO_PEGTL_TEST_ASSERT( !result ); + TAO_PEGTL_TEST_ASSERT( state_b ); - verify_analyze< apply0<> >( __LINE__, __FILE__, false, false ); + verify_analyze< apply0<> >( __LINE__, __FILE__, false, false ); - verify_rule< apply0<> >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); + verify_rule< apply0<> >( __LINE__, __FILE__, "", result_type::success, 0 ); - for( char i = 1; i < 127; ++i ) { - char t[] = { i, 0 }; - verify_rule< apply0<> >( __LINE__, __FILE__, std::string( t ), result_type::SUCCESS, 1 ); - } + for( char i = 1; i < 127; ++i ) { + char t[] = { i, 0 }; // NOLINT + verify_rule< apply0<> >( __LINE__, __FILE__, std::string( t ), result_type::success, 1 ); } + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_at.cpp b/packages/PEGTL/src/test/pegtl/rule_at.cpp index bd4f5d63e..6f73c253b 100644 --- a/packages/PEGTL/src/test/pegtl/rule_at.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_at.cpp @@ -1,61 +1,55 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE - { - int at_counter = 0; + int at_counter = 0; + + template< typename Rule > + struct at_action + {}; - template< typename Rule > - struct at_action - : public nothing< Rule > + template<> + struct at_action< any > + { + template< typename Input > + static void apply( const Input& /*unused*/ ) { - }; + ++at_counter; + } + }; - template<> - struct at_action< any > + void unit_test() + { + TAO_PEGTL_TEST_ASSERT( at_counter == 0 ); + + verify_analyze< at< eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< at< any > >( __LINE__, __FILE__, false, false ); + + verify_rule< at< eof > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< at< eof > >( __LINE__, __FILE__, "a", result_type::local_failure, 1 ); + verify_rule< at< any > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< at< any > >( __LINE__, __FILE__, "a", result_type::success, 1 ); + verify_rule< at< any > >( __LINE__, __FILE__, "aa", result_type::success, 2 ); + verify_rule< at< any > >( __LINE__, __FILE__, "aaaa", result_type::success, 4 ); + verify_rule< must< at< alpha > > >( __LINE__, __FILE__, "1", result_type::global_failure, 1 ); + verify_rule< must< at< alpha, alpha > > >( __LINE__, __FILE__, "a1a", result_type::global_failure, 3 ); { - template< typename Input > - static void apply( const Input& /*unused*/ ) - { - ++at_counter; - } - }; - - void unit_test() + memory_input in( "f", 1, __FILE__ ); + parse< any, at_action >( in ); + TAO_PEGTL_TEST_ASSERT( at_counter == 1 ); + } { - TAO_PEGTL_TEST_ASSERT( at_counter == 0 ); - - verify_analyze< at< eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< at< any > >( __LINE__, __FILE__, false, false ); - - verify_rule< at< eof > >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - verify_rule< at< eof > >( __LINE__, __FILE__, "a", result_type::LOCAL_FAILURE, 1 ); - verify_rule< at< any > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< at< any > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 1 ); - verify_rule< at< any > >( __LINE__, __FILE__, "aa", result_type::SUCCESS, 2 ); - verify_rule< at< any > >( __LINE__, __FILE__, "aaaa", result_type::SUCCESS, 4 ); - verify_rule< must< at< alpha > > >( __LINE__, __FILE__, "1", result_type::GLOBAL_FAILURE, 1 ); - verify_rule< must< at< alpha, alpha > > >( __LINE__, __FILE__, "a1a", result_type::GLOBAL_FAILURE, 3 ); - { - memory_input<> in( "f", 1, __FILE__ ); - parse< any, at_action >( in ); - TAO_PEGTL_TEST_ASSERT( at_counter == 1 ); - } - { - memory_input<> in( "f", 1, __FILE__ ); - parse< at< any >, at_action >( in ); - TAO_PEGTL_TEST_ASSERT( at_counter == 1 ); - } + memory_input in( "f", 1, __FILE__ ); + parse< at< any >, at_action >( in ); + TAO_PEGTL_TEST_ASSERT( at_counter == 1 ); } + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_bof.cpp b/packages/PEGTL/src/test/pegtl/rule_bof.cpp index a2fc690ad..ff44dbef1 100644 --- a/packages/PEGTL/src/test/pegtl/rule_bof.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_bof.cpp @@ -1,33 +1,29 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< bof >( __LINE__, __FILE__, false, false ); + verify_analyze< bof >( __LINE__, __FILE__, false, false ); - verify_rule< bof >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); + verify_rule< bof >( __LINE__, __FILE__, "", result_type::success, 0 ); - for( char i = 1; i < 127; ++i ) { - const char s[] = { i, 0 }; - verify_rule< bof >( __LINE__, __FILE__, s, result_type::SUCCESS, 1 ); - } - verify_rule< seq< alpha, bof > >( __LINE__, __FILE__, "a", result_type::LOCAL_FAILURE, 1 ); - verify_rule< seq< alpha, bof > >( __LINE__, __FILE__, "ab", result_type::LOCAL_FAILURE, 2 ); - verify_rule< seq< alpha, bof, alpha > >( __LINE__, __FILE__, "ab", result_type::LOCAL_FAILURE, 2 ); - verify_rule< seq< alpha, eol, bof > >( __LINE__, __FILE__, "a\n", result_type::LOCAL_FAILURE, 2 ); - verify_rule< seq< alpha, eol, bof > >( __LINE__, __FILE__, "a\nb", result_type::LOCAL_FAILURE, 3 ); + for( char i = 1; i < 127; ++i ) { + const char s[] = { i, 0 }; // NOLINT + verify_rule< bof >( __LINE__, __FILE__, s, result_type::success, 1 ); } + verify_rule< seq< alpha, bof > >( __LINE__, __FILE__, "a", result_type::local_failure, 1 ); + verify_rule< seq< alpha, bof > >( __LINE__, __FILE__, "ab", result_type::local_failure, 2 ); + verify_rule< seq< alpha, bof, alpha > >( __LINE__, __FILE__, "ab", result_type::local_failure, 2 ); + verify_rule< seq< alpha, eol, bof > >( __LINE__, __FILE__, "a\n", result_type::local_failure, 2 ); + verify_rule< seq< alpha, eol, bof > >( __LINE__, __FILE__, "a\nb", result_type::local_failure, 3 ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_bol.cpp b/packages/PEGTL/src/test/pegtl/rule_bol.cpp index b0e14d898..60852c6d8 100644 --- a/packages/PEGTL/src/test/pegtl/rule_bol.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_bol.cpp @@ -1,32 +1,28 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< bol >( __LINE__, __FILE__, false, false ); + verify_analyze< bol >( __LINE__, __FILE__, false, false ); - verify_only< bol >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); + verify_only< bol >( __LINE__, __FILE__, "", result_type::success, 0 ); - for( char i = 1; i < 127; ++i ) { - const char s[] = { i, 0 }; - verify_only< bol >( __LINE__, __FILE__, s, result_type::SUCCESS, 1 ); - } - verify_only< seq< alpha, bol > >( __LINE__, __FILE__, "a", result_type::LOCAL_FAILURE, 1 ); - verify_only< seq< alpha, bol > >( __LINE__, __FILE__, "ab", result_type::LOCAL_FAILURE, 2 ); - verify_only< seq< alpha, bol, alpha > >( __LINE__, __FILE__, "ab", result_type::LOCAL_FAILURE, 2 ); - verify_only< seq< alpha, eol, bol, alpha, eof > >( __LINE__, __FILE__, "a\nb", result_type::SUCCESS, 0 ); + for( char i = 1; i < 127; ++i ) { + const char s[] = { i, 0 }; // NOLINT + verify_only< bol >( __LINE__, __FILE__, s, result_type::success, 1 ); } + verify_only< seq< alpha, bol > >( __LINE__, __FILE__, "a", result_type::local_failure, 1 ); + verify_only< seq< alpha, bol > >( __LINE__, __FILE__, "ab", result_type::local_failure, 2 ); + verify_only< seq< alpha, bol, alpha > >( __LINE__, __FILE__, "ab", result_type::local_failure, 2 ); + verify_only< seq< alpha, eol, bol, alpha, eof > >( __LINE__, __FILE__, "a\nb", result_type::success, 0 ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_bytes.cpp b/packages/PEGTL/src/test/pegtl/rule_bytes.cpp index 3bd3d8515..ad9462640 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" @@ -6,37 +6,33 @@ #include "verify_char.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< bytes< 0 > >( __LINE__, __FILE__, false, false ); + verify_analyze< bytes< 0 > >( __LINE__, __FILE__, false, false ); - verify_rule< bytes< 0 > >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - verify_rule< bytes< 0 > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 1 ); + verify_rule< bytes< 0 > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< bytes< 0 > >( __LINE__, __FILE__, "a", result_type::success, 1 ); - verify_analyze< bytes< 1 > >( __LINE__, __FILE__, true, false ); + verify_analyze< bytes< 1 > >( __LINE__, __FILE__, true, false ); - for( char c = 0; c < 127; ++c ) { - verify_char< bytes< 1 > >( __LINE__, __FILE__, c, result_type::SUCCESS ); - } - verify_rule< bytes< 1 > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< bytes< 1 > >( __LINE__, __FILE__, "aa", result_type::SUCCESS, 1 ); - - verify_analyze< bytes< 2 > >( __LINE__, __FILE__, true, false ); - verify_analyze< bytes< 42 > >( __LINE__, __FILE__, true, false ); + for( char c = 0; c < 127; ++c ) { + verify_char< bytes< 1 > >( __LINE__, __FILE__, c, result_type::success ); + } + verify_rule< bytes< 1 > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< bytes< 1 > >( __LINE__, __FILE__, "aa", result_type::success, 1 ); - verify_rule< bytes< 3 > >( __LINE__, __FILE__, "abcd", result_type::SUCCESS, 1 ); - verify_rule< bytes< 4 > >( __LINE__, __FILE__, "abcd", result_type::SUCCESS, 0 ); - verify_rule< bytes< 5 > >( __LINE__, __FILE__, "abcd", result_type::LOCAL_FAILURE, 4 ); + verify_analyze< bytes< 2 > >( __LINE__, __FILE__, true, false ); + verify_analyze< bytes< 42 > >( __LINE__, __FILE__, true, false ); - verify_rule< bytes< 4 > >( __LINE__, __FILE__, "abcdefghij", result_type::SUCCESS, 6 ); - } + verify_rule< bytes< 3 > >( __LINE__, __FILE__, "abcd", result_type::success, 1 ); + verify_rule< bytes< 4 > >( __LINE__, __FILE__, "abcd", result_type::success, 0 ); + verify_rule< bytes< 5 > >( __LINE__, __FILE__, "abcd", result_type::local_failure, 4 ); - } // namespace TAO_PEGTL_NAMESPACE + verify_rule< bytes< 4 > >( __LINE__, __FILE__, "abcdefghij", result_type::success, 6 ); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_control.cpp b/packages/PEGTL/src/test/pegtl/rule_control.cpp index e70fa1fae..c4cc810da 100644 --- a/packages/PEGTL/src/test/pegtl/rule_control.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_control.cpp @@ -1,23 +1,19 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_seqs.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE - { - template< typename... Rules > - using test_control_rule = control< normal, Rules... >; - - void unit_test() - { - verify_seqs< test_control_rule >(); - } + template< typename... Rules > + using test_control_rule = control< normal, Rules... >; - } // namespace TAO_PEGTL_NAMESPACE + void unit_test() + { + verify_seqs< test_control_rule >(); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_disable.cpp b/packages/PEGTL/src/test/pegtl/rule_disable.cpp index 638a42394..db15b8a1e 100644 --- a/packages/PEGTL/src/test/pegtl/rule_disable.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_disable.cpp @@ -1,20 +1,16 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_seqs.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_seqs< disable >(); - } + verify_seqs< disable >(); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_enable.cpp b/packages/PEGTL/src/test/pegtl/rule_enable.cpp index 1eef732da..de998a6e3 100644 --- a/packages/PEGTL/src/test/pegtl/rule_enable.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_enable.cpp @@ -1,20 +1,16 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_seqs.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_seqs< enable >(); - } + verify_seqs< enable >(); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_eof.cpp b/packages/PEGTL/src/test/pegtl/rule_eof.cpp index 5e9918709..ccb1809f1 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" @@ -6,24 +6,20 @@ #include "verify_char.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< eof >( __LINE__, __FILE__, false, false ); + verify_analyze< eof >( __LINE__, __FILE__, false, false ); - verify_rule< eof >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); + verify_rule< eof >( __LINE__, __FILE__, "", result_type::success, 0 ); - for( char i = 1; i < 127; ++i ) { - verify_char< eof >( __LINE__, __FILE__, i, result_type::LOCAL_FAILURE ); - } - verify_rule< eof >( __LINE__, __FILE__, "abcdefghijklmn", result_type::LOCAL_FAILURE, 14 ); + for( char i = 1; i < 127; ++i ) { + verify_char< eof >( __LINE__, __FILE__, i, result_type::local_failure ); } + verify_rule< eof >( __LINE__, __FILE__, "abcdefghijklmn", result_type::local_failure, 14 ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // 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 169ad7245..01105fed2 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" @@ -6,23 +6,19 @@ #include "verify_char.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< failure >( __LINE__, __FILE__, true, false ); // "Success implies consumption" is true because "success" never happens. + verify_analyze< failure >( __LINE__, __FILE__, true, false ); // "Success implies consumption" is true because "success" never happens. - verify_rule< failure >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); + verify_rule< failure >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); - for( char i = 1; i < 127; ++i ) { - verify_char< failure >( __LINE__, __FILE__, i, result_type::LOCAL_FAILURE ); - } + for( char i = 1; i < 127; ++i ) { + verify_char< failure >( __LINE__, __FILE__, i, result_type::local_failure ); } + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_if_apply.cpp b/packages/PEGTL/src/test/pegtl/rule_if_apply.cpp index ef05b7ff3..ab9576511 100644 --- a/packages/PEGTL/src/test/pegtl/rule_if_apply.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_if_apply.cpp @@ -1,129 +1,124 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_seqs.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace test1 { - namespace test1 + struct action_a { - struct action_a + template< typename Input > + static void apply( const Input& in, std::string& r, std::string& s ) { - template< typename Input > - static void apply( const Input& in, std::string& r, std::string& s ) - { - TAO_PEGTL_TEST_ASSERT( r.empty() ); - TAO_PEGTL_TEST_ASSERT( s.empty() ); - r += in.string(); - } - }; - - struct action_b - { - template< typename Input > - static void apply( const Input& in, std::string& r, std::string& s ) - { - TAO_PEGTL_TEST_ASSERT( s.empty() ); - s += in.string(); - s += "*"; - s += r; - } - }; - - struct action2_a - { - template< typename Input > - static void apply( const Input& in, bool& state_b ) - { - TAO_PEGTL_TEST_ASSERT( in.string() == "foo" ); - TAO_PEGTL_TEST_ASSERT( !state_b ); - } - }; - - struct action2_b - { - template< typename Input > - static bool apply( const Input& in, bool& state_b ) - { - TAO_PEGTL_TEST_ASSERT( in.string() == "foo" ); - TAO_PEGTL_TEST_ASSERT( !state_b ); - state_b = true; - return false; - } - }; - - struct action2_c - { - template< typename Input > - static void apply( const Input& /*unused*/, bool& /*unused*/ ) - { - TAO_PEGTL_TEST_ASSERT( false ); - } - }; - - template< typename Rule > - struct action : nothing< Rule > + TAO_PEGTL_TEST_ASSERT( r.empty() ); + TAO_PEGTL_TEST_ASSERT( s.empty() ); + r += in.string(); + } + }; + + struct action_b + { + template< typename Input > + static void apply( const Input& in, std::string& r, std::string& s ) { - }; + TAO_PEGTL_TEST_ASSERT( s.empty() ); + s += in.string(); + s += "*"; + s += r; + } + }; - int flag = 0; + struct action2_a + { + template< typename Input > + static void apply( const Input& in, bool& state_b ) + { + TAO_PEGTL_TEST_ASSERT( in.string_view() == "foo" ); + TAO_PEGTL_TEST_ASSERT( !state_b ); + } + }; - template<> - struct action< one< '-' > > + struct action2_b + { + template< typename Input > + static bool apply( const Input& in, bool& state_b ) { - static void apply0( std::string& /*unused*/, std::string& /*unused*/ ) - { - ++flag; - } - }; + TAO_PEGTL_TEST_ASSERT( in.string_view() == "foo" ); + TAO_PEGTL_TEST_ASSERT( !state_b ); + state_b = true; + return false; + } + }; - } // namespace test1 + struct action2_c + { + template< typename Input > + static void apply( const Input& /*unused*/, bool& /*unused*/ ) + { + TAO_PEGTL_TEST_ASSERT( false ); + } + }; - template< typename... Rules > - using if_apply_seq = if_apply< seq< Rules... > >; + template< typename Rule > + struct action + {}; - template< typename... Rules > - using if_apply_disable = if_apply< disable< Rules... > >; + int flag = 0; - void unit_test() + template<> + struct action< one< '-' > > { - std::string state_r; - std::string state_s; - TAO_PEGTL_TEST_ASSERT( test1::flag == 0 ); - memory_input<> in1( "-", __FUNCTION__ ); - parse< must< if_apply< one< '-' >, test1::action_a, test1::action_b > >, test1::action >( in1, state_r, state_s ); - TAO_PEGTL_TEST_ASSERT( test1::flag == 1 ); - TAO_PEGTL_TEST_ASSERT( state_r == "-" ); - TAO_PEGTL_TEST_ASSERT( state_s == "-*-" ); - memory_input<> in2( "-", __FUNCTION__ ); - parse< must< disable< if_apply< one< '-' >, test1::action_a, test1::action_b > > >, test1::action >( in2, state_r, state_s ); - TAO_PEGTL_TEST_ASSERT( test1::flag == 1 ); - TAO_PEGTL_TEST_ASSERT( state_r == "-" ); - TAO_PEGTL_TEST_ASSERT( state_s == "-*-" ); - + static void apply0( std::string& /*unused*/, std::string& /*unused*/ ) { - bool state_b = false; - const bool result = parse< if_apply< plus< alpha >, test1::action2_a, test1::action2_b, test1::action2_c > >( memory_input<>( "foo bar", __FUNCTION__ ), state_b ); - TAO_PEGTL_TEST_ASSERT( !result ); - TAO_PEGTL_TEST_ASSERT( state_b ); + ++flag; } + }; - { - bool state_b = false; - const bool result = parse< if_apply< plus< alpha >, test1::action2_a, test1::action2_b, test1::action2_c > >( memory_input<>( "", __FUNCTION__ ), state_b ); - TAO_PEGTL_TEST_ASSERT( !result ); - TAO_PEGTL_TEST_ASSERT( !state_b ); - } + } // namespace test1 + + template< typename... Rules > + using if_apply_seq = if_apply< seq< Rules... > >; - verify_seqs< if_apply_seq >(); - verify_seqs< if_apply_disable >(); + template< typename... Rules > + using if_apply_disable = if_apply< disable< Rules... > >; + + void unit_test() + { + std::string state_r; + std::string state_s; + TAO_PEGTL_TEST_ASSERT( test1::flag == 0 ); + memory_input in1( "-", __FUNCTION__ ); + parse< must< if_apply< one< '-' >, test1::action_a, test1::action_b > >, test1::action >( in1, state_r, state_s ); + TAO_PEGTL_TEST_ASSERT( test1::flag == 1 ); + TAO_PEGTL_TEST_ASSERT( state_r == "-" ); + TAO_PEGTL_TEST_ASSERT( state_s == "-*-" ); + memory_input in2( "-", __FUNCTION__ ); + parse< must< disable< if_apply< one< '-' >, test1::action_a, test1::action_b > > >, test1::action >( in2, state_r, state_s ); + TAO_PEGTL_TEST_ASSERT( test1::flag == 1 ); + TAO_PEGTL_TEST_ASSERT( state_r == "-" ); + TAO_PEGTL_TEST_ASSERT( state_s == "-*-" ); + + { + bool state_b = false; + const bool result = parse< if_apply< plus< alpha >, test1::action2_a, test1::action2_b, test1::action2_c > >( memory_input( "foo bar", __FUNCTION__ ), state_b ); + TAO_PEGTL_TEST_ASSERT( !result ); + TAO_PEGTL_TEST_ASSERT( state_b ); + } + + { + bool state_b = false; + const bool result = parse< if_apply< plus< alpha >, test1::action2_a, test1::action2_b, test1::action2_c > >( memory_input( "", __FUNCTION__ ), state_b ); + TAO_PEGTL_TEST_ASSERT( !result ); + TAO_PEGTL_TEST_ASSERT( !state_b ); } - } // namespace TAO_PEGTL_NAMESPACE + verify_seqs< if_apply_seq >(); + verify_seqs< if_apply_disable >(); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_if_must.cpp b/packages/PEGTL/src/test/pegtl/rule_if_must.cpp index 797c4d63d..8900d8186 100644 --- a/packages/PEGTL/src/test/pegtl/rule_if_must.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_if_must.cpp @@ -1,48 +1,44 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< if_must< any, any > >( __LINE__, __FILE__, true, false ); - verify_analyze< if_must< eof, any > >( __LINE__, __FILE__, true, false ); - verify_analyze< if_must< opt< any >, any > >( __LINE__, __FILE__, true, false ); - verify_analyze< if_must< any, opt< any > > >( __LINE__, __FILE__, true, false ); - verify_analyze< if_must< any, eof > >( __LINE__, __FILE__, true, false ); - verify_analyze< if_must< opt< any >, opt< any > > >( __LINE__, __FILE__, false, false ); - verify_analyze< if_must< eof, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< if_must< any, any > >( __LINE__, __FILE__, true, false ); + verify_analyze< if_must< eof, any > >( __LINE__, __FILE__, true, false ); + verify_analyze< if_must< opt< any >, any > >( __LINE__, __FILE__, true, false ); + verify_analyze< if_must< any, opt< any > > >( __LINE__, __FILE__, true, false ); + verify_analyze< if_must< any, eof > >( __LINE__, __FILE__, true, false ); + verify_analyze< if_must< opt< any >, opt< any > > >( __LINE__, __FILE__, false, false ); + verify_analyze< if_must< eof, eof > >( __LINE__, __FILE__, false, false ); - verify_rule< if_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< if_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", result_type::GLOBAL_FAILURE, 0 ); - verify_rule< if_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "b", result_type::LOCAL_FAILURE, 1 ); - verify_rule< if_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ba", result_type::LOCAL_FAILURE, 2 ); - verify_rule< if_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::SUCCESS, 0 ); - verify_rule< if_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aba", result_type::SUCCESS, 1 ); - verify_rule< if_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abb", result_type::SUCCESS, 1 ); - verify_rule< if_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abab", result_type::SUCCESS, 2 ); - verify_rule< if_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ac", result_type::GLOBAL_FAILURE, 1 ); - verify_rule< if_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "acb", result_type::GLOBAL_FAILURE, 2 ); - verify_rule< if_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< if_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "b", result_type::LOCAL_FAILURE, 1 ); - verify_rule< if_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "bc", result_type::LOCAL_FAILURE, 2 ); - verify_rule< if_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "a", result_type::GLOBAL_FAILURE, 1 ); - verify_rule< if_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "ab", result_type::GLOBAL_FAILURE, 2 ); - verify_rule< if_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "ac", result_type::GLOBAL_FAILURE, 2 ); - verify_rule< if_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "abb", result_type::GLOBAL_FAILURE, 3 ); - verify_rule< if_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "acc", result_type::GLOBAL_FAILURE, 3 ); - verify_rule< if_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "acb", result_type::GLOBAL_FAILURE, 3 ); - verify_rule< if_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "abc", result_type::SUCCESS, 0 ); - } + verify_rule< if_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< if_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", result_type::global_failure, 0 ); + verify_rule< if_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "b", result_type::local_failure, 1 ); + verify_rule< if_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ba", result_type::local_failure, 2 ); + verify_rule< if_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::success, 0 ); + verify_rule< if_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aba", result_type::success, 1 ); + verify_rule< if_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abb", result_type::success, 1 ); + verify_rule< if_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abab", result_type::success, 2 ); + verify_rule< if_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ac", result_type::global_failure, 1 ); + verify_rule< if_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "acb", result_type::global_failure, 2 ); + verify_rule< if_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< if_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "b", result_type::local_failure, 1 ); + verify_rule< if_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "bc", result_type::local_failure, 2 ); + verify_rule< if_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "a", result_type::global_failure, 1 ); + verify_rule< if_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "ab", result_type::global_failure, 2 ); + verify_rule< if_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "ac", result_type::global_failure, 2 ); + verify_rule< if_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "abb", result_type::global_failure, 3 ); + verify_rule< if_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "acc", result_type::global_failure, 3 ); + verify_rule< if_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "acb", result_type::global_failure, 3 ); + verify_rule< if_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "abc", result_type::success, 0 ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" 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 d360bb6be..b8fe63c6c 100644 --- a/packages/PEGTL/src/test/pegtl/rule_if_must_else.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_if_must_else.cpp @@ -1,20 +1,16 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_ifmt.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_ifmt< if_must_else >( result_type::GLOBAL_FAILURE ); - } + verify_ifmt< if_must_else >( result_type::global_failure ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" 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 29a2717b7..7dac12c7b 100644 --- a/packages/PEGTL/src/test/pegtl/rule_if_then_else.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_if_then_else.cpp @@ -1,20 +1,16 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_ifmt.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_ifmt< if_then_else >(); - } + verify_ifmt< if_then_else >(); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_list.cpp b/packages/PEGTL/src/test/pegtl/rule_list.cpp index d423602dc..bed729ec8 100644 --- a/packages/PEGTL/src/test/pegtl/rule_list.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_list.cpp @@ -1,62 +1,58 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< list< eof, eof > >( __LINE__, __FILE__, false, true ); - verify_analyze< list< eof, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< list< any, eof > >( __LINE__, __FILE__, true, false ); - verify_analyze< list< any, any > >( __LINE__, __FILE__, true, false ); - - verify_analyze< list< eof, eof, eof > >( __LINE__, __FILE__, false, true ); - verify_analyze< list< eof, eof, any > >( __LINE__, __FILE__, false, true ); - verify_analyze< list< eof, any, eof > >( __LINE__, __FILE__, false, true ); - verify_analyze< list< eof, any, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< list< any, eof, eof > >( __LINE__, __FILE__, true, true ); - verify_analyze< list< any, eof, any > >( __LINE__, __FILE__, true, false ); - verify_analyze< list< any, any, eof > >( __LINE__, __FILE__, true, true ); - verify_analyze< list< any, any, any > >( __LINE__, __FILE__, true, false ); - - verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "b", result_type::LOCAL_FAILURE, 1 ); - verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, ",", result_type::LOCAL_FAILURE, 1 ); - verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, ",a", result_type::LOCAL_FAILURE, 2 ); - verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,", result_type::SUCCESS, 1 ); - verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 0 ); - verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,a", result_type::SUCCESS, 0 ); - verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,b", result_type::SUCCESS, 2 ); - verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,a,a", result_type::SUCCESS, 0 ); - verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,a,a,a", result_type::SUCCESS, 0 ); - verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,a,a,b", result_type::SUCCESS, 2 ); - verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,a,a,,", result_type::SUCCESS, 2 ); - - verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a ", result_type::SUCCESS, 1 ); - verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, " a", result_type::LOCAL_FAILURE, 2 ); - verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a ,a", result_type::SUCCESS, 3 ); - verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a, a", result_type::SUCCESS, 3 ); - - verify_rule< list< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< list< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, " ", result_type::LOCAL_FAILURE, 1 ); - verify_rule< list< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, ",", result_type::LOCAL_FAILURE, 1 ); - verify_rule< list< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a ", result_type::SUCCESS, 1 ); - verify_rule< list< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, " a", result_type::LOCAL_FAILURE, 2 ); - verify_rule< list< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a ,a", result_type::SUCCESS, 0 ); - verify_rule< list< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a, a", result_type::SUCCESS, 0 ); - verify_rule< list< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a, a,", result_type::SUCCESS, 1 ); - verify_rule< list< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a, a ,", result_type::SUCCESS, 2 ); - verify_rule< list< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, " a , a ", result_type::LOCAL_FAILURE, 7 ); - } - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + verify_analyze< list< eof, eof > >( __LINE__, __FILE__, false, true ); + verify_analyze< list< eof, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< list< any, eof > >( __LINE__, __FILE__, true, false ); + verify_analyze< list< any, any > >( __LINE__, __FILE__, true, false ); + + verify_analyze< list< eof, eof, eof > >( __LINE__, __FILE__, false, true ); + verify_analyze< list< eof, eof, any > >( __LINE__, __FILE__, false, true ); + verify_analyze< list< eof, any, eof > >( __LINE__, __FILE__, false, true ); + verify_analyze< list< eof, any, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< list< any, eof, eof > >( __LINE__, __FILE__, true, true ); + verify_analyze< list< any, eof, any > >( __LINE__, __FILE__, true, false ); + verify_analyze< list< any, any, eof > >( __LINE__, __FILE__, true, true ); + verify_analyze< list< any, any, any > >( __LINE__, __FILE__, true, false ); + + verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "b", result_type::local_failure, 1 ); + verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, ",", result_type::local_failure, 1 ); + verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, ",a", result_type::local_failure, 2 ); + verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,", result_type::success, 1 ); + verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,a", result_type::success, 0 ); + verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,b", result_type::success, 2 ); + verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,a,a", result_type::success, 0 ); + verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,a,a,a", result_type::success, 0 ); + verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,a,a,b", result_type::success, 2 ); + verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,a,a,,", result_type::success, 2 ); + + verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a ", result_type::success, 1 ); + verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, " a", result_type::local_failure, 2 ); + verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a ,a", result_type::success, 3 ); + verify_rule< list< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a, a", result_type::success, 3 ); + + verify_rule< list< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< list< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, " ", result_type::local_failure, 1 ); + verify_rule< list< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, ",", result_type::local_failure, 1 ); + verify_rule< list< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a ", result_type::success, 1 ); + verify_rule< list< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, " a", result_type::local_failure, 2 ); + verify_rule< list< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a ,a", result_type::success, 0 ); + verify_rule< list< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a, a", result_type::success, 0 ); + verify_rule< list< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a, a,", result_type::success, 1 ); + verify_rule< list< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a, a ,", result_type::success, 2 ); + verify_rule< list< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, " a , a ", result_type::local_failure, 7 ); + } + +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_list_must.cpp b/packages/PEGTL/src/test/pegtl/rule_list_must.cpp index c1290d763..e2f2b7fe5 100644 --- a/packages/PEGTL/src/test/pegtl/rule_list_must.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_list_must.cpp @@ -1,60 +1,56 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< list_must< eof, eof > >( __LINE__, __FILE__, false, true ); - verify_analyze< list_must< eof, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< list_must< any, eof > >( __LINE__, __FILE__, true, false ); - verify_analyze< list_must< any, any > >( __LINE__, __FILE__, true, false ); - - verify_analyze< list_must< eof, eof, eof > >( __LINE__, __FILE__, false, true ); - verify_analyze< list_must< eof, eof, any > >( __LINE__, __FILE__, false, true ); - verify_analyze< list_must< eof, any, eof > >( __LINE__, __FILE__, false, true ); - verify_analyze< list_must< eof, any, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< list_must< any, eof, eof > >( __LINE__, __FILE__, true, true ); - verify_analyze< list_must< any, eof, any > >( __LINE__, __FILE__, true, false ); - verify_analyze< list_must< any, any, eof > >( __LINE__, __FILE__, true, true ); - verify_analyze< list_must< any, any, any > >( __LINE__, __FILE__, true, false ); - - verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "b", result_type::LOCAL_FAILURE, 1 ); - verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, ",", result_type::LOCAL_FAILURE, 1 ); - verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, ",a", result_type::LOCAL_FAILURE, 2 ); - verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,", result_type::GLOBAL_FAILURE, 2 ); - verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 0 ); - verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,a", result_type::SUCCESS, 0 ); - verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,b", result_type::GLOBAL_FAILURE, 3 ); - verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,a,a", result_type::SUCCESS, 0 ); - verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,a,a,a", result_type::SUCCESS, 0 ); - - verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a ", result_type::SUCCESS, 1 ); - verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, " a", result_type::LOCAL_FAILURE, 2 ); - verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a ,a", result_type::SUCCESS, 3 ); - verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a, a", result_type::GLOBAL_FAILURE, 0 ); - - verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, " ", result_type::LOCAL_FAILURE, 1 ); - verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, ",", result_type::LOCAL_FAILURE, 1 ); - verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a ", result_type::SUCCESS, 1 ); - verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, " a", result_type::LOCAL_FAILURE, 2 ); - verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a ,a", result_type::SUCCESS, 0 ); - verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a, a", result_type::SUCCESS, 0 ); - verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a, a,", result_type::GLOBAL_FAILURE, 5 ); - verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a, a ,", result_type::GLOBAL_FAILURE, 6 ); - verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, " a , a ", result_type::LOCAL_FAILURE, 7 ); - } - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + verify_analyze< list_must< eof, eof > >( __LINE__, __FILE__, false, true ); + verify_analyze< list_must< eof, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< list_must< any, eof > >( __LINE__, __FILE__, true, false ); + verify_analyze< list_must< any, any > >( __LINE__, __FILE__, true, false ); + + verify_analyze< list_must< eof, eof, eof > >( __LINE__, __FILE__, false, true ); + verify_analyze< list_must< eof, eof, any > >( __LINE__, __FILE__, false, true ); + verify_analyze< list_must< eof, any, eof > >( __LINE__, __FILE__, false, true ); + verify_analyze< list_must< eof, any, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< list_must< any, eof, eof > >( __LINE__, __FILE__, true, true ); + verify_analyze< list_must< any, eof, any > >( __LINE__, __FILE__, true, false ); + verify_analyze< list_must< any, any, eof > >( __LINE__, __FILE__, true, true ); + verify_analyze< list_must< any, any, any > >( __LINE__, __FILE__, true, false ); + + verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "b", result_type::local_failure, 1 ); + verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, ",", result_type::local_failure, 1 ); + verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, ",a", result_type::local_failure, 2 ); + verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,", result_type::global_failure, 2 ); + verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,a", result_type::success, 0 ); + verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,b", result_type::global_failure, 3 ); + verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,a,a", result_type::success, 0 ); + verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,a,a,a", result_type::success, 0 ); + + verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a ", result_type::success, 1 ); + verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, " a", result_type::local_failure, 2 ); + verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a ,a", result_type::success, 3 ); + verify_rule< list_must< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a, a", result_type::global_failure, 0 ); + + verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, " ", result_type::local_failure, 1 ); + verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, ",", result_type::local_failure, 1 ); + verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a ", result_type::success, 1 ); + verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, " a", result_type::local_failure, 2 ); + verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a ,a", result_type::success, 0 ); + verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a, a", result_type::success, 0 ); + verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a, a,", result_type::global_failure, 5 ); + verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a, a ,", result_type::global_failure, 6 ); + verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, " a , a ", result_type::local_failure, 7 ); + } + +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_list_tail.cpp b/packages/PEGTL/src/test/pegtl/rule_list_tail.cpp index d44afb945..50378895c 100644 --- a/packages/PEGTL/src/test/pegtl/rule_list_tail.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_list_tail.cpp @@ -1,62 +1,58 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - 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< 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< any, any, any > >( __LINE__, __FILE__, true, false ); - - verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "b", result_type::LOCAL_FAILURE, 1 ); - verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, ",", result_type::LOCAL_FAILURE, 1 ); - verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, ",a", result_type::LOCAL_FAILURE, 2 ); - verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,", result_type::SUCCESS, 0 ); - verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 0 ); - 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,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 ); - - verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a ", result_type::SUCCESS, 1 ); - verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, " a", result_type::LOCAL_FAILURE, 2 ); - verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a ,a", result_type::SUCCESS, 3 ); - verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a, a", result_type::SUCCESS, 2 ); - - verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, " ", result_type::LOCAL_FAILURE, 1 ); - verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, ",", result_type::LOCAL_FAILURE, 1 ); - verify_rule< list_tail< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a ", result_type::SUCCESS, 1 ); - verify_rule< list_tail< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, " a", result_type::LOCAL_FAILURE, 2 ); - 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::LOCAL_FAILURE, 7 ); - } - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + 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< 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< any, any, any > >( __LINE__, __FILE__, true, false ); + + verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "b", result_type::local_failure, 1 ); + verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, ",", result_type::local_failure, 1 ); + verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, ",a", result_type::local_failure, 2 ); + verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a,", result_type::success, 0 ); + verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + 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,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 ); + + verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a ", result_type::success, 1 ); + verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, " a", result_type::local_failure, 2 ); + verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a ,a", result_type::success, 3 ); + verify_rule< list_tail< one< 'a' >, one< ',' > > >( __LINE__, __FILE__, "a, a", result_type::success, 2 ); + + verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, " ", result_type::local_failure, 1 ); + verify_rule< list_must< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, ",", result_type::local_failure, 1 ); + verify_rule< list_tail< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, "a ", result_type::success, 1 ); + verify_rule< list_tail< one< 'a' >, one< ',' >, blank > >( __LINE__, __FILE__, " a", result_type::local_failure, 2 ); + 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::local_failure, 7 ); + } + +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_minus.cpp b/packages/PEGTL/src/test/pegtl/rule_minus.cpp index de8f5258d..2fc804c7e 100644 --- a/packages/PEGTL/src/test/pegtl/rule_minus.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_minus.cpp @@ -1,54 +1,50 @@ -// Copyright (c) 2016-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2016-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< minus< alpha, digit > >( __LINE__, __FILE__, true, false ); - verify_analyze< minus< opt< alpha >, digit > >( __LINE__, __FILE__, false, false ); - - verify_rule< minus< alnum, digit > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< minus< alnum, digit > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 0 ); - verify_rule< minus< alnum, digit > >( __LINE__, __FILE__, "1", result_type::LOCAL_FAILURE, 1 ); - verify_rule< minus< alnum, digit > >( __LINE__, __FILE__, "%", result_type::LOCAL_FAILURE, 1 ); - verify_rule< minus< alnum, digit > >( __LINE__, __FILE__, "a%", result_type::SUCCESS, 1 ); - - verify_rule< must< minus< alnum, digit > > >( __LINE__, __FILE__, "%", result_type::GLOBAL_FAILURE, 1 ); - verify_rule< must< minus< alnum, digit > > >( __LINE__, __FILE__, "1", result_type::GLOBAL_FAILURE, 0 ); - - verify_rule< minus< plus< alnum >, digit > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< minus< plus< alnum >, digit > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 0 ); - verify_rule< minus< plus< alnum >, digit > >( __LINE__, __FILE__, "1", result_type::LOCAL_FAILURE, 1 ); - verify_rule< minus< plus< alnum >, digit > >( __LINE__, __FILE__, "%", result_type::LOCAL_FAILURE, 1 ); - verify_rule< minus< plus< alnum >, digit > >( __LINE__, __FILE__, "a%", result_type::SUCCESS, 1 ); - verify_rule< minus< plus< alnum >, digit > >( __LINE__, __FILE__, "aa", result_type::SUCCESS, 0 ); - verify_rule< minus< plus< alnum >, digit > >( __LINE__, __FILE__, "a1", result_type::SUCCESS, 0 ); - verify_rule< minus< plus< alnum >, digit > >( __LINE__, __FILE__, "1a", result_type::SUCCESS, 0 ); - verify_rule< minus< plus< alnum >, digit > >( __LINE__, __FILE__, "11", result_type::SUCCESS, 0 ); - verify_rule< minus< plus< alnum >, digit > >( __LINE__, __FILE__, "%%", result_type::LOCAL_FAILURE, 2 ); - - verify_rule< minus< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< minus< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 0 ); - verify_rule< minus< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "1", result_type::LOCAL_FAILURE, 1 ); - verify_rule< minus< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "%", result_type::LOCAL_FAILURE, 1 ); - verify_rule< minus< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "a%", result_type::SUCCESS, 1 ); - verify_rule< minus< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "aaa", result_type::SUCCESS, 0 ); - verify_rule< minus< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "aaa%", result_type::SUCCESS, 1 ); - verify_rule< minus< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "111", result_type::LOCAL_FAILURE, 3 ); - verify_rule< minus< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "111%", result_type::LOCAL_FAILURE, 4 ); - verify_rule< minus< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "a1a", result_type::SUCCESS, 0 ); - verify_rule< minus< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "1a1", result_type::SUCCESS, 0 ); - } - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + verify_analyze< minus< alpha, digit > >( __LINE__, __FILE__, true, false ); + verify_analyze< minus< opt< alpha >, digit > >( __LINE__, __FILE__, false, false ); + + verify_rule< minus< alnum, digit > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< minus< alnum, digit > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< minus< alnum, digit > >( __LINE__, __FILE__, "1", result_type::local_failure, 1 ); + verify_rule< minus< alnum, digit > >( __LINE__, __FILE__, "%", result_type::local_failure, 1 ); + verify_rule< minus< alnum, digit > >( __LINE__, __FILE__, "a%", result_type::success, 1 ); + + verify_rule< must< minus< alnum, digit > > >( __LINE__, __FILE__, "%", result_type::global_failure, 1 ); + verify_rule< must< minus< alnum, digit > > >( __LINE__, __FILE__, "1", result_type::global_failure, 0 ); + + verify_rule< minus< plus< alnum >, digit > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< minus< plus< alnum >, digit > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< minus< plus< alnum >, digit > >( __LINE__, __FILE__, "1", result_type::local_failure, 1 ); + verify_rule< minus< plus< alnum >, digit > >( __LINE__, __FILE__, "%", result_type::local_failure, 1 ); + verify_rule< minus< plus< alnum >, digit > >( __LINE__, __FILE__, "a%", result_type::success, 1 ); + verify_rule< minus< plus< alnum >, digit > >( __LINE__, __FILE__, "aa", result_type::success, 0 ); + verify_rule< minus< plus< alnum >, digit > >( __LINE__, __FILE__, "a1", result_type::success, 0 ); + verify_rule< minus< plus< alnum >, digit > >( __LINE__, __FILE__, "1a", result_type::success, 0 ); + verify_rule< minus< plus< alnum >, digit > >( __LINE__, __FILE__, "11", result_type::success, 0 ); + verify_rule< minus< plus< alnum >, digit > >( __LINE__, __FILE__, "%%", result_type::local_failure, 2 ); + + verify_rule< minus< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< minus< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< minus< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "1", result_type::local_failure, 1 ); + verify_rule< minus< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "%", result_type::local_failure, 1 ); + verify_rule< minus< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "a%", result_type::success, 1 ); + verify_rule< minus< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "aaa", result_type::success, 0 ); + verify_rule< minus< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "aaa%", result_type::success, 1 ); + verify_rule< minus< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "111", result_type::local_failure, 3 ); + verify_rule< minus< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "111%", result_type::local_failure, 4 ); + verify_rule< minus< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "a1a", result_type::success, 0 ); + verify_rule< minus< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "1a1", result_type::success, 0 ); + } + +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_must.cpp b/packages/PEGTL/src/test/pegtl/rule_must.cpp index 60d793096..8bbdfc999 100644 --- a/packages/PEGTL/src/test/pegtl/rule_must.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_must.cpp @@ -1,20 +1,16 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_seqs.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_seqs< must >( result_type::GLOBAL_FAILURE ); - } + verify_seqs< must >( result_type::global_failure ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_not_at.cpp b/packages/PEGTL/src/test/pegtl/rule_not_at.cpp index 74dbd86bd..4ad66acd8 100644 --- a/packages/PEGTL/src/test/pegtl/rule_not_at.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_not_at.cpp @@ -1,66 +1,60 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE - { - int at_counter = 0; + int at_counter = 0; - template< typename Rule > - struct at_action - : public nothing< Rule > - { - }; + template< typename Rule > + struct at_action + {}; - template<> - struct at_action< alpha > + template<> + struct at_action< alpha > + { + template< typename Input > + static void apply( const Input& /*unused*/ ) { - template< typename Input > - static void apply( const Input& /*unused*/ ) - { - ++at_counter; - } - }; + ++at_counter; + } + }; - void unit_test() + void unit_test() + { + TAO_PEGTL_TEST_ASSERT( at_counter == 0 ); + + verify_analyze< not_at< eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< not_at< any > >( __LINE__, __FILE__, false, false ); + + verify_rule< not_at< eof > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< not_at< eof > >( __LINE__, __FILE__, " ", result_type::success, 1 ); + verify_rule< not_at< any > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< not_at< any > >( __LINE__, __FILE__, "a", result_type::local_failure, 1 ); + verify_rule< not_at< any > >( __LINE__, __FILE__, "aa", result_type::local_failure, 2 ); + verify_rule< not_at< any > >( __LINE__, __FILE__, "aaaa", result_type::local_failure, 4 ); + verify_rule< must< not_at< alpha > > >( __LINE__, __FILE__, "a", result_type::global_failure, 1 ); + verify_rule< must< not_at< alpha, alpha > > >( __LINE__, __FILE__, "aa1", result_type::global_failure, 3 ); { - TAO_PEGTL_TEST_ASSERT( at_counter == 0 ); - - verify_analyze< not_at< eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< not_at< any > >( __LINE__, __FILE__, false, false ); - - verify_rule< not_at< eof > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< not_at< eof > >( __LINE__, __FILE__, " ", result_type::SUCCESS, 1 ); - verify_rule< not_at< any > >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - verify_rule< not_at< any > >( __LINE__, __FILE__, "a", result_type::LOCAL_FAILURE, 1 ); - verify_rule< not_at< any > >( __LINE__, __FILE__, "aa", result_type::LOCAL_FAILURE, 2 ); - verify_rule< not_at< any > >( __LINE__, __FILE__, "aaaa", result_type::LOCAL_FAILURE, 4 ); - verify_rule< must< not_at< alpha > > >( __LINE__, __FILE__, "a", result_type::GLOBAL_FAILURE, 1 ); - verify_rule< must< not_at< alpha, alpha > > >( __LINE__, __FILE__, "aa1", result_type::GLOBAL_FAILURE, 3 ); - { - memory_input<> in( "a", 1, __FILE__ ); - parse< alpha, at_action >( in ); - TAO_PEGTL_TEST_ASSERT( at_counter == 1 ); - } - { - memory_input<> in( "1", 1, __FILE__ ); - parse< not_at< alpha >, at_action >( in ); - TAO_PEGTL_TEST_ASSERT( at_counter == 1 ); - } - { - memory_input<> in( "a", 1, __FILE__ ); - parse< not_at< alpha >, at_action >( in ); - TAO_PEGTL_TEST_ASSERT( at_counter == 1 ); - } + memory_input in( "a", 1, __FILE__ ); + parse< alpha, at_action >( in ); + TAO_PEGTL_TEST_ASSERT( at_counter == 1 ); } + { + memory_input in( "1", 1, __FILE__ ); + parse< not_at< alpha >, at_action >( in ); + TAO_PEGTL_TEST_ASSERT( at_counter == 1 ); + } + { + memory_input in( "a", 1, __FILE__ ); + parse< not_at< alpha >, at_action >( in ); + TAO_PEGTL_TEST_ASSERT( at_counter == 1 ); + } + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_opt.cpp b/packages/PEGTL/src/test/pegtl/rule_opt.cpp index 1fd4dc7b6..951bdb741 100644 --- a/packages/PEGTL/src/test/pegtl/rule_opt.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_opt.cpp @@ -1,69 +1,64 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE - { - template< typename Rule > - struct my_action : nothing< Rule > - { - }; - - template<> - struct my_action< eof > - { - static void apply0( bool& b ) - { - b = true; - } - }; + template< typename Rule > + struct my_action + {}; - void unit_test() + template<> + struct my_action< eof > + { + static void apply0( bool& b ) { - verify_analyze< opt< any > >( __LINE__, __FILE__, false, false ); - verify_analyze< opt< eof > >( __LINE__, __FILE__, false, false ); + b = true; + } + }; - verify_rule< opt< one< 'a' > > >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - verify_rule< opt< one< 'a' > > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 0 ); - verify_rule< opt< one< 'a' > > >( __LINE__, __FILE__, "aa", result_type::SUCCESS, 1 ); - verify_rule< opt< one< 'a' > > >( __LINE__, __FILE__, "ab", result_type::SUCCESS, 1 ); - verify_rule< opt< one< 'a' > > >( __LINE__, __FILE__, "ba", result_type::SUCCESS, 2 ); + void unit_test() + { + verify_analyze< opt< any > >( __LINE__, __FILE__, false, false ); + verify_analyze< opt< eof > >( __LINE__, __FILE__, false, false ); - verify_rule< opt< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - verify_rule< opt< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 1 ); - verify_rule< opt< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::SUCCESS, 0 ); - verify_rule< opt< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aba", result_type::SUCCESS, 1 ); - verify_rule< opt< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abab", result_type::SUCCESS, 2 ); - verify_rule< opt< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "bab", result_type::SUCCESS, 3 ); - verify_rule< opt< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "cb", result_type::SUCCESS, 2 ); + verify_rule< opt< one< 'a' > > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< opt< one< 'a' > > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< opt< one< 'a' > > >( __LINE__, __FILE__, "aa", result_type::success, 1 ); + verify_rule< opt< one< 'a' > > >( __LINE__, __FILE__, "ab", result_type::success, 1 ); + verify_rule< opt< one< 'a' > > >( __LINE__, __FILE__, "ba", result_type::success, 2 ); - verify_rule< must< opt< one< 'a' > > > >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - verify_rule< must< opt< one< 'a' > > > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 0 ); - verify_rule< must< opt< one< 'a' > > > >( __LINE__, __FILE__, "aa", result_type::SUCCESS, 1 ); - verify_rule< must< opt< one< 'a' > > > >( __LINE__, __FILE__, "ab", result_type::SUCCESS, 1 ); - verify_rule< must< opt< one< 'a' > > > >( __LINE__, __FILE__, "ba", result_type::SUCCESS, 2 ); + verify_rule< opt< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< opt< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", result_type::success, 1 ); + verify_rule< opt< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::success, 0 ); + verify_rule< opt< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aba", result_type::success, 1 ); + verify_rule< opt< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abab", result_type::success, 2 ); + verify_rule< opt< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "bab", result_type::success, 3 ); + verify_rule< opt< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "cb", result_type::success, 2 ); - verify_rule< must< opt< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - verify_rule< must< opt< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 1 ); - verify_rule< must< opt< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "ab", result_type::SUCCESS, 0 ); - verify_rule< must< opt< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "aba", result_type::SUCCESS, 1 ); - verify_rule< must< opt< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "abab", result_type::SUCCESS, 2 ); - verify_rule< must< opt< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "bab", result_type::SUCCESS, 3 ); - verify_rule< must< opt< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "cb", result_type::SUCCESS, 2 ); + verify_rule< must< opt< one< 'a' > > > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< must< opt< one< 'a' > > > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< must< opt< one< 'a' > > > >( __LINE__, __FILE__, "aa", result_type::success, 1 ); + verify_rule< must< opt< one< 'a' > > > >( __LINE__, __FILE__, "ab", result_type::success, 1 ); + verify_rule< must< opt< one< 'a' > > > >( __LINE__, __FILE__, "ba", result_type::success, 2 ); - bool success = false; - const bool result = parse< opt< eof >, my_action >( memory_input<>( "", __FUNCTION__ ), success ); - TAO_PEGTL_TEST_ASSERT( result ); - TAO_PEGTL_TEST_ASSERT( success ); - } + verify_rule< must< opt< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< must< opt< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "a", result_type::success, 1 ); + verify_rule< must< opt< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "ab", result_type::success, 0 ); + verify_rule< must< opt< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "aba", result_type::success, 1 ); + verify_rule< must< opt< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "abab", result_type::success, 2 ); + verify_rule< must< opt< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "bab", result_type::success, 3 ); + verify_rule< must< opt< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "cb", result_type::success, 2 ); - } // namespace TAO_PEGTL_NAMESPACE + bool success = false; + const bool result = parse< opt< eof >, my_action >( memory_input( "", __FUNCTION__ ), success ); + TAO_PEGTL_TEST_ASSERT( result ); + TAO_PEGTL_TEST_ASSERT( success ); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_opt_must.cpp b/packages/PEGTL/src/test/pegtl/rule_opt_must.cpp index 279e40804..cd06deea9 100644 --- a/packages/PEGTL/src/test/pegtl/rule_opt_must.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_opt_must.cpp @@ -1,48 +1,44 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< opt_must< any, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< opt_must< eof, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< opt_must< opt< any >, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< opt_must< any, opt< any > > >( __LINE__, __FILE__, false, false ); - verify_analyze< opt_must< any, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< opt_must< opt< any >, opt< any > > >( __LINE__, __FILE__, false, false ); - verify_analyze< opt_must< eof, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< opt_must< any, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< opt_must< eof, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< opt_must< opt< any >, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< opt_must< any, opt< any > > >( __LINE__, __FILE__, false, false ); + verify_analyze< opt_must< any, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< opt_must< opt< any >, opt< any > > >( __LINE__, __FILE__, false, false ); + verify_analyze< opt_must< eof, eof > >( __LINE__, __FILE__, false, false ); - verify_rule< opt_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", result_type::SUCCESS ); - verify_rule< opt_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", result_type::GLOBAL_FAILURE, 0 ); - verify_rule< opt_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "b", result_type::SUCCESS, 1 ); - verify_rule< opt_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ba", result_type::SUCCESS, 2 ); - verify_rule< opt_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::SUCCESS ); - verify_rule< opt_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aba", result_type::SUCCESS, 1 ); - verify_rule< opt_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abb", result_type::SUCCESS, 1 ); - verify_rule< opt_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abab", result_type::SUCCESS, 2 ); - verify_rule< opt_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ac", result_type::GLOBAL_FAILURE, 1 ); - verify_rule< opt_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "acb", result_type::GLOBAL_FAILURE, 2 ); - verify_rule< opt_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "", result_type::SUCCESS ); - verify_rule< opt_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "b", result_type::SUCCESS, 1 ); - verify_rule< opt_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "bc", result_type::SUCCESS, 2 ); - verify_rule< opt_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "a", result_type::GLOBAL_FAILURE, 1 ); - verify_rule< opt_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "ab", result_type::GLOBAL_FAILURE, 2 ); - verify_rule< opt_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "ac", result_type::GLOBAL_FAILURE, 2 ); - verify_rule< opt_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "abb", result_type::GLOBAL_FAILURE, 3 ); - verify_rule< opt_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "acc", result_type::GLOBAL_FAILURE, 3 ); - verify_rule< opt_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "acb", result_type::GLOBAL_FAILURE, 3 ); - verify_rule< opt_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "abc", result_type::SUCCESS, 0 ); - } + verify_rule< opt_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", result_type::success ); + verify_rule< opt_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", result_type::global_failure, 0 ); + verify_rule< opt_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "b", result_type::success, 1 ); + verify_rule< opt_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ba", result_type::success, 2 ); + verify_rule< opt_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::success ); + verify_rule< opt_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aba", result_type::success, 1 ); + verify_rule< opt_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abb", result_type::success, 1 ); + verify_rule< opt_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abab", result_type::success, 2 ); + verify_rule< opt_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ac", result_type::global_failure, 1 ); + verify_rule< opt_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "acb", result_type::global_failure, 2 ); + verify_rule< opt_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "", result_type::success ); + verify_rule< opt_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "b", result_type::success, 1 ); + verify_rule< opt_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "bc", result_type::success, 2 ); + verify_rule< opt_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "a", result_type::global_failure, 1 ); + verify_rule< opt_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "ab", result_type::global_failure, 2 ); + verify_rule< opt_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "ac", result_type::global_failure, 2 ); + verify_rule< opt_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "abb", result_type::global_failure, 3 ); + verify_rule< opt_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "acc", result_type::global_failure, 3 ); + verify_rule< opt_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "acb", result_type::global_failure, 3 ); + verify_rule< opt_must< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "abc", result_type::success, 0 ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_pad.cpp b/packages/PEGTL/src/test/pegtl/rule_pad.cpp index 67c3cdc92..6cb6fe5fd 100644 --- a/packages/PEGTL/src/test/pegtl/rule_pad.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_pad.cpp @@ -1,53 +1,49 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< pad< eof, eof, eof > >( __LINE__, __FILE__, false, true ); - verify_analyze< pad< eof, eof, any > >( __LINE__, __FILE__, false, true ); - verify_analyze< pad< eof, any, eof > >( __LINE__, __FILE__, false, true ); - verify_analyze< pad< eof, any, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< pad< any, eof, eof > >( __LINE__, __FILE__, true, true ); - verify_analyze< pad< any, eof, any > >( __LINE__, __FILE__, true, true ); - verify_analyze< pad< any, any, eof > >( __LINE__, __FILE__, true, true ); - verify_analyze< pad< any, any, any > >( __LINE__, __FILE__, true, false ); + verify_analyze< pad< eof, eof, eof > >( __LINE__, __FILE__, false, true ); + verify_analyze< pad< eof, eof, any > >( __LINE__, __FILE__, false, true ); + verify_analyze< pad< eof, any, eof > >( __LINE__, __FILE__, false, true ); + verify_analyze< pad< eof, any, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< pad< any, eof, eof > >( __LINE__, __FILE__, true, true ); + verify_analyze< pad< any, eof, any > >( __LINE__, __FILE__, true, true ); + verify_analyze< pad< any, any, eof > >( __LINE__, __FILE__, true, true ); + verify_analyze< pad< any, any, any > >( __LINE__, __FILE__, true, false ); - verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, " ", result_type::LOCAL_FAILURE, 1 ); - verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, " ", result_type::LOCAL_FAILURE, 2 ); - verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, "b", result_type::LOCAL_FAILURE, 1 ); - verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, "ba", result_type::LOCAL_FAILURE, 2 ); - verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 0 ); - verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, " a", result_type::SUCCESS, 0 ); - verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, "a ", result_type::SUCCESS, 0 ); - verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, " a", result_type::SUCCESS, 0 ); - verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, "a ", result_type::SUCCESS, 0 ); - verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, " a ", result_type::SUCCESS, 0 ); - verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, " a ", result_type::SUCCESS, 0 ); - verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, "aa", result_type::SUCCESS, 1 ); - verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, "a a", result_type::SUCCESS, 1 ); - verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, " a a ", result_type::SUCCESS, 2 ); + verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, " ", result_type::local_failure, 1 ); + verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, " ", result_type::local_failure, 2 ); + verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, "b", result_type::local_failure, 1 ); + verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, "ba", result_type::local_failure, 2 ); + verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, " a", result_type::success, 0 ); + verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, "a ", result_type::success, 0 ); + verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, " a", result_type::success, 0 ); + verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, "a ", result_type::success, 0 ); + verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, " a ", result_type::success, 0 ); + verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, " a ", result_type::success, 0 ); + verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, "aa", result_type::success, 1 ); + verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, "a a", result_type::success, 1 ); + verify_rule< pad< one< 'a' >, space > >( __LINE__, __FILE__, " a a ", result_type::success, 2 ); - verify_rule< pad< one< 'a' >, digit, blank > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 0 ); - verify_rule< pad< one< 'a' >, digit, blank > >( __LINE__, __FILE__, "1a", result_type::SUCCESS, 0 ); - verify_rule< pad< one< 'a' >, digit, blank > >( __LINE__, __FILE__, "123a", result_type::SUCCESS, 0 ); - verify_rule< pad< one< 'a' >, digit, blank > >( __LINE__, __FILE__, "a ", result_type::SUCCESS, 0 ); - verify_rule< pad< one< 'a' >, digit, blank > >( __LINE__, __FILE__, "a ", result_type::SUCCESS, 0 ); - verify_rule< pad< one< 'a' >, digit, blank > >( __LINE__, __FILE__, "123a ", result_type::SUCCESS, 0 ); - verify_rule< pad< one< 'a' >, digit, blank > >( __LINE__, __FILE__, " a", result_type::LOCAL_FAILURE, 2 ); - verify_rule< pad< one< 'a' >, digit, blank > >( __LINE__, __FILE__, "a1", result_type::SUCCESS, 1 ); - } + verify_rule< pad< one< 'a' >, digit, blank > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< pad< one< 'a' >, digit, blank > >( __LINE__, __FILE__, "1a", result_type::success, 0 ); + verify_rule< pad< one< 'a' >, digit, blank > >( __LINE__, __FILE__, "123a", result_type::success, 0 ); + verify_rule< pad< one< 'a' >, digit, blank > >( __LINE__, __FILE__, "a ", result_type::success, 0 ); + verify_rule< pad< one< 'a' >, digit, blank > >( __LINE__, __FILE__, "a ", result_type::success, 0 ); + verify_rule< pad< one< 'a' >, digit, blank > >( __LINE__, __FILE__, "123a ", result_type::success, 0 ); + verify_rule< pad< one< 'a' >, digit, blank > >( __LINE__, __FILE__, " a", result_type::local_failure, 2 ); + verify_rule< pad< one< 'a' >, digit, blank > >( __LINE__, __FILE__, "a1", result_type::success, 1 ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_pad_opt.cpp b/packages/PEGTL/src/test/pegtl/rule_pad_opt.cpp index 198d0f3ed..d16c5064a 100644 --- a/packages/PEGTL/src/test/pegtl/rule_pad_opt.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_pad_opt.cpp @@ -1,41 +1,37 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< pad_opt< eof, eof > >( __LINE__, __FILE__, false, true ); - verify_analyze< pad_opt< eof, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< pad_opt< any, eof > >( __LINE__, __FILE__, false, true ); - verify_analyze< pad_opt< any, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< pad_opt< eof, eof > >( __LINE__, __FILE__, false, true ); + verify_analyze< pad_opt< eof, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< pad_opt< any, eof > >( __LINE__, __FILE__, false, true ); + verify_analyze< pad_opt< any, any > >( __LINE__, __FILE__, false, false ); - verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, " ", result_type::SUCCESS, 0 ); - verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, " ", result_type::SUCCESS, 0 ); - verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, "b", result_type::SUCCESS, 1 ); - verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, "ba", result_type::SUCCESS, 2 ); - verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 0 ); - verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, " a", result_type::SUCCESS, 0 ); - verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, "a ", result_type::SUCCESS, 0 ); - verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, " a", result_type::SUCCESS, 0 ); - verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, " b", result_type::SUCCESS, 1 ); - verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, "a ", result_type::SUCCESS, 0 ); - verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, " a ", result_type::SUCCESS, 0 ); - verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, " a ", result_type::SUCCESS, 0 ); - verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, "aa", result_type::SUCCESS, 1 ); - verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, "a a", result_type::SUCCESS, 1 ); - verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, " a a ", result_type::SUCCESS, 2 ); - } + verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, " ", result_type::success, 0 ); + verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, " ", result_type::success, 0 ); + verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, "b", result_type::success, 1 ); + verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, "ba", result_type::success, 2 ); + verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, " a", result_type::success, 0 ); + verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, "a ", result_type::success, 0 ); + verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, " a", result_type::success, 0 ); + verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, " b", result_type::success, 1 ); + verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, "a ", result_type::success, 0 ); + verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, " a ", result_type::success, 0 ); + verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, " a ", result_type::success, 0 ); + verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, "aa", result_type::success, 1 ); + verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, "a a", result_type::success, 1 ); + verify_rule< pad_opt< one< 'a' >, space > >( __LINE__, __FILE__, " a a ", result_type::success, 2 ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // 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 113f2739a..251cf15be 100644 --- a/packages/PEGTL/src/test/pegtl/rule_plus.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_plus.cpp @@ -1,46 +1,42 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< plus< eof > >( __LINE__, __FILE__, false, true ); - verify_analyze< plus< any > >( __LINE__, __FILE__, true, false ); - verify_analyze< plus< eof, eof, eof > >( __LINE__, __FILE__, false, true ); - verify_analyze< plus< any, eof, any > >( __LINE__, __FILE__, true, false ); + verify_analyze< plus< eof > >( __LINE__, __FILE__, false, true ); + verify_analyze< plus< any > >( __LINE__, __FILE__, true, false ); + verify_analyze< plus< eof, eof, eof > >( __LINE__, __FILE__, false, true ); + verify_analyze< plus< any, eof, any > >( __LINE__, __FILE__, true, false ); - verify_rule< plus< one< 'a' > > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< plus< one< 'a' > > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 0 ); - verify_rule< plus< one< 'a' > > >( __LINE__, __FILE__, "aa", result_type::SUCCESS, 0 ); - verify_rule< plus< one< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::SUCCESS, 0 ); - verify_rule< plus< one< 'a' > > >( __LINE__, __FILE__, "b", result_type::LOCAL_FAILURE, 1 ); - verify_rule< plus< one< 'a' > > >( __LINE__, __FILE__, "ab", result_type::SUCCESS, 1 ); - verify_rule< plus< one< 'a' > > >( __LINE__, __FILE__, "aab", result_type::SUCCESS, 1 ); - verify_rule< plus< one< 'a' > > >( __LINE__, __FILE__, "aaab", result_type::SUCCESS, 1 ); + verify_rule< plus< one< 'a' > > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< plus< one< 'a' > > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< plus< one< 'a' > > >( __LINE__, __FILE__, "aa", result_type::success, 0 ); + verify_rule< plus< one< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::success, 0 ); + verify_rule< plus< one< 'a' > > >( __LINE__, __FILE__, "b", result_type::local_failure, 1 ); + verify_rule< plus< one< 'a' > > >( __LINE__, __FILE__, "ab", result_type::success, 1 ); + verify_rule< plus< one< 'a' > > >( __LINE__, __FILE__, "aab", result_type::success, 1 ); + verify_rule< plus< one< 'a' > > >( __LINE__, __FILE__, "aaab", result_type::success, 1 ); - verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", result_type::LOCAL_FAILURE, 1 ); - verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "b", result_type::LOCAL_FAILURE, 1 ); - verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::SUCCESS, 0 ); - verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ac", result_type::LOCAL_FAILURE, 2 ); - verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aa", result_type::LOCAL_FAILURE, 2 ); - verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aba", result_type::SUCCESS, 1 ); - verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abb", result_type::SUCCESS, 1 ); - verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abc", result_type::SUCCESS, 1 ); - verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abab", result_type::SUCCESS, 0 ); - verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ababa", result_type::SUCCESS, 1 ); - verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ababb", result_type::SUCCESS, 1 ); - } + verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", result_type::local_failure, 1 ); + verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "b", result_type::local_failure, 1 ); + verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::success, 0 ); + verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ac", result_type::local_failure, 2 ); + verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aa", result_type::local_failure, 2 ); + verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aba", result_type::success, 1 ); + verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abb", result_type::success, 1 ); + verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abc", result_type::success, 1 ); + verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abab", result_type::success, 0 ); + verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ababa", result_type::success, 1 ); + verify_rule< plus< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ababb", result_type::success, 1 ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_rematch.cpp b/packages/PEGTL/src/test/pegtl/rule_rematch.cpp new file mode 100644 index 000000000..d6d384469 --- /dev/null +++ b/packages/PEGTL/src/test/pegtl/rule_rematch.cpp @@ -0,0 +1,97 @@ +// Copyright (c) 2019 Dr. Colin Hirsch and Daniel Frey +// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ + +#include "test.hpp" +#include "verify_analyze.hpp" +#include "verify_rule.hpp" + +namespace TAO_PEGTL_NAMESPACE +{ + void unit_test() + { + verify_rule< rematch< one< 'c' > > >( __LINE__, __FILE__, "c", result_type::success, 0 ); + verify_rule< rematch< one< 'c' > > >( __LINE__, __FILE__, "a", result_type::local_failure, 1 ); + verify_rule< rematch< one< 'c' > > >( __LINE__, __FILE__, "b", result_type::local_failure, 1 ); + verify_rule< rematch< one< 'c' > > >( __LINE__, __FILE__, "cc", result_type::success, 1 ); + verify_rule< rematch< one< 'c' > > >( __LINE__, __FILE__, "bc", result_type::local_failure, 2 ); + + verify_analyze< rematch< alpha, digit > >( __LINE__, __FILE__, true, false ); + verify_analyze< rematch< opt< alpha >, digit > >( __LINE__, __FILE__, false, false ); + + verify_rule< rematch< alnum, digit > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< rematch< alnum, digit > >( __LINE__, __FILE__, "1", result_type::success, 0 ); + verify_rule< rematch< alnum, digit > >( __LINE__, __FILE__, "a", result_type::local_failure, 1 ); + verify_rule< rematch< alnum, digit > >( __LINE__, __FILE__, "%", result_type::local_failure, 1 ); + verify_rule< rematch< alnum, digit > >( __LINE__, __FILE__, "1%", result_type::success, 1 ); + verify_rule< rematch< alnum, digit > >( __LINE__, __FILE__, "a%", result_type::local_failure, 2 ); + verify_rule< rematch< alnum, digit > >( __LINE__, __FILE__, "12", result_type::success, 1 ); + verify_rule< rematch< alnum, digit > >( __LINE__, __FILE__, "1c", result_type::success, 1 ); + + verify_rule< rematch< alnum, digit, success > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< rematch< alnum, digit, success > >( __LINE__, __FILE__, "1", result_type::success, 0 ); + verify_rule< rematch< alnum, digit, success > >( __LINE__, __FILE__, "a", result_type::local_failure, 1 ); + verify_rule< rematch< alnum, digit, success > >( __LINE__, __FILE__, "%", result_type::local_failure, 1 ); + verify_rule< rematch< alnum, digit, success > >( __LINE__, __FILE__, "1%", result_type::success, 1 ); + verify_rule< rematch< alnum, digit, success > >( __LINE__, __FILE__, "a%", result_type::local_failure, 2 ); + verify_rule< rematch< alnum, digit, success > >( __LINE__, __FILE__, "12", result_type::success, 1 ); + verify_rule< rematch< alnum, digit, success > >( __LINE__, __FILE__, "1c", result_type::success, 1 ); + + verify_rule< rematch< alnum, success, digit > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< rematch< alnum, success, digit > >( __LINE__, __FILE__, "1", result_type::success, 0 ); + verify_rule< rematch< alnum, success, digit > >( __LINE__, __FILE__, "a", result_type::local_failure, 1 ); + verify_rule< rematch< alnum, success, digit > >( __LINE__, __FILE__, "%", result_type::local_failure, 1 ); + verify_rule< rematch< alnum, success, digit > >( __LINE__, __FILE__, "1%", result_type::success, 1 ); + verify_rule< rematch< alnum, success, digit > >( __LINE__, __FILE__, "a%", result_type::local_failure, 2 ); + verify_rule< rematch< alnum, success, digit > >( __LINE__, __FILE__, "12", result_type::success, 1 ); + verify_rule< rematch< alnum, success, digit > >( __LINE__, __FILE__, "1c", result_type::success, 1 ); + + verify_rule< rematch< plus< alnum >, digit > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< rematch< plus< alnum >, digit > >( __LINE__, __FILE__, "1", result_type::success, 0 ); + verify_rule< rematch< plus< alnum >, digit > >( __LINE__, __FILE__, "a", result_type::local_failure, 1 ); + verify_rule< rematch< plus< alnum >, digit > >( __LINE__, __FILE__, "%", result_type::local_failure, 1 ); + verify_rule< rematch< plus< alnum >, digit > >( __LINE__, __FILE__, "1%", result_type::success, 1 ); + verify_rule< rematch< plus< alnum >, digit > >( __LINE__, __FILE__, "a%", result_type::local_failure, 1 ); + verify_rule< rematch< plus< alnum >, digit > >( __LINE__, __FILE__, "12", result_type::success, 0 ); + verify_rule< rematch< plus< alnum >, digit > >( __LINE__, __FILE__, "1c", result_type::success, 0 ); + verify_rule< rematch< plus< alnum >, digit > >( __LINE__, __FILE__, "aa", result_type::local_failure, 2 ); + verify_rule< rematch< plus< alnum >, digit > >( __LINE__, __FILE__, "a1", result_type::local_failure, 2 ); + verify_rule< rematch< plus< alnum >, digit > >( __LINE__, __FILE__, "%%", result_type::local_failure, 2 ); + + verify_rule< rematch< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< rematch< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "1", result_type::success, 0 ); + verify_rule< rematch< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "a", result_type::local_failure, 1 ); + verify_rule< rematch< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "%", result_type::local_failure, 1 ); + verify_rule< rematch< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "1%", result_type::success, 1 ); + verify_rule< rematch< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "a%", result_type::local_failure, 1 ); + verify_rule< rematch< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "12", result_type::success, 0 ); + verify_rule< rematch< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "1c", result_type::success, 0 ); + verify_rule< rematch< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "aa", result_type::local_failure, 2 ); + verify_rule< rematch< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "a1", result_type::local_failure, 2 ); + verify_rule< rematch< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "%%", result_type::local_failure, 2 ); + verify_rule< rematch< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "aaa", result_type::local_failure, 3 ); + verify_rule< rematch< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "aaa%", result_type::local_failure, 4 ); + verify_rule< rematch< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "111", result_type::success, 0 ); + verify_rule< rematch< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "111%", result_type::success, 1 ); + verify_rule< rematch< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "a1a", result_type::local_failure, 3 ); + verify_rule< rematch< plus< alnum >, plus< digit > > >( __LINE__, __FILE__, "1a1", result_type::success, 0 ); + + verify_rule< rematch< plus< alnum >, seq< string< 'f', 'o', 'o' >, eof > > >( __LINE__, __FILE__, "foo", result_type::success, 0 ); + verify_rule< rematch< plus< alnum >, seq< string< 'f', 'o', 'o' >, eof > > >( __LINE__, __FILE__, "foo%", result_type::success, 1 ); + verify_rule< rematch< plus< alnum >, seq< string< 'f', 'o', 'o' >, eof > > >( __LINE__, __FILE__, "foo5", result_type::local_failure, 4 ); + + verify_rule< rematch< plus< alnum >, success, seq< string< 'f', 'o', 'o' >, eof > > >( __LINE__, __FILE__, "foo", result_type::success, 0 ); + verify_rule< rematch< plus< alnum >, success, seq< string< 'f', 'o', 'o' >, eof > > >( __LINE__, __FILE__, "foo%", result_type::success, 1 ); + verify_rule< rematch< plus< alnum >, success, seq< string< 'f', 'o', 'o' >, eof > > >( __LINE__, __FILE__, "foo5", result_type::local_failure, 4 ); + + verify_rule< rematch< plus< alnum >, seq< string< 'f', 'o', 'o' >, eof >, success > >( __LINE__, __FILE__, "foo", result_type::success, 0 ); + verify_rule< rematch< plus< alnum >, seq< string< 'f', 'o', 'o' >, eof >, success > >( __LINE__, __FILE__, "foo%", result_type::success, 1 ); + verify_rule< rematch< plus< alnum >, seq< string< 'f', 'o', 'o' >, eof >, success > >( __LINE__, __FILE__, "foo5", result_type::local_failure, 4 ); + + verify_rule< rematch< plus< alnum >, seq< string< 'f', 'o', 'o' >, eof >, string< 'f', 'o', 'o' > > >( __LINE__, __FILE__, "foo", result_type::success, 0 ); + verify_rule< rematch< plus< alnum >, seq< string< 'f', 'o', 'o' >, eof >, string< 'f', 'o', 'o' > > >( __LINE__, __FILE__, "foo%", result_type::success, 1 ); + verify_rule< rematch< plus< alnum >, seq< string< 'f', 'o', 'o' >, eof >, string< 'f', 'o', 'o' > > >( __LINE__, __FILE__, "foo5", result_type::local_failure, 4 ); + } + +} // namespace TAO_PEGTL_NAMESPACE + +#include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_rep.cpp b/packages/PEGTL/src/test/pegtl/rule_rep.cpp index fa76d0ca5..0c54cd851 100644 --- a/packages/PEGTL/src/test/pegtl/rule_rep.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_rep.cpp @@ -1,78 +1,74 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< rep< 0, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep< 0, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep< 1, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep< 1, any > >( __LINE__, __FILE__, true, false ); - verify_analyze< rep< 7, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep< 9, any > >( __LINE__, __FILE__, true, false ); + verify_analyze< rep< 0, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep< 0, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep< 1, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep< 1, any > >( __LINE__, __FILE__, true, false ); + verify_analyze< rep< 7, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep< 9, any > >( __LINE__, __FILE__, true, false ); - verify_analyze< rep< 0, eof, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep< 0, any, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep< 0, any, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep< 0, eof, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep< 1, eof, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep< 1, any, eof > >( __LINE__, __FILE__, true, false ); - verify_analyze< rep< 1, any, any > >( __LINE__, __FILE__, true, false ); - verify_analyze< rep< 1, eof, any > >( __LINE__, __FILE__, true, false ); + verify_analyze< rep< 0, eof, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep< 0, any, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep< 0, any, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep< 0, eof, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep< 1, eof, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep< 1, any, eof > >( __LINE__, __FILE__, true, false ); + verify_analyze< rep< 1, any, any > >( __LINE__, __FILE__, true, false ); + verify_analyze< rep< 1, eof, any > >( __LINE__, __FILE__, true, false ); - verify_rule< rep< 3, one< 'a' > > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< rep< 3, one< 'a' > > >( __LINE__, __FILE__, "a", result_type::LOCAL_FAILURE, 1 ); - verify_rule< rep< 3, one< 'a' > > >( __LINE__, __FILE__, "aa", result_type::LOCAL_FAILURE, 2 ); - verify_rule< rep< 3, one< 'a' > > >( __LINE__, __FILE__, "b", result_type::LOCAL_FAILURE, 1 ); - verify_rule< rep< 3, one< 'a' > > >( __LINE__, __FILE__, "bb", result_type::LOCAL_FAILURE, 2 ); - verify_rule< rep< 3, one< 'a' > > >( __LINE__, __FILE__, "bbb", result_type::LOCAL_FAILURE, 3 ); - verify_rule< rep< 3, one< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::SUCCESS, 0 ); - verify_rule< rep< 3, one< 'a' > > >( __LINE__, __FILE__, "aaaa", result_type::SUCCESS, 1 ); - verify_rule< rep< 3, one< 'a' > > >( __LINE__, __FILE__, "aaab", result_type::SUCCESS, 1 ); - verify_rule< rep< 3, one< 'a' > > >( __LINE__, __FILE__, "baaab", result_type::LOCAL_FAILURE, 5 ); + verify_rule< rep< 3, one< 'a' > > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< rep< 3, one< 'a' > > >( __LINE__, __FILE__, "a", result_type::local_failure, 1 ); + verify_rule< rep< 3, one< 'a' > > >( __LINE__, __FILE__, "aa", result_type::local_failure, 2 ); + verify_rule< rep< 3, one< 'a' > > >( __LINE__, __FILE__, "b", result_type::local_failure, 1 ); + verify_rule< rep< 3, one< 'a' > > >( __LINE__, __FILE__, "bb", result_type::local_failure, 2 ); + verify_rule< rep< 3, one< 'a' > > >( __LINE__, __FILE__, "bbb", result_type::local_failure, 3 ); + verify_rule< rep< 3, one< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::success, 0 ); + verify_rule< rep< 3, one< 'a' > > >( __LINE__, __FILE__, "aaaa", result_type::success, 1 ); + verify_rule< rep< 3, one< 'a' > > >( __LINE__, __FILE__, "aaab", result_type::success, 1 ); + verify_rule< rep< 3, one< 'a' > > >( __LINE__, __FILE__, "baaab", result_type::local_failure, 5 ); - verify_rule< rep< 2, two< 'a' > > >( __LINE__, __FILE__, "a", result_type::LOCAL_FAILURE, 1 ); - verify_rule< rep< 2, two< 'a' > > >( __LINE__, __FILE__, "aa", result_type::LOCAL_FAILURE, 2 ); - verify_rule< rep< 2, two< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::LOCAL_FAILURE, 3 ); - verify_rule< rep< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaa", result_type::SUCCESS, 0 ); - verify_rule< rep< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaa", result_type::SUCCESS, 1 ); - verify_rule< rep< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaaa", result_type::SUCCESS, 2 ); - verify_rule< rep< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaaaa", result_type::SUCCESS, 3 ); + verify_rule< rep< 2, two< 'a' > > >( __LINE__, __FILE__, "a", result_type::local_failure, 1 ); + verify_rule< rep< 2, two< 'a' > > >( __LINE__, __FILE__, "aa", result_type::local_failure, 2 ); + verify_rule< rep< 2, two< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::local_failure, 3 ); + verify_rule< rep< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaa", result_type::success, 0 ); + verify_rule< rep< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaa", result_type::success, 1 ); + verify_rule< rep< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaaa", result_type::success, 2 ); + verify_rule< rep< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaaaa", result_type::success, 3 ); - verify_rule< rep< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< rep< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", result_type::LOCAL_FAILURE, 1 ); - verify_rule< rep< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::LOCAL_FAILURE, 2 ); - verify_rule< rep< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aba", result_type::LOCAL_FAILURE, 3 ); - verify_rule< rep< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abab", result_type::SUCCESS, 0 ); - verify_rule< rep< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ababa", result_type::SUCCESS, 1 ); - verify_rule< rep< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ababab", result_type::SUCCESS, 2 ); + verify_rule< rep< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< rep< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", result_type::local_failure, 1 ); + verify_rule< rep< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::local_failure, 2 ); + verify_rule< rep< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aba", result_type::local_failure, 3 ); + verify_rule< rep< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abab", result_type::success, 0 ); + verify_rule< rep< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ababa", result_type::success, 1 ); + verify_rule< rep< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ababab", result_type::success, 2 ); - verify_rule< must< rep< 2, one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "", result_type::GLOBAL_FAILURE, 0 ); - verify_rule< must< rep< 2, one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "a", result_type::GLOBAL_FAILURE, 1 ); - verify_rule< must< rep< 2, one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "ab", result_type::GLOBAL_FAILURE, 0 ); - verify_rule< must< rep< 2, one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "aba", result_type::GLOBAL_FAILURE, 1 ); - verify_rule< must< rep< 2, one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "abab", result_type::SUCCESS, 0 ); - verify_rule< must< rep< 2, one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "ababa", result_type::SUCCESS, 1 ); - verify_rule< must< rep< 2, one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "ababab", result_type::SUCCESS, 2 ); + verify_rule< must< rep< 2, one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "", result_type::global_failure, 0 ); + verify_rule< must< rep< 2, one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "a", result_type::global_failure, 1 ); + verify_rule< must< rep< 2, one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "ab", result_type::global_failure, 0 ); + verify_rule< must< rep< 2, one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "aba", result_type::global_failure, 1 ); + verify_rule< must< rep< 2, one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "abab", result_type::success, 0 ); + verify_rule< must< rep< 2, one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "ababa", result_type::success, 1 ); + verify_rule< must< rep< 2, one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "ababab", result_type::success, 2 ); - verify_rule< try_catch< must< rep< 2, one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< try_catch< must< rep< 2, one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "a", result_type::LOCAL_FAILURE, 1 ); - verify_rule< try_catch< must< rep< 2, one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "ab", result_type::LOCAL_FAILURE, 2 ); - verify_rule< try_catch< must< rep< 2, one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "aba", result_type::LOCAL_FAILURE, 3 ); - verify_rule< try_catch< must< rep< 2, one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "abab", result_type::SUCCESS, 0 ); - verify_rule< try_catch< must< rep< 2, one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "ababa", result_type::SUCCESS, 1 ); - verify_rule< try_catch< must< rep< 2, one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "ababab", result_type::SUCCESS, 2 ); - } + verify_rule< try_catch< must< rep< 2, one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< try_catch< must< rep< 2, one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "a", result_type::local_failure, 1 ); + verify_rule< try_catch< must< rep< 2, one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "ab", result_type::local_failure, 2 ); + verify_rule< try_catch< must< rep< 2, one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "aba", result_type::local_failure, 3 ); + verify_rule< try_catch< must< rep< 2, one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "abab", result_type::success, 0 ); + verify_rule< try_catch< must< rep< 2, one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "ababa", result_type::success, 1 ); + verify_rule< try_catch< must< rep< 2, one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "ababab", result_type::success, 2 ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_rep_max.cpp b/packages/PEGTL/src/test/pegtl/rule_rep_max.cpp index 30d19ae6c..60dfb0b34 100644 --- a/packages/PEGTL/src/test/pegtl/rule_rep_max.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_rep_max.cpp @@ -1,58 +1,54 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< rep_max< 1, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep_max< 2, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep_max< 1, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep_max< 2, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep_max< 1, any, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep_max< 2, any, any > >( __LINE__, __FILE__, false, false ); - - verify_rule< rep_max< 3, one< 'a' > > >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - verify_rule< rep_max< 3, one< 'a' > > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 0 ); - verify_rule< rep_max< 3, one< 'a' > > >( __LINE__, __FILE__, "aa", result_type::SUCCESS, 0 ); - verify_rule< rep_max< 3, one< 'a' > > >( __LINE__, __FILE__, "b", result_type::SUCCESS, 1 ); - verify_rule< rep_max< 3, one< 'a' > > >( __LINE__, __FILE__, "bb", result_type::SUCCESS, 2 ); - verify_rule< rep_max< 3, one< 'a' > > >( __LINE__, __FILE__, "bbb", result_type::SUCCESS, 3 ); - verify_rule< rep_max< 3, one< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::SUCCESS, 0 ); - verify_rule< rep_max< 3, one< 'a' > > >( __LINE__, __FILE__, "aaaa", result_type::LOCAL_FAILURE, 4 ); - verify_rule< rep_max< 3, one< 'a' > > >( __LINE__, __FILE__, "aaab", result_type::SUCCESS, 1 ); - verify_rule< rep_max< 3, one< 'a' > > >( __LINE__, __FILE__, "baaab", result_type::SUCCESS, 5 ); - - verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 1 ); - verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aa", result_type::SUCCESS, 2 ); - verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ba", result_type::SUCCESS, 2 ); - verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::SUCCESS, 0 ); - verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aba", result_type::SUCCESS, 1 ); - verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abb", result_type::SUCCESS, 1 ); - verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aab", result_type::SUCCESS, 3 ); - verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abab", result_type::SUCCESS, 0 ); - verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ababb", result_type::SUCCESS, 1 ); - verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ababa", result_type::SUCCESS, 1 ); - verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ababab", result_type::LOCAL_FAILURE, 6 ); - - verify_rule< rep_max< 2, two< 'a' > > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 1 ); - verify_rule< rep_max< 2, two< 'a' > > >( __LINE__, __FILE__, "aa", result_type::SUCCESS, 0 ); - verify_rule< rep_max< 2, two< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::SUCCESS, 1 ); - verify_rule< rep_max< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaa", result_type::SUCCESS, 0 ); - verify_rule< rep_max< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaa", result_type::SUCCESS, 1 ); - verify_rule< rep_max< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaaa", result_type::LOCAL_FAILURE, 6 ); - verify_rule< rep_max< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaaaa", result_type::LOCAL_FAILURE, 7 ); - } - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + verify_analyze< rep_max< 1, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep_max< 2, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep_max< 1, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep_max< 2, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep_max< 1, any, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep_max< 2, any, any > >( __LINE__, __FILE__, false, false ); + + verify_rule< rep_max< 3, one< 'a' > > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< rep_max< 3, one< 'a' > > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< rep_max< 3, one< 'a' > > >( __LINE__, __FILE__, "aa", result_type::success, 0 ); + verify_rule< rep_max< 3, one< 'a' > > >( __LINE__, __FILE__, "b", result_type::success, 1 ); + verify_rule< rep_max< 3, one< 'a' > > >( __LINE__, __FILE__, "bb", result_type::success, 2 ); + verify_rule< rep_max< 3, one< 'a' > > >( __LINE__, __FILE__, "bbb", result_type::success, 3 ); + verify_rule< rep_max< 3, one< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::success, 0 ); + verify_rule< rep_max< 3, one< 'a' > > >( __LINE__, __FILE__, "aaaa", result_type::local_failure, 4 ); + verify_rule< rep_max< 3, one< 'a' > > >( __LINE__, __FILE__, "aaab", result_type::success, 1 ); + verify_rule< rep_max< 3, one< 'a' > > >( __LINE__, __FILE__, "baaab", result_type::success, 5 ); + + verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", result_type::success, 1 ); + verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aa", result_type::success, 2 ); + verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ba", result_type::success, 2 ); + verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::success, 0 ); + verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aba", result_type::success, 1 ); + verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abb", result_type::success, 1 ); + verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aab", result_type::success, 3 ); + verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abab", result_type::success, 0 ); + verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ababb", result_type::success, 1 ); + verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ababa", result_type::success, 1 ); + verify_rule< rep_max< 2, one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ababab", result_type::local_failure, 6 ); + + verify_rule< rep_max< 2, two< 'a' > > >( __LINE__, __FILE__, "a", result_type::success, 1 ); + verify_rule< rep_max< 2, two< 'a' > > >( __LINE__, __FILE__, "aa", result_type::success, 0 ); + verify_rule< rep_max< 2, two< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::success, 1 ); + verify_rule< rep_max< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaa", result_type::success, 0 ); + verify_rule< rep_max< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaa", result_type::success, 1 ); + verify_rule< rep_max< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaaa", result_type::local_failure, 6 ); + verify_rule< rep_max< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaaaa", result_type::local_failure, 7 ); + } + +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_rep_min.cpp b/packages/PEGTL/src/test/pegtl/rule_rep_min.cpp index 0db1afde3..20a33d5eb 100644 --- a/packages/PEGTL/src/test/pegtl/rule_rep_min.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_rep_min.cpp @@ -1,43 +1,39 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< rep_min< 0, eof > >( __LINE__, __FILE__, false, true ); - verify_analyze< rep_min< 1, eof > >( __LINE__, __FILE__, false, true ); - verify_analyze< rep_min< 0, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep_min< 1, any > >( __LINE__, __FILE__, true, false ); + verify_analyze< rep_min< 0, eof > >( __LINE__, __FILE__, false, true ); + verify_analyze< rep_min< 1, eof > >( __LINE__, __FILE__, false, true ); + verify_analyze< rep_min< 0, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep_min< 1, any > >( __LINE__, __FILE__, true, false ); - verify_rule< rep_min< 3, one< 'a' > > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< rep_min< 3, one< 'a' > > >( __LINE__, __FILE__, "a", result_type::LOCAL_FAILURE, 1 ); - verify_rule< rep_min< 3, one< 'a' > > >( __LINE__, __FILE__, "aa", result_type::LOCAL_FAILURE, 2 ); - verify_rule< rep_min< 3, one< 'a' > > >( __LINE__, __FILE__, "b", result_type::LOCAL_FAILURE, 1 ); - verify_rule< rep_min< 3, one< 'a' > > >( __LINE__, __FILE__, "bb", result_type::LOCAL_FAILURE, 2 ); - verify_rule< rep_min< 3, one< 'a' > > >( __LINE__, __FILE__, "bbb", result_type::LOCAL_FAILURE, 3 ); - verify_rule< rep_min< 3, one< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::SUCCESS, 0 ); - verify_rule< rep_min< 3, one< 'a' > > >( __LINE__, __FILE__, "aaaa", result_type::SUCCESS, 0 ); - verify_rule< rep_min< 3, one< 'a' > > >( __LINE__, __FILE__, "aaab", result_type::SUCCESS, 1 ); - verify_rule< rep_min< 3, one< 'a' > > >( __LINE__, __FILE__, "baaab", result_type::LOCAL_FAILURE, 5 ); + verify_rule< rep_min< 3, one< 'a' > > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< rep_min< 3, one< 'a' > > >( __LINE__, __FILE__, "a", result_type::local_failure, 1 ); + verify_rule< rep_min< 3, one< 'a' > > >( __LINE__, __FILE__, "aa", result_type::local_failure, 2 ); + verify_rule< rep_min< 3, one< 'a' > > >( __LINE__, __FILE__, "b", result_type::local_failure, 1 ); + verify_rule< rep_min< 3, one< 'a' > > >( __LINE__, __FILE__, "bb", result_type::local_failure, 2 ); + verify_rule< rep_min< 3, one< 'a' > > >( __LINE__, __FILE__, "bbb", result_type::local_failure, 3 ); + verify_rule< rep_min< 3, one< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::success, 0 ); + verify_rule< rep_min< 3, one< 'a' > > >( __LINE__, __FILE__, "aaaa", result_type::success, 0 ); + verify_rule< rep_min< 3, one< 'a' > > >( __LINE__, __FILE__, "aaab", result_type::success, 1 ); + verify_rule< rep_min< 3, one< 'a' > > >( __LINE__, __FILE__, "baaab", result_type::local_failure, 5 ); - verify_rule< rep_min< 2, two< 'a' > > >( __LINE__, __FILE__, "a", result_type::LOCAL_FAILURE, 1 ); - verify_rule< rep_min< 2, two< 'a' > > >( __LINE__, __FILE__, "aa", result_type::LOCAL_FAILURE, 2 ); - verify_rule< rep_min< 2, two< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::LOCAL_FAILURE, 3 ); - verify_rule< rep_min< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaa", result_type::SUCCESS, 0 ); - verify_rule< rep_min< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaa", result_type::SUCCESS, 1 ); - verify_rule< rep_min< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaaa", result_type::SUCCESS, 0 ); - verify_rule< rep_min< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaaaa", result_type::SUCCESS, 1 ); - } + verify_rule< rep_min< 2, two< 'a' > > >( __LINE__, __FILE__, "a", result_type::local_failure, 1 ); + verify_rule< rep_min< 2, two< 'a' > > >( __LINE__, __FILE__, "aa", result_type::local_failure, 2 ); + verify_rule< rep_min< 2, two< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::local_failure, 3 ); + verify_rule< rep_min< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaa", result_type::success, 0 ); + verify_rule< rep_min< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaa", result_type::success, 1 ); + verify_rule< rep_min< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaaa", result_type::success, 0 ); + verify_rule< rep_min< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaaaa", result_type::success, 1 ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" 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 446cd6cd8..8ad8a1119 100644 --- a/packages/PEGTL/src/test/pegtl/rule_rep_min_max.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_rep_min_max.cpp @@ -1,53 +1,49 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< rep_min_max< 0, 1, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep_min_max< 0, 2, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep_min_max< 1, 2, any > >( __LINE__, __FILE__, true, false ); - verify_analyze< rep_min_max< 0, 1, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep_min_max< 0, 2, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep_min_max< 1, 2, eof > >( __LINE__, __FILE__, false, false ); - - verify_analyze< rep_min_max< 0, 1, any, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep_min_max< 0, 2, any, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep_min_max< 1, 2, eof, any > >( __LINE__, __FILE__, true, false ); - verify_analyze< rep_min_max< 0, 1, eof, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep_min_max< 0, 2, eof, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep_min_max< 1, 2, eof, eof > >( __LINE__, __FILE__, false, false ); - - verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "a", result_type::LOCAL_FAILURE, 1 ); - verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "aa", result_type::SUCCESS, 0 ); - verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::SUCCESS, 0 ); - verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "aaaa", result_type::SUCCESS, 0 ); - verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "aaaaa", result_type::LOCAL_FAILURE, 5 ); - verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "b", result_type::LOCAL_FAILURE, 1 ); - verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "bb", result_type::LOCAL_FAILURE, 2 ); - verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "bbb", result_type::LOCAL_FAILURE, 3 ); - verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "bbbb", result_type::LOCAL_FAILURE, 4 ); - verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "bbbbb", result_type::LOCAL_FAILURE, 5 ); - verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "ba", result_type::LOCAL_FAILURE, 2 ); - verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "baa", result_type::LOCAL_FAILURE, 3 ); - verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "baaa", result_type::LOCAL_FAILURE, 4 ); - verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "baaaa", result_type::LOCAL_FAILURE, 5 ); - - verify_rule< must< rep_min_max< 3, 4, one< 'a' > > > >( __LINE__, __FILE__, "aa", result_type::GLOBAL_FAILURE, 0 ); - - verify_rule< try_catch< must< rep_min_max< 3, 4, one< 'a' > > > > >( __LINE__, __FILE__, "aa", result_type::LOCAL_FAILURE, 2 ); - } - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + verify_analyze< rep_min_max< 0, 1, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep_min_max< 0, 2, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep_min_max< 1, 2, any > >( __LINE__, __FILE__, true, false ); + verify_analyze< rep_min_max< 0, 1, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep_min_max< 0, 2, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep_min_max< 1, 2, eof > >( __LINE__, __FILE__, false, false ); + + verify_analyze< rep_min_max< 0, 1, any, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep_min_max< 0, 2, any, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep_min_max< 1, 2, eof, any > >( __LINE__, __FILE__, true, false ); + verify_analyze< rep_min_max< 0, 1, eof, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep_min_max< 0, 2, eof, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep_min_max< 1, 2, eof, eof > >( __LINE__, __FILE__, false, false ); + + verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "a", result_type::local_failure, 1 ); + verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "aa", result_type::success, 0 ); + verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::success, 0 ); + verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "aaaa", result_type::success, 0 ); + verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "aaaaa", result_type::local_failure, 5 ); + verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "b", result_type::local_failure, 1 ); + verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "bb", result_type::local_failure, 2 ); + verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "bbb", result_type::local_failure, 3 ); + verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "bbbb", result_type::local_failure, 4 ); + verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "bbbbb", result_type::local_failure, 5 ); + verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "ba", result_type::local_failure, 2 ); + verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "baa", result_type::local_failure, 3 ); + verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "baaa", result_type::local_failure, 4 ); + verify_rule< rep_min_max< 2, 4, one< 'a' > > >( __LINE__, __FILE__, "baaaa", result_type::local_failure, 5 ); + + verify_rule< must< rep_min_max< 3, 4, one< 'a' > > > >( __LINE__, __FILE__, "aa", result_type::global_failure, 0 ); + + verify_rule< try_catch< must< rep_min_max< 3, 4, one< 'a' > > > > >( __LINE__, __FILE__, "aa", result_type::local_failure, 2 ); + } + +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_rep_opt.cpp b/packages/PEGTL/src/test/pegtl/rule_rep_opt.cpp index 56764e072..2e232f769 100644 --- a/packages/PEGTL/src/test/pegtl/rule_rep_opt.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_rep_opt.cpp @@ -1,48 +1,44 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< rep_opt< 1, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep_opt< 6, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep_opt< 1, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep_opt< 6, eof > >( __LINE__, __FILE__, false, false ); - - verify_analyze< rep_opt< 1, any, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep_opt< 1, eof, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep_opt< 1, any, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< rep_opt< 1, eof, eof > >( __LINE__, __FILE__, false, false ); - - verify_rule< rep_opt< 3, one< 'a' > > >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - verify_rule< rep_opt< 3, one< 'a' > > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 0 ); - verify_rule< rep_opt< 3, one< 'a' > > >( __LINE__, __FILE__, "aa", result_type::SUCCESS, 0 ); - verify_rule< rep_opt< 3, one< 'a' > > >( __LINE__, __FILE__, "b", result_type::SUCCESS, 1 ); - verify_rule< rep_opt< 3, one< 'a' > > >( __LINE__, __FILE__, "bb", result_type::SUCCESS, 2 ); - verify_rule< rep_opt< 3, one< 'a' > > >( __LINE__, __FILE__, "bbb", result_type::SUCCESS, 3 ); - verify_rule< rep_opt< 3, one< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::SUCCESS, 0 ); - verify_rule< rep_opt< 3, one< 'a' > > >( __LINE__, __FILE__, "aaaa", result_type::SUCCESS, 1 ); - verify_rule< rep_opt< 3, one< 'a' > > >( __LINE__, __FILE__, "aaab", result_type::SUCCESS, 1 ); - verify_rule< rep_opt< 3, one< 'a' > > >( __LINE__, __FILE__, "baaab", result_type::SUCCESS, 5 ); - - verify_rule< rep_opt< 2, two< 'a' > > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 1 ); - verify_rule< rep_opt< 2, two< 'a' > > >( __LINE__, __FILE__, "aa", result_type::SUCCESS, 0 ); - verify_rule< rep_opt< 2, two< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::SUCCESS, 1 ); - verify_rule< rep_opt< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaa", result_type::SUCCESS, 0 ); - verify_rule< rep_opt< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaa", result_type::SUCCESS, 1 ); - verify_rule< rep_opt< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaaa", result_type::SUCCESS, 2 ); - verify_rule< rep_opt< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaaaa", result_type::SUCCESS, 3 ); - } - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + verify_analyze< rep_opt< 1, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep_opt< 6, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep_opt< 1, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep_opt< 6, eof > >( __LINE__, __FILE__, false, false ); + + verify_analyze< rep_opt< 1, any, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep_opt< 1, eof, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep_opt< 1, any, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< rep_opt< 1, eof, eof > >( __LINE__, __FILE__, false, false ); + + verify_rule< rep_opt< 3, one< 'a' > > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< rep_opt< 3, one< 'a' > > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< rep_opt< 3, one< 'a' > > >( __LINE__, __FILE__, "aa", result_type::success, 0 ); + verify_rule< rep_opt< 3, one< 'a' > > >( __LINE__, __FILE__, "b", result_type::success, 1 ); + verify_rule< rep_opt< 3, one< 'a' > > >( __LINE__, __FILE__, "bb", result_type::success, 2 ); + verify_rule< rep_opt< 3, one< 'a' > > >( __LINE__, __FILE__, "bbb", result_type::success, 3 ); + verify_rule< rep_opt< 3, one< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::success, 0 ); + verify_rule< rep_opt< 3, one< 'a' > > >( __LINE__, __FILE__, "aaaa", result_type::success, 1 ); + verify_rule< rep_opt< 3, one< 'a' > > >( __LINE__, __FILE__, "aaab", result_type::success, 1 ); + verify_rule< rep_opt< 3, one< 'a' > > >( __LINE__, __FILE__, "baaab", result_type::success, 5 ); + + verify_rule< rep_opt< 2, two< 'a' > > >( __LINE__, __FILE__, "a", result_type::success, 1 ); + verify_rule< rep_opt< 2, two< 'a' > > >( __LINE__, __FILE__, "aa", result_type::success, 0 ); + verify_rule< rep_opt< 2, two< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::success, 1 ); + verify_rule< rep_opt< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaa", result_type::success, 0 ); + verify_rule< rep_opt< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaa", result_type::success, 1 ); + verify_rule< rep_opt< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaaa", result_type::success, 2 ); + verify_rule< rep_opt< 2, two< 'a' > > >( __LINE__, __FILE__, "aaaaaaa", result_type::success, 3 ); + } + +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_require.cpp b/packages/PEGTL/src/test/pegtl/rule_require.cpp index f020edd3f..0a8e389ed 100644 --- a/packages/PEGTL/src/test/pegtl/rule_require.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_require.cpp @@ -1,41 +1,37 @@ -// Copyright (c) 2017-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2017-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< require< 0 > >( __LINE__, __FILE__, false, false ); - verify_analyze< require< 1 > >( __LINE__, __FILE__, false, false ); - verify_analyze< require< 9 > >( __LINE__, __FILE__, false, false ); + verify_analyze< require< 0 > >( __LINE__, __FILE__, false, false ); + verify_analyze< require< 1 > >( __LINE__, __FILE__, false, false ); + verify_analyze< require< 9 > >( __LINE__, __FILE__, false, false ); - verify_rule< require< 0 > >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - verify_rule< require< 0 > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 1 ); - verify_rule< require< 0 > >( __LINE__, __FILE__, " ", result_type::SUCCESS, 2 ); - verify_rule< require< 1 > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< require< 1 > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 1 ); - verify_rule< require< 1 > >( __LINE__, __FILE__, " ", result_type::SUCCESS, 2 ); - verify_rule< require< 9 > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< require< 9 > >( __LINE__, __FILE__, "1", result_type::LOCAL_FAILURE, 1 ); - verify_rule< require< 9 > >( __LINE__, __FILE__, "12", result_type::LOCAL_FAILURE, 2 ); - verify_rule< require< 9 > >( __LINE__, __FILE__, "123", result_type::LOCAL_FAILURE, 3 ); - verify_rule< require< 9 > >( __LINE__, __FILE__, "1234", result_type::LOCAL_FAILURE, 4 ); - verify_rule< require< 9 > >( __LINE__, __FILE__, "12345", result_type::LOCAL_FAILURE, 5 ); - verify_rule< require< 9 > >( __LINE__, __FILE__, "123456", result_type::LOCAL_FAILURE, 6 ); - verify_rule< require< 9 > >( __LINE__, __FILE__, "1234567", result_type::LOCAL_FAILURE, 7 ); - verify_rule< require< 9 > >( __LINE__, __FILE__, "12345678", result_type::LOCAL_FAILURE, 8 ); - verify_rule< require< 9 > >( __LINE__, __FILE__, "123456789", result_type::SUCCESS, 9 ); - verify_rule< require< 9 > >( __LINE__, __FILE__, "123456789123456789", result_type::SUCCESS, 18 ); - } + verify_rule< require< 0 > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< require< 0 > >( __LINE__, __FILE__, "a", result_type::success, 1 ); + verify_rule< require< 0 > >( __LINE__, __FILE__, " ", result_type::success, 2 ); + verify_rule< require< 1 > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< require< 1 > >( __LINE__, __FILE__, "a", result_type::success, 1 ); + verify_rule< require< 1 > >( __LINE__, __FILE__, " ", result_type::success, 2 ); + verify_rule< require< 9 > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< require< 9 > >( __LINE__, __FILE__, "1", result_type::local_failure, 1 ); + verify_rule< require< 9 > >( __LINE__, __FILE__, "12", result_type::local_failure, 2 ); + verify_rule< require< 9 > >( __LINE__, __FILE__, "123", result_type::local_failure, 3 ); + verify_rule< require< 9 > >( __LINE__, __FILE__, "1234", result_type::local_failure, 4 ); + verify_rule< require< 9 > >( __LINE__, __FILE__, "12345", result_type::local_failure, 5 ); + verify_rule< require< 9 > >( __LINE__, __FILE__, "123456", result_type::local_failure, 6 ); + verify_rule< require< 9 > >( __LINE__, __FILE__, "1234567", result_type::local_failure, 7 ); + verify_rule< require< 9 > >( __LINE__, __FILE__, "12345678", result_type::local_failure, 8 ); + verify_rule< require< 9 > >( __LINE__, __FILE__, "123456789", result_type::success, 9 ); + verify_rule< require< 9 > >( __LINE__, __FILE__, "123456789123456789", result_type::success, 18 ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_seq.cpp b/packages/PEGTL/src/test/pegtl/rule_seq.cpp index 405ba6798..686d6ba9c 100644 --- a/packages/PEGTL/src/test/pegtl/rule_seq.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_seq.cpp @@ -1,20 +1,16 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_seqs.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_seqs< seq >(); - } + verify_seqs< seq >(); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_sor.cpp b/packages/PEGTL/src/test/pegtl/rule_sor.cpp index d14c20b0c..01385de84 100644 --- a/packages/PEGTL/src/test/pegtl/rule_sor.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_sor.cpp @@ -1,53 +1,49 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< sor< eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< sor< any > >( __LINE__, __FILE__, true, false ); - - verify_analyze< sor< any, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< sor< eof, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< sor< eof, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< sor< any, any > >( __LINE__, __FILE__, true, false ); - - verify_analyze< sor< any, any, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< sor< any, eof, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< sor< any, eof, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< sor< any, any, any > >( __LINE__, __FILE__, true, false ); - verify_analyze< sor< eof, any, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< sor< eof, eof, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< sor< eof, eof, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< sor< eof, any, any > >( __LINE__, __FILE__, false, false ); - - verify_rule< sor<> >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< sor<> >( __LINE__, __FILE__, "a", result_type::LOCAL_FAILURE, 1 ); - - verify_rule< sor< one< 'a' > > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< sor< one< 'a' > > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 0 ); - verify_rule< sor< one< 'a' > > >( __LINE__, __FILE__, "aa", result_type::SUCCESS, 1 ); - - verify_rule< sor< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< sor< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 0 ); - verify_rule< sor< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "b", result_type::SUCCESS, 0 ); - verify_rule< sor< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "c", result_type::LOCAL_FAILURE, 1 ); - verify_rule< sor< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aa", result_type::SUCCESS, 1 ); - verify_rule< sor< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::SUCCESS, 1 ); - verify_rule< sor< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ba", result_type::SUCCESS, 1 ); - verify_rule< sor< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "bb", result_type::SUCCESS, 1 ); - verify_rule< sor< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "cb", result_type::LOCAL_FAILURE, 2 ); - } - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + verify_analyze< sor< eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< sor< any > >( __LINE__, __FILE__, true, false ); + + verify_analyze< sor< any, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< sor< eof, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< sor< eof, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< sor< any, any > >( __LINE__, __FILE__, true, false ); + + verify_analyze< sor< any, any, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< sor< any, eof, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< sor< any, eof, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< sor< any, any, any > >( __LINE__, __FILE__, true, false ); + verify_analyze< sor< eof, any, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< sor< eof, eof, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< sor< eof, eof, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< sor< eof, any, any > >( __LINE__, __FILE__, false, false ); + + verify_rule< sor<> >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< sor<> >( __LINE__, __FILE__, "a", result_type::local_failure, 1 ); + + verify_rule< sor< one< 'a' > > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< sor< one< 'a' > > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< sor< one< 'a' > > >( __LINE__, __FILE__, "aa", result_type::success, 1 ); + + verify_rule< sor< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< sor< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< sor< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "b", result_type::success, 0 ); + verify_rule< sor< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "c", result_type::local_failure, 1 ); + verify_rule< sor< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aa", result_type::success, 1 ); + verify_rule< sor< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::success, 1 ); + verify_rule< sor< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ba", result_type::success, 1 ); + verify_rule< sor< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "bb", result_type::success, 1 ); + verify_rule< sor< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "cb", result_type::local_failure, 2 ); + } + +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_star.cpp b/packages/PEGTL/src/test/pegtl/rule_star.cpp index 4bf89e78f..1689eaff6 100644 --- a/packages/PEGTL/src/test/pegtl/rule_star.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_star.cpp @@ -1,40 +1,36 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< star< eof > >( __LINE__, __FILE__, false, true ); - verify_analyze< star< any > >( __LINE__, __FILE__, false, false ); - verify_analyze< star< eof, eof, eof > >( __LINE__, __FILE__, false, true ); - verify_analyze< star< any, eof, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< star< eof > >( __LINE__, __FILE__, false, true ); + verify_analyze< star< any > >( __LINE__, __FILE__, false, false ); + verify_analyze< star< eof, eof, eof > >( __LINE__, __FILE__, false, true ); + verify_analyze< star< any, eof, any > >( __LINE__, __FILE__, false, false ); - verify_rule< star< one< 'a' > > >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - 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__, "ba", result_type::SUCCESS, 2 ); - verify_rule< star< one< 'a' > > >( __LINE__, __FILE__, "b", result_type::SUCCESS, 1 ); + verify_rule< star< one< 'a' > > >( __LINE__, __FILE__, "", result_type::success, 0 ); + 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__, "ba", result_type::success, 2 ); + verify_rule< star< one< 'a' > > >( __LINE__, __FILE__, "b", result_type::success, 1 ); - verify_rule< star< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - 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__, "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 ); - verify_rule< star< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ababab", result_type::SUCCESS, 0 ); - } + verify_rule< star< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", result_type::success, 0 ); + 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__, "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 ); + verify_rule< star< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ababab", result_type::success, 0 ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_star_must.cpp b/packages/PEGTL/src/test/pegtl/rule_star_must.cpp index ed72bb6dc..b2300c8f7 100644 --- a/packages/PEGTL/src/test/pegtl/rule_star_must.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_star_must.cpp @@ -1,40 +1,36 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< star_must< eof > >( __LINE__, __FILE__, false, true ); - verify_analyze< star_must< any > >( __LINE__, __FILE__, false, false ); - verify_analyze< star_must< eof, eof, eof > >( __LINE__, __FILE__, false, true ); - verify_analyze< star_must< any, eof, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< star_must< eof > >( __LINE__, __FILE__, false, true ); + verify_analyze< star_must< any > >( __LINE__, __FILE__, false, false ); + verify_analyze< star_must< eof, eof, eof > >( __LINE__, __FILE__, false, true ); + verify_analyze< star_must< any, eof, any > >( __LINE__, __FILE__, false, false ); - verify_rule< star_must< one< 'a' > > >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - verify_rule< star_must< one< 'a' > > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 0 ); - verify_rule< star_must< one< 'a' > > >( __LINE__, __FILE__, "aa", result_type::SUCCESS, 0 ); - verify_rule< star_must< one< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::SUCCESS, 0 ); - verify_rule< star_must< one< 'a' > > >( __LINE__, __FILE__, "ba", result_type::SUCCESS, 2 ); - verify_rule< star_must< one< 'a' > > >( __LINE__, __FILE__, "b", result_type::SUCCESS, 1 ); + verify_rule< star_must< one< 'a' > > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< star_must< one< 'a' > > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< star_must< one< 'a' > > >( __LINE__, __FILE__, "aa", result_type::success, 0 ); + verify_rule< star_must< one< 'a' > > >( __LINE__, __FILE__, "aaa", result_type::success, 0 ); + verify_rule< star_must< one< 'a' > > >( __LINE__, __FILE__, "ba", result_type::success, 2 ); + verify_rule< star_must< one< 'a' > > >( __LINE__, __FILE__, "b", result_type::success, 1 ); - verify_rule< star_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - verify_rule< star_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", result_type::GLOBAL_FAILURE, 1 ); - verify_rule< star_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::SUCCESS, 0 ); - verify_rule< star_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aba", result_type::GLOBAL_FAILURE, 3 ); - verify_rule< star_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abb", result_type::SUCCESS, 1 ); - verify_rule< star_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abab", result_type::SUCCESS, 0 ); - verify_rule< star_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ababc", result_type::SUCCESS, 1 ); - verify_rule< star_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ababab", result_type::SUCCESS, 0 ); - } + verify_rule< star_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< star_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", result_type::global_failure, 1 ); + verify_rule< star_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::success, 0 ); + verify_rule< star_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aba", result_type::global_failure, 3 ); + verify_rule< star_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abb", result_type::success, 1 ); + verify_rule< star_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abab", result_type::success, 0 ); + verify_rule< star_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ababc", result_type::success, 1 ); + verify_rule< star_must< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ababab", result_type::success, 0 ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // 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 2db82feb2..34560037b 100644 --- a/packages/PEGTL/src/test/pegtl/rule_state.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_state.cpp @@ -1,57 +1,32 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_seqs.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + struct test_state_state { - struct test_state_state + template< typename Input > + explicit test_state_state( const Input& /*unused*/ ) { - template< typename Input > - explicit test_state_state( const Input& /*unused*/ ) - { - } - - template< typename Input > - void success( const Input& /*unused*/ ) const - { - } - }; - - struct test_state_with_template_parameters_state - { - template< typename Input > - explicit test_state_with_template_parameters_state( const Input& /*unused*/ ) - { - } - - template< apply_mode, - rewind_mode, - template< typename... > class Action, - template< typename... > class Control, - typename Input > - void success( const Input& /*unused*/ ) const - { - } - }; - - template< typename... Rules > - using test_state_rule = state< test_state_state, Rules... >; - - template< typename... Rules > - using test_state_with_template_parameters_rule = state< test_state_with_template_parameters_state, Rules... >; + } - void unit_test() + template< typename Input > + void success( const Input& /*unused*/ ) const { - verify_seqs< test_state_rule >(); - verify_seqs< test_state_with_template_parameters_rule >(); } + }; - } // namespace TAO_PEGTL_NAMESPACE + template< typename... Rules > + using test_state_rule = state< test_state_state, Rules... >; + + void unit_test() + { + verify_seqs< test_state_rule >(); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_success.cpp b/packages/PEGTL/src/test/pegtl/rule_success.cpp index d927f708e..08e4185fc 100644 --- a/packages/PEGTL/src/test/pegtl/rule_success.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_success.cpp @@ -1,28 +1,24 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_analyze< success >( __LINE__, __FILE__, false, false ); + verify_analyze< success >( __LINE__, __FILE__, false, false ); - verify_rule< success >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); + verify_rule< success >( __LINE__, __FILE__, "", result_type::success, 0 ); - for( char i = 1; i < 127; ++i ) { - char t[] = { i, 0 }; - verify_rule< success >( __LINE__, __FILE__, std::string( t ), result_type::SUCCESS, 1 ); - } + for( char i = 1; i < 127; ++i ) { + char t[] = { i, 0 }; // NOLINT + verify_rule< success >( __LINE__, __FILE__, std::string( t ), result_type::success, 1 ); } + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_try_catch.cpp b/packages/PEGTL/src/test/pegtl/rule_try_catch.cpp index 0f6fbc4ff..646aa86fd 100644 --- a/packages/PEGTL/src/test/pegtl/rule_try_catch.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_try_catch.cpp @@ -1,24 +1,20 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_seqs.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE - { - template< typename... Rules > - using test_try_catch_rule = try_catch< must< Rules... > >; - - void unit_test() - { - verify_seqs< try_catch >(); - verify_seqs< test_try_catch_rule >(); - } + template< typename... Rules > + using test_try_catch_rule = try_catch< must< Rules... > >; - } // namespace TAO_PEGTL_NAMESPACE + void unit_test() + { + verify_seqs< try_catch >(); + verify_seqs< test_try_catch_rule >(); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/rule_until.cpp b/packages/PEGTL/src/test/pegtl/rule_until.cpp index ade660ac4..10f315c77 100644 --- a/packages/PEGTL/src/test/pegtl/rule_until.cpp +++ b/packages/PEGTL/src/test/pegtl/rule_until.cpp @@ -1,120 +1,118 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + struct my_rule { - struct my_rule + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& /*unused*/, bool& v, States... /*unused*/ ) { - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input > - static bool match( Input& /*unused*/, bool& v ) - { - return v; - } - }; - - template< typename Rule > - struct my_action : nothing< Rule > - { - }; + return v; + } + }; - template<> - struct my_action< eof > - { - static void apply0( bool& v ) - { - v = true; - } - }; + template< typename Rule > + struct my_action + {}; - void unit_test() + template<> + struct my_action< eof > + { + static void apply0( bool& v ) { - verify_analyze< until< eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< until< any > >( __LINE__, __FILE__, true, false ); - verify_analyze< until< eof, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< until< any, any > >( __LINE__, __FILE__, true, false ); - - verify_rule< until< eof > >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - verify_rule< until< any > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< until< one< 'a' > > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 0 ); - verify_rule< until< one< 'a' > > >( __LINE__, __FILE__, "ba", result_type::SUCCESS, 0 ); - verify_rule< until< one< 'a' > > >( __LINE__, __FILE__, "bba", result_type::SUCCESS, 0 ); - verify_rule< until< one< 'a' > > >( __LINE__, __FILE__, "bbbbbbbbbbbbbbba", result_type::SUCCESS, 0 ); - verify_rule< until< one< 'a' > > >( __LINE__, __FILE__, "ab", result_type::SUCCESS, 1 ); - verify_rule< until< one< 'a' > > >( __LINE__, __FILE__, "bab", result_type::SUCCESS, 1 ); - verify_rule< until< one< 'a' > > >( __LINE__, __FILE__, "bbab", result_type::SUCCESS, 1 ); - verify_rule< until< one< 'a' > > >( __LINE__, __FILE__, "bbbbbbbbbbbbbbbab", result_type::SUCCESS, 1 ); - - verify_rule< must< until< one< 'a' > > > >( __LINE__, __FILE__, "bbb", result_type::GLOBAL_FAILURE, 0 ); - - verify_rule< try_catch< must< until< one< 'a' > > > > >( __LINE__, __FILE__, "bbb", result_type::LOCAL_FAILURE, 3 ); - - verify_rule< until< eof, any > >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - verify_rule< until< any, any > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< until< one< 'a' >, any > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 0 ); - verify_rule< until< one< 'a' >, any > >( __LINE__, __FILE__, "ba", result_type::SUCCESS, 0 ); - verify_rule< until< one< 'a' >, any > >( __LINE__, __FILE__, "bba", result_type::SUCCESS, 0 ); - verify_rule< until< one< 'a' >, any > >( __LINE__, __FILE__, "bbbbbbbbbbbbbbba", result_type::SUCCESS, 0 ); - verify_rule< until< one< 'a' >, any > >( __LINE__, __FILE__, "ab", result_type::SUCCESS, 1 ); - verify_rule< until< one< 'a' >, any > >( __LINE__, __FILE__, "bab", result_type::SUCCESS, 1 ); - verify_rule< until< one< 'a' >, any > >( __LINE__, __FILE__, "bbab", result_type::SUCCESS, 1 ); - verify_rule< until< one< 'a' >, any > >( __LINE__, __FILE__, "bbbbbbbbbbbbbbbab", result_type::SUCCESS, 1 ); - - verify_rule< until< eof, one< 'a' > > >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - verify_rule< until< eof, one< 'a' > > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 0 ); - verify_rule< until< eof, one< 'a' > > >( __LINE__, __FILE__, "aa", result_type::SUCCESS, 0 ); - verify_rule< until< eof, one< 'a' > > >( __LINE__, __FILE__, "aaaaab", result_type::LOCAL_FAILURE, 6 ); - verify_rule< until< eof, one< 'a' > > >( __LINE__, __FILE__, "baaaaa", result_type::LOCAL_FAILURE, 6 ); - - verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 0 ); - verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aa", result_type::SUCCESS, 1 ); - verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::SUCCESS, 1 ); - verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "b", result_type::LOCAL_FAILURE, 1 ); - verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "bb", result_type::LOCAL_FAILURE, 2 ); - verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ba", result_type::SUCCESS, 0 ); - verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "bba", result_type::SUCCESS, 0 ); - verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "bbbbbbbbbbbbbba", result_type::SUCCESS, 0 ); - verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "baa", result_type::SUCCESS, 1 ); - verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "bbaa", result_type::SUCCESS, 1 ); - verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "bbbbbbbbbbbbbbaa", result_type::SUCCESS, 1 ); - verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "bab", result_type::SUCCESS, 1 ); - verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "bbab", result_type::SUCCESS, 1 ); - verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "bbbbbbbbbbbbbbab", result_type::SUCCESS, 1 ); - - verify_rule< until< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< until< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "a", result_type::SUCCESS, 0 ); - verify_rule< until< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "bca", result_type::SUCCESS, 0 ); - verify_rule< until< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "bcbca", result_type::SUCCESS, 0 ); - verify_rule< until< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "bcbcbcbcbca", result_type::SUCCESS, 0 ); - verify_rule< until< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "babca", result_type::LOCAL_FAILURE, 5 ); - verify_rule< until< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "bcbcb", result_type::LOCAL_FAILURE, 5 ); - verify_rule< until< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "cbcbc", result_type::LOCAL_FAILURE, 5 ); - verify_rule< until< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "bcbcbc", result_type::LOCAL_FAILURE, 6 ); - - verify_rule< must< until< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "bbb", result_type::GLOBAL_FAILURE, 0 ); - verify_rule< must< until< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "bbbc", result_type::GLOBAL_FAILURE, 1 ); - - verify_rule< try_catch< must< until< one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "bbb", result_type::LOCAL_FAILURE, 3 ); - verify_rule< try_catch< must< until< one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "bbbc", result_type::LOCAL_FAILURE, 4 ); - - bool success = false; - const bool result = parse< until< my_rule, eof >, my_action >( memory_input<>( "", __FUNCTION__ ), success ); - TAO_PEGTL_TEST_ASSERT( result ); - TAO_PEGTL_TEST_ASSERT( success ); + v = true; } + }; - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + void unit_test() + { + verify_analyze< until< eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< until< any > >( __LINE__, __FILE__, true, false ); + verify_analyze< until< eof, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< until< any, any > >( __LINE__, __FILE__, true, false ); + + verify_rule< until< eof > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< until< any > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< until< one< 'a' > > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< until< one< 'a' > > >( __LINE__, __FILE__, "ba", result_type::success, 0 ); + verify_rule< until< one< 'a' > > >( __LINE__, __FILE__, "bba", result_type::success, 0 ); + verify_rule< until< one< 'a' > > >( __LINE__, __FILE__, "bbbbbbbbbbbbbbba", result_type::success, 0 ); + verify_rule< until< one< 'a' > > >( __LINE__, __FILE__, "ab", result_type::success, 1 ); + verify_rule< until< one< 'a' > > >( __LINE__, __FILE__, "bab", result_type::success, 1 ); + verify_rule< until< one< 'a' > > >( __LINE__, __FILE__, "bbab", result_type::success, 1 ); + verify_rule< until< one< 'a' > > >( __LINE__, __FILE__, "bbbbbbbbbbbbbbbab", result_type::success, 1 ); + + verify_rule< must< until< one< 'a' > > > >( __LINE__, __FILE__, "bbb", result_type::global_failure, 0 ); + + verify_rule< try_catch< must< until< one< 'a' > > > > >( __LINE__, __FILE__, "bbb", result_type::local_failure, 3 ); + + verify_rule< until< eof, any > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< until< any, any > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< until< one< 'a' >, any > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< until< one< 'a' >, any > >( __LINE__, __FILE__, "ba", result_type::success, 0 ); + verify_rule< until< one< 'a' >, any > >( __LINE__, __FILE__, "bba", result_type::success, 0 ); + verify_rule< until< one< 'a' >, any > >( __LINE__, __FILE__, "bbbbbbbbbbbbbbba", result_type::success, 0 ); + verify_rule< until< one< 'a' >, any > >( __LINE__, __FILE__, "ab", result_type::success, 1 ); + verify_rule< until< one< 'a' >, any > >( __LINE__, __FILE__, "bab", result_type::success, 1 ); + verify_rule< until< one< 'a' >, any > >( __LINE__, __FILE__, "bbab", result_type::success, 1 ); + verify_rule< until< one< 'a' >, any > >( __LINE__, __FILE__, "bbbbbbbbbbbbbbbab", result_type::success, 1 ); + + verify_rule< until< eof, one< 'a' > > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< until< eof, one< 'a' > > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< until< eof, one< 'a' > > >( __LINE__, __FILE__, "aa", result_type::success, 0 ); + verify_rule< until< eof, one< 'a' > > >( __LINE__, __FILE__, "aaaaab", result_type::local_failure, 6 ); + verify_rule< until< eof, one< 'a' > > >( __LINE__, __FILE__, "baaaaa", result_type::local_failure, 6 ); + + verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aa", result_type::success, 1 ); + verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::success, 1 ); + verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "b", result_type::local_failure, 1 ); + verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "bb", result_type::local_failure, 2 ); + verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ba", result_type::success, 0 ); + verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "bba", result_type::success, 0 ); + verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "bbbbbbbbbbbbbba", result_type::success, 0 ); + verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "baa", result_type::success, 1 ); + verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "bbaa", result_type::success, 1 ); + verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "bbbbbbbbbbbbbbaa", result_type::success, 1 ); + verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "bab", result_type::success, 1 ); + verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "bbab", result_type::success, 1 ); + verify_rule< until< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "bbbbbbbbbbbbbbab", result_type::success, 1 ); + + verify_rule< until< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< until< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "a", result_type::success, 0 ); + verify_rule< until< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "bca", result_type::success, 0 ); + verify_rule< until< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "bcbca", result_type::success, 0 ); + verify_rule< until< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "bcbcbcbcbca", result_type::success, 0 ); + verify_rule< until< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "babca", result_type::local_failure, 5 ); + verify_rule< until< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "bcbcb", result_type::local_failure, 5 ); + verify_rule< until< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "cbcbc", result_type::local_failure, 5 ); + verify_rule< until< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "bcbcbc", result_type::local_failure, 6 ); + + verify_rule< must< until< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "bbb", result_type::global_failure, 0 ); + verify_rule< must< until< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "bbbc", result_type::global_failure, 1 ); + + verify_rule< try_catch< must< until< one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "bbb", result_type::local_failure, 3 ); + verify_rule< try_catch< must< until< one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "bbbc", result_type::local_failure, 4 ); + + bool success = false; + const bool result = parse< until< my_rule, eof >, my_action >( memory_input<>( "", __FUNCTION__ ), success ); + TAO_PEGTL_TEST_ASSERT( result ); + TAO_PEGTL_TEST_ASSERT( success ); + } + +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/test.hpp b/packages/PEGTL/src/test/pegtl/test.hpp index 6094d02af..e00d7b47c 100644 --- a/packages/PEGTL/src/test/pegtl/test.hpp +++ b/packages/PEGTL/src/test/pegtl/test.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_SRC_TEST_PEGTL_TEST_HPP // NOLINT @@ -6,22 +6,19 @@ #include <cstddef> #include <iostream> -#include <string> -#include <utility> -#include <vector> #include <tao/pegtl.hpp> -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE - { - std::size_t failed = 0; // NOLINT - std::vector< std::pair< std::string, std::string > > applied; // NOLINT + std::size_t failed = 0; // NOLINT + +} // namespace TAO_PEGTL_NAMESPACE - } // namespace TAO_PEGTL_NAMESPACE +#define TAO_TEST_STRINGIZE_INTERNAL( ... ) #__VA_ARGS__ +#define TAO_TEST_STRINGIZE( ... ) TAO_TEST_STRINGIZE_INTERNAL( __VA_ARGS__ ) -} // namespace tao +#define TAO_TEST_LINE TAO_TEST_STRINGIZE( __LINE__ ) #define TAO_PEGTL_TEST_UNWRAP( ... ) __VA_ARGS__ @@ -39,11 +36,11 @@ namespace tao ++failed; \ } while( false ) -#define TAO_PEGTL_TEST_ASSERT( eXPReSSioN ) \ +#define TAO_PEGTL_TEST_ASSERT( ... ) \ do { \ - if( !( eXPReSSioN ) ) { \ + if( !( __VA_ARGS__ ) ) { \ std::cerr << "pegtl: unit test assert [ " \ - << ( #eXPReSSioN ) \ + << ( #__VA_ARGS__ ) \ << " ] failed in line [ " \ << __LINE__ \ << " ] file [ " \ @@ -70,44 +67,32 @@ namespace tao } \ } while( false ) -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + template< unsigned Size, apply_mode B, rewind_mode N, typename... Rules > + struct test_rule { - template< unsigned Size, apply_mode B, rewind_mode N, typename... Rules > - struct test_rule + using analyze_t = typename seq< Rules... >::analyze_t; + + template< apply_mode A, + rewind_mode M, + template< typename... > + class Action, + template< typename... > + class Control, + typename Input, + typename... States > + static bool match( Input& in, States&&... st ) { - using analyze_t = typename seq< Rules... >::analyze_t; - - template< apply_mode A, - rewind_mode M, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - static bool match( Input& in, States&&... st ) - { - static_assert( A == B, "unexpected apply mode" ); - static_assert( M == N, "unexpected rewind mode" ); - - TAO_PEGTL_TEST_ASSERT( in.size() == Size ); - - return seq< Rules... >::template match< A, M, Action, Control >( in, st... ); - } - }; - - template< typename Rule > - struct test_action - { - template< typename Input > - static void apply( const Input& in ) - { - applied.push_back( std::make_pair( internal::demangle< Rule >(), in.string() ) ); - } - }; + static_assert( A == B, "unexpected apply mode" ); + static_assert( M == N, "unexpected rewind mode" ); + + TAO_PEGTL_TEST_ASSERT( in.size() == Size ); - } // namespace TAO_PEGTL_NAMESPACE + return seq< Rules... >::template match< A, M, Action, Control >( in, st... ); + } + }; -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/src/test/pegtl/tester.cpp b/packages/PEGTL/src/test/pegtl/tester.cpp index 9d8ffbf7c..42fdeceb4 100644 --- a/packages/PEGTL/src/test/pegtl/tester.cpp +++ b/packages/PEGTL/src/test/pegtl/tester.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include <iostream> diff --git a/packages/PEGTL/src/test/pegtl/uint16_general.cpp b/packages/PEGTL/src/test/pegtl/uint16_general.cpp index 4e1fbd88b..18e6748ee 100644 --- a/packages/PEGTL/src/test/pegtl/uint16_general.cpp +++ b/packages/PEGTL/src/test/pegtl/uint16_general.cpp @@ -1,178 +1,174 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_char.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_rule< uint16_be::any >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< uint16_le::any >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); + verify_rule< uint16_be::any >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< uint16_le::any >( __LINE__, __FILE__, "", result_type::local_failure ); - verify_rule< uint16_be::any >( __LINE__, __FILE__, "\x01", result_type::LOCAL_FAILURE ); - verify_rule< uint16_le::any >( __LINE__, __FILE__, "\x01", result_type::LOCAL_FAILURE ); + verify_rule< uint16_be::any >( __LINE__, __FILE__, "\x01", result_type::local_failure ); + verify_rule< uint16_le::any >( __LINE__, __FILE__, "\x01", result_type::local_failure ); - verify_rule< uint16_be::any >( __LINE__, __FILE__, "\x01\x02", result_type::SUCCESS ); - verify_rule< uint16_be::any >( __LINE__, __FILE__, "\x71\x72", result_type::SUCCESS ); - verify_rule< uint16_le::any >( __LINE__, __FILE__, "\x01\x02", result_type::SUCCESS ); - verify_rule< uint16_le::any >( __LINE__, __FILE__, "\x71\x72", result_type::SUCCESS ); + verify_rule< uint16_be::any >( __LINE__, __FILE__, "\x01\x02", result_type::success ); + verify_rule< uint16_be::any >( __LINE__, __FILE__, "\x71\x72", result_type::success ); + verify_rule< uint16_le::any >( __LINE__, __FILE__, "\x01\x02", result_type::success ); + verify_rule< uint16_le::any >( __LINE__, __FILE__, "\x71\x72", result_type::success ); - verify_rule< uint16_be::any >( __LINE__, __FILE__, "\x01\x02\x03", result_type::SUCCESS, 1 ); - verify_rule< uint16_be::any >( __LINE__, __FILE__, "\x71\x72\x03", result_type::SUCCESS, 1 ); - verify_rule< uint16_le::any >( __LINE__, __FILE__, "\x01\x02\x03", result_type::SUCCESS, 1 ); - verify_rule< uint16_le::any >( __LINE__, __FILE__, "\x71\x72\x03", result_type::SUCCESS, 1 ); + verify_rule< uint16_be::any >( __LINE__, __FILE__, "\x01\x02\x03", result_type::success, 1 ); + verify_rule< uint16_be::any >( __LINE__, __FILE__, "\x71\x72\x03", result_type::success, 1 ); + verify_rule< uint16_le::any >( __LINE__, __FILE__, "\x01\x02\x03", result_type::success, 1 ); + verify_rule< uint16_le::any >( __LINE__, __FILE__, "\x71\x72\x03", result_type::success, 1 ); - verify_rule< uint16_be::any >( __LINE__, __FILE__, "\x01\x02\x03\x55", result_type::SUCCESS, 2 ); - verify_rule< uint16_be::any >( __LINE__, __FILE__, "\x71\x72\x03\x55", result_type::SUCCESS, 2 ); - verify_rule< uint16_le::any >( __LINE__, __FILE__, "\x01\x02\x03\x55", result_type::SUCCESS, 2 ); - verify_rule< uint16_le::any >( __LINE__, __FILE__, "\x71\x72\x03\x55", result_type::SUCCESS, 2 ); + verify_rule< uint16_be::any >( __LINE__, __FILE__, "\x01\x02\x03\x55", result_type::success, 2 ); + verify_rule< uint16_be::any >( __LINE__, __FILE__, "\x71\x72\x03\x55", result_type::success, 2 ); + verify_rule< uint16_le::any >( __LINE__, __FILE__, "\x01\x02\x03\x55", result_type::success, 2 ); + verify_rule< uint16_le::any >( __LINE__, __FILE__, "\x71\x72\x03\x55", result_type::success, 2 ); - verify_rule< uint16_be::mask_not_one< 0xffff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x01", result_type::LOCAL_FAILURE ); + verify_rule< uint16_be::mask_not_one< 0xffff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x01", result_type::local_failure ); - verify_rule< uint16_be::mask_not_one< 0xffff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x01\x11", result_type::LOCAL_FAILURE ); - verify_rule< uint16_be::mask_not_one< 0xffff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\x01", result_type::SUCCESS ); + verify_rule< uint16_be::mask_not_one< 0xffff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x01\x11", result_type::local_failure ); + verify_rule< uint16_be::mask_not_one< 0xffff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\x01", result_type::success ); - verify_rule< uint16_le::mask_not_one< 0xffff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x01\x11", result_type::SUCCESS ); - verify_rule< uint16_le::mask_not_one< 0xffff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\x01", result_type::LOCAL_FAILURE ); + verify_rule< uint16_le::mask_not_one< 0xffff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x01\x11", result_type::success ); + verify_rule< uint16_le::mask_not_one< 0xffff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\x01", result_type::local_failure ); - verify_rule< uint16_be::mask_not_one< 0x0fff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\xf3\x11", result_type::SUCCESS ); - verify_rule< uint16_be::mask_not_one< 0x0fff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\xf1\x11", result_type::LOCAL_FAILURE ); + verify_rule< uint16_be::mask_not_one< 0x0fff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\xf3\x11", result_type::success ); + verify_rule< uint16_be::mask_not_one< 0x0fff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\xf1\x11", result_type::local_failure ); - verify_rule< uint16_le::mask_not_one< 0x0fff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\xf3", result_type::SUCCESS ); - verify_rule< uint16_le::mask_not_one< 0x0fff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\xf1", result_type::LOCAL_FAILURE ); + verify_rule< uint16_le::mask_not_one< 0x0fff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\xf3", result_type::success ); + verify_rule< uint16_le::mask_not_one< 0x0fff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\xf1", result_type::local_failure ); - verify_rule< uint16_be::mask_not_range< 0xffff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x02\x77", result_type::LOCAL_FAILURE ); - verify_rule< uint16_be::mask_not_range< 0xffff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x02", result_type::SUCCESS ); + verify_rule< uint16_be::mask_not_range< 0xffff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x02\x77", result_type::local_failure ); + verify_rule< uint16_be::mask_not_range< 0xffff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x02", result_type::success ); - verify_rule< uint16_le::mask_not_range< 0xffff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x02\x77", result_type::SUCCESS ); - verify_rule< uint16_le::mask_not_range< 0xffff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x02", result_type::LOCAL_FAILURE ); + verify_rule< uint16_le::mask_not_range< 0xffff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x02\x77", result_type::success ); + verify_rule< uint16_le::mask_not_range< 0xffff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x02", result_type::local_failure ); - verify_rule< uint16_be::mask_not_range< 0x0fff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x52\x77", result_type::LOCAL_FAILURE ); - verify_rule< uint16_be::mask_not_range< 0x0fff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x56\x77", result_type::SUCCESS ); + verify_rule< uint16_be::mask_not_range< 0x0fff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x52\x77", result_type::local_failure ); + verify_rule< uint16_be::mask_not_range< 0x0fff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x56\x77", result_type::success ); - verify_rule< uint16_le::mask_not_range< 0x0fff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x52", result_type::LOCAL_FAILURE ); - verify_rule< uint16_le::mask_not_range< 0x0fff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x56", result_type::SUCCESS ); + verify_rule< uint16_le::mask_not_range< 0x0fff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x52", result_type::local_failure ); + verify_rule< uint16_le::mask_not_range< 0x0fff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x56", result_type::success ); - verify_rule< uint16_be::mask_one< 0xffff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x01\x11", result_type::SUCCESS ); - verify_rule< uint16_be::mask_one< 0xffff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\x01", result_type::LOCAL_FAILURE ); + verify_rule< uint16_be::mask_one< 0xffff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x01\x11", result_type::success ); + verify_rule< uint16_be::mask_one< 0xffff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\x01", result_type::local_failure ); - verify_rule< uint16_le::mask_one< 0xffff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x01\x11", result_type::LOCAL_FAILURE ); - verify_rule< uint16_le::mask_one< 0xffff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\x01", result_type::SUCCESS ); + verify_rule< uint16_le::mask_one< 0xffff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x01\x11", result_type::local_failure ); + verify_rule< uint16_le::mask_one< 0xffff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\x01", result_type::success ); - verify_rule< uint16_be::mask_one< 0x0fff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\xf3\x11", result_type::LOCAL_FAILURE ); - verify_rule< uint16_be::mask_one< 0x0fff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\xf1\x11", result_type::SUCCESS ); + verify_rule< uint16_be::mask_one< 0x0fff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\xf3\x11", result_type::local_failure ); + verify_rule< uint16_be::mask_one< 0x0fff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\xf1\x11", result_type::success ); - verify_rule< uint16_le::mask_one< 0x0fff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\xf3", result_type::LOCAL_FAILURE ); - verify_rule< uint16_le::mask_one< 0x0fff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\xf1", result_type::SUCCESS ); + verify_rule< uint16_le::mask_one< 0x0fff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\xf3", result_type::local_failure ); + verify_rule< uint16_le::mask_one< 0x0fff, 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\xf1", result_type::success ); - verify_rule< uint16_be::mask_range< 0xffff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x02\x77", result_type::SUCCESS ); - verify_rule< uint16_be::mask_range< 0xffff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x02", result_type::LOCAL_FAILURE ); + verify_rule< uint16_be::mask_range< 0xffff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x02\x77", result_type::success ); + verify_rule< uint16_be::mask_range< 0xffff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x02", result_type::local_failure ); - verify_rule< uint16_le::mask_range< 0xffff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x02\x77", result_type::LOCAL_FAILURE ); - verify_rule< uint16_le::mask_range< 0xffff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x02", result_type::SUCCESS ); + verify_rule< uint16_le::mask_range< 0xffff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x02\x77", result_type::local_failure ); + verify_rule< uint16_le::mask_range< 0xffff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x02", result_type::success ); - verify_rule< uint16_be::mask_range< 0x0fff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x52\x77", result_type::SUCCESS ); - verify_rule< uint16_be::mask_range< 0x0fff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x56\x77", result_type::LOCAL_FAILURE ); + verify_rule< uint16_be::mask_range< 0x0fff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x52\x77", result_type::success ); + verify_rule< uint16_be::mask_range< 0x0fff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x56\x77", result_type::local_failure ); - verify_rule< uint16_le::mask_range< 0x0fff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x52", result_type::SUCCESS ); - verify_rule< uint16_le::mask_range< 0x0fff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x56", result_type::LOCAL_FAILURE ); + verify_rule< uint16_le::mask_range< 0x0fff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x52", result_type::success ); + verify_rule< uint16_le::mask_range< 0x0fff, 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x56", result_type::local_failure ); - verify_rule< uint16_be::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x01\x23", result_type::SUCCESS ); - verify_rule< uint16_be::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x02\x34", result_type::LOCAL_FAILURE ); - verify_rule< uint16_be::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x03\x45", result_type::SUCCESS ); - verify_rule< uint16_be::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x67\x89", result_type::LOCAL_FAILURE ); + verify_rule< uint16_be::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x01\x23", result_type::success ); + verify_rule< uint16_be::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x02\x34", result_type::local_failure ); + verify_rule< uint16_be::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x03\x45", result_type::success ); + verify_rule< uint16_be::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x67\x89", result_type::local_failure ); - verify_rule< uint16_le::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x23\x01", result_type::SUCCESS ); - verify_rule< uint16_le::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x34\x02", result_type::LOCAL_FAILURE ); - verify_rule< uint16_le::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x45\x03", result_type::SUCCESS ); - verify_rule< uint16_le::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x89\x67", result_type::LOCAL_FAILURE ); + verify_rule< uint16_le::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x23\x01", result_type::success ); + verify_rule< uint16_le::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x34\x02", result_type::local_failure ); + verify_rule< uint16_le::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x45\x03", result_type::success ); + verify_rule< uint16_le::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x89\x67", result_type::local_failure ); - verify_rule< uint16_be::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x01\x23", result_type::SUCCESS ); - verify_rule< uint16_be::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x02\x34", result_type::LOCAL_FAILURE ); - verify_rule< uint16_be::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x03\x45", result_type::SUCCESS ); - verify_rule< uint16_be::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x67\x89", result_type::SUCCESS ); + verify_rule< uint16_be::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x01\x23", result_type::success ); + verify_rule< uint16_be::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x02\x34", result_type::local_failure ); + verify_rule< uint16_be::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x03\x45", result_type::success ); + verify_rule< uint16_be::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x67\x89", result_type::success ); - verify_rule< uint16_le::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x23\x01", result_type::SUCCESS ); - verify_rule< uint16_le::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x34\x02", result_type::LOCAL_FAILURE ); - verify_rule< uint16_le::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x45\x03", result_type::SUCCESS ); - verify_rule< uint16_le::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x89\x67", result_type::SUCCESS ); + verify_rule< uint16_le::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x23\x01", result_type::success ); + verify_rule< uint16_le::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x34\x02", result_type::local_failure ); + verify_rule< uint16_le::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x45\x03", result_type::success ); + verify_rule< uint16_le::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x89\x67", result_type::success ); - verify_rule< uint16_be::mask_ranges< 0xff0f, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x02\x50", result_type::SUCCESS ); - verify_rule< uint16_be::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x02\x50", result_type::LOCAL_FAILURE ); + verify_rule< uint16_be::mask_ranges< 0xff0f, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x02\x50", result_type::success ); + verify_rule< uint16_be::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x02\x50", result_type::local_failure ); - verify_rule< uint16_le::mask_ranges< 0xff0f, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x50\x02", result_type::SUCCESS ); - verify_rule< uint16_le::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x50\x02", result_type::LOCAL_FAILURE ); + verify_rule< uint16_le::mask_ranges< 0xff0f, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x50\x02", result_type::success ); + verify_rule< uint16_le::mask_ranges< 0xffff, 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x50\x02", result_type::local_failure ); - verify_rule< uint16_be::mask_string< 0xffff, 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x01\x23\x45\x67", result_type::SUCCESS ); - verify_rule< uint16_be::mask_string< 0xffff, 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x23\x01\x67\x45", result_type::LOCAL_FAILURE ); + verify_rule< uint16_be::mask_string< 0xffff, 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x01\x23\x45\x67", result_type::success ); + verify_rule< uint16_be::mask_string< 0xffff, 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x23\x01\x67\x45", result_type::local_failure ); - verify_rule< uint16_le::mask_string< 0xffff, 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x01\x23\x45\x67", result_type::LOCAL_FAILURE ); - verify_rule< uint16_le::mask_string< 0xffff, 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x23\x01\x67\x45", result_type::SUCCESS ); + verify_rule< uint16_le::mask_string< 0xffff, 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x01\x23\x45\x67", result_type::local_failure ); + verify_rule< uint16_le::mask_string< 0xffff, 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x23\x01\x67\x45", result_type::success ); - verify_rule< uint16_be::mask_string< 0xffff, 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x81\x23\x45\x67", result_type::LOCAL_FAILURE ); - verify_rule< uint16_be::mask_string< 0x4fff, 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x81\x23\x45\x67", result_type::SUCCESS ); + verify_rule< uint16_be::mask_string< 0xffff, 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x81\x23\x45\x67", result_type::local_failure ); + verify_rule< uint16_be::mask_string< 0x4fff, 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x81\x23\x45\x67", result_type::success ); - verify_rule< uint16_le::mask_string< 0xffff, 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x23\x81\x67\x45", result_type::LOCAL_FAILURE ); - verify_rule< uint16_le::mask_string< 0x4fff, 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x23\x81\x67\x45", result_type::SUCCESS ); + verify_rule< uint16_le::mask_string< 0xffff, 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x23\x81\x67\x45", result_type::local_failure ); + verify_rule< uint16_le::mask_string< 0x4fff, 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x23\x81\x67\x45", result_type::success ); - verify_rule< uint16_be::not_one< 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x01\x11", result_type::LOCAL_FAILURE ); - verify_rule< uint16_be::not_one< 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\x01", result_type::SUCCESS ); + verify_rule< uint16_be::not_one< 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x01\x11", result_type::local_failure ); + verify_rule< uint16_be::not_one< 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\x01", result_type::success ); - verify_rule< uint16_le::not_one< 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x01\x11", result_type::SUCCESS ); - verify_rule< uint16_le::not_one< 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\x01", result_type::LOCAL_FAILURE ); + verify_rule< uint16_le::not_one< 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x01\x11", result_type::success ); + verify_rule< uint16_le::not_one< 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\x01", result_type::local_failure ); - verify_rule< uint16_be::not_range< 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x02\x77", result_type::LOCAL_FAILURE ); - verify_rule< uint16_be::not_range< 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x02", result_type::SUCCESS ); + verify_rule< uint16_be::not_range< 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x02\x77", result_type::local_failure ); + verify_rule< uint16_be::not_range< 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x02", result_type::success ); - verify_rule< uint16_le::not_range< 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x02\x77", result_type::SUCCESS ); - verify_rule< uint16_le::not_range< 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x02", result_type::LOCAL_FAILURE ); + verify_rule< uint16_le::not_range< 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x02\x77", result_type::success ); + verify_rule< uint16_le::not_range< 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x02", result_type::local_failure ); - verify_rule< uint16_be::one< 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x01\x11", result_type::SUCCESS ); - verify_rule< uint16_be::one< 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\x01", result_type::LOCAL_FAILURE ); + verify_rule< uint16_be::one< 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x01\x11", result_type::success ); + verify_rule< uint16_be::one< 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\x01", result_type::local_failure ); - verify_rule< uint16_le::one< 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x01\x11", result_type::LOCAL_FAILURE ); - verify_rule< uint16_le::one< 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\x01", result_type::SUCCESS ); + verify_rule< uint16_le::one< 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x01\x11", result_type::local_failure ); + verify_rule< uint16_le::one< 0x0111, 0x0222 > >( __LINE__, __FILE__, "\x11\x01", result_type::success ); - verify_rule< uint16_be::range< 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x02\x77", result_type::SUCCESS ); - verify_rule< uint16_be::range< 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x02", result_type::LOCAL_FAILURE ); + verify_rule< uint16_be::range< 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x02\x77", result_type::success ); + verify_rule< uint16_be::range< 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x02", result_type::local_failure ); - verify_rule< uint16_le::range< 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x02\x77", result_type::LOCAL_FAILURE ); - verify_rule< uint16_le::range< 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x02", result_type::SUCCESS ); + verify_rule< uint16_le::range< 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x02\x77", result_type::local_failure ); + verify_rule< uint16_le::range< 0x0100, 0x0400 > >( __LINE__, __FILE__, "\x77\x02", result_type::success ); - verify_rule< uint16_be::ranges< 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x01\x23", result_type::SUCCESS ); - verify_rule< uint16_be::ranges< 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x02\x34", result_type::LOCAL_FAILURE ); - verify_rule< uint16_be::ranges< 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x03\x45", result_type::SUCCESS ); - verify_rule< uint16_be::ranges< 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x67\x89", result_type::LOCAL_FAILURE ); + verify_rule< uint16_be::ranges< 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x01\x23", result_type::success ); + verify_rule< uint16_be::ranges< 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x02\x34", result_type::local_failure ); + verify_rule< uint16_be::ranges< 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x03\x45", result_type::success ); + verify_rule< uint16_be::ranges< 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x67\x89", result_type::local_failure ); - verify_rule< uint16_le::ranges< 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x23\x01", result_type::SUCCESS ); - verify_rule< uint16_le::ranges< 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x34\x02", result_type::LOCAL_FAILURE ); - verify_rule< uint16_le::ranges< 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x45\x03", result_type::SUCCESS ); - verify_rule< uint16_le::ranges< 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x89\x67", result_type::LOCAL_FAILURE ); + verify_rule< uint16_le::ranges< 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x23\x01", result_type::success ); + verify_rule< uint16_le::ranges< 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x34\x02", result_type::local_failure ); + verify_rule< uint16_le::ranges< 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x45\x03", result_type::success ); + verify_rule< uint16_le::ranges< 0x0111, 0x0222, 0x0333, 0x0444 > >( __LINE__, __FILE__, "\x89\x67", result_type::local_failure ); - verify_rule< uint16_be::ranges< 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x01\x23", result_type::SUCCESS ); - verify_rule< uint16_be::ranges< 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x02\x34", result_type::LOCAL_FAILURE ); - verify_rule< uint16_be::ranges< 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x03\x45", result_type::SUCCESS ); - verify_rule< uint16_be::ranges< 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x67\x89", result_type::SUCCESS ); + verify_rule< uint16_be::ranges< 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x01\x23", result_type::success ); + verify_rule< uint16_be::ranges< 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x02\x34", result_type::local_failure ); + verify_rule< uint16_be::ranges< 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x03\x45", result_type::success ); + verify_rule< uint16_be::ranges< 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x67\x89", result_type::success ); - verify_rule< uint16_le::ranges< 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x23\x01", result_type::SUCCESS ); - verify_rule< uint16_le::ranges< 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x34\x02", result_type::LOCAL_FAILURE ); - verify_rule< uint16_le::ranges< 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x45\x03", result_type::SUCCESS ); - verify_rule< uint16_le::ranges< 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x89\x67", result_type::SUCCESS ); + verify_rule< uint16_le::ranges< 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x23\x01", result_type::success ); + verify_rule< uint16_le::ranges< 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x34\x02", result_type::local_failure ); + verify_rule< uint16_le::ranges< 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x45\x03", result_type::success ); + verify_rule< uint16_le::ranges< 0x0111, 0x0222, 0x0333, 0x0444, 0x6789 > >( __LINE__, __FILE__, "\x89\x67", result_type::success ); - verify_rule< uint16_be::string< 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x01\x23\x45\x67", result_type::SUCCESS ); - verify_rule< uint16_be::string< 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x23\x01\x67\x45", result_type::LOCAL_FAILURE ); + verify_rule< uint16_be::string< 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x01\x23\x45\x67", result_type::success ); + verify_rule< uint16_be::string< 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x23\x01\x67\x45", result_type::local_failure ); - verify_rule< uint16_le::string< 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x01\x23\x45\x67", result_type::LOCAL_FAILURE ); - verify_rule< uint16_le::string< 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x23\x01\x67\x45", result_type::SUCCESS ); - } + verify_rule< uint16_le::string< 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x01\x23\x45\x67", result_type::local_failure ); + verify_rule< uint16_le::string< 0x0123, 0x4567 > >( __LINE__, __FILE__, "\x23\x01\x67\x45", result_type::success ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/uint32_general.cpp b/packages/PEGTL/src/test/pegtl/uint32_general.cpp index 3c4c6f3ce..4ed62de18 100644 --- a/packages/PEGTL/src/test/pegtl/uint32_general.cpp +++ b/packages/PEGTL/src/test/pegtl/uint32_general.cpp @@ -1,183 +1,179 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_char.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_rule< uint32_be::any >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< uint32_le::any >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); + verify_rule< uint32_be::any >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< uint32_le::any >( __LINE__, __FILE__, "", result_type::local_failure ); - verify_rule< uint32_be::any >( __LINE__, __FILE__, "\x01", result_type::LOCAL_FAILURE ); - verify_rule< uint32_le::any >( __LINE__, __FILE__, "\x01", result_type::LOCAL_FAILURE ); + verify_rule< uint32_be::any >( __LINE__, __FILE__, "\x01", result_type::local_failure ); + verify_rule< uint32_le::any >( __LINE__, __FILE__, "\x01", result_type::local_failure ); - verify_rule< uint32_be::any >( __LINE__, __FILE__, "\x01\x02", result_type::LOCAL_FAILURE ); - verify_rule< uint32_be::any >( __LINE__, __FILE__, "\x71\x72", result_type::LOCAL_FAILURE ); - verify_rule< uint32_le::any >( __LINE__, __FILE__, "\x01\x02", result_type::LOCAL_FAILURE ); - verify_rule< uint32_le::any >( __LINE__, __FILE__, "\x71\x72", result_type::LOCAL_FAILURE ); + verify_rule< uint32_be::any >( __LINE__, __FILE__, "\x01\x02", result_type::local_failure ); + verify_rule< uint32_be::any >( __LINE__, __FILE__, "\x71\x72", result_type::local_failure ); + verify_rule< uint32_le::any >( __LINE__, __FILE__, "\x01\x02", result_type::local_failure ); + verify_rule< uint32_le::any >( __LINE__, __FILE__, "\x71\x72", result_type::local_failure ); - verify_rule< uint32_be::any >( __LINE__, __FILE__, "\x01\x02\x03", result_type::LOCAL_FAILURE ); - verify_rule< uint32_be::any >( __LINE__, __FILE__, "\x71\x72\x03", result_type::LOCAL_FAILURE ); - verify_rule< uint32_le::any >( __LINE__, __FILE__, "\x01\x02\x03", result_type::LOCAL_FAILURE ); - verify_rule< uint32_le::any >( __LINE__, __FILE__, "\x71\x72\x03", result_type::LOCAL_FAILURE ); + verify_rule< uint32_be::any >( __LINE__, __FILE__, "\x01\x02\x03", result_type::local_failure ); + verify_rule< uint32_be::any >( __LINE__, __FILE__, "\x71\x72\x03", result_type::local_failure ); + verify_rule< uint32_le::any >( __LINE__, __FILE__, "\x01\x02\x03", result_type::local_failure ); + verify_rule< uint32_le::any >( __LINE__, __FILE__, "\x71\x72\x03", result_type::local_failure ); - verify_rule< uint32_be::any >( __LINE__, __FILE__, "\x01\x02\x03\x55", result_type::SUCCESS ); - verify_rule< uint32_be::any >( __LINE__, __FILE__, "\x71\x72\x03\x55", result_type::SUCCESS ); - verify_rule< uint32_le::any >( __LINE__, __FILE__, "\x01\x02\x03\x55", result_type::SUCCESS ); - verify_rule< uint32_le::any >( __LINE__, __FILE__, "\x71\x72\x03\x55", result_type::SUCCESS ); + verify_rule< uint32_be::any >( __LINE__, __FILE__, "\x01\x02\x03\x55", result_type::success ); + verify_rule< uint32_be::any >( __LINE__, __FILE__, "\x71\x72\x03\x55", result_type::success ); + verify_rule< uint32_le::any >( __LINE__, __FILE__, "\x01\x02\x03\x55", result_type::success ); + verify_rule< uint32_le::any >( __LINE__, __FILE__, "\x71\x72\x03\x55", result_type::success ); - verify_rule< uint32_be::any >( __LINE__, __FILE__, "\x01\x02\x03\x55\x44", result_type::SUCCESS, 1 ); - verify_rule< uint32_be::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44", result_type::SUCCESS, 1 ); - verify_rule< uint32_le::any >( __LINE__, __FILE__, "\x01\x02\x03\x55\x44", result_type::SUCCESS, 1 ); - verify_rule< uint32_le::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44", result_type::SUCCESS, 1 ); + verify_rule< uint32_be::any >( __LINE__, __FILE__, "\x01\x02\x03\x55\x44", result_type::success, 1 ); + verify_rule< uint32_be::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44", result_type::success, 1 ); + verify_rule< uint32_le::any >( __LINE__, __FILE__, "\x01\x02\x03\x55\x44", result_type::success, 1 ); + verify_rule< uint32_le::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44", result_type::success, 1 ); - verify_rule< uint32_be::mask_not_one< 0xffffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x01\x11\x11", result_type::LOCAL_FAILURE ); + verify_rule< uint32_be::mask_not_one< 0xffffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x01\x11\x11", result_type::local_failure ); - verify_rule< uint32_be::mask_not_one< 0xffffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11", result_type::LOCAL_FAILURE ); - verify_rule< uint32_be::mask_not_one< 0xffffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x01", result_type::SUCCESS ); + verify_rule< uint32_be::mask_not_one< 0xffffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11", result_type::local_failure ); + verify_rule< uint32_be::mask_not_one< 0xffffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x01", result_type::success ); - verify_rule< uint32_le::mask_not_one< 0xffffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11", result_type::SUCCESS ); - verify_rule< uint32_le::mask_not_one< 0xffffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x01", result_type::LOCAL_FAILURE ); + verify_rule< uint32_le::mask_not_one< 0xffffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11", result_type::success ); + verify_rule< uint32_le::mask_not_one< 0xffffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x01", result_type::local_failure ); - verify_rule< uint32_be::mask_not_one< 0x0fffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\xf3\x11\x11\x11", result_type::SUCCESS ); - verify_rule< uint32_be::mask_not_one< 0x0fffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\xf1\x11\x11\x11", result_type::LOCAL_FAILURE ); + verify_rule< uint32_be::mask_not_one< 0x0fffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\xf3\x11\x11\x11", result_type::success ); + verify_rule< uint32_be::mask_not_one< 0x0fffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\xf1\x11\x11\x11", result_type::local_failure ); - verify_rule< uint32_le::mask_not_one< 0x0fffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\xf3", result_type::SUCCESS ); - verify_rule< uint32_le::mask_not_one< 0x0fffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\xf1", result_type::LOCAL_FAILURE ); + verify_rule< uint32_le::mask_not_one< 0x0fffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\xf3", result_type::success ); + verify_rule< uint32_le::mask_not_one< 0x0fffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\xf1", result_type::local_failure ); - verify_rule< uint32_be::mask_not_range< 0xffffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77", result_type::LOCAL_FAILURE ); - verify_rule< uint32_be::mask_not_range< 0xffffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x02", result_type::SUCCESS ); + verify_rule< uint32_be::mask_not_range< 0xffffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77", result_type::local_failure ); + verify_rule< uint32_be::mask_not_range< 0xffffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x02", result_type::success ); - verify_rule< uint32_le::mask_not_range< 0xffffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77", result_type::SUCCESS ); - verify_rule< uint32_le::mask_not_range< 0xffffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x02", result_type::LOCAL_FAILURE ); + verify_rule< uint32_le::mask_not_range< 0xffffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77", result_type::success ); + verify_rule< uint32_le::mask_not_range< 0xffffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x02", result_type::local_failure ); - verify_rule< uint32_be::mask_not_range< 0x0fffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x52\x77\x77\x77", result_type::LOCAL_FAILURE ); - verify_rule< uint32_be::mask_not_range< 0x0fffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x56\x77\x77\x77", result_type::SUCCESS ); + verify_rule< uint32_be::mask_not_range< 0x0fffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x52\x77\x77\x77", result_type::local_failure ); + verify_rule< uint32_be::mask_not_range< 0x0fffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x56\x77\x77\x77", result_type::success ); - verify_rule< uint32_le::mask_not_range< 0x0fffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x52", result_type::LOCAL_FAILURE ); - verify_rule< uint32_le::mask_not_range< 0x0fffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x56", result_type::SUCCESS ); + verify_rule< uint32_le::mask_not_range< 0x0fffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x52", result_type::local_failure ); + verify_rule< uint32_le::mask_not_range< 0x0fffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x56", result_type::success ); - verify_rule< uint32_be::mask_one< 0xffffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11", result_type::SUCCESS ); - verify_rule< uint32_be::mask_one< 0xffffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x01", result_type::LOCAL_FAILURE ); + verify_rule< uint32_be::mask_one< 0xffffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11", result_type::success ); + verify_rule< uint32_be::mask_one< 0xffffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x01", result_type::local_failure ); - verify_rule< uint32_le::mask_one< 0xffffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11", result_type::LOCAL_FAILURE ); - verify_rule< uint32_le::mask_one< 0xffffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x01", result_type::SUCCESS ); + verify_rule< uint32_le::mask_one< 0xffffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11", result_type::local_failure ); + verify_rule< uint32_le::mask_one< 0xffffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x01", result_type::success ); - verify_rule< uint32_be::mask_one< 0x0fffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\xf3\x11\x11\x11", result_type::LOCAL_FAILURE ); - verify_rule< uint32_be::mask_one< 0x0fffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\xf1\x11\x11\x11", result_type::SUCCESS ); + verify_rule< uint32_be::mask_one< 0x0fffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\xf3\x11\x11\x11", result_type::local_failure ); + verify_rule< uint32_be::mask_one< 0x0fffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\xf1\x11\x11\x11", result_type::success ); - verify_rule< uint32_le::mask_one< 0x0fffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\xf3", result_type::LOCAL_FAILURE ); - verify_rule< uint32_le::mask_one< 0x0fffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\xf1", result_type::SUCCESS ); + verify_rule< uint32_le::mask_one< 0x0fffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\xf3", result_type::local_failure ); + verify_rule< uint32_le::mask_one< 0x0fffffff, 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\xf1", result_type::success ); - verify_rule< uint32_be::mask_range< 0xffffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77", result_type::SUCCESS ); - verify_rule< uint32_be::mask_range< 0xffffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x02", result_type::LOCAL_FAILURE ); + verify_rule< uint32_be::mask_range< 0xffffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77", result_type::success ); + verify_rule< uint32_be::mask_range< 0xffffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x02", result_type::local_failure ); - verify_rule< uint32_le::mask_range< 0xffffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77", result_type::LOCAL_FAILURE ); - verify_rule< uint32_le::mask_range< 0xffffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x02", result_type::SUCCESS ); + verify_rule< uint32_le::mask_range< 0xffffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77", result_type::local_failure ); + verify_rule< uint32_le::mask_range< 0xffffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x02", result_type::success ); - verify_rule< uint32_be::mask_range< 0x0fffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x52\x77\x77\x77", result_type::SUCCESS ); - verify_rule< uint32_be::mask_range< 0x0fffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x56\x77\x77\x77", result_type::LOCAL_FAILURE ); + verify_rule< uint32_be::mask_range< 0x0fffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x52\x77\x77\x77", result_type::success ); + verify_rule< uint32_be::mask_range< 0x0fffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x56\x77\x77\x77", result_type::local_failure ); - verify_rule< uint32_le::mask_range< 0x0fffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x52", result_type::SUCCESS ); - verify_rule< uint32_le::mask_range< 0x0fffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x56", result_type::LOCAL_FAILURE ); + verify_rule< uint32_le::mask_range< 0x0fffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x52", result_type::success ); + verify_rule< uint32_le::mask_range< 0x0fffffff, 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x56", result_type::local_failure ); - verify_rule< uint32_be::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x01\x23\x45\x67", result_type::SUCCESS ); - verify_rule< uint32_be::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x02\x34\x56\x78", result_type::LOCAL_FAILURE ); - verify_rule< uint32_be::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x03\x45\x67\x89", result_type::SUCCESS ); - verify_rule< uint32_be::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x67\x89\x12\x34", result_type::LOCAL_FAILURE ); + verify_rule< uint32_be::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x01\x23\x45\x67", result_type::success ); + verify_rule< uint32_be::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x02\x34\x56\x78", result_type::local_failure ); + verify_rule< uint32_be::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x03\x45\x67\x89", result_type::success ); + verify_rule< uint32_be::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x67\x89\x12\x34", result_type::local_failure ); - verify_rule< uint32_le::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x67\x45\x23\x01", result_type::SUCCESS ); - verify_rule< uint32_le::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x78\x56\x34\x02", result_type::LOCAL_FAILURE ); - verify_rule< uint32_le::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x89\x67\x45\x03", result_type::SUCCESS ); - verify_rule< uint32_le::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x34\x12\x89\x67", result_type::LOCAL_FAILURE ); + verify_rule< uint32_le::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x67\x45\x23\x01", result_type::success ); + verify_rule< uint32_le::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x78\x56\x34\x02", result_type::local_failure ); + verify_rule< uint32_le::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x89\x67\x45\x03", result_type::success ); + verify_rule< uint32_le::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x34\x12\x89\x67", result_type::local_failure ); - verify_rule< uint32_be::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x01\x23\x45\x67", result_type::SUCCESS ); - verify_rule< uint32_be::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x02\x34\x56\x78", result_type::LOCAL_FAILURE ); - verify_rule< uint32_be::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x03\x45\x67\x89", result_type::SUCCESS ); - verify_rule< uint32_be::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x67\x89\x01\x02", result_type::SUCCESS ); + verify_rule< uint32_be::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x01\x23\x45\x67", result_type::success ); + verify_rule< uint32_be::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x02\x34\x56\x78", result_type::local_failure ); + verify_rule< uint32_be::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x03\x45\x67\x89", result_type::success ); + verify_rule< uint32_be::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x67\x89\x01\x02", result_type::success ); - verify_rule< uint32_le::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x67\x45\x23\x01", result_type::SUCCESS ); - verify_rule< uint32_le::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x78\x56\x34\x02", result_type::LOCAL_FAILURE ); - verify_rule< uint32_le::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x89\x67\x45\x03", result_type::SUCCESS ); - verify_rule< uint32_le::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x02\x01\x89\x67", result_type::SUCCESS ); + verify_rule< uint32_le::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x67\x45\x23\x01", result_type::success ); + verify_rule< uint32_le::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x78\x56\x34\x02", result_type::local_failure ); + verify_rule< uint32_le::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x89\x67\x45\x03", result_type::success ); + verify_rule< uint32_le::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x02\x01\x89\x67", result_type::success ); - verify_rule< uint32_be::mask_ranges< 0xff0fffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x02\x50\x02\x02", result_type::SUCCESS ); - verify_rule< uint32_be::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x02\x50\x02\x02", result_type::LOCAL_FAILURE ); + verify_rule< uint32_be::mask_ranges< 0xff0fffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x02\x50\x02\x02", result_type::success ); + verify_rule< uint32_be::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x02\x50\x02\x02", result_type::local_failure ); - verify_rule< uint32_le::mask_ranges< 0xff0fffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x02\x02\x50\x02", result_type::SUCCESS ); - verify_rule< uint32_le::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x02\x02\x50\x02", result_type::LOCAL_FAILURE ); + verify_rule< uint32_le::mask_ranges< 0xff0fffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x02\x02\x50\x02", result_type::success ); + verify_rule< uint32_le::mask_ranges< 0xffffffff, 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x02\x02\x50\x02", result_type::local_failure ); - verify_rule< uint32_be::mask_string< 0xffffffff, 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x01\x23\x32\x10\x45\x67\x76\x54", result_type::SUCCESS ); - verify_rule< uint32_be::mask_string< 0xffffffff, 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x10\x32\x23\x01\x54\x76\x67\x45", result_type::LOCAL_FAILURE ); + verify_rule< uint32_be::mask_string< 0xffffffff, 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x01\x23\x32\x10\x45\x67\x76\x54", result_type::success ); + verify_rule< uint32_be::mask_string< 0xffffffff, 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x10\x32\x23\x01\x54\x76\x67\x45", result_type::local_failure ); - verify_rule< uint32_le::mask_string< 0xffffffff, 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x01\x23\x32\x10\x45\x67\x76\x54", result_type::LOCAL_FAILURE ); - verify_rule< uint32_le::mask_string< 0xffffffff, 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x10\x32\x23\x01\x54\x76\x67\x45", result_type::SUCCESS ); + verify_rule< uint32_le::mask_string< 0xffffffff, 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x01\x23\x32\x10\x45\x67\x76\x54", result_type::local_failure ); + verify_rule< uint32_le::mask_string< 0xffffffff, 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x10\x32\x23\x01\x54\x76\x67\x45", result_type::success ); - verify_rule< uint32_be::mask_string< 0xffffffff, 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x81\x23\x32\x10\x45\x67\x76\x54", result_type::LOCAL_FAILURE ); - verify_rule< uint32_be::mask_string< 0x4fffffff, 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x81\x23\x32\x10\x45\x67\x76\x54", result_type::SUCCESS ); + verify_rule< uint32_be::mask_string< 0xffffffff, 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x81\x23\x32\x10\x45\x67\x76\x54", result_type::local_failure ); + verify_rule< uint32_be::mask_string< 0x4fffffff, 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x81\x23\x32\x10\x45\x67\x76\x54", result_type::success ); - verify_rule< uint32_le::mask_string< 0xffffffff, 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x10\x32\x23\x81\x54\x76\x67\x45", result_type::LOCAL_FAILURE ); - verify_rule< uint32_le::mask_string< 0x4fffffff, 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x10\x32\x23\x81\x54\x76\x67\x45", result_type::SUCCESS ); + verify_rule< uint32_le::mask_string< 0xffffffff, 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x10\x32\x23\x81\x54\x76\x67\x45", result_type::local_failure ); + verify_rule< uint32_le::mask_string< 0x4fffffff, 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x10\x32\x23\x81\x54\x76\x67\x45", result_type::success ); - verify_rule< uint32_be::not_one< 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11", result_type::LOCAL_FAILURE ); - verify_rule< uint32_be::not_one< 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x01", result_type::SUCCESS ); + verify_rule< uint32_be::not_one< 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11", result_type::local_failure ); + verify_rule< uint32_be::not_one< 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x01", result_type::success ); - verify_rule< uint32_le::not_one< 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11", result_type::SUCCESS ); - verify_rule< uint32_le::not_one< 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x01", result_type::LOCAL_FAILURE ); + verify_rule< uint32_le::not_one< 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11", result_type::success ); + verify_rule< uint32_le::not_one< 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x01", result_type::local_failure ); - verify_rule< uint32_be::not_range< 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77", result_type::LOCAL_FAILURE ); - verify_rule< uint32_be::not_range< 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x02", result_type::SUCCESS ); + verify_rule< uint32_be::not_range< 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77", result_type::local_failure ); + verify_rule< uint32_be::not_range< 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x02", result_type::success ); - verify_rule< uint32_le::not_range< 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77", result_type::SUCCESS ); - verify_rule< uint32_le::not_range< 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x02", result_type::LOCAL_FAILURE ); + verify_rule< uint32_le::not_range< 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77", result_type::success ); + verify_rule< uint32_le::not_range< 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x02", result_type::local_failure ); - verify_rule< uint32_be::one< 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11", result_type::SUCCESS ); - verify_rule< uint32_be::one< 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x01", result_type::LOCAL_FAILURE ); + verify_rule< uint32_be::one< 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11", result_type::success ); + verify_rule< uint32_be::one< 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x01", result_type::local_failure ); - verify_rule< uint32_le::one< 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11", result_type::LOCAL_FAILURE ); - verify_rule< uint32_le::one< 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x01", result_type::SUCCESS ); + verify_rule< uint32_le::one< 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11", result_type::local_failure ); + verify_rule< uint32_le::one< 0x01111111, 0x02222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x01", result_type::success ); - verify_rule< uint32_be::range< 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77", result_type::SUCCESS ); - verify_rule< uint32_be::range< 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x02", result_type::LOCAL_FAILURE ); + verify_rule< uint32_be::range< 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77", result_type::success ); + verify_rule< uint32_be::range< 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x02", result_type::local_failure ); - verify_rule< uint32_le::range< 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77", result_type::LOCAL_FAILURE ); - verify_rule< uint32_le::range< 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x02", result_type::SUCCESS ); + verify_rule< uint32_le::range< 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77", result_type::local_failure ); + verify_rule< uint32_le::range< 0x01000000, 0x04000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x02", result_type::success ); - verify_rule< uint32_be::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x01\x23\x45\x67", result_type::SUCCESS ); - verify_rule< uint32_be::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x02\x34\x56\x78", result_type::LOCAL_FAILURE ); - verify_rule< uint32_be::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x03\x45\x67\x89", result_type::SUCCESS ); - verify_rule< uint32_be::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x67\x89\x12\x34", result_type::LOCAL_FAILURE ); + verify_rule< uint32_be::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x01\x23\x45\x67", result_type::success ); + verify_rule< uint32_be::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x02\x34\x56\x78", result_type::local_failure ); + verify_rule< uint32_be::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x03\x45\x67\x89", result_type::success ); + verify_rule< uint32_be::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x67\x89\x12\x34", result_type::local_failure ); - verify_rule< uint32_le::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x67\x45\x23\x01", result_type::SUCCESS ); - verify_rule< uint32_le::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x78\x56\x34\x02", result_type::LOCAL_FAILURE ); - verify_rule< uint32_le::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x89\x67\x45\x03", result_type::SUCCESS ); - verify_rule< uint32_le::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x34\x12\x89\x67", result_type::LOCAL_FAILURE ); + verify_rule< uint32_le::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x67\x45\x23\x01", result_type::success ); + verify_rule< uint32_le::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x78\x56\x34\x02", result_type::local_failure ); + verify_rule< uint32_le::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x89\x67\x45\x03", result_type::success ); + verify_rule< uint32_le::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444 > >( __LINE__, __FILE__, "\x34\x12\x89\x67", result_type::local_failure ); - verify_rule< uint32_be::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x01\x23\x45\x67", result_type::SUCCESS ); - verify_rule< uint32_be::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x02\x34\x56\x78", result_type::LOCAL_FAILURE ); - verify_rule< uint32_be::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x03\x45\x67\x89", result_type::SUCCESS ); - verify_rule< uint32_be::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x67\x89\x01\x02", result_type::SUCCESS ); + verify_rule< uint32_be::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x01\x23\x45\x67", result_type::success ); + verify_rule< uint32_be::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x02\x34\x56\x78", result_type::local_failure ); + verify_rule< uint32_be::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x03\x45\x67\x89", result_type::success ); + verify_rule< uint32_be::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x67\x89\x01\x02", result_type::success ); - verify_rule< uint32_le::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x67\x45\x23\x01", result_type::SUCCESS ); - verify_rule< uint32_le::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x78\x56\x34\x02", result_type::LOCAL_FAILURE ); - verify_rule< uint32_le::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x89\x67\x45\x03", result_type::SUCCESS ); - verify_rule< uint32_le::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x02\x01\x89\x67", result_type::SUCCESS ); + verify_rule< uint32_le::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x67\x45\x23\x01", result_type::success ); + verify_rule< uint32_le::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x78\x56\x34\x02", result_type::local_failure ); + verify_rule< uint32_le::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x89\x67\x45\x03", result_type::success ); + verify_rule< uint32_le::ranges< 0x01111111, 0x02222222, 0x03333333, 0x04444444, 0x67890102 > >( __LINE__, __FILE__, "\x02\x01\x89\x67", result_type::success ); - verify_rule< uint32_be::string< 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x01\x23\x32\x10\x45\x67\x76\x54", result_type::SUCCESS ); - verify_rule< uint32_be::string< 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x10\x32\x23\x01\x54\x76\x67\x45", result_type::LOCAL_FAILURE ); + verify_rule< uint32_be::string< 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x01\x23\x32\x10\x45\x67\x76\x54", result_type::success ); + verify_rule< uint32_be::string< 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x10\x32\x23\x01\x54\x76\x67\x45", result_type::local_failure ); - verify_rule< uint32_le::string< 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x01\x23\x32\x10\x45\x67\x76\x54", result_type::LOCAL_FAILURE ); - verify_rule< uint32_le::string< 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x10\x32\x23\x01\x54\x76\x67\x45", result_type::SUCCESS ); - } + verify_rule< uint32_le::string< 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x01\x23\x32\x10\x45\x67\x76\x54", result_type::local_failure ); + verify_rule< uint32_le::string< 0x01233210, 0x45677654 > >( __LINE__, __FILE__, "\x10\x32\x23\x01\x54\x76\x67\x45", result_type::success ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/uint64_general.cpp b/packages/PEGTL/src/test/pegtl/uint64_general.cpp index fc0eb0d63..b32701eed 100644 --- a/packages/PEGTL/src/test/pegtl/uint64_general.cpp +++ b/packages/PEGTL/src/test/pegtl/uint64_general.cpp @@ -1,187 +1,183 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_char.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_rule< uint64_be::any >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< uint64_le::any >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); + verify_rule< uint64_be::any >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< uint64_le::any >( __LINE__, __FILE__, "", result_type::local_failure ); - verify_rule< uint64_be::any >( __LINE__, __FILE__, "\x01", result_type::LOCAL_FAILURE ); - verify_rule< uint64_le::any >( __LINE__, __FILE__, "\x01", result_type::LOCAL_FAILURE ); + verify_rule< uint64_be::any >( __LINE__, __FILE__, "\x01", result_type::local_failure ); + verify_rule< uint64_le::any >( __LINE__, __FILE__, "\x01", result_type::local_failure ); - verify_rule< uint64_be::any >( __LINE__, __FILE__, "\x71\x72", result_type::LOCAL_FAILURE ); - verify_rule< uint64_le::any >( __LINE__, __FILE__, "\x71\x72", result_type::LOCAL_FAILURE ); + verify_rule< uint64_be::any >( __LINE__, __FILE__, "\x71\x72", result_type::local_failure ); + verify_rule< uint64_le::any >( __LINE__, __FILE__, "\x71\x72", result_type::local_failure ); - verify_rule< uint64_be::any >( __LINE__, __FILE__, "\x71\x72\x03", result_type::LOCAL_FAILURE ); - verify_rule< uint64_le::any >( __LINE__, __FILE__, "\x71\x72\x03", result_type::LOCAL_FAILURE ); + verify_rule< uint64_be::any >( __LINE__, __FILE__, "\x71\x72\x03", result_type::local_failure ); + verify_rule< uint64_le::any >( __LINE__, __FILE__, "\x71\x72\x03", result_type::local_failure ); - verify_rule< uint64_be::any >( __LINE__, __FILE__, "\x71\x72\x03\x55", result_type::LOCAL_FAILURE ); - verify_rule< uint64_le::any >( __LINE__, __FILE__, "\x71\x72\x03\x55", result_type::LOCAL_FAILURE ); + verify_rule< uint64_be::any >( __LINE__, __FILE__, "\x71\x72\x03\x55", result_type::local_failure ); + verify_rule< uint64_le::any >( __LINE__, __FILE__, "\x71\x72\x03\x55", result_type::local_failure ); - verify_rule< uint64_be::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44", result_type::LOCAL_FAILURE ); - verify_rule< uint64_le::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44", result_type::LOCAL_FAILURE ); + verify_rule< uint64_be::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44", result_type::local_failure ); + verify_rule< uint64_le::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44", result_type::local_failure ); - verify_rule< uint64_be::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44\x33", result_type::LOCAL_FAILURE ); - verify_rule< uint64_le::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44\x33", result_type::LOCAL_FAILURE ); + verify_rule< uint64_be::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44\x33", result_type::local_failure ); + verify_rule< uint64_le::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44\x33", result_type::local_failure ); - verify_rule< uint64_be::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44\x33\x22", result_type::LOCAL_FAILURE ); - verify_rule< uint64_le::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44\x33\x22", result_type::LOCAL_FAILURE ); + verify_rule< uint64_be::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44\x33\x22", result_type::local_failure ); + verify_rule< uint64_le::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44\x33\x22", result_type::local_failure ); - verify_rule< uint64_be::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44\x33\x22\x11", result_type::SUCCESS ); - verify_rule< uint64_le::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44\x33\x22\x11", result_type::SUCCESS ); + verify_rule< uint64_be::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44\x33\x22\x11", result_type::success ); + verify_rule< uint64_le::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44\x33\x22\x11", result_type::success ); - verify_rule< uint64_be::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44\x33\x22\x11\x99", result_type::SUCCESS, 1 ); - verify_rule< uint64_le::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44\x33\x22\x11\x99", result_type::SUCCESS, 1 ); + verify_rule< uint64_be::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44\x33\x22\x11\x99", result_type::success, 1 ); + verify_rule< uint64_le::any >( __LINE__, __FILE__, "\x71\x72\x03\x55\x44\x33\x22\x11\x99", result_type::success, 1 ); - verify_rule< uint64_be::mask_not_one< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11\x11\x11\x11", result_type::LOCAL_FAILURE ); + verify_rule< uint64_be::mask_not_one< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11\x11\x11\x11", result_type::local_failure ); - verify_rule< uint64_be::mask_not_one< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11\x11\x11\x11\x11", result_type::LOCAL_FAILURE ); - verify_rule< uint64_be::mask_not_one< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\x01", result_type::SUCCESS ); + verify_rule< uint64_be::mask_not_one< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11\x11\x11\x11\x11", result_type::local_failure ); + verify_rule< uint64_be::mask_not_one< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\x01", result_type::success ); - verify_rule< uint64_le::mask_not_one< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11\x11\x11\x11\x11", result_type::SUCCESS ); - verify_rule< uint64_le::mask_not_one< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\x01", result_type::LOCAL_FAILURE ); + verify_rule< uint64_le::mask_not_one< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11\x11\x11\x11\x11", result_type::success ); + verify_rule< uint64_le::mask_not_one< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\x01", result_type::local_failure ); - verify_rule< uint64_be::mask_not_one< 0x0fffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\xf3\x11\x11\x11\x11\x11\x11\x11", result_type::SUCCESS ); - verify_rule< uint64_be::mask_not_one< 0x0fffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\xf1\x11\x11\x11\x11\x11\x11\x11", result_type::LOCAL_FAILURE ); + verify_rule< uint64_be::mask_not_one< 0x0fffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\xf3\x11\x11\x11\x11\x11\x11\x11", result_type::success ); + verify_rule< uint64_be::mask_not_one< 0x0fffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\xf1\x11\x11\x11\x11\x11\x11\x11", result_type::local_failure ); - verify_rule< uint64_le::mask_not_one< 0x0fffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\xf3", result_type::SUCCESS ); - verify_rule< uint64_le::mask_not_one< 0x0fffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\xf1", result_type::LOCAL_FAILURE ); + verify_rule< uint64_le::mask_not_one< 0x0fffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\xf3", result_type::success ); + verify_rule< uint64_le::mask_not_one< 0x0fffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\xf1", result_type::local_failure ); - verify_rule< uint64_be::mask_not_range< 0xffffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77\x77\x77\x77\x77", result_type::LOCAL_FAILURE ); - verify_rule< uint64_be::mask_not_range< 0xffffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x02", result_type::SUCCESS ); + verify_rule< uint64_be::mask_not_range< 0xffffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77\x77\x77\x77\x77", result_type::local_failure ); + verify_rule< uint64_be::mask_not_range< 0xffffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x02", result_type::success ); - verify_rule< uint64_le::mask_not_range< 0xffffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77\x77\x77\x77\x77", result_type::SUCCESS ); - verify_rule< uint64_le::mask_not_range< 0xffffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x02", result_type::LOCAL_FAILURE ); + verify_rule< uint64_le::mask_not_range< 0xffffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77\x77\x77\x77\x77", result_type::success ); + verify_rule< uint64_le::mask_not_range< 0xffffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x02", result_type::local_failure ); - verify_rule< uint64_be::mask_not_range< 0x0fffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x52\x77\x77\x77\x77\x77\x77\x77", result_type::LOCAL_FAILURE ); - verify_rule< uint64_be::mask_not_range< 0x0fffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x56\x77\x77\x77\x77\x77\x77\x77", result_type::SUCCESS ); + verify_rule< uint64_be::mask_not_range< 0x0fffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x52\x77\x77\x77\x77\x77\x77\x77", result_type::local_failure ); + verify_rule< uint64_be::mask_not_range< 0x0fffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x56\x77\x77\x77\x77\x77\x77\x77", result_type::success ); - verify_rule< uint64_le::mask_not_range< 0x0fffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x52", result_type::LOCAL_FAILURE ); - verify_rule< uint64_le::mask_not_range< 0x0fffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x56", result_type::SUCCESS ); + verify_rule< uint64_le::mask_not_range< 0x0fffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x52", result_type::local_failure ); + verify_rule< uint64_le::mask_not_range< 0x0fffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x56", result_type::success ); - verify_rule< uint64_be::mask_one< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11\x11\x11\x11\x11", result_type::SUCCESS ); - verify_rule< uint64_be::mask_one< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\x01", result_type::LOCAL_FAILURE ); + verify_rule< uint64_be::mask_one< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11\x11\x11\x11\x11", result_type::success ); + verify_rule< uint64_be::mask_one< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\x01", result_type::local_failure ); - verify_rule< uint64_le::mask_one< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11\x11\x11\x11\x11", result_type::LOCAL_FAILURE ); - verify_rule< uint64_le::mask_one< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\x01", result_type::SUCCESS ); + verify_rule< uint64_le::mask_one< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11\x11\x11\x11\x11", result_type::local_failure ); + verify_rule< uint64_le::mask_one< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\x01", result_type::success ); - verify_rule< uint64_be::mask_one< 0x0fffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\xf3\x11\x11\x11\x11\x11\x11\x11", result_type::LOCAL_FAILURE ); - verify_rule< uint64_be::mask_one< 0x0fffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\xf1\x11\x11\x11\x11\x11\x11\x11", result_type::SUCCESS ); + verify_rule< uint64_be::mask_one< 0x0fffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\xf3\x11\x11\x11\x11\x11\x11\x11", result_type::local_failure ); + verify_rule< uint64_be::mask_one< 0x0fffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\xf1\x11\x11\x11\x11\x11\x11\x11", result_type::success ); - verify_rule< uint64_le::mask_one< 0x0fffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\xf3", result_type::LOCAL_FAILURE ); - verify_rule< uint64_le::mask_one< 0x0fffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\xf1", result_type::SUCCESS ); + verify_rule< uint64_le::mask_one< 0x0fffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\xf3", result_type::local_failure ); + verify_rule< uint64_le::mask_one< 0x0fffffffffffffff, 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\xf1", result_type::success ); - verify_rule< uint64_be::mask_range< 0xffffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77\x77\x77\x77\x77", result_type::SUCCESS ); - verify_rule< uint64_be::mask_range< 0xffffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x02", result_type::LOCAL_FAILURE ); + verify_rule< uint64_be::mask_range< 0xffffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77\x77\x77\x77\x77", result_type::success ); + verify_rule< uint64_be::mask_range< 0xffffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x02", result_type::local_failure ); - verify_rule< uint64_le::mask_range< 0xffffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77\x77\x77\x77\x77", result_type::LOCAL_FAILURE ); - verify_rule< uint64_le::mask_range< 0xffffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x02", result_type::SUCCESS ); + verify_rule< uint64_le::mask_range< 0xffffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77\x77\x77\x77\x77", result_type::local_failure ); + verify_rule< uint64_le::mask_range< 0xffffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x02", result_type::success ); - verify_rule< uint64_be::mask_range< 0x0fffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x52\x77\x77\x77\x77\x77\x77\x77", result_type::SUCCESS ); - verify_rule< uint64_be::mask_range< 0x0fffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x56\x77\x77\x77\x77\x77\x77\x77", result_type::LOCAL_FAILURE ); + verify_rule< uint64_be::mask_range< 0x0fffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x52\x77\x77\x77\x77\x77\x77\x77", result_type::success ); + verify_rule< uint64_be::mask_range< 0x0fffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x56\x77\x77\x77\x77\x77\x77\x77", result_type::local_failure ); - verify_rule< uint64_le::mask_range< 0x0fffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x52", result_type::SUCCESS ); - verify_rule< uint64_le::mask_range< 0x0fffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x56", result_type::LOCAL_FAILURE ); + verify_rule< uint64_le::mask_range< 0x0fffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x52", result_type::success ); + verify_rule< uint64_le::mask_range< 0x0fffffffffffffff, 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x56", result_type::local_failure ); - verify_rule< uint64_be::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x01\x23\x45\x67\x99\x99\x99\x99", result_type::SUCCESS ); - verify_rule< uint64_be::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x02\x34\x56\x78\x99\x99\x99\x99", result_type::LOCAL_FAILURE ); - verify_rule< uint64_be::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x03\x45\x67\x89\x99\x99\x99\x99", result_type::SUCCESS ); - verify_rule< uint64_be::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x67\x89\x12\x34\x99\x99\x99\x99", result_type::LOCAL_FAILURE ); + verify_rule< uint64_be::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x01\x23\x45\x67\x99\x99\x99\x99", result_type::success ); + verify_rule< uint64_be::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x02\x34\x56\x78\x99\x99\x99\x99", result_type::local_failure ); + verify_rule< uint64_be::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x03\x45\x67\x89\x99\x99\x99\x99", result_type::success ); + verify_rule< uint64_be::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x67\x89\x12\x34\x99\x99\x99\x99", result_type::local_failure ); - verify_rule< uint64_le::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x67\x45\x23\x01", result_type::SUCCESS ); - verify_rule< uint64_le::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x78\x56\x34\x02", result_type::LOCAL_FAILURE ); - verify_rule< uint64_le::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x89\x67\x45\x03", result_type::SUCCESS ); - verify_rule< uint64_le::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x34\x12\x89\x67", result_type::LOCAL_FAILURE ); + verify_rule< uint64_le::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x67\x45\x23\x01", result_type::success ); + verify_rule< uint64_le::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x78\x56\x34\x02", result_type::local_failure ); + verify_rule< uint64_le::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x89\x67\x45\x03", result_type::success ); + verify_rule< uint64_le::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x34\x12\x89\x67", result_type::local_failure ); - verify_rule< uint64_be::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x01\x23\x45\x67\x99\x99\x99\x99", result_type::SUCCESS ); - verify_rule< uint64_be::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x02\x34\x56\x78\x99\x99\x99\x99", result_type::LOCAL_FAILURE ); - verify_rule< uint64_be::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x03\x45\x67\x89\x99\x99\x99\x99", result_type::SUCCESS ); - verify_rule< uint64_be::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x67\x89\x01\x02\x99\x99\x99\x99", result_type::SUCCESS ); + verify_rule< uint64_be::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x01\x23\x45\x67\x99\x99\x99\x99", result_type::success ); + verify_rule< uint64_be::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x02\x34\x56\x78\x99\x99\x99\x99", result_type::local_failure ); + verify_rule< uint64_be::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x03\x45\x67\x89\x99\x99\x99\x99", result_type::success ); + verify_rule< uint64_be::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x67\x89\x01\x02\x99\x99\x99\x99", result_type::success ); - verify_rule< uint64_le::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x67\x45\x23\x01", result_type::SUCCESS ); - verify_rule< uint64_le::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x78\x56\x34\x02", result_type::LOCAL_FAILURE ); - verify_rule< uint64_le::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x89\x67\x45\x03", result_type::SUCCESS ); - verify_rule< uint64_le::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x02\x01\x89\x67", result_type::SUCCESS ); + verify_rule< uint64_le::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x67\x45\x23\x01", result_type::success ); + verify_rule< uint64_le::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x78\x56\x34\x02", result_type::local_failure ); + verify_rule< uint64_le::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x89\x67\x45\x03", result_type::success ); + verify_rule< uint64_le::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x02\x01\x89\x67", result_type::success ); - verify_rule< uint64_be::mask_ranges< 0xff0fffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x02\x50\x02\x02\x99\x99\x99\x99", result_type::SUCCESS ); - verify_rule< uint64_be::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x02\x50\x02\x02\x99\x99\x99\x99", result_type::LOCAL_FAILURE ); + verify_rule< uint64_be::mask_ranges< 0xff0fffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x02\x50\x02\x02\x99\x99\x99\x99", result_type::success ); + verify_rule< uint64_be::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x02\x50\x02\x02\x99\x99\x99\x99", result_type::local_failure ); - verify_rule< uint64_le::mask_ranges< 0xff0fffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x02\x02\x50\x02", result_type::SUCCESS ); - verify_rule< uint64_le::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x02\x02\x50\x02", result_type::LOCAL_FAILURE ); + verify_rule< uint64_le::mask_ranges< 0xff0fffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x02\x02\x50\x02", result_type::success ); + verify_rule< uint64_le::mask_ranges< 0xffffffffffffffff, 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x02\x02\x50\x02", result_type::local_failure ); - verify_rule< uint64_be::mask_string< 0xffffffffffffffff, 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\x01\x23\x32\x10\xde\xad\xca\xfe\x45\x67\x76\x54\xba\xff\xb1\xff", result_type::SUCCESS ); - verify_rule< uint64_be::mask_string< 0xffffffffffffffff, 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\xfe\xca\xad\xde\x10\x32\x23\x01\xff\xb1\xff\xba\x54\x76\x67\x45", result_type::LOCAL_FAILURE ); + verify_rule< uint64_be::mask_string< 0xffffffffffffffff, 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\x01\x23\x32\x10\xde\xad\xca\xfe\x45\x67\x76\x54\xba\xff\xb1\xff", result_type::success ); + verify_rule< uint64_be::mask_string< 0xffffffffffffffff, 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\xfe\xca\xad\xde\x10\x32\x23\x01\xff\xb1\xff\xba\x54\x76\x67\x45", result_type::local_failure ); - verify_rule< uint64_le::mask_string< 0xffffffffffffffff, 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\x01\x23\x32\x10\xde\xad\xca\xfe\x45\x67\x76\x54\xba\xff\xb1\xff", result_type::LOCAL_FAILURE ); - verify_rule< uint64_le::mask_string< 0xffffffffffffffff, 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\xfe\xca\xad\xde\x10\x32\x23\x01\xff\xb1\xff\xba\x54\x76\x67\x45", result_type::SUCCESS ); + verify_rule< uint64_le::mask_string< 0xffffffffffffffff, 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\x01\x23\x32\x10\xde\xad\xca\xfe\x45\x67\x76\x54\xba\xff\xb1\xff", result_type::local_failure ); + verify_rule< uint64_le::mask_string< 0xffffffffffffffff, 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\xfe\xca\xad\xde\x10\x32\x23\x01\xff\xb1\xff\xba\x54\x76\x67\x45", result_type::success ); - verify_rule< uint64_be::mask_string< 0x4fffffffffffffff, 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\x81\x23\x32\x10\xde\xad\xca\xfe\x45\x67\x76\x54\xba\xff\xb1\xff", result_type::SUCCESS ); - verify_rule< uint64_be::mask_string< 0x8fffffffffffffff, 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\x81\x23\x32\x10\xde\xad\xca\xfe\x45\x67\x76\x54\xba\xff\xb1\xff", result_type::LOCAL_FAILURE ); + verify_rule< uint64_be::mask_string< 0x4fffffffffffffff, 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\x81\x23\x32\x10\xde\xad\xca\xfe\x45\x67\x76\x54\xba\xff\xb1\xff", result_type::success ); + verify_rule< uint64_be::mask_string< 0x8fffffffffffffff, 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\x81\x23\x32\x10\xde\xad\xca\xfe\x45\x67\x76\x54\xba\xff\xb1\xff", result_type::local_failure ); - verify_rule< uint64_le::mask_string< 0x4fffffffffffffff, 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\xfe\xca\xad\xde\x10\x32\x23\x81\xff\xb1\xff\xba\x54\x76\x67\x45", result_type::SUCCESS ); - verify_rule< uint64_le::mask_string< 0x8fffffffffffffff, 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\xfe\xca\xad\xde\x10\x32\x23\x81\xff\xb1\xff\xba\x54\x76\x67\x45", result_type::LOCAL_FAILURE ); + verify_rule< uint64_le::mask_string< 0x4fffffffffffffff, 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\xfe\xca\xad\xde\x10\x32\x23\x81\xff\xb1\xff\xba\x54\x76\x67\x45", result_type::success ); + verify_rule< uint64_le::mask_string< 0x8fffffffffffffff, 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\xfe\xca\xad\xde\x10\x32\x23\x81\xff\xb1\xff\xba\x54\x76\x67\x45", result_type::local_failure ); - verify_rule< uint64_be::not_one< 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11\x11\x11\x11\x11", result_type::LOCAL_FAILURE ); - verify_rule< uint64_be::not_one< 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\x01", result_type::SUCCESS ); + verify_rule< uint64_be::not_one< 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11\x11\x11\x11\x11", result_type::local_failure ); + verify_rule< uint64_be::not_one< 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\x01", result_type::success ); - verify_rule< uint64_le::not_one< 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11\x11\x11\x11\x11", result_type::SUCCESS ); - verify_rule< uint64_le::not_one< 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\x01", result_type::LOCAL_FAILURE ); + verify_rule< uint64_le::not_one< 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11\x11\x11\x11\x11", result_type::success ); + verify_rule< uint64_le::not_one< 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\x01", result_type::local_failure ); - verify_rule< uint64_be::not_range< 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77\x77\x77\x77\x77", result_type::LOCAL_FAILURE ); - verify_rule< uint64_be::not_range< 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x02", result_type::SUCCESS ); + verify_rule< uint64_be::not_range< 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77\x77\x77\x77\x77", result_type::local_failure ); + verify_rule< uint64_be::not_range< 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x02", result_type::success ); - verify_rule< uint64_le::not_range< 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77\x77\x77\x77\x77", result_type::SUCCESS ); - verify_rule< uint64_le::not_range< 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x02", result_type::LOCAL_FAILURE ); + verify_rule< uint64_le::not_range< 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77\x77\x77\x77\x77", result_type::success ); + verify_rule< uint64_le::not_range< 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x02", result_type::local_failure ); - verify_rule< uint64_be::one< 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11\x11\x11\x11\x11", result_type::SUCCESS ); - verify_rule< uint64_be::one< 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\x01", result_type::LOCAL_FAILURE ); + verify_rule< uint64_be::one< 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11\x11\x11\x11\x11", result_type::success ); + verify_rule< uint64_be::one< 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\x01", result_type::local_failure ); - verify_rule< uint64_le::one< 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11\x11\x11\x11\x11", result_type::LOCAL_FAILURE ); - verify_rule< uint64_le::one< 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\x01", result_type::SUCCESS ); + verify_rule< uint64_le::one< 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x01\x11\x11\x11\x11\x11\x11\x11", result_type::local_failure ); + verify_rule< uint64_le::one< 0x0111111111111111, 0x0222222222222222 > >( __LINE__, __FILE__, "\x11\x11\x11\x11\x11\x11\x11\x01", result_type::success ); - verify_rule< uint64_be::range< 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77\x77\x77\x77\x77", result_type::SUCCESS ); - verify_rule< uint64_be::range< 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x02", result_type::LOCAL_FAILURE ); + verify_rule< uint64_be::range< 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77\x77\x77\x77\x77", result_type::success ); + verify_rule< uint64_be::range< 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x02", result_type::local_failure ); - verify_rule< uint64_le::range< 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77\x77\x77\x77\x77", result_type::LOCAL_FAILURE ); - verify_rule< uint64_le::range< 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x02", result_type::SUCCESS ); + verify_rule< uint64_le::range< 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x02\x77\x77\x77\x77\x77\x77\x77", result_type::local_failure ); + verify_rule< uint64_le::range< 0x0100000000000000, 0x0400000000000000 > >( __LINE__, __FILE__, "\x77\x77\x77\x77\x77\x77\x77\x02", result_type::success ); - verify_rule< uint64_be::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x01\x23\x45\x67\x99\x99\x99\x99", result_type::SUCCESS ); - verify_rule< uint64_be::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x02\x34\x56\x78\x99\x99\x99\x99", result_type::LOCAL_FAILURE ); - verify_rule< uint64_be::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x03\x45\x67\x89\x99\x99\x99\x99", result_type::SUCCESS ); - verify_rule< uint64_be::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x67\x89\x12\x34\x99\x99\x99\x99", result_type::LOCAL_FAILURE ); + verify_rule< uint64_be::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x01\x23\x45\x67\x99\x99\x99\x99", result_type::success ); + verify_rule< uint64_be::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x02\x34\x56\x78\x99\x99\x99\x99", result_type::local_failure ); + verify_rule< uint64_be::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x03\x45\x67\x89\x99\x99\x99\x99", result_type::success ); + verify_rule< uint64_be::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x67\x89\x12\x34\x99\x99\x99\x99", result_type::local_failure ); - verify_rule< uint64_le::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x67\x45\x23\x01", result_type::SUCCESS ); - verify_rule< uint64_le::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x78\x56\x34\x02", result_type::LOCAL_FAILURE ); - verify_rule< uint64_le::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x89\x67\x45\x03", result_type::SUCCESS ); - verify_rule< uint64_le::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x34\x12\x89\x67", result_type::LOCAL_FAILURE ); + verify_rule< uint64_le::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x67\x45\x23\x01", result_type::success ); + verify_rule< uint64_le::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x78\x56\x34\x02", result_type::local_failure ); + verify_rule< uint64_le::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x89\x67\x45\x03", result_type::success ); + verify_rule< uint64_le::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x34\x12\x89\x67", result_type::local_failure ); - verify_rule< uint64_be::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x01\x23\x45\x67\x99\x99\x99\x99", result_type::SUCCESS ); - verify_rule< uint64_be::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x02\x34\x56\x78\x99\x99\x99\x99", result_type::LOCAL_FAILURE ); - verify_rule< uint64_be::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x03\x45\x67\x89\x99\x99\x99\x99", result_type::SUCCESS ); - verify_rule< uint64_be::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x67\x89\x01\x02\x99\x99\x99\x99", result_type::SUCCESS ); + verify_rule< uint64_be::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x01\x23\x45\x67\x99\x99\x99\x99", result_type::success ); + verify_rule< uint64_be::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x02\x34\x56\x78\x99\x99\x99\x99", result_type::local_failure ); + verify_rule< uint64_be::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x03\x45\x67\x89\x99\x99\x99\x99", result_type::success ); + verify_rule< uint64_be::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x67\x89\x01\x02\x99\x99\x99\x99", result_type::success ); - verify_rule< uint64_le::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x67\x45\x23\x01", result_type::SUCCESS ); - verify_rule< uint64_le::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x78\x56\x34\x02", result_type::LOCAL_FAILURE ); - verify_rule< uint64_le::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x89\x67\x45\x03", result_type::SUCCESS ); - verify_rule< uint64_le::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x02\x01\x89\x67", result_type::SUCCESS ); + verify_rule< uint64_le::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x67\x45\x23\x01", result_type::success ); + verify_rule< uint64_le::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x78\x56\x34\x02", result_type::local_failure ); + verify_rule< uint64_le::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x89\x67\x45\x03", result_type::success ); + verify_rule< uint64_le::ranges< 0x0111111111111111, 0x0222222222222222, 0x0333333333333333, 0x0444444444444444, 0x6789010299999999 > >( __LINE__, __FILE__, "\x99\x99\x99\x99\x02\x01\x89\x67", result_type::success ); - verify_rule< uint64_be::string< 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\x01\x23\x32\x10\xde\xad\xca\xfe\x45\x67\x76\x54\xba\xff\xb1\xff", result_type::SUCCESS ); - verify_rule< uint64_be::string< 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\xfe\xca\xad\xde\x10\x32\x23\x01\xff\xb1\xff\xba\x54\x76\x67\x45", result_type::LOCAL_FAILURE ); + verify_rule< uint64_be::string< 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\x01\x23\x32\x10\xde\xad\xca\xfe\x45\x67\x76\x54\xba\xff\xb1\xff", result_type::success ); + verify_rule< uint64_be::string< 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\xfe\xca\xad\xde\x10\x32\x23\x01\xff\xb1\xff\xba\x54\x76\x67\x45", result_type::local_failure ); - verify_rule< uint64_le::string< 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\x01\x23\x32\x10\xde\xad\xca\xfe\x45\x67\x76\x54\xba\xff\xb1\xff", result_type::LOCAL_FAILURE ); - verify_rule< uint64_le::string< 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\xfe\xca\xad\xde\x10\x32\x23\x01\xff\xb1\xff\xba\x54\x76\x67\x45", result_type::SUCCESS ); - } + verify_rule< uint64_le::string< 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\x01\x23\x32\x10\xde\xad\xca\xfe\x45\x67\x76\x54\xba\xff\xb1\xff", result_type::local_failure ); + verify_rule< uint64_le::string< 0x01233210deadcafe, 0x45677654baffb1ff > >( __LINE__, __FILE__, "\xfe\xca\xad\xde\x10\x32\x23\x01\xff\xb1\xff\xba\x54\x76\x67\x45", result_type::success ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/uint8_general.cpp b/packages/PEGTL/src/test/pegtl/uint8_general.cpp index c1642686f..75ec3268a 100644 --- a/packages/PEGTL/src/test/pegtl/uint8_general.cpp +++ b/packages/PEGTL/src/test/pegtl/uint8_general.cpp @@ -1,251 +1,247 @@ -// Copyright (c) 2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2018-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_char.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_rule< uint8::any >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - - for( int i = -100; i < 200; ++i ) { - verify_char< uint8::any >( __LINE__, __FILE__, char( i ), true ); - } - verify_rule< uint8::mask_not_one< 0xff, 0x01, 0x02 > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_not_one< 0xff, 0x01, 0x02 > >( __LINE__, __FILE__, "\x03", result_type::SUCCESS ); - verify_rule< uint8::mask_not_one< 0xff, 0x01, 0x02 > >( __LINE__, __FILE__, "\x03\x01", result_type::SUCCESS, 1 ); - verify_rule< uint8::mask_not_one< 0xff, 0x01, 0x10 > >( __LINE__, __FILE__, "\x01", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_not_one< 0xff, 0x01, 0x10 > >( __LINE__, __FILE__, "\x01\x01", result_type::LOCAL_FAILURE ); - - verify_rule< uint8::mask_not_one< 0xf0, 0x01, 0x02 > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_not_one< 0xf0, 0x01, 0x02 > >( __LINE__, __FILE__, "\x03", result_type::SUCCESS ); - verify_rule< uint8::mask_not_one< 0xf0, 0x01, 0x02 > >( __LINE__, __FILE__, "\x03\x01", result_type::SUCCESS, 1 ); - verify_rule< uint8::mask_not_one< 0xf0, 0x01, 0x10 > >( __LINE__, __FILE__, "\x01", result_type::SUCCESS ); - verify_rule< uint8::mask_not_one< 0xf0, 0x01, 0x10 > >( __LINE__, __FILE__, "\x01\x01", result_type::SUCCESS, 1 ); - verify_rule< uint8::mask_not_one< 0xf0, 0x01, 0x10 > >( __LINE__, __FILE__, "\x31", result_type::SUCCESS ); - verify_rule< uint8::mask_not_one< 0xf0, 0x01, 0x10 > >( __LINE__, __FILE__, "\x31\x01", result_type::SUCCESS, 1 ); - verify_rule< uint8::mask_not_one< 0xf0, 0x01, 0x10 > >( __LINE__, __FILE__, "\x11", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_not_one< 0xf0, 0x01, 0x10 > >( __LINE__, __FILE__, "\x11\x01", result_type::LOCAL_FAILURE ); - - verify_rule< uint8::mask_not_range< 0xff, 0x10, 0x2f > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_not_range< 0xff, 0x10, 0x2f > >( __LINE__, __FILE__, "\x0f", result_type::SUCCESS ); - verify_rule< uint8::mask_not_range< 0xff, 0x10, 0x2f > >( __LINE__, __FILE__, "\x0f\x0f", result_type::SUCCESS, 1 ); - verify_rule< uint8::mask_not_range< 0xff, 0x10, 0x2f > >( __LINE__, __FILE__, "\x30", result_type::SUCCESS ); - verify_rule< uint8::mask_not_range< 0xff, 0x10, 0x2f > >( __LINE__, __FILE__, "\x30\x30", result_type::SUCCESS, 1 ); - verify_rule< uint8::mask_not_range< 0xff, 0x10, 0x2f > >( __LINE__, __FILE__, "\x10", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_not_range< 0xff, 0x10, 0x2f > >( __LINE__, __FILE__, "\x10\x10", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_not_range< 0xff, 0x10, 0x2f > >( __LINE__, __FILE__, "\x2f", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_not_range< 0xff, 0x10, 0x2f > >( __LINE__, __FILE__, "\x2f\x2f", result_type::LOCAL_FAILURE ); - - verify_rule< uint8::mask_not_range< 0xf0, 0x10, 0x30 > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_not_range< 0xf0, 0x10, 0x30 > >( __LINE__, __FILE__, "\x0f", result_type::SUCCESS ); - verify_rule< uint8::mask_not_range< 0xf0, 0x10, 0x30 > >( __LINE__, __FILE__, "\x0f\x0f", result_type::SUCCESS, 1 ); - verify_rule< uint8::mask_not_range< 0xf0, 0x10, 0x30 > >( __LINE__, __FILE__, "\x40", result_type::SUCCESS ); - verify_rule< uint8::mask_not_range< 0xf0, 0x10, 0x30 > >( __LINE__, __FILE__, "\x40\x40", result_type::SUCCESS, 1 ); - verify_rule< uint8::mask_not_range< 0xf0, 0x10, 0x30 > >( __LINE__, __FILE__, "\x30", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_not_range< 0xf0, 0x10, 0x30 > >( __LINE__, __FILE__, "\x30\x30", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_not_range< 0xf0, 0x10, 0x30 > >( __LINE__, __FILE__, "\x31", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_not_range< 0xf0, 0x10, 0x30 > >( __LINE__, __FILE__, "\x31\x31", result_type::LOCAL_FAILURE ); - - verify_rule< uint8::mask_one< 0xff, 0x10, 0x40 > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_one< 0xff, 0x10, 0x40 > >( __LINE__, __FILE__, "\x10", result_type::SUCCESS ); - verify_rule< uint8::mask_one< 0xff, 0x10, 0x40 > >( __LINE__, __FILE__, "\x10\x10", result_type::SUCCESS, 1 ); - verify_rule< uint8::mask_one< 0xff, 0x10, 0x40 > >( __LINE__, __FILE__, "\x40", result_type::SUCCESS ); - verify_rule< uint8::mask_one< 0xff, 0x10, 0x40 > >( __LINE__, __FILE__, "\x40\x40", result_type::SUCCESS, 1 ); - verify_rule< uint8::mask_one< 0xff, 0x10, 0x40 > >( __LINE__, __FILE__, "\x20", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_one< 0xff, 0x10, 0x40 > >( __LINE__, __FILE__, "\x20\x20", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_one< 0xff, 0x10, 0x40 > >( __LINE__, __FILE__, "\x11", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_one< 0xff, 0x10, 0x40 > >( __LINE__, __FILE__, "\x11\x10", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_one< 0xff, 0x10, 0x40 > >( __LINE__, __FILE__, "\x3f", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_one< 0xff, 0x10, 0x40 > >( __LINE__, __FILE__, "\x3f\x10", result_type::LOCAL_FAILURE ); - - verify_rule< uint8::mask_one< 0x1f, 0x10, 0x14 > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_one< 0x1f, 0x10, 0x14 > >( __LINE__, __FILE__, "\x10", result_type::SUCCESS ); - verify_rule< uint8::mask_one< 0x1f, 0x10, 0x14 > >( __LINE__, __FILE__, "\x10\x10", result_type::SUCCESS, 1 ); - verify_rule< uint8::mask_one< 0x1f, 0x10, 0x14 > >( __LINE__, __FILE__, "\xf0", result_type::SUCCESS ); - verify_rule< uint8::mask_one< 0x1f, 0x10, 0x14 > >( __LINE__, __FILE__, "\xf0\x10", result_type::SUCCESS, 1 ); - verify_rule< uint8::mask_one< 0x1f, 0x10, 0x14 > >( __LINE__, __FILE__, "\x54", result_type::SUCCESS ); - verify_rule< uint8::mask_one< 0x1f, 0x10, 0x14 > >( __LINE__, __FILE__, "\x54\x54", result_type::SUCCESS, 1 ); - verify_rule< uint8::mask_one< 0x1f, 0x10, 0x40 > >( __LINE__, __FILE__, "\x11", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_one< 0x1f, 0x10, 0x40 > >( __LINE__, __FILE__, "\x11\x10", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_one< 0x1f, 0x10, 0x40 > >( __LINE__, __FILE__, "\x3f", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_one< 0x1f, 0x10, 0x40 > >( __LINE__, __FILE__, "\x3f\x10", result_type::LOCAL_FAILURE ); - - verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "\x01", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "\x16", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "\x16\x17", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "\x17", result_type::SUCCESS ); - verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "\x17\x17", result_type::SUCCESS, 1 ); - verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "\x27", result_type::SUCCESS ); - verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "\x27\x17", result_type::SUCCESS, 1 ); - verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "\x28", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "\x28\x17", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "\x7f", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "\xff", result_type::LOCAL_FAILURE ); - - verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x01", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x91", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x16", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x16\x17", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x96", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x96\x17", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x17", result_type::SUCCESS ); - verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x17\x17", result_type::SUCCESS, 1 ); - verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x57", result_type::SUCCESS ); - verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x57\x17", result_type::SUCCESS, 1 ); - verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x27", result_type::SUCCESS ); - verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x27\x17", result_type::SUCCESS, 1 ); - verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x67", result_type::SUCCESS ); - verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x67\x17", result_type::SUCCESS, 1 ); - verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x28", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x28\x17", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x68", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x68\x17", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x7f", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\xff", result_type::LOCAL_FAILURE ); - - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\x01", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\x0f", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\x18", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\x3f", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\x48", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\x94", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\x10", result_type::SUCCESS ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\x17", result_type::SUCCESS ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\x40", result_type::SUCCESS ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\x47", result_type::SUCCESS ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\xf0", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\xf1", result_type::LOCAL_FAILURE ); - - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\x01", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\x0f", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\x18", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\x3f", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\x48", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\x94", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\x10", result_type::SUCCESS ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\x17", result_type::SUCCESS ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\x40", result_type::SUCCESS ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\x47", result_type::SUCCESS ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\xf0", result_type::SUCCESS ); - verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\xf1", result_type::LOCAL_FAILURE ); - - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41 > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41 > >( __LINE__, __FILE__, "\x01", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41 > >( __LINE__, __FILE__, "\x0f", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41 > >( __LINE__, __FILE__, "\x18", result_type::SUCCESS ); - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41 > >( __LINE__, __FILE__, "\x3f", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41 > >( __LINE__, __FILE__, "\x48", result_type::SUCCESS ); - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41 > >( __LINE__, __FILE__, "\x94", result_type::SUCCESS ); - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41 > >( __LINE__, __FILE__, "\x10", result_type::SUCCESS ); - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41 > >( __LINE__, __FILE__, "\x11", result_type::SUCCESS ); - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41 > >( __LINE__, __FILE__, "\x40", result_type::SUCCESS ); - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41 > >( __LINE__, __FILE__, "\x47", result_type::LOCAL_FAILURE ); - - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x01", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x0f", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x18", result_type::SUCCESS ); - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x3f", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x48", result_type::SUCCESS ); - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x94", result_type::SUCCESS ); - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x10", result_type::SUCCESS ); - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x11", result_type::SUCCESS ); - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x40", result_type::SUCCESS ); - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x47", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x73", result_type::SUCCESS ); - verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x72", result_type::LOCAL_FAILURE ); - - verify_rule< uint8::mask_string< 0xf0, 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_string< 0xf0, 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x10", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_string< 0xf0, 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x10\x20", result_type::LOCAL_FAILURE ); - verify_rule< uint8::mask_string< 0xf0, 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x10\x20\x30", result_type::SUCCESS ); - verify_rule< uint8::mask_string< 0xf0, 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x10\x20\x30\x10", result_type::SUCCESS, 1 ); - verify_rule< uint8::mask_string< 0xf0, 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x11\x22\x33", result_type::SUCCESS ); - verify_rule< uint8::mask_string< 0xf0, 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x1f\x2f\x3f", result_type::SUCCESS ); - - verify_rule< uint8::not_one< 0x10, 0x20 > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< uint8::not_one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x10", result_type::LOCAL_FAILURE ); - verify_rule< uint8::not_one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x20", result_type::LOCAL_FAILURE ); - verify_rule< uint8::not_one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x20\x02", result_type::LOCAL_FAILURE ); - verify_rule< uint8::not_one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x02", result_type::SUCCESS ); - verify_rule< uint8::not_one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x02\x20", result_type::SUCCESS, 1 ); - verify_rule< uint8::not_one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x11", result_type::SUCCESS ); - verify_rule< uint8::not_one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x1f", result_type::SUCCESS ); - - verify_rule< uint8::not_range< 0x10, 0x20 > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< uint8::not_range< 0x10, 0x20 > >( __LINE__, __FILE__, "\x0f", result_type::SUCCESS ); - verify_rule< uint8::not_range< 0x10, 0x20 > >( __LINE__, __FILE__, "\x21", result_type::SUCCESS ); - verify_rule< uint8::not_range< 0x10, 0x20 > >( __LINE__, __FILE__, "\x10", result_type::LOCAL_FAILURE ); - verify_rule< uint8::not_range< 0x10, 0x20 > >( __LINE__, __FILE__, "\x17", result_type::LOCAL_FAILURE ); - verify_rule< uint8::not_range< 0x10, 0x20 > >( __LINE__, __FILE__, "\x20", result_type::LOCAL_FAILURE ); - verify_rule< uint8::not_range< 0x10, 0x20 > >( __LINE__, __FILE__, "\xab", result_type::SUCCESS ); - - verify_rule< uint8::one< 0x10, 0x20 > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< uint8::one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x0f", result_type::LOCAL_FAILURE ); - verify_rule< uint8::one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x21", result_type::LOCAL_FAILURE ); - verify_rule< uint8::one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x10", result_type::SUCCESS ); - verify_rule< uint8::one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x17", result_type::LOCAL_FAILURE ); - verify_rule< uint8::one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x20", result_type::SUCCESS ); - - verify_rule< uint8::range< 0x10, 0x20 > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< uint8::range< 0x10, 0x20 > >( __LINE__, __FILE__, "\x0f", result_type::LOCAL_FAILURE ); - verify_rule< uint8::range< 0x10, 0x20 > >( __LINE__, __FILE__, "\x21", result_type::LOCAL_FAILURE ); - verify_rule< uint8::range< 0x10, 0x20 > >( __LINE__, __FILE__, "\x10", result_type::SUCCESS ); - verify_rule< uint8::range< 0x10, 0x20 > >( __LINE__, __FILE__, "\x17", result_type::SUCCESS ); - verify_rule< uint8::range< 0x10, 0x20 > >( __LINE__, __FILE__, "\x20", result_type::SUCCESS ); - verify_rule< uint8::range< 0x10, 0x20 > >( __LINE__, __FILE__, "\xab", result_type::LOCAL_FAILURE ); - - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x0f", result_type::LOCAL_FAILURE ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x21", result_type::LOCAL_FAILURE ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x2f", result_type::LOCAL_FAILURE ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x41", result_type::LOCAL_FAILURE ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x8f", result_type::LOCAL_FAILURE ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x10", result_type::SUCCESS ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x16", result_type::SUCCESS ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x1f", result_type::SUCCESS ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x20", result_type::SUCCESS ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x30", result_type::SUCCESS ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x36", result_type::SUCCESS ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x3f", result_type::SUCCESS ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x40", result_type::SUCCESS ); - - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x0f", result_type::LOCAL_FAILURE ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x21", result_type::LOCAL_FAILURE ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x2f", result_type::LOCAL_FAILURE ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x41", result_type::LOCAL_FAILURE ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x8f", result_type::SUCCESS ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x10", result_type::SUCCESS ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x16", result_type::SUCCESS ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x1f", result_type::SUCCESS ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x20", result_type::SUCCESS ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x30", result_type::SUCCESS ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x36", result_type::SUCCESS ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x3f", result_type::SUCCESS ); - verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x40", result_type::SUCCESS ); - - verify_rule< uint8::string< 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE ); - verify_rule< uint8::string< 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x10", result_type::LOCAL_FAILURE ); - verify_rule< uint8::string< 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x10\x20", result_type::LOCAL_FAILURE ); - verify_rule< uint8::string< 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x10\x20\x30", result_type::SUCCESS ); - verify_rule< uint8::string< 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x10\x20\x30\x10", result_type::SUCCESS, 1 ); - verify_rule< uint8::string< 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x11\x22\x33", result_type::LOCAL_FAILURE ); - verify_rule< uint8::string< 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x1f\x21\x31", result_type::LOCAL_FAILURE ); - } - - } // namespace TAO_PEGTL_NAMESPACE + verify_rule< uint8::any >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); -} // namespace tao + for( int i = -100; i < 200; ++i ) { + verify_char< uint8::any >( __LINE__, __FILE__, char( i ), true ); + } + verify_rule< uint8::mask_not_one< 0xff, 0x01, 0x02 > >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< uint8::mask_not_one< 0xff, 0x01, 0x02 > >( __LINE__, __FILE__, "\x03", result_type::success ); + verify_rule< uint8::mask_not_one< 0xff, 0x01, 0x02 > >( __LINE__, __FILE__, "\x03\x01", result_type::success, 1 ); + verify_rule< uint8::mask_not_one< 0xff, 0x01, 0x10 > >( __LINE__, __FILE__, "\x01", result_type::local_failure ); + verify_rule< uint8::mask_not_one< 0xff, 0x01, 0x10 > >( __LINE__, __FILE__, "\x01\x01", result_type::local_failure ); + + verify_rule< uint8::mask_not_one< 0xf0, 0x01, 0x02 > >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< uint8::mask_not_one< 0xf0, 0x01, 0x02 > >( __LINE__, __FILE__, "\x03", result_type::success ); + verify_rule< uint8::mask_not_one< 0xf0, 0x01, 0x02 > >( __LINE__, __FILE__, "\x03\x01", result_type::success, 1 ); + verify_rule< uint8::mask_not_one< 0xf0, 0x01, 0x10 > >( __LINE__, __FILE__, "\x01", result_type::success ); + verify_rule< uint8::mask_not_one< 0xf0, 0x01, 0x10 > >( __LINE__, __FILE__, "\x01\x01", result_type::success, 1 ); + verify_rule< uint8::mask_not_one< 0xf0, 0x01, 0x10 > >( __LINE__, __FILE__, "\x31", result_type::success ); + verify_rule< uint8::mask_not_one< 0xf0, 0x01, 0x10 > >( __LINE__, __FILE__, "\x31\x01", result_type::success, 1 ); + verify_rule< uint8::mask_not_one< 0xf0, 0x01, 0x10 > >( __LINE__, __FILE__, "\x11", result_type::local_failure ); + verify_rule< uint8::mask_not_one< 0xf0, 0x01, 0x10 > >( __LINE__, __FILE__, "\x11\x01", result_type::local_failure ); + + verify_rule< uint8::mask_not_range< 0xff, 0x10, 0x2f > >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< uint8::mask_not_range< 0xff, 0x10, 0x2f > >( __LINE__, __FILE__, "\x0f", result_type::success ); + verify_rule< uint8::mask_not_range< 0xff, 0x10, 0x2f > >( __LINE__, __FILE__, "\x0f\x0f", result_type::success, 1 ); + verify_rule< uint8::mask_not_range< 0xff, 0x10, 0x2f > >( __LINE__, __FILE__, "\x30", result_type::success ); + verify_rule< uint8::mask_not_range< 0xff, 0x10, 0x2f > >( __LINE__, __FILE__, "\x30\x30", result_type::success, 1 ); + verify_rule< uint8::mask_not_range< 0xff, 0x10, 0x2f > >( __LINE__, __FILE__, "\x10", result_type::local_failure ); + verify_rule< uint8::mask_not_range< 0xff, 0x10, 0x2f > >( __LINE__, __FILE__, "\x10\x10", result_type::local_failure ); + verify_rule< uint8::mask_not_range< 0xff, 0x10, 0x2f > >( __LINE__, __FILE__, "\x2f", result_type::local_failure ); + verify_rule< uint8::mask_not_range< 0xff, 0x10, 0x2f > >( __LINE__, __FILE__, "\x2f\x2f", result_type::local_failure ); + + verify_rule< uint8::mask_not_range< 0xf0, 0x10, 0x30 > >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< uint8::mask_not_range< 0xf0, 0x10, 0x30 > >( __LINE__, __FILE__, "\x0f", result_type::success ); + verify_rule< uint8::mask_not_range< 0xf0, 0x10, 0x30 > >( __LINE__, __FILE__, "\x0f\x0f", result_type::success, 1 ); + verify_rule< uint8::mask_not_range< 0xf0, 0x10, 0x30 > >( __LINE__, __FILE__, "\x40", result_type::success ); + verify_rule< uint8::mask_not_range< 0xf0, 0x10, 0x30 > >( __LINE__, __FILE__, "\x40\x40", result_type::success, 1 ); + verify_rule< uint8::mask_not_range< 0xf0, 0x10, 0x30 > >( __LINE__, __FILE__, "\x30", result_type::local_failure ); + verify_rule< uint8::mask_not_range< 0xf0, 0x10, 0x30 > >( __LINE__, __FILE__, "\x30\x30", result_type::local_failure ); + verify_rule< uint8::mask_not_range< 0xf0, 0x10, 0x30 > >( __LINE__, __FILE__, "\x31", result_type::local_failure ); + verify_rule< uint8::mask_not_range< 0xf0, 0x10, 0x30 > >( __LINE__, __FILE__, "\x31\x31", result_type::local_failure ); + + verify_rule< uint8::mask_one< 0xff, 0x10, 0x40 > >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< uint8::mask_one< 0xff, 0x10, 0x40 > >( __LINE__, __FILE__, "\x10", result_type::success ); + verify_rule< uint8::mask_one< 0xff, 0x10, 0x40 > >( __LINE__, __FILE__, "\x10\x10", result_type::success, 1 ); + verify_rule< uint8::mask_one< 0xff, 0x10, 0x40 > >( __LINE__, __FILE__, "\x40", result_type::success ); + verify_rule< uint8::mask_one< 0xff, 0x10, 0x40 > >( __LINE__, __FILE__, "\x40\x40", result_type::success, 1 ); + verify_rule< uint8::mask_one< 0xff, 0x10, 0x40 > >( __LINE__, __FILE__, "\x20", result_type::local_failure ); + verify_rule< uint8::mask_one< 0xff, 0x10, 0x40 > >( __LINE__, __FILE__, "\x20\x20", result_type::local_failure ); + verify_rule< uint8::mask_one< 0xff, 0x10, 0x40 > >( __LINE__, __FILE__, "\x11", result_type::local_failure ); + verify_rule< uint8::mask_one< 0xff, 0x10, 0x40 > >( __LINE__, __FILE__, "\x11\x10", result_type::local_failure ); + verify_rule< uint8::mask_one< 0xff, 0x10, 0x40 > >( __LINE__, __FILE__, "\x3f", result_type::local_failure ); + verify_rule< uint8::mask_one< 0xff, 0x10, 0x40 > >( __LINE__, __FILE__, "\x3f\x10", result_type::local_failure ); + + verify_rule< uint8::mask_one< 0x1f, 0x10, 0x14 > >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< uint8::mask_one< 0x1f, 0x10, 0x14 > >( __LINE__, __FILE__, "\x10", result_type::success ); + verify_rule< uint8::mask_one< 0x1f, 0x10, 0x14 > >( __LINE__, __FILE__, "\x10\x10", result_type::success, 1 ); + verify_rule< uint8::mask_one< 0x1f, 0x10, 0x14 > >( __LINE__, __FILE__, "\xf0", result_type::success ); + verify_rule< uint8::mask_one< 0x1f, 0x10, 0x14 > >( __LINE__, __FILE__, "\xf0\x10", result_type::success, 1 ); + verify_rule< uint8::mask_one< 0x1f, 0x10, 0x14 > >( __LINE__, __FILE__, "\x54", result_type::success ); + verify_rule< uint8::mask_one< 0x1f, 0x10, 0x14 > >( __LINE__, __FILE__, "\x54\x54", result_type::success, 1 ); + verify_rule< uint8::mask_one< 0x1f, 0x10, 0x40 > >( __LINE__, __FILE__, "\x11", result_type::local_failure ); + verify_rule< uint8::mask_one< 0x1f, 0x10, 0x40 > >( __LINE__, __FILE__, "\x11\x10", result_type::local_failure ); + verify_rule< uint8::mask_one< 0x1f, 0x10, 0x40 > >( __LINE__, __FILE__, "\x3f", result_type::local_failure ); + verify_rule< uint8::mask_one< 0x1f, 0x10, 0x40 > >( __LINE__, __FILE__, "\x3f\x10", result_type::local_failure ); + + verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "\x01", result_type::local_failure ); + verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "\x16", result_type::local_failure ); + verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "\x16\x17", result_type::local_failure ); + verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "\x17", result_type::success ); + verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "\x17\x17", result_type::success, 1 ); + verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "\x27", result_type::success ); + verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "\x27\x17", result_type::success, 1 ); + verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "\x28", result_type::local_failure ); + verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "\x28\x17", result_type::local_failure ); + verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "\x7f", result_type::local_failure ); + verify_rule< uint8::mask_range< 0xff, 0x17, 0x27 > >( __LINE__, __FILE__, "\xff", result_type::local_failure ); + + verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x01", result_type::local_failure ); + verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x91", result_type::local_failure ); + verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x16", result_type::local_failure ); + verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x16\x17", result_type::local_failure ); + verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x96", result_type::local_failure ); + verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x96\x17", result_type::local_failure ); + verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x17", result_type::success ); + verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x17\x17", result_type::success, 1 ); + verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x57", result_type::success ); + verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x57\x17", result_type::success, 1 ); + verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x27", result_type::success ); + verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x27\x17", result_type::success, 1 ); + verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x67", result_type::success ); + verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x67\x17", result_type::success, 1 ); + verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x28", result_type::local_failure ); + verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x28\x17", result_type::local_failure ); + verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x68", result_type::local_failure ); + verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x68\x17", result_type::local_failure ); + verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\x7f", result_type::local_failure ); + verify_rule< uint8::mask_range< 0xbf, 0x17, 0x27 > >( __LINE__, __FILE__, "\xff", result_type::local_failure ); + + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\x01", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\x0f", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\x18", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\x3f", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\x48", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\x94", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\x10", result_type::success ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\x17", result_type::success ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\x40", result_type::success ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\x47", result_type::success ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\xf0", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47 > >( __LINE__, __FILE__, "\xf1", result_type::local_failure ); + + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\x01", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\x0f", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\x18", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\x3f", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\x48", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\x94", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\x10", result_type::success ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\x17", result_type::success ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\x40", result_type::success ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\x47", result_type::success ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\xf0", result_type::success ); + verify_rule< uint8::mask_ranges< 0xff, 0x10, 0x17, 0x40, 0x47, 0xf0 > >( __LINE__, __FILE__, "\xf1", result_type::local_failure ); + + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41 > >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41 > >( __LINE__, __FILE__, "\x01", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41 > >( __LINE__, __FILE__, "\x0f", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41 > >( __LINE__, __FILE__, "\x18", result_type::success ); + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41 > >( __LINE__, __FILE__, "\x3f", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41 > >( __LINE__, __FILE__, "\x48", result_type::success ); + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41 > >( __LINE__, __FILE__, "\x94", result_type::success ); + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41 > >( __LINE__, __FILE__, "\x10", result_type::success ); + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41 > >( __LINE__, __FILE__, "\x11", result_type::success ); + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41 > >( __LINE__, __FILE__, "\x40", result_type::success ); + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41 > >( __LINE__, __FILE__, "\x47", result_type::local_failure ); + + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x01", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x0f", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x18", result_type::success ); + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x3f", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x48", result_type::success ); + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x94", result_type::success ); + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x10", result_type::success ); + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x11", result_type::success ); + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x40", result_type::success ); + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x47", result_type::local_failure ); + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x73", result_type::success ); + verify_rule< uint8::mask_ranges< 0x73, 0x10, 0x11, 0x40, 0x41, 0x73 > >( __LINE__, __FILE__, "\x72", result_type::local_failure ); + + verify_rule< uint8::mask_string< 0xf0, 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< uint8::mask_string< 0xf0, 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x10", result_type::local_failure ); + verify_rule< uint8::mask_string< 0xf0, 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x10\x20", result_type::local_failure ); + verify_rule< uint8::mask_string< 0xf0, 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x10\x20\x30", result_type::success ); + verify_rule< uint8::mask_string< 0xf0, 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x10\x20\x30\x10", result_type::success, 1 ); + verify_rule< uint8::mask_string< 0xf0, 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x11\x22\x33", result_type::success ); + verify_rule< uint8::mask_string< 0xf0, 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x1f\x2f\x3f", result_type::success ); + + verify_rule< uint8::not_one< 0x10, 0x20 > >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< uint8::not_one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x10", result_type::local_failure ); + verify_rule< uint8::not_one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x20", result_type::local_failure ); + verify_rule< uint8::not_one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x20\x02", result_type::local_failure ); + verify_rule< uint8::not_one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x02", result_type::success ); + verify_rule< uint8::not_one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x02\x20", result_type::success, 1 ); + verify_rule< uint8::not_one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x11", result_type::success ); + verify_rule< uint8::not_one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x1f", result_type::success ); + + verify_rule< uint8::not_range< 0x10, 0x20 > >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< uint8::not_range< 0x10, 0x20 > >( __LINE__, __FILE__, "\x0f", result_type::success ); + verify_rule< uint8::not_range< 0x10, 0x20 > >( __LINE__, __FILE__, "\x21", result_type::success ); + verify_rule< uint8::not_range< 0x10, 0x20 > >( __LINE__, __FILE__, "\x10", result_type::local_failure ); + verify_rule< uint8::not_range< 0x10, 0x20 > >( __LINE__, __FILE__, "\x17", result_type::local_failure ); + verify_rule< uint8::not_range< 0x10, 0x20 > >( __LINE__, __FILE__, "\x20", result_type::local_failure ); + verify_rule< uint8::not_range< 0x10, 0x20 > >( __LINE__, __FILE__, "\xab", result_type::success ); + + verify_rule< uint8::one< 0x10, 0x20 > >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< uint8::one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x0f", result_type::local_failure ); + verify_rule< uint8::one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x21", result_type::local_failure ); + verify_rule< uint8::one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x10", result_type::success ); + verify_rule< uint8::one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x17", result_type::local_failure ); + verify_rule< uint8::one< 0x10, 0x20 > >( __LINE__, __FILE__, "\x20", result_type::success ); + + verify_rule< uint8::range< 0x10, 0x20 > >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< uint8::range< 0x10, 0x20 > >( __LINE__, __FILE__, "\x0f", result_type::local_failure ); + verify_rule< uint8::range< 0x10, 0x20 > >( __LINE__, __FILE__, "\x21", result_type::local_failure ); + verify_rule< uint8::range< 0x10, 0x20 > >( __LINE__, __FILE__, "\x10", result_type::success ); + verify_rule< uint8::range< 0x10, 0x20 > >( __LINE__, __FILE__, "\x17", result_type::success ); + verify_rule< uint8::range< 0x10, 0x20 > >( __LINE__, __FILE__, "\x20", result_type::success ); + verify_rule< uint8::range< 0x10, 0x20 > >( __LINE__, __FILE__, "\xab", result_type::local_failure ); + + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x0f", result_type::local_failure ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x21", result_type::local_failure ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x2f", result_type::local_failure ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x41", result_type::local_failure ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x8f", result_type::local_failure ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x10", result_type::success ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x16", result_type::success ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x1f", result_type::success ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x20", result_type::success ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x30", result_type::success ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x36", result_type::success ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x3f", result_type::success ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40 > >( __LINE__, __FILE__, "\x40", result_type::success ); + + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x0f", result_type::local_failure ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x21", result_type::local_failure ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x2f", result_type::local_failure ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x41", result_type::local_failure ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x8f", result_type::success ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x10", result_type::success ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x16", result_type::success ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x1f", result_type::success ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x20", result_type::success ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x30", result_type::success ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x36", result_type::success ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x3f", result_type::success ); + verify_rule< uint8::ranges< 0x10, 0x20, 0x30, 0x40, 0x8f > >( __LINE__, __FILE__, "\x40", result_type::success ); + + verify_rule< uint8::string< 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "", result_type::local_failure ); + verify_rule< uint8::string< 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x10", result_type::local_failure ); + verify_rule< uint8::string< 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x10\x20", result_type::local_failure ); + verify_rule< uint8::string< 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x10\x20\x30", result_type::success ); + verify_rule< uint8::string< 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x10\x20\x30\x10", result_type::success, 1 ); + verify_rule< uint8::string< 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x11\x22\x33", result_type::local_failure ); + verify_rule< uint8::string< 0x10, 0x20, 0x30 > >( __LINE__, __FILE__, "\x1f\x21\x31", result_type::local_failure ); + } + +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/utf16_general.cpp b/packages/PEGTL/src/test/pegtl/utf16_general.cpp index 38eb6a18e..1a9521612 100644 --- a/packages/PEGTL/src/test/pegtl/utf16_general.cpp +++ b/packages/PEGTL/src/test/pegtl/utf16_general.cpp @@ -1,157 +1,153 @@ -// Copyright (c) 2015-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace { - namespace + std::string u16s( const char16_t u ) { - std::string u16s( const char16_t u ) - { - return std::string( static_cast< const char* >( static_cast< const void* >( &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( static_cast< const char* >( static_cast< const void* >( &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( static_cast< const char* >( static_cast< const void* >( &u ) ), sizeof( u ) ); - } - - } // namespace - - void test_utf16() - { - verify_rule< utf16::any >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< utf16::any >( __LINE__, __FILE__, "\x01", result_type::LOCAL_FAILURE, 1 ); - verify_rule< utf16::any >( __LINE__, __FILE__, "\xff", result_type::LOCAL_FAILURE, 1 ); - - verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0 ), result_type::SUCCESS, 0 ); - verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 1 ), result_type::SUCCESS, 0 ); - verify_rule< utf16::any >( __LINE__, __FILE__, " ", result_type::SUCCESS, 0 ); - verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0x00ff ), result_type::SUCCESS, 0 ); - verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0x0100 ), result_type::SUCCESS, 0 ); - verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0x0fff ), result_type::SUCCESS, 0 ); - verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0x1000 ), result_type::SUCCESS, 0 ); - verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xd800 ), result_type::LOCAL_FAILURE, 0 ); - verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xd900 ), result_type::LOCAL_FAILURE, 0 ); - verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xde00 ), result_type::LOCAL_FAILURE, 0 ); - verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xfffe ) + " ", result_type::SUCCESS, 1 ); - verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xffff ) + " ", result_type::SUCCESS, 2 ); - - verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xd7ff ) + u16s( 0xdfff ), result_type::SUCCESS, 2 ); - verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xdc00 ) + u16s( 0xdfff ), result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xd800 ) + u16s( 0x0020 ), result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xd800 ) + u16s( 0xff20 ), result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xd800 ) + u16s( 0xdf00 ), result_type::SUCCESS, 0 ); - verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xd800 ) + u16s( 0xdfff ), result_type::SUCCESS, 0 ); - verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xdbff ) + u16s( 0xdc00 ), result_type::SUCCESS, 0 ); - verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xdbff ) + u16s( 0xdfff ), result_type::SUCCESS, 0 ); - - verify_rule< utf16::one< 0x20 > >( __LINE__, __FILE__, u16s( 0x20 ), result_type::SUCCESS, 0 ); - verify_rule< utf16::one< 0x20ac > >( __LINE__, __FILE__, u16s( 0x20ac ), result_type::SUCCESS, 0 ); - verify_rule< utf16::one< 0x10437 > >( __LINE__, __FILE__, u16s( 0xd801 ) + u16s( 0xdc37 ), result_type::SUCCESS, 0 ); - - verify_rule< utf16::bom >( __LINE__, __FILE__, u16s( 0xfeff ), result_type::SUCCESS, 0 ); - verify_rule< utf16::bom >( __LINE__, __FILE__, u16s( 0xfffe ), result_type::LOCAL_FAILURE, 2 ); - - verify_rule< utf16::string< 0x20, 0x20ac, 0x10437 > >( __LINE__, __FILE__, u16s( 0x20 ) + u16s( 0x20ac ) + u16s( 0xd801 ) + u16s( 0xdc37 ) + u16s( 0x20 ), result_type::SUCCESS, 2 ); + return std::string( static_cast< const char* >( static_cast< const void* >( &u ) ), sizeof( u ) ); } - void test_utf16_be() + std::string u16s_be( const char16_t v ) { - verify_rule< utf16_be::any >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< utf16_be::any >( __LINE__, __FILE__, "\x01", result_type::LOCAL_FAILURE, 1 ); - verify_rule< utf16_be::any >( __LINE__, __FILE__, "\xff", result_type::LOCAL_FAILURE, 1 ); - - verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0 ), result_type::SUCCESS, 0 ); - verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 1 ), result_type::SUCCESS, 0 ); - verify_rule< utf16_be::any >( __LINE__, __FILE__, " ", result_type::SUCCESS, 0 ); - verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0x00ff ), result_type::SUCCESS, 0 ); - verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0x0100 ), result_type::SUCCESS, 0 ); - verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0x0fff ), result_type::SUCCESS, 0 ); - verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0x1000 ), result_type::SUCCESS, 0 ); - verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xd800 ), result_type::LOCAL_FAILURE, 0 ); - verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xd900 ), result_type::LOCAL_FAILURE, 0 ); - verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xde00 ), result_type::LOCAL_FAILURE, 0 ); - verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xfffe ) + " ", result_type::SUCCESS, 1 ); - verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xffff ) + " ", result_type::SUCCESS, 2 ); - - verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xd7ff ) + u16s_be( 0xdfff ), result_type::SUCCESS, 2 ); - verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xdc00 ) + u16s_be( 0xdfff ), result_type::LOCAL_FAILURE, 0 ); - verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xd800 ) + u16s_be( 0x0020 ), result_type::LOCAL_FAILURE, 0 ); - verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xd800 ) + u16s_be( 0xff20 ), result_type::LOCAL_FAILURE, 0 ); - verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xd800 ) + u16s_be( 0xdf00 ), result_type::SUCCESS, 0 ); - verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xd800 ) + u16s_be( 0xdfff ), result_type::SUCCESS, 0 ); - verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xdbff ) + u16s_be( 0xdc00 ), result_type::SUCCESS, 0 ); - verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xdbff ) + u16s_be( 0xdfff ), result_type::SUCCESS, 0 ); - - verify_rule< utf16_be::one< 0x20 > >( __LINE__, __FILE__, u16s_be( 0x20 ), result_type::SUCCESS, 0 ); - verify_rule< utf16_be::one< 0x20ac > >( __LINE__, __FILE__, u16s_be( 0x20ac ), result_type::SUCCESS, 0 ); - verify_rule< utf16_be::one< 0x10437 > >( __LINE__, __FILE__, u16s_be( 0xd801 ) + u16s_be( 0xdc37 ), result_type::SUCCESS, 0 ); - - verify_rule< utf16_be::bom >( __LINE__, __FILE__, u16s_be( 0xfeff ), result_type::SUCCESS, 0 ); - verify_rule< utf16_be::bom >( __LINE__, __FILE__, u16s_be( 0xfffe ), result_type::LOCAL_FAILURE, 2 ); - - verify_rule< utf16_be::string< 0x20, 0x20ac, 0x10437 > >( __LINE__, __FILE__, u16s_be( 0x20 ) + u16s_be( 0x20ac ) + u16s_be( 0xd801 ) + u16s_be( 0xdc37 ) + u16s_be( 0x20 ), result_type::SUCCESS, 2 ); + const std::uint16_t u = internal::h_to_be( std::uint16_t( v ) ); + return std::string( static_cast< const char* >( static_cast< const void* >( &u ) ), sizeof( u ) ); } - void test_utf16_le() + std::string u16s_le( const char16_t v ) { - verify_rule< utf16_le::any >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< utf16_le::any >( __LINE__, __FILE__, "\x01", result_type::LOCAL_FAILURE, 1 ); - verify_rule< utf16_le::any >( __LINE__, __FILE__, "\xff", result_type::LOCAL_FAILURE, 1 ); - - verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0 ), result_type::SUCCESS, 0 ); - verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 1 ), result_type::SUCCESS, 0 ); - verify_rule< utf16_le::any >( __LINE__, __FILE__, " ", result_type::SUCCESS, 0 ); - verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0x00ff ), result_type::SUCCESS, 0 ); - verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0x0100 ), result_type::SUCCESS, 0 ); - verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0x0fff ), result_type::SUCCESS, 0 ); - verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0x1000 ), result_type::SUCCESS, 0 ); - verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xd800 ), result_type::LOCAL_FAILURE, 0 ); - verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xd900 ), result_type::LOCAL_FAILURE, 0 ); - verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xde00 ), result_type::LOCAL_FAILURE, 0 ); - verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xfffe ) + " ", result_type::SUCCESS, 1 ); - verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xffff ) + " ", result_type::SUCCESS, 2 ); - - verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xd7ff ) + u16s_le( 0xdfff ), result_type::SUCCESS, 2 ); - verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xdc00 ) + u16s_le( 0xdfff ), result_type::LOCAL_FAILURE, 0 ); - verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xd800 ) + u16s_le( 0x0020 ), result_type::LOCAL_FAILURE, 0 ); - verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xd800 ) + u16s_le( 0xff20 ), result_type::LOCAL_FAILURE, 0 ); - verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xd800 ) + u16s_le( 0xdf00 ), result_type::SUCCESS, 0 ); - verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xd800 ) + u16s_le( 0xdfff ), result_type::SUCCESS, 0 ); - verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xdbff ) + u16s_le( 0xdc00 ), result_type::SUCCESS, 0 ); - verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xdbff ) + u16s_le( 0xdfff ), result_type::SUCCESS, 0 ); - - verify_rule< utf16_le::one< 0x20 > >( __LINE__, __FILE__, u16s_le( 0x20 ), result_type::SUCCESS, 0 ); - verify_rule< utf16_le::one< 0x20ac > >( __LINE__, __FILE__, u16s_le( 0x20ac ), result_type::SUCCESS, 0 ); - verify_rule< utf16_le::one< 0x10437 > >( __LINE__, __FILE__, u16s_le( 0xd801 ) + u16s_le( 0xdc37 ), result_type::SUCCESS, 0 ); - - verify_rule< utf16_le::bom >( __LINE__, __FILE__, u16s_le( 0xfeff ), result_type::SUCCESS, 0 ); - verify_rule< utf16_le::bom >( __LINE__, __FILE__, u16s_le( 0xfffe ), result_type::LOCAL_FAILURE, 2 ); - - verify_rule< utf16_le::string< 0x20, 0x20ac, 0x10437 > >( __LINE__, __FILE__, u16s_le( 0x20 ) + u16s_le( 0x20ac ) + u16s_le( 0xd801 ) + u16s_le( 0xdc37 ) + u16s_le( 0x20 ), result_type::SUCCESS, 2 ); + const std::uint16_t u = internal::h_to_le( std::uint16_t( v ) ); + return std::string( static_cast< const char* >( static_cast< const void* >( &u ) ), sizeof( u ) ); } - void unit_test() - { - test_utf16(); - test_utf16_be(); - test_utf16_le(); - } + } // namespace - } // namespace TAO_PEGTL_NAMESPACE + void test_utf16() + { + verify_rule< utf16::any >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< utf16::any >( __LINE__, __FILE__, "\x01", result_type::local_failure, 1 ); + verify_rule< utf16::any >( __LINE__, __FILE__, "\xff", result_type::local_failure, 1 ); + + verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0 ), result_type::success, 0 ); + verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 1 ), result_type::success, 0 ); + verify_rule< utf16::any >( __LINE__, __FILE__, " ", result_type::success, 0 ); + verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0x00ff ), result_type::success, 0 ); + verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0x0100 ), result_type::success, 0 ); + verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0x0fff ), result_type::success, 0 ); + verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0x1000 ), result_type::success, 0 ); + verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xd800 ), result_type::local_failure, 0 ); + verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xd900 ), result_type::local_failure, 0 ); + verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xde00 ), result_type::local_failure, 0 ); + verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xfffe ) + " ", result_type::success, 1 ); + verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xffff ) + " ", result_type::success, 2 ); + + verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xd7ff ) + u16s( 0xdfff ), result_type::success, 2 ); + verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xdc00 ) + u16s( 0xdfff ), result_type::local_failure, 4 ); + verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xd800 ) + u16s( 0x0020 ), result_type::local_failure, 4 ); + verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xd800 ) + u16s( 0xff20 ), result_type::local_failure, 4 ); + verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xd800 ) + u16s( 0xdf00 ), result_type::success, 0 ); + verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xd800 ) + u16s( 0xdfff ), result_type::success, 0 ); + verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xdbff ) + u16s( 0xdc00 ), result_type::success, 0 ); + verify_rule< utf16::any >( __LINE__, __FILE__, u16s( 0xdbff ) + u16s( 0xdfff ), result_type::success, 0 ); + + verify_rule< utf16::one< 0x20 > >( __LINE__, __FILE__, u16s( 0x20 ), result_type::success, 0 ); + verify_rule< utf16::one< 0x20ac > >( __LINE__, __FILE__, u16s( 0x20ac ), result_type::success, 0 ); + verify_rule< utf16::one< 0x10437 > >( __LINE__, __FILE__, u16s( 0xd801 ) + u16s( 0xdc37 ), result_type::success, 0 ); + + verify_rule< utf16::bom >( __LINE__, __FILE__, u16s( 0xfeff ), result_type::success, 0 ); + verify_rule< utf16::bom >( __LINE__, __FILE__, u16s( 0xfffe ), result_type::local_failure, 2 ); + + verify_rule< utf16::string< 0x20, 0x20ac, 0x10437 > >( __LINE__, __FILE__, u16s( 0x20 ) + u16s( 0x20ac ) + u16s( 0xd801 ) + u16s( 0xdc37 ) + u16s( 0x20 ), result_type::success, 2 ); + } + + void test_utf16_be() + { + verify_rule< utf16_be::any >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< utf16_be::any >( __LINE__, __FILE__, "\x01", result_type::local_failure, 1 ); + verify_rule< utf16_be::any >( __LINE__, __FILE__, "\xff", result_type::local_failure, 1 ); + + verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0 ), result_type::success, 0 ); + verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 1 ), result_type::success, 0 ); + verify_rule< utf16_be::any >( __LINE__, __FILE__, " ", result_type::success, 0 ); + verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0x00ff ), result_type::success, 0 ); + verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0x0100 ), result_type::success, 0 ); + verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0x0fff ), result_type::success, 0 ); + verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0x1000 ), result_type::success, 0 ); + verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xd800 ), result_type::local_failure, 0 ); + verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xd900 ), result_type::local_failure, 0 ); + verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xde00 ), result_type::local_failure, 0 ); + verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xfffe ) + " ", result_type::success, 1 ); + verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xffff ) + " ", result_type::success, 2 ); + + verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xd7ff ) + u16s_be( 0xdfff ), result_type::success, 2 ); + verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xdc00 ) + u16s_be( 0xdfff ), result_type::local_failure, 0 ); + verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xd800 ) + u16s_be( 0x0020 ), result_type::local_failure, 0 ); + verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xd800 ) + u16s_be( 0xff20 ), result_type::local_failure, 0 ); + verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xd800 ) + u16s_be( 0xdf00 ), result_type::success, 0 ); + verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xd800 ) + u16s_be( 0xdfff ), result_type::success, 0 ); + verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xdbff ) + u16s_be( 0xdc00 ), result_type::success, 0 ); + verify_rule< utf16_be::any >( __LINE__, __FILE__, u16s_be( 0xdbff ) + u16s_be( 0xdfff ), result_type::success, 0 ); + + verify_rule< utf16_be::one< 0x20 > >( __LINE__, __FILE__, u16s_be( 0x20 ), result_type::success, 0 ); + verify_rule< utf16_be::one< 0x20ac > >( __LINE__, __FILE__, u16s_be( 0x20ac ), result_type::success, 0 ); + verify_rule< utf16_be::one< 0x10437 > >( __LINE__, __FILE__, u16s_be( 0xd801 ) + u16s_be( 0xdc37 ), result_type::success, 0 ); + + verify_rule< utf16_be::bom >( __LINE__, __FILE__, u16s_be( 0xfeff ), result_type::success, 0 ); + verify_rule< utf16_be::bom >( __LINE__, __FILE__, u16s_be( 0xfffe ), result_type::local_failure, 2 ); + + verify_rule< utf16_be::string< 0x20, 0x20ac, 0x10437 > >( __LINE__, __FILE__, u16s_be( 0x20 ) + u16s_be( 0x20ac ) + u16s_be( 0xd801 ) + u16s_be( 0xdc37 ) + u16s_be( 0x20 ), result_type::success, 2 ); + } + + void test_utf16_le() + { + verify_rule< utf16_le::any >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< utf16_le::any >( __LINE__, __FILE__, "\x01", result_type::local_failure, 1 ); + verify_rule< utf16_le::any >( __LINE__, __FILE__, "\xff", result_type::local_failure, 1 ); + + verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0 ), result_type::success, 0 ); + verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 1 ), result_type::success, 0 ); + verify_rule< utf16_le::any >( __LINE__, __FILE__, " ", result_type::success, 0 ); + verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0x00ff ), result_type::success, 0 ); + verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0x0100 ), result_type::success, 0 ); + verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0x0fff ), result_type::success, 0 ); + verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0x1000 ), result_type::success, 0 ); + verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xd800 ), result_type::local_failure, 0 ); + verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xd900 ), result_type::local_failure, 0 ); + verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xde00 ), result_type::local_failure, 0 ); + verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xfffe ) + " ", result_type::success, 1 ); + verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xffff ) + " ", result_type::success, 2 ); + + verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xd7ff ) + u16s_le( 0xdfff ), result_type::success, 2 ); + verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xdc00 ) + u16s_le( 0xdfff ), result_type::local_failure, 0 ); + verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xd800 ) + u16s_le( 0x0020 ), result_type::local_failure, 0 ); + verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xd800 ) + u16s_le( 0xff20 ), result_type::local_failure, 0 ); + verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xd800 ) + u16s_le( 0xdf00 ), result_type::success, 0 ); + verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xd800 ) + u16s_le( 0xdfff ), result_type::success, 0 ); + verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xdbff ) + u16s_le( 0xdc00 ), result_type::success, 0 ); + verify_rule< utf16_le::any >( __LINE__, __FILE__, u16s_le( 0xdbff ) + u16s_le( 0xdfff ), result_type::success, 0 ); + + verify_rule< utf16_le::one< 0x20 > >( __LINE__, __FILE__, u16s_le( 0x20 ), result_type::success, 0 ); + verify_rule< utf16_le::one< 0x20ac > >( __LINE__, __FILE__, u16s_le( 0x20ac ), result_type::success, 0 ); + verify_rule< utf16_le::one< 0x10437 > >( __LINE__, __FILE__, u16s_le( 0xd801 ) + u16s_le( 0xdc37 ), result_type::success, 0 ); + + verify_rule< utf16_le::bom >( __LINE__, __FILE__, u16s_le( 0xfeff ), result_type::success, 0 ); + verify_rule< utf16_le::bom >( __LINE__, __FILE__, u16s_le( 0xfffe ), result_type::local_failure, 2 ); + + verify_rule< utf16_le::string< 0x20, 0x20ac, 0x10437 > >( __LINE__, __FILE__, u16s_le( 0x20 ) + u16s_le( 0x20ac ) + u16s_le( 0xd801 ) + u16s_le( 0xdc37 ) + u16s_le( 0x20 ), result_type::success, 2 ); + } + + void unit_test() + { + test_utf16(); + test_utf16_be(); + test_utf16_le(); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/utf32_general.cpp b/packages/PEGTL/src/test/pegtl/utf32_general.cpp index f9fc058a9..d00da771d 100644 --- a/packages/PEGTL/src/test/pegtl/utf32_general.cpp +++ b/packages/PEGTL/src/test/pegtl/utf32_general.cpp @@ -1,136 +1,132 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + namespace { - namespace + std::string u32s( const char32_t u ) { - std::string u32s( const char32_t u ) - { - return std::string( static_cast< const char* >( static_cast< const void* >( &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( static_cast< const char* >( static_cast< const void* >( &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( static_cast< const char* >( static_cast< const void* >( &u ) ), sizeof( u ) ); - } - - } // namespace - - void test_utf32() - { - verify_rule< utf32::any >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< utf32::any >( __LINE__, __FILE__, "\xff", result_type::LOCAL_FAILURE, 1 ); - verify_rule< utf32::any >( __LINE__, __FILE__, "\xff\xff", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf32::any >( __LINE__, __FILE__, "\xff\xff\xff", result_type::LOCAL_FAILURE, 3 ); - - verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0 ), result_type::SUCCESS, 0 ); - verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 1 ), result_type::SUCCESS, 0 ); - verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0x00ff ) + " ", result_type::SUCCESS, 1 ); - verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0x0100 ) + " ", result_type::SUCCESS, 2 ); - verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0x0fff ) + " ", result_type::SUCCESS, 3 ); - verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0x1000 ) + " ", result_type::SUCCESS, 4 ); - verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0xd7ff ), result_type::SUCCESS, 0 ); - verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0xe000 ), result_type::SUCCESS, 0 ); - verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0xfffe ), result_type::SUCCESS, 0 ); - verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0xffff ), result_type::SUCCESS, 0 ); - verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0x100000 ), result_type::SUCCESS, 0 ); - verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0x10fffe ), result_type::SUCCESS, 0 ); - verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0x10ffff ), result_type::SUCCESS, 0 ); - - verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0xd800 ), result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0xd900 ), result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0xdc00 ), result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0xdfff ), result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0x110000 ), result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0x110000 ) + u32s( 0 ), result_type::LOCAL_FAILURE, 8 ); - - verify_rule< utf32::one< 0x20 > >( __LINE__, __FILE__, u32s( 0x20 ), result_type::SUCCESS, 0 ); - verify_rule< utf32::one< 0x20ac > >( __LINE__, __FILE__, u32s( 0x20ac ), result_type::SUCCESS, 0 ); - verify_rule< utf32::one< 0x10fedc > >( __LINE__, __FILE__, u32s( 0x10fedc ), result_type::SUCCESS, 0 ); - - verify_rule< utf32::string< 0x20, 0x20ac, 0x10fedc > >( __LINE__, __FILE__, u32s( 0x20 ) + u32s( 0x20ac ) + u32s( 0x10fedc ) + u32s( 0x20 ), result_type::SUCCESS, 4 ); + return std::string( static_cast< const char* >( static_cast< const void* >( &u ) ), sizeof( u ) ); } - void test_utf32_be() + std::string u32s_be( const char32_t v ) { - verify_rule< utf32_be::any >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< utf32_be::any >( __LINE__, __FILE__, "\xff", result_type::LOCAL_FAILURE, 1 ); - verify_rule< utf32_be::any >( __LINE__, __FILE__, "\xff\xff", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf32_be::any >( __LINE__, __FILE__, "\xff\xff\xff", result_type::LOCAL_FAILURE, 3 ); - - verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0 ), result_type::SUCCESS, 0 ); - verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 1 ), result_type::SUCCESS, 0 ); - verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0x00ff ) + " ", result_type::SUCCESS, 1 ); - verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0x0100 ) + " ", result_type::SUCCESS, 2 ); - verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0x0fff ) + " ", result_type::SUCCESS, 3 ); - verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0x1000 ) + " ", result_type::SUCCESS, 4 ); - verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0xfffe ), result_type::SUCCESS, 0 ); - verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0xffff ), result_type::SUCCESS, 0 ); - verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0x100000 ), result_type::SUCCESS, 0 ); - verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0x10fffe ), result_type::SUCCESS, 0 ); - verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0x10ffff ), result_type::SUCCESS, 0 ); - - verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0x110000 ), result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0x110000 ) + u32s_be( 0 ), result_type::LOCAL_FAILURE, 8 ); - - verify_rule< utf32_be::one< 0x20 > >( __LINE__, __FILE__, u32s_be( 0x20 ), result_type::SUCCESS, 0 ); - verify_rule< utf32_be::one< 0x20ac > >( __LINE__, __FILE__, u32s_be( 0x20ac ), result_type::SUCCESS, 0 ); - verify_rule< utf32_be::one< 0x10fedc > >( __LINE__, __FILE__, u32s_be( 0x10fedc ), result_type::SUCCESS, 0 ); - - verify_rule< utf32_be::string< 0x20, 0x20ac, 0x10fedc > >( __LINE__, __FILE__, u32s_be( 0x20 ) + u32s_be( 0x20ac ) + u32s_be( 0x10fedc ) + u32s_be( 0x20 ), result_type::SUCCESS, 4 ); + const std::uint32_t u = internal::h_to_be( std::uint32_t( v ) ); + return std::string( static_cast< const char* >( static_cast< const void* >( &u ) ), sizeof( u ) ); } - void test_utf32_le() + std::string u32s_le( const char32_t v ) { - verify_rule< utf32_le::any >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< utf32_le::any >( __LINE__, __FILE__, "\xff", result_type::LOCAL_FAILURE, 1 ); - verify_rule< utf32_le::any >( __LINE__, __FILE__, "\xff\xff", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf32_le::any >( __LINE__, __FILE__, "\xff\xff\xff", result_type::LOCAL_FAILURE, 3 ); - - verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0 ), result_type::SUCCESS, 0 ); - verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 1 ), result_type::SUCCESS, 0 ); - verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0x00ff ) + " ", result_type::SUCCESS, 1 ); - verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0x0100 ) + " ", result_type::SUCCESS, 2 ); - verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0x0fff ) + " ", result_type::SUCCESS, 3 ); - verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0x1000 ) + " ", result_type::SUCCESS, 4 ); - verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0xfffe ), result_type::SUCCESS, 0 ); - verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0xffff ), result_type::SUCCESS, 0 ); - verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0x100000 ), result_type::SUCCESS, 0 ); - verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0x10fffe ), result_type::SUCCESS, 0 ); - verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0x10ffff ), result_type::SUCCESS, 0 ); - - verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0x110000 ), result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0x110000 ) + u32s_le( 0 ), result_type::LOCAL_FAILURE, 8 ); - - verify_rule< utf32_le::one< 0x20 > >( __LINE__, __FILE__, u32s_le( 0x20 ), result_type::SUCCESS, 0 ); - verify_rule< utf32_le::one< 0x20ac > >( __LINE__, __FILE__, u32s_le( 0x20ac ), result_type::SUCCESS, 0 ); - verify_rule< utf32_le::one< 0x10fedc > >( __LINE__, __FILE__, u32s_le( 0x10fedc ), result_type::SUCCESS, 0 ); - - verify_rule< utf32_le::string< 0x20, 0x20ac, 0x10fedc > >( __LINE__, __FILE__, u32s_le( 0x20 ) + u32s_le( 0x20ac ) + u32s_le( 0x10fedc ) + u32s_le( 0x20 ), result_type::SUCCESS, 4 ); + const std::uint32_t u = internal::h_to_le( std::uint32_t( v ) ); + return std::string( static_cast< const char* >( static_cast< const void* >( &u ) ), sizeof( u ) ); } - void unit_test() - { - test_utf32(); - test_utf32_be(); - test_utf32_le(); - } + } // namespace - } // namespace TAO_PEGTL_NAMESPACE + void test_utf32() + { + verify_rule< utf32::any >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< utf32::any >( __LINE__, __FILE__, "\xff", result_type::local_failure, 1 ); + verify_rule< utf32::any >( __LINE__, __FILE__, "\xff\xff", result_type::local_failure, 2 ); + verify_rule< utf32::any >( __LINE__, __FILE__, "\xff\xff\xff", result_type::local_failure, 3 ); + + verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0 ), result_type::success, 0 ); + verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 1 ), result_type::success, 0 ); + verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0x00ff ) + " ", result_type::success, 1 ); + verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0x0100 ) + " ", result_type::success, 2 ); + verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0x0fff ) + " ", result_type::success, 3 ); + verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0x1000 ) + " ", result_type::success, 4 ); + verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0xd7ff ), result_type::success, 0 ); + verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0xe000 ), result_type::success, 0 ); + verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0xfffe ), result_type::success, 0 ); + verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0xffff ), result_type::success, 0 ); + verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0x100000 ), result_type::success, 0 ); + verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0x10fffe ), result_type::success, 0 ); + verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0x10ffff ), result_type::success, 0 ); + + verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0xd800 ), result_type::local_failure, 4 ); + verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0xd900 ), result_type::local_failure, 4 ); + verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0xdc00 ), result_type::local_failure, 4 ); + verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0xdfff ), result_type::local_failure, 4 ); + verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0x110000 ), result_type::local_failure, 4 ); + verify_rule< utf32::any >( __LINE__, __FILE__, u32s( 0x110000 ) + u32s( 0 ), result_type::local_failure, 8 ); + + verify_rule< utf32::one< 0x20 > >( __LINE__, __FILE__, u32s( 0x20 ), result_type::success, 0 ); + verify_rule< utf32::one< 0x20ac > >( __LINE__, __FILE__, u32s( 0x20ac ), result_type::success, 0 ); + verify_rule< utf32::one< 0x10fedc > >( __LINE__, __FILE__, u32s( 0x10fedc ), result_type::success, 0 ); + + verify_rule< utf32::string< 0x20, 0x20ac, 0x10fedc > >( __LINE__, __FILE__, u32s( 0x20 ) + u32s( 0x20ac ) + u32s( 0x10fedc ) + u32s( 0x20 ), result_type::success, 4 ); + } + + void test_utf32_be() + { + verify_rule< utf32_be::any >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< utf32_be::any >( __LINE__, __FILE__, "\xff", result_type::local_failure, 1 ); + verify_rule< utf32_be::any >( __LINE__, __FILE__, "\xff\xff", result_type::local_failure, 2 ); + verify_rule< utf32_be::any >( __LINE__, __FILE__, "\xff\xff\xff", result_type::local_failure, 3 ); + + verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0 ), result_type::success, 0 ); + verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 1 ), result_type::success, 0 ); + verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0x00ff ) + " ", result_type::success, 1 ); + verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0x0100 ) + " ", result_type::success, 2 ); + verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0x0fff ) + " ", result_type::success, 3 ); + verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0x1000 ) + " ", result_type::success, 4 ); + verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0xfffe ), result_type::success, 0 ); + verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0xffff ), result_type::success, 0 ); + verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0x100000 ), result_type::success, 0 ); + verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0x10fffe ), result_type::success, 0 ); + verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0x10ffff ), result_type::success, 0 ); + + verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0x110000 ), result_type::local_failure, 4 ); + verify_rule< utf32_be::any >( __LINE__, __FILE__, u32s_be( 0x110000 ) + u32s_be( 0 ), result_type::local_failure, 8 ); + + verify_rule< utf32_be::one< 0x20 > >( __LINE__, __FILE__, u32s_be( 0x20 ), result_type::success, 0 ); + verify_rule< utf32_be::one< 0x20ac > >( __LINE__, __FILE__, u32s_be( 0x20ac ), result_type::success, 0 ); + verify_rule< utf32_be::one< 0x10fedc > >( __LINE__, __FILE__, u32s_be( 0x10fedc ), result_type::success, 0 ); + + verify_rule< utf32_be::string< 0x20, 0x20ac, 0x10fedc > >( __LINE__, __FILE__, u32s_be( 0x20 ) + u32s_be( 0x20ac ) + u32s_be( 0x10fedc ) + u32s_be( 0x20 ), result_type::success, 4 ); + } + + void test_utf32_le() + { + verify_rule< utf32_le::any >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< utf32_le::any >( __LINE__, __FILE__, "\xff", result_type::local_failure, 1 ); + verify_rule< utf32_le::any >( __LINE__, __FILE__, "\xff\xff", result_type::local_failure, 2 ); + verify_rule< utf32_le::any >( __LINE__, __FILE__, "\xff\xff\xff", result_type::local_failure, 3 ); + + verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0 ), result_type::success, 0 ); + verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 1 ), result_type::success, 0 ); + verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0x00ff ) + " ", result_type::success, 1 ); + verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0x0100 ) + " ", result_type::success, 2 ); + verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0x0fff ) + " ", result_type::success, 3 ); + verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0x1000 ) + " ", result_type::success, 4 ); + verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0xfffe ), result_type::success, 0 ); + verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0xffff ), result_type::success, 0 ); + verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0x100000 ), result_type::success, 0 ); + verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0x10fffe ), result_type::success, 0 ); + verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0x10ffff ), result_type::success, 0 ); + + verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0x110000 ), result_type::local_failure, 4 ); + verify_rule< utf32_le::any >( __LINE__, __FILE__, u32s_le( 0x110000 ) + u32s_le( 0 ), result_type::local_failure, 8 ); + + verify_rule< utf32_le::one< 0x20 > >( __LINE__, __FILE__, u32s_le( 0x20 ), result_type::success, 0 ); + verify_rule< utf32_le::one< 0x20ac > >( __LINE__, __FILE__, u32s_le( 0x20ac ), result_type::success, 0 ); + verify_rule< utf32_le::one< 0x10fedc > >( __LINE__, __FILE__, u32s_le( 0x10fedc ), result_type::success, 0 ); + + verify_rule< utf32_le::string< 0x20, 0x20ac, 0x10fedc > >( __LINE__, __FILE__, u32s_le( 0x20 ) + u32s_le( 0x20ac ) + u32s_le( 0x10fedc ) + u32s_le( 0x20 ), result_type::success, 4 ); + } + + void unit_test() + { + test_utf32(); + test_utf32_be(); + test_utf32_le(); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/utf8_general.cpp b/packages/PEGTL/src/test/pegtl/utf8_general.cpp index 6d3267e23..fe0f85f41 100644 --- a/packages/PEGTL/src/test/pegtl/utf8_general.cpp +++ b/packages/PEGTL/src/test/pegtl/utf8_general.cpp @@ -1,267 +1,263 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #include "test.hpp" #include "verify_char.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + void unit_test() { - void unit_test() - { - verify_rule< utf8::any >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - - for( int i = -100; i < 200; ++i ) { - verify_char< utf8::any >( __LINE__, __FILE__, char( i ), ( i & 0x80 ) == 0 ); - } - verify_rule< utf8::any >( __LINE__, __FILE__, "\x30", result_type::SUCCESS, 0 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xc2\xa2", result_type::SUCCESS, 0 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xe2\x82\xac", result_type::SUCCESS, 0 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\x90\x8d\x88", result_type::SUCCESS, 0 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\x30\x20", result_type::SUCCESS, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xc2\xa2\x20", result_type::SUCCESS, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xe2\x82\xac\x20", result_type::SUCCESS, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\x90\x8d\x88\x20", result_type::SUCCESS, 1 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xc0", result_type::LOCAL_FAILURE, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf", result_type::LOCAL_FAILURE, 1 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xc0\x01", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xc0\x3c", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xc0\x7f", result_type::LOCAL_FAILURE, 2 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\x01", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\x3c", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\x7f", result_type::LOCAL_FAILURE, 2 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xc0\x01\x81", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xc0\x3c\x81", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xc0\x7f\x81", result_type::LOCAL_FAILURE, 3 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\x01\x81", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\x3c\x81", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\x7f\x81", result_type::LOCAL_FAILURE, 3 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xc3\x81", result_type::SUCCESS, 0 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xc3\x81\x81", result_type::SUCCESS, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xc3\x81\x81\x81", result_type::SUCCESS, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xc3\x81\x81\x81\x81", result_type::SUCCESS, 3 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\x80", result_type::SUCCESS, 0 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\x80\x80", result_type::SUCCESS, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\x80\x80\x80", result_type::SUCCESS, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\x80\x80\x80\x80", result_type::SUCCESS, 3 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\xbf", result_type::SUCCESS, 0 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\xbf\xbf", result_type::SUCCESS, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\xbf\xbf\xbf", result_type::SUCCESS, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\xbf\xbf\xbf\xbf", result_type::SUCCESS, 3 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\xff", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\xff\xff", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\xff\xff\xff", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\xff\xff\xff\xff", result_type::LOCAL_FAILURE, 5 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xe0", result_type::LOCAL_FAILURE, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xe7", result_type::LOCAL_FAILURE, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xef", result_type::LOCAL_FAILURE, 1 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xe0\x0f", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xe7\x0f", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\x0f", result_type::LOCAL_FAILURE, 2 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xe0\x80", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xe7\x80", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\x80", result_type::LOCAL_FAILURE, 2 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xe0\xff", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xe7\xff", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\xff", result_type::LOCAL_FAILURE, 2 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xe0\x80\x80", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xe0\x80\x80\x80", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xe0\xff\xff", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\xff\xff\xff", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\xff\xff", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\xff\xff\xff", result_type::LOCAL_FAILURE, 4 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xe7\x80\x80", result_type::SUCCESS, 0 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xe7\x80\x80\x80", result_type::SUCCESS, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xe7\x80\x80\x80\x80", result_type::SUCCESS, 2 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\xbf\xbf", result_type::SUCCESS, 0 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\xbf\xbf\xbf", result_type::SUCCESS, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\xbf\xbf\xbf\xbf", result_type::SUCCESS, 2 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\x80\xff", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\x80\xff\xff", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\x80\xff\xff\xff", result_type::LOCAL_FAILURE, 5 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\xff\xff", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\xff\xff\xff", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\xff\xff\xff\xff", result_type::LOCAL_FAILURE, 5 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0", result_type::LOCAL_FAILURE, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf7", result_type::LOCAL_FAILURE, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\x80", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf7\x80", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\x80\x80", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf7\x80\x80", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\x80\x80\xff", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf7\x80\x80\xff", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\xc0\x80\x80", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf7\xc0\x80\x80", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\x80\xf0\x80", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf7\x80\xf0\x80", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\x80\x80\x80", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf5\x80\x80\x80", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf6\x80\x80\x80", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf7\x80\x80\x80", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf4\x9f\xbf\xbf", result_type::LOCAL_FAILURE, 4 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf1\x80\x80\x80", result_type::SUCCESS, 0 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf2\x80\x80\x80", result_type::SUCCESS, 0 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf3\x80\x80\x80", result_type::SUCCESS, 0 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf4\x80\x80\x80", result_type::SUCCESS, 0 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\xa0\x80\x80", result_type::SUCCESS, 0 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\x90\x80\x80", result_type::SUCCESS, 0 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf4\x8f\xbf\xbf", result_type::SUCCESS, 0 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf1\x80\x80\x80\x80", result_type::SUCCESS, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf2\x80\x80\x80\x80", result_type::SUCCESS, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf3\x80\x80\x80\x80", result_type::SUCCESS, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf4\x80\x80\x80\x80", result_type::SUCCESS, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\xa0\x80\x80\x80", result_type::SUCCESS, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\x90\x80\x80\x80", result_type::SUCCESS, 1 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xff", result_type::LOCAL_FAILURE, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xff ", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xff ", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xff ", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xff ", result_type::LOCAL_FAILURE, 5 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xff ", result_type::LOCAL_FAILURE, 6 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xff ", result_type::LOCAL_FAILURE, 7 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xff ", result_type::LOCAL_FAILURE, 8 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xff\x80", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xff\x80\x80", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xff\x80\x80\x80", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xff\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 5 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xff\x80\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 6 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xff\x80\x80\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 7 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xff\x80\x80\x80\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 8 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe", result_type::LOCAL_FAILURE, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe ", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe ", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe ", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe ", result_type::LOCAL_FAILURE, 5 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe ", result_type::LOCAL_FAILURE, 6 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe ", result_type::LOCAL_FAILURE, 7 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe ", result_type::LOCAL_FAILURE, 8 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe\x80", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe\x80\x80", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe\x80\x80\x80", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 5 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe\x80\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 6 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe\x80\x80\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 7 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe\x80\x80\x80\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 8 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc", result_type::LOCAL_FAILURE, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc ", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc ", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc ", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc ", result_type::LOCAL_FAILURE, 5 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc ", result_type::LOCAL_FAILURE, 6 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc ", result_type::LOCAL_FAILURE, 7 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc ", result_type::LOCAL_FAILURE, 8 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc\x80", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc\x80\x80", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc\x80\x80\x80", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 5 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc\x80\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 6 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc\x80\x80\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 7 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc\x80\x80\x80\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 8 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8", result_type::LOCAL_FAILURE, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8 ", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8 ", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8 ", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8 ", result_type::LOCAL_FAILURE, 5 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8 ", result_type::LOCAL_FAILURE, 6 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8 ", result_type::LOCAL_FAILURE, 7 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8 ", result_type::LOCAL_FAILURE, 8 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8\x80", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8\x80\x80", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8\x80\x80\x80", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 5 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8\x80\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 6 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8\x80\x80\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 7 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8\x80\x80\x80\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 8 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\x80", result_type::LOCAL_FAILURE, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x80 ", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x80 ", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x80 ", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x80 ", result_type::LOCAL_FAILURE, 5 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x80 ", result_type::LOCAL_FAILURE, 6 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x80 ", result_type::LOCAL_FAILURE, 7 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x80 ", result_type::LOCAL_FAILURE, 8 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x80\x80", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x80\x80\x80", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x80\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 5 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x80\x80\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 6 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x80\x80\x80\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 7 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x80\x80\x80\x80\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 8 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\x81", result_type::LOCAL_FAILURE, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x81 ", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x81 ", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x81 ", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x81 ", result_type::LOCAL_FAILURE, 5 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x81 ", result_type::LOCAL_FAILURE, 6 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x81 ", result_type::LOCAL_FAILURE, 7 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x81 ", result_type::LOCAL_FAILURE, 8 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x81\x80", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x81\x80\x80", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x81\x80\x80\x80", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x81\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 5 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x81\x80\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 6 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x81\x80\x80\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 7 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x81\x80\x80\x80\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 8 ); - - verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f", result_type::LOCAL_FAILURE, 1 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f ", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f ", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f ", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f ", result_type::LOCAL_FAILURE, 5 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f ", result_type::LOCAL_FAILURE, 6 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f ", result_type::LOCAL_FAILURE, 7 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f ", result_type::LOCAL_FAILURE, 8 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f\x80", result_type::LOCAL_FAILURE, 2 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f\x80\x80", result_type::LOCAL_FAILURE, 3 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f\x80\x80\x80", result_type::LOCAL_FAILURE, 4 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 5 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f\x80\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 6 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f\x80\x80\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 7 ); - verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f\x80\x80\x80\x80\x80\x80\x80", result_type::LOCAL_FAILURE, 8 ); - - verify_rule< utf8::one< 0x20 > >( __LINE__, __FILE__, "\x20", result_type::SUCCESS, 0 ); - verify_rule< utf8::one< 0xa2 > >( __LINE__, __FILE__, "\xc2\xa2", result_type::SUCCESS, 0 ); - verify_rule< utf8::one< 0x20ac > >( __LINE__, __FILE__, "\xe2\x82\xac", result_type::SUCCESS, 0 ); - verify_rule< utf8::one< 0x10348 > >( __LINE__, __FILE__, "\xf0\x90\x8d\x88", result_type::SUCCESS, 0 ); - - verify_rule< utf8::bom >( __LINE__, __FILE__, "\xef\xbb\xbf", result_type::SUCCESS, 0 ); - verify_rule< utf8::bom >( __LINE__, __FILE__, "\xef\xbb\xbf ", result_type::SUCCESS, 1 ); - - verify_rule< utf8::string< 0x20, 0xa2, 0x20ac, 0x10348 > >( __LINE__, __FILE__, "\x20\xc2\xa2\xe2\x82\xac\xf0\x90\x8d\x88\x20", result_type::SUCCESS, 1 ); - } - - } // namespace TAO_PEGTL_NAMESPACE + verify_rule< utf8::any >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); -} // namespace tao + for( int i = -100; i < 200; ++i ) { + verify_char< utf8::any >( __LINE__, __FILE__, char( i ), ( i & 0x80 ) == 0 ); + } + verify_rule< utf8::any >( __LINE__, __FILE__, "\x30", result_type::success, 0 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xc2\xa2", result_type::success, 0 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xe2\x82\xac", result_type::success, 0 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\x90\x8d\x88", result_type::success, 0 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\x30\x20", result_type::success, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xc2\xa2\x20", result_type::success, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xe2\x82\xac\x20", result_type::success, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\x90\x8d\x88\x20", result_type::success, 1 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xc0", result_type::local_failure, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf", result_type::local_failure, 1 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xc0\x01", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xc0\x3c", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xc0\x7f", result_type::local_failure, 2 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\x01", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\x3c", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\x7f", result_type::local_failure, 2 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xc0\x01\x81", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xc0\x3c\x81", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xc0\x7f\x81", result_type::local_failure, 3 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\x01\x81", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\x3c\x81", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\x7f\x81", result_type::local_failure, 3 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xc3\x81", result_type::success, 0 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xc3\x81\x81", result_type::success, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xc3\x81\x81\x81", result_type::success, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xc3\x81\x81\x81\x81", result_type::success, 3 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\x80", result_type::success, 0 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\x80\x80", result_type::success, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\x80\x80\x80", result_type::success, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\x80\x80\x80\x80", result_type::success, 3 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\xbf", result_type::success, 0 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\xbf\xbf", result_type::success, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\xbf\xbf\xbf", result_type::success, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\xbf\xbf\xbf\xbf", result_type::success, 3 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\xff", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\xff\xff", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\xff\xff\xff", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xcf\xff\xff\xff\xff", result_type::local_failure, 5 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xe0", result_type::local_failure, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xe7", result_type::local_failure, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xef", result_type::local_failure, 1 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xe0\x0f", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xe7\x0f", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\x0f", result_type::local_failure, 2 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xe0\x80", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xe7\x80", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\x80", result_type::local_failure, 2 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xe0\xff", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xe7\xff", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\xff", result_type::local_failure, 2 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xe0\x80\x80", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xe0\x80\x80\x80", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xe0\xff\xff", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\xff\xff\xff", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\xff\xff", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\xff\xff\xff", result_type::local_failure, 4 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xe7\x80\x80", result_type::success, 0 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xe7\x80\x80\x80", result_type::success, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xe7\x80\x80\x80\x80", result_type::success, 2 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\xbf\xbf", result_type::success, 0 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\xbf\xbf\xbf", result_type::success, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\xbf\xbf\xbf\xbf", result_type::success, 2 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\x80\xff", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\x80\xff\xff", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\x80\xff\xff\xff", result_type::local_failure, 5 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\xff\xff", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\xff\xff\xff", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xef\xff\xff\xff\xff", result_type::local_failure, 5 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0", result_type::local_failure, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf7", result_type::local_failure, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\x80", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf7\x80", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\x80\x80", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf7\x80\x80", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\x80\x80\xff", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf7\x80\x80\xff", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\xc0\x80\x80", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf7\xc0\x80\x80", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\x80\xf0\x80", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf7\x80\xf0\x80", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\x80\x80\x80", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf5\x80\x80\x80", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf6\x80\x80\x80", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf7\x80\x80\x80", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf4\x9f\xbf\xbf", result_type::local_failure, 4 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf1\x80\x80\x80", result_type::success, 0 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf2\x80\x80\x80", result_type::success, 0 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf3\x80\x80\x80", result_type::success, 0 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf4\x80\x80\x80", result_type::success, 0 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\xa0\x80\x80", result_type::success, 0 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\x90\x80\x80", result_type::success, 0 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf4\x8f\xbf\xbf", result_type::success, 0 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf1\x80\x80\x80\x80", result_type::success, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf2\x80\x80\x80\x80", result_type::success, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf3\x80\x80\x80\x80", result_type::success, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf4\x80\x80\x80\x80", result_type::success, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\xa0\x80\x80\x80", result_type::success, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf0\x90\x80\x80\x80", result_type::success, 1 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xff", result_type::local_failure, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xff ", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xff ", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xff ", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xff ", result_type::local_failure, 5 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xff ", result_type::local_failure, 6 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xff ", result_type::local_failure, 7 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xff ", result_type::local_failure, 8 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xff\x80", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xff\x80\x80", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xff\x80\x80\x80", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xff\x80\x80\x80\x80", result_type::local_failure, 5 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xff\x80\x80\x80\x80\x80", result_type::local_failure, 6 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xff\x80\x80\x80\x80\x80\x80", result_type::local_failure, 7 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xff\x80\x80\x80\x80\x80\x80\x80", result_type::local_failure, 8 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe", result_type::local_failure, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe ", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe ", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe ", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe ", result_type::local_failure, 5 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe ", result_type::local_failure, 6 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe ", result_type::local_failure, 7 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe ", result_type::local_failure, 8 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe\x80", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe\x80\x80", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe\x80\x80\x80", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe\x80\x80\x80\x80", result_type::local_failure, 5 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe\x80\x80\x80\x80\x80", result_type::local_failure, 6 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe\x80\x80\x80\x80\x80\x80", result_type::local_failure, 7 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfe\x80\x80\x80\x80\x80\x80\x80", result_type::local_failure, 8 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc", result_type::local_failure, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc ", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc ", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc ", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc ", result_type::local_failure, 5 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc ", result_type::local_failure, 6 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc ", result_type::local_failure, 7 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc ", result_type::local_failure, 8 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc\x80", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc\x80\x80", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc\x80\x80\x80", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc\x80\x80\x80\x80", result_type::local_failure, 5 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc\x80\x80\x80\x80\x80", result_type::local_failure, 6 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc\x80\x80\x80\x80\x80\x80", result_type::local_failure, 7 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xfc\x80\x80\x80\x80\x80\x80\x80", result_type::local_failure, 8 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8", result_type::local_failure, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8 ", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8 ", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8 ", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8 ", result_type::local_failure, 5 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8 ", result_type::local_failure, 6 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8 ", result_type::local_failure, 7 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8 ", result_type::local_failure, 8 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8\x80", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8\x80\x80", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8\x80\x80\x80", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8\x80\x80\x80\x80", result_type::local_failure, 5 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8\x80\x80\x80\x80\x80", result_type::local_failure, 6 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8\x80\x80\x80\x80\x80\x80", result_type::local_failure, 7 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\xf8\x80\x80\x80\x80\x80\x80\x80", result_type::local_failure, 8 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\x80", result_type::local_failure, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x80 ", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x80 ", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x80 ", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x80 ", result_type::local_failure, 5 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x80 ", result_type::local_failure, 6 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x80 ", result_type::local_failure, 7 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x80 ", result_type::local_failure, 8 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x80\x80", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x80\x80\x80", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x80\x80\x80\x80", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x80\x80\x80\x80\x80", result_type::local_failure, 5 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x80\x80\x80\x80\x80\x80", result_type::local_failure, 6 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x80\x80\x80\x80\x80\x80\x80", result_type::local_failure, 7 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x80\x80\x80\x80\x80\x80\x80\x80", result_type::local_failure, 8 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\x81", result_type::local_failure, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x81 ", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x81 ", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x81 ", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x81 ", result_type::local_failure, 5 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x81 ", result_type::local_failure, 6 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x81 ", result_type::local_failure, 7 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x81 ", result_type::local_failure, 8 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x81\x80", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x81\x80\x80", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x81\x80\x80\x80", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x81\x80\x80\x80\x80", result_type::local_failure, 5 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x81\x80\x80\x80\x80\x80", result_type::local_failure, 6 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x81\x80\x80\x80\x80\x80\x80", result_type::local_failure, 7 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x81\x80\x80\x80\x80\x80\x80\x80", result_type::local_failure, 8 ); + + verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f", result_type::local_failure, 1 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f ", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f ", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f ", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f ", result_type::local_failure, 5 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f ", result_type::local_failure, 6 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f ", result_type::local_failure, 7 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f ", result_type::local_failure, 8 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f\x80", result_type::local_failure, 2 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f\x80\x80", result_type::local_failure, 3 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f\x80\x80\x80", result_type::local_failure, 4 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f\x80\x80\x80\x80", result_type::local_failure, 5 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f\x80\x80\x80\x80\x80", result_type::local_failure, 6 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f\x80\x80\x80\x80\x80\x80", result_type::local_failure, 7 ); + verify_rule< utf8::any >( __LINE__, __FILE__, "\x8f\x80\x80\x80\x80\x80\x80\x80", result_type::local_failure, 8 ); + + verify_rule< utf8::one< 0x20 > >( __LINE__, __FILE__, "\x20", result_type::success, 0 ); + verify_rule< utf8::one< 0xa2 > >( __LINE__, __FILE__, "\xc2\xa2", result_type::success, 0 ); + verify_rule< utf8::one< 0x20ac > >( __LINE__, __FILE__, "\xe2\x82\xac", result_type::success, 0 ); + verify_rule< utf8::one< 0x10348 > >( __LINE__, __FILE__, "\xf0\x90\x8d\x88", result_type::success, 0 ); + + verify_rule< utf8::bom >( __LINE__, __FILE__, "\xef\xbb\xbf", result_type::success, 0 ); + verify_rule< utf8::bom >( __LINE__, __FILE__, "\xef\xbb\xbf ", result_type::success, 1 ); + + verify_rule< utf8::string< 0x20, 0xa2, 0x20ac, 0x10348 > >( __LINE__, __FILE__, "\x20\xc2\xa2\xe2\x82\xac\xf0\x90\x8d\x88\x20", result_type::success, 1 ); + } + +} // namespace TAO_PEGTL_NAMESPACE #include "main.hpp" diff --git a/packages/PEGTL/src/test/pegtl/verify_analyze.hpp b/packages/PEGTL/src/test/pegtl/verify_analyze.hpp index 703ce0bba..4787e8aff 100644 --- a/packages/PEGTL/src/test/pegtl/verify_analyze.hpp +++ b/packages/PEGTL/src/test/pegtl/verify_analyze.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_SRC_TEST_PEGTL_VERIFY_ANALYZE_HPP // NOLINT @@ -8,28 +8,24 @@ #include "test.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + template< typename Rule > + void verify_analyze( const unsigned line, const char* file, const bool expect_consume, const bool expect_problems ) { - template< typename Rule > - void verify_analyze( const unsigned line, const char* file, const bool expect_consume, const bool expect_problems ) - { - analysis::analyze_cycles< Rule > a( false ); - - const bool has_problems = ( a.problems() != 0 ); - const bool does_consume = a.template consumes< Rule >(); - - if( has_problems != expect_problems ) { - TAO_PEGTL_TEST_FAILED( "analyze -- problems received/expected [ " << has_problems << " / " << expect_problems << " ]" ); - } - if( does_consume != expect_consume ) { - TAO_PEGTL_TEST_FAILED( "analyze -- consumes received/expected [ " << does_consume << " / " << expect_consume << " ]" ); - } - } + analysis::analyze_cycles< Rule > a( false ); + + const bool has_problems = ( a.problems() != 0 ); + const bool does_consume = a.template consumes< Rule >(); - } // namespace TAO_PEGTL_NAMESPACE + if( has_problems != expect_problems ) { + TAO_PEGTL_TEST_FAILED( "analyze -- problems received/expected [ " << has_problems << " / " << expect_problems << " ]" ); + } + if( does_consume != expect_consume ) { + TAO_PEGTL_TEST_FAILED( "analyze -- consumes received/expected [ " << does_consume << " / " << expect_consume << " ]" ); + } + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/src/test/pegtl/verify_char.hpp b/packages/PEGTL/src/test/pegtl/verify_char.hpp index e81591076..94800209d 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_SRC_TEST_PEGTL_VERIFY_CHAR_HPP // NOLINT @@ -10,24 +10,20 @@ #include "result_type.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + template< typename Rule > + void verify_char( const std::size_t line, const char* file, const char data, const result_type result ) { - template< typename Rule > - void verify_char( const std::size_t line, const char* file, const char data, const result_type result ) - { - verify_rule< Rule >( line, file, std::string( std::size_t( 1 ), data ), result, ( result == result_type::SUCCESS ) ? 0 : 1 ); - } + verify_rule< Rule >( line, file, std::string( std::size_t( 1 ), data ), result, ( result == result_type::success ) ? 0 : 1 ); + } - template< typename Rule > - void verify_char( const std::size_t line, const char* file, const char data, const bool result ) - { - verify_char< Rule >( line, file, data, result ? result_type::SUCCESS : result_type::LOCAL_FAILURE ); - } - - } // namespace TAO_PEGTL_NAMESPACE + template< typename Rule > + void verify_char( const std::size_t line, const char* file, const char data, const bool result ) + { + verify_char< Rule >( line, file, data, result ? result_type::success : result_type::local_failure ); + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/src/test/pegtl/verify_fail.hpp b/packages/PEGTL/src/test/pegtl/verify_fail.hpp index a843b7e6f..4ca68eec1 100644 --- a/packages/PEGTL/src/test/pegtl/verify_fail.hpp +++ b/packages/PEGTL/src/test/pegtl/verify_fail.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2015-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_SRC_TEST_PEGTL_VERIFY_FAIL_HPP // NOLINT @@ -13,24 +13,20 @@ #include "test.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + template< typename Rule, template< typename > class Action = nothing, typename... States > + void verify_fail( const std::size_t line, const char* file, const std::string& s, States&&... st ) { - template< typename Rule, template< typename > class Action = nothing, typename... States > - void verify_fail( const std::size_t line, const char* file, const std::string& s, States&&... st ) - { - try { - memory_input<> in( s, "expect exception" ); - parse< Rule, Action >( in, st... ); - TAO_PEGTL_TEST_FAILED( "expected exception" ); - } - catch( ... ) { - } + try { + memory_input in( s, "expect exception" ); + parse< Rule, Action >( in, st... ); + TAO_PEGTL_TEST_FAILED( "expected exception" ); } + catch( ... ) { + } + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/src/test/pegtl/verify_file.hpp b/packages/PEGTL/src/test/pegtl/verify_file.hpp index ad581503c..3b3d4ad42 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_SRC_TEST_PEGTL_VERIFY_FILE_HPP // NOLINT @@ -8,152 +8,143 @@ #include "test.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE - { - struct file_content : seq< TAO_PEGTL_STRING( "dummy content" ), eol, discard > - { - }; + struct file_content : seq< TAO_PEGTL_STRING( "dummy content" ), eol, discard > + {}; - struct file_grammar : seq< rep_min_max< 11, 11, file_content >, eof > - { - }; + struct file_grammar : seq< rep_min_max< 11, 11, file_content >, eof > + {}; - template< typename Rule > - struct file_action - : nothing< Rule > - { - }; + template< typename Rule > + struct file_action + {}; - template<> - struct file_action< eof > + template<> + struct file_action< eof > + { + static void apply0( bool& flag ) { - static void apply0( bool& flag ) - { - flag = true; - } - }; + flag = true; + } + }; - template< typename Rule > - struct file_control - : normal< Rule > - { - }; + template< typename Rule > + struct file_control + : normal< Rule > + {}; - template<> - struct file_control< eof > - : normal< eof > + template<> + struct file_control< eof > + : normal< eof > + { + template< typename Input > + static void success( const Input& /*unused*/, bool& flag ) { - template< typename Input > - static void success( const Input& /*unused*/, bool& flag ) - { - flag = true; - } - }; + flag = true; + } + }; - template< typename T > - void verify_file() + template< typename T > + void verify_file() + { { - { - const std::string f{ "src/test/pegtl/no_such_file.txt" }; - try { - T in( f ); - parse< file_grammar >( in ); - TAO_PEGTL_TEST_ASSERT( !"no error on opening non-existing file" ); - } - catch( const input_error& ) { - } - } - { - const std::string f{ "src/test/pegtl/file_data.txt" }; + const std::string f{ "src/test/pegtl/no_such_file.txt" }; + try { T in( f ); - std::cout << in.source() << std::endl; - TAO_PEGTL_TEST_ASSERT( in.source() == f ); - TAO_PEGTL_TEST_ASSERT( parse< file_grammar >( in ) ); - TAO_PEGTL_TEST_ASSERT( in.source() == f ); + parse< file_grammar >( in ); + TAO_PEGTL_TEST_ASSERT( !"no error on opening non-existing file" ); } - { - const std::string f{ "src/test/pegtl/file_data.txt" }; - T in( f ); - bool flag = true; - TAO_PEGTL_TEST_ASSERT( in.source() == f ); - TAO_PEGTL_TEST_ASSERT( parse< file_grammar >( in, flag ) ); - TAO_PEGTL_TEST_ASSERT( flag == true ); - } - { - const std::string f{ "src/test/pegtl/file_data.txt" }; - T in( f ); - bool flag = false; - TAO_PEGTL_TEST_ASSERT( in.source() == f ); - TAO_PEGTL_TEST_ASSERT( parse< file_grammar >( in, flag ) ); - TAO_PEGTL_TEST_ASSERT( flag == false ); - } - { - const std::string f{ "src/test/pegtl/file_data.txt" }; - T in( f ); - bool flag = false; - TAO_PEGTL_TEST_ASSERT( in.source() == f ); - const bool result = parse< file_grammar, file_action >( in, flag ); - TAO_PEGTL_TEST_ASSERT( result ); - TAO_PEGTL_TEST_ASSERT( flag == true ); - } - { - const std::string f{ "src/test/pegtl/file_data.txt" }; - T in( f ); - bool flag = false; - TAO_PEGTL_TEST_ASSERT( in.source() == f ); - const bool result = parse< file_grammar, nothing, file_control >( in, flag ); - TAO_PEGTL_TEST_ASSERT( result ); - TAO_PEGTL_TEST_ASSERT( flag == true ); - } - const char* foo = "foo"; - const memory_input<> m( foo, foo + 3, foo ); - { - const std::string f{ "src/test/pegtl/file_data.txt" }; - T in( f ); - TAO_PEGTL_TEST_ASSERT( in.source() == f ); - TAO_PEGTL_TEST_ASSERT( parse_nested< file_grammar >( m, in ) ); - TAO_PEGTL_TEST_ASSERT( in.source() == f ); - } - { - const std::string f{ "src/test/pegtl/file_data.txt" }; - T in( f ); - bool flag = true; - TAO_PEGTL_TEST_ASSERT( in.source() == f ); - TAO_PEGTL_TEST_ASSERT( parse_nested< file_grammar >( m, in, flag ) ); - TAO_PEGTL_TEST_ASSERT( flag == true ); - } - { - const std::string f{ "src/test/pegtl/file_data.txt" }; - T in( f ); - bool flag = false; - TAO_PEGTL_TEST_ASSERT( in.source() == f ); - TAO_PEGTL_TEST_ASSERT( parse_nested< file_grammar >( m, in, flag ) ); - TAO_PEGTL_TEST_ASSERT( flag == false ); - } - { - const std::string f{ "src/test/pegtl/file_data.txt" }; - T in( f ); - bool flag = false; - TAO_PEGTL_TEST_ASSERT( in.source() == f ); - const bool result = parse_nested< file_grammar, file_action >( m, in, flag ); - TAO_PEGTL_TEST_ASSERT( result ); - TAO_PEGTL_TEST_ASSERT( flag == true ); - } - { - const std::string f{ "src/test/pegtl/file_data.txt" }; - T in( f ); - bool flag = false; - TAO_PEGTL_TEST_ASSERT( in.source() == f ); - const bool result = parse_nested< file_grammar, nothing, file_control >( m, in, flag ); - TAO_PEGTL_TEST_ASSERT( result ); - TAO_PEGTL_TEST_ASSERT( flag == true ); + catch( const std::system_error& ) { } } + { + const std::string f{ "src/test/pegtl/file_data.txt" }; + T in( f ); + std::cout << in.source() << std::endl; + TAO_PEGTL_TEST_ASSERT( in.source() == f ); + TAO_PEGTL_TEST_ASSERT( parse< file_grammar >( in ) ); + TAO_PEGTL_TEST_ASSERT( in.source() == f ); + } + { + const std::string f{ "src/test/pegtl/file_data.txt" }; + T in( f ); + bool flag = true; + TAO_PEGTL_TEST_ASSERT( in.source() == f ); + TAO_PEGTL_TEST_ASSERT( parse< file_grammar >( in, flag ) ); + TAO_PEGTL_TEST_ASSERT( flag == true ); + } + { + const std::string f{ "src/test/pegtl/file_data.txt" }; + T in( f ); + bool flag = false; + TAO_PEGTL_TEST_ASSERT( in.source() == f ); + TAO_PEGTL_TEST_ASSERT( parse< file_grammar >( in, flag ) ); + TAO_PEGTL_TEST_ASSERT( flag == false ); + } + { + const std::string f{ "src/test/pegtl/file_data.txt" }; + T in( f ); + bool flag = false; + TAO_PEGTL_TEST_ASSERT( in.source() == f ); + const bool result = parse< file_grammar, file_action >( in, flag ); + TAO_PEGTL_TEST_ASSERT( result ); + TAO_PEGTL_TEST_ASSERT( flag == true ); + } + { + const std::string f{ "src/test/pegtl/file_data.txt" }; + T in( f ); + bool flag = false; + TAO_PEGTL_TEST_ASSERT( in.source() == f ); + const bool result = parse< file_grammar, nothing, file_control >( in, flag ); + TAO_PEGTL_TEST_ASSERT( result ); + TAO_PEGTL_TEST_ASSERT( flag == true ); + } + const char* foo = "foo"; + const memory_input m( foo, foo + 3, foo ); + { + const std::string f{ "src/test/pegtl/file_data.txt" }; + T in( f ); + TAO_PEGTL_TEST_ASSERT( in.source() == f ); + TAO_PEGTL_TEST_ASSERT( parse_nested< file_grammar >( m, in ) ); + TAO_PEGTL_TEST_ASSERT( in.source() == f ); + } + { + const std::string f{ "src/test/pegtl/file_data.txt" }; + T in( f ); + bool flag = true; + TAO_PEGTL_TEST_ASSERT( in.source() == f ); + TAO_PEGTL_TEST_ASSERT( parse_nested< file_grammar >( m, in, flag ) ); + TAO_PEGTL_TEST_ASSERT( flag == true ); + } + { + const std::string f{ "src/test/pegtl/file_data.txt" }; + T in( f ); + bool flag = false; + TAO_PEGTL_TEST_ASSERT( in.source() == f ); + TAO_PEGTL_TEST_ASSERT( parse_nested< file_grammar >( m, in, flag ) ); + TAO_PEGTL_TEST_ASSERT( flag == false ); + } + { + const std::string f{ "src/test/pegtl/file_data.txt" }; + T in( f ); + bool flag = false; + TAO_PEGTL_TEST_ASSERT( in.source() == f ); + const bool result = parse_nested< file_grammar, file_action >( m, in, flag ); + TAO_PEGTL_TEST_ASSERT( result ); + TAO_PEGTL_TEST_ASSERT( flag == true ); + } + { + const std::string f{ "src/test/pegtl/file_data.txt" }; + T in( f ); + bool flag = false; + TAO_PEGTL_TEST_ASSERT( in.source() == f ); + const bool result = parse_nested< file_grammar, nothing, file_control >( m, in, flag ); + TAO_PEGTL_TEST_ASSERT( result ); + TAO_PEGTL_TEST_ASSERT( flag == true ); + } + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/src/test/pegtl/verify_ifmt.hpp b/packages/PEGTL/src/test/pegtl/verify_ifmt.hpp index 4b7c265d5..b7ea5e99c 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_SRC_TEST_PEGTL_VERIFY_IFMT_HPP // NOLINT @@ -9,39 +9,35 @@ #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + template< template< typename, typename, typename > class S > + void verify_ifmt( const result_type failure = result_type::local_failure ) { - template< template< typename, typename, typename > class S > - void verify_ifmt( const result_type failure = result_type::LOCAL_FAILURE ) - { - verify_analyze< S< eof, eof, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< S< eof, eof, any > >( __LINE__, __FILE__, false, false ); - verify_analyze< S< eof, any, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< S< eof, any, any > >( __LINE__, __FILE__, true, false ); - verify_analyze< S< any, eof, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< S< any, eof, any > >( __LINE__, __FILE__, true, false ); - verify_analyze< S< any, any, eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< S< any, any, any > >( __LINE__, __FILE__, true, false ); - - verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "", failure, 0 ); - verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "b", failure, 1 ); - verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "c", result_type::SUCCESS, 0 ); - verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "ab", result_type::SUCCESS, 0 ); - verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "ac", failure, 2 ); - - verify_rule< must< S< one< 'a' >, one< 'b' >, one< 'c' > > > >( __LINE__, __FILE__, "", result_type::GLOBAL_FAILURE, 0 ); - verify_rule< must< S< one< 'a' >, one< 'b' >, one< 'c' > > > >( __LINE__, __FILE__, "a", result_type::GLOBAL_FAILURE, 0 ); - verify_rule< must< S< one< 'a' >, one< 'b' >, one< 'c' > > > >( __LINE__, __FILE__, "ac", result_type::GLOBAL_FAILURE, 1 ); - verify_rule< must< S< one< 'a' >, one< 'b' >, one< 'c' > > > >( __LINE__, __FILE__, "b", result_type::GLOBAL_FAILURE, 1 ); - - verify_rule< must< S< one< 'a' >, one< 'b' >, seq< one< 'c' >, one< 'd' > > > > >( __LINE__, __FILE__, "c", result_type::GLOBAL_FAILURE, 0 ); - verify_rule< must< S< one< 'a' >, one< 'b' >, seq< one< 'c' >, one< 'd' > > > > >( __LINE__, __FILE__, "cc", result_type::GLOBAL_FAILURE, 1 ); - } - - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao + verify_analyze< S< eof, eof, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< S< eof, eof, any > >( __LINE__, __FILE__, false, false ); + verify_analyze< S< eof, any, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< S< eof, any, any > >( __LINE__, __FILE__, true, false ); + verify_analyze< S< any, eof, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< S< any, eof, any > >( __LINE__, __FILE__, true, false ); + verify_analyze< S< any, any, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< S< any, any, any > >( __LINE__, __FILE__, true, false ); + + verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "", failure, 0 ); + verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "b", failure, 1 ); + verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "c", result_type::success, 0 ); + verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "ab", result_type::success, 0 ); + verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "ac", failure, 2 ); + + verify_rule< must< S< one< 'a' >, one< 'b' >, one< 'c' > > > >( __LINE__, __FILE__, "", result_type::global_failure, 0 ); + verify_rule< must< S< one< 'a' >, one< 'b' >, one< 'c' > > > >( __LINE__, __FILE__, "a", result_type::global_failure, 0 ); + verify_rule< must< S< one< 'a' >, one< 'b' >, one< 'c' > > > >( __LINE__, __FILE__, "ac", result_type::global_failure, 1 ); + verify_rule< must< S< one< 'a' >, one< 'b' >, one< 'c' > > > >( __LINE__, __FILE__, "b", result_type::global_failure, 1 ); + + verify_rule< must< S< one< 'a' >, one< 'b' >, seq< one< 'c' >, one< 'd' > > > > >( __LINE__, __FILE__, "c", result_type::global_failure, 0 ); + verify_rule< must< S< one< 'a' >, one< 'b' >, seq< one< 'c' >, one< 'd' > > > > >( __LINE__, __FILE__, "cc", result_type::global_failure, 1 ); + } + +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/src/test/pegtl/verify_impl.hpp b/packages/PEGTL/src/test/pegtl/verify_impl.hpp index 255fbe61e..595598406 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_SRC_TEST_PEGTL_VERIFY_IMPL_HPP // NOLINT @@ -16,41 +16,37 @@ #include "result_type.hpp" #include "test.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + template< typename Rule, template< typename... > class Action, typename Input > + result_type verify_impl_two( Input& in ) { - template< typename Rule, template< typename... > class Action, typename Input > - result_type verify_impl_two( Input& in ) - { - try { - if( normal< Rule >::template match< apply_mode::ACTION, rewind_mode::REQUIRED, Action, normal >( in ) ) { - return result_type::SUCCESS; - } - return result_type::LOCAL_FAILURE; - } - catch( const std::exception& ) { - return result_type::GLOBAL_FAILURE; - } - catch( ... ) { - std::cerr << "Code should be unreachable in " << __FUNCTION__ << " (" << __FILE__ << ':' << __LINE__ << ')' << std::endl; - std::abort(); + try { + if( normal< Rule >::template match< apply_mode::action, rewind_mode::required, Action, normal >( in ) ) { + return result_type::success; } + return result_type::local_failure; + } + catch( const std::exception& ) { + return result_type::global_failure; + } + catch( ... ) { + std::cerr << "Code should be unreachable in " << __FUNCTION__ << " (" << __FILE__ << ':' << __LINE__ << ')' << std::endl; + std::abort(); } + } - template< typename Rule, template< typename... > class Action, typename Input > - void verify_impl_one( const std::size_t line, const char* file, const std::string& data, Input& in, const result_type expected, const std::size_t remain ) - { - const result_type received = verify_impl_two< Rule, Action >( in ); + template< typename Rule, template< typename... > class Action, typename Input > + void verify_impl_one( const std::size_t line, const char* file, const std::string& data, Input& in, const result_type expected, const std::size_t remain ) + { + const result_type received = verify_impl_two< Rule, Action >( in ); - if( ( received == expected ) && ( ( received == result_type::GLOBAL_FAILURE ) || ( in.size( 999999999 ) == remain ) ) ) { - return; - } - TAO_PEGTL_TEST_FAILED( "input data [ '" << data << "' ] result received/expected [ " << received << " / " << expected << " ] remain received/expected [ " << in.size( 999999999 ) << " / " << remain << " ]" ); + if( ( received == expected ) && ( ( received == result_type::global_failure ) || ( in.size( 999999999 ) == remain ) ) ) { + return; } + TAO_PEGTL_TEST_FAILED( "input data [ '" << data << "' ] result received/expected [ " << received << " / " << expected << " ] remain received/expected [ " << in.size( 999999999 ) << " / " << remain << " ]" ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/src/test/pegtl/verify_rule.hpp b/packages/PEGTL/src/test/pegtl/verify_rule.hpp index 522cc2a75..a6a8ef4a8 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_SRC_TEST_PEGTL_VERIFY_RULE_HPP // NOLINT @@ -14,71 +14,67 @@ #include "result_type.hpp" #include "verify_impl.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + template< typename Rule > + struct verify_action_impl { - template< typename Rule > - struct verify_action_impl + template< typename Input, typename... States > + static void apply( const Input& /*unused*/, States&&... /*unused*/ ) { - template< typename Input, typename... States > - static void apply( const Input& /*unused*/, States&&... /*unused*/ ) - { - } - }; + } + }; - template< typename Rule > - struct verify_action_impl0 + template< typename Rule > + struct verify_action_impl0 + { + template< typename... States > + static void apply0( States&&... /*unused*/ ) { - template< typename... States > - static void apply0( States&&... /*unused*/ ) - { - } - }; + } + }; - template< typename Rule, typename Eol = eol::lf_crlf > - void verify_rule( const std::size_t line, const char* file, const std::string& data, const result_type expected, std::size_t remain = 0 ) + template< typename Rule, typename Eol = eol::lf_crlf > + void verify_rule( const std::size_t line, const char* file, const std::string& data, const result_type expected, std::size_t remain = 0 ) + { + remain = ( expected == result_type::success ) ? remain : data.size(); { - remain = ( expected == result_type::SUCCESS ) ? remain : data.size(); - { - memory_input< tracking_mode::IMMEDIATE, Eol > in( data.data(), data.data() + data.size(), file, 0, line, 0 ); - verify_impl_one< Rule, nothing >( line, file, data, in, expected, remain ); - memory_input< tracking_mode::LAZY, Eol > i2( data.data(), data.data() + data.size(), file ); - verify_impl_one< Rule, nothing >( line, file, data, i2, expected, remain ); - } - { - memory_input< tracking_mode::IMMEDIATE, Eol > in( data.data(), data.data() + data.size(), file, 0, line, 0 ); - verify_impl_one< Rule, verify_action_impl >( line, file, data, in, expected, remain ); - memory_input< tracking_mode::LAZY, Eol > i2( data.data(), data.data() + data.size(), file ); - verify_impl_one< Rule, verify_action_impl >( line, file, data, i2, expected, remain ); - } - { - memory_input< tracking_mode::IMMEDIATE, Eol > in( data.data(), data.data() + data.size(), file, 0, line, 0 ); - verify_impl_one< Rule, verify_action_impl0 >( line, file, data, in, expected, remain ); - memory_input< tracking_mode::LAZY, Eol > i2( data.data(), data.data() + data.size(), file ); - verify_impl_one< Rule, verify_action_impl0 >( line, file, data, i2, expected, remain ); - } + memory_input< tracking_mode::eager, Eol > in( data.data(), data.data() + data.size(), file, 0, line, 0 ); + verify_impl_one< Rule, nothing >( line, file, data, in, expected, remain ); + memory_input< tracking_mode::lazy, Eol > i2( data.data(), data.data() + data.size(), file ); + verify_impl_one< Rule, nothing >( line, file, data, i2, expected, remain ); + } + { + memory_input< tracking_mode::eager, Eol > in( data.data(), data.data() + data.size(), file, 0, line, 0 ); + verify_impl_one< Rule, verify_action_impl >( line, file, data, in, expected, remain ); + memory_input< tracking_mode::lazy, Eol > i2( data.data(), data.data() + data.size(), file ); + verify_impl_one< Rule, verify_action_impl >( line, file, data, i2, expected, remain ); } - - template< typename Rule, typename Eol = eol::lf_crlf > - void verify_only( const std::size_t line, const char* file, const std::string& data, const result_type expected, const std::size_t remain ) { - { - memory_input< tracking_mode::IMMEDIATE, Eol > in( data.data(), data.data() + data.size(), file, 0, line, 0 ); - verify_impl_one< Rule, nothing >( line, file, data, in, expected, remain ); - } - { - memory_input< tracking_mode::IMMEDIATE, Eol > in( data.data(), data.data() + data.size(), file, 0, line, 0 ); - verify_impl_one< Rule, verify_action_impl >( line, file, data, in, expected, remain ); - } - { - memory_input< tracking_mode::IMMEDIATE, Eol > in( data.data(), data.data() + data.size(), file, 0, line, 0 ); - verify_impl_one< Rule, verify_action_impl0 >( line, file, data, in, expected, remain ); - } + memory_input< tracking_mode::eager, Eol > in( data.data(), data.data() + data.size(), file, 0, line, 0 ); + verify_impl_one< Rule, verify_action_impl0 >( line, file, data, in, expected, remain ); + memory_input< tracking_mode::lazy, Eol > i2( data.data(), data.data() + data.size(), file ); + verify_impl_one< Rule, verify_action_impl0 >( line, file, data, i2, expected, remain ); } + } - } // namespace TAO_PEGTL_NAMESPACE + template< typename Rule, typename Eol = eol::lf_crlf > + void verify_only( const std::size_t line, const char* file, const std::string& data, const result_type expected, const std::size_t remain ) + { + { + memory_input< tracking_mode::eager, Eol > in( data.data(), data.data() + data.size(), file, 0, line, 0 ); + verify_impl_one< Rule, nothing >( line, file, data, in, expected, remain ); + } + { + memory_input< tracking_mode::eager, Eol > in( data.data(), data.data() + data.size(), file, 0, line, 0 ); + verify_impl_one< Rule, verify_action_impl >( line, file, data, in, expected, remain ); + } + { + memory_input< tracking_mode::eager, Eol > in( data.data(), data.data() + data.size(), file, 0, line, 0 ); + verify_impl_one< Rule, verify_action_impl0 >( line, file, data, in, expected, remain ); + } + } -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif diff --git a/packages/PEGTL/src/test/pegtl/verify_seqs.hpp b/packages/PEGTL/src/test/pegtl/verify_seqs.hpp index 70b7e39c3..1de8bcf44 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-2018 Dr. Colin Hirsch and Daniel Frey +// Copyright (c) 2014-2019 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_PEGTL_SRC_TEST_PEGTL_VERIFY_SEQS_HPP // NOLINT @@ -9,63 +9,59 @@ #include "verify_analyze.hpp" #include "verify_rule.hpp" -namespace tao +namespace TAO_PEGTL_NAMESPACE { - namespace TAO_PEGTL_NAMESPACE + template< template< typename... > class S > + void verify_seqs( const result_type failure = result_type::local_failure ) { - template< template< typename... > class S > - void verify_seqs( const result_type failure = result_type::LOCAL_FAILURE ) - { - verify_analyze< S< any > >( __LINE__, __FILE__, true, false ); - verify_analyze< S< eof > >( __LINE__, __FILE__, false, false ); - verify_analyze< S< any, eof > >( __LINE__, __FILE__, true, false ); - verify_analyze< S< opt< any >, eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< S< any > >( __LINE__, __FILE__, true, false ); + verify_analyze< S< eof > >( __LINE__, __FILE__, false, false ); + verify_analyze< S< any, eof > >( __LINE__, __FILE__, true, false ); + verify_analyze< S< opt< any >, eof > >( __LINE__, __FILE__, false, false ); - verify_rule< S<> >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - verify_rule< S<> >( __LINE__, __FILE__, "a", result_type::SUCCESS, 1 ); + verify_rule< S<> >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< S<> >( __LINE__, __FILE__, "a", result_type::success, 1 ); - verify_rule< S< eof > >( __LINE__, __FILE__, "", result_type::SUCCESS, 0 ); - verify_rule< S< eof > >( __LINE__, __FILE__, "a", failure, 1 ); - verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "", failure, 0 ); - verify_rule< S< one< 'c' >, eof > >( __LINE__, __FILE__, "", failure, 0 ); - verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "c", result_type::SUCCESS, 0 ); - verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "a", failure, 1 ); - verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "b", failure, 1 ); - verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "cc", result_type::SUCCESS, 1 ); - verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "bc", failure, 2 ); - verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", failure, 0 ); - verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", failure, 1 ); - verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "b", failure, 1 ); - verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "c", failure, 1 ); - verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::SUCCESS, 0 ); - verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aba", result_type::SUCCESS, 1 ); - verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abb", result_type::SUCCESS, 1 ); - verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abc", result_type::SUCCESS, 1 ); - verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abab", result_type::SUCCESS, 2 ); - verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "", failure, 0 ); - verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "a", failure, 1 ); - verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "ab", failure, 2 ); - verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "abc", result_type::SUCCESS, 0 ); - verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' >, eof > >( __LINE__, __FILE__, "abc", result_type::SUCCESS, 0 ); - verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "abcd", result_type::SUCCESS, 1 ); + verify_rule< S< eof > >( __LINE__, __FILE__, "", result_type::success, 0 ); + verify_rule< S< eof > >( __LINE__, __FILE__, "a", failure, 1 ); + verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "", failure, 0 ); + verify_rule< S< one< 'c' >, eof > >( __LINE__, __FILE__, "", failure, 0 ); + verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "c", result_type::success, 0 ); + verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "a", failure, 1 ); + verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "b", failure, 1 ); + verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "cc", result_type::success, 1 ); + verify_rule< S< one< 'c' > > >( __LINE__, __FILE__, "bc", failure, 2 ); + verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "", failure, 0 ); + verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "a", failure, 1 ); + verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "b", failure, 1 ); + verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "c", failure, 1 ); + verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "ab", result_type::success, 0 ); + verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "aba", result_type::success, 1 ); + verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abb", result_type::success, 1 ); + verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abc", result_type::success, 1 ); + verify_rule< S< one< 'a' >, one< 'b' > > >( __LINE__, __FILE__, "abab", result_type::success, 2 ); + verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "", failure, 0 ); + verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "a", failure, 1 ); + verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "ab", failure, 2 ); + verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "abc", result_type::success, 0 ); + verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' >, eof > >( __LINE__, __FILE__, "abc", result_type::success, 0 ); + verify_rule< S< one< 'a' >, one< 'b' >, one< 'c' > > >( __LINE__, __FILE__, "abcd", result_type::success, 1 ); - verify_rule< must< S< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "", result_type::GLOBAL_FAILURE, 0 ); - verify_rule< must< S< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "a", result_type::GLOBAL_FAILURE, 0 ); - verify_rule< must< S< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "b", result_type::GLOBAL_FAILURE, 1 ); - verify_rule< must< S< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "c", result_type::GLOBAL_FAILURE, 1 ); - verify_rule< must< S< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "ab", result_type::SUCCESS, 0 ); - verify_rule< must< S< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "aba", result_type::SUCCESS, 1 ); + verify_rule< must< S< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "", result_type::global_failure, 0 ); + verify_rule< must< S< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "a", result_type::global_failure, 0 ); + verify_rule< must< S< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "b", result_type::global_failure, 1 ); + verify_rule< must< S< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "c", result_type::global_failure, 1 ); + verify_rule< must< S< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "ab", result_type::success, 0 ); + verify_rule< must< S< one< 'a' >, one< 'b' > > > >( __LINE__, __FILE__, "aba", result_type::success, 1 ); - verify_rule< try_catch< must< S< one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "", result_type::LOCAL_FAILURE, 0 ); - verify_rule< try_catch< must< S< one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "a", result_type::LOCAL_FAILURE, 1 ); - verify_rule< try_catch< must< S< one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "b", result_type::LOCAL_FAILURE, 1 ); - verify_rule< try_catch< must< S< one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "c", result_type::LOCAL_FAILURE, 1 ); - verify_rule< try_catch< must< S< one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "ab", result_type::SUCCESS, 0 ); - verify_rule< try_catch< must< S< one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "aba", result_type::SUCCESS, 1 ); - } + verify_rule< try_catch< must< S< one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "", result_type::local_failure, 0 ); + verify_rule< try_catch< must< S< one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "a", result_type::local_failure, 1 ); + verify_rule< try_catch< must< S< one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "b", result_type::local_failure, 1 ); + verify_rule< try_catch< must< S< one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "c", result_type::local_failure, 1 ); + verify_rule< try_catch< must< S< one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "ab", result_type::success, 0 ); + verify_rule< try_catch< must< S< one< 'a' >, one< 'b' > > > > >( __LINE__, __FILE__, "aba", result_type::success, 1 ); + } - } // namespace TAO_PEGTL_NAMESPACE - -} // namespace tao +} // namespace TAO_PEGTL_NAMESPACE #endif -- GitLab