From cb906e739f27931e9798510cd83725131ed55209 Mon Sep 17 00:00:00 2001 From: Li Jin <dragon-fly@qq.com> Date: Thu, 13 Jul 2017 16:03:11 +0800 Subject: rewrite parsing codes with parserlib. --- MoonParser.xcodeproj/project.pbxproj | 328 +--- MoonParser/ast.cpp | 68 + MoonParser/ast.hpp | 437 +++++ MoonParser/main.cpp | 2121 ++++++----------------- MoonParser/parser.cpp | 1462 ++++++++++++++++ MoonParser/parser.hpp | 428 +++++ MoonParser/parserlib.hpp | 8 + MoonParser/pegtl.hpp | 31 - MoonParser/pegtl/analysis/analyze_cycles.hpp | 134 -- MoonParser/pegtl/analysis/counted.hpp | 29 - MoonParser/pegtl/analysis/generic.hpp | 39 - MoonParser/pegtl/analysis/grammar_info.hpp | 40 - MoonParser/pegtl/analysis/insert_guard.hpp | 66 - MoonParser/pegtl/analysis/insert_rules.hpp | 45 - MoonParser/pegtl/analysis/rule_info.hpp | 37 - MoonParser/pegtl/analysis/rule_type.hpp | 29 - MoonParser/pegtl/analyze.hpp | 25 - MoonParser/pegtl/apply_mode.hpp | 23 - MoonParser/pegtl/argv_input.hpp | 52 - MoonParser/pegtl/ascii.hpp | 67 - MoonParser/pegtl/buffer_input.hpp | 179 -- MoonParser/pegtl/config.hpp | 15 - MoonParser/pegtl/contrib/abnf.hpp | 43 - MoonParser/pegtl/contrib/alphabet.hpp | 75 - MoonParser/pegtl/contrib/changes.hpp | 86 - MoonParser/pegtl/contrib/counter.hpp | 58 - MoonParser/pegtl/contrib/http.hpp | 152 -- MoonParser/pegtl/contrib/json.hpp | 98 -- MoonParser/pegtl/contrib/raw_string.hpp | 252 --- MoonParser/pegtl/contrib/rep_one_min_max.hpp | 72 - MoonParser/pegtl/contrib/to_string.hpp | 42 - MoonParser/pegtl/contrib/tracer.hpp | 111 -- MoonParser/pegtl/contrib/unescape.hpp | 203 --- MoonParser/pegtl/contrib/uri.hpp | 116 -- MoonParser/pegtl/cstream_input.hpp | 34 - MoonParser/pegtl/eol.hpp | 54 - MoonParser/pegtl/file_input.hpp | 37 - MoonParser/pegtl/input_error.hpp | 41 - MoonParser/pegtl/internal/action.hpp | 52 - MoonParser/pegtl/internal/action_input.hpp | 108 -- MoonParser/pegtl/internal/alnum.hpp | 26 - MoonParser/pegtl/internal/alpha.hpp | 26 - MoonParser/pegtl/internal/any.hpp | 68 - MoonParser/pegtl/internal/apply.hpp | 79 - MoonParser/pegtl/internal/apply0.hpp | 77 - MoonParser/pegtl/internal/at.hpp | 62 - MoonParser/pegtl/internal/bof.hpp | 41 - MoonParser/pegtl/internal/bol.hpp | 41 - MoonParser/pegtl/internal/bump_help.hpp | 64 - MoonParser/pegtl/internal/bump_impl.hpp | 53 - MoonParser/pegtl/internal/bytes.hpp | 46 - MoonParser/pegtl/internal/control.hpp | 52 - MoonParser/pegtl/internal/cr_crlf_eol.hpp | 39 - MoonParser/pegtl/internal/cr_eol.hpp | 39 - MoonParser/pegtl/internal/crlf_eol.hpp | 39 - MoonParser/pegtl/internal/cstream_reader.hpp | 48 - MoonParser/pegtl/internal/cstring_reader.hpp | 49 - MoonParser/pegtl/internal/demangle.hpp | 44 - MoonParser/pegtl/internal/demangle_cxxabi.hpp | 41 - MoonParser/pegtl/internal/demangle_nop.hpp | 28 - MoonParser/pegtl/internal/demangle_sanitise.hpp | 48 - MoonParser/pegtl/internal/disable.hpp | 52 - MoonParser/pegtl/internal/discard.hpp | 42 - MoonParser/pegtl/internal/dusel_mode.hpp | 25 - MoonParser/pegtl/internal/duseltronik.hpp | 114 -- MoonParser/pegtl/internal/enable.hpp | 52 - MoonParser/pegtl/internal/eof.hpp | 41 - MoonParser/pegtl/internal/eol.hpp | 42 - MoonParser/pegtl/internal/eolf.hpp | 43 - MoonParser/pegtl/internal/file_mapper.hpp | 91 - MoonParser/pegtl/internal/file_opener.hpp | 70 - MoonParser/pegtl/internal/file_reader.hpp | 96 - MoonParser/pegtl/internal/has_apply0.hpp | 38 - MoonParser/pegtl/internal/identifier.hpp | 30 - MoonParser/pegtl/internal/if_apply.hpp | 90 - MoonParser/pegtl/internal/if_must.hpp | 27 - MoonParser/pegtl/internal/if_must_else.hpp | 27 - MoonParser/pegtl/internal/if_then_else.hpp | 59 - MoonParser/pegtl/internal/input_pair.hpp | 35 - MoonParser/pegtl/internal/integer_sequence.hpp | 85 - MoonParser/pegtl/internal/istream_reader.hpp | 47 - MoonParser/pegtl/internal/istring.hpp | 107 -- MoonParser/pegtl/internal/iterator.hpp | 53 - MoonParser/pegtl/internal/lf_crlf_eol.hpp | 44 - MoonParser/pegtl/internal/lf_eol.hpp | 39 - MoonParser/pegtl/internal/list.hpp | 27 - MoonParser/pegtl/internal/list_must.hpp | 28 - MoonParser/pegtl/internal/list_tail.hpp | 28 - MoonParser/pegtl/internal/list_tail_pad.hpp | 30 - MoonParser/pegtl/internal/marker.hpp | 93 - MoonParser/pegtl/internal/minus.hpp | 69 - MoonParser/pegtl/internal/must.hpp | 79 - MoonParser/pegtl/internal/not_at.hpp | 62 - MoonParser/pegtl/internal/one.hpp | 81 - MoonParser/pegtl/internal/opt.hpp | 67 - MoonParser/pegtl/internal/pad.hpp | 27 - MoonParser/pegtl/internal/pad_opt.hpp | 28 - MoonParser/pegtl/internal/peek_char.hpp | 35 - MoonParser/pegtl/internal/peek_utf16.hpp | 54 - MoonParser/pegtl/internal/peek_utf32.hpp | 46 - MoonParser/pegtl/internal/peek_utf8.hpp | 88 - MoonParser/pegtl/internal/pegtl_string.hpp | 98 -- MoonParser/pegtl/internal/plus.hpp | 61 - MoonParser/pegtl/internal/raise.hpp | 57 - MoonParser/pegtl/internal/range.hpp | 60 - MoonParser/pegtl/internal/ranges.hpp | 102 -- MoonParser/pegtl/internal/rep.hpp | 75 - MoonParser/pegtl/internal/rep_min.hpp | 28 - MoonParser/pegtl/internal/rep_min_max.hpp | 88 - MoonParser/pegtl/internal/rep_opt.hpp | 54 - MoonParser/pegtl/internal/require.hpp | 52 - MoonParser/pegtl/internal/result_on_found.hpp | 27 - MoonParser/pegtl/internal/rule_conjunction.hpp | 63 - MoonParser/pegtl/internal/rules.hpp | 61 - MoonParser/pegtl/internal/seq.hpp | 80 - MoonParser/pegtl/internal/skip_control.hpp | 35 - MoonParser/pegtl/internal/sor.hpp | 74 - MoonParser/pegtl/internal/star.hpp | 56 - MoonParser/pegtl/internal/star_must.hpp | 27 - MoonParser/pegtl/internal/state.hpp | 83 - MoonParser/pegtl/internal/string.hpp | 68 - MoonParser/pegtl/internal/trivial.hpp | 42 - MoonParser/pegtl/internal/try_catch_type.hpp | 72 - MoonParser/pegtl/internal/until.hpp | 91 - MoonParser/pegtl/istream_input.hpp | 34 - MoonParser/pegtl/memory_input.hpp | 285 --- MoonParser/pegtl/mmap_input.hpp | 55 - MoonParser/pegtl/normal.hpp | 81 - MoonParser/pegtl/nothing.hpp | 27 - MoonParser/pegtl/parse.hpp | 53 - MoonParser/pegtl/parse_error.hpp | 45 - MoonParser/pegtl/position.hpp | 54 - MoonParser/pegtl/read_input.hpp | 52 - MoonParser/pegtl/rewind_mode.hpp | 24 - MoonParser/pegtl/rules.hpp | 69 - MoonParser/pegtl/string_input.hpp | 51 - MoonParser/pegtl/tracking_mode.hpp | 23 - MoonParser/pegtl/utf16.hpp | 35 - MoonParser/pegtl/utf32.hpp | 35 - MoonParser/pegtl/utf8.hpp | 35 - MoonParser/pegtl/version.hpp | 13 - MoonParser/slice.cpp | 119 -- MoonParser/slice.h | 157 -- 143 files changed, 2923 insertions(+), 10276 deletions(-) create mode 100644 MoonParser/ast.cpp create mode 100644 MoonParser/ast.hpp create mode 100644 MoonParser/parser.cpp create mode 100644 MoonParser/parser.hpp create mode 100644 MoonParser/parserlib.hpp delete mode 100644 MoonParser/pegtl.hpp delete mode 100644 MoonParser/pegtl/analysis/analyze_cycles.hpp delete mode 100644 MoonParser/pegtl/analysis/counted.hpp delete mode 100644 MoonParser/pegtl/analysis/generic.hpp delete mode 100644 MoonParser/pegtl/analysis/grammar_info.hpp delete mode 100644 MoonParser/pegtl/analysis/insert_guard.hpp delete mode 100644 MoonParser/pegtl/analysis/insert_rules.hpp delete mode 100644 MoonParser/pegtl/analysis/rule_info.hpp delete mode 100644 MoonParser/pegtl/analysis/rule_type.hpp delete mode 100644 MoonParser/pegtl/analyze.hpp delete mode 100644 MoonParser/pegtl/apply_mode.hpp delete mode 100644 MoonParser/pegtl/argv_input.hpp delete mode 100644 MoonParser/pegtl/ascii.hpp delete mode 100644 MoonParser/pegtl/buffer_input.hpp delete mode 100644 MoonParser/pegtl/config.hpp delete mode 100644 MoonParser/pegtl/contrib/abnf.hpp delete mode 100644 MoonParser/pegtl/contrib/alphabet.hpp delete mode 100644 MoonParser/pegtl/contrib/changes.hpp delete mode 100644 MoonParser/pegtl/contrib/counter.hpp delete mode 100644 MoonParser/pegtl/contrib/http.hpp delete mode 100644 MoonParser/pegtl/contrib/json.hpp delete mode 100644 MoonParser/pegtl/contrib/raw_string.hpp delete mode 100644 MoonParser/pegtl/contrib/rep_one_min_max.hpp delete mode 100644 MoonParser/pegtl/contrib/to_string.hpp delete mode 100644 MoonParser/pegtl/contrib/tracer.hpp delete mode 100644 MoonParser/pegtl/contrib/unescape.hpp delete mode 100644 MoonParser/pegtl/contrib/uri.hpp delete mode 100644 MoonParser/pegtl/cstream_input.hpp delete mode 100644 MoonParser/pegtl/eol.hpp delete mode 100644 MoonParser/pegtl/file_input.hpp delete mode 100644 MoonParser/pegtl/input_error.hpp delete mode 100644 MoonParser/pegtl/internal/action.hpp delete mode 100644 MoonParser/pegtl/internal/action_input.hpp delete mode 100644 MoonParser/pegtl/internal/alnum.hpp delete mode 100644 MoonParser/pegtl/internal/alpha.hpp delete mode 100644 MoonParser/pegtl/internal/any.hpp delete mode 100644 MoonParser/pegtl/internal/apply.hpp delete mode 100644 MoonParser/pegtl/internal/apply0.hpp delete mode 100644 MoonParser/pegtl/internal/at.hpp delete mode 100644 MoonParser/pegtl/internal/bof.hpp delete mode 100644 MoonParser/pegtl/internal/bol.hpp delete mode 100644 MoonParser/pegtl/internal/bump_help.hpp delete mode 100644 MoonParser/pegtl/internal/bump_impl.hpp delete mode 100644 MoonParser/pegtl/internal/bytes.hpp delete mode 100644 MoonParser/pegtl/internal/control.hpp delete mode 100644 MoonParser/pegtl/internal/cr_crlf_eol.hpp delete mode 100644 MoonParser/pegtl/internal/cr_eol.hpp delete mode 100644 MoonParser/pegtl/internal/crlf_eol.hpp delete mode 100644 MoonParser/pegtl/internal/cstream_reader.hpp delete mode 100644 MoonParser/pegtl/internal/cstring_reader.hpp delete mode 100644 MoonParser/pegtl/internal/demangle.hpp delete mode 100644 MoonParser/pegtl/internal/demangle_cxxabi.hpp delete mode 100644 MoonParser/pegtl/internal/demangle_nop.hpp delete mode 100644 MoonParser/pegtl/internal/demangle_sanitise.hpp delete mode 100644 MoonParser/pegtl/internal/disable.hpp delete mode 100644 MoonParser/pegtl/internal/discard.hpp delete mode 100644 MoonParser/pegtl/internal/dusel_mode.hpp delete mode 100644 MoonParser/pegtl/internal/duseltronik.hpp delete mode 100644 MoonParser/pegtl/internal/enable.hpp delete mode 100644 MoonParser/pegtl/internal/eof.hpp delete mode 100644 MoonParser/pegtl/internal/eol.hpp delete mode 100644 MoonParser/pegtl/internal/eolf.hpp delete mode 100644 MoonParser/pegtl/internal/file_mapper.hpp delete mode 100644 MoonParser/pegtl/internal/file_opener.hpp delete mode 100644 MoonParser/pegtl/internal/file_reader.hpp delete mode 100644 MoonParser/pegtl/internal/has_apply0.hpp delete mode 100644 MoonParser/pegtl/internal/identifier.hpp delete mode 100644 MoonParser/pegtl/internal/if_apply.hpp delete mode 100644 MoonParser/pegtl/internal/if_must.hpp delete mode 100644 MoonParser/pegtl/internal/if_must_else.hpp delete mode 100644 MoonParser/pegtl/internal/if_then_else.hpp delete mode 100644 MoonParser/pegtl/internal/input_pair.hpp delete mode 100644 MoonParser/pegtl/internal/integer_sequence.hpp delete mode 100644 MoonParser/pegtl/internal/istream_reader.hpp delete mode 100644 MoonParser/pegtl/internal/istring.hpp delete mode 100644 MoonParser/pegtl/internal/iterator.hpp delete mode 100644 MoonParser/pegtl/internal/lf_crlf_eol.hpp delete mode 100644 MoonParser/pegtl/internal/lf_eol.hpp delete mode 100644 MoonParser/pegtl/internal/list.hpp delete mode 100644 MoonParser/pegtl/internal/list_must.hpp delete mode 100644 MoonParser/pegtl/internal/list_tail.hpp delete mode 100644 MoonParser/pegtl/internal/list_tail_pad.hpp delete mode 100644 MoonParser/pegtl/internal/marker.hpp delete mode 100644 MoonParser/pegtl/internal/minus.hpp delete mode 100644 MoonParser/pegtl/internal/must.hpp delete mode 100644 MoonParser/pegtl/internal/not_at.hpp delete mode 100644 MoonParser/pegtl/internal/one.hpp delete mode 100644 MoonParser/pegtl/internal/opt.hpp delete mode 100644 MoonParser/pegtl/internal/pad.hpp delete mode 100644 MoonParser/pegtl/internal/pad_opt.hpp delete mode 100644 MoonParser/pegtl/internal/peek_char.hpp delete mode 100644 MoonParser/pegtl/internal/peek_utf16.hpp delete mode 100644 MoonParser/pegtl/internal/peek_utf32.hpp delete mode 100644 MoonParser/pegtl/internal/peek_utf8.hpp delete mode 100644 MoonParser/pegtl/internal/pegtl_string.hpp delete mode 100644 MoonParser/pegtl/internal/plus.hpp delete mode 100644 MoonParser/pegtl/internal/raise.hpp delete mode 100644 MoonParser/pegtl/internal/range.hpp delete mode 100644 MoonParser/pegtl/internal/ranges.hpp delete mode 100644 MoonParser/pegtl/internal/rep.hpp delete mode 100644 MoonParser/pegtl/internal/rep_min.hpp delete mode 100644 MoonParser/pegtl/internal/rep_min_max.hpp delete mode 100644 MoonParser/pegtl/internal/rep_opt.hpp delete mode 100644 MoonParser/pegtl/internal/require.hpp delete mode 100644 MoonParser/pegtl/internal/result_on_found.hpp delete mode 100644 MoonParser/pegtl/internal/rule_conjunction.hpp delete mode 100644 MoonParser/pegtl/internal/rules.hpp delete mode 100644 MoonParser/pegtl/internal/seq.hpp delete mode 100644 MoonParser/pegtl/internal/skip_control.hpp delete mode 100644 MoonParser/pegtl/internal/sor.hpp delete mode 100644 MoonParser/pegtl/internal/star.hpp delete mode 100644 MoonParser/pegtl/internal/star_must.hpp delete mode 100644 MoonParser/pegtl/internal/state.hpp delete mode 100644 MoonParser/pegtl/internal/string.hpp delete mode 100644 MoonParser/pegtl/internal/trivial.hpp delete mode 100644 MoonParser/pegtl/internal/try_catch_type.hpp delete mode 100644 MoonParser/pegtl/internal/until.hpp delete mode 100644 MoonParser/pegtl/istream_input.hpp delete mode 100644 MoonParser/pegtl/memory_input.hpp delete mode 100644 MoonParser/pegtl/mmap_input.hpp delete mode 100644 MoonParser/pegtl/normal.hpp delete mode 100644 MoonParser/pegtl/nothing.hpp delete mode 100644 MoonParser/pegtl/parse.hpp delete mode 100644 MoonParser/pegtl/parse_error.hpp delete mode 100644 MoonParser/pegtl/position.hpp delete mode 100644 MoonParser/pegtl/read_input.hpp delete mode 100644 MoonParser/pegtl/rewind_mode.hpp delete mode 100644 MoonParser/pegtl/rules.hpp delete mode 100644 MoonParser/pegtl/string_input.hpp delete mode 100644 MoonParser/pegtl/tracking_mode.hpp delete mode 100644 MoonParser/pegtl/utf16.hpp delete mode 100644 MoonParser/pegtl/utf32.hpp delete mode 100644 MoonParser/pegtl/utf8.hpp delete mode 100644 MoonParser/pegtl/version.hpp delete mode 100644 MoonParser/slice.cpp delete mode 100644 MoonParser/slice.h diff --git a/MoonParser.xcodeproj/project.pbxproj b/MoonParser.xcodeproj/project.pbxproj index 8f027f1..d83e197 100644 --- a/MoonParser.xcodeproj/project.pbxproj +++ b/MoonParser.xcodeproj/project.pbxproj @@ -7,8 +7,9 @@ objects = { /* Begin PBXBuildFile section */ - 3C06322F1F0CBE210089D0AB /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C0631A21F0CBE210089D0AB /* main.cpp */; }; - 3C0632301F0CBE210089D0AB /* slice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C06322D1F0CBE210089D0AB /* slice.cpp */; }; + 3C6FFA331F16F97400541BCA /* ast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C6FFA2D1F16F97400541BCA /* ast.cpp */; }; + 3C6FFA341F16F97400541BCA /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C6FFA2F1F16F97400541BCA /* main.cpp */; }; + 3C6FFA351F16F97400541BCA /* parser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C6FFA301F16F97400541BCA /* parser.cpp */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -24,144 +25,13 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 3C0631A21F0CBE210089D0AB /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; - 3C0631A51F0CBE210089D0AB /* analyze_cycles.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = analyze_cycles.hpp; sourceTree = "<group>"; }; - 3C0631A61F0CBE210089D0AB /* counted.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = counted.hpp; sourceTree = "<group>"; }; - 3C0631A71F0CBE210089D0AB /* generic.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = generic.hpp; sourceTree = "<group>"; }; - 3C0631A81F0CBE210089D0AB /* grammar_info.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = grammar_info.hpp; sourceTree = "<group>"; }; - 3C0631A91F0CBE210089D0AB /* insert_guard.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = insert_guard.hpp; sourceTree = "<group>"; }; - 3C0631AA1F0CBE210089D0AB /* insert_rules.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = insert_rules.hpp; sourceTree = "<group>"; }; - 3C0631AB1F0CBE210089D0AB /* rule_info.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rule_info.hpp; sourceTree = "<group>"; }; - 3C0631AC1F0CBE210089D0AB /* rule_type.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rule_type.hpp; sourceTree = "<group>"; }; - 3C0631AD1F0CBE210089D0AB /* analyze.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = analyze.hpp; sourceTree = "<group>"; }; - 3C0631AE1F0CBE210089D0AB /* apply_mode.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = apply_mode.hpp; sourceTree = "<group>"; }; - 3C0631AF1F0CBE210089D0AB /* argv_input.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = argv_input.hpp; sourceTree = "<group>"; }; - 3C0631B01F0CBE210089D0AB /* ascii.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ascii.hpp; sourceTree = "<group>"; }; - 3C0631B11F0CBE210089D0AB /* buffer_input.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = buffer_input.hpp; sourceTree = "<group>"; }; - 3C0631B21F0CBE210089D0AB /* config.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = config.hpp; sourceTree = "<group>"; }; - 3C0631B41F0CBE210089D0AB /* abnf.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = abnf.hpp; sourceTree = "<group>"; }; - 3C0631B51F0CBE210089D0AB /* alphabet.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = alphabet.hpp; sourceTree = "<group>"; }; - 3C0631B61F0CBE210089D0AB /* changes.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = changes.hpp; sourceTree = "<group>"; }; - 3C0631B71F0CBE210089D0AB /* counter.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = counter.hpp; sourceTree = "<group>"; }; - 3C0631B81F0CBE210089D0AB /* http.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = http.hpp; sourceTree = "<group>"; }; - 3C0631B91F0CBE210089D0AB /* json.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = json.hpp; sourceTree = "<group>"; }; - 3C0631BA1F0CBE210089D0AB /* raw_string.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = raw_string.hpp; sourceTree = "<group>"; }; - 3C0631BB1F0CBE210089D0AB /* rep_one_min_max.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rep_one_min_max.hpp; sourceTree = "<group>"; }; - 3C0631BC1F0CBE210089D0AB /* to_string.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = to_string.hpp; sourceTree = "<group>"; }; - 3C0631BD1F0CBE210089D0AB /* tracer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = tracer.hpp; sourceTree = "<group>"; }; - 3C0631BE1F0CBE210089D0AB /* unescape.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = unescape.hpp; sourceTree = "<group>"; }; - 3C0631BF1F0CBE210089D0AB /* uri.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = uri.hpp; sourceTree = "<group>"; }; - 3C0631C01F0CBE210089D0AB /* cstream_input.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cstream_input.hpp; sourceTree = "<group>"; }; - 3C0631C11F0CBE210089D0AB /* eol.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = eol.hpp; sourceTree = "<group>"; }; - 3C0631C21F0CBE210089D0AB /* file_input.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = file_input.hpp; sourceTree = "<group>"; }; - 3C0631C31F0CBE210089D0AB /* input_error.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = input_error.hpp; sourceTree = "<group>"; }; - 3C0631C51F0CBE210089D0AB /* action.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = action.hpp; sourceTree = "<group>"; }; - 3C0631C61F0CBE210089D0AB /* action_input.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = action_input.hpp; sourceTree = "<group>"; }; - 3C0631C71F0CBE210089D0AB /* alnum.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = alnum.hpp; sourceTree = "<group>"; }; - 3C0631C81F0CBE210089D0AB /* alpha.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = alpha.hpp; sourceTree = "<group>"; }; - 3C0631C91F0CBE210089D0AB /* any.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = any.hpp; sourceTree = "<group>"; }; - 3C0631CA1F0CBE210089D0AB /* apply.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = apply.hpp; sourceTree = "<group>"; }; - 3C0631CB1F0CBE210089D0AB /* apply0.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = apply0.hpp; sourceTree = "<group>"; }; - 3C0631CC1F0CBE210089D0AB /* at.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = at.hpp; sourceTree = "<group>"; }; - 3C0631CD1F0CBE210089D0AB /* bof.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = bof.hpp; sourceTree = "<group>"; }; - 3C0631CE1F0CBE210089D0AB /* bol.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = bol.hpp; sourceTree = "<group>"; }; - 3C0631CF1F0CBE210089D0AB /* bump_help.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = bump_help.hpp; sourceTree = "<group>"; }; - 3C0631D01F0CBE210089D0AB /* bump_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = bump_impl.hpp; sourceTree = "<group>"; }; - 3C0631D11F0CBE210089D0AB /* bytes.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = bytes.hpp; sourceTree = "<group>"; }; - 3C0631D21F0CBE210089D0AB /* control.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = control.hpp; sourceTree = "<group>"; }; - 3C0631D31F0CBE210089D0AB /* cr_crlf_eol.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cr_crlf_eol.hpp; sourceTree = "<group>"; }; - 3C0631D41F0CBE210089D0AB /* cr_eol.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cr_eol.hpp; sourceTree = "<group>"; }; - 3C0631D51F0CBE210089D0AB /* crlf_eol.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = crlf_eol.hpp; sourceTree = "<group>"; }; - 3C0631D61F0CBE210089D0AB /* cstream_reader.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cstream_reader.hpp; sourceTree = "<group>"; }; - 3C0631D71F0CBE210089D0AB /* cstring_reader.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cstring_reader.hpp; sourceTree = "<group>"; }; - 3C0631D81F0CBE210089D0AB /* demangle.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = demangle.hpp; sourceTree = "<group>"; }; - 3C0631D91F0CBE210089D0AB /* demangle_cxxabi.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = demangle_cxxabi.hpp; sourceTree = "<group>"; }; - 3C0631DA1F0CBE210089D0AB /* demangle_nop.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = demangle_nop.hpp; sourceTree = "<group>"; }; - 3C0631DB1F0CBE210089D0AB /* demangle_sanitise.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = demangle_sanitise.hpp; sourceTree = "<group>"; }; - 3C0631DC1F0CBE210089D0AB /* disable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = disable.hpp; sourceTree = "<group>"; }; - 3C0631DD1F0CBE210089D0AB /* discard.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = discard.hpp; sourceTree = "<group>"; }; - 3C0631DE1F0CBE210089D0AB /* dusel_mode.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = dusel_mode.hpp; sourceTree = "<group>"; }; - 3C0631DF1F0CBE210089D0AB /* duseltronik.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = duseltronik.hpp; sourceTree = "<group>"; }; - 3C0631E01F0CBE210089D0AB /* enable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = enable.hpp; sourceTree = "<group>"; }; - 3C0631E11F0CBE210089D0AB /* eof.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = eof.hpp; sourceTree = "<group>"; }; - 3C0631E21F0CBE210089D0AB /* eol.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = eol.hpp; sourceTree = "<group>"; }; - 3C0631E31F0CBE210089D0AB /* eolf.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = eolf.hpp; sourceTree = "<group>"; }; - 3C0631E41F0CBE210089D0AB /* file_mapper.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = file_mapper.hpp; sourceTree = "<group>"; }; - 3C0631E51F0CBE210089D0AB /* file_opener.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = file_opener.hpp; sourceTree = "<group>"; }; - 3C0631E61F0CBE210089D0AB /* file_reader.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = file_reader.hpp; sourceTree = "<group>"; }; - 3C0631E71F0CBE210089D0AB /* has_apply0.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = has_apply0.hpp; sourceTree = "<group>"; }; - 3C0631E81F0CBE210089D0AB /* identifier.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = identifier.hpp; sourceTree = "<group>"; }; - 3C0631E91F0CBE210089D0AB /* if_apply.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = if_apply.hpp; sourceTree = "<group>"; }; - 3C0631EA1F0CBE210089D0AB /* if_must.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = if_must.hpp; sourceTree = "<group>"; }; - 3C0631EB1F0CBE210089D0AB /* if_must_else.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = if_must_else.hpp; sourceTree = "<group>"; }; - 3C0631EC1F0CBE210089D0AB /* if_then_else.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = if_then_else.hpp; sourceTree = "<group>"; }; - 3C0631ED1F0CBE210089D0AB /* input_pair.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = input_pair.hpp; sourceTree = "<group>"; }; - 3C0631EE1F0CBE210089D0AB /* integer_sequence.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = integer_sequence.hpp; sourceTree = "<group>"; }; - 3C0631EF1F0CBE210089D0AB /* istream_reader.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = istream_reader.hpp; sourceTree = "<group>"; }; - 3C0631F01F0CBE210089D0AB /* istring.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = istring.hpp; sourceTree = "<group>"; }; - 3C0631F11F0CBE210089D0AB /* iterator.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = iterator.hpp; sourceTree = "<group>"; }; - 3C0631F21F0CBE210089D0AB /* lf_crlf_eol.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lf_crlf_eol.hpp; sourceTree = "<group>"; }; - 3C0631F31F0CBE210089D0AB /* lf_eol.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lf_eol.hpp; sourceTree = "<group>"; }; - 3C0631F41F0CBE210089D0AB /* list.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = list.hpp; sourceTree = "<group>"; }; - 3C0631F51F0CBE210089D0AB /* list_must.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = list_must.hpp; sourceTree = "<group>"; }; - 3C0631F61F0CBE210089D0AB /* list_tail.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = list_tail.hpp; sourceTree = "<group>"; }; - 3C0631F71F0CBE210089D0AB /* list_tail_pad.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = list_tail_pad.hpp; sourceTree = "<group>"; }; - 3C0631F81F0CBE210089D0AB /* marker.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = marker.hpp; sourceTree = "<group>"; }; - 3C0631F91F0CBE210089D0AB /* minus.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = minus.hpp; sourceTree = "<group>"; }; - 3C0631FA1F0CBE210089D0AB /* must.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = must.hpp; sourceTree = "<group>"; }; - 3C0631FB1F0CBE210089D0AB /* not_at.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = not_at.hpp; sourceTree = "<group>"; }; - 3C0631FC1F0CBE210089D0AB /* one.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = one.hpp; sourceTree = "<group>"; }; - 3C0631FD1F0CBE210089D0AB /* opt.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = opt.hpp; sourceTree = "<group>"; }; - 3C0631FE1F0CBE210089D0AB /* pad.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = pad.hpp; sourceTree = "<group>"; }; - 3C0631FF1F0CBE210089D0AB /* pad_opt.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = pad_opt.hpp; sourceTree = "<group>"; }; - 3C0632001F0CBE210089D0AB /* peek_char.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = peek_char.hpp; sourceTree = "<group>"; }; - 3C0632011F0CBE210089D0AB /* peek_utf16.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = peek_utf16.hpp; sourceTree = "<group>"; }; - 3C0632021F0CBE210089D0AB /* peek_utf32.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = peek_utf32.hpp; sourceTree = "<group>"; }; - 3C0632031F0CBE210089D0AB /* peek_utf8.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = peek_utf8.hpp; sourceTree = "<group>"; }; - 3C0632041F0CBE210089D0AB /* pegtl_string.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = pegtl_string.hpp; sourceTree = "<group>"; }; - 3C0632051F0CBE210089D0AB /* plus.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = plus.hpp; sourceTree = "<group>"; }; - 3C0632061F0CBE210089D0AB /* raise.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = raise.hpp; sourceTree = "<group>"; }; - 3C0632071F0CBE210089D0AB /* range.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = range.hpp; sourceTree = "<group>"; }; - 3C0632081F0CBE210089D0AB /* ranges.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ranges.hpp; sourceTree = "<group>"; }; - 3C0632091F0CBE210089D0AB /* rep.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rep.hpp; sourceTree = "<group>"; }; - 3C06320A1F0CBE210089D0AB /* rep_min.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rep_min.hpp; sourceTree = "<group>"; }; - 3C06320B1F0CBE210089D0AB /* rep_min_max.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rep_min_max.hpp; sourceTree = "<group>"; }; - 3C06320C1F0CBE210089D0AB /* rep_opt.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rep_opt.hpp; sourceTree = "<group>"; }; - 3C06320D1F0CBE210089D0AB /* require.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = require.hpp; sourceTree = "<group>"; }; - 3C06320E1F0CBE210089D0AB /* result_on_found.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = result_on_found.hpp; sourceTree = "<group>"; }; - 3C06320F1F0CBE210089D0AB /* rule_conjunction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rule_conjunction.hpp; sourceTree = "<group>"; }; - 3C0632101F0CBE210089D0AB /* rules.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rules.hpp; sourceTree = "<group>"; }; - 3C0632111F0CBE210089D0AB /* seq.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = seq.hpp; sourceTree = "<group>"; }; - 3C0632121F0CBE210089D0AB /* skip_control.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = skip_control.hpp; sourceTree = "<group>"; }; - 3C0632131F0CBE210089D0AB /* sor.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = sor.hpp; sourceTree = "<group>"; }; - 3C0632141F0CBE210089D0AB /* star.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = star.hpp; sourceTree = "<group>"; }; - 3C0632151F0CBE210089D0AB /* star_must.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = star_must.hpp; sourceTree = "<group>"; }; - 3C0632161F0CBE210089D0AB /* state.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = state.hpp; sourceTree = "<group>"; }; - 3C0632171F0CBE210089D0AB /* string.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = string.hpp; sourceTree = "<group>"; }; - 3C0632181F0CBE210089D0AB /* trivial.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = trivial.hpp; sourceTree = "<group>"; }; - 3C0632191F0CBE210089D0AB /* try_catch_type.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = try_catch_type.hpp; sourceTree = "<group>"; }; - 3C06321A1F0CBE210089D0AB /* until.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = until.hpp; sourceTree = "<group>"; }; - 3C06321B1F0CBE210089D0AB /* istream_input.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = istream_input.hpp; sourceTree = "<group>"; }; - 3C06321C1F0CBE210089D0AB /* memory_input.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = memory_input.hpp; sourceTree = "<group>"; }; - 3C06321D1F0CBE210089D0AB /* mmap_input.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = mmap_input.hpp; sourceTree = "<group>"; }; - 3C06321E1F0CBE210089D0AB /* normal.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = normal.hpp; sourceTree = "<group>"; }; - 3C06321F1F0CBE210089D0AB /* nothing.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = nothing.hpp; sourceTree = "<group>"; }; - 3C0632201F0CBE210089D0AB /* parse.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = parse.hpp; sourceTree = "<group>"; }; - 3C0632211F0CBE210089D0AB /* parse_error.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = parse_error.hpp; sourceTree = "<group>"; }; - 3C0632221F0CBE210089D0AB /* position.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = position.hpp; sourceTree = "<group>"; }; - 3C0632231F0CBE210089D0AB /* read_input.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = read_input.hpp; sourceTree = "<group>"; }; - 3C0632241F0CBE210089D0AB /* rewind_mode.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rewind_mode.hpp; sourceTree = "<group>"; }; - 3C0632251F0CBE210089D0AB /* rules.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rules.hpp; sourceTree = "<group>"; }; - 3C0632261F0CBE210089D0AB /* string_input.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = string_input.hpp; sourceTree = "<group>"; }; - 3C0632271F0CBE210089D0AB /* tracking_mode.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = tracking_mode.hpp; sourceTree = "<group>"; }; - 3C0632281F0CBE210089D0AB /* utf16.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = utf16.hpp; sourceTree = "<group>"; }; - 3C0632291F0CBE210089D0AB /* utf32.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = utf32.hpp; sourceTree = "<group>"; }; - 3C06322A1F0CBE210089D0AB /* utf8.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = utf8.hpp; sourceTree = "<group>"; }; - 3C06322B1F0CBE210089D0AB /* version.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = version.hpp; sourceTree = "<group>"; }; - 3C06322C1F0CBE210089D0AB /* pegtl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = pegtl.hpp; sourceTree = "<group>"; }; - 3C06322D1F0CBE210089D0AB /* slice.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = slice.cpp; sourceTree = "<group>"; }; - 3C06322E1F0CBE210089D0AB /* slice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = slice.h; sourceTree = "<group>"; }; 3C0F0F6C1EF3781E000EADDB /* MoonParser */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = MoonParser; sourceTree = BUILT_PRODUCTS_DIR; }; + 3C6FFA2D1F16F97400541BCA /* ast.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ast.cpp; sourceTree = "<group>"; }; + 3C6FFA2E1F16F97400541BCA /* ast.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ast.hpp; sourceTree = "<group>"; }; + 3C6FFA2F1F16F97400541BCA /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; + 3C6FFA301F16F97400541BCA /* parser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = parser.cpp; sourceTree = "<group>"; }; + 3C6FFA311F16F97400541BCA /* parser.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = parser.hpp; sourceTree = "<group>"; }; + 3C6FFA321F16F97400541BCA /* parserlib.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = parserlib.hpp; sourceTree = "<group>"; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -178,179 +48,16 @@ 3C0631A11F0CBE210089D0AB /* MoonParser */ = { isa = PBXGroup; children = ( - 3C0631A21F0CBE210089D0AB /* main.cpp */, - 3C0631A31F0CBE210089D0AB /* pegtl */, - 3C06322C1F0CBE210089D0AB /* pegtl.hpp */, - 3C06322D1F0CBE210089D0AB /* slice.cpp */, - 3C06322E1F0CBE210089D0AB /* slice.h */, + 3C6FFA2D1F16F97400541BCA /* ast.cpp */, + 3C6FFA2E1F16F97400541BCA /* ast.hpp */, + 3C6FFA2F1F16F97400541BCA /* main.cpp */, + 3C6FFA301F16F97400541BCA /* parser.cpp */, + 3C6FFA311F16F97400541BCA /* parser.hpp */, + 3C6FFA321F16F97400541BCA /* parserlib.hpp */, ); path = MoonParser; sourceTree = "<group>"; }; - 3C0631A31F0CBE210089D0AB /* pegtl */ = { - isa = PBXGroup; - children = ( - 3C0631A41F0CBE210089D0AB /* analysis */, - 3C0631AD1F0CBE210089D0AB /* analyze.hpp */, - 3C0631AE1F0CBE210089D0AB /* apply_mode.hpp */, - 3C0631AF1F0CBE210089D0AB /* argv_input.hpp */, - 3C0631B01F0CBE210089D0AB /* ascii.hpp */, - 3C0631B11F0CBE210089D0AB /* buffer_input.hpp */, - 3C0631B21F0CBE210089D0AB /* config.hpp */, - 3C0631B31F0CBE210089D0AB /* contrib */, - 3C0631C01F0CBE210089D0AB /* cstream_input.hpp */, - 3C0631C11F0CBE210089D0AB /* eol.hpp */, - 3C0631C21F0CBE210089D0AB /* file_input.hpp */, - 3C0631C31F0CBE210089D0AB /* input_error.hpp */, - 3C0631C41F0CBE210089D0AB /* internal */, - 3C06321B1F0CBE210089D0AB /* istream_input.hpp */, - 3C06321C1F0CBE210089D0AB /* memory_input.hpp */, - 3C06321D1F0CBE210089D0AB /* mmap_input.hpp */, - 3C06321E1F0CBE210089D0AB /* normal.hpp */, - 3C06321F1F0CBE210089D0AB /* nothing.hpp */, - 3C0632201F0CBE210089D0AB /* parse.hpp */, - 3C0632211F0CBE210089D0AB /* parse_error.hpp */, - 3C0632221F0CBE210089D0AB /* position.hpp */, - 3C0632231F0CBE210089D0AB /* read_input.hpp */, - 3C0632241F0CBE210089D0AB /* rewind_mode.hpp */, - 3C0632251F0CBE210089D0AB /* rules.hpp */, - 3C0632261F0CBE210089D0AB /* string_input.hpp */, - 3C0632271F0CBE210089D0AB /* tracking_mode.hpp */, - 3C0632281F0CBE210089D0AB /* utf16.hpp */, - 3C0632291F0CBE210089D0AB /* utf32.hpp */, - 3C06322A1F0CBE210089D0AB /* utf8.hpp */, - 3C06322B1F0CBE210089D0AB /* version.hpp */, - ); - path = pegtl; - sourceTree = "<group>"; - }; - 3C0631A41F0CBE210089D0AB /* analysis */ = { - isa = PBXGroup; - children = ( - 3C0631A51F0CBE210089D0AB /* analyze_cycles.hpp */, - 3C0631A61F0CBE210089D0AB /* counted.hpp */, - 3C0631A71F0CBE210089D0AB /* generic.hpp */, - 3C0631A81F0CBE210089D0AB /* grammar_info.hpp */, - 3C0631A91F0CBE210089D0AB /* insert_guard.hpp */, - 3C0631AA1F0CBE210089D0AB /* insert_rules.hpp */, - 3C0631AB1F0CBE210089D0AB /* rule_info.hpp */, - 3C0631AC1F0CBE210089D0AB /* rule_type.hpp */, - ); - path = analysis; - sourceTree = "<group>"; - }; - 3C0631B31F0CBE210089D0AB /* contrib */ = { - isa = PBXGroup; - children = ( - 3C0631B41F0CBE210089D0AB /* abnf.hpp */, - 3C0631B51F0CBE210089D0AB /* alphabet.hpp */, - 3C0631B61F0CBE210089D0AB /* changes.hpp */, - 3C0631B71F0CBE210089D0AB /* counter.hpp */, - 3C0631B81F0CBE210089D0AB /* http.hpp */, - 3C0631B91F0CBE210089D0AB /* json.hpp */, - 3C0631BA1F0CBE210089D0AB /* raw_string.hpp */, - 3C0631BB1F0CBE210089D0AB /* rep_one_min_max.hpp */, - 3C0631BC1F0CBE210089D0AB /* to_string.hpp */, - 3C0631BD1F0CBE210089D0AB /* tracer.hpp */, - 3C0631BE1F0CBE210089D0AB /* unescape.hpp */, - 3C0631BF1F0CBE210089D0AB /* uri.hpp */, - ); - path = contrib; - sourceTree = "<group>"; - }; - 3C0631C41F0CBE210089D0AB /* internal */ = { - isa = PBXGroup; - children = ( - 3C0631C51F0CBE210089D0AB /* action.hpp */, - 3C0631C61F0CBE210089D0AB /* action_input.hpp */, - 3C0631C71F0CBE210089D0AB /* alnum.hpp */, - 3C0631C81F0CBE210089D0AB /* alpha.hpp */, - 3C0631C91F0CBE210089D0AB /* any.hpp */, - 3C0631CA1F0CBE210089D0AB /* apply.hpp */, - 3C0631CB1F0CBE210089D0AB /* apply0.hpp */, - 3C0631CC1F0CBE210089D0AB /* at.hpp */, - 3C0631CD1F0CBE210089D0AB /* bof.hpp */, - 3C0631CE1F0CBE210089D0AB /* bol.hpp */, - 3C0631CF1F0CBE210089D0AB /* bump_help.hpp */, - 3C0631D01F0CBE210089D0AB /* bump_impl.hpp */, - 3C0631D11F0CBE210089D0AB /* bytes.hpp */, - 3C0631D21F0CBE210089D0AB /* control.hpp */, - 3C0631D31F0CBE210089D0AB /* cr_crlf_eol.hpp */, - 3C0631D41F0CBE210089D0AB /* cr_eol.hpp */, - 3C0631D51F0CBE210089D0AB /* crlf_eol.hpp */, - 3C0631D61F0CBE210089D0AB /* cstream_reader.hpp */, - 3C0631D71F0CBE210089D0AB /* cstring_reader.hpp */, - 3C0631D81F0CBE210089D0AB /* demangle.hpp */, - 3C0631D91F0CBE210089D0AB /* demangle_cxxabi.hpp */, - 3C0631DA1F0CBE210089D0AB /* demangle_nop.hpp */, - 3C0631DB1F0CBE210089D0AB /* demangle_sanitise.hpp */, - 3C0631DC1F0CBE210089D0AB /* disable.hpp */, - 3C0631DD1F0CBE210089D0AB /* discard.hpp */, - 3C0631DE1F0CBE210089D0AB /* dusel_mode.hpp */, - 3C0631DF1F0CBE210089D0AB /* duseltronik.hpp */, - 3C0631E01F0CBE210089D0AB /* enable.hpp */, - 3C0631E11F0CBE210089D0AB /* eof.hpp */, - 3C0631E21F0CBE210089D0AB /* eol.hpp */, - 3C0631E31F0CBE210089D0AB /* eolf.hpp */, - 3C0631E41F0CBE210089D0AB /* file_mapper.hpp */, - 3C0631E51F0CBE210089D0AB /* file_opener.hpp */, - 3C0631E61F0CBE210089D0AB /* file_reader.hpp */, - 3C0631E71F0CBE210089D0AB /* has_apply0.hpp */, - 3C0631E81F0CBE210089D0AB /* identifier.hpp */, - 3C0631E91F0CBE210089D0AB /* if_apply.hpp */, - 3C0631EA1F0CBE210089D0AB /* if_must.hpp */, - 3C0631EB1F0CBE210089D0AB /* if_must_else.hpp */, - 3C0631EC1F0CBE210089D0AB /* if_then_else.hpp */, - 3C0631ED1F0CBE210089D0AB /* input_pair.hpp */, - 3C0631EE1F0CBE210089D0AB /* integer_sequence.hpp */, - 3C0631EF1F0CBE210089D0AB /* istream_reader.hpp */, - 3C0631F01F0CBE210089D0AB /* istring.hpp */, - 3C0631F11F0CBE210089D0AB /* iterator.hpp */, - 3C0631F21F0CBE210089D0AB /* lf_crlf_eol.hpp */, - 3C0631F31F0CBE210089D0AB /* lf_eol.hpp */, - 3C0631F41F0CBE210089D0AB /* list.hpp */, - 3C0631F51F0CBE210089D0AB /* list_must.hpp */, - 3C0631F61F0CBE210089D0AB /* list_tail.hpp */, - 3C0631F71F0CBE210089D0AB /* list_tail_pad.hpp */, - 3C0631F81F0CBE210089D0AB /* marker.hpp */, - 3C0631F91F0CBE210089D0AB /* minus.hpp */, - 3C0631FA1F0CBE210089D0AB /* must.hpp */, - 3C0631FB1F0CBE210089D0AB /* not_at.hpp */, - 3C0631FC1F0CBE210089D0AB /* one.hpp */, - 3C0631FD1F0CBE210089D0AB /* opt.hpp */, - 3C0631FE1F0CBE210089D0AB /* pad.hpp */, - 3C0631FF1F0CBE210089D0AB /* pad_opt.hpp */, - 3C0632001F0CBE210089D0AB /* peek_char.hpp */, - 3C0632011F0CBE210089D0AB /* peek_utf16.hpp */, - 3C0632021F0CBE210089D0AB /* peek_utf32.hpp */, - 3C0632031F0CBE210089D0AB /* peek_utf8.hpp */, - 3C0632041F0CBE210089D0AB /* pegtl_string.hpp */, - 3C0632051F0CBE210089D0AB /* plus.hpp */, - 3C0632061F0CBE210089D0AB /* raise.hpp */, - 3C0632071F0CBE210089D0AB /* range.hpp */, - 3C0632081F0CBE210089D0AB /* ranges.hpp */, - 3C0632091F0CBE210089D0AB /* rep.hpp */, - 3C06320A1F0CBE210089D0AB /* rep_min.hpp */, - 3C06320B1F0CBE210089D0AB /* rep_min_max.hpp */, - 3C06320C1F0CBE210089D0AB /* rep_opt.hpp */, - 3C06320D1F0CBE210089D0AB /* require.hpp */, - 3C06320E1F0CBE210089D0AB /* result_on_found.hpp */, - 3C06320F1F0CBE210089D0AB /* rule_conjunction.hpp */, - 3C0632101F0CBE210089D0AB /* rules.hpp */, - 3C0632111F0CBE210089D0AB /* seq.hpp */, - 3C0632121F0CBE210089D0AB /* skip_control.hpp */, - 3C0632131F0CBE210089D0AB /* sor.hpp */, - 3C0632141F0CBE210089D0AB /* star.hpp */, - 3C0632151F0CBE210089D0AB /* star_must.hpp */, - 3C0632161F0CBE210089D0AB /* state.hpp */, - 3C0632171F0CBE210089D0AB /* string.hpp */, - 3C0632181F0CBE210089D0AB /* trivial.hpp */, - 3C0632191F0CBE210089D0AB /* try_catch_type.hpp */, - 3C06321A1F0CBE210089D0AB /* until.hpp */, - ); - path = internal; - sourceTree = "<group>"; - }; 3C0F0F631EF3781E000EADDB = { isa = PBXGroup; children = ( @@ -424,8 +131,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 3C0632301F0CBE210089D0AB /* slice.cpp in Sources */, - 3C06322F1F0CBE210089D0AB /* main.cpp in Sources */, + 3C6FFA341F16F97400541BCA /* main.cpp in Sources */, + 3C6FFA351F16F97400541BCA /* parser.cpp in Sources */, + 3C6FFA331F16F97400541BCA /* ast.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/MoonParser/ast.cpp b/MoonParser/ast.cpp new file mode 100644 index 0000000..66f6493 --- /dev/null +++ b/MoonParser/ast.cpp @@ -0,0 +1,68 @@ +#include <cassert> +#include "ast.hpp" + + +namespace parserlib { + + +//current AST container. +static ast_container *_current = 0; + + +/** sets the container under construction to be this. + */ +ast_container::ast_container() { + _current = this; +} + + +/** sets the container under construction to be this. + @param src source object. + */ +ast_container::ast_container(const ast_container &src) { + _current = this; +} + + +/** Asks all members to construct themselves from the stack. + The members are asked to construct themselves in reverse order. + from a node stack. + @param st stack. + */ +void ast_container::construct(ast_stack &st) { + for(ast_member_vector::reverse_iterator it = m_members.rbegin(); + it != m_members.rend(); + ++it) + { + ast_member *member = *it; + member->construct(st); + } +} + + +//register the AST member to the current container. +void ast_member::_init() { + assert(_current); + m_container = _current; + _current->m_members.push_back(this); +} + + +/** parses the given input. + @param i input. + @param g root rule of grammar. + @param ws whitespace rule. + @param el list of errors. + @param ud user data, passed to the parse procedures. + @return pointer to ast node created, or null if there was an error. + The return object must be deleted by the caller. + */ +ast_node *parse(input &i, rule &g, error_list &el, void* ud) { + ast_stack st; + if (!parse(i, g, el, &st, ud)) return 0; + assert(st.size() == 1); + return st[0]; +} + + +} //namespace parserlib diff --git a/MoonParser/ast.hpp b/MoonParser/ast.hpp new file mode 100644 index 0000000..5d87db9 --- /dev/null +++ b/MoonParser/ast.hpp @@ -0,0 +1,437 @@ +#ifndef AST_HPP +#define AST_HPP + + +#include <cassert> +#include <list> +#include <stdexcept> +#include "parser.hpp" + + +namespace parserlib { + + +class ast_node; +template <class T, bool OPT> class ast_ptr; +template <class T> class ast_list; +template <class T> class ast; + + +/** type of AST node stack. + */ +typedef std::vector<ast_node *> ast_stack; + + +/** Base class for AST nodes. + */ +class ast_node : public input_range { +public: + ///constructor. + ast_node() : m_parent(0) {} + + /** copy constructor. + @param n source object. + */ + ast_node(const ast_node &n) : m_parent(0) {} + + ///destructor. + virtual ~ast_node() {} + + /** assignment operator. + @param n source object. + @return reference to this. + */ + ast_node &operator = (const ast_node &n) { return *this; } + + /** get the parent node. + @return the parent node, if there is one. + */ + ast_node *parent() const { return m_parent; } + + /** interface for filling the contents of the node + from a node stack. + @param st stack. + */ + virtual void construct(ast_stack &st) {} + +private: + //parent + ast_node *m_parent; + + template <class T, bool OPT> friend class ast_ptr; + template <class T> friend class ast_list; + template <class T> friend class ast; +}; + + +class ast_member; + + +/** type of ast member vector. + */ +typedef std::vector<ast_member *> ast_member_vector; + + +/** base class for AST nodes with children. + */ +class ast_container : public ast_node { +public: + /** sets the container under construction to be this. + */ + ast_container(); + + /** sets the container under construction to be this. + Members are not copied. + @param src source object. + */ + ast_container(const ast_container &src); + + /** the assignment operator. + The members are not copied. + @param src source object. + @return reference to this. + */ + ast_container &operator = (const ast_container &src) { + return *this; + } + + /** returns the vector of AST members. + @return the vector of AST members. + */ + const ast_member_vector &members() const { + return m_members; + } + + /** Asks all members to construct themselves from the stack. + The members are asked to construct themselves in reverse order. + from a node stack. + @param st stack. + */ + virtual void construct(ast_stack &st); + +private: + ast_member_vector m_members; + + friend class ast_member; +}; + + +/** Base class for children of ast_container. + */ +class ast_member { +public: + /** automatically registers itself to the container under construction. + */ + ast_member() { _init(); } + + /** automatically registers itself to the container under construction. + @param src source object. + */ + ast_member(const ast_member &src) { _init(); } + + /** the assignment operator. + @param src source object. + @return reference to this. + */ + ast_member &operator = (const ast_member &src) { + return *this; + } + + /** returns the container this belongs to. + @return the container this belongs to. + */ + ast_container *container() const { return m_container; } + + /** interface for filling the the member from a node stack. + @param st stack. + */ + virtual void construct(ast_stack &st) = 0; + +private: + //the container this belongs to. + ast_container *m_container; + + //register the AST member to the current container. + void _init(); +}; + + +/** pointer to an AST object. + It assumes ownership of the object. + It pops an object of the given type from the stack. + @tparam T type of object to control. + @tparam OPT if true, the object becomes optional. + */ +template <class T, bool OPT = false> class ast_ptr : public ast_member { +public: + /** the default constructor. + @param obj object. + */ + ast_ptr(T *obj = 0) : m_ptr(obj) { + _set_parent(); + } + + /** the copy constructor. + It duplicates the underlying object. + @param src source object. + */ + ast_ptr(const ast_ptr<T, OPT> &src) : + m_ptr(src.m_ptr ? new T(*src.m_ptr) : 0) + { + _set_parent(); + } + + /** deletes the underlying object. + */ + ~ast_ptr() { + delete m_ptr; + } + + /** copies the given object. + The old object is deleted. + @param obj new object. + @return reference to this. + */ + ast_ptr<T, OPT> &operator = (const T *obj) { + delete m_ptr; + m_ptr = obj ? new T(*obj) : 0; + _set_parent(); + return *this; + } + + /** copies the underlying object. + The old object is deleted. + @param src source object. + @return reference to this. + */ + ast_ptr<T, OPT> &operator = (const ast_ptr<T, OPT> &src) { + delete m_ptr; + m_ptr = src.m_ptr ? new T(*src.m_ptr) : 0; + _set_parent(); + return *this; + } + + /** gets the underlying ptr value. + @return the underlying ptr value. + */ + T *get() const { + return m_ptr; + } + + /** auto conversion to the underlying object ptr. + @return the underlying ptr value. + */ + operator T *() const { + return m_ptr; + } + + /** member access. + @return the underlying ptr value. + */ + T *operator ->() const { + assert(m_ptr); + return m_ptr; + } + + /** Pops a node from the stack. + @param st stack. + @exception std::logic_error thrown if the node is not of the appropriate type; + thrown only if OPT == false or if the stack is empty. + */ + virtual void construct(ast_stack &st) { + //check the stack node + if (st.empty()) throw std::logic_error("invalid AST stack"); + + //get the node + ast_node *node = st.back(); + + //get the object + T *obj = dynamic_cast<T *>(node); + + //if the object is optional, simply return + if (OPT) { + if (!obj) return; + } + + //else if the object is mandatory, throw an exception + else { + if (!obj) throw std::logic_error("invalid AST node"); + } + + //pop the node from the stack + st.pop_back(); + + //set the new object + delete m_ptr; + m_ptr = obj; + _set_parent(); + } + +private: + //ptr + T *m_ptr; + + //set parent of object + void _set_parent() { + if (m_ptr) m_ptr->m_parent = container(); + } +}; + + +/** A list of objects. + It pops objects of the given type from the ast stack, until no more objects can be popped. + It assumes ownership of objects. + @tparam T type of object to control. + */ +template <class T> class ast_list : public ast_member { +public: + ///list type. + typedef std::list<T *> container; + + ///the default constructor. + ast_list() {} + + /** duplicates the objects of the given list. + @param src source object. + */ + ast_list(const ast_list<T> &src) { + _dup(src); + } + + /** deletes the objects. + */ + ~ast_list() { + _clear(); + } + + /** deletes the objects of this list and duplicates the given one. + @param src source object. + @return reference to this. + */ + ast_list<T> &operator = (const ast_list<T> &src) { + if (&src != this) { + _clear(); + _dup(src); + } + return *this; + } + + /** returns the container of objects. + @return the container of objects. + */ + const container &objects() const { + return m_objects; + } + + /** Pops objects of type T from the stack until no more objects can be popped. + @param st stack. + */ + virtual void construct(ast_stack &st) { + for(;;) { + //if the stack is empty + if (st.empty()) break; + + //get the node + ast_node *node = st.back(); + + //get the object + T *obj = dynamic_cast<T *>(node); + + //if the object was not not of the appropriate type, + //end the list parsing + if (!obj) return; + + //remove the node from the stack + st.pop_back(); + + //insert the object in the list, in reverse order + m_objects.push_front(obj); + + //set the object's parent + obj->m_parent = ast_member::container(); + } + } + +private: + //objects + container m_objects; + + //deletes the objects of this list. + void _clear() { + while (!m_objects.empty()) { + delete m_objects.back(); + m_objects.pop_back(); + } + } + + //duplicate the given list. + void _dup(const ast_list<T> &src) { + for(typename container::const_iterator it = src.m_objects.begin(); + it != src.m_objects.end(); + ++it) + { + T *obj = new T(*it); + m_objects.push_back(obj); + obj->m_parent = ast_member::container(); + } + } +}; + + +/** AST function which creates an object of type T + and pushes it to the node stack. + */ +template <class T> class ast { +public: + /** constructor. + @param r rule to attach the AST function to. + */ + ast(rule &r) { + r.set_parse_proc(&_parse_proc); + } + +private: + //parse proc + static void _parse_proc(const pos &b, const pos &e, void *d) { + ast_stack *st = reinterpret_cast<ast_stack *>(d); + T *obj = new T; + obj->m_begin = b; + obj->m_end = e; + obj->construct(*st); + st->push_back(obj); + } +}; + + +/** parses the given input. + @param i input. + @param g root rule of grammar. + @param el list of errors. + @param ud user data, passed to the parse procedures. + @return pointer to ast node created, or null if there was an error. + The return object must be deleted by the caller. + */ +ast_node *parse(input &i, rule &g, error_list &el, void* ud); + + +/** parses the given input. + @param i input. + @param g root rule of grammar. + @param el list of errors. + @param ast result pointer to created ast. + @param ud user data, passed to the parse procedures. + @return true on success, false on error. + */ +template <class T> bool parse(input &i, rule &g, error_list &el, T *&ast, void* ud = nullptr) { + ast_node *node = parse(i, g, el, ud); + ast = dynamic_cast<T *>(node); + if (ast) return true; + delete node; + return false; +} + + +} //namespace parserlib + + +#endif //AST_HPP diff --git a/MoonParser/main.cpp b/MoonParser/main.cpp index e692732..cf7bc2d 100644 --- a/MoonParser/main.cpp +++ b/MoonParser/main.cpp @@ -1,1698 +1,581 @@ -// -// main.cpp -// PegtlStudy -// -// Created by Li Jin on 2017/6/16. -// Copyright © 2017年 Li Jin. All rights reserved. -// - #include <iostream> +using std::cout; +#include <string> +using std::string; #include <unordered_set> -#include <vector> -#include <queue> +using std::unordered_set; #include <stack> -#include <memory> -#include "pegtl.hpp" -#include "pegtl/analyze.hpp" -#include "slice.h" -using namespace silly; - -using namespace tao::pegtl; - -namespace helloworld // with operator precedence climbing +using std::stack; +#include <algorithm> +#include <sstream> +using std::stringstream; +#include "parserlib.hpp" +using namespace parserlib; + +#define p(expr) user(expr, [](const item_t& item) \ +{ \ + stringstream stream; \ + for (input_it i = item.begin; i != item.end; ++i) stream << static_cast<char>(*i); \ + cout << #expr << ": [" << stream.str() << "]\n"; \ + return true; \ +}) + +struct State { - struct Stack + State() { - Stack() - { - pushStack(); - } - void pushValue(int value) - { - _values.back().push(value); - } - void pushOp(char op) - { - _ops.back().push(op); - } - void pushStack() - { - _values.emplace_back(); - _ops.emplace_back(); - } - int getPriority(char op) - { - switch (op) - { - case '+': return 1; - case '-': return 1; - case '*': return 2; - case '/': return 2; - } - return 0; - } - /* - def compute_expr(tokenizer, min_prec): - atom_lhs = tokenizer.get_next_token() - - while True: - cur = tokenizer.cur_token - if (cur is None or OPINFO_MAP[cur.value].prec < min_prec): - break - - op = cur.value - prec, assoc = OPINFO_MAP[op] - next_min_prec = prec + 1 if assoc == 'LEFT' else prec - - atom_rhs = compute_expr(tokenizer, next_min_prec) - - atom_lhs = compute_op(op, atom_lhs, atom_rhs) - - return atom_lhs - */ - int parseNext(int minPrecedence) - { - int lhs = _values.back().front(); - _values.back().pop(); - - while (true) - { - if (_ops.back().empty()) - { - break; - } - char op = _ops.back().front(); - if (getPriority(op) < minPrecedence) - { - break; - } - _ops.back().pop(); - int nextMinPrecedence = getPriority(op) + 1; - int rhs = parseNext(nextMinPrecedence); - switch (op) - { - case '+': - std::cout << lhs << " + " << rhs << " = " << lhs+rhs << '\n'; - lhs = lhs + rhs; - break; - case '-': - std::cout << lhs << " - " << rhs << " = " << lhs-rhs << '\n'; - lhs = lhs - rhs; - break; - case '*': - std::cout << lhs << " * " << rhs << " = " << lhs*rhs << '\n'; - lhs = lhs * rhs; - break; - case '/': - std::cout << lhs << " / " << rhs << " = " << lhs/rhs << '\n'; - lhs = lhs / rhs; - break; - } - } - return lhs; - } - void popStack() - { - int value = parseNext(0); - _values.pop_back(); - if (_values.empty()) - { - _values.emplace_back(); - } - _ops.pop_back(); - if (_ops.empty()) - { - _ops.emplace_back(); - } - pushValue(value); - } - int getValue() const - { - return _values.back().back(); - } - private: - std::vector<std::queue<char>> _ops; - std::vector<std::queue<int>> _values; + indents.push(0); + stringOpen = -1; + } + size_t stringOpen; + stack<int> indents; + stack<bool> doStack; + unordered_set<string> keywords = { + "and", "while", "else", "using", "continue", + "local", "not", "then", "return", "from", + "extends", "for", "do", "or", "export", + "class", "in", "unless", "when", "elseif", + "switch", "break", "if", "with", "import" }; - - struct number : seq<opt<one<'+', '-'>>, plus<digit>> { }; - - struct expr; - - struct bracket : if_must<one<'('>, expr, one<')'>> { }; - - struct atomic : sor<number, bracket> { }; - - struct op : one<'+', '-', '*', '/'> { }; - - struct expr : list<atomic, op, space> { }; - - template<typename Rule> - struct action : nothing<Rule> { }; - - template<> - struct action<number> +}; + +rule Any = any(); +rule White = *set(" \t\r\n"); +rule plain_space = *set(" \t"); +rule Break = nl(-expr('\r') >> '\n'); +rule Stop = Break | eof(); +rule Comment = "--" >> *(not_(set("\r\n")) >> Any) >> and_(Stop); +rule Indent = *set(" \t"); +rule Space = plain_space >> -Comment; +rule SomeSpace = +set(" \t") >> -Comment; +rule SpaceBreak = Space >> Break; +rule EmptyLine = SpaceBreak; +rule AlphaNum = range('a', 'z') | range('A', 'Z') | range('0', '9') | '_'; +rule _Name = (range('a', 'z') | range('A', 'Z') | '_') >> *AlphaNum; +rule SpaceName = Space >> _Name; +rule _Num = + ( + "0x" >> + +(range('0', '9') | range('a', 'f') | range('A', 'F')) >> + -(-set("uU") >> set("lL") >> set("lL")) + ) | ( + +range('0', '9') >> -set("uU") >> set("lL") >> set("lL") + ) | ( + ( + (+range('0', '9') >> -('.' >> +range('0', '9'))) | + ('.' >> +range('0', '9')) + ) >> -(set("eE") >> -expr('-') >> +range('0', '9')) + ); +rule Num = Space >> _Num; +rule Cut = false_(); +rule Nothing = true_(); + +#define sym(str) (Space >> str) +#define symx(str) expr(str) +#define ensure(patt, finally) (((patt) >> (finally)) | ((finally) >> (Cut))) +#define key(str) (Space >> str >> not_(AlphaNum)) +#define opWord(str) (Space >> str >> not_(AlphaNum)) +#define op(str) (Space >> str) + +rule Name = user(SpaceName, [](const item_t& item) +{ + stringstream stream; + for (input_it i = item.begin; i != item.end; ++i) stream << static_cast<char>(*i); + string name; + stream >> name; + State* st = reinterpret_cast<State*>(item.user_data); + auto it = st->keywords.find(name); + return it == st->keywords.end(); +}); + +rule self = expr('@'); +rule self_name = '@' >> _Name; +rule self_class = expr("@@"); +rule self_class_name = "@@" >> _Name; + +rule SelfName = Space >> (self_class_name | self_class | self_name | self); +rule KeyName = SelfName | Space >> _Name; +rule VarArg = Space >> "..."; + +rule check_indent = user(Indent, [](const item_t& item) +{ + int indent = 0; + for (input_it i = item.begin; i != item.end; ++i) { - template<typename Input> - static void apply(const Input& in, Stack& stack) + switch (*i) { - stack.pushValue(std::stoi(in.string())); + case ' ': indent++; break; + case '\t': indent += 4; break; } - }; + } + State* st = reinterpret_cast<State*>(item.user_data); + return st->indents.top() == indent; +}); +rule CheckIndent = and_(check_indent); - template<> - struct action<op> +rule advance = user(Indent, [](const item_t& item) +{ + int indent = 0; + for (input_it i = item.begin; i != item.end; ++i) { - template<typename Input> - static void apply(const Input& in, Stack& stack) + switch (*i) { - stack.pushOp(*in.begin()); + case ' ': indent++; break; + case '\t': indent += 4; break; } - }; - - template<> - struct action<one<'('>> + } + State* st = reinterpret_cast<State*>(item.user_data); + int top = st->indents.top(); + if (top != -1 && indent > top) { - static void apply0(Stack& stack) - { - stack.pushStack(); - } - }; + st->indents.push(indent); + return true; + } + return false; +}); +rule Advance = and_(advance); - template<> - struct action<expr> +rule push_indent = user(Indent, [](const item_t& item) +{ + int indent = 0; + for (input_it i = item.begin; i != item.end; ++i) { - template<typename Input> - static void apply(const Input& in, Stack& stack) + switch (*i) { - stack.popStack(); + case ' ': indent++; break; + case '\t': indent += 4; break; } - }; + } + State* st = reinterpret_cast<State*>(item.user_data); + st->indents.push(indent); + return true; +}); +rule PushIndent = and_(push_indent); -} // namespace hello +rule PreventIndent = user(true_(), [](const item_t& item) +{ + State* st = reinterpret_cast<State*>(item.user_data); + st->indents.push(-1); + return true; +}); -namespace moon +rule PopIndent = user(true_(), [](const item_t& item) { - int moonType = 0; + State* st = reinterpret_cast<State*>(item.user_data); + st->indents.pop(); + return true; +}); - template <class T> - int MoonType() - { - static int type = moonType++; - return type; - } +extern rule Block; - struct Node - { - virtual ~Node() {} - slice::Slice token; - }; +rule InBlock = Advance >> Block >> PopIndent; - struct State - { - State() - { - indents.push(0); - stringOpen = -1; - astStack.emplace_back(); - } - size_t stringOpen; - std::stack<int> indents; - std::stack<bool> doStack; - std::unordered_set<std::string> keywords = - { - "and", "while", "else", "using", "continue", - "local", "not", "then", "return", "from", - "extends", "for", "do", "or", "export", - "class", "in", "unless", "when", "elseif", - "switch", "break", "if", "with", "import" - }; - std::stack<size_t> indexStack; - std::vector<std::vector<std::shared_ptr<Node>>> astStack; - }; +extern rule NameList; - struct White : star<one<' ', '\t', '\r', '\n'>> {}; - struct plain_space : star<one<' ', '\t'>> {}; - struct Break : seq<opt<one<'\r'>>, one<'\n'>> {}; - struct Stop : sor<Break, eof> {}; - struct Comment : seq<string<'-', '-'>, star<not_at<one<'\r', '\n'>>, any>, at<Stop>> {}; - struct Indent : star<one<' ', '\t'>> {}; - struct Space : seq<plain_space, opt<Comment>> {}; - struct SomeSpace : seq<plus<blank>, opt<Comment>> {}; - struct SpaceBreak : seq<Space, Break> {}; - typedef SpaceBreak EmptyLine; - struct AlphaNum : ranges<'a', 'z', 'A', 'Z', '0', '9', '_', '_'> {}; - struct _Name : seq<ranges<'a', 'z', 'A', 'Z', '_', '_'>, star<AlphaNum>> {}; - struct SpaceName : seq<Space, _Name> {}; - struct _Num : sor< - seq< - string<'0' ,'x'>, - plus<ranges<'0', '9', 'a', 'f', 'A', 'F'>>, - opt<seq< - opt<one<'u', 'U'>>, one<'l', 'L'>, one<'l', 'L'> - >> - >, - seq< - plus<range<'0', '9'>>, - seq< - opt<one<'u', 'U'>>, one<'l', 'L'>, one<'l', 'L'> - > - >, - seq< - sor< - seq< - plus<range<'0', '9'>>, - opt<seq< - one<'.'>, plus<range<'0', '9'>> - >> - >, - seq< - one<'.'>, - plus<range<'0', '9'>> - > - >, - opt<seq< - one<'e', 'E'>, opt<one<'-'>>, plus<range<'0', '9'>> - >> - > - > {}; - struct Num : seq<Space, _Num> {}; - - struct Cut : failure {}; - - template<char... Cs> struct sym : seq<Space, string<Cs...>> {}; - template<char... Cs> struct symx : string<Cs...> {}; - - template<typename patt, typename finally> - struct ensure : sor<seq<patt, finally>, seq<finally, Cut>> {}; - - template<char... Cs> struct key : seq<Space, string<Cs...>, not_at<AlphaNum>> {}; - template<char... Cs> struct opWord : seq<Space, string<Cs...>, not_at<AlphaNum>> {}; - template<char... Cs> struct op : seq<Space, string<Cs...>> {}; - - struct Name - { - using analyze_t = analysis::generic<analysis::rule_type::ANY>; +rule Local = key("local") >> (op('*') | op('^') | NameList); - template<apply_mode A, rewind_mode M, - template<typename...> class Action, - template<typename...> class Control, - typename Input> - static bool match(Input& in, State& st) - { - const char* current = in.current(); - memory_input<> memIn(current, in.end() - current, current); - if (SpaceName::match<A, M, Action, Control>(memIn, st)) - { - auto name = slice::Slice(current, memIn.current() - current); - auto trimed = name; - trimed.trimSpace(); - auto it = st.keywords.find(trimed); - if (it == st.keywords.end()) - { - in.bump(name.size()); - return true; - } - } - return false; - } - }; +rule colon_import_name = sym('\\') >> Name; +rule ImportName = colon_import_name | Name; +rule ImportNameList = *SpaceBreak >> ImportName >> *((+SpaceBreak | sym(',') >> *SpaceBreak) >> ImportName); - struct self : one<'@'> {}; - struct self_name : seq<one<'@'>, _Name> {}; - struct self_class : string<'@', '@'> {}; - struct self_class_name : seq<string<'@', '@'>, _Name> {}; +extern rule Exp; - struct SelfName : seq<Space, sor<self_class_name, self_class, self_name, self>> {}; - struct KeyName : sor<SelfName, seq<Space, _Name>> {}; - struct VarArg : seq<Space, string<'.', '.', '.'>> {}; +rule Import = key("import") >> ImportNameList >> *SpaceBreak >> key("from") >> Exp; +rule BreakLoop = key("break") | key("continue"); - struct CheckIndentBump - { - using analyze_t = analysis::generic<analysis::rule_type::ANY>; +extern rule ExpListLow, ExpList, Assign; - template<apply_mode A, rewind_mode M, - template<typename...> class Action, - template<typename...> class Control, - typename Input> - static bool match(Input& in, State& st) - { - const char* current = in.current(); - if (Indent::match<A, M, Action, Control>(in, st)) - { - int indent = 0; - for (const char* ch = current; ch < in.current(); ch++) - { - switch (*ch) - { - case ' ': indent++; break; - case '\t': indent += 4; break; - } - } - return st.indents.top() == indent; - } - return false; - } - }; - struct CheckIndent : at<CheckIndentBump> {}; +rule Return = key("return") >> (ExpListLow | Nothing); +rule WithExp = ExpList >> -Assign; - struct AdvanceBump - { - using analyze_t = analysis::generic<analysis::rule_type::ANY>; +extern rule DisableDo, PopDo, Body; - template<apply_mode A, rewind_mode M, - template<typename...> class Action, - template<typename...> class Control, - typename Input> - static bool match(Input& in, State& st) - { - const char* current = in.current(); - if (Indent::match<A, M, Action, Control>(in, st)) - { - int indent = 0; - for (const char* ch = current; ch < in.current(); ch++) - { - switch (*ch) - { - case ' ': indent++; break; - case '\t': indent += 4; break; - } - } - int top = st.indents.top(); - if (top != -1 && indent > top) - { - st.indents.push(indent); - return true; - } - return false; - } - return false; - } - }; - struct Advance : at<AdvanceBump> {}; +rule With = key("with") >> DisableDo >> ensure(WithExp, PopDo) >> -key("do") >> Body; +rule SwitchCase = key("when") >> ExpList >> -key("then") >> Body; +rule SwitchElse = key("else") >> Body; - struct PushIndentBump - { - using analyze_t = analysis::generic<analysis::rule_type::ANY>; +rule SwitchBlock = *EmptyLine >> + Advance >> + SwitchCase >> + *(+Break >> SwitchCase) >> + -(+Break >> SwitchElse) >> + PopIndent; - template<apply_mode A, rewind_mode M, - template<typename...> class Action, - template<typename...> class Control, - typename Input> - static bool match(Input& in, State& st) - { - const char* current = in.current(); - if (Indent::match<A, M, Action, Control>(in, st)) - { - int indent = 0; - for (const char* ch = current; ch < in.current(); ch++) - { - switch (*ch) - { - case ' ': indent++; break; - case '\t': indent += 4; break; - } - } - st.indents.push(indent); - return true; - } - return false; - } - }; - struct PushIndent : at<PushIndentBump> {}; +rule Switch = key("switch") >> + DisableDo >> ensure(Exp, PopDo) >> + -key("do") >> -Space >> Break >> SwitchBlock; - struct PreventIndentBump - { - using analyze_t = analysis::generic<analysis::rule_type::ANY>; +rule IfCond = Exp >> -Assign; +rule IfElseIf = -(Break >> *EmptyLine >> CheckIndent) >> key("elseif") >> IfCond >> -key("then") >> Body; +rule IfElse = -(Break >> *EmptyLine >> CheckIndent) >> key("else") >> Body; +rule If = key("if") >> IfCond >> -key("then") >> Body >> *IfElseIf >> -IfElse; +rule Unless = key("unless") >> IfCond >> -key("then") >> Body >> *IfElseIf >> -IfElse; - template<apply_mode A, rewind_mode M, - template<typename...> class Action, - template<typename...> class Control, - typename Input> - static bool match(Input& in, State& st) - { - st.indents.push(-1); - return true; - } - }; - struct PreventIndent : at<PreventIndentBump> {}; +rule While = key("while") >> DisableDo >> ensure(Exp, PopDo) >> -key("do") >> Body; - struct PopIndentBump - { - using analyze_t = analysis::generic<analysis::rule_type::ANY>; +rule for_args = Name >> sym('=') >> Exp >> sym(',') >> Exp >> (sym(',') >> Exp | Nothing); - template<apply_mode A, rewind_mode M, - template<typename...> class Action, - template<typename...> class Control, - typename Input> - static bool match(Input& in, State& st) - { - st.indents.pop(); - return true; - } - }; - struct PopIndent : at<PopIndentBump> {}; - - struct Block; - - struct InBlock : seq<Advance, Block, PopIndent> {}; - - struct NameList; - - struct Local : seq< - key<'l', 'o', 'c', 'a', 'l'>, - sor< - sor<op<'*'>, op<'^'>>, - NameList - > - > {}; - - struct colon_import_name : seq<sym<'\\'>, Name> {}; - struct ImportName : sor<colon_import_name, Name> {}; - struct ImportNameList : seq< - star<SpaceBreak>, - ImportName, - star< - sor< - plus<SpaceBreak>, - seq<sym<','>, star<SpaceBreak>> - >, - ImportName - > - > {}; - - struct Exp; - - struct Import : seq<key<'i', 'm', 'p', 'o', 'r', 't'>, ImportNameList, star<SpaceBreak>, key<'f', 'r', 'o', 'm'>, Exp> {}; - - struct BreakLoop : sor<key<'b', 'r', 'e', 'a', 'k'>, key<'c', 'o', 'n', 't', 'i', 'n', 'u', 'e'>> {}; - - struct ExpListLow; - - struct ExpList; - struct Assign; - - struct Return : seq<key<'r', 'e', 't', 'u', 'r', 'n'>, sor<ExpListLow, success>> {}; - struct WithExp : seq<ExpList, opt<Assign>> {}; - - struct DisableDo; - struct PopDo; - struct Body; - - struct With : seq<key<'w', 'i', 't', 'h'>, DisableDo, ensure<WithExp, PopDo>, opt<key<'d', 'o'>>, Body> {}; - - struct SwitchCase : seq<key<'w', 'h', 'e', 'n'>, ExpList, opt<key<'t', 'h', 'e', 'n'>>, Body> {}; - struct SwitchElse : seq<key<'e', 'l', 's', 'e'>, Body> {}; - struct SwitchBlock : seq< - star<EmptyLine>, - Advance, - seq< - SwitchCase, - star<plus<Break>, SwitchCase>, - opt<plus<Break>, SwitchElse> - >, - PopIndent - > {}; - struct Switch : seq<key<'s', 'w', 'i', 't', 'c', 'h'>, DisableDo, ensure<Exp, PopDo>, opt<key<'d', 'o'>>, opt<Space>, Break, SwitchBlock> {}; - - struct IfCond : seq<Exp, opt<Assign>> {}; - - struct IfElse : seq< - opt<Break, star<EmptyLine>, CheckIndent>, - key<'e', 'l', 's', 'e'>, Body - > {}; - - struct IfElseIf : seq< - opt<Break, star<EmptyLine>, CheckIndent>, - key<'e', 'l', 's', 'e', 'i', 'f'>, IfCond, - opt<key<'t', 'h', 'e', 'n'>>, Body - > {}; - - struct If : seq<key<'i', 'f'>, IfCond, opt<key<'t', 'h', 'e', 'n'>>, Body, star<IfElseIf>, opt<IfElse>> {}; - struct Unless : seq<key<'u', 'n', 'l', 'e', 's', 's'>, IfCond, opt<key<'t', 'h', 'e', 'n'>>, Body, star<IfElseIf>, opt<IfElse>> {}; - - struct While : seq<key<'w', 'h', 'i', 'l', 'e'>, DisableDo, ensure<Exp, PopDo>, opt<key<'d','o'>>, Body> {}; - struct For : seq<key<'f', 'o', 'r'>, DisableDo, - ensure< - seq< - Name, sym<'='>, - seq<Exp, sym<','>, Exp, opt<sym<','>, Exp>> - >, - PopDo - >, - opt<key<'d', 'o'>>, Body> {}; - - struct AssignableNameList; - - struct ForEach : seq< - key<'f', 'o', 'r'>, - AssignableNameList, - key<'i', 'n'>, - DisableDo, - ensure< - sor< - seq<sym<'*'>, Exp>, ExpList - >, - PopDo - >, - opt<key<'d', 'o'>>, - Body - > {}; - - struct Do - { - using analyze_t = analysis::generic<analysis::rule_type::ANY>; +rule For = key("for") >> DisableDo >> + ensure(for_args, PopDo) >> + -key("do") >> Body; - template<apply_mode A, rewind_mode M, - template<typename...> class Action, - template<typename...> class Control, - typename Input> - static bool match(Input& in, State& st) - { - if (at<seq<key<'d', 'o'>, Body>>::match<A, M, Action, Control>(in, st)) - { - if (st.doStack.empty() || st.doStack.top()) - { - return true; - } - } - return false; - } - }; +extern rule AssignableNameList; - struct DisableDo - { - using analyze_t = analysis::generic<analysis::rule_type::ANY>; +rule for_in = sym('*') >> Exp | ExpList; - template<apply_mode A, rewind_mode M, - template<typename...> class Action, - template<typename...> class Control, - typename Input> - static bool match(Input& in, State& st) - { - st.doStack.push(false); - return true; - } - }; +rule ForEach = key("for") >> AssignableNameList >> key("in") >> + DisableDo >> ensure(for_in, PopDo) >> + -key("do") >> Body; - struct PopDo - { - using analyze_t = analysis::generic<analysis::rule_type::ANY>; +rule Do = user(key("do") >> Body, [](const item_t& item) +{ + State* st = reinterpret_cast<State*>(item.user_data); + return st->doStack.empty() || st->doStack.top(); +}); - template<apply_mode A, rewind_mode M, - template<typename...> class Action, - template<typename...> class Control, - typename Input> - static bool match(Input& in, State& st) - { - st.doStack.pop(); - return true; - } - }; +rule DisableDo = user(true_(), [](const item_t& item) +{ + State* st = reinterpret_cast<State*>(item.user_data); + st->doStack.push(false); + return true; +}); - struct CompInner; - - struct Comprehension : seq<sym<'['>, Exp, CompInner, sym<']'>> {}; - struct TblComprehension : seq<sym<'{'>, seq<Exp, opt<sym<','>, Exp>>, CompInner, sym<'}'>> {}; - - struct CompForEach; - struct CompFor; - struct CompClause; - - struct CompInner : seq<sor<CompForEach, CompFor>, star<CompClause>> {}; - struct CompForEach : seq< - key<'f', 'o', 'r'>, - AssignableNameList, - key<'i', 'n'>, - sor< - seq<sym<'*'>, Exp>, Exp - > - > {}; - struct CompFor : seq<key<'f', 'o', 'r'>, Name, sym<'='>, seq<Exp, sym<','>, Exp, opt<sym<','>, Exp>>> {}; - struct CompClause : sor<CompFor, CompForEach, seq<key<'w', 'h', 'e', 'n'>, Exp>> {}; - - struct TableBlock; - - struct Assign : seq<sym<'='>, sor<With, If, Switch, TableBlock, ExpListLow>> {}; - - struct Update : seq<sor< - sym<'.', '.', '='>, - sym<'+', '='>, - sym<'-', '='>, - sym<'*', '='>, - sym<'/', '='>, - sym<'%', '='>, - sym<'o', 'r', '='>, - sym<'a', 'n', 'd', '='>, - sym<'&', '='>, - sym<'|', '='>, - sym<'>', '>', '='>, - sym<'<', '<', '='> - >, Exp> {}; - - struct CharOperators : seq<Space, one<'+', '-', '*' ,'/', '%', '^', '>', '<', '|', '&'>> {}; - struct WordOperators : sor< - opWord<'o', 'r'>, - opWord<'a', 'n', 'd'>, - op<'<', '='>, - op<'>', '='>, - op<'~', '='>, - op<'!', '='>, - op<'=', '='>, - op<'.', '.'>, - op<'<', '<'>, - op<'>', '>'>, - op<'/', '/'>> {}; - struct BinaryOperator : seq<sor<WordOperators, CharOperators>, star<SpaceBreak>> {}; - - struct Chain; - - struct Assignable : sor<at<Chain>, Name, SelfName> {}; - - struct Value; - - struct Exp : seq<Value, star<BinaryOperator, Value>> {}; - - struct Callable; - struct InvokeArgs; - - struct ChainValue : seq<sor<Chain, Callable>, opt<InvokeArgs>> {}; - - struct KeyValueList; - struct String; - struct SimpleValue; - - struct Value : sor<SimpleValue, KeyValueList, ChainValue, String> {}; - struct SliceValue : Exp {}; - - struct LuaString; - - struct single_string_inner : sor<string<'\\', '\''>, string<'\\', '\\'>, not_one<'\''>> {}; - struct SingleString : seq<symx<'\''>, star<single_string_inner>, sym<'\''>> {}; - struct interp : seq<symx<'#', '{'>, Exp, sym<'}'>> {}; - struct double_string_plain : sor<string<'\\', '\"'>, string<'\\', '\\'>, not_one<'\"'>> {}; - struct double_string_inner : plus<seq<not_at<interp>, double_string_plain>> {}; - struct DoubleString : seq<symx<'\"'>, star<sor<double_string_inner, interp>>, sym<'\"'>> {}; - struct String : sor<seq<Space, DoubleString>, seq<Space, SingleString>, LuaString> {}; - - struct lua_string_open : seq<one<'['>, star<one<'='>>, one<'['>> {}; - struct lua_string_close : seq<one<']'>, star<one<'='>>, one<']'>> {}; - - struct LuaStringOpen - { - using analyze_t = analysis::generic<analysis::rule_type::ANY>; +rule PopDo = user(true_(), [](const item_t& item) +{ + State* st = reinterpret_cast<State*>(item.user_data); + st->doStack.pop(); + return true; +}); - template<apply_mode A, rewind_mode M, - template<typename...> class Action, - template<typename...> class Control, - typename Input> - static bool match(Input& in, State& st) - { - const char* current = in.current(); - if (lua_string_open::match<A, M, Action, Control>(in, st)) - { - st.stringOpen = in.current() - current + 1; - return true; - } - return false; - } - }; +extern rule CompInner; - struct LuaStringClose - { - using analyze_t = analysis::generic<analysis::rule_type::ANY>; +rule Comprehension = sym('[') >> Exp >> CompInner >> sym(']'); +rule TblComprehension = sym('{') >> (Exp >> -(sym(',') >> Exp)) >> CompInner >> sym('}'); - template<apply_mode A, rewind_mode M, - template<typename...> class Action, - template<typename...> class Control, - typename Input> - static bool match(Input& in, State& st) - { - const char* current = in.current(); - if (lua_string_close::match<A, M, Action, Control>(in, st)) - { - return st.stringOpen == in.current() - current + 1; - } - return false; - } - }; +extern rule CompForEach, CompFor, CompClause; - struct LuaStringContent : star<not_at<LuaStringClose>, any> {}; +rule CompInner = (CompForEach | CompFor) >> *CompClause; +rule CompForEach = key("for") >> AssignableNameList >> key("in") >> (sym('*') >> Exp | Exp); +rule CompFor = key("for") >> Name >> sym('=') >> Exp >> sym(',') >> Exp >> (sym(',') >> Exp | Nothing); +rule CompClause = CompFor | CompForEach | key("when") >> Exp; - struct LuaString - { - using analyze_t = analysis::generic<analysis::rule_type::ANY>; +extern rule TableBlock; - template<apply_mode A, rewind_mode M, - template<typename...> class Action, - template<typename...> class Control, - typename Input> - static bool match(Input& in, State& st) - { - bool result = seq<LuaStringOpen, opt<Break>, LuaStringContent, LuaStringClose>::match<A, M, Action, Control>(in, st); - st.stringOpen = -1; - return result; - } - }; +rule Assign = sym('=') >> (With | If | Switch | TableBlock | ExpListLow); - struct Parens : seq<sym<'('>, star<SpaceBreak>, Exp, star<SpaceBreak>, sym<')'>> {}; - struct Callable : sor<Name, SelfName, VarArg, Parens> {}; - - struct FnArgsExpList : seq< - Exp, - star< - sor<Break, sym<','>>, - White, Exp - > - > {}; - - struct FnArgs : sor< - seq<symx<'('>, star<SpaceBreak>, opt<FnArgsExpList>, star<SpaceBreak>, sym<')'>>, - seq<sym<'!'>, not_at<one<'='>>> - > {}; - - struct ChainItems; - struct DotChainItem; - struct ColonChain; - - struct Chain : sor< - seq< - sor<Callable, String, not_at<one<'.', '\\'>>>, - ChainItems - >, - seq<Space, - sor< - seq<DotChainItem, opt<ChainItems>>, - ColonChain - > - > - > {}; - - struct ChainItem; - - struct ChainItems : sor< - seq<plus<ChainItem>, opt<ColonChain>>, - ColonChain - > {}; - - struct Invoke; - struct Slice; - - struct ChainItem : sor< - Invoke, - DotChainItem, - Slice, - seq<symx<'['>, Exp, sym<']'>> - > {}; - - struct DotChainItem : seq<symx<'.'>, _Name> {}; - struct ColonChainItem : seq<symx<'\\'>, _Name> {}; - struct ColonChain : seq< - ColonChainItem, - opt<Invoke, opt<ChainItems>> - > {}; - - struct SliceOne : success {}; - struct SliceTwo : success {}; - struct Slice : seq< - symx<'['>, sor<SliceValue, SliceOne>, sym<','>, sor<SliceValue, SliceTwo>, opt<sym<','>, SliceValue>, sym<']'>> {}; - - struct Invoke : sor< - FnArgs, - SingleString, - DoubleString, - seq<at<one<'['>>, LuaString> - > {}; - - struct KeyValue; - struct TableValueList; - struct TableLitLine; - - struct TableValue : sor<KeyValue, Exp> {}; - struct TableLit : seq< - sym<'{'>, - seq< - opt<TableValueList>, opt<sym<','>>, - opt< - SpaceBreak, TableLitLine, - star<opt<sym<','>>, SpaceBreak, TableLitLine>, - opt<sym<','>> - > - >, - White, sym<'}'> - > {}; - - struct TableValueList : seq<TableValue, star<sym<','>, TableValue>> {}; - struct TableLitLine : sor< - seq<PushIndent, sor<seq<TableValueList, PopIndent>, seq<PopIndent, Cut>>>, - Space - > {}; - - struct KeyValueLine; - - struct TableBlockInner : seq<KeyValueLine, star<plus<SpaceBreak>, KeyValueLine>> {}; - struct TableBlock : seq<plus<SpaceBreak>, Advance, ensure<TableBlockInner, PopIndent>> {}; - - struct Statement; - - struct ClassLine : seq< - CheckIndent, - seq< - sor<KeyValueList, Statement, Exp>, - opt<sym<','>> - > - > {}; - - struct ClassBlock : seq<plus<SpaceBreak>, Advance, ClassLine, star<plus<SpaceBreak>, ClassLine>, PopIndent> {}; - - struct class_no_derive : success {}; - struct class_no_extend : success {}; - struct class_no_body : success {}; - struct ClassDecl : seq< - string<'c', 'l', 'a', 's', 's'>, - not_at<one<':'>>, - sor<Assignable, class_no_derive>, - opt<sor<string<'e', 'x', 't', 'e', 'n', 'd', 's'>, PreventIndent, ensure<Exp, PopIndent>, class_no_extend>>, - sor<ClassBlock, class_no_body> - > {}; - - struct Export : seq< - string<'e', 'x', 'p', 'o', 'r', 't'>, - sor< - ClassDecl, - op<'*'>, - op<'^'>, - seq<NameList, opt<sym<'='>, ExpListLow>> - > - > {}; - - struct KeyValue : sor< - seq<sym<':'>, not_at<SomeSpace>, Name>, - seq< - sor< - KeyName, - seq<sym<'['>, Exp, sym<']'>>, - seq<Space, DoubleString>, - seq<Space, SingleString> - >, - symx<':'>, - sor< - Exp, TableBlock, seq<plus<SpaceBreak>, Exp> - > - > - > {}; - - struct KeyValueList : seq<KeyValue, star<sym<','>, KeyValue>> {}; - struct KeyValueLine : seq<CheckIndent, KeyValueList, opt<sym<','>>> {}; - - struct FnArgDef : seq<sor<Name, SelfName>, opt<sym<'='>, Exp>> {}; - - struct FnArgDefList : sor< - seq< - FnArgDef, - star<sor<sym<','>, Break>, White, FnArgDef>, - star<sor<sym<','>, Break>, White, VarArg> - >, - VarArg - > {}; - - struct outer_value_shadow : seq<string<'u', 's', 'i', 'n', 'g'>, sor<NameList, seq<Space, string<'n', 'i', 'l'>>>> {}; - struct outer_value_no_shadow : success {}; - struct without_args_def : success {}; - - struct FnArgsDef : sor< - seq<sym<'('>, White, opt<FnArgDefList>, - sor< - outer_value_shadow, - outer_value_no_shadow - >, - White, sym<')'> - >, - without_args_def - > {}; - - struct FunLit : seq< - FnArgsDef, - sor< - sym<'-', '>'>, - sym<'=', '>'> - >, - sor<Body, success> - > {}; - - struct NameList : seq<Name, star<sym<','>, Name>> {}; - struct NameOrDestructure : sor<Name, TableLit> {}; - struct AssignableNameList : seq<NameOrDestructure, star<sym<','>, NameOrDestructure>> {}; - - struct ExpList : seq<Exp, star<sym<','>, Exp>> {}; - struct ExpListLow : seq<Exp, star<sor<sym<','>, sym<';'>>, Exp>> {}; - - struct ArgLine : seq<CheckIndent, ExpList> {}; - struct ArgBlock : seq<ArgLine, star<sym<','>, SpaceBreak, ArgLine>, PopIndent> {}; - - struct InvokeArgs : seq< - not_at<one<'-'>>, - sor< - seq< - ExpList, - opt<sor< - seq< - sym<','>, - sor< - TableBlock, seq<SpaceBreak, Advance, ArgBlock, opt<TableBlock>> - > - >, - TableBlock - >> - >, - TableBlock - > - > {}; - - struct SimpleValue : sor< - key<'n', 'i', 'l'>, - key<'t', 'r', 'u', 'e'>, - key<'f', 'a', 'l', 's', 'e'>, - If, Unless, Switch, With, ClassDecl, ForEach, For, While, Do, - seq<sym<'-'>, not_at<SomeSpace>, Exp>, - seq<sym<'#'>, Exp>, - seq<sym<'~'>, Exp>, - seq<key<'n', 'o', 't'>, Exp>, - TblComprehension, - TableLit, - Comprehension, - FunLit, - Num - > {}; - - struct Assignment : seq< - ExpList, - sor<Update, Assign> - > {}; - - struct Statement : seq< - sor< - Import, While, With, For, ForEach, - Switch, Return, Local, Export, BreakLoop, - Assignment, ExpList - >, - Space, - opt< - sor< - seq< - key<'i', 'f'>, Exp, - opt< - key<'e', 'l', 's', 'e'>, Exp - >, - Space - >, - seq<key<'u', 'n', 'l', 'e', 's', 's'>, Exp>, - CompInner - >, - Space - > - > {}; - - struct Body : sor< - seq<opt<Space>, Break, star<EmptyLine>, InBlock>, - Statement - > {}; - - struct Line : sor< - seq<CheckIndent, Statement>, - seq<Space, at<Stop>> - > {}; - - struct Block : seq<Line, star<plus<Break>, Line>> {}; - - struct BlockWithEnd : seq<Block, eof> {}; - - template <class T> - struct NodeBase : Node - { - static int id; - }; +rule Update = +( + sym("..=") | + sym("+=") | + sym("-=") | + sym("*=") | + sym("/=") | + sym("%=") | + sym("or=") | + sym("and=") | + sym("&=") | + sym("|=") | + sym(">>=") | + sym("<<=") +) >> Exp; - template <class T> - int NodeBase<T>::id = MoonType<T>(); +rule CharOperators = Space >> set("+-*/%^><|&"); +rule WordOperators = + opWord("or") | + opWord("and") | + op("<=") | + op(">=") | + op("~=") | + op("!=") | + op("==") | + op("..") | + op("<<") | + op(">>") | + op("//"); - struct ImportNameNode : Node - { - }; +rule BinaryOperator = (WordOperators | CharOperators) >> *SpaceBreak; - struct ImportNameListNode : NodeBase<ImportNameListNode> - { - std::vector<std::shared_ptr<Node>> names; - }; +extern rule Chain; - struct ImportNode : NodeBase<ImportNode> - { - std::shared_ptr<Node> nameList; - std::shared_ptr<Node> exp; - }; +rule Assignable = Chain | Name | SelfName; - template<typename Rule> - struct action : nothing<Rule> {}; +extern rule Value; - template<> - struct action<ImportName> - { - template<typename Input> - static void apply(const Input& in, State& st) - { - auto node = std::make_shared<ImportNameNode>(); - node->token = slice::Slice(in.begin(), in.end() - in.begin()); - node->token.trimSpace(); - st.astStack.pop_back(); - st.astStack.back().push_back(node); - } - }; +rule Exp = Value >> *(BinaryOperator >> Value); - template<> - struct action<Exp> - { - template<typename Input> - static void apply(const Input& in, State& st) - { - auto node = std::make_shared<Node>(); - node->token = slice::Slice(in.begin(), in.end() - in.begin()); - node->token.trimSpace(); - st.astStack.pop_back(); - st.astStack.back().push_back(node); - } - }; +extern rule Callable, InvokeArgs; - template<> - struct action<Import> - { - template<typename Input> - static void apply(const Input& in, State& st) - { - auto node = std::make_shared<ImportNode>(); - node->exp = st.astStack.back().back(); - st.astStack.back().pop_back(); - node->nameList = st.astStack.back().back(); - st.astStack.back().pop_back(); - st.astStack.pop_back(); - st.astStack.back().push_back(node); - } - }; +rule ChainValue = (Chain | Callable) >> (InvokeArgs | Nothing); - template<> - struct action<ImportNameListNode> - { - template<typename Input> - static void apply(const Input& in, State& st) - { - auto node = std::make_shared<ImportNameListNode>(); - node->names = std::move(st.astStack.back()); - st.astStack.pop_back(); - st.astStack.back().push_back(node); - } - }; +extern rule KeyValueList, String, SimpleValue; - template<typename Rule> - struct control : normal<Rule> {}; +rule Value = SimpleValue | KeyValueList | ChainValue | String; +rule SliceValue = Exp; - template<> - struct control<ImportNameListNode> : normal<ImportNameListNode> - { - template<typename Input> - static void start(Input& in, State& st) - { - st.astStack.emplace_back(); - } +extern rule LuaString; - template<typename Input> - static void failure(Input& /*unused*/, State& st) - { - st.astStack.pop_back(); - } +rule single_string_inner = expr("\\'") | "\\\\" | not_(expr('\'')) >> Any; +rule SingleString = symx('\'') >> *single_string_inner >> sym('\''); +rule interp = symx("#{") >> Exp >> sym('}'); +rule double_string_plain = expr("\\\"") | "\\\\" | not_(expr('"')) >> Any; +rule double_string_inner = +(not_(interp) >> double_string_plain); +rule DoubleString = symx('"') >> *(double_string_inner | interp) >> sym('"'); +rule String = Space >> (DoubleString | SingleString | LuaString); - template<typename Input> - static void success(Input& /*unused*/, State& st) - { - } - }; -} +rule lua_string_open = '[' >> *expr('=') >> '['; +rule lua_string_close = ']' >> *expr('=') >> ']'; -int main() +rule LuaStringOpen = user(lua_string_open, [](const item_t& item) { - analyze<moon::BlockWithEnd>(); - moon::State state; - string_input<> inName(R"xoxox( - -Dorothy! -EditMenuView = require "View.Control.Operation.EditMenu" -MessageBox = require "Control.Basic.MessageBox" - --- [no signals] --- [no params] -Class EditMenuView, - __init:=> - {:width} = CCDirector.winSize - isHide = false - - @itemArea\setupMenuScroll @itemMenu - @itemArea.viewSize = @itemMenu\alignItems! - - for child in *@itemMenu.children - child.positionX = -35 - child.visible = false - child.displayed = false - @showItemButtons {"graphic","physics","logic","data"},true,true - - buttonNames = { - "sprite","model","body" - "effect","layer","world" - } + size_t count = std::distance(item.begin, item.end); + State* st = reinterpret_cast<State*>(item.user_data); + st->stringOpen = count; + return true; +}); + +rule LuaStringClose = user(lua_string_close, [](const item_t& item) +{ + size_t count = std::distance(item.begin, item.end); + State* st = reinterpret_cast<State*>(item.user_data); + return st->stringOpen == count; +}); + +rule LuaStringContent = *(not_(LuaStringClose) >> Any); - clearSelection = -> - for name in *buttonNames - with @[name.."Btn"] - if .selected - .selected = false - .color = ccColor3 0x00ffff - .scaleX = 0 - .scaleY = 0 - \perform oScale 0.3,1,1,oEase.OutBack - emit .event,nil - - for name in *buttonNames - with @[name.."Btn"] - .selected = false - upperName = name\sub(1,1)\upper!..name\sub(2,-1) - .event = "Scene."..upperName.."Selected" - @gslot .event,(item)-> - if item - .selected = true - .color = ccColor3 0xff0088 - .scaleX = 0 - .scaleY = 0 - \perform oScale 0.3,1,1,oEase.OutBack - \slot "Tapped",-> - if not .selected - emit "Scene.View"..upperName - clearSelection! - else - .selected = false - .color = ccColor3 0x00ffff - emit .event,nil - - @triggerBtn\slot "Tapped",-> - clearSelection! - if @pickPanel.visible - MessageBox text:"Pick An Item First",okOnly:true - else - emit "Scene.Trigger.Open" - - @actionBtn\slot "Tapped",-> - clearSelection! - if @pickPanel.visible - MessageBox text:"Pick An Item First",okOnly:true - else - emit "Scene.Action.Open" - - @aiBtn\slot "Tapped",-> - clearSelection! - if @pickPanel.visible - MessageBox text:"Pick An Item First",okOnly:true - else - emit "Scene.AITree.Open" - - @unitBtn\slot "Tapped",-> - clearSelection! - if @pickPanel.visible - MessageBox text:"Pick An Item First",okOnly:true - else - emit "Scene.Unit.Open" - - @delBtn\slot "Tapped",-> - clearSelection! - emit "Scene.EditMenu.Delete" - - mode = 0 - @zoomBtn\slot "Tapped",-> - scale = switch mode - when 0 then 2 - when 1 then 0.5 - when 2 then 1 - mode += 1 - mode %= 3 - @zoomBtn.text = string.format("%d%%",scale*100) - emit "Scene.ViewArea.ScaleTo",scale - - @originBtn\slot "Tapped",-> editor\moveTo oVec2.zero - - @progressUp.visible = false - @progressDown.visible = false - - with @upBtn - .visible = false - .enabled = false - \slot "TapBegan",-> - clearSelection! - \schedule once -> - sleep 0.4 - @progressUp.visible = true - @progressUp\play! - \slot "Tapped",-> - if @progressUp.visible - if @progressUp.done - emit "Scene.EditMenu.Top" - else - emit "Scene.EditMenu.Up" - \slot "TapEnded",-> - \unschedule! - if @progressUp.visible - @progressUp.visible = false - - with @downBtn - .visible = false - .enabled = false - \slot "TapBegan",-> - clearSelection! - \schedule once -> - sleep 0.4 - @progressDown.visible = true - @progressDown\play! - \slot "Tapped",-> - if @progressDown.visible - if @progressDown.done - emit "Scene.EditMenu.Bottom" - else - emit "Scene.EditMenu.Down" - \slot "TapEnded",-> - \unschedule! - if @progressDown.visible - @progressDown.visible = false - - with @foldBtn - .visible = false - .enabled = false - \slot "Tapped",-> - clearSelection! - emit "Scene.ViewPanel.Fold",editor.currentData - - with @editBtn - .visible = false - .enabled = false - \slot "Tapped",-> - emit "Scene.SettingPanel.Edit",nil - editor\editCurrentItemInPlace! - - with @menuBtn - .dirty = false - \slot "Tapped",-> - clearSelection! - if .dirty - editor\save! - emit "Scene.Dirty",false - else - ScenePanel = require "Control.Item.ScenePanel" - ScenePanel! - emit "Scene.SettingPanel.Edit",nil - - with @undoBtn - .visible = false - \slot "Tapped",-> - clearSelection! - editor.currentSceneFile = editor.currentSceneFile - emit "Scene.Dirty",false - - with @xFixBtn - .visible = false - \slot "Tapped",(button)-> - editor.xFix = not editor.xFix - if editor.yFix - editor.yFix = false - @yFixBtn.color = ccColor3 0x00ffff - button.color = ccColor3 editor.xFix and 0xff0088 or 0x00ffff - emit "Scene.FixChange" - - with @yFixBtn - .visible = false - \slot "Tapped",(button)-> - editor.yFix = not editor.yFix - if editor.xFix - editor.xFix = false - @xFixBtn.color = ccColor3 0x00ffff - button.color = ccColor3 editor.yFix and 0xff0088 or 0x00ffff - emit "Scene.FixChange" - - @iconCam.visible = false - - currentSubCam = nil - with @camBtn - .visible = false - .editing = false - \gslot "Scene.Camera.Select",(subCam)-> - currentSubCam = subCam - \slot "Tapped",-> - .editing = not .editing - if .editing - emit "Scene.Camera.Activate",currentSubCam - else - emit "Scene.Camera.Activate",nil - - with @zoomEditBtn - .visible = false - .editing = false - \slot "Tapped",-> - .editing = not .editing - if .editing and currentSubCam - emit "Scene.Edit.ShowRuler", {currentSubCam.zoom,0.5,10,1,(value)-> - emit "Scene.ViewArea.Scale",value - } - else - emit "Scene.Edit.ShowRuler",nil - - @playBtn\slot "Tapped",-> - settings = editor\getSettings! - sceneFile = if settings.StartupScene - editor.sceneFullPath..settings.StartupScene..".scene" - else - nil - if not sceneFile or not oContent\exist sceneFile - MessageBox text:"Startup Scene\nIs Required!",okOnly:true - return - @menuBtn\emit "Tapped" if @menuBtn.dirty - -- test codes below - Game = require "Lib.Game.Game" - game = Game editor.game,false - editorData = editor\getEditorData! - editorData.lastScene = editor.lastScene - emit "Scene.EditorData",editorData - editor\emit "Quit",game\loadScene! - - setupItemButton = (button,groupLine,subItems)-> - groupLine.data = button - with button - .showItem = false - \slot "Tapped",-> - return if .scheduled - .showItem = not .showItem - if .showItem - groupLine.visible = true - groupLine.opacity = 0 - groupLine\perform oOpacity 0.3,1 - groupLine.position = button.position-oVec2 25,25 - else - \schedule once -> - groupLine\perform oOpacity 0.3,0 - sleep 0.3 - groupLine.visible = false - @showItemButtons subItems,.showItem - setupItemButton @graphicBtn,@graphicLine,{"sprite","model","effect","layer"} - setupItemButton @physicsBtn,@physicsLine,{"body","world"} - setupItemButton @logicBtn,@logicLine,{"trigger","action","ai"} - setupItemButton @dataBtn,@dataLine,{"unit"} - - @gslot "Scene.ShowFix",(value)-> - editor.xFix = false - editor.yFix = false - emit "Scene.FixChange" - if value - with @xFixBtn - .visible = true - .color = ccColor3 0x00ffff - .scaleX = 0 - .scaleY = 0 - \perform oScale 0.5,1,1,oEase.OutBack - with @yFixBtn - .visible = true - .color = ccColor3 0x00ffff - .scaleX = 0 - .scaleY = 0 - \perform oScale 0.5,1,1,oEase.OutBack - else - @xFixBtn.visible = false - @yFixBtn.visible = false - - @gslot "Scene.Dirty",(dirty)-> - with @menuBtn - if .dirty ~= dirty - .dirty = dirty - if dirty - .text = "Save" - with @undoBtn - if not .visible - .enabled = true - .visible = true - .scaleX = 0 - .scaleY = 0 - \perform oScale 0.3,1,1,oEase.OutBack - else - .color = ccColor3 0x00ffff - .text = "Menu" - with @undoBtn - if .visible - .enabled = false - \perform CCSequence { - oScale 0.3,0,0,oEase.InBack - CCHide! - } - - itemChoosed = (itemData)-> - return if isHide - if @camBtn.visible or @iconCam.visible - @iconCam.visible = false - @camBtn.visible = false - emit "Scene.Camera.Activate",nil - emit "Scene.Camera.Select",nil - emit "Scene.ViewPanel.FoldState",{ - itemData:itemData - handler:(state)-> - if state ~= nil - @setButtonVisible @foldBtn,true - switch itemData.typeName - when "Body","Model","Effect" - @setButtonVisible @editBtn,true - else - @setButtonVisible @editBtn,false - text = @foldBtn.text - targetText = state and "Un\nFold" or "Fold" - if text ~= targetText - @foldBtn.text = targetText - if @foldBtn.scale.done - @setButtonVisible @foldBtn,true - else - @setButtonVisible @foldBtn,false - @setButtonVisible @upBtn,false - @setButtonVisible @downBtn,false - @setButtonVisible @editBtn,false - } - return unless itemData - switch itemData.typeName - when "Camera","PlatformWorld","UILayer" - @setButtonVisible @upBtn,false - @setButtonVisible @downBtn,false - {:x,:y} = @upBtn.position - @foldBtn\runAction oPos 0.3,x,y,oEase.OutQuad - if itemData.typeName == "Camera" - clearSelection! - with @iconCam - .visible = true - .scaleX = 0 - .scaleY = 0 - \perform oScale 0.3,0.5,0.5,oEase.OutBack - else - item = editor\getItem itemData - hasChildren = false - if itemData.typeName == "World" - hasChildren = #item.parent.parent.children > 1 - else - hasChildren = #item.parent.children > 1 - if item.parent.children and hasChildren - @setButtonVisible @upBtn,true - @setButtonVisible @downBtn,true - {:x,:y} = @downBtn.position - @foldBtn\runAction oPos 0.3,x,y-60,oEase.OutQuad - @editBtn\runAction oPos 0.3,x,y-120,oEase.OutQuad - else - @setButtonVisible @upBtn,false - @setButtonVisible @downBtn,false - {:x,:y} = @upBtn.position - @foldBtn\runAction oPos 0.3,x,y,oEase.OutQuad - @editBtn\runAction oPos 0.3,x,y-60,oEase.OutQuad - @gslot "Scene.ViewPanel.Pick",itemChoosed - @gslot "Scene.ViewPanel.Select",itemChoosed - - @gslot "Scene.ViewArea.Scale",(scale)-> - mode = 2 if scale ~= 1 - @zoomBtn.text = string.format("%d%%",scale*100) - @gslot "Scene.ViewArea.ScaleReset",-> - mode = 0 - @zoomBtn.text = "100%" - emit "Scene.ViewArea.ScaleTo",1 - - @gslot "Scene.Camera.Select",(subCam)-> - if subCam and not @camBtn.visible - @iconCam.opacity = 0 - with @camBtn - .visible = true - .scaleX = 0 - .scaleY = 0 - \perform oScale 0.3,1,1,oEase.OutBack - else - @camBtn.visible = false - with @iconCam - .opacity = 1 - .scaleX = 0 - .scaleY = 0 - \perform oScale 0.3,0.5,0.5,oEase.OutBack - - changeDisplay = (child)-> - if child.positionX < width/2 - child\perform oPos 0.5,-child.positionX,child.positionY,oEase.OutQuad - else - child\perform oPos 0.5,width*2-child.positionX,child.positionY,oEase.OutQuad - - @gslot "Scene.HideEditor",(args)-> - {hide,all} = args - return if isHide == hide - isHide = hide - @enabled = @camBtn.editing or not hide - for i = 1,#@children - child = @children[i] - switch child - when @camBtn - posX = @camBtn.editing and width-35 or width-345 - child\perform oPos 0.5,posX,child.positionY,oEase.OutQuad - when @menuBtn,@undoBtn,@zoomEditBtn,@iconCam - if all - changeDisplay child - else - continue - else - changeDisplay child - - @gslot "Scene.Camera.Activate",(subCam)-> - editor.isFixed = not @camBtn.editing - if subCam - with @zoomEditBtn - .scaleX = 0 - .scaleY = 0 - .visible = true - \perform CCSequence { - CCDelay 0.5 - oScale 0.3,1,1,oEase.OutBack - } - else - @zoomEditBtn.visible = false - @zoomEditBtn.editing = false - emit "Scene.Edit.ShowRuler",nil - - @gslot "Scene.EditMenu.ClearSelection",clearSelection - - setButtonVisible:(button,visible)=> - return if visible == button.enabled - button.enabled = visible - if visible - if not button.visible - button.visible = true - button.scaleX = 0 - button.scaleY = 0 - button\perform oScale 0.3,1,1,oEase.OutBack - else - button\perform CCSequence { - oScale 0.3,0,0,oEase.InBack - CCHide! - } - - showItemButtons:(names,visible,instant=false)=> - buttonSet = {@["#{name}Btn"],true for name in *names} - posX = 35 - posY = @itemMenu.height-25 - if visible - offset = @itemArea.offset - firstItem = nil - for child in *@itemMenu.children - isTarget = buttonSet[child] - firstItem = child if isTarget and not firstItem - if child.displayed or isTarget - offsetX = switch child - when @graphicBtn,@physicsBtn,@logicBtn,@dataBtn then 0 - else 20 - child.position = offset+oVec2(posX+offsetX,posY) - if isTarget - child.displayed = true - child.visible = true - if not instant - child.face.scaleY = 0 - child.face\perform oScale 0.3,1,1,oEase.OutBack - posY -= 60 - elseif child.data -- data is parentButton - child.position = child.data.position-oVec2(25,25) - @itemArea.viewSize = CCSize 70,@itemArea.height-posY-35 - @itemArea\scrollToPosY firstItem.positionY - else - @itemMenu\schedule once -> - if not instant - for child in *@itemMenu.children - if buttonSet[child] - child.face\perform oScale 0.3,1,0,oEase.OutQuad - sleep 0.3 - offset = @itemArea.offset - lastPosY = nil - for child in *@itemMenu.children - if buttonSet[child] - child.positionX = -35 - child.displayed = false - child.visible = false - lastPosY = child.positionY - elseif child.displayed - if lastPosY and child.positionY < lastPosY - child.face.scaleY = 0 - child.face\perform oScale 0.3,1,1,oEase.OutBack - offsetX = switch child - when @graphicBtn,@physicsBtn,@logicBtn,@dataBtn then 0 - else 20 - child.position = offset+oVec2(posX+offsetX,posY) - posY -= 60 - elseif lastPosY and child.data and child.positionY < lastPosY - child.opacity = 0 - child\perform oOpacity 0.3,1 - child.position = child.data.position-oVec2(25,25) - @itemArea.viewSize = CCSize 70,@itemArea.height-posY-35 - -)xoxox", "abc"); - - string_input<> in(R"PIG(import Path, Struct from require "utils")PIG", "bcd"); - try +rule LuaString = user(LuaStringOpen >> -Break >> LuaStringContent >> LuaStringClose, [](const item_t& item) +{ + State* st = reinterpret_cast<State*>(item.user_data); + st->stringOpen = -1; + return true; +}); + +rule Parens = sym('(') >> *SpaceBreak >> Exp >> *SpaceBreak >> sym(')'); +rule Callable = Name | SelfName | VarArg | Parens; +rule FnArgsExpList = Exp >> *((Break | sym(',')) >> White >> Exp); + +rule FnArgs = +( + symx('(') >> *SpaceBreak >> (FnArgsExpList | Nothing) >> *SpaceBreak >> sym(')') +) | ( + sym('!') >> not_(expr('=')) >> Nothing +); + +extern rule ChainItems, DotChainItem, ColonChain; + +rule chain_call = (Callable | String) >> ChainItems; +rule chain_item = not_(set(".\\")) >> ChainItems; +rule chain_dot_chain = DotChainItem >> (ChainItems | Nothing); + +rule Chain = + chain_call | + chain_item | + Space >> (chain_dot_chain | ColonChain); + +extern rule ChainItem; + +rule chain_items = +ChainItem >> (ColonChain | Nothing); +rule ChainItems = chain_items | ColonChain; + +extern rule Invoke, Slice; + +rule ChainItem = Invoke | DotChainItem | Slice | symx('[') >> Exp >> sym(']'); +rule DotChainItem = symx('.') >> _Name; +rule ColonChainItem = symx('\\') >> _Name; +rule ColonChain = ColonChainItem >> ((Invoke >> (ChainItems | Nothing)) | Nothing >> Nothing); + +rule Slice = + symx('[') >> + (SliceValue | Nothing) >> + sym(',') >> + (SliceValue | Nothing) >> + (sym(',') >> + SliceValue | Nothing) >> + sym(']'); + +rule Invoke = + FnArgs | + SingleString | + DoubleString | + and_(expr('[')) >> LuaString; + +extern rule KeyValue, TableValueList, TableLitLine; + +rule TableValue = KeyValue | Exp; + +rule table_lit_lines = SpaceBreak >> TableLitLine >> *(-sym(',') >> SpaceBreak >> TableLitLine) >> -sym(','); + +rule TableLit = + sym('{') >> + (TableValueList | Nothing) >> + -sym(',') >> + (table_lit_lines | Nothing) >> + White >> sym('}'); + +rule TableValueList = TableValue >> *(sym(',') >> TableValue); + +rule TableLitLine = +( + PushIndent >> (TableValueList >> PopIndent | PopIndent) +) | ( + Space >> Nothing +); + +extern rule KeyValueLine; + +rule TableBlockInner = KeyValueLine >> *(+(SpaceBreak) >> KeyValueLine); +rule TableBlock = +(SpaceBreak) >> Advance >> ensure(TableBlockInner, PopIndent); + +extern rule Statement; + +rule ClassLine = CheckIndent >> (KeyValueList | Statement | Exp) >> -sym(','); +rule ClassBlock = +(SpaceBreak) >> Advance >> ClassLine >> *(+(SpaceBreak) >> ClassLine) >> PopIndent; + +rule ClassDecl = + key("class") >> not_(expr(':')) >> + (Assignable | Nothing) >> + (key("extends") >> PreventIndent >> ensure(Exp, PopIndent) | Nothing) >> + (ClassBlock | Nothing); + +rule export_values = sym('=') >> ExpListLow; +rule Export = key("export") >> (ClassDecl | op('*') | op('^') | NameList >> (export_values | Nothing)); + +rule KeyValue = +( + sym(':') >> not_(SomeSpace) >> Name +) | ( + (KeyName | + sym('[') >> Exp >> sym(']') | + Space >> DoubleString | + Space >> SingleString + ) >> + symx(':') >> + (Exp | TableBlock | +(SpaceBreak) >> Exp) +); + +rule KeyValueList = KeyValue >> *(sym(',') >> KeyValue); +rule KeyValueLine = CheckIndent >> KeyValueList >> -sym(','); + +rule FnArgDef = (Name | SelfName) >> (sym('=') >> Exp | Nothing); + +rule FnArgDefList = +( + FnArgDef >> + *((sym(',') | Break) >> White >> FnArgDef) >> + ((sym(',') | Break) >> White >> VarArg | Nothing) +) | ( + VarArg +); + +rule outer_value_shadow = key("using") >> (NameList | Space >> expr("nil")); + +rule normal_fn_args_def = + sym('(') >> White >> (FnArgDefList | Nothing) >> (outer_value_shadow | Nothing) >> White >> sym(')'); + +rule FnArgsDef = normal_fn_args_def | Nothing; +rule fn_arrow = sym("->"); +rule fat_arrow = sym("=>"); +rule FunLit = FnArgsDef >> (fn_arrow | fat_arrow) >> (Body | Nothing); + +rule NameList = Name >> *(sym(',') >> Name); +rule NameOrDestructure = Name | TableLit; +rule AssignableNameList = NameOrDestructure >> *(sym(',') >> NameOrDestructure); + +rule ExpList = Exp >> *(sym(',') >> Exp); +rule ExpListLow = Exp >> *((sym(',') | sym(';')) >> Exp); + +rule ArgLine = CheckIndent >> ExpList; +rule ArgBlock = ArgLine >> *(sym(',') >> SpaceBreak >> ArgLine) >> PopIndent; + +rule invoke_args_with_table = + sym(',') >> + ( + TableBlock >> Nothing | + SpaceBreak>> Advance >> ArgBlock >> (TableBlock | Nothing) + ); + +rule InvokeArgs = + not_(expr('-')) >> + ( + ExpList >> (invoke_args_with_table | TableBlock | Nothing) | + TableBlock >> Nothing + ); + +rule SimpleValue = + key("nil") | key("true") | key("false") | + If | Unless | Switch | With | ClassDecl | ForEach | For | While | Do | + sym('-') >> not_(SomeSpace) >> Exp | + sym('#') >> Exp | + sym('~') >> Exp | + key("not") >> Exp | + TblComprehension | TableLit | Comprehension | FunLit | Num; + +rule Assignment = ExpList >> (Update | Assign); + +rule if_else_line = key("if") >> Exp >> (key("else") >> Exp | Nothing); +rule unless_line = key("unless") >> Exp; + +rule Statement = +( + Import | While | With | For | ForEach | + Switch | Return | Local | Export | BreakLoop | + Assignment | ExpList +) >> Space >> +( + (if_else_line | unless_line | CompInner) >> Space | Nothing +); + +rule Body = -Space >> Break >> *EmptyLine >> InBlock | Statement; + +rule empty_line_stop = Space >> and_(Stop); +rule Line = CheckIndent >> Statement | empty_line_stop; +rule Block = Line >> *(+Break >> Line); +rule BlockWithEnd = Block >> eof(); + +class AstNode : public ast_container +{ +public: + virtual void construct(ast_stack& st) { - if (parse<must<moon::Import, eof>, moon::action, moon::control>(in, state)) + stringstream stream; + for (input::iterator it = m_begin.m_it; it != m_end.m_it; ++it) { - std::cout << "matched.\n"; - } - else - { - std::cout << "not matched.\n"; + stream << (char)*it; } + _value = stream.str(); } - catch (parse_error e) + void print() { - std::cout << "not matched.\n"; - std::cout << e.what() << '\n'; + cout << _value << '\n'; } -/* - analyze<hello::expr>(); - const char* text = "1 + 2 + 3 * 4 / 2"; - string_input<> in(text, "abc"); - try +private: + string _value; +}; + +rule ExprEnd = Block >> eof(); + +ast<AstNode> testNode(ExprEnd); + +int main() +{ + string s = R"baddog()baddog"; + input i(s.begin(), s.end()); + + error_list el; + AstNode* root = nullptr; + State st; + if (parse(i, ExprEnd, el, root, &st)) { - hello::Stack stack; - if (parse<hello::expr, hello::action>(in, stack)) - { - std::cout << text << " = " << stack.getValue() << '\n'; - } - return 0; + cout << "matched!\n"; } - catch (parse_error e) + else { - std::cout << e.what() << '\n'; - return 1; + cout << "not matched!\n"; + for (error_list::iterator it = el.begin(); it != el.end(); ++it) + { + const error& err = *it; + cout << "line " << err.m_begin.m_line << ", col " << err.m_begin.m_col << ": syntax error\n"; + } } -*/ + system("pause"); return 0; } diff --git a/MoonParser/parser.cpp b/MoonParser/parser.cpp new file mode 100644 index 0000000..5a7da73 --- /dev/null +++ b/MoonParser/parser.cpp @@ -0,0 +1,1462 @@ +#include <cstdlib> +#include <cstring> +#include <cassert> +#include <stdexcept> +#include <unordered_map> +#include "parser.hpp" + + +namespace parserlib { + + +//internal map from rules to parse procs +typedef std::unordered_map<rule *, parse_proc> _parse_proc_map_t; + +//on exit, it deletes the parse proc map +static _parse_proc_map_t& _get_parse_proc_map() { + static _parse_proc_map_t _parse_proc_map; + return _parse_proc_map; +} + + +//get the parse proc from the map +static parse_proc _get_parse_proc(rule *r) { + _parse_proc_map_t& _parse_proc_map = _get_parse_proc_map(); + _parse_proc_map_t::iterator it = _parse_proc_map.find(r); + if (it == _parse_proc_map.end()) return 0; + return it->second; +} + + +//internal private class that manages access to the public classes' internals. +class _private { +public: + //get the internal expression object from the expression. + static _expr *get_expr(const expr &e) { + return e.m_expr; + } + + //create new expression from given expression + static expr construct_expr(_expr *e) { + return e; + } + + //get the internal expression object from the rule. + static _expr *get_expr(rule &r) { + return r.m_expr; + } + + //get the internal parse proc from the rule. + static parse_proc get_parse_proc(rule &r) { + return r.m_parse_proc; + } +}; + + +class _context; + + +//parser state +class _state { +public: + //position + pos m_pos; + + //size of match vector + size_t m_matches; + + //constructor + _state(_context &con); +}; + + +//match +class _match { +public: + //rule matched + rule *m_rule; + + //begin position + pos m_begin; + + //end position + pos m_end; + + //null constructor + _match() {} + + //constructor from parameters + _match(rule *r, const pos &b, const pos &e) : + m_rule(r), + m_begin(b), + m_end(e) + { + } +}; + + +//match vector +typedef std::vector<_match> _match_vector; + + +//parsing context +class _context { +public: + //user data + void* m_user_data; + + //current position + pos m_pos; + + //error position + pos m_error_pos; + + //input begin + input::iterator m_begin; + + //input end + input::iterator m_end; + + //matches + _match_vector m_matches; + + //constructor + _context(input &i, void* ud) : + m_user_data(ud), + m_pos(i), + m_error_pos(i), + m_begin(i.begin()), + m_end(i.end()) + { + } + + //check if the end is reached + bool end() const { + return m_pos.m_it == m_end; + } + + //get the current symbol + int symbol() const { + assert(!end()); + return *m_pos.m_it; + } + + //set the longest possible error + void set_error_pos() { + if (m_pos.m_it > m_error_pos.m_it) { + m_error_pos = m_pos; + } + } + + //next column + void next_col() { + ++m_pos.m_it; + ++m_pos.m_col; + } + + //next line + void next_line() { + ++m_pos.m_line; + m_pos.m_col = 1; + } + + //restore the state + void restore(const _state &st) { + m_pos = st.m_pos; + m_matches.resize(st.m_matches); + } + + //parse non-term rule. + bool parse_non_term(rule &r); + + //parse term rule. + bool parse_term(rule &r); + + //execute all the parse procs + void do_parse_procs(void *d) const { + for(_match_vector::const_iterator it = m_matches.begin(); + it != m_matches.end(); + ++it) + { + const _match &m = *it; + parse_proc p = _private::get_parse_proc(*m.m_rule); + p(m.m_begin, m.m_end, d); + } + } + +private: + //parse non-term rule. + bool _parse_non_term(rule &r); + + //parse term rule. + bool _parse_term(rule &r); +}; + + +//base class for expressions +class _expr { +public: + //destructor. + virtual ~_expr() { + } + + //parse with whitespace + virtual bool parse_non_term(_context &con) const = 0; + + //parse terminal + virtual bool parse_term(_context &con) const = 0; +}; + + +//single character expression. +class _char : public _expr { +public: + //constructor. + _char(int c) : + m_char(c) + { + } + + //parse with whitespace + virtual bool parse_non_term(_context &con) const { + return _parse(con); + } + + //parse terminal + virtual bool parse_term(_context &con) const { + return _parse(con); + } + +private: + //character + int m_char; + + //internal parse + bool _parse(_context &con) const { + if (!con.end()) { + int ch = con.symbol(); + if (ch == m_char) { + con.next_col(); + return true; + } + } + con.set_error_pos(); + return false; + } +}; + + +//string expression. +class _string : public _expr { +public: + //constructor from ansi string. + _string(const char *s) : + m_string(s, s + strlen(s)) + { + } + + //constructor from wide string. + _string(const wchar_t *s) : + m_string(s, s + wcslen(s)) + { + } + + //parse with whitespace + virtual bool parse_non_term(_context &con) const { + return _parse(con); + } + + //parse terminal + virtual bool parse_term(_context &con) const { + return _parse(con); + } + +private: + //string + std::vector<int> m_string; + + //parse the string + bool _parse(_context &con) const { + for(std::vector<int>::const_iterator it = m_string.begin(), + end = m_string.end();;) + { + if (it == end) return true; + if (con.end()) break; + if (con.symbol() != *it) break; + ++it; + con.next_col(); + } + con.set_error_pos(); + return false; + } +}; + + +//set expression. +class _set : public _expr { +public: + //constructor from ansi string. + _set(const char *s) { + for(; *s; ++s) { + _add(*s); + } + } + + //constructor from wide string. + _set(const wchar_t *s) { + for(; *s; ++s) { + _add(*s); + } + } + + //constructor from range. + _set(int min, int max) { + assert(min >= 0); + assert(min <= max); + m_set.resize((size_t)max + 1U); + for(; min <= max; ++min) { + m_set[(size_t)min] = true; + } + } + + //parse with whitespace + virtual bool parse_non_term(_context &con) const { + return _parse(con); + } + + //parse terminal + virtual bool parse_term(_context &con) const { + return _parse(con); + } + +private: + //set is kept as an array of flags, for quick access + std::vector<bool> m_set; + + //add character + void _add(size_t i) { + if (i >= m_set.size()) { + m_set.resize(i + 1); + } + m_set[i] = true; + } + + //internal parse + bool _parse(_context &con) const { + if (!con.end()) { + size_t ch = con.symbol(); + if (ch < m_set.size() && m_set[ch]) { + con.next_col(); + return true; + } + } + con.set_error_pos(); + return false; + } +}; + + +//base class for unary expressions +class _unary : public _expr { +public: + //constructor. + _unary(_expr *e) : + m_expr(e) + { + } + + //destructor. + virtual ~_unary() { + delete m_expr; + } + +protected: + //expression + _expr *m_expr; +}; + + +//terminal +class _term : public _unary { +public: + //constructor. + _term(_expr *e) : + _unary(e) + { + } + + //parse with whitespace + virtual bool parse_non_term(_context &con) const { + return m_expr->parse_term(con); + } + + //parse terminal + virtual bool parse_term(_context &con) const { + return m_expr->parse_term(con); + } +}; + + +//user +class _user : public _unary { +public: + //constructor. + _user(_expr *e, const user_handler &callback) : + _unary(e), + m_handler(callback) + { + } + + //parse with whitespace + virtual bool parse_non_term(_context &con) const { + pos pos = con.m_pos; + if (m_expr->parse_non_term(con)) { + item_t item = {pos.m_it, con.m_pos.m_it, con.m_user_data}; + return m_handler(item); + } + return false; + } + + //parse terminal + virtual bool parse_term(_context &con) const { + pos pos = con.m_pos; + if (m_expr->parse_term(con)) { + item_t item = {pos.m_it, con.m_pos.m_it, con.m_user_data}; + return m_handler(item); + } + return false; + } +private: + user_handler m_handler; +}; + + +//loop 0 +class _loop0 : public _unary { +public: + //constructor. + _loop0(_expr *e) : + _unary(e) + { + } + + //parse with whitespace + virtual bool parse_non_term(_context &con) const { + //if parsing of the first fails, restore the context and stop + _state st(con); + if (!m_expr->parse_non_term(con)) { + con.restore(st); + return true; + } + + //parse the rest + for(;;) { + _state st(con); + if (!m_expr->parse_non_term(con)) { + con.restore(st); + break; + } + } + + return true; + } + + //parse terminal + virtual bool parse_term(_context &con) const { + //if parsing of the first fails, restore the context and stop + _state st(con); + if (!m_expr->parse_term(con)) { + con.restore(st); + return true; + } + + //parse the rest until no more parsing is possible + for(;;) { + _state st(con); + if (!m_expr->parse_term(con)) { + con.restore(st); + break; + } + } + + return true; + } +}; + + +//loop 1 +class _loop1 : public _unary { +public: + //constructor. + _loop1(_expr *e) : + _unary(e) + { + } + + //parse with whitespace + virtual bool parse_non_term(_context &con) const { + //parse the first; if the first fails, stop + if (!m_expr->parse_non_term(con)) return false; + + //parse the rest until no more parsing is possible + for(;;) { + _state st(con); + if (!m_expr->parse_non_term(con)) { + con.restore(st); + break; + } + } + + return true; + } + + //parse terminal + virtual bool parse_term(_context &con) const { + //parse the first; if the first fails, stop + if (!m_expr->parse_term(con)) return false; + + //parse the rest until no more parsing is possible + for(;;) { + _state st(con); + if (!m_expr->parse_term(con)) { + con.restore(st); + break; + } + } + + return true; + } +}; + + +//optional +class _optional : public _unary { +public: + //constructor. + _optional(_expr *e) : + _unary(e) + { + } + + //parse with whitespace + virtual bool parse_non_term(_context &con) const { + _state st(con); + if (!m_expr->parse_non_term(con)) con.restore(st); + return true; + } + + //parse terminal + virtual bool parse_term(_context &con) const { + _state st(con); + if (!m_expr->parse_term(con)) con.restore(st); + return true; + } +}; + + +//and +class _and : public _unary { +public: + //constructor. + _and(_expr *e) : + _unary(e) + { + } + + //parse with whitespace + virtual bool parse_non_term(_context &con) const { + _state st(con); + bool ok = m_expr->parse_non_term(con); + con.restore(st); + return ok; + } + + //parse terminal + virtual bool parse_term(_context &con) const { + _state st(con); + bool ok = m_expr->parse_term(con); + con.restore(st); + return ok; + } +}; + + +//not +class _not : public _unary { +public: + //constructor. + _not(_expr *e) : + _unary(e) + { + } + + //parse with whitespace + virtual bool parse_non_term(_context &con) const { + _state st(con); + bool ok = !m_expr->parse_non_term(con); + con.restore(st); + return ok; + } + + //parse terminal + virtual bool parse_term(_context &con) const { + _state st(con); + bool ok = !m_expr->parse_term(con); + con.restore(st); + return ok; + } +}; + + +//newline +class _nl : public _unary { +public: + //constructor. + _nl(_expr *e) : + _unary(e) + { + } + + //parse with whitespace + virtual bool parse_non_term(_context &con) const { + if (!m_expr->parse_non_term(con)) return false; + con.next_line(); + return true; + } + + //parse terminal + virtual bool parse_term(_context &con) const { + if (!m_expr->parse_term(con)) return false; + con.next_line(); + return true; + } +}; + + +//base class for binary expressions +class _binary : public _expr { +public: + //constructor. + _binary(_expr *left, _expr *right) : + m_left(left), m_right(right) + { + } + + //destructor. + virtual ~_binary() { + delete m_left; + delete m_right; + } + +protected: + //left and right expressions + _expr *m_left, *m_right; +}; + + +//sequence +class _seq : public _binary { +public: + //constructor. + _seq(_expr *left, _expr *right) : + _binary(left, right) + { + } + + //parse with whitespace + virtual bool parse_non_term(_context &con) const { + if (!m_left->parse_non_term(con)) return false; + return m_right->parse_non_term(con); + } + + //parse terminal + virtual bool parse_term(_context &con) const { + if (!m_left->parse_term(con)) return false; + return m_right->parse_term(con); + } +}; + + +//choice +class _choice : public _binary { +public: + //constructor. + _choice(_expr *left, _expr *right) : + _binary(left, right) + { + } + + //parse with whitespace + virtual bool parse_non_term(_context &con) const { + _state st(con); + if (m_left->parse_non_term(con)) return true; + con.restore(st); + return m_right->parse_non_term(con); + } + + //parse terminal + virtual bool parse_term(_context &con) const { + _state st(con); + if (m_left->parse_term(con)) return true; + con.restore(st); + return m_right->parse_term(con); + } +}; + + +//reference to rule +class _ref : public _expr { +public: + //constructor. + _ref(rule &r) : + m_rule(r) + { + } + + //parse with whitespace + virtual bool parse_non_term(_context &con) const { + return con.parse_non_term(m_rule); + } + + //parse terminal + virtual bool parse_term(_context &con) const { + return con.parse_term(m_rule); + } + +private: + //reference + rule &m_rule; +}; + + +//eof +class _eof : public _expr { +public: + //parse with whitespace + virtual bool parse_non_term(_context &con) const { + return parse_term(con); + } + + //parse terminal + virtual bool parse_term(_context &con) const { + return con.end(); + } +}; + + +//any +class _any : public _expr { +public: + //parse with whitespace + virtual bool parse_non_term(_context &con) const { + return parse_term(con); + } + + //parse terminal + virtual bool parse_term(_context &con) const { + if (!con.end()) { + con.next_col(); + return true; + } + con.set_error_pos(); + return false; + } +}; + + +//true +class _true : public _expr { +public: + //parse with whitespace + virtual bool parse_non_term(_context &con) const { + return true; + } + + //parse terminal + virtual bool parse_term(_context &con) const { + return true; + } +}; + + +//false +class _false: public _expr { +public: + //parse with whitespace + virtual bool parse_non_term(_context &con) const { + return false; + } + + //parse terminal + virtual bool parse_term(_context &con) const { + return false; + } +}; + +//exception thrown when left recursion terminates successfully +struct _lr_ok { + rule *m_rule; + _lr_ok(rule *r) : m_rule(r) {} +}; + + +//constructor +_state::_state(_context &con) : + m_pos(con.m_pos), + m_matches(con.m_matches.size()) +{ +} + + +//parse non-term rule. +bool _context::parse_non_term(rule &r) { + //save the state of the rule + rule::_state old_state = r.m_state; + + //success/failure result + bool ok; + + //compute the new position + size_t new_pos = m_pos.m_it - m_begin; + + //check if we have left recursion + bool lr = new_pos == r.m_state.m_pos; + + //update the rule's state + r.m_state.m_pos = new_pos; + + //handle the mode of the rule + switch (r.m_state.m_mode) { + //normal parse + case rule::_PARSE: + if (lr) { + //first try to parse the rule by rejecting it, so alternative branches are examined + r.m_state.m_mode = rule::_REJECT; + ok = _parse_non_term(r); + + //if the first try is successful, try accepting the rule, + //so other elements of the sequence are parsed + if (ok) { + r.m_state.m_mode = rule::_ACCEPT; + + //loop until no more parsing can be done + for(;;) { + //store the correct state, in order to backtrack if the call fails + _state st(*this); + + //update the rule position to the current position, + //because at this state the rule is resolving the left recursion + r.m_state.m_pos = m_pos.m_it - m_begin; + + //if parsing fails, restore the last good state and stop + if (!_parse_non_term(r)) { + restore(st); + break; + } + } + + //since the left recursion was resolved successfully, + //return via a non-local exit + r.m_state = old_state; + throw _lr_ok(r.this_ptr()); + } + } + else { + try { + ok = _parse_non_term(r); + } + catch (const _lr_ok &ex) { + //since left recursions may be mutual, we must test which rule's left recursion + //was ended successfully + if (ex.m_rule == r.this_ptr()) { + ok = true; + } + else { + r.m_state = old_state; + throw; + } + } + } + break; + + //reject the left recursive rule + case rule::_REJECT: + if (lr) { + ok = false; + } + else { + r.m_state.m_mode = rule::_PARSE; + ok = _parse_non_term(r); + r.m_state.m_mode = rule::_REJECT; + } + break; + + //accept the left recursive rule + case rule::_ACCEPT: + if (lr) { + ok = true; + } + else { + r.m_state.m_mode = rule::_PARSE; + ok = _parse_non_term(r); + r.m_state.m_mode = rule::_ACCEPT; + } + break; + } + + //restore the rule's state + r.m_state = old_state; + + return ok; +} + + +//parse term rule. +bool _context::parse_term(rule &r) { + //save the state of the rule + rule::_state old_state = r.m_state; + + //success/failure result + bool ok; + + //compute the new position + size_t new_pos = m_pos.m_it - m_begin; + + //check if we have left recursion + bool lr = new_pos == r.m_state.m_pos; + + //update the rule's state + r.m_state.m_pos = new_pos; + + //handle the mode of the rule + switch (r.m_state.m_mode) { + //normal parse + case rule::_PARSE: + if (lr) { + //first try to parse the rule by rejecting it, so alternative branches are examined + r.m_state.m_mode = rule::_REJECT; + ok = _parse_term(r); + + //if the first try is successful, try accepting the rule, + //so other elements of the sequence are parsed + if (ok) { + r.m_state.m_mode = rule::_ACCEPT; + + //loop until no more parsing can be done + for(;;) { + //store the correct state, in order to backtrack if the call fails + _state st(*this); + + //update the rule position to the current position, + //because at this state the rule is resolving the left recursion + r.m_state.m_pos = m_pos.m_it - m_begin; + + //if parsing fails, restore the last good state and stop + if (!_parse_term(r)) { + restore(st); + break; + } + } + + //since the left recursion was resolved successfully, + //return via a non-local exit + r.m_state = old_state; + throw _lr_ok(r.this_ptr()); + } + } + else { + try { + ok = _parse_term(r); + } + catch (const _lr_ok &ex) { + //since left recursions may be mutual, we must test which rule's left recursion + //was ended successfully + if (ex.m_rule == r.this_ptr()) { + ok = true; + } + else { + r.m_state = old_state; + throw; + } + } + } + break; + + //reject the left recursive rule + case rule::_REJECT: + if (lr) { + ok = false; + } + else { + r.m_state.m_mode = rule::_PARSE; + ok = _parse_term(r); + r.m_state.m_mode = rule::_REJECT; + } + break; + + //accept the left recursive rule + case rule::_ACCEPT: + if (lr) { + ok = true; + } + else { + r.m_state.m_mode = rule::_PARSE; + ok = _parse_term(r); + r.m_state.m_mode = rule::_ACCEPT; + } + break; + } + + //restore the rule's state + r.m_state = old_state; + + return ok; +} + + +//parse non-term rule internal. +bool _context::_parse_non_term(rule &r) { + bool ok; + if (_private::get_parse_proc(r)) { + pos b = m_pos; + ok = _private::get_expr(r)->parse_non_term(*this); + if (ok) { + m_matches.push_back(_match(r.this_ptr(), b, m_pos)); + } + } + else { + ok = _private::get_expr(r)->parse_non_term(*this); + } + return ok; +} + + +//parse term rule internal. +bool _context::_parse_term(rule &r) { + bool ok; + if (_private::get_parse_proc(r)) { + pos b = m_pos; + ok = _private::get_expr(r)->parse_term(*this); + if (ok) { + m_matches.push_back(_match(r.this_ptr(), b, m_pos)); + } + } + else { + ok = _private::get_expr(r)->parse_term(*this); + } + return ok; +} + + +//get syntax error +static error _syntax_error(_context &con) { + return error(con.m_error_pos, con.m_error_pos, ERROR_SYNTAX_ERROR); +} + + +//get eof error +static error _eof_error(_context &con) { + return error(con.m_error_pos, con.m_error_pos, ERROR_INVALID_EOF); +} + + +/** constructor from input. + @param i input. + */ +pos::pos(input &i) : + m_it(i.begin()), + m_line(1), + m_col(1) +{ +} + + +/** character terminal constructor. + @param c character. + */ +expr::expr(int c) : + m_expr(new _char(c)) +{ +} + + +/** null-terminated string terminal constructor. + @param s null-terminated string. + */ +expr::expr(const char *s) : + m_expr(new _string(s)) +{ +} + + +/** null-terminated wide string terminal constructor. + @param s null-terminated string. + */ +expr::expr(const wchar_t *s) : + m_expr(new _string(s)) +{ +} + + +/** rule reference constructor. + @param r rule. + */ +expr::expr(rule &r) : + m_expr(new _ref(r)) +{ +} + + +/** creates a zero-or-more loop out of this expression. + @return a zero-or-more loop expression. + */ +expr expr::operator *() const { + return _private::construct_expr(new _loop0(m_expr)); +} + + +/** creates a one-or-more loop out of this expression. + @return a one-or-more loop expression. + */ +expr expr::operator +() const { + return _private::construct_expr(new _loop1(m_expr)); +} + + +/** creates an optional out of this expression. + @return an optional expression. + */ +expr expr::operator -() const { + return _private::construct_expr(new _optional(m_expr)); +} + + +/** creates an AND-expression. + @return an AND-expression. + */ +expr expr::operator &() const { + return _private::construct_expr((new _and(m_expr))); +} + + +/** creates a NOT-expression. + @return a NOT-expression. + */ +expr expr::operator !() const { + return _private::construct_expr(new _not(m_expr)); +} + + +/** constructor. + @param b begin position. + @param e end position. + */ +input_range::input_range(const pos &b, const pos &e) : + m_begin(b), + m_end(e) +{ +} + + +/** constructor. + @param b begin position. + @param e end position. + @param t error type. + */ +error::error(const pos &b, const pos &e, int t) : + input_range(b, e), + m_type(t) +{ +} + + +/** compare on begin position. + @param e the other error to compare this with. + @return true if this comes before the previous error, false otherwise. + */ +bool error::operator < (const error &e) const { + return m_begin.m_it < e.m_begin.m_it; +} + + +/** character terminal constructor. + @param c character. + */ +rule::rule(int c) : + m_expr(new _char(c)) +{ + m_parse_proc = _get_parse_proc(this); +} + + +/** null-terminated string terminal constructor. + @param s null-terminated string. + */ +rule::rule(const char *s) : + m_expr(new _string(s)) +{ + m_parse_proc = _get_parse_proc(this); +} + + +/** null-terminated wide string terminal constructor. + @param s null-terminated string. + */ +rule::rule(const wchar_t *s) : + m_expr(new _string(s)) +{ + m_parse_proc = _get_parse_proc(this); +} + + +/** constructor from expression. + @param e expression. + */ +rule::rule(const expr &e) : + m_expr(_private::get_expr(e)) +{ + m_parse_proc = _get_parse_proc(this); +} + + +/** constructor from rule. + @param r rule. + */ +rule::rule(rule &r) : + m_expr(new _ref(r)), + m_parse_proc(0) +{ + m_parse_proc = _get_parse_proc(this); +} + + +/** invalid constructor from rule (required by gcc). + @param r rule. + @exception std::logic_error always thrown. + */ +rule::rule(const rule &r) { + throw std::logic_error("invalid operation"); +} + + +/** deletes the internal object that represents the expression. + */ +rule::~rule() { + delete m_expr; +} + + +/** creates a zero-or-more loop out of this rule. + @return a zero-or-more loop rule. + */ +expr rule::operator *() { + return _private::construct_expr(new _loop0(new _ref(*this))); +} + + +/** creates a one-or-more loop out of this rule. + @return a one-or-more loop rule. + */ +expr rule::operator +() { + return _private::construct_expr(new _loop1(new _ref(*this))); +} + + +/** creates an optional out of this rule. + @return an optional rule. + */ +expr rule::operator -() { + return _private::construct_expr(new _optional(new _ref(*this))); +} + + +/** creates an AND-expression out of this rule. + @return an AND-expression out of this rule. + */ +expr rule::operator &() { + return _private::construct_expr(new _and(new _ref(*this))); +} + + +/** creates a NOT-expression out of this rule. + @return a NOT-expression out of this rule. + */ +expr rule::operator !() { + return _private::construct_expr(new _not(new _ref(*this))); +} + + +/** sets the parse procedure. + @param p procedure. + */ +void rule::set_parse_proc(parse_proc p) { + assert(p); + m_parse_proc = p; + _parse_proc_map_t& _parse_proc_map = _get_parse_proc_map(); + _parse_proc_map[this] = p; +} + + +/** creates a sequence of expressions. + @param left left operand. + @param right right operand. + @return an expression which parses a sequence. + */ +expr operator >> (const expr &left, const expr &right) { + return _private::construct_expr( + new _seq(_private::get_expr(left), _private::get_expr(right))); +} + + +/** creates a choice of expressions. + @param left left operand. + @param right right operand. + @return an expression which parses a choice. + */ +expr operator | (const expr &left, const expr &right) { + return _private::construct_expr( + new _choice(_private::get_expr(left), _private::get_expr(right))); +} + + +/** converts a parser expression into a terminal. + @param e expression. + @return an expression which parses a terminal. + */ +expr term(const expr &e) { + return _private::construct_expr( + new _term(_private::get_expr(e))); +} + + +/** creates a set expression from a null-terminated string. + @param s null-terminated string with characters of the set. + @return an expression which parses a single character out of a set. + */ +expr set(const char *s) { + return _private::construct_expr(new _set(s)); +} + + +/** creates a set expression from a null-terminated wide string. + @param s null-terminated string with characters of the set. + @return an expression which parses a single character out of a set. + */ +expr set(const wchar_t *s) { + return _private::construct_expr(new _set(s)); +} + + +/** creates a range expression. + @param min min character. + @param max max character. + @return an expression which parses a single character out of range. + */ +expr range(int min, int max) { + return _private::construct_expr(new _set(min, max)); +} + + +/** creates an expression which increments the line counter + and resets the column counter when the given expression + is parsed successfully; used for newline characters. + @param e expression to wrap into a newline parser. + @return an expression that handles newlines. + */ +expr nl(const expr &e) { + return _private::construct_expr(new _nl(_private::get_expr(e))); +} + + +/** creates an expression which tests for the end of input. + @return an expression that handles the end of input. + */ +expr eof() { + return _private::construct_expr(new _eof()); +} + + +/** creates a not expression. + @param e expression. + @return the appropriate expression. + */ +expr not_(const expr &e) { + return !e; +} + + +/** creates an and expression. + @param e expression. + @return the appropriate expression. + */ +expr and_(const expr &e) { + return &e; +} + + +/** creates an expression that parses any character. + @return the appropriate expression. + */ +expr any() { + return _private::construct_expr(new _any()); +} + + +/** parsing succeeds without consuming any input. +*/ +expr true_() { + return _private::construct_expr(new _true()); +} + + +/** parsing fails without consuming any input. +*/ +expr false_() { + return _private::construct_expr(new _false()); +} + + +/** parse with target expression and let user handle result. +*/ +expr user(const expr &e, const user_handler& handler) { + return _private::construct_expr(new _user(_private::get_expr(e), handler)); +} + + +/** parses the given input. + The parse procedures of each rule parsed are executed + before this function returns, if parsing succeeds. + @param i input. + @param g root rule of grammar. + @param el list of errors. + @param d user data, passed to the parse procedures. + @return true on parsing success, false on failure. + */ +bool parse(input &i, rule &g, error_list &el, void *d, void* ud) { + //prepare context + _context con(i, ud); + + //parse grammar + if (!con.parse_non_term(g)) { + el.push_back(_syntax_error(con)); + return false; + } + + //if end is not reached, there was an error + if (!con.end()) { + if (con.m_error_pos.m_it < con.m_end) { + el.push_back(_syntax_error(con)); + } + else { + el.push_back(_eof_error(con)); + } + return false; + } + + //success; execute the parse procedures + con.do_parse_procs(d); + return true; +} + + +} //namespace parserlib diff --git a/MoonParser/parser.hpp b/MoonParser/parser.hpp new file mode 100644 index 0000000..540a51c --- /dev/null +++ b/MoonParser/parser.hpp @@ -0,0 +1,428 @@ +#ifndef PARSER_HPP +#define PARSER_HPP + + +//gcc chokes without rule::rule(const rule &), +//msvc complains when rule::rule(const rule &) is defined. +#ifdef _MSC_VER +#pragma warning (disable: 4521) +#endif + + +#include <vector> +#include <string> +#include <list> +#include <functional> + + +namespace parserlib { + + +class _private; +class _expr; +class _context; +class rule; + + +///type of the parser's input. +typedef std::vector<int> input; +typedef input::iterator input_it; +struct item_t +{ + input_it begin; + input_it end; + void* user_data; +}; +typedef std::function<bool(const item_t&)> user_handler; + + +///position into the input. +class pos { +public: + ///interator into the input. + input::iterator m_it; + + ///line. + int m_line; + + ///column. + int m_col; + + ///null constructor. + pos() {} + + /** constructor from input. + @param i input. + */ + pos(input &i); +}; + + +/** a grammar expression. + */ +class expr { +public: + /** character terminal constructor. + @param c character. + */ + expr(int c); + + /** null-terminated string terminal constructor. + @param s null-terminated string. + */ + expr(const char *s); + + /** null-terminated wide string terminal constructor. + @param s null-terminated string. + */ + expr(const wchar_t *s); + + /** rule reference constructor. + @param r rule. + */ + expr(rule &r); + + /** creates a zero-or-more loop out of this expression. + @return a zero-or-more loop expression. + */ + expr operator *() const; + + /** creates a one-or-more loop out of this expression. + @return a one-or-more loop expression. + */ + expr operator +() const; + + /** creates an optional out of this expression. + @return an optional expression. + */ + expr operator -() const; + + /** creates an AND-expression. + @return an AND-expression. + */ + expr operator &() const; + + /** creates a NOT-expression. + @return a NOT-expression. + */ + expr operator !() const; + +private: + //internal expression + _expr *m_expr; + + //internal constructor from internal expression + expr(_expr *e) : m_expr(e) {} + + //assignment not allowed + expr &operator = (expr &); + + friend class _private; +}; + + +/** type of procedure to invoke when a rule is successfully parsed. + @param b begin position of input. + @param e end position of input. + @param d pointer to user data. + */ +typedef void (*parse_proc)(const pos &b, const pos &e, void *d); + + +///input range. +class input_range { +public: + ///begin position. + pos m_begin; + + ///end position. + pos m_end; + + ///empty constructor. + input_range() {} + + /** constructor. + @param b begin position. + @param e end position. + */ + input_range(const pos &b, const pos &e); +}; + + +///enum with error types. +enum ERROR_TYPE { + ///syntax error + ERROR_SYNTAX_ERROR = 1, + + ///invalid end of file + ERROR_INVALID_EOF, + + ///first user error + ERROR_USER = 100 +}; + + +///error. +class error : public input_range { +public: + ///type + int m_type; + + /** constructor. + @param b begin position. + @param e end position. + @param t type. + */ + error(const pos &b, const pos &e, int t); + + /** compare on begin position. + @param e the other error to compare this with. + @return true if this comes before the previous error, false otherwise. + */ + bool operator < (const error &e) const; +}; + + +///type of error list. +typedef std::list<error> error_list; + + +/** represents a rule. + */ +class rule { +public: + /** character terminal constructor. + @param c character. + */ + rule(int c); + + /** null-terminated string terminal constructor. + @param s null-terminated string. + */ + rule(const char *s); + + /** null-terminated wide string terminal constructor. + @param s null-terminated string. + */ + rule(const wchar_t *s); + + /** constructor from expression. + @param e expression. + */ + rule(const expr &e); + + /** constructor from rule. + @param r rule. + */ + rule(rule &r); + + /** invalid constructor from rule (required by gcc). + @param r rule. + @exception std::logic_error always thrown. + */ + rule(const rule &r); + + /** deletes the internal object that represents the expression. + */ + ~rule(); + + /** creates a zero-or-more loop out of this rule. + @return a zero-or-more loop rule. + */ + expr operator *(); + + /** creates a one-or-more loop out of this rule. + @return a one-or-more loop rule. + */ + expr operator +(); + + /** creates an optional out of this rule. + @return an optional rule. + */ + expr operator -(); + + /** creates an AND-expression out of this rule. + @return an AND-expression out of this rule. + */ + expr operator &(); + + /** creates a NOT-expression out of this rule. + @return a NOT-expression out of this rule. + */ + expr operator !(); + + /** sets the parse procedure. + @param p procedure. + */ + void set_parse_proc(parse_proc p); + + /** get the this ptr (since operator & is overloaded). + @return pointer to this. + */ + rule *this_ptr() { return this; } + +private: + //mode + enum _MODE { + _PARSE, + _REJECT, + _ACCEPT + }; + + //state + struct _state { + //position in source code, relative to start + size_t m_pos; + + //mode + _MODE m_mode; + + //constructor + _state(size_t pos = -1, _MODE mode = _PARSE) : + m_pos(pos), m_mode(mode) {} + }; + + //internal expression + _expr *m_expr; + + //associated parse procedure. + parse_proc m_parse_proc; + + //state + _state m_state; + + //assignment not allowed + rule &operator = (rule &); + + friend class _private; + friend class _context; +}; + + +/** creates a sequence of expressions. + @param left left operand. + @param right right operand. + @return an expression which parses a sequence. + */ +expr operator >> (const expr &left, const expr &right); + + +/** creates a choice of expressions. + @param left left operand. + @param right right operand. + @return an expression which parses a choice. + */ +expr operator | (const expr &left, const expr &right); + + +/** converts a parser expression into a terminal. + @param e expression. + @return an expression which parses a terminal. + */ +expr term(const expr &e); + + +/** creates a set expression from a null-terminated string. + @param s null-terminated string with characters of the set. + @return an expression which parses a single character out of a set. + */ +expr set(const char *s); + + +/** creates a set expression from a null-terminated wide string. + @param s null-terminated string with characters of the set. + @return an expression which parses a single character out of a set. + */ +expr set(const wchar_t *s); + + +/** creates a range expression. + @param min min character. + @param max max character. + @return an expression which parses a single character out of range. + */ +expr range(int min, int max); + + +/** creates an expression which increments the line counter + and resets the column counter when the given expression + is parsed successfully; used for newline characters. + @param e expression to wrap into a newline parser. + @return an expression that handles newlines. + */ +expr nl(const expr &e); + + +/** creates an expression which tests for the end of input. + @return an expression that handles the end of input. + */ +expr eof(); + + +/** creates a not expression. + @param e expression. + @return the appropriate expression. + */ +expr not_(const expr &e); + + +/** creates an and expression. + @param e expression. + @return the appropriate expression. + */ +expr and_(const expr &e); + + +/** creates an expression that parses any character. + @return the appropriate expression. + */ +expr any(); + + +/** parsing succeeds without consuming any input. + */ +expr true_(); + + +/** parsing fails without consuming any input. +*/ +expr false_(); + + +/** parse with target expression and let user handle result. +*/ +expr user(const expr &e, const user_handler& handler); + + +/** parses the given input. + The parse procedures of each rule parsed are executed + before this function returns, if parsing succeeds. + @param i input. + @param g root rule of grammar. + @param el list of errors. + @param d user data, passed to the parse procedures. + @return true on parsing success, false on failure. + */ +bool parse(input &i, rule &g, error_list &el, void *d, void* ud); + + +/** output the specific input range to the specific stream. + @param stream stream. + @param ir input range. + @return the stream. + */ +template <class T> T &operator << (T &stream, const input_range &ir) { + for(input::const_iterator it = ir.m_begin.m_it; + it != ir.m_end.m_it; + ++it) + { + stream << (typename T::char_type)*it; + } + return stream; +} + + +} //namespace parserlib + + +#endif //PARSER_HPP diff --git a/MoonParser/parserlib.hpp b/MoonParser/parserlib.hpp new file mode 100644 index 0000000..afbd1f0 --- /dev/null +++ b/MoonParser/parserlib.hpp @@ -0,0 +1,8 @@ +#ifndef PARSERLIB_HPP +#define PARSERLIB_HPP + + +#include "ast.hpp" + + +#endif //PARSERLIB_HPP diff --git a/MoonParser/pegtl.hpp b/MoonParser/pegtl.hpp deleted file mode 100644 index e96cd79..0000000 --- a/MoonParser/pegtl.hpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_PEGTL_HPP -#define TAOCPP_PEGTL_INCLUDE_PEGTL_HPP - -#include "pegtl/config.hpp" -#include "pegtl/version.hpp" - -#include "pegtl/ascii.hpp" -#include "pegtl/parse.hpp" -#include "pegtl/rules.hpp" -#include "pegtl/utf16.hpp" -#include "pegtl/utf32.hpp" -#include "pegtl/utf8.hpp" - -#include "pegtl/argv_input.hpp" -#include "pegtl/buffer_input.hpp" -#include "pegtl/cstream_input.hpp" -#include "pegtl/file_input.hpp" -#include "pegtl/istream_input.hpp" -#include "pegtl/memory_input.hpp" -#include "pegtl/read_input.hpp" -#include "pegtl/string_input.hpp" - -// The following are not included by -// default because they include <iostream>. - -// #include "pegtl/analyze.hpp" - -#endif diff --git a/MoonParser/pegtl/analysis/analyze_cycles.hpp b/MoonParser/pegtl/analysis/analyze_cycles.hpp deleted file mode 100644 index f063ee1..0000000 --- a/MoonParser/pegtl/analysis/analyze_cycles.hpp +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_ANALYSIS_ANALYZE_CYCLES_HPP -#define TAOCPP_PEGTL_INCLUDE_ANALYSIS_ANALYZE_CYCLES_HPP - -#include <cassert> - -#include <map> -#include <set> - -#include <iostream> -#include <utility> - -#include "../config.hpp" - -#include "grammar_info.hpp" -#include "insert_guard.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace analysis - { - 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; - } - - 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 = 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; - } - } - throw std::runtime_error( "code should be unreachable" ); // LCOV_EXCL_LINE - } - if( !accum ) { - ++m_problems; - if( m_verbose ) { - std::cout << "problem: cycle without progress detected at rule class " << start->first << std::endl; - } - } - 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(); - } - 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; - } - }; - - } // namespace analysis - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/analysis/counted.hpp b/MoonParser/pegtl/analysis/counted.hpp deleted file mode 100644 index 84a12ae..0000000 --- a/MoonParser/pegtl/analysis/counted.hpp +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_ANALYSIS_COUNTED_HPP -#define TAOCPP_PEGTL_INCLUDE_ANALYSIS_COUNTED_HPP - -#include "../config.hpp" - -#include "generic.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace analysis - { - template< rule_type Type, unsigned Count, typename... Rules > - struct counted - : generic< ( Count != 0 ) ? Type : rule_type::OPT, Rules... > - { - }; - - } // namespace analysis - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/analysis/generic.hpp b/MoonParser/pegtl/analysis/generic.hpp deleted file mode 100644 index 27e0ffe..0000000 --- a/MoonParser/pegtl/analysis/generic.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_ANALYSIS_GENERIC_HPP -#define TAOCPP_PEGTL_INCLUDE_ANALYSIS_GENERIC_HPP - -#include "../config.hpp" - -#include "grammar_info.hpp" -#include "insert_rules.hpp" -#include "rule_type.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace analysis - { - 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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/analysis/grammar_info.hpp b/MoonParser/pegtl/analysis/grammar_info.hpp deleted file mode 100644 index 15c96ab..0000000 --- a/MoonParser/pegtl/analysis/grammar_info.hpp +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_ANALYSIS_GRAMMAR_INFO_HPP -#define TAOCPP_PEGTL_INCLUDE_ANALYSIS_GRAMMAR_INFO_HPP - -#include <map> -#include <string> -#include <utility> - -#include "../config.hpp" -#include "../internal/demangle.hpp" - -#include "rule_info.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - 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 ) ) ); - } - }; - - } // namespace analysis - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/analysis/insert_guard.hpp b/MoonParser/pegtl/analysis/insert_guard.hpp deleted file mode 100644 index 9a4cc35..0000000 --- a/MoonParser/pegtl/analysis/insert_guard.hpp +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_ANALYSIS_INSERT_GUARD_HPP -#define TAOCPP_PEGTL_INCLUDE_ANALYSIS_INSERT_GUARD_HPP - -#include <utility> - -#include "../config.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace analysis - { - template< typename C > - class insert_guard - { - public: - insert_guard( insert_guard&& other ) noexcept - : m_i( other.m_i ), - m_c( other.m_c ) - { - other.m_c = nullptr; - } - - insert_guard( C& container, const typename C::value_type& value ) - : m_i( container.insert( value ) ), - m_c( &container ) - { - } - - ~insert_guard() - { - if( m_c && m_i.second ) { - m_c->erase( m_i.first ); - } - } - - insert_guard( const insert_guard& ) = delete; - void operator=( const insert_guard& ) = delete; - - explicit operator bool() const noexcept - { - return m_i.second; - } - - private: - const std::pair< typename C::iterator, bool > m_i; - C* m_c; - }; - - template< typename C > - insert_guard< C > make_insert_guard( C& container, const typename C::value_type& value ) - { - return insert_guard< C >( container, value ); - } - - } // namespace analysis - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/analysis/insert_rules.hpp b/MoonParser/pegtl/analysis/insert_rules.hpp deleted file mode 100644 index ff55f66..0000000 --- a/MoonParser/pegtl/analysis/insert_rules.hpp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_ANALYSIS_INSERT_RULES_HPP -#define TAOCPP_PEGTL_INCLUDE_ANALYSIS_INSERT_RULES_HPP - -#include "../config.hpp" - -#include "grammar_info.hpp" -#include "rule_info.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace analysis - { - template< typename... > - struct insert_rules; - - template<> - struct insert_rules<> - { - static void insert( grammar_info&, rule_info& ) - { - } - }; - - 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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/analysis/rule_info.hpp b/MoonParser/pegtl/analysis/rule_info.hpp deleted file mode 100644 index 22910ec..0000000 --- a/MoonParser/pegtl/analysis/rule_info.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_ANALYSIS_RULE_INFO_HPP -#define TAOCPP_PEGTL_INCLUDE_ANALYSIS_RULE_INFO_HPP - -#include <string> -#include <vector> - -#include "../config.hpp" - -#include "rule_type.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace analysis - { - struct rule_info - { - explicit rule_info( const rule_type in_type ) - : type( in_type ) - { - } - - rule_type type; - std::vector< std::string > rules; - }; - - } // namespace analysis - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/analysis/rule_type.hpp b/MoonParser/pegtl/analysis/rule_type.hpp deleted file mode 100644 index fc5d4c8..0000000 --- a/MoonParser/pegtl/analysis/rule_type.hpp +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_ANALYSIS_RULE_TYPE_HPP -#define TAOCPP_PEGTL_INCLUDE_ANALYSIS_RULE_TYPE_HPP - -#include "../config.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - 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. - }; - - } // namespace analysis - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/analyze.hpp b/MoonParser/pegtl/analyze.hpp deleted file mode 100644 index 5468a14..0000000 --- a/MoonParser/pegtl/analyze.hpp +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_ANALYZE_HPP -#define TAOCPP_PEGTL_INCLUDE_ANALYZE_HPP - -#include "config.hpp" - -#include "analysis/analyze_cycles.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - template< typename Rule > - std::size_t analyze( const bool verbose = true ) - { - return analysis::analyze_cycles< Rule >( verbose ).problems(); - } - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/apply_mode.hpp b/MoonParser/pegtl/apply_mode.hpp deleted file mode 100644 index 93a701b..0000000 --- a/MoonParser/pegtl/apply_mode.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_APPLY_MODE_HPP -#define TAOCPP_PEGTL_INCLUDE_APPLY_MODE_HPP - -#include "config.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - enum class apply_mode : bool - { - ACTION = true, - NOTHING = false - }; - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/argv_input.hpp b/MoonParser/pegtl/argv_input.hpp deleted file mode 100644 index 3846975..0000000 --- a/MoonParser/pegtl/argv_input.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_ARGV_INPUT_HPP -#define TAOCPP_PEGTL_INCLUDE_ARGV_INPUT_HPP - -#include <cstddef> -#include <sstream> -#include <string> -#include <utility> - -#include "config.hpp" -#include "eol.hpp" -#include "memory_input.hpp" -#include "tracking_mode.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - 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 > - { - 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 ) ) - { - } - }; - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/ascii.hpp b/MoonParser/pegtl/ascii.hpp deleted file mode 100644 index 9158061..0000000 --- a/MoonParser/pegtl/ascii.hpp +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_ASCII_HPP -#define TAOCPP_PEGTL_INCLUDE_ASCII_HPP - -#include "config.hpp" -#include "eol.hpp" - -#include "internal/result_on_found.hpp" -#include "internal/rules.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - 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 {}; - 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< 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 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< typename Input > - static bool match( Input& ) noexcept - { - static_assert( sizeof( Input ) == 0, "empty keywords not allowed" ); - return false; - } - }; - - } // namespace ascii - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#include "internal/pegtl_string.hpp" - -#endif diff --git a/MoonParser/pegtl/buffer_input.hpp b/MoonParser/pegtl/buffer_input.hpp deleted file mode 100644 index b65e365..0000000 --- a/MoonParser/pegtl/buffer_input.hpp +++ /dev/null @@ -1,179 +0,0 @@ -// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_BUFFER_INPUT_HPP -#define TAOCPP_PEGTL_INCLUDE_BUFFER_INPUT_HPP - -#include <cstddef> -#include <cstring> -#include <memory> -#include <string> - -#include "config.hpp" -#include "eol.hpp" -#include "memory_input.hpp" -#include "position.hpp" -#include "tracking_mode.hpp" - -#include "internal/action_input.hpp" -#include "internal/bump_impl.hpp" -#include "internal/iterator.hpp" -#include "internal/marker.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - 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; - - using eol_t = Eol; - using source_t = Source; - - using iterator_t = internal::iterator; - - 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 ) ) - { - } - - buffer_input( const buffer_input& ) = delete; - void operator=( const buffer_input& ) = delete; - - bool empty() - { - require( 1 ); - return m_current.data == m_end; - } - - std::size_t size( const std::size_t amount ) - { - require( amount ); - return std::size_t( m_end - m_current.data ); - } - - const char* current() const noexcept - { - return m_current.data; - } - - const char* end( const std::size_t amount ) - { - require( amount ); - 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; - } - - const Source& source() const noexcept - { - return m_source; - } - - char peek_char( const std::size_t offset = 0 ) const noexcept - { - return m_current.data[ offset ]; - } - - unsigned char peek_byte( const std::size_t offset = 0 ) const noexcept - { - return static_cast< unsigned char >( peek_char( offset ) ); - } - - void bump( const std::size_t in_count = 1 ) noexcept - { - internal::bump( m_current, in_count, Eol::ch ); - } - - void bump_in_this_line( const std::size_t in_count = 1 ) noexcept - { - internal::bump_in_this_line( m_current, in_count ); - } - - void bump_to_next_line( const std::size_t in_count = 1 ) noexcept - { - internal::bump_to_next_line( m_current, in_count ); - } - - void discard() noexcept - { - 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( const_cast< char* >( m_end ), amount - std::size_t( m_end - m_current.data ) ) ) { - m_end += r; - } - else { - m_maximum = 0; - } - } - } - } - - template< rewind_mode M > - internal::marker< iterator_t, M > mark() noexcept - { - return internal::marker< iterator_t, M >( m_current ); - } - - TAOCPP_PEGTL_NAMESPACE::position position( const iterator_t& it ) const - { - return TAOCPP_PEGTL_NAMESPACE::position( it, m_source ); - } - - TAOCPP_PEGTL_NAMESPACE::position position() const - { - return position( m_current ); - } - - const iterator_t& iterator() const noexcept - { - return m_current; - } - - private: - Reader m_reader; - std::size_t m_maximum; - std::unique_ptr< char[] > m_buffer; - iterator_t m_current; - const char* m_end; - const Source m_source; - }; - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/config.hpp b/MoonParser/pegtl/config.hpp deleted file mode 100644 index e93f74a..0000000 --- a/MoonParser/pegtl/config.hpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_CONFIG_HPP -#define TAOCPP_PEGTL_INCLUDE_CONFIG_HPP - -#ifndef TAOCPP_PEGTL_NAMESPACE -#define TAOCPP_PEGTL_NAMESPACE pegtl -#endif - -// Enable some improvements to the readability of -// demangled type names under some circumstances. -// #define TAOCPP_PEGTL_PRETTY_DEMANGLE - -#endif diff --git a/MoonParser/pegtl/contrib/abnf.hpp b/MoonParser/pegtl/contrib/abnf.hpp deleted file mode 100644 index 15319f5..0000000 --- a/MoonParser/pegtl/contrib/abnf.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_ABNF_HPP -#define TAOCPP_PEGTL_INCLUDE_CONTRIB_ABNF_HPP - -#include "../config.hpp" -#include "../internal/rules.hpp" - -namespace tao -{ - namespace TAOCPP_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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/contrib/alphabet.hpp b/MoonParser/pegtl/contrib/alphabet.hpp deleted file mode 100644 index c0dce42..0000000 --- a/MoonParser/pegtl/contrib/alphabet.hpp +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2015-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_ALPHABET_HPP -#define TAOCPP_PEGTL_INCLUDE_CONTRIB_ALPHABET_HPP - -#include "../config.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - inline 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'; - - } // namespace alphabet - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/contrib/changes.hpp b/MoonParser/pegtl/contrib/changes.hpp deleted file mode 100644 index 7b9f8dc..0000000 --- a/MoonParser/pegtl/contrib/changes.hpp +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2015-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_CHANGES_HPP -#define TAOCPP_PEGTL_INCLUDE_CONTRIB_CHANGES_HPP - -#include <type_traits> - -#include "../config.hpp" -#include "../normal.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - struct dummy_disabled_state - { - template< typename... Ts > - void success( Ts&&... ) const noexcept - { - } - }; - - template< apply_mode A, typename State > - using state_disable_helper = typename std::conditional< A == apply_mode::ACTION, State, dummy_disabled_state >::type; - - } // 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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/contrib/counter.hpp b/MoonParser/pegtl/contrib/counter.hpp deleted file mode 100644 index 52beb3b..0000000 --- a/MoonParser/pegtl/contrib/counter.hpp +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_COUNTER_HPP -#define TAOCPP_PEGTL_INCLUDE_CONTRIB_COUNTER_HPP - -#include <cassert> -#include <utility> - -#include "../config.hpp" -#include "../normal.hpp" - -#include "../internal/demangle.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - 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&, counter_state& ts ) - { - ++ts.counts[ internal::demangle< Rule >() ].start; - } - - template< typename Input > - static void success( const Input&, counter_state& ts ) - { - ++ts.counts[ internal::demangle< Rule >() ].success; - } - - template< typename Input > - static void failure( const Input&, counter_state& ts ) - { - ++ts.counts[ internal::demangle< Rule >() ].failure; - } - }; - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/contrib/http.hpp b/MoonParser/pegtl/contrib/http.hpp deleted file mode 100644 index 1446449..0000000 --- a/MoonParser/pegtl/contrib/http.hpp +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_HTTP_HPP -#define TAOCPP_PEGTL_INCLUDE_CONTRIB_HTTP_HPP - -#include "../ascii.hpp" -#include "../config.hpp" -#include "../rules.hpp" -#include "../utf8.hpp" -#include "abnf.hpp" -#include "uri.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace http - { - // HTTP 1.1 grammar according to RFC 7230. - - // This grammar is a direct PEG translation of the original HTTP grammar. - // It should be considered experimental -- in case of any issues, in particular - // missing rules for attached actions, please contact the developers. - - using namespace abnf; - - using OWS = star< WSP >; // optional whitespace - using RWS = plus< WSP >; // required whitespace - using BWS = OWS; // "bad" whitespace - - // cppcheck-suppress constStatement - using obs_text = not_range< 0x00, 0x7F >; - using obs_fold = seq< CRLF, plus< WSP > >; - - // clang-format off - struct tchar : sor< ALPHA, DIGIT, one< '!', '#', '$', '%', '&', '\'', '*', '+', '-', '.', '^', '_', '`', '|', '~' > > {}; - struct token : plus< tchar > {}; - - struct field_name : token {}; - - struct field_vchar : sor< VCHAR, obs_text > {}; - struct field_content : list< field_vchar, plus< WSP > > {}; - struct field_value : star< sor< field_content, obs_fold > > {}; - - struct header_field : seq< field_name, one< ':' >, OWS, field_value, OWS > {}; - - struct method : token {}; - - struct absolute_path : plus< one< '/' >, uri::segment > {}; - - struct origin_form : seq< absolute_path, uri::opt_query > {}; - struct absolute_form : uri::absolute_URI {}; - struct authority_form : uri::authority {}; - struct asterisk_form : one< '*' > {}; - - struct request_target : sor< origin_form, absolute_form, authority_form, asterisk_form > {}; - - struct status_code : rep< 3, DIGIT > {}; - struct reason_phrase : star< sor< VCHAR, obs_text, WSP > > {}; - - struct HTTP_version : if_must< TAOCPP_PEGTL_STRING( "HTTP/" ), DIGIT, one< '.' >, DIGIT > {}; - - struct request_line : if_must< method, SP, request_target, SP, HTTP_version, CRLF > {}; - struct status_line : if_must< HTTP_version, SP, status_code, SP, reason_phrase, CRLF > {}; - struct start_line : sor< status_line, request_line > {}; - - struct message_body : star< OCTET > {}; - struct HTTP_message : seq< start_line, star< header_field, CRLF >, CRLF, opt< message_body > > {}; - - struct Content_Length : plus< DIGIT > {}; - - struct uri_host : uri::host {}; - struct port : uri::port {}; - - struct Host : seq< uri_host, opt< one< ':' >, port > > {}; - - // PEG are different from CFGs! (this replaces ctext and qdtext) - using text = sor< HTAB, range< 0x20, 0x7E >, obs_text >; - - struct quoted_pair : if_must< one< '\\' >, sor< VCHAR, obs_text, WSP > > {}; - struct quoted_string : if_must< DQUOTE, until< 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< TAOCPP_PEGTL_ISTRING( "chunked" ), - TAOCPP_PEGTL_ISTRING( "compress" ), - TAOCPP_PEGTL_ISTRING( "deflate" ), - TAOCPP_PEGTL_ISTRING( "gzip" ), - transfer_extension > {}; - - struct rank : sor< seq< one< '0' >, opt< one< '.' >, rep_opt< 3, 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< TAOCPP_PEGTL_ISTRING( "trailers" ), seq< transfer_coding, opt< t_ranking > > > {}; - - struct TE : opt< sor< one< ',' >, t_codings >, star< OWS, one< ',' >, opt< OWS, t_codings > > > {}; - - template< typename T > - using make_comma_list = seq< star< one< ',' >, OWS >, T, star< OWS, one< ',' >, opt< OWS, T > > >; - - struct connection_option : token {}; - struct Connection : make_comma_list< connection_option > {}; - - struct Trailer : make_comma_list< field_name > {}; - - struct Transfer_Encoding : make_comma_list< transfer_coding > {}; - - struct protocol_name : token {}; - struct protocol_version : token {}; - struct protocol : seq< protocol_name, opt< one< '/' >, protocol_version > > {}; - struct Upgrade : make_comma_list< protocol > {}; - - struct pseudonym : token {}; - - struct received_protocol : seq< opt< protocol_name, one< '/' > >, protocol_version > {}; - struct received_by : sor< seq< uri_host, opt< one< ':' >, port > >, pseudonym > {}; - - struct comment : if_must< one< '(' >, until< one< ')' >, sor< comment, quoted_pair, text > > > {}; - - struct Via : make_comma_list< seq< received_protocol, RWS, received_by, opt< RWS, comment > > > {}; - - struct http_URI : if_must< TAOCPP_PEGTL_ISTRING( "http://" ), uri::authority, uri::path_abempty, uri::opt_query, uri::opt_fragment > {}; - struct https_URI : if_must< TAOCPP_PEGTL_ISTRING( "https://" ), uri::authority, uri::path_abempty, uri::opt_query, uri::opt_fragment > {}; - - struct partial_URI : seq< uri::relative_part, uri::opt_query > {}; - - struct chunk_size : plus< HEXDIG > {}; - - struct chunk_ext_name : token {}; - struct chunk_ext_val : sor< quoted_string, token > {}; - struct chunk_ext : star< if_must< one< ';' >, chunk_ext_name, if_must< one< '=' >, chunk_ext_val > > > {}; - - struct chunk_data : until< at< CRLF >, OCTET > {}; - - struct chunk : seq< chunk_size, opt< chunk_ext >, CRLF, chunk_data, CRLF > {}; - - struct last_chunk : seq< plus< one< '0' > >, opt< chunk_ext >, CRLF > {}; - - struct trailer_part : star< header_field, CRLF > {}; - - struct chunked_body : seq< until< last_chunk, chunk >, trailer_part, CRLF > {}; - // clang-format on - - } // namespace http - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/contrib/json.hpp b/MoonParser/pegtl/contrib/json.hpp deleted file mode 100644 index 688f607..0000000 --- a/MoonParser/pegtl/contrib/json.hpp +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_JSON_HPP -#define TAOCPP_PEGTL_INCLUDE_CONTRIB_JSON_HPP - -#include "../ascii.hpp" -#include "../config.hpp" -#include "../rules.hpp" -#include "../utf8.hpp" - -#include "abnf.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace json - { - // JSON grammar according to RFC 7159 (for UTF-8 encoded JSON only). - - // 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_ : TAOCPP_PEGTL_STRING( "false" ) {}; - struct null : TAOCPP_PEGTL_STRING( "null" ) {}; - struct true_ : TAOCPP_PEGTL_STRING( "true" ) {}; - - 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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/contrib/raw_string.hpp b/MoonParser/pegtl/contrib/raw_string.hpp deleted file mode 100644 index 592ce5b..0000000 --- a/MoonParser/pegtl/contrib/raw_string.hpp +++ /dev/null @@ -1,252 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_RAW_STRING_HPP -#define TAOCPP_PEGTL_INCLUDE_CONTRIB_RAW_STRING_HPP - -#include "../apply_mode.hpp" -#include "../config.hpp" -#include "../nothing.hpp" -#include "../rewind_mode.hpp" - -#include "../internal/iterator.hpp" -#include "../internal/must.hpp" -#include "../internal/skip_control.hpp" -#include "../internal/state.hpp" -#include "../internal/until.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< char Open, char Marker, char Close, typename... Contents > - struct raw_string_tag - { - }; - - template< bool use_action, bool use_apply0, typename Tag > - struct raw_string_state_apply; - - template< typename Tag > - struct raw_string_state_apply< false, false, Tag > - { - template< template< typename... > class, - template< typename... > class, - typename State, - typename Input, - typename... States > - static void success( const State&, const Input&, States&&... ) - { - } - }; - - template< typename Tag > - struct raw_string_state_apply< true, false, Tag > - { - template< template< typename... > class Action, - template< typename... > class Control, - typename State, - typename Input, - typename... States > - static void success( const State& s, const Input& in, States&&... st ) - { - Control< Tag >::template apply< Action >( s.iter, in, st... ); - } - }; - - template< typename Tag > - struct raw_string_state_apply< true, true, Tag > - { - template< template< typename... > class Action, - template< typename... > class Control, - typename State, - typename Input, - typename... States > - static void success( const State&, const Input& in, States&&... st ) - { - Control< Tag >::template apply0< Action >( in, st... ); - } - }; - - template< typename Tag, typename Iterator > - struct raw_string_state - { - template< typename Input, typename... States > - raw_string_state( const Input&, States&&... ) - { - } - - template< apply_mode A, - rewind_mode, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename... States > - void success( Input& in, States&&... st ) const - { - constexpr bool use_action = ( A == apply_mode::ACTION ) && ( !is_nothing< Action, Tag >::value ); - constexpr bool use_apply0 = use_action && has_apply0< Action< Tag >, type_list< States... > >::value; - raw_string_state_apply< use_action, use_apply0, Tag >::template success< Action, Control >( *this, in, st... ); - in.bump_in_this_line( marker_size ); - } - - raw_string_state( const raw_string_state& ) = delete; - void operator=( const raw_string_state& ) = delete; - - Iterator iter; - std::size_t marker_size = 0; - }; - - 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 State > - static bool match( Input& in, State& ls ) - { - 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: - ls.marker_size = i + 1; - in.bump( ls.marker_size ); - eol::match( in ); - ls.iter = in.iterator(); - return true; - case Marker: - break; - default: - return false; - } - } - 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::ANY >; - - template< apply_mode A, - rewind_mode, - template< typename... > class Action, - template< typename... > class Control, - typename Input, - typename State > - static bool match( Input& in, const State& ls ) - { - if( in.size( ls.marker_size ) < ls.marker_size ) { - return false; - } - if( in.peek_char( 0 ) != Close ) { - return false; - } - if( in.peek_char( ls.marker_size - 1 ) != Close ) { - return false; - } - for( std::size_t i = 0; i < ls.marker_size - 2; ++i ) { - if( in.peek_char( i + 1 ) != Marker ) { - return false; - } - } - return true; - } - }; - - template< char Marker, char Close > - struct skip_control< at_raw_string_close< Marker, Close > > : std::true_type - { - }; - - template< class Tag, typename... Rules > - struct raw_string_switch_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 bool match( Input& in, States&&... st ) - { - using Iterator = typename Input::iterator_t; - raw_string_state< Tag, Iterator > s( const_cast< const Input& >( in ), st... ); - - if( duseltronik< seq< Rules... >, A, M, Action, Control >::match( in, s ) ) { - s.template success< A, M, Action, Control >( in, st... ); - return true; - } - return false; - } - }; - - template< typename Tag, typename... Rules > - struct skip_control< raw_string_switch_state< Tag, 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 - : internal::raw_string_switch_state< internal::raw_string_tag< Open, Marker, Close >, - internal::raw_string_open< Open, Marker >, - internal::must< internal::until< internal::at_raw_string_close< Marker, Close >, Contents... > > > - { - // This is used to bind an action to the content. - using content = internal::raw_string_tag< Open, Marker, Close, Contents... >; - - // This is used for error-reporting when a raw string is not closed properly. - using close = internal::until< internal::at_raw_string_close< Marker, Close > >; - }; - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/contrib/rep_one_min_max.hpp b/MoonParser/pegtl/contrib/rep_one_min_max.hpp deleted file mode 100644 index 28fdbcd..0000000 --- a/MoonParser/pegtl/contrib/rep_one_min_max.hpp +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_REP_ONE_MIN_MAX_HPP -#define TAOCPP_PEGTL_INCLUDE_CONTRIB_REP_ONE_MIN_MAX_HPP - -#include <algorithm> - -#include "../config.hpp" - -#include "../analysis/counted.hpp" - -#include "../internal/bump_help.hpp" -#include "../internal/skip_control.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< unsigned Min, unsigned Max, char C > - struct rep_one_min_max - { - 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)" ); - - 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; - } - return false; - } - }; - - template< unsigned Min, unsigned Max, char C > - struct skip_control< rep_one_min_max< Min, Max, C > > : std::true_type - { - }; - - } // namespace internal - - inline namespace ascii - { - template< unsigned Min, unsigned Max, char C > - struct rep_one_min_max : internal::rep_one_min_max< Min, Max, C > - { - }; - - struct ellipsis : internal::rep_one_min_max< 3, 3, '.' > - { - }; - - } // namespace ascii - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/contrib/to_string.hpp b/MoonParser/pegtl/contrib/to_string.hpp deleted file mode 100644 index 4c19931..0000000 --- a/MoonParser/pegtl/contrib/to_string.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_TO_STRING_HPP -#define TAOCPP_PEGTL_INCLUDE_CONTRIB_TO_STRING_HPP - -#include <string> - -#include "../config.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< typename > - struct to_string; - - template< template< char... > class X, char... Cs > - struct to_string< X< Cs... > > - { - static std::string get() - { - const char s[] = { Cs..., 0 }; - return std::string( s, sizeof...( Cs ) ); - } - }; - - } // namespace internal - - template< typename T > - std::string to_string() - { - return internal::to_string< T >::get(); - } - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/contrib/tracer.hpp b/MoonParser/pegtl/contrib/tracer.hpp deleted file mode 100644 index 5649078..0000000 --- a/MoonParser/pegtl/contrib/tracer.hpp +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_TRACER_HPP -#define TAOCPP_PEGTL_INCLUDE_CONTRIB_TRACER_HPP - -#include <cassert> -#include <iomanip> -#include <iostream> -#include <utility> -#include <vector> - -#include "../config.hpp" -#include "../normal.hpp" - -#include "../internal/demangle.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - struct trace_state - { - unsigned rule = 0; - unsigned line = 0; - std::vector< unsigned > stack; - }; - - template< typename Rule > - struct tracer - : normal< Rule > - { - template< typename Input, typename... States > - static void start( const Input& in, States&&... ) - { - std::cerr << in.position() << " start " << internal::demangle< Rule >() << std::endl; - } - - template< typename Input > - static void start( const Input& in, trace_state& ts ) - { - std::cerr << std::setw( 6 ) << ++ts.line << " " << std::setw( 6 ) << ++ts.rule << " " << in.position() << " start " << internal::demangle< Rule >() << std::endl; - ts.stack.push_back( ts.rule ); - } - - template< typename Input, typename... States > - static void success( const Input& in, States&&... ) - { - std::cerr << in.position() << " success " << internal::demangle< Rule >() << std::endl; - } - - template< typename Input > - static void success( const Input& in, trace_state& ts ) - { - 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; - ts.stack.pop_back(); - } - - template< typename Input, typename... States > - static void failure( const Input& in, States&&... ) - { - std::cerr << in.position() << " failure " << internal::demangle< Rule >() << std::endl; - } - - template< typename Input > - static void failure( const Input& in, trace_state& ts ) - { - 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; - ts.stack.pop_back(); - } - - template< template< typename... > class Action, typename Input, typename... States > - static void apply0( const Input&, States&&... st ) - { - std::cerr << "apply0 " << internal::demangle< Action< Rule > >() << std::endl; - Action< Rule >::apply0( st... ); - } - - template< template< typename... > class Action, typename Input > - static void apply0( const Input&, trace_state& ts ) - { - std::cerr << std::setw( 6 ) << ++ts.line << " " << internal::demangle< Action< Rule > >() << "::apply0()" << std::endl; - Action< Rule >::apply0( ts ); - } - - template< template< typename... > class Action, typename Iterator, typename Input, typename... States > - static void apply( const Iterator& begin, const Input& in, States&&... st ) - { - std::cerr << "apply " << internal::demangle< Action< Rule > >() << std::endl; - using action_t = typename Input::action_t; - const action_t action_input( begin, in ); - Action< Rule >::apply( action_input, st... ); - } - - template< template< typename... > class Action, typename Iterator, typename Input > - static void apply( const Iterator& begin, const Input& in, trace_state& ts ) - { - 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 ); - Action< Rule >::apply( action_input, ts ); - } - }; - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/contrib/unescape.hpp b/MoonParser/pegtl/contrib/unescape.hpp deleted file mode 100644 index 2a7c53f..0000000 --- a/MoonParser/pegtl/contrib/unescape.hpp +++ /dev/null @@ -1,203 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_UNESCAPE_HPP -#define TAOCPP_PEGTL_INCLUDE_CONTRIB_UNESCAPE_HPP - -#include <cassert> -#include <string> - -#include "../ascii.hpp" -#include "../config.hpp" -#include "../parse_error.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - 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 ) { - char tmp[] = { char( ( ( utf32 & 0xf000 ) >> 12 ) | 0xe0 ), - char( ( ( utf32 & 0x0fc0 ) >> 6 ) | 0x80 ), - char( ( ( utf32 & 0x003f ) ) | 0x80 ) }; - string.append( tmp, sizeof( tmp ) ); - return true; - } - if( utf32 <= 0x10ffff ) { - char tmp[] = { char( ( ( utf32 & 0x1c0000 ) >> 18 ) | 0xf0 ), - char( ( ( utf32 & 0x03f000 ) >> 12 ) | 0x80 ), - char( ( ( utf32 & 0x000fc0 ) >> 6 ) | 0x80 ), - char( ( ( utf32 & 0x00003f ) ) | 0x80 ) }; - string.append( tmp, sizeof( tmp ) ); - return true; - } - return false; - } - - // This function MUST only be called for characters matching tao::TAOCPP_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 ); - } - throw std::runtime_error( "invalid character in unhex" ); // LCOV_EXCL_LINE - } - - template< typename I > - I unhex_string( const char* begin, const char* const end ) - { - I r = 0; - while( begin != end ) { - r <<= 4; - r += unhex_char< I >( *begin++ ); - } - return r; - } - - // Actions for common unescape situations. - - struct append_all - { - template< typename 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::TAOCPP_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.begin(), static_cast< const T* >( nullptr ) ); - } - - template< char... Qs > - static char apply_one( const char c, const one< Qs... >* ) - { - static_assert( sizeof...( Qs ) == sizeof...( Rs ), "size mismatch between escaped characters and their mappings" ); - return apply_two( c, { Qs... }, { Rs... } ); - } - - static char apply_two( const char c, const std::initializer_list< char >& q, const std::initializer_list< char >& r ) - { - for( std::size_t i = 0; i < q.size(); ++i ) { - if( *( q.begin() + i ) == c ) { - return *( r.begin() + i ); - } - } - throw std::runtime_error( "invalid character in unescape" ); // 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, 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 ); - } - } - }; - - 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() ); - } - }; - - // 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 7159. - - 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; - utf8_append_utf32( st.unescaped, ( ( ( c & 0x03ff ) << 10 ) | ( d & 0x03ff ) ) + 0x10000 ); - continue; - } - } - utf8_append_utf32( st.unescaped, c ); - } - } - }; - - } // namespace unescape - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/contrib/uri.hpp b/MoonParser/pegtl/contrib/uri.hpp deleted file mode 100644 index 1401a7d..0000000 --- a/MoonParser/pegtl/contrib/uri.hpp +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_URI_HPP -#define TAOCPP_PEGTL_INCLUDE_CONTRIB_URI_HPP - -#include "../ascii.hpp" -#include "../config.hpp" -#include "../rules.hpp" -#include "../utf8.hpp" - -#include "abnf.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace uri - { - // URI grammar according to RFC 3986. - - // This grammar is a direct PEG translation of the original URI grammar. - // It should be considered experimental -- in case of any issues, in particular - // missing rules for attached actions, please contact the developers. - - // Note that this grammar has multiple top-level rules. - - using namespace abnf; - - using dot = one< '.' >; - using colon = one< ':' >; - - // clang-format off - struct dec_octet : sor< one< '0' >, - rep_min_max< 1, 2, DIGIT >, - seq< one< '1' >, DIGIT, DIGIT >, - seq< one< '2' >, range< '0', '4' >, DIGIT >, - seq< string< '2', '5' >, range< '0', '5' > > > {}; - - struct IPv4address : seq< dec_octet, dot, dec_octet, dot, dec_octet, dot, dec_octet > {}; - - struct h16 : rep_min_max< 1, 4, HEXDIG > {}; - struct ls32 : sor< seq< h16, colon, h16 >, IPv4address > {}; - - struct dcolon : two< ':' > {}; - - struct IPv6address : sor< seq< rep< 6, h16, colon >, ls32 >, - seq< dcolon, rep< 5, h16, colon >, ls32 >, - seq< opt< h16 >, dcolon, rep< 4, h16, colon >, ls32 >, - seq< opt< h16, opt< colon, h16 > >, dcolon, rep< 3, h16, colon >, ls32 >, - seq< opt< h16, rep_opt< 2, colon, h16 > >, dcolon, rep< 2, h16, colon >, ls32 >, - seq< opt< h16, rep_opt< 3, colon, h16 > >, dcolon, h16, colon, ls32 >, - seq< opt< h16, rep_opt< 4, colon, h16 > >, dcolon, ls32 >, - seq< opt< h16, rep_opt< 5, colon, h16 > >, dcolon, h16 >, - seq< opt< h16, rep_opt< 6, colon, h16 > >, dcolon > > {}; - - struct gen_delims : one< ':', '/', '?', '#', '[', ']', '@' > {}; - struct sub_delims : one< '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=' > {}; - - struct unreserved : sor< ALPHA, DIGIT, one< '-', '.', '_', '~' > > {}; - struct reserved : sor< gen_delims, sub_delims > {}; - - struct IPvFuture : if_must< one< 'v' >, plus< HEXDIG >, dot, plus< sor< unreserved, sub_delims, colon > > > {}; - - struct IP_literal : if_must< one< '[' >, sor< IPvFuture, IPv6address >, one< ']' > > {}; - - struct pct_encoded : if_must< one< '%' >, HEXDIG, HEXDIG > {}; - struct pchar : sor< unreserved, pct_encoded, sub_delims, one< ':', '@' > > {}; - - struct query : star< sor< pchar, one< '/', '?' > > > {}; - struct fragment : star< sor< pchar, one< '/', '?' > > > {}; - - struct segment : star< pchar > {}; - struct segment_nz : plus< pchar > {}; - struct segment_nz_nc : plus< sor< unreserved, pct_encoded, sub_delims, one< '@' > > > {}; // non-zero-length segment without any colon ":" - - struct path_abempty : star< one< '/' >, segment > {}; - struct path_absolute : seq< one< '/' >, opt< segment_nz, star< one< '/' >, segment > > > {}; - struct path_noscheme : seq< segment_nz_nc, star< one< '/' >, segment > > {}; - struct path_rootless : seq< segment_nz, star< one< '/' >, segment > > {}; - struct path_empty : success {}; - - struct path : sor< path_noscheme, // begins with a non-colon segment - path_rootless, // begins with a segment - path_absolute, // begins with "/" but not "//" - path_abempty > {}; // begins with "/" or is empty - - struct reg_name : star< sor< unreserved, pct_encoded, sub_delims > > {}; - - struct port : star< DIGIT > {}; - struct host : sor< IP_literal, IPv4address, reg_name > {}; - struct userinfo : star< sor< unreserved, pct_encoded, sub_delims, colon > > {}; - struct authority : seq< opt< userinfo, one< '@' > >, host, opt< colon, port > > {}; - - struct scheme : seq< ALPHA, star< sor< ALPHA, DIGIT, one< '+', '-', '.' > > > > {}; - - using dslash = two< '/' >; - using opt_query = opt< if_must< one< '?' >, query > >; - using opt_fragment = opt< if_must< one< '#' >, fragment > >; - - struct hier_part : sor< if_must< dslash, authority, path_abempty >, path_rootless, path_absolute, path_empty > {}; - struct relative_part : sor< if_must< dslash, authority, path_abempty >, path_noscheme, path_absolute, path_empty > {}; - struct relative_ref : seq< relative_part, opt_query, opt_fragment > {}; - - struct URI : seq< scheme, one< ':' >, hier_part, opt_query, opt_fragment > {}; - struct URI_reference : sor< URI, relative_ref > {}; - struct absolute_URI : seq< scheme, one< ':' >, hier_part, opt_query > {}; - // clang-format on - - } // namespace uri - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/cstream_input.hpp b/MoonParser/pegtl/cstream_input.hpp deleted file mode 100644 index ad520e3..0000000 --- a/MoonParser/pegtl/cstream_input.hpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_CSTREAM_INPUT_HPP -#define TAOCPP_PEGTL_INCLUDE_CSTREAM_INPUT_HPP - -#include <cstdio> - -#include "buffer_input.hpp" -#include "config.hpp" -#include "eol.hpp" - -#include "internal/cstream_reader.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - 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 ) - : buffer_input< internal::cstream_reader, Eol >( std::forward< T >( in_source ), in_maximum, in_stream ) - { - } - }; - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/eol.hpp b/MoonParser/pegtl/eol.hpp deleted file mode 100644 index ca3e604..0000000 --- a/MoonParser/pegtl/eol.hpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_EOL_HPP -#define TAOCPP_PEGTL_INCLUDE_EOL_HPP - -#include <cstddef> -#include <utility> - -#include "config.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - using eol_pair = std::pair< bool, std::size_t >; - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#include "internal/cr_crlf_eol.hpp" -#include "internal/cr_eol.hpp" -#include "internal/crlf_eol.hpp" -#include "internal/lf_crlf_eol.hpp" -#include "internal/lf_eol.hpp" - -#include "internal/eol.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - inline namespace ascii - { - // 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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/file_input.hpp b/MoonParser/pegtl/file_input.hpp deleted file mode 100644 index 625d491..0000000 --- a/MoonParser/pegtl/file_input.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2015-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_FILE_INPUT_HPP -#define TAOCPP_PEGTL_INCLUDE_FILE_INPUT_HPP - -#include "config.hpp" -#include "eol.hpp" -#include "tracking_mode.hpp" - -#if defined( __unix__ ) || ( defined( __APPLE__ ) && defined( __MACH__ ) ) -#include <unistd.h> // Required for _POSIX_MAPPED_FILES -#endif - -#if defined( _POSIX_MAPPED_FILES ) -#include "mmap_input.hpp" -#else -#include "read_input.hpp" -#endif - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { -#if defined( _POSIX_MAPPED_FILES ) - template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf > - using file_input = mmap_input< P, Eol >; -#else - template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf > - using file_input = read_input< P, Eol >; -#endif - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/input_error.hpp b/MoonParser/pegtl/input_error.hpp deleted file mode 100644 index 605ce4d..0000000 --- a/MoonParser/pegtl/input_error.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INPUT_ERROR_HPP -#define TAOCPP_PEGTL_INCLUDE_INPUT_ERROR_HPP - -#include <cerrno> -#include <sstream> -#include <stdexcept> - -#include "config.hpp" - -namespace tao -{ - namespace TAOCPP_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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#define TAOCPP_PEGTL_THROW_INPUT_ERROR( MESSAGE ) \ - do { \ - const int errorno = errno; \ - std::ostringstream oss; \ - oss << "pegtl: " << MESSAGE << " errno " << errorno; \ - throw tao::TAOCPP_PEGTL_NAMESPACE::input_error( oss.str(), errorno ); \ - } while( false ) - -#endif diff --git a/MoonParser/pegtl/internal/action.hpp b/MoonParser/pegtl/internal/action.hpp deleted file mode 100644 index 933bffe..0000000 --- a/MoonParser/pegtl/internal/action.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_ACTION_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_ACTION_HPP - -#include "../config.hpp" - -#include "duseltronik.hpp" -#include "seq.hpp" -#include "skip_control.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - 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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/action_input.hpp b/MoonParser/pegtl/internal/action_input.hpp deleted file mode 100644 index db48950..0000000 --- a/MoonParser/pegtl/internal/action_input.hpp +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_ACTION_INPUT_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_ACTION_INPUT_HPP - -#include <cstddef> -#include <string> - -#include "iterator.hpp" - -#include "../config.hpp" -#include "../position.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - inline const char* begin_c_ptr( const char* p ) noexcept - { - return p; - } - - inline const char* begin_c_ptr( const iterator& it ) noexcept - { - return it.data; - } - - 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& operator=( const 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 ]; - } - - unsigned char peek_byte( const std::size_t offset = 0 ) const noexcept - { - return static_cast< unsigned char >( peek_char( offset ) ); - } - - TAOCPP_PEGTL_NAMESPACE::position position() const noexcept - { - return input().position( iterator() ); // NOTE: Not efficient with LAZY inputs. - } - - protected: - const iterator_t m_begin; - const Input& m_input; - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/alnum.hpp b/MoonParser/pegtl/internal/alnum.hpp deleted file mode 100644 index cdad330..0000000 --- a/MoonParser/pegtl/internal/alnum.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_ALNUM_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_ALNUM_HPP - -#include "../config.hpp" - -#include "peek_char.hpp" -#include "ranges.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - using alnum = ranges< peek_char, 'a', 'z', 'A', 'Z', '0', '9' >; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/alpha.hpp b/MoonParser/pegtl/internal/alpha.hpp deleted file mode 100644 index d696ca2..0000000 --- a/MoonParser/pegtl/internal/alpha.hpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_ALPHA_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_ALPHA_HPP - -#include "../config.hpp" - -#include "peek_char.hpp" -#include "ranges.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - using alpha = ranges< peek_char, 'a', 'z', 'A', 'Z' >; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/any.hpp b/MoonParser/pegtl/internal/any.hpp deleted file mode 100644 index aebe239..0000000 --- a/MoonParser/pegtl/internal/any.hpp +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_ANY_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_ANY_HPP - -#include "../config.hpp" - -#include "peek_char.hpp" -#include "skip_control.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_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 Input > - static bool match( Input& in ) - { - 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 ) - { - if( !in.empty() ) { - if( const auto t = Peek::peek( in ) ) { - in.bump( t.size ); - return true; - } - } - return false; - } - }; - - template< typename Peek > - struct skip_control< any< Peek > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/apply.hpp b/MoonParser/pegtl/internal/apply.hpp deleted file mode 100644 index 4e70255..0000000 --- a/MoonParser/pegtl/internal/apply.hpp +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_APPLY_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_APPLY_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../analysis/counted.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< apply_mode A, typename... Actions > - struct apply_impl; - - 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 - ( Actions::apply( i2, st... ), ... ); -#else - using swallow = bool[]; - (void)swallow{ ( Actions::apply( i2, st... ), true )..., true }; -#endif - return true; - } - }; - - template< typename... Actions > - struct apply_impl< apply_mode::NOTHING, Actions... > - { - template< typename Input, typename... States > - static bool match( Input&, States&&... ) - { - 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 - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/apply0.hpp b/MoonParser/pegtl/internal/apply0.hpp deleted file mode 100644 index c8aa7aa..0000000 --- a/MoonParser/pegtl/internal/apply0.hpp +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_APPLY0_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_APPLY0_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../analysis/counted.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< apply_mode A, typename... Actions > - struct apply0_impl; - - template< typename... Actions > - struct apply0_impl< apply_mode::ACTION, Actions... > - { - template< typename... States > - static bool match( States&&... st ) - { -#ifdef __cpp_fold_expressions - ( Actions::apply0( st... ), ... ); -#else - using swallow = bool[]; - (void)swallow{ ( Actions::apply0( st... ), true )..., true }; -#endif - return true; - } - }; - - template< typename... Actions > - struct apply0_impl< apply_mode::NOTHING, Actions... > - { - template< typename... States > - static bool match( States&&... ) - { - 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&, States&&... st ) - { - return apply0_impl< A, Actions... >::match( st... ); - } - }; - - template< typename... Actions > - struct skip_control< apply0< Actions... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/at.hpp b/MoonParser/pegtl/internal/at.hpp deleted file mode 100644 index d5bb455..0000000 --- a/MoonParser/pegtl/internal/at.hpp +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_AT_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_AT_HPP - -#include "../config.hpp" - -#include "rule_conjunction.hpp" -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - 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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/bof.hpp b/MoonParser/pegtl/internal/bof.hpp deleted file mode 100644 index 8a1dde7..0000000 --- a/MoonParser/pegtl/internal/bof.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_BOF_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_BOF_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - 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; - } - }; - - template<> - struct skip_control< bof > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/bol.hpp b/MoonParser/pegtl/internal/bol.hpp deleted file mode 100644 index bf3e33f..0000000 --- a/MoonParser/pegtl/internal/bol.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_BOL_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_BOL_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - 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; - } - }; - - template<> - struct skip_control< bol > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/bump_help.hpp b/MoonParser/pegtl/internal/bump_help.hpp deleted file mode 100644 index 577870e..0000000 --- a/MoonParser/pegtl/internal/bump_help.hpp +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) 2015-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_BUMP_UTIL_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_BUMP_UTIL_HPP - -#include <cstddef> -#include <type_traits> - -#include "../config.hpp" - -#include "result_on_found.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - 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 - { - using eol_t = typename Input::eol_t; - bump_impl< bool_and< ( Cs != eol_t::ch )... >::value != bool( R ) >::bump( in, count ); - } - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/bump_impl.hpp b/MoonParser/pegtl/internal/bump_impl.hpp deleted file mode 100644 index 6ab9005..0000000 --- a/MoonParser/pegtl/internal/bump_impl.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_BUMP_IMPL_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_BUMP_IMPL_HPP - -#include "../config.hpp" - -#include "iterator.hpp" - -namespace tao -{ - namespace TAOCPP_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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/bytes.hpp b/MoonParser/pegtl/internal/bytes.hpp deleted file mode 100644 index c180a68..0000000 --- a/MoonParser/pegtl/internal/bytes.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_BYTES_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_BYTES_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" - -#include "../analysis/counted.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< unsigned Num > - struct bytes - { - using analyze_t = analysis::counted< analysis::rule_type::ANY, Num >; - - template< typename Input > - static bool match( Input& in ) - { - 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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/control.hpp b/MoonParser/pegtl/internal/control.hpp deleted file mode 100644 index 16fab5c..0000000 --- a/MoonParser/pegtl/internal/control.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_CONTROL_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_CONTROL_HPP - -#include "../config.hpp" - -#include "duseltronik.hpp" -#include "seq.hpp" -#include "skip_control.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - 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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/cr_crlf_eol.hpp b/MoonParser/pegtl/internal/cr_crlf_eol.hpp deleted file mode 100644 index ebfc75d..0000000 --- a/MoonParser/pegtl/internal/cr_crlf_eol.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_CR_CRLF_EOL_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_CR_CRLF_EOL_HPP - -#include "../config.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - struct cr_crlf_eol - { - static constexpr int ch = '\r'; - - template< typename Input > - static eol_pair match( Input& in ) - { - 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; - } - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/cr_eol.hpp b/MoonParser/pegtl/internal/cr_eol.hpp deleted file mode 100644 index 79388eb..0000000 --- a/MoonParser/pegtl/internal/cr_eol.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_CR_EOL_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_CR_EOL_HPP - -#include "../config.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - struct cr_eol - { - static constexpr int ch = '\r'; - - template< typename Input > - static eol_pair match( Input& in ) - { - 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; - } - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/crlf_eol.hpp b/MoonParser/pegtl/internal/crlf_eol.hpp deleted file mode 100644 index 621b6b3..0000000 --- a/MoonParser/pegtl/internal/crlf_eol.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_CRLF_EOL_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_CRLF_EOL_HPP - -#include "../config.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - struct crlf_eol - { - static constexpr int ch = '\n'; - - template< typename Input > - static eol_pair match( Input& in ) - { - 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; - } - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/cstream_reader.hpp b/MoonParser/pegtl/internal/cstream_reader.hpp deleted file mode 100644 index c1670bf..0000000 --- a/MoonParser/pegtl/internal/cstream_reader.hpp +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_CSTREAM_READER_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_CSTREAM_READER_HPP - -#include <cstddef> -#include <cstdio> - -#include "../config.hpp" -#include "../input_error.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - struct cstream_reader - { - explicit cstream_reader( std::FILE* s ) noexcept - : m_cstream( s ) - { - } - - 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. - TAOCPP_PEGTL_THROW_INPUT_ERROR( "error in fread() from cstream" ); // LCOV_EXCL_LINE - } - - std::FILE* m_cstream; - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/cstring_reader.hpp b/MoonParser/pegtl/internal/cstring_reader.hpp deleted file mode 100644 index ff8c11e..0000000 --- a/MoonParser/pegtl/internal/cstring_reader.hpp +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_CSTRING_READER_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_CSTRING_READER_HPP - -#include <cassert> -#include <cstddef> - -#include "../config.hpp" -#include "../input_error.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - struct cstring_reader - { - explicit cstring_reader( const char* zero_terminated ) noexcept - : m_cstring( zero_terminated ) - { - assert( m_cstring ); - } - - 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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/demangle.hpp b/MoonParser/pegtl/internal/demangle.hpp deleted file mode 100644 index 64efe6f..0000000 --- a/MoonParser/pegtl/internal/demangle.hpp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_DEMANGLE_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_DEMANGLE_HPP - -#include <string> -#include <typeinfo> - -#include "../config.hpp" - -#if defined( __GLIBCXX__ ) -#include "demangle_cxxabi.hpp" -#elif defined( __has_include ) -// clang-format off -#if __has_include( <cxxabi.h> ) -// clang-format on -#include "demangle_cxxabi.hpp" -#else -#include "demangle_nop.hpp" -#endif -#else -#include "demangle_nop.hpp" -#endif - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< typename T > - std::string demangle() - { - return demangle( typeid( T ).name() ); - } - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/demangle_cxxabi.hpp b/MoonParser/pegtl/internal/demangle_cxxabi.hpp deleted file mode 100644 index aba72f9..0000000 --- a/MoonParser/pegtl/internal/demangle_cxxabi.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_DEMANGLE_CXXABI_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_DEMANGLE_CXXABI_HPP - -#include <cstdlib> -#include <cxxabi.h> -#include <memory> -#include <string> - -#include "../config.hpp" - -#include "demangle_sanitise.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - 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 TAOCPP_PEGTL_PRETTY_DEMANGLE - demangle_sanitise_chars( result ); -#endif - return result; - } - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/demangle_nop.hpp b/MoonParser/pegtl/internal/demangle_nop.hpp deleted file mode 100644 index 70bf3ec..0000000 --- a/MoonParser/pegtl/internal/demangle_nop.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_DEMANGLE_NOP_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_DEMANGLE_NOP_HPP - -#include <string> - -#include "../config.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - inline std::string demangle( const char* symbol ) - { - return symbol; - } - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/demangle_sanitise.hpp b/MoonParser/pegtl/internal/demangle_sanitise.hpp deleted file mode 100644 index f869ea6..0000000 --- a/MoonParser/pegtl/internal/demangle_sanitise.hpp +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_DEMANGLE_SANITISE_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_DEMANGLE_SANITISE_HPP - -#include <string> - -#include "../config.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - 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 ) + '\'' ); - } - } - } - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/disable.hpp b/MoonParser/pegtl/internal/disable.hpp deleted file mode 100644 index 19ccb1e..0000000 --- a/MoonParser/pegtl/internal/disable.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_DISABLE_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_DISABLE_HPP - -#include "../config.hpp" - -#include "duseltronik.hpp" -#include "seq.hpp" -#include "skip_control.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - 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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/discard.hpp b/MoonParser/pegtl/internal/discard.hpp deleted file mode 100644 index 9aac60f..0000000 --- a/MoonParser/pegtl/internal/discard.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_DISCARD_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_DISCARD_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - struct discard - { - using analyze_t = analysis::generic< analysis::rule_type::OPT >; - - template< typename Input > - static bool match( Input& in ) - { - in.discard(); - return true; - } - }; - - template<> - struct skip_control< discard > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/dusel_mode.hpp b/MoonParser/pegtl/internal/dusel_mode.hpp deleted file mode 100644 index df757aa..0000000 --- a/MoonParser/pegtl/internal/dusel_mode.hpp +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_DUSEL_MODE_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_DUSEL_MODE_HPP - -#include "../config.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - enum class dusel_mode : char - { - NOTHING = 0, - CONTROL = 1, - CONTROL_AND_APPLY = 2, - CONTROL_AND_APPLY0 = 3 - }; - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/duseltronik.hpp b/MoonParser/pegtl/internal/duseltronik.hpp deleted file mode 100644 index 23a6e1f..0000000 --- a/MoonParser/pegtl/internal/duseltronik.hpp +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_DUSELTRONIK_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_DUSELTRONIK_HPP - -#include "../apply_mode.hpp" -#include "../config.hpp" -#include "../rewind_mode.hpp" - -#include "dusel_mode.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - 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... ); - } - - // NOTE: The additional "int = 0" is a work-around for missing expression SFINAE in VS2015. - - template< typename Input, typename... States, int = 0 > - static auto match( Input& in, States&&... ) -> 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( const_cast< const Input& >( in ), st... ); - - if( duseltronik< Rule, A, M, Action, Control, dusel_mode::NOTHING >::match( in, st... ) ) { - Control< Rule >::success( const_cast< const Input& >( in ), st... ); - return true; - } - Control< Rule >::failure( const_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 > - { - template< typename Input, typename... States > - static bool match( Input& in, States&&... st ) - { - auto m = in.template mark< rewind_mode::REQUIRED >(); - - if( duseltronik< Rule, A, rewind_mode::ACTIVE, Action, Control, dusel_mode::CONTROL >::match( in, st... ) ) { - Control< Rule >::template apply< Action >( m.iterator(), const_cast< const Input& >( in ), st... ); - return m( true ); - } - 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 > - { - template< typename Input, typename... States > - static bool match( Input& in, States&&... st ) - { - if( duseltronik< Rule, A, M, Action, Control, dusel_mode::CONTROL >::match( in, st... ) ) { - Control< Rule >::template apply0< Action >( const_cast< const Input& >( in ), st... ); - return true; - } - return false; - } - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/enable.hpp b/MoonParser/pegtl/internal/enable.hpp deleted file mode 100644 index c01268c..0000000 --- a/MoonParser/pegtl/internal/enable.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_ENABLE_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_ENABLE_HPP - -#include "../config.hpp" - -#include "duseltronik.hpp" -#include "seq.hpp" -#include "skip_control.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - 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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/eof.hpp b/MoonParser/pegtl/internal/eof.hpp deleted file mode 100644 index a702fa6..0000000 --- a/MoonParser/pegtl/internal/eof.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_EOF_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_EOF_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - struct eof - { - using analyze_t = analysis::generic< analysis::rule_type::OPT >; - - template< typename Input > - static bool match( Input& in ) - { - return in.empty(); - } - }; - - template<> - struct skip_control< eof > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/eol.hpp b/MoonParser/pegtl/internal/eol.hpp deleted file mode 100644 index bfd43c2..0000000 --- a/MoonParser/pegtl/internal/eol.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_EOL_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_EOL_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - struct eol - { - using analyze_t = analysis::generic< analysis::rule_type::ANY >; - - template< typename Input > - static bool match( Input& in ) - { - using eol_t = typename Input::eol_t; - return eol_t::match( in ).first; - } - }; - - template<> - struct skip_control< eol > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/eolf.hpp b/MoonParser/pegtl/internal/eolf.hpp deleted file mode 100644 index 168311c..0000000 --- a/MoonParser/pegtl/internal/eolf.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_EOLF_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_EOLF_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - struct eolf - { - using analyze_t = analysis::generic< analysis::rule_type::OPT >; - - template< typename Input > - static bool match( Input& in ) - { - using eol_t = typename Input::eol_t; - const auto p = eol_t::match( in ); - return p.first || ( !p.second ); - } - }; - - template<> - struct skip_control< eolf > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/file_mapper.hpp b/MoonParser/pegtl/internal/file_mapper.hpp deleted file mode 100644 index 800b9df..0000000 --- a/MoonParser/pegtl/internal/file_mapper.hpp +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_FILE_MAPPER_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_FILE_MAPPER_HPP - -#include <sys/mman.h> -#include <unistd.h> - -#include "../config.hpp" - -#include "file_opener.hpp" - -#include "../input_error.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - 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 && ( intptr_t( m_data ) == -1 ) ) { - TAOCPP_PEGTL_THROW_INPUT_ERROR( "unable to mmap() file " << reader.m_source << " descriptor " << reader.m_fd ); - } - } - - ~file_mapper() noexcept - { - ::munmap( const_cast< char* >( m_data ), m_size ); // Legacy C interface requires pointer-to-mutable but does not write through the pointer. - } - - file_mapper( const file_mapper& ) = delete; - void operator=( const 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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/file_opener.hpp b/MoonParser/pegtl/internal/file_opener.hpp deleted file mode 100644 index 0b1ad6d..0000000 --- a/MoonParser/pegtl/internal/file_opener.hpp +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_FILE_OPENER_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_FILE_OPENER_HPP - -#include <fcntl.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> - -#include <utility> - -#include "../config.hpp" -#include "../input_error.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - struct file_opener - { - explicit file_opener( const char* filename ) - : m_source( filename ), - m_fd( open() ) - { - } - - ~file_opener() noexcept - { - ::close( m_fd ); - } - - file_opener( const file_opener& ) = delete; - void operator=( const file_opener& ) = delete; - - std::size_t size() const - { - struct stat st; - errno = 0; - if(::fstat( m_fd, &st ) < 0 ) { - TAOCPP_PEGTL_THROW_INPUT_ERROR( "unable to fstat() file " << m_source << " descriptor " << m_fd ); - } - return std::size_t( st.st_size ); - } - - const char* const m_source; - const int m_fd; - - private: - int open() const - { - errno = 0; - const int fd = ::open( m_source, O_RDONLY ); - if( fd >= 0 ) { - return fd; - } - TAOCPP_PEGTL_THROW_INPUT_ERROR( "unable to open() file " << m_source << " for reading" ); - } - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/file_reader.hpp b/MoonParser/pegtl/internal/file_reader.hpp deleted file mode 100644 index 9bcdf97..0000000 --- a/MoonParser/pegtl/internal/file_reader.hpp +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_FILE_READER_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_FILE_READER_HPP - -#include <cstdio> -#include <memory> -#include <string> -#include <utility> - -#include "../config.hpp" -#include "../input_error.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - struct file_close - { - void operator()( FILE* f ) const - { - std::fclose( f ); - } - }; - - class file_reader - { - public: - explicit file_reader( const char* filename ) - : m_source( filename ), - m_file( open() ) - { - } - - file_reader( const file_reader& ) = delete; - void operator=( const file_reader& ) = delete; - - std::size_t size() const - { - errno = 0; - if( std::fseek( m_file.get(), 0, SEEK_END ) != 0 ) { - TAOCPP_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 ) { - TAOCPP_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 ) { - TAOCPP_PEGTL_THROW_INPUT_ERROR( "unable to fseek() to beginning of file " << m_source ); // LCOV_EXCL_LINE - } - return std::size_t( s ); - } - - std::string read() const - { - std::string nrv; - nrv.resize( size() ); - errno = 0; - if( ( nrv.size() != 0 ) && ( std::fread( &nrv[ 0 ], nrv.size(), 1, m_file.get() ) != 1 ) ) { - TAOCPP_PEGTL_THROW_INPUT_ERROR( "unable to fread() file " << m_source << " size " << nrv.size() ); // LCOV_EXCL_LINE - } - return nrv; - } - - private: - const char* const m_source; - const std::unique_ptr< std::FILE, file_close > m_file; - - std::FILE* open() const - { - errno = 0; -#if defined( _MSC_VER ) - std::FILE* file; - if(::fopen_s( &file, m_source, "rb" ) == 0 ) -#else - if( auto* file = std::fopen( m_source, "rb" ) ) -#endif - { - return file; - } - TAOCPP_PEGTL_THROW_INPUT_ERROR( "unable to fopen() file " << m_source << " for reading" ); - } - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/has_apply0.hpp b/MoonParser/pegtl/internal/has_apply0.hpp deleted file mode 100644 index 01ef7f9..0000000 --- a/MoonParser/pegtl/internal/has_apply0.hpp +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_HAS_APPLY0_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_HAS_APPLY0_HPP - -#include <type_traits> - -#include "../config.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< typename... S > - struct type_list - { - }; - - template< typename A, typename L, typename = void > - struct has_apply0 : std::false_type - { - }; - - template< typename A, typename... S > - struct has_apply0< A, type_list< S... >, decltype( A::apply0( std::declval< S >()... ), void() ) > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/identifier.hpp b/MoonParser/pegtl/internal/identifier.hpp deleted file mode 100644 index 1ee4571..0000000 --- a/MoonParser/pegtl/internal/identifier.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_IDENTIFIER_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_IDENTIFIER_HPP - -#include "../config.hpp" - -#include "peek_char.hpp" -#include "ranges.hpp" -#include "seq.hpp" -#include "star.hpp" - -namespace tao -{ - namespace TAOCPP_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 > >; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/if_apply.hpp b/MoonParser/pegtl/internal/if_apply.hpp deleted file mode 100644 index 1e6bb99..0000000 --- a/MoonParser/pegtl/internal/if_apply.hpp +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_IF_APPLY_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_IF_APPLY_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< apply_mode A, typename Rule, typename... Actions > - struct if_apply_impl; - - 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 - ( Actions::apply( i2, st... ), ... ); -#else - using swallow = bool[]; - (void)swallow{ ( Actions::apply( i2, st... ), true )..., true }; -#endif - return m( true ); - } - 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... ); - } - }; - - 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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/if_must.hpp b/MoonParser/pegtl/internal/if_must.hpp deleted file mode 100644 index 2a56d7e..0000000 --- a/MoonParser/pegtl/internal/if_must.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_IF_MUST_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_IF_MUST_HPP - -#include "../config.hpp" - -#include "must.hpp" -#include "seq.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Cond, typename... Thens > - using if_must = seq< Cond, must< Thens... > >; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/if_must_else.hpp b/MoonParser/pegtl/internal/if_must_else.hpp deleted file mode 100644 index 2ccb205..0000000 --- a/MoonParser/pegtl/internal/if_must_else.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_IF_MUST_ELSE_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_IF_MUST_ELSE_HPP - -#include "../config.hpp" - -#include "if_then_else.hpp" -#include "must.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Cond, typename Then, typename Else > - using if_must_else = if_then_else< Cond, must< Then >, must< Else > >; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/if_then_else.hpp b/MoonParser/pegtl/internal/if_then_else.hpp deleted file mode 100644 index e55831f..0000000 --- a/MoonParser/pegtl/internal/if_then_else.hpp +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_IF_THEN_ELSE_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_IF_THEN_ELSE_HPP - -#include "../config.hpp" - -#include "not_at.hpp" -#include "seq.hpp" -#include "skip_control.hpp" -#include "sor.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - 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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/input_pair.hpp b/MoonParser/pegtl/internal/input_pair.hpp deleted file mode 100644 index de4e6ba..0000000 --- a/MoonParser/pegtl/internal/input_pair.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_INPUT_PAIR_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_INPUT_PAIR_HPP - -#include "../config.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Data > - struct input_pair - { - Data data; - unsigned char size; - - using data_t = Data; - - explicit operator bool() const noexcept - { - return size > 0; - } - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/integer_sequence.hpp b/MoonParser/pegtl/internal/integer_sequence.hpp deleted file mode 100644 index cdcf20d..0000000 --- a/MoonParser/pegtl/internal/integer_sequence.hpp +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_INTEGER_SEQUENCE_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_INTEGER_SEQUENCE_HPP - -#include <cstddef> -#include <type_traits> -#include <utility> - -namespace tao -{ - namespace TAOCPP_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< typename, std::size_t, bool > - struct double_up; - - template< typename T, T... Ns, std::size_t N > - struct double_up< integer_sequence< T, Ns... >, N, false > - { - using type = integer_sequence< T, Ns..., ( N + Ns )... >; - }; - - template< typename T, T... Ns, std::size_t N > - struct double_up< integer_sequence< T, Ns... >, N, true > - { - using type = integer_sequence< T, Ns..., ( N + Ns )..., 2 * N >; - }; - - template< typename T, T N, typename = void > - struct generate_sequence; - - template< typename T, T N > - using generate_sequence_t = typename generate_sequence< T, N >::type; - - template< typename T, T N, typename > - struct generate_sequence - : double_up< generate_sequence_t< T, N / 2 >, N / 2, N % 2 == 1 > - { - }; - - template< typename T, T N > - struct generate_sequence< T, N, typename std::enable_if< ( N == 0 ) >::type > - { - using type = integer_sequence< T >; - }; - - template< typename T, T N > - struct generate_sequence< T, N, typename std::enable_if< ( N == 1 ) >::type > - { - using type = integer_sequence< T, 0 >; - }; - - template< typename T, T N > - using make_integer_sequence = generate_sequence_t< T, N >; - - 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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/istream_reader.hpp b/MoonParser/pegtl/internal/istream_reader.hpp deleted file mode 100644 index 8509080..0000000 --- a/MoonParser/pegtl/internal/istream_reader.hpp +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_ISTREAM_READER_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_ISTREAM_READER_HPP - -#include <istream> - -#include "../config.hpp" -#include "../input_error.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - 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; - } - TAOCPP_PEGTL_THROW_INPUT_ERROR( "error in istream.read()" ); - } - - std::istream& m_istream; - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/istring.hpp b/MoonParser/pegtl/internal/istring.hpp deleted file mode 100644 index 3ed2835..0000000 --- a/MoonParser/pegtl/internal/istring.hpp +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_ISTRING_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_ISTRING_HPP - -#include <type_traits> - -#include "../config.hpp" - -#include "bump_help.hpp" -#include "result_on_found.hpp" -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../analysis/counted.hpp" - -namespace tao -{ - namespace TAOCPP_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, bool A = is_alpha< C >::value > - struct ichar_equal; - - template< char C > - struct ichar_equal< C, true > - { - static bool match( const char c ) noexcept - { - return ( C | 0x20 ) == ( c | 0x20 ); - } - }; - - template< char C > - struct ichar_equal< C, false > - { - static bool match( const char c ) noexcept - { - return c == C; - } - }; - - template< char... Cs > - struct istring_equal; - - template<> - struct istring_equal<> - { - static bool match( const char* ) noexcept - { - 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 ) - { - 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 - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/iterator.hpp b/MoonParser/pegtl/internal/iterator.hpp deleted file mode 100644 index 4179738..0000000 --- a/MoonParser/pegtl/internal/iterator.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_ITERATOR_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_ITERATOR_HPP - -#include <cstdlib> - -#include "../config.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - struct iterator - { - iterator() noexcept = default; - - explicit iterator( const char* in_data ) noexcept - : data( in_data ), - byte( 0 ), - line( 1 ), - byte_in_line( 0 ) - { - } - - 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( const iterator& ) = default; - iterator& operator=( const iterator& ) = default; - - const char* data; - - std::size_t byte; - std::size_t line; - std::size_t byte_in_line; - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/lf_crlf_eol.hpp b/MoonParser/pegtl/internal/lf_crlf_eol.hpp deleted file mode 100644 index 90b5b03..0000000 --- a/MoonParser/pegtl/internal/lf_crlf_eol.hpp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_LF_CRLF_EOL_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_LF_CRLF_EOL_HPP - -#include "../config.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - struct lf_crlf_eol - { - static constexpr int ch = '\n'; - - template< typename Input > - static eol_pair match( Input& in ) - { - 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; - } - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/lf_eol.hpp b/MoonParser/pegtl/internal/lf_eol.hpp deleted file mode 100644 index 438b8f0..0000000 --- a/MoonParser/pegtl/internal/lf_eol.hpp +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_LF_EOL_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_LF_EOL_HPP - -#include "../config.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - struct lf_eol - { - static constexpr int ch = '\n'; - - template< typename Input > - static eol_pair match( Input& in ) - { - 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; - } - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/list.hpp b/MoonParser/pegtl/internal/list.hpp deleted file mode 100644 index 1a812fb..0000000 --- a/MoonParser/pegtl/internal/list.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_LIST_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_LIST_HPP - -#include "../config.hpp" - -#include "seq.hpp" -#include "star.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Rule, typename Sep > - using list = seq< Rule, star< Sep, Rule > >; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/list_must.hpp b/MoonParser/pegtl/internal/list_must.hpp deleted file mode 100644 index 9b60311..0000000 --- a/MoonParser/pegtl/internal/list_must.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_LIST_MUST_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_LIST_MUST_HPP - -#include "../config.hpp" - -#include "must.hpp" -#include "seq.hpp" -#include "star.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Rule, typename Sep > - using list_must = seq< Rule, star< Sep, must< Rule > > >; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/list_tail.hpp b/MoonParser/pegtl/internal/list_tail.hpp deleted file mode 100644 index dd7b920..0000000 --- a/MoonParser/pegtl/internal/list_tail.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_LIST_TAIL_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_LIST_TAIL_HPP - -#include "../config.hpp" - -#include "list.hpp" -#include "opt.hpp" -#include "seq.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Rule, typename Sep > - using list_tail = seq< list< Rule, Sep >, opt< Sep > >; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/list_tail_pad.hpp b/MoonParser/pegtl/internal/list_tail_pad.hpp deleted file mode 100644 index 0f3ebf6..0000000 --- a/MoonParser/pegtl/internal/list_tail_pad.hpp +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_LIST_TAIL_PAD_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_LIST_TAIL_PAD_HPP - -#include "../config.hpp" - -#include "list.hpp" -#include "opt.hpp" -#include "pad.hpp" -#include "seq.hpp" -#include "star.hpp" - -namespace tao -{ - namespace TAOCPP_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 > >; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/marker.hpp b/MoonParser/pegtl/internal/marker.hpp deleted file mode 100644 index 76cba0e..0000000 --- a/MoonParser/pegtl/internal/marker.hpp +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_MARKER_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_MARKER_HPP - -#include "../config.hpp" -#include "../rewind_mode.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Iterator, rewind_mode M > - class marker - { - public: - static constexpr rewind_mode next_rewind_mode = M; - - explicit marker( const Iterator& ) noexcept - { - } - - marker( marker&& ) noexcept - { - } - - marker( const marker& ) = delete; - void operator=( const 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( 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; - } - } - - marker( const marker& ) = delete; - void operator=( const 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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/minus.hpp b/MoonParser/pegtl/internal/minus.hpp deleted file mode 100644 index 88242e5..0000000 --- a/MoonParser/pegtl/internal/minus.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_MINUS_HPP -#define TAOCPP_PEGTL_INCLUDE_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 TAOCPP_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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/must.hpp b/MoonParser/pegtl/internal/must.hpp deleted file mode 100644 index 4ac9920..0000000 --- a/MoonParser/pegtl/internal/must.hpp +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_MUST_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_MUST_HPP - -#include "../config.hpp" - -#include "raise.hpp" -#include "rule_conjunction.hpp" -#include "skip_control.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - // 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. - - 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 > - 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 - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/not_at.hpp b/MoonParser/pegtl/internal/not_at.hpp deleted file mode 100644 index ed80c56..0000000 --- a/MoonParser/pegtl/internal/not_at.hpp +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_NOT_AT_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_NOT_AT_HPP - -#include "../config.hpp" - -#include "rule_conjunction.hpp" -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - 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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/one.hpp b/MoonParser/pegtl/internal/one.hpp deleted file mode 100644 index a3941eb..0000000 --- a/MoonParser/pegtl/internal/one.hpp +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_ONE_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_ONE_HPP - -#include <algorithm> -#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 TAOCPP_PEGTL_NAMESPACE - { - 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(); - } - - 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 ) - { - 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; - } - } - } - 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< typename Input > - static bool match( Input& in ) - { - 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; - } - } - } - 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 - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/opt.hpp b/MoonParser/pegtl/internal/opt.hpp deleted file mode 100644 index a897443..0000000 --- a/MoonParser/pegtl/internal/opt.hpp +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_OPT_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_OPT_HPP - -#include <type_traits> - -#include "../config.hpp" - -#include "duseltronik.hpp" -#include "seq.hpp" -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_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< 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( !in.empty() ) { - 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 - { - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/pad.hpp b/MoonParser/pegtl/internal/pad.hpp deleted file mode 100644 index fcb6e4f..0000000 --- a/MoonParser/pegtl/internal/pad.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_PAD_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_PAD_HPP - -#include "../config.hpp" - -#include "seq.hpp" -#include "star.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Rule, typename Pad1, typename Pad2 = Pad1 > - using pad = seq< star< Pad1 >, Rule, star< Pad2 > >; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/pad_opt.hpp b/MoonParser/pegtl/internal/pad_opt.hpp deleted file mode 100644 index 4b7d400..0000000 --- a/MoonParser/pegtl/internal/pad_opt.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_PAD_OPT_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_PAD_OPT_HPP - -#include "../config.hpp" - -#include "opt.hpp" -#include "seq.hpp" -#include "star.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Rule, typename Pad > - using pad_opt = seq< star< Pad >, opt< Rule, star< Pad > > >; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/peek_char.hpp b/MoonParser/pegtl/internal/peek_char.hpp deleted file mode 100644 index 064e6da..0000000 --- a/MoonParser/pegtl/internal/peek_char.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_PEEK_CHAR_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_PEEK_CHAR_HPP - -#include <cstddef> - -#include "input_pair.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - 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 ) - { - return { in.peek_char( o ), 1 }; - } - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/peek_utf16.hpp b/MoonParser/pegtl/internal/peek_utf16.hpp deleted file mode 100644 index a643b1f..0000000 --- a/MoonParser/pegtl/internal/peek_utf16.hpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_PEEK_UTF16_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_PEEK_UTF16_HPP - -#include <type_traits> - -#include "../config.hpp" - -#include "input_pair.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - struct peek_utf16 - { - 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 ) - { - const std::size_t s = in.size( 4 ); - if( s >= 2 ) { - const char32_t t = *reinterpret_cast< const short_t* >( in.current() ); - if( ( t < 0xd800 ) || ( t > 0xdbff ) || ( s < 4 ) ) { - return { t, 2 }; - } - const char32_t u = *reinterpret_cast< const short_t* >( in.current() + 2 ); - if( ( u < 0xdc00 ) || ( u > 0xdfff ) ) { - return { t, 2 }; - } - return { ( ( ( t & 0x03ff ) << 10 ) | ( u & 0x03ff ) ) + 0x10000, 4 }; - } - return { 0, 0 }; - } - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/peek_utf32.hpp b/MoonParser/pegtl/internal/peek_utf32.hpp deleted file mode 100644 index f082064..0000000 --- a/MoonParser/pegtl/internal/peek_utf32.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_PEEK_UTF32_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_PEEK_UTF32_HPP - -#include <cstddef> - -#include "../config.hpp" - -#include "input_pair.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - struct peek_utf32 - { - 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 ) - { - const std::size_t s = in.size( 4 ); - if( s >= 4 ) { - const char32_t t = *reinterpret_cast< const char32_t* >( in.current() ); - if( ( 0 <= t ) && ( t <= 0x10ffff ) ) { - return { t, 4 }; - } - } - return { 0, 0 }; - } - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/peek_utf8.hpp b/MoonParser/pegtl/internal/peek_utf8.hpp deleted file mode 100644 index 9ea0a0e..0000000 --- a/MoonParser/pegtl/internal/peek_utf8.hpp +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_PEEK_UTF8_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_PEEK_UTF8_HPP - -#include "../config.hpp" - -#include "input_pair.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - struct peek_utf8 - { - using data_t = char32_t; - using pair_t = input_pair< char32_t >; - - template< typename Input > - static pair_t peek( Input& in ) - { - char32_t c0 = in.peek_byte(); - - 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 }; - } - } - } - } - 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 ) { - 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 }; - } - } - } - } - return { 0, 0 }; - } - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/pegtl_string.hpp b/MoonParser/pegtl/internal/pegtl_string.hpp deleted file mode 100644 index 7c27fd8..0000000 --- a/MoonParser/pegtl/internal/pegtl_string.hpp +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (c) 2015-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_TAOCPP_PEGTL_STRING_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_TAOCPP_PEGTL_STRING_HPP - -#include <cstddef> -#include <type_traits> - -#include "../ascii.hpp" -#include "../config.hpp" - -namespace tao -{ - namespace TAOCPP_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. - - 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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#define TAOCPP_PEGTL_INTERNAL_EMPTY() -#define TAOCPP_PEGTL_INTERNAL_DEFER( X ) X TAOCPP_PEGTL_INTERNAL_EMPTY() -#define TAOCPP_PEGTL_INTERNAL_EXPAND( ... ) __VA_ARGS__ - -#define TAOCPP_PEGTL_INTERNAL_STRING_AT( S, x, n ) \ - tao::TAOCPP_PEGTL_NAMESPACE::internal::string_at< S, ( 0##n < sizeof( x ) ) ? x[ 0##n ] : 0, ( 0##n < sizeof( x ) - 1 ) >::type - -#define TAOCPP_PEGTL_INTERNAL_JOIN_8( M, S, x, n ) \ - tao::TAOCPP_PEGTL_NAMESPACE::internal::string_join< TAOCPP_PEGTL_INTERNAL_DEFER( M )( S, x, n##0 ), \ - TAOCPP_PEGTL_INTERNAL_DEFER( M )( S, x, n##1 ), \ - TAOCPP_PEGTL_INTERNAL_DEFER( M )( S, x, n##2 ), \ - TAOCPP_PEGTL_INTERNAL_DEFER( M )( S, x, n##3 ), \ - TAOCPP_PEGTL_INTERNAL_DEFER( M )( S, x, n##4 ), \ - TAOCPP_PEGTL_INTERNAL_DEFER( M )( S, x, n##5 ), \ - TAOCPP_PEGTL_INTERNAL_DEFER( M )( S, x, n##6 ), \ - TAOCPP_PEGTL_INTERNAL_DEFER( M )( S, x, n##7 ) >::type - -#define TAOCPP_PEGTL_INTERNAL_STRING_8( S, x, n ) \ - TAOCPP_PEGTL_INTERNAL_JOIN_8( TAOCPP_PEGTL_INTERNAL_STRING_AT, S, x, n ) - -#define TAOCPP_PEGTL_INTERNAL_STRING_64( S, x, n ) \ - TAOCPP_PEGTL_INTERNAL_JOIN_8( TAOCPP_PEGTL_INTERNAL_STRING_8, S, x, n ) - -#define TAOCPP_PEGTL_INTERNAL_STRING_512( S, x, n ) \ - TAOCPP_PEGTL_INTERNAL_JOIN_8( TAOCPP_PEGTL_INTERNAL_STRING_64, S, x, n ) - -#define TAOCPP_PEGTL_INTERNAL_STRING( S, x ) \ - TAOCPP_PEGTL_INTERNAL_EXPAND( \ - TAOCPP_PEGTL_INTERNAL_EXPAND( \ - TAOCPP_PEGTL_INTERNAL_EXPAND( \ - tao::TAOCPP_PEGTL_NAMESPACE::internal::string_max_length< TAOCPP_PEGTL_INTERNAL_STRING_512( S, x, ), sizeof( x ) - 1 >::type ) ) ) - -#define TAOCPP_PEGTL_STRING( x ) \ - TAOCPP_PEGTL_INTERNAL_STRING( tao::TAOCPP_PEGTL_NAMESPACE::ascii::string, x ) - -#define TAOCPP_PEGTL_ISTRING( x ) \ - TAOCPP_PEGTL_INTERNAL_STRING( tao::TAOCPP_PEGTL_NAMESPACE::ascii::istring, x ) - -#define TAOCPP_PEGTL_KEYWORD( x ) \ - TAOCPP_PEGTL_INTERNAL_STRING( tao::TAOCPP_PEGTL_NAMESPACE::ascii::keyword, x ) - -#endif diff --git a/MoonParser/pegtl/internal/plus.hpp b/MoonParser/pegtl/internal/plus.hpp deleted file mode 100644 index 5adc1f8..0000000 --- a/MoonParser/pegtl/internal/plus.hpp +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_PLUS_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_PLUS_HPP - -#include <type_traits> - -#include "../config.hpp" - -#include "duseltronik.hpp" -#include "opt.hpp" -#include "seq.hpp" -#include "skip_control.hpp" -#include "star.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - // 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 duseltronik< seq< Rule, Rules... >, A, M, Action, Control >::match( in, st... ) && duseltronik< star< Rule, Rules... >, A, M, Action, Control >::match( in, st... ); - } - }; - - template< typename Rule, typename... Rules > - struct skip_control< plus< Rule, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/raise.hpp b/MoonParser/pegtl/internal/raise.hpp deleted file mode 100644 index d183ce0..0000000 --- a/MoonParser/pegtl/internal/raise.hpp +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_RAISE_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_RAISE_HPP - -#include <cstdlib> -#include <type_traits> - -#include "../config.hpp" - -#include "skip_control.hpp" - -#include "../analysis/generic.hpp" -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< typename T > - struct raise - { - using analyze_t = analysis::generic< analysis::rule_type::ANY >; - - 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( const_cast< const Input& >( in ), st... ); -#if defined( _MSC_VER ) - __assume( false ); // LCOV_EXCL_LINE -#else - std::abort(); // LCOV_EXCL_LINE -#endif - } - }; - - template< typename T > - struct skip_control< raise< T > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/range.hpp b/MoonParser/pegtl/internal/range.hpp deleted file mode 100644 index 227595f..0000000 --- a/MoonParser/pegtl/internal/range.hpp +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_RANGE_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_RANGE_HPP - -#include "../config.hpp" - -#include "bump_help.hpp" -#include "result_on_found.hpp" -#include "skip_control.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< result_on_found R, typename Peek, typename Peek::data_t Lo, typename Peek::data_t Hi > - struct range - { - 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 ) - { - using eol_t = typename Input::eol_t; - - if( !in.empty() ) { - if( const auto t = Peek::peek( in ) ) { - if( ( ( Lo <= t.data ) && ( t.data <= Hi ) ) == bool( R ) ) { - bump_impl< can_match_eol< eol_t::ch >::value >::bump( in, 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 - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/ranges.hpp b/MoonParser/pegtl/internal/ranges.hpp deleted file mode 100644 index e3ee65c..0000000 --- a/MoonParser/pegtl/internal/ranges.hpp +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_RANGES_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_RANGES_HPP - -#include "../config.hpp" - -#include "bump_help.hpp" -#include "range.hpp" -#include "skip_control.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< int Eol, typename Char, Char... Cs > - struct ranges_impl; - - template< int Eol, typename Char > - struct ranges_impl< Eol, Char > - { - static constexpr bool can_match_eol = false; - - static bool match( const Char ) noexcept - { - return 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 c ) noexcept - { - return c == Eq; - } - }; - - template< int Eol, typename Char, Char Lo, Char Hi, Char... Cs > - struct ranges_impl< Eol, Char, Lo, Hi, Cs... > - { - static constexpr bool can_match_eol = ( ( ( Lo <= Eol ) && ( Eol <= Hi ) ) || ranges_impl< Eol, Char, Cs... >::can_match_eol ); - - 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 ) - { - using eol_t = typename Input::eol_t; - - if( !in.empty() ) { - if( const auto t = Peek::peek( in ) ) { - if( ranges_impl< eol_t::ch, typename Peek::data_t, Cs... >::match( t.data ) ) { - bump_impl< can_match_eol< eol_t::ch >::value >::bump( in, 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 - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/rep.hpp b/MoonParser/pegtl/internal/rep.hpp deleted file mode 100644 index df66ee2..0000000 --- a/MoonParser/pegtl/internal/rep.hpp +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_REP_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_REP_HPP - -#include "../config.hpp" - -#include "rule_conjunction.hpp" -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/counted.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< unsigned Num, typename... Rules > - struct rep; - - template< unsigned Num > - struct rep< Num > - : trivial< true > - { - }; - - template< typename Rule, typename... Rules > - struct rep< 0, Rule, Rules... > - : trivial< true > - { - }; - - 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 > - 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 ); - } - }; - - template< unsigned Num, typename... Rules > - struct skip_control< rep< Num, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/rep_min.hpp b/MoonParser/pegtl/internal/rep_min.hpp deleted file mode 100644 index f5e61da..0000000 --- a/MoonParser/pegtl/internal/rep_min.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_REP_MIN_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_REP_MIN_HPP - -#include "../config.hpp" - -#include "rep.hpp" -#include "seq.hpp" -#include "star.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< unsigned Min, typename Rule, typename... Rules > - using rep_min = seq< rep< Min, Rule, Rules... >, star< Rule, Rules... > >; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/rep_min_max.hpp b/MoonParser/pegtl/internal/rep_min_max.hpp deleted file mode 100644 index 7463398..0000000 --- a/MoonParser/pegtl/internal/rep_min_max.hpp +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_REP_MIN_MAX_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_REP_MIN_MAX_HPP - -#include <type_traits> - -#include "../config.hpp" - -#include "duseltronik.hpp" -#include "not_at.hpp" -#include "rule_conjunction.hpp" -#include "seq.hpp" -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/counted.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - 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. - } - }; - - template< unsigned Min, unsigned Max, typename... Rules > - struct skip_control< rep_min_max< Min, Max, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/rep_opt.hpp b/MoonParser/pegtl/internal/rep_opt.hpp deleted file mode 100644 index 55bcd47..0000000 --- a/MoonParser/pegtl/internal/rep_opt.hpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_REP_OPT_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_REP_OPT_HPP - -#include "../config.hpp" - -#include "duseltronik.hpp" -#include "seq.hpp" -#include "skip_control.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - 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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/require.hpp b/MoonParser/pegtl/internal/require.hpp deleted file mode 100644 index 0506356..0000000 --- a/MoonParser/pegtl/internal/require.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_REQUIRE_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_REQUIRE_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_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< typename Input > - static bool match( Input& in ) - { - return in.size( Amount ) >= Amount; - } - }; - - template< unsigned Amount > - struct skip_control< require< Amount > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/result_on_found.hpp b/MoonParser/pegtl/internal/result_on_found.hpp deleted file mode 100644 index e41f35c..0000000 --- a/MoonParser/pegtl/internal/result_on_found.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_RESULT_ON_FOUND_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_RESULT_ON_FOUND_HPP - -#include "../config.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - enum class result_on_found : bool - { - SUCCESS = true, - FAILURE = false - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/rule_conjunction.hpp b/MoonParser/pegtl/internal/rule_conjunction.hpp deleted file mode 100644 index 2eb41e2..0000000 --- a/MoonParser/pegtl/internal/rule_conjunction.hpp +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_RULE_CONJUNCTION_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_RULE_CONJUNCTION_HPP - -#include "../apply_mode.hpp" -#include "../config.hpp" -#include "../rewind_mode.hpp" - -namespace tao -{ - namespace TAOCPP_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&, States&&... ) - { - 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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/rules.hpp b/MoonParser/pegtl/internal/rules.hpp deleted file mode 100644 index 91725ae..0000000 --- a/MoonParser/pegtl/internal/rules.hpp +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_RULES_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_RULES_HPP - -#include "action.hpp" -#include "alnum.hpp" -#include "alpha.hpp" -#include "any.hpp" -#include "apply.hpp" -#include "apply0.hpp" -#include "at.hpp" -#include "bof.hpp" -#include "bol.hpp" -#include "bytes.hpp" -#include "control.hpp" -#include "disable.hpp" -#include "discard.hpp" -#include "enable.hpp" -#include "eof.hpp" -#include "eol.hpp" -#include "eolf.hpp" -#include "identifier.hpp" -#include "if_apply.hpp" -#include "if_must.hpp" -#include "if_must_else.hpp" -#include "if_then_else.hpp" -#include "istring.hpp" -#include "list.hpp" -#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" -#include "opt.hpp" -#include "pad.hpp" -#include "pad_opt.hpp" -#include "plus.hpp" -#include "raise.hpp" -#include "range.hpp" -#include "ranges.hpp" -#include "rep.hpp" -#include "rep_min.hpp" -#include "rep_min_max.hpp" -#include "rep_opt.hpp" -#include "require.hpp" -#include "seq.hpp" -#include "skip_control.hpp" -#include "sor.hpp" -#include "star.hpp" -#include "star_must.hpp" -#include "state.hpp" -#include "string.hpp" -#include "trivial.hpp" -#include "try_catch_type.hpp" -#include "until.hpp" - -#endif diff --git a/MoonParser/pegtl/internal/seq.hpp b/MoonParser/pegtl/internal/seq.hpp deleted file mode 100644 index f99cc7c..0000000 --- a/MoonParser/pegtl/internal/seq.hpp +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_SEQ_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_SEQ_HPP - -#include "../config.hpp" - -#include "rule_conjunction.hpp" -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_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< 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< typename... Rules > - struct skip_control< seq< Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/skip_control.hpp b/MoonParser/pegtl/internal/skip_control.hpp deleted file mode 100644 index e40ace5..0000000 --- a/MoonParser/pegtl/internal/skip_control.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_SKIP_CONTROL_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_SKIP_CONTROL_HPP - -#include <type_traits> - -#include "../config.hpp" - -namespace tao -{ - namespace TAOCPP_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. - - template< typename Rule > - struct skip_control : std::false_type - { - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/sor.hpp b/MoonParser/pegtl/internal/sor.hpp deleted file mode 100644 index 6d85a5c..0000000 --- a/MoonParser/pegtl/internal/sor.hpp +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_SOR_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_SOR_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -#include "integer_sequence.hpp" - -namespace tao -{ - namespace TAOCPP_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< 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< typename... Rules > - struct skip_control< sor< Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/star.hpp b/MoonParser/pegtl/internal/star.hpp deleted file mode 100644 index 854f25f..0000000 --- a/MoonParser/pegtl/internal/star.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_STAR_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_STAR_HPP - -#include <type_traits> - -#include "../config.hpp" - -#include "duseltronik.hpp" -#include "seq.hpp" -#include "skip_control.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - 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( duseltronik< seq< Rule, Rules... >, A, rewind_mode::REQUIRED, Action, Control >::match( in, st... ) ) { - } - return true; - } - }; - - template< typename Rule, typename... Rules > - struct skip_control< star< Rule, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/star_must.hpp b/MoonParser/pegtl/internal/star_must.hpp deleted file mode 100644 index baaef4f..0000000 --- a/MoonParser/pegtl/internal/star_must.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_STAR_MUST_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_STAR_MUST_HPP - -#include "../config.hpp" - -#include "if_must.hpp" -#include "star.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - template< typename Cond, typename... Rules > - using star_must = star< if_must< Cond, Rules... > >; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/state.hpp b/MoonParser/pegtl/internal/state.hpp deleted file mode 100644 index 7fbe921..0000000 --- a/MoonParser/pegtl/internal/state.hpp +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_STATE_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_STATE_HPP - -#include "../config.hpp" - -#include "duseltronik.hpp" -#include "seq.hpp" -#include "skip_control.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - 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( const_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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/string.hpp b/MoonParser/pegtl/internal/string.hpp deleted file mode 100644 index 75245e3..0000000 --- a/MoonParser/pegtl/internal/string.hpp +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_STRING_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_STRING_HPP - -#include <cstring> -#include <utility> - -#include "../config.hpp" - -#include "bump_help.hpp" -#include "result_on_found.hpp" -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../analysis/counted.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - 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; - } - - template< char... Cs > - struct string; - - template<> - struct string<> - : trivial< true > - { - }; - - template< char... Cs > - struct string - { - using analyze_t = analysis::counted< analysis::rule_type::ANY, sizeof...( Cs ) >; - - template< typename Input > - static bool match( Input& in ) - { - 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< char... Cs > - struct skip_control< string< Cs... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/trivial.hpp b/MoonParser/pegtl/internal/trivial.hpp deleted file mode 100644 index 3416175..0000000 --- a/MoonParser/pegtl/internal/trivial.hpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_TRIVIAL_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_TRIVIAL_HPP - -#include "../config.hpp" - -#include "skip_control.hpp" - -#include "../analysis/counted.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - 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& ) noexcept - { - return Result; - } - }; - - template< bool Result > - struct skip_control< trivial< Result > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/try_catch_type.hpp b/MoonParser/pegtl/internal/try_catch_type.hpp deleted file mode 100644 index 83fddb4..0000000 --- a/MoonParser/pegtl/internal/try_catch_type.hpp +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_TRY_CATCH_TYPE_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_TRY_CATCH_TYPE_HPP - -#include <type_traits> - -#include "../config.hpp" - -#include "duseltronik.hpp" -#include "seq.hpp" -#include "skip_control.hpp" -#include "trivial.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_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 skip_control< try_catch_type< Exception, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/internal/until.hpp b/MoonParser/pegtl/internal/until.hpp deleted file mode 100644 index 6a564a4..0000000 --- a/MoonParser/pegtl/internal/until.hpp +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_UNTIL_HPP -#define TAOCPP_PEGTL_INCLUDE_INTERNAL_UNTIL_HPP - -#include "../config.hpp" - -#include "bytes.hpp" -#include "eof.hpp" -#include "not_at.hpp" -#include "rule_conjunction.hpp" -#include "skip_control.hpp" -#include "star.hpp" - -#include "../apply_mode.hpp" -#include "../rewind_mode.hpp" - -#include "../analysis/generic.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - 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 >(); - - while( !Control< Cond >::template match< A, rewind_mode::REQUIRED, Action, Control >( in, st... ) ) { - if( in.empty() ) { - return false; - } - 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 > - 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( in.empty() || ( !rule_conjunction< Rules... >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ) ) { - return false; - } - } - return m( true ); - } - }; - - template< typename Cond, typename... Rules > - struct skip_control< until< Cond, Rules... > > : std::true_type - { - }; - - } // namespace internal - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/istream_input.hpp b/MoonParser/pegtl/istream_input.hpp deleted file mode 100644 index b0232f9..0000000 --- a/MoonParser/pegtl/istream_input.hpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_ISTREAM_INPUT_HPP -#define TAOCPP_PEGTL_INCLUDE_ISTREAM_INPUT_HPP - -#include <istream> - -#include "buffer_input.hpp" -#include "config.hpp" -#include "eol.hpp" - -#include "internal/istream_reader.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - 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 ) - : buffer_input< internal::istream_reader, Eol >( std::forward< T >( in_source ), in_maximum, in_stream ) - { - } - }; - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/memory_input.hpp b/MoonParser/pegtl/memory_input.hpp deleted file mode 100644 index 2d7fa42..0000000 --- a/MoonParser/pegtl/memory_input.hpp +++ /dev/null @@ -1,285 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_MEMORY_INPUT_HPP -#define TAOCPP_PEGTL_INCLUDE_MEMORY_INPUT_HPP - -#include <cstddef> -#include <cstring> -#include <string> -#include <type_traits> -#include <utility> - -#include "config.hpp" -#include "eol.hpp" -#include "position.hpp" -#include "tracking_mode.hpp" - -#include "internal/action_input.hpp" -#include "internal/bump_impl.hpp" -#include "internal/iterator.hpp" -#include "internal/marker.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - 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_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_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 operator=( const memory_input_base& ) = delete; - - const char* current() const noexcept - { - return m_current.data; - } - - const char* end( const std::size_t = 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 ); - } - - TAOCPP_PEGTL_NAMESPACE::position position( const iterator_t& it ) const - { - return TAOCPP_PEGTL_NAMESPACE::position( it, m_source ); - } - - protected: - 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 operator=( const memory_input_base& ) = delete; - - const char* current() const noexcept - { - return m_current; - } - - const char* end( const std::size_t = 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; - } - - TAOCPP_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 TAOCPP_PEGTL_NAMESPACE::position( c, m_source ); - } - - 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 > - { - 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< Source, T&& >::value ) - : 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< Source, T&& >::value ) - : memory_input( in_string.data(), in_string.size(), std::forward< T >( in_source ) ) - { - } - - 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 ) ) - { - } - - 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 ) ) - { - } - - memory_input( const memory_input& ) = delete; - memory_input operator=( const memory_input& ) = delete; - - const Source& source() const noexcept - { - return this->m_source; - } - - bool empty() const noexcept - { - return this->current() == this->end(); - } - - std::size_t size( const std::size_t = 0 ) const noexcept - { - return std::size_t( this->end() - this->current() ); - } - - char peek_char( const std::size_t offset = 0 ) const noexcept - { - return this->current()[ offset ]; - } - - unsigned char peek_byte( const std::size_t offset = 0 ) const noexcept - { - return static_cast< unsigned char >( peek_char( offset ) ); - } - - iterator_t& iterator() noexcept - { - return this->m_current; - } - - const iterator_t& iterator() const noexcept - { - return this->m_current; - } - - using internal::memory_input_base< P, Eol, Source >::position; - - TAOCPP_PEGTL_NAMESPACE::position position() const - { - return position( iterator() ); - } - - void discard() const noexcept - { - } - - void require( const std::size_t ) const noexcept - { - } - - template< rewind_mode M > - internal::marker< iterator_t, M > mark() noexcept - { - return internal::marker< iterator_t, M >( iterator() ); - } - }; - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/mmap_input.hpp b/MoonParser/pegtl/mmap_input.hpp deleted file mode 100644 index 0a112ef..0000000 --- a/MoonParser/pegtl/mmap_input.hpp +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_MMAP_INPUT_HPP -#define TAOCPP_PEGTL_INCLUDE_MMAP_INPUT_HPP - -#include <string> -#include <utility> - -#include "config.hpp" -#include "eol.hpp" -#include "memory_input.hpp" -#include "tracking_mode.hpp" - -#include "internal/file_mapper.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - struct mmap_holder - { - const std::string filename; - const file_mapper data; - - template< typename T > - mmap_holder( T&& in_filename ) - : filename( std::forward< T >( in_filename ) ), - data( filename.c_str() ) - { - } - }; - - } // 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< 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() ) - { - } - }; - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/normal.hpp b/MoonParser/pegtl/normal.hpp deleted file mode 100644 index d5752d1..0000000 --- a/MoonParser/pegtl/normal.hpp +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_NORMAL_HPP -#define TAOCPP_PEGTL_INCLUDE_NORMAL_HPP - -#include "apply_mode.hpp" -#include "config.hpp" -#include "nothing.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_apply0.hpp" -#include "internal/skip_control.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - template< typename Rule > - struct normal - { - template< typename Input, typename... States > - static void start( const Input&, States&&... ) noexcept - { - } - - template< typename Input, typename... States > - static void success( const Input&, States&&... ) noexcept - { - } - - template< typename Input, typename... States > - static void failure( const Input&, States&&... ) noexcept - { - } - - template< typename Input, typename... States > - static void raise( const Input& in, States&&... ) - { - throw parse_error( "parse error matching " + internal::demangle< Rule >(), in ); - } - - template< template< typename... > class Action, typename Input, typename... States > - static void apply0( const Input&, States&&... st ) - { - Action< Rule >::apply0( st... ); - } - - 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... ); - } - - 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 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... ); - } - }; - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/nothing.hpp b/MoonParser/pegtl/nothing.hpp deleted file mode 100644 index 9b121a2..0000000 --- a/MoonParser/pegtl/nothing.hpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_NOTHING_HPP -#define TAOCPP_PEGTL_INCLUDE_NOTHING_HPP - -#include <type_traits> - -#include "config.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - template< typename Rule > - struct nothing - { - }; - - template< template< typename... > class Action, typename Rule > - using is_nothing = std::is_base_of< nothing< Rule >, Action< Rule > >; - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/parse.hpp b/MoonParser/pegtl/parse.hpp deleted file mode 100644 index c478cfa..0000000 --- a/MoonParser/pegtl/parse.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_PARSE_HPP -#define TAOCPP_PEGTL_INCLUDE_PARSE_HPP - -#include "apply_mode.hpp" -#include "config.hpp" -#include "normal.hpp" -#include "nothing.hpp" -#include "parse_error.hpp" -#include "rewind_mode.hpp" - -namespace tao -{ - namespace TAOCPP_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 ) - { - 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... ); - } - catch( parse_error& e ) { - e.positions.push_back( oi.position() ); - throw; - } - } - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/parse_error.hpp b/MoonParser/pegtl/parse_error.hpp deleted file mode 100644 index e015efb..0000000 --- a/MoonParser/pegtl/parse_error.hpp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_PARSE_ERROR_HPP -#define TAOCPP_PEGTL_INCLUDE_PARSE_ERROR_HPP - -#include <stdexcept> -#include <vector> - -#include "config.hpp" -#include "position.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - struct parse_error - : public std::runtime_error - { - 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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/position.hpp b/MoonParser/pegtl/position.hpp deleted file mode 100644 index c25225c..0000000 --- a/MoonParser/pegtl/position.hpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_POSITION_HPP -#define TAOCPP_PEGTL_INCLUDE_POSITION_HPP - -#include <cstdlib> -#include <ostream> -#include <sstream> -#include <string> -#include <utility> - -#include "config.hpp" - -#include "internal/iterator.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - 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 ) ) - { - } - - 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(); - } - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/read_input.hpp b/MoonParser/pegtl/read_input.hpp deleted file mode 100644 index 9ebfaca..0000000 --- a/MoonParser/pegtl/read_input.hpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_READ_INPUT_HPP -#define TAOCPP_PEGTL_INCLUDE_READ_INPUT_HPP - -#include <string> - -#include "config.hpp" -#include "eol.hpp" -#include "string_input.hpp" -#include "tracking_mode.hpp" - -#include "internal/file_reader.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - struct filename_holder - { - const std::string filename; - - template< typename T > - explicit filename_holder( T&& in_filename ) - : filename( std::forward< T >( in_filename ) ) - { - } - }; - - } // 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< 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() ) - { - } - }; - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/rewind_mode.hpp b/MoonParser/pegtl/rewind_mode.hpp deleted file mode 100644 index f78edb9..0000000 --- a/MoonParser/pegtl/rewind_mode.hpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_REWIND_MODE_HPP -#define TAOCPP_PEGTL_INCLUDE_REWIND_MODE_HPP - -#include "config.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - enum class rewind_mode : char - { - ACTIVE, - REQUIRED, - DONTCARE - }; - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/rules.hpp b/MoonParser/pegtl/rules.hpp deleted file mode 100644 index e1c50b2..0000000 --- a/MoonParser/pegtl/rules.hpp +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_RULES_HPP -#define TAOCPP_PEGTL_INCLUDE_RULES_HPP - -#include "config.hpp" -#include "parse_error.hpp" - -#include "internal/rules.hpp" - -namespace tao -{ - namespace TAOCPP_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< 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 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 - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/string_input.hpp b/MoonParser/pegtl/string_input.hpp deleted file mode 100644 index a1c1f98..0000000 --- a/MoonParser/pegtl/string_input.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_STRING_INPUT_HPP -#define TAOCPP_PEGTL_INCLUDE_STRING_INPUT_HPP - -#include <string> -#include <utility> - -#include "config.hpp" -#include "eol.hpp" -#include "memory_input.hpp" -#include "tracking_mode.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace internal - { - struct string_holder - { - const std::string data; - - template< typename T > - explicit string_holder( T&& in_data ) - : data( std::forward< T >( in_data ) ) - { - } - }; - - } // 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< typename T, typename... Ts > - explicit string_input( T&& in_data, Ts&&... ts ) - : internal::string_holder( std::forward< T >( in_data ) ), - memory_input< P, Eol, Source >( data.data(), data.size(), std::forward< Ts >( ts )... ) - { - } - }; - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/tracking_mode.hpp b/MoonParser/pegtl/tracking_mode.hpp deleted file mode 100644 index 7ed945b..0000000 --- a/MoonParser/pegtl/tracking_mode.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_TRACKING_MODE_HPP -#define TAOCPP_PEGTL_INCLUDE_TRACKING_MODE_HPP - -#include "config.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - enum class tracking_mode : bool - { - IMMEDIATE, - LAZY - }; - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/utf16.hpp b/MoonParser/pegtl/utf16.hpp deleted file mode 100644 index faa7180..0000000 --- a/MoonParser/pegtl/utf16.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2015-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_UTF16_HPP -#define TAOCPP_PEGTL_INCLUDE_UTF16_HPP - -#include "config.hpp" - -#include "internal/peek_utf16.hpp" -#include "internal/result_on_found.hpp" -#include "internal/rules.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace utf16 - { - // clang-format off - struct any : internal::any< internal::peek_utf16 > {}; - template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_utf16, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_utf16, Lo, Hi > {}; - template< char32_t... Cs > struct one : internal::one< internal::result_on_found::SUCCESS, internal::peek_utf16, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::SUCCESS, internal::peek_utf16, Lo, Hi > {}; - template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf16, Cs... > {}; - template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_utf16, Cs >... > {}; - // clang-format on - - } // namespace utf16 - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/utf32.hpp b/MoonParser/pegtl/utf32.hpp deleted file mode 100644 index 848137b..0000000 --- a/MoonParser/pegtl/utf32.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_UTF32_HPP -#define TAOCPP_PEGTL_INCLUDE_UTF32_HPP - -#include "config.hpp" - -#include "internal/peek_utf32.hpp" -#include "internal/result_on_found.hpp" -#include "internal/rules.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace utf32 - { - // clang-format off - struct any : internal::any< internal::peek_utf32 > {}; - template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_utf32, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_utf32, Lo, Hi > {}; - template< char32_t... Cs > struct one : internal::one< internal::result_on_found::SUCCESS, internal::peek_utf32, Cs... > {}; - template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::SUCCESS, internal::peek_utf32, Lo, Hi > {}; - template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf32, Cs... > {}; - template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_utf32, Cs >... > {}; - // clang-format on - - } // namespace utf32 - - } // namespace TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/utf8.hpp b/MoonParser/pegtl/utf8.hpp deleted file mode 100644 index 9ec046e..0000000 --- a/MoonParser/pegtl/utf8.hpp +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_UTF8_HPP -#define TAOCPP_PEGTL_INCLUDE_UTF8_HPP - -#include "config.hpp" - -#include "internal/peek_utf8.hpp" -#include "internal/result_on_found.hpp" -#include "internal/rules.hpp" - -namespace tao -{ - namespace TAOCPP_PEGTL_NAMESPACE - { - namespace utf8 - { - // clang-format off - struct any : internal::any< internal::peek_utf8 > {}; - 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 TAOCPP_PEGTL_NAMESPACE - -} // namespace tao - -#endif diff --git a/MoonParser/pegtl/version.hpp b/MoonParser/pegtl/version.hpp deleted file mode 100644 index 867d5e4..0000000 --- a/MoonParser/pegtl/version.hpp +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey -// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ - -#ifndef TAOCPP_PEGTL_INCLUDE_VERSION_HPP -#define TAOCPP_PEGTL_INCLUDE_VERSION_HPP - -#define TAOCPP_PEGTL_VERSION "2.1.2" - -#define TAOCPP_PEGTL_VERSION_MAJOR 2 -#define TAOCPP_PEGTL_VERSION_MINOR 1 -#define TAOCPP_PEGTL_VERSION_PATCH 2 - -#endif diff --git a/MoonParser/slice.cpp b/MoonParser/slice.cpp deleted file mode 100644 index 7caddbc..0000000 --- a/MoonParser/slice.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/** - * Copyright (C) 2017, IppClub. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include "Slice.h" -#include <cstdlib> - -namespace silly { - -namespace slice { - -const std::string Slice::Empty; - -int Slice::compare(const Slice &rhs) const { - int ret = 0; - - // It's illegal to pass nullptr to memcmp. - if (str_ && rhs.str_) - ret = memcmp(str_, rhs.str_, len_); - - if (ret == 0) { - // Use len_ - rhs.len_ as returned value may cause overflow - // of size_t type length. Therefore +1, -1 are returned here. - if (len_ < rhs.len_) - return -1; - else if (len_ > rhs.len_) - return 1; - } - return ret; -} - -std::string Slice::getFilePath() const { - std::string filename = toString(); - size_t pos = filename.find_last_of("/\\"); - if (pos == std::string::npos) - { - return Slice::Empty; - } - return filename.substr(0, pos) + "/"; -} - -std::string Slice::getFileName() const { - std::string filename = toString(); - size_t pos = filename.find_last_of("/\\"); - if (pos == std::string::npos) { - return Slice::Empty; - } - return filename.substr(pos+1); -} - -std::string Slice::toLower() const { - std::string tmp = toString(); - for (size_t i = 0; i < tmp.length(); i++) { - tmp[i] = (char)tolower(tmp[i]); - } - return tmp; -} - -std::string Slice::toUpper() const { - std::string tmp = toString(); - for (size_t i = 0; i < tmp.length(); i++) { - tmp[i] = (char)toupper(tmp[i]); - } - return tmp; -} - -std::string Slice::getFileExtension() const { - std::string filename = toString(); - size_t pos = filename.rfind('.'); - if (pos == std::string::npos) { - return Slice::Empty; - } - return Slice(filename.substr(pos + 1)).toLower(); -} - -std::list<Slice> Slice::split(const Slice& delims) const { - std::string text = toString(); - std::string delimers = delims.toString(); - std::list<Slice> tokens; - std::size_t start = text.find_first_not_of(delimers), end = 0; - while ((end = text.find_first_of(delimers, start)) != std::string::npos) { - tokens.push_back(Slice(str_ + start, end - start)); - start = text.find_first_not_of(delimers, end); - } - if (start != std::string::npos) { - tokens.push_back(Slice(str_ + start)); - } - return tokens; -} - -float Slice::stof(const Slice& str) { - return static_cast<float>(std::atof(str.toString().c_str())); -} - -int Slice::stoi(const Slice& str) { - return std::atoi(str.toString().c_str()); -} - -} // namespace slice - -} // namespace silly diff --git a/MoonParser/slice.h b/MoonParser/slice.h deleted file mode 100644 index 60e0ae1..0000000 --- a/MoonParser/slice.h +++ /dev/null @@ -1,157 +0,0 @@ -/** - * Copyright (C) 2017, IppClub. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#pragma once - -#include <cassert> -#include <cstring> -#include <string> -#include <list> - -namespace silly { - -namespace slice { -// A Slice object wraps a "const char *" or a "const std::string&" but -// without copying their contents. -class Slice { - private: - struct TrustedInitTag {}; - constexpr Slice(const char* s, size_t n, TrustedInitTag) : str_(s), len_(n) {} - - public: - // implicit conversion from std::string to Slice - Slice(const std::string &s) : Slice(s.data(), s.size()) {} - - Slice(const char *s) : Slice(s, s ? strlen(s) : 0) {} - - Slice(const char *s, size_t n) : str_(s), len_(n) {} - - Slice(std::pair<const char*,size_t> sp) : str_(sp.first), len_(sp.second) {} - - constexpr Slice(std::nullptr_t p = nullptr) : str_(nullptr), len_(0) {} - - operator std::string() const { - return std::string(str_, len_); - } - - const char &operator[](size_t n) const { - return str_[n]; - } - - size_t size() const { - return len_; - } - - const char *rawData() const { - return str_; - } - - std::string toString() const { - return std::string(str_, len_); - } - - bool empty() const { - return len_ == 0; - } - - // similar with std::string::compare - // http://en.cppreference.com/w/cpp/string/basic_string/compare - int compare(const Slice &rhs) const; - - void skip(size_t n) { - assert(n <= len_); - str_ += n; - len_ -= n; - } - - void copyTo(char *dest, bool appendEndingNull = true) const { - memcpy(dest, str_, len_); - if (appendEndingNull) { - dest[len_] = '\0'; - } - } - - Slice &trimSpace() { - assert(len_ > 0); - size_t start = 0, end = len_ - 1; - while (start < end && isspace(str_[start])) { - start++; - } - while (start < end && isspace(str_[end])) { - end--; - } - str_ += start; - len_ = end - start + 1; - return *this; - } - - typedef const char *const_iterator; - - const_iterator begin() const { - return str_; - } - - const_iterator end() const { - return str_ + len_; - } - - std::string getFilePath() const; - std::string getFileName() const; - std::string getFileExtension() const; - std::string toLower() const; - std::string toUpper() const; - std::list<Slice> split(const Slice& delimer) const; - - static const std::string Empty; - static float stof(const Slice& str); - static int stoi(const Slice& str); - - constexpr friend Slice operator"" _slice(const char* s, size_t n); - private: - const char *str_; - size_t len_; -}; - -inline Slice trimSpace(const Slice &s) { - Slice tmp = s; - return tmp.trimSpace(); -} - -inline bool operator==(const Slice &lhs, const Slice &rhs) { - return lhs.compare(rhs) == 0; -} - -inline bool operator!=(const Slice &lhs, const Slice &rhs) { - return !(lhs == rhs); -} - -inline std::string operator+(const std::string& lhs, const Slice &rhs) { - return lhs + rhs.toString(); -} - -constexpr Slice operator"" _slice(const char* s, size_t n) { - return Slice(s, n, Slice::TrustedInitTag{}); -} - -} // namespace slice - -} // namespace silly -- cgit v1.2.3-55-g6feb