aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2017-07-05 14:30:02 +0800
committerLi Jin <dragon-fly@qq.com>2017-07-05 14:30:02 +0800
commit2dc481058998344b7f97721d47987be3ac053768 (patch)
tree9afd61edfc6d3f079262a3086ebef8cb70943a31
parent2d074d650ead2142857ff9f8b192b061d1506eca (diff)
downloadyuescript-2dc481058998344b7f97721d47987be3ac053768.tar.gz
yuescript-2dc481058998344b7f97721d47987be3ac053768.tar.bz2
yuescript-2dc481058998344b7f97721d47987be3ac053768.zip
Learn PEGTL a little.
-rw-r--r--MoonParser.xcodeproj/project.pbxproj568
-rw-r--r--MoonParser.xcodeproj/project.xcworkspace/contents.xcworkspacedata7
-rw-r--r--MoonParser/main.cpp1399
-rw-r--r--MoonParser/pegtl.hpp31
-rw-r--r--MoonParser/pegtl/analysis/analyze_cycles.hpp134
-rw-r--r--MoonParser/pegtl/analysis/counted.hpp29
-rw-r--r--MoonParser/pegtl/analysis/generic.hpp39
-rw-r--r--MoonParser/pegtl/analysis/grammar_info.hpp40
-rw-r--r--MoonParser/pegtl/analysis/insert_guard.hpp66
-rw-r--r--MoonParser/pegtl/analysis/insert_rules.hpp45
-rw-r--r--MoonParser/pegtl/analysis/rule_info.hpp37
-rw-r--r--MoonParser/pegtl/analysis/rule_type.hpp29
-rw-r--r--MoonParser/pegtl/analyze.hpp25
-rw-r--r--MoonParser/pegtl/apply_mode.hpp23
-rw-r--r--MoonParser/pegtl/argv_input.hpp52
-rw-r--r--MoonParser/pegtl/ascii.hpp67
-rw-r--r--MoonParser/pegtl/buffer_input.hpp179
-rw-r--r--MoonParser/pegtl/config.hpp15
-rw-r--r--MoonParser/pegtl/contrib/abnf.hpp43
-rw-r--r--MoonParser/pegtl/contrib/alphabet.hpp75
-rw-r--r--MoonParser/pegtl/contrib/changes.hpp86
-rw-r--r--MoonParser/pegtl/contrib/counter.hpp58
-rw-r--r--MoonParser/pegtl/contrib/http.hpp152
-rw-r--r--MoonParser/pegtl/contrib/json.hpp98
-rw-r--r--MoonParser/pegtl/contrib/raw_string.hpp252
-rw-r--r--MoonParser/pegtl/contrib/rep_one_min_max.hpp72
-rw-r--r--MoonParser/pegtl/contrib/to_string.hpp42
-rw-r--r--MoonParser/pegtl/contrib/tracer.hpp111
-rw-r--r--MoonParser/pegtl/contrib/unescape.hpp203
-rw-r--r--MoonParser/pegtl/contrib/uri.hpp116
-rw-r--r--MoonParser/pegtl/cstream_input.hpp34
-rw-r--r--MoonParser/pegtl/eol.hpp54
-rw-r--r--MoonParser/pegtl/file_input.hpp37
-rw-r--r--MoonParser/pegtl/input_error.hpp41
-rw-r--r--MoonParser/pegtl/internal/action.hpp52
-rw-r--r--MoonParser/pegtl/internal/action_input.hpp108
-rw-r--r--MoonParser/pegtl/internal/alnum.hpp26
-rw-r--r--MoonParser/pegtl/internal/alpha.hpp26
-rw-r--r--MoonParser/pegtl/internal/any.hpp68
-rw-r--r--MoonParser/pegtl/internal/apply.hpp79
-rw-r--r--MoonParser/pegtl/internal/apply0.hpp77
-rw-r--r--MoonParser/pegtl/internal/at.hpp62
-rw-r--r--MoonParser/pegtl/internal/bof.hpp41
-rw-r--r--MoonParser/pegtl/internal/bol.hpp41
-rw-r--r--MoonParser/pegtl/internal/bump_help.hpp64
-rw-r--r--MoonParser/pegtl/internal/bump_impl.hpp53
-rw-r--r--MoonParser/pegtl/internal/bytes.hpp46
-rw-r--r--MoonParser/pegtl/internal/control.hpp52
-rw-r--r--MoonParser/pegtl/internal/cr_crlf_eol.hpp39
-rw-r--r--MoonParser/pegtl/internal/cr_eol.hpp39
-rw-r--r--MoonParser/pegtl/internal/crlf_eol.hpp39
-rw-r--r--MoonParser/pegtl/internal/cstream_reader.hpp48
-rw-r--r--MoonParser/pegtl/internal/cstring_reader.hpp49
-rw-r--r--MoonParser/pegtl/internal/demangle.hpp44
-rw-r--r--MoonParser/pegtl/internal/demangle_cxxabi.hpp41
-rw-r--r--MoonParser/pegtl/internal/demangle_nop.hpp28
-rw-r--r--MoonParser/pegtl/internal/demangle_sanitise.hpp48
-rw-r--r--MoonParser/pegtl/internal/disable.hpp52
-rw-r--r--MoonParser/pegtl/internal/discard.hpp42
-rw-r--r--MoonParser/pegtl/internal/dusel_mode.hpp25
-rw-r--r--MoonParser/pegtl/internal/duseltronik.hpp114
-rw-r--r--MoonParser/pegtl/internal/enable.hpp52
-rw-r--r--MoonParser/pegtl/internal/eof.hpp41
-rw-r--r--MoonParser/pegtl/internal/eol.hpp42
-rw-r--r--MoonParser/pegtl/internal/eolf.hpp43
-rw-r--r--MoonParser/pegtl/internal/file_mapper.hpp91
-rw-r--r--MoonParser/pegtl/internal/file_opener.hpp70
-rw-r--r--MoonParser/pegtl/internal/file_reader.hpp96
-rw-r--r--MoonParser/pegtl/internal/has_apply0.hpp38
-rw-r--r--MoonParser/pegtl/internal/identifier.hpp30
-rw-r--r--MoonParser/pegtl/internal/if_apply.hpp90
-rw-r--r--MoonParser/pegtl/internal/if_must.hpp27
-rw-r--r--MoonParser/pegtl/internal/if_must_else.hpp27
-rw-r--r--MoonParser/pegtl/internal/if_then_else.hpp59
-rw-r--r--MoonParser/pegtl/internal/input_pair.hpp35
-rw-r--r--MoonParser/pegtl/internal/integer_sequence.hpp85
-rw-r--r--MoonParser/pegtl/internal/istream_reader.hpp47
-rw-r--r--MoonParser/pegtl/internal/istring.hpp107
-rw-r--r--MoonParser/pegtl/internal/iterator.hpp53
-rw-r--r--MoonParser/pegtl/internal/lf_crlf_eol.hpp44
-rw-r--r--MoonParser/pegtl/internal/lf_eol.hpp39
-rw-r--r--MoonParser/pegtl/internal/list.hpp27
-rw-r--r--MoonParser/pegtl/internal/list_must.hpp28
-rw-r--r--MoonParser/pegtl/internal/list_tail.hpp28
-rw-r--r--MoonParser/pegtl/internal/list_tail_pad.hpp30
-rw-r--r--MoonParser/pegtl/internal/marker.hpp93
-rw-r--r--MoonParser/pegtl/internal/minus.hpp69
-rw-r--r--MoonParser/pegtl/internal/must.hpp79
-rw-r--r--MoonParser/pegtl/internal/not_at.hpp62
-rw-r--r--MoonParser/pegtl/internal/one.hpp81
-rw-r--r--MoonParser/pegtl/internal/opt.hpp67
-rw-r--r--MoonParser/pegtl/internal/pad.hpp27
-rw-r--r--MoonParser/pegtl/internal/pad_opt.hpp28
-rw-r--r--MoonParser/pegtl/internal/peek_char.hpp35
-rw-r--r--MoonParser/pegtl/internal/peek_utf16.hpp54
-rw-r--r--MoonParser/pegtl/internal/peek_utf32.hpp46
-rw-r--r--MoonParser/pegtl/internal/peek_utf8.hpp88
-rw-r--r--MoonParser/pegtl/internal/pegtl_string.hpp98
-rw-r--r--MoonParser/pegtl/internal/plus.hpp61
-rw-r--r--MoonParser/pegtl/internal/raise.hpp57
-rw-r--r--MoonParser/pegtl/internal/range.hpp60
-rw-r--r--MoonParser/pegtl/internal/ranges.hpp102
-rw-r--r--MoonParser/pegtl/internal/rep.hpp75
-rw-r--r--MoonParser/pegtl/internal/rep_min.hpp28
-rw-r--r--MoonParser/pegtl/internal/rep_min_max.hpp88
-rw-r--r--MoonParser/pegtl/internal/rep_opt.hpp54
-rw-r--r--MoonParser/pegtl/internal/require.hpp52
-rw-r--r--MoonParser/pegtl/internal/result_on_found.hpp27
-rw-r--r--MoonParser/pegtl/internal/rule_conjunction.hpp63
-rw-r--r--MoonParser/pegtl/internal/rules.hpp61
-rw-r--r--MoonParser/pegtl/internal/seq.hpp80
-rw-r--r--MoonParser/pegtl/internal/skip_control.hpp35
-rw-r--r--MoonParser/pegtl/internal/sor.hpp74
-rw-r--r--MoonParser/pegtl/internal/star.hpp56
-rw-r--r--MoonParser/pegtl/internal/star_must.hpp27
-rw-r--r--MoonParser/pegtl/internal/state.hpp83
-rw-r--r--MoonParser/pegtl/internal/string.hpp68
-rw-r--r--MoonParser/pegtl/internal/trivial.hpp42
-rw-r--r--MoonParser/pegtl/internal/try_catch_type.hpp72
-rw-r--r--MoonParser/pegtl/internal/until.hpp91
-rw-r--r--MoonParser/pegtl/istream_input.hpp34
-rw-r--r--MoonParser/pegtl/memory_input.hpp285
-rw-r--r--MoonParser/pegtl/mmap_input.hpp55
-rw-r--r--MoonParser/pegtl/normal.hpp81
-rw-r--r--MoonParser/pegtl/nothing.hpp27
-rw-r--r--MoonParser/pegtl/parse.hpp53
-rw-r--r--MoonParser/pegtl/parse_error.hpp45
-rw-r--r--MoonParser/pegtl/position.hpp54
-rw-r--r--MoonParser/pegtl/read_input.hpp52
-rw-r--r--MoonParser/pegtl/rewind_mode.hpp24
-rw-r--r--MoonParser/pegtl/rules.hpp69
-rw-r--r--MoonParser/pegtl/string_input.hpp51
-rw-r--r--MoonParser/pegtl/tracking_mode.hpp23
-rw-r--r--MoonParser/pegtl/utf16.hpp35
-rw-r--r--MoonParser/pegtl/utf32.hpp35
-rw-r--r--MoonParser/pegtl/utf8.hpp35
-rw-r--r--MoonParser/pegtl/version.hpp13
-rw-r--r--MoonParser/slice.cpp119
-rw-r--r--MoonParser/slice.h157
139 files changed, 10321 insertions, 0 deletions
diff --git a/MoonParser.xcodeproj/project.pbxproj b/MoonParser.xcodeproj/project.pbxproj
new file mode 100644
index 0000000..2585cd1
--- /dev/null
+++ b/MoonParser.xcodeproj/project.pbxproj
@@ -0,0 +1,568 @@
1// !$*UTF8*$!
2{
3 archiveVersion = 1;
4 classes = {
5 };
6 objectVersion = 46;
7 objects = {
8
9/* Begin PBXBuildFile section */
10 3C06322F1F0CBE210089D0AB /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C0631A21F0CBE210089D0AB /* main.cpp */; };
11 3C0632301F0CBE210089D0AB /* slice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3C06322D1F0CBE210089D0AB /* slice.cpp */; };
12/* End PBXBuildFile section */
13
14/* Begin PBXCopyFilesBuildPhase section */
15 3C0F0F6A1EF3781E000EADDB /* CopyFiles */ = {
16 isa = PBXCopyFilesBuildPhase;
17 buildActionMask = 2147483647;
18 dstPath = /usr/share/man/man1/;
19 dstSubfolderSpec = 0;
20 files = (
21 );
22 runOnlyForDeploymentPostprocessing = 1;
23 };
24/* End PBXCopyFilesBuildPhase section */
25
26/* Begin PBXFileReference section */
27 3C0631A21F0CBE210089D0AB /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
28 3C0631A51F0CBE210089D0AB /* analyze_cycles.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = analyze_cycles.hpp; sourceTree = "<group>"; };
29 3C0631A61F0CBE210089D0AB /* counted.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = counted.hpp; sourceTree = "<group>"; };
30 3C0631A71F0CBE210089D0AB /* generic.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = generic.hpp; sourceTree = "<group>"; };
31 3C0631A81F0CBE210089D0AB /* grammar_info.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = grammar_info.hpp; sourceTree = "<group>"; };
32 3C0631A91F0CBE210089D0AB /* insert_guard.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = insert_guard.hpp; sourceTree = "<group>"; };
33 3C0631AA1F0CBE210089D0AB /* insert_rules.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = insert_rules.hpp; sourceTree = "<group>"; };
34 3C0631AB1F0CBE210089D0AB /* rule_info.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rule_info.hpp; sourceTree = "<group>"; };
35 3C0631AC1F0CBE210089D0AB /* rule_type.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rule_type.hpp; sourceTree = "<group>"; };
36 3C0631AD1F0CBE210089D0AB /* analyze.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = analyze.hpp; sourceTree = "<group>"; };
37 3C0631AE1F0CBE210089D0AB /* apply_mode.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = apply_mode.hpp; sourceTree = "<group>"; };
38 3C0631AF1F0CBE210089D0AB /* argv_input.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = argv_input.hpp; sourceTree = "<group>"; };
39 3C0631B01F0CBE210089D0AB /* ascii.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ascii.hpp; sourceTree = "<group>"; };
40 3C0631B11F0CBE210089D0AB /* buffer_input.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = buffer_input.hpp; sourceTree = "<group>"; };
41 3C0631B21F0CBE210089D0AB /* config.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = config.hpp; sourceTree = "<group>"; };
42 3C0631B41F0CBE210089D0AB /* abnf.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = abnf.hpp; sourceTree = "<group>"; };
43 3C0631B51F0CBE210089D0AB /* alphabet.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = alphabet.hpp; sourceTree = "<group>"; };
44 3C0631B61F0CBE210089D0AB /* changes.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = changes.hpp; sourceTree = "<group>"; };
45 3C0631B71F0CBE210089D0AB /* counter.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = counter.hpp; sourceTree = "<group>"; };
46 3C0631B81F0CBE210089D0AB /* http.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = http.hpp; sourceTree = "<group>"; };
47 3C0631B91F0CBE210089D0AB /* json.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = json.hpp; sourceTree = "<group>"; };
48 3C0631BA1F0CBE210089D0AB /* raw_string.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = raw_string.hpp; sourceTree = "<group>"; };
49 3C0631BB1F0CBE210089D0AB /* rep_one_min_max.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rep_one_min_max.hpp; sourceTree = "<group>"; };
50 3C0631BC1F0CBE210089D0AB /* to_string.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = to_string.hpp; sourceTree = "<group>"; };
51 3C0631BD1F0CBE210089D0AB /* tracer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = tracer.hpp; sourceTree = "<group>"; };
52 3C0631BE1F0CBE210089D0AB /* unescape.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = unescape.hpp; sourceTree = "<group>"; };
53 3C0631BF1F0CBE210089D0AB /* uri.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = uri.hpp; sourceTree = "<group>"; };
54 3C0631C01F0CBE210089D0AB /* cstream_input.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cstream_input.hpp; sourceTree = "<group>"; };
55 3C0631C11F0CBE210089D0AB /* eol.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = eol.hpp; sourceTree = "<group>"; };
56 3C0631C21F0CBE210089D0AB /* file_input.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = file_input.hpp; sourceTree = "<group>"; };
57 3C0631C31F0CBE210089D0AB /* input_error.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = input_error.hpp; sourceTree = "<group>"; };
58 3C0631C51F0CBE210089D0AB /* action.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = action.hpp; sourceTree = "<group>"; };
59 3C0631C61F0CBE210089D0AB /* action_input.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = action_input.hpp; sourceTree = "<group>"; };
60 3C0631C71F0CBE210089D0AB /* alnum.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = alnum.hpp; sourceTree = "<group>"; };
61 3C0631C81F0CBE210089D0AB /* alpha.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = alpha.hpp; sourceTree = "<group>"; };
62 3C0631C91F0CBE210089D0AB /* any.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = any.hpp; sourceTree = "<group>"; };
63 3C0631CA1F0CBE210089D0AB /* apply.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = apply.hpp; sourceTree = "<group>"; };
64 3C0631CB1F0CBE210089D0AB /* apply0.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = apply0.hpp; sourceTree = "<group>"; };
65 3C0631CC1F0CBE210089D0AB /* at.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = at.hpp; sourceTree = "<group>"; };
66 3C0631CD1F0CBE210089D0AB /* bof.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = bof.hpp; sourceTree = "<group>"; };
67 3C0631CE1F0CBE210089D0AB /* bol.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = bol.hpp; sourceTree = "<group>"; };
68 3C0631CF1F0CBE210089D0AB /* bump_help.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = bump_help.hpp; sourceTree = "<group>"; };
69 3C0631D01F0CBE210089D0AB /* bump_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = bump_impl.hpp; sourceTree = "<group>"; };
70 3C0631D11F0CBE210089D0AB /* bytes.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = bytes.hpp; sourceTree = "<group>"; };
71 3C0631D21F0CBE210089D0AB /* control.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = control.hpp; sourceTree = "<group>"; };
72 3C0631D31F0CBE210089D0AB /* cr_crlf_eol.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cr_crlf_eol.hpp; sourceTree = "<group>"; };
73 3C0631D41F0CBE210089D0AB /* cr_eol.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cr_eol.hpp; sourceTree = "<group>"; };
74 3C0631D51F0CBE210089D0AB /* crlf_eol.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = crlf_eol.hpp; sourceTree = "<group>"; };
75 3C0631D61F0CBE210089D0AB /* cstream_reader.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cstream_reader.hpp; sourceTree = "<group>"; };
76 3C0631D71F0CBE210089D0AB /* cstring_reader.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cstring_reader.hpp; sourceTree = "<group>"; };
77 3C0631D81F0CBE210089D0AB /* demangle.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = demangle.hpp; sourceTree = "<group>"; };
78 3C0631D91F0CBE210089D0AB /* demangle_cxxabi.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = demangle_cxxabi.hpp; sourceTree = "<group>"; };
79 3C0631DA1F0CBE210089D0AB /* demangle_nop.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = demangle_nop.hpp; sourceTree = "<group>"; };
80 3C0631DB1F0CBE210089D0AB /* demangle_sanitise.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = demangle_sanitise.hpp; sourceTree = "<group>"; };
81 3C0631DC1F0CBE210089D0AB /* disable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = disable.hpp; sourceTree = "<group>"; };
82 3C0631DD1F0CBE210089D0AB /* discard.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = discard.hpp; sourceTree = "<group>"; };
83 3C0631DE1F0CBE210089D0AB /* dusel_mode.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = dusel_mode.hpp; sourceTree = "<group>"; };
84 3C0631DF1F0CBE210089D0AB /* duseltronik.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = duseltronik.hpp; sourceTree = "<group>"; };
85 3C0631E01F0CBE210089D0AB /* enable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = enable.hpp; sourceTree = "<group>"; };
86 3C0631E11F0CBE210089D0AB /* eof.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = eof.hpp; sourceTree = "<group>"; };
87 3C0631E21F0CBE210089D0AB /* eol.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = eol.hpp; sourceTree = "<group>"; };
88 3C0631E31F0CBE210089D0AB /* eolf.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = eolf.hpp; sourceTree = "<group>"; };
89 3C0631E41F0CBE210089D0AB /* file_mapper.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = file_mapper.hpp; sourceTree = "<group>"; };
90 3C0631E51F0CBE210089D0AB /* file_opener.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = file_opener.hpp; sourceTree = "<group>"; };
91 3C0631E61F0CBE210089D0AB /* file_reader.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = file_reader.hpp; sourceTree = "<group>"; };
92 3C0631E71F0CBE210089D0AB /* has_apply0.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = has_apply0.hpp; sourceTree = "<group>"; };
93 3C0631E81F0CBE210089D0AB /* identifier.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = identifier.hpp; sourceTree = "<group>"; };
94 3C0631E91F0CBE210089D0AB /* if_apply.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = if_apply.hpp; sourceTree = "<group>"; };
95 3C0631EA1F0CBE210089D0AB /* if_must.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = if_must.hpp; sourceTree = "<group>"; };
96 3C0631EB1F0CBE210089D0AB /* if_must_else.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = if_must_else.hpp; sourceTree = "<group>"; };
97 3C0631EC1F0CBE210089D0AB /* if_then_else.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = if_then_else.hpp; sourceTree = "<group>"; };
98 3C0631ED1F0CBE210089D0AB /* input_pair.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = input_pair.hpp; sourceTree = "<group>"; };
99 3C0631EE1F0CBE210089D0AB /* integer_sequence.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = integer_sequence.hpp; sourceTree = "<group>"; };
100 3C0631EF1F0CBE210089D0AB /* istream_reader.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = istream_reader.hpp; sourceTree = "<group>"; };
101 3C0631F01F0CBE210089D0AB /* istring.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = istring.hpp; sourceTree = "<group>"; };
102 3C0631F11F0CBE210089D0AB /* iterator.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = iterator.hpp; sourceTree = "<group>"; };
103 3C0631F21F0CBE210089D0AB /* lf_crlf_eol.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lf_crlf_eol.hpp; sourceTree = "<group>"; };
104 3C0631F31F0CBE210089D0AB /* lf_eol.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lf_eol.hpp; sourceTree = "<group>"; };
105 3C0631F41F0CBE210089D0AB /* list.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = list.hpp; sourceTree = "<group>"; };
106 3C0631F51F0CBE210089D0AB /* list_must.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = list_must.hpp; sourceTree = "<group>"; };
107 3C0631F61F0CBE210089D0AB /* list_tail.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = list_tail.hpp; sourceTree = "<group>"; };
108 3C0631F71F0CBE210089D0AB /* list_tail_pad.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = list_tail_pad.hpp; sourceTree = "<group>"; };
109 3C0631F81F0CBE210089D0AB /* marker.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = marker.hpp; sourceTree = "<group>"; };
110 3C0631F91F0CBE210089D0AB /* minus.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = minus.hpp; sourceTree = "<group>"; };
111 3C0631FA1F0CBE210089D0AB /* must.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = must.hpp; sourceTree = "<group>"; };
112 3C0631FB1F0CBE210089D0AB /* not_at.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = not_at.hpp; sourceTree = "<group>"; };
113 3C0631FC1F0CBE210089D0AB /* one.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = one.hpp; sourceTree = "<group>"; };
114 3C0631FD1F0CBE210089D0AB /* opt.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = opt.hpp; sourceTree = "<group>"; };
115 3C0631FE1F0CBE210089D0AB /* pad.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = pad.hpp; sourceTree = "<group>"; };
116 3C0631FF1F0CBE210089D0AB /* pad_opt.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = pad_opt.hpp; sourceTree = "<group>"; };
117 3C0632001F0CBE210089D0AB /* peek_char.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = peek_char.hpp; sourceTree = "<group>"; };
118 3C0632011F0CBE210089D0AB /* peek_utf16.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = peek_utf16.hpp; sourceTree = "<group>"; };
119 3C0632021F0CBE210089D0AB /* peek_utf32.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = peek_utf32.hpp; sourceTree = "<group>"; };
120 3C0632031F0CBE210089D0AB /* peek_utf8.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = peek_utf8.hpp; sourceTree = "<group>"; };
121 3C0632041F0CBE210089D0AB /* pegtl_string.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = pegtl_string.hpp; sourceTree = "<group>"; };
122 3C0632051F0CBE210089D0AB /* plus.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = plus.hpp; sourceTree = "<group>"; };
123 3C0632061F0CBE210089D0AB /* raise.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = raise.hpp; sourceTree = "<group>"; };
124 3C0632071F0CBE210089D0AB /* range.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = range.hpp; sourceTree = "<group>"; };
125 3C0632081F0CBE210089D0AB /* ranges.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ranges.hpp; sourceTree = "<group>"; };
126 3C0632091F0CBE210089D0AB /* rep.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rep.hpp; sourceTree = "<group>"; };
127 3C06320A1F0CBE210089D0AB /* rep_min.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rep_min.hpp; sourceTree = "<group>"; };
128 3C06320B1F0CBE210089D0AB /* rep_min_max.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rep_min_max.hpp; sourceTree = "<group>"; };
129 3C06320C1F0CBE210089D0AB /* rep_opt.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rep_opt.hpp; sourceTree = "<group>"; };
130 3C06320D1F0CBE210089D0AB /* require.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = require.hpp; sourceTree = "<group>"; };
131 3C06320E1F0CBE210089D0AB /* result_on_found.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = result_on_found.hpp; sourceTree = "<group>"; };
132 3C06320F1F0CBE210089D0AB /* rule_conjunction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rule_conjunction.hpp; sourceTree = "<group>"; };
133 3C0632101F0CBE210089D0AB /* rules.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rules.hpp; sourceTree = "<group>"; };
134 3C0632111F0CBE210089D0AB /* seq.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = seq.hpp; sourceTree = "<group>"; };
135 3C0632121F0CBE210089D0AB /* skip_control.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = skip_control.hpp; sourceTree = "<group>"; };
136 3C0632131F0CBE210089D0AB /* sor.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = sor.hpp; sourceTree = "<group>"; };
137 3C0632141F0CBE210089D0AB /* star.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = star.hpp; sourceTree = "<group>"; };
138 3C0632151F0CBE210089D0AB /* star_must.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = star_must.hpp; sourceTree = "<group>"; };
139 3C0632161F0CBE210089D0AB /* state.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = state.hpp; sourceTree = "<group>"; };
140 3C0632171F0CBE210089D0AB /* string.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = string.hpp; sourceTree = "<group>"; };
141 3C0632181F0CBE210089D0AB /* trivial.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = trivial.hpp; sourceTree = "<group>"; };
142 3C0632191F0CBE210089D0AB /* try_catch_type.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = try_catch_type.hpp; sourceTree = "<group>"; };
143 3C06321A1F0CBE210089D0AB /* until.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = until.hpp; sourceTree = "<group>"; };
144 3C06321B1F0CBE210089D0AB /* istream_input.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = istream_input.hpp; sourceTree = "<group>"; };
145 3C06321C1F0CBE210089D0AB /* memory_input.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = memory_input.hpp; sourceTree = "<group>"; };
146 3C06321D1F0CBE210089D0AB /* mmap_input.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = mmap_input.hpp; sourceTree = "<group>"; };
147 3C06321E1F0CBE210089D0AB /* normal.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = normal.hpp; sourceTree = "<group>"; };
148 3C06321F1F0CBE210089D0AB /* nothing.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = nothing.hpp; sourceTree = "<group>"; };
149 3C0632201F0CBE210089D0AB /* parse.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = parse.hpp; sourceTree = "<group>"; };
150 3C0632211F0CBE210089D0AB /* parse_error.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = parse_error.hpp; sourceTree = "<group>"; };
151 3C0632221F0CBE210089D0AB /* position.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = position.hpp; sourceTree = "<group>"; };
152 3C0632231F0CBE210089D0AB /* read_input.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = read_input.hpp; sourceTree = "<group>"; };
153 3C0632241F0CBE210089D0AB /* rewind_mode.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rewind_mode.hpp; sourceTree = "<group>"; };
154 3C0632251F0CBE210089D0AB /* rules.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rules.hpp; sourceTree = "<group>"; };
155 3C0632261F0CBE210089D0AB /* string_input.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = string_input.hpp; sourceTree = "<group>"; };
156 3C0632271F0CBE210089D0AB /* tracking_mode.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = tracking_mode.hpp; sourceTree = "<group>"; };
157 3C0632281F0CBE210089D0AB /* utf16.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = utf16.hpp; sourceTree = "<group>"; };
158 3C0632291F0CBE210089D0AB /* utf32.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = utf32.hpp; sourceTree = "<group>"; };
159 3C06322A1F0CBE210089D0AB /* utf8.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = utf8.hpp; sourceTree = "<group>"; };
160 3C06322B1F0CBE210089D0AB /* version.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = version.hpp; sourceTree = "<group>"; };
161 3C06322C1F0CBE210089D0AB /* pegtl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = pegtl.hpp; sourceTree = "<group>"; };
162 3C06322D1F0CBE210089D0AB /* slice.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = slice.cpp; sourceTree = "<group>"; };
163 3C06322E1F0CBE210089D0AB /* slice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = slice.h; sourceTree = "<group>"; };
164 3C0F0F6C1EF3781E000EADDB /* MoonParser */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = MoonParser; sourceTree = BUILT_PRODUCTS_DIR; };
165/* End PBXFileReference section */
166
167/* Begin PBXFrameworksBuildPhase section */
168 3C0F0F691EF3781E000EADDB /* Frameworks */ = {
169 isa = PBXFrameworksBuildPhase;
170 buildActionMask = 2147483647;
171 files = (
172 );
173 runOnlyForDeploymentPostprocessing = 0;
174 };
175/* End PBXFrameworksBuildPhase section */
176
177/* Begin PBXGroup section */
178 3C0631A11F0CBE210089D0AB /* MoonParser */ = {
179 isa = PBXGroup;
180 children = (
181 3C0631A21F0CBE210089D0AB /* main.cpp */,
182 3C0631A31F0CBE210089D0AB /* pegtl */,
183 3C06322C1F0CBE210089D0AB /* pegtl.hpp */,
184 3C06322D1F0CBE210089D0AB /* slice.cpp */,
185 3C06322E1F0CBE210089D0AB /* slice.h */,
186 );
187 path = MoonParser;
188 sourceTree = "<group>";
189 };
190 3C0631A31F0CBE210089D0AB /* pegtl */ = {
191 isa = PBXGroup;
192 children = (
193 3C0631A41F0CBE210089D0AB /* analysis */,
194 3C0631AD1F0CBE210089D0AB /* analyze.hpp */,
195 3C0631AE1F0CBE210089D0AB /* apply_mode.hpp */,
196 3C0631AF1F0CBE210089D0AB /* argv_input.hpp */,
197 3C0631B01F0CBE210089D0AB /* ascii.hpp */,
198 3C0631B11F0CBE210089D0AB /* buffer_input.hpp */,
199 3C0631B21F0CBE210089D0AB /* config.hpp */,
200 3C0631B31F0CBE210089D0AB /* contrib */,
201 3C0631C01F0CBE210089D0AB /* cstream_input.hpp */,
202 3C0631C11F0CBE210089D0AB /* eol.hpp */,
203 3C0631C21F0CBE210089D0AB /* file_input.hpp */,
204 3C0631C31F0CBE210089D0AB /* input_error.hpp */,
205 3C0631C41F0CBE210089D0AB /* internal */,
206 3C06321B1F0CBE210089D0AB /* istream_input.hpp */,
207 3C06321C1F0CBE210089D0AB /* memory_input.hpp */,
208 3C06321D1F0CBE210089D0AB /* mmap_input.hpp */,
209 3C06321E1F0CBE210089D0AB /* normal.hpp */,
210 3C06321F1F0CBE210089D0AB /* nothing.hpp */,
211 3C0632201F0CBE210089D0AB /* parse.hpp */,
212 3C0632211F0CBE210089D0AB /* parse_error.hpp */,
213 3C0632221F0CBE210089D0AB /* position.hpp */,
214 3C0632231F0CBE210089D0AB /* read_input.hpp */,
215 3C0632241F0CBE210089D0AB /* rewind_mode.hpp */,
216 3C0632251F0CBE210089D0AB /* rules.hpp */,
217 3C0632261F0CBE210089D0AB /* string_input.hpp */,
218 3C0632271F0CBE210089D0AB /* tracking_mode.hpp */,
219 3C0632281F0CBE210089D0AB /* utf16.hpp */,
220 3C0632291F0CBE210089D0AB /* utf32.hpp */,
221 3C06322A1F0CBE210089D0AB /* utf8.hpp */,
222 3C06322B1F0CBE210089D0AB /* version.hpp */,
223 );
224 path = pegtl;
225 sourceTree = "<group>";
226 };
227 3C0631A41F0CBE210089D0AB /* analysis */ = {
228 isa = PBXGroup;
229 children = (
230 3C0631A51F0CBE210089D0AB /* analyze_cycles.hpp */,
231 3C0631A61F0CBE210089D0AB /* counted.hpp */,
232 3C0631A71F0CBE210089D0AB /* generic.hpp */,
233 3C0631A81F0CBE210089D0AB /* grammar_info.hpp */,
234 3C0631A91F0CBE210089D0AB /* insert_guard.hpp */,
235 3C0631AA1F0CBE210089D0AB /* insert_rules.hpp */,
236 3C0631AB1F0CBE210089D0AB /* rule_info.hpp */,
237 3C0631AC1F0CBE210089D0AB /* rule_type.hpp */,
238 );
239 path = analysis;
240 sourceTree = "<group>";
241 };
242 3C0631B31F0CBE210089D0AB /* contrib */ = {
243 isa = PBXGroup;
244 children = (
245 3C0631B41F0CBE210089D0AB /* abnf.hpp */,
246 3C0631B51F0CBE210089D0AB /* alphabet.hpp */,
247 3C0631B61F0CBE210089D0AB /* changes.hpp */,
248 3C0631B71F0CBE210089D0AB /* counter.hpp */,
249 3C0631B81F0CBE210089D0AB /* http.hpp */,
250 3C0631B91F0CBE210089D0AB /* json.hpp */,
251 3C0631BA1F0CBE210089D0AB /* raw_string.hpp */,
252 3C0631BB1F0CBE210089D0AB /* rep_one_min_max.hpp */,
253 3C0631BC1F0CBE210089D0AB /* to_string.hpp */,
254 3C0631BD1F0CBE210089D0AB /* tracer.hpp */,
255 3C0631BE1F0CBE210089D0AB /* unescape.hpp */,
256 3C0631BF1F0CBE210089D0AB /* uri.hpp */,
257 );
258 path = contrib;
259 sourceTree = "<group>";
260 };
261 3C0631C41F0CBE210089D0AB /* internal */ = {
262 isa = PBXGroup;
263 children = (
264 3C0631C51F0CBE210089D0AB /* action.hpp */,
265 3C0631C61F0CBE210089D0AB /* action_input.hpp */,
266 3C0631C71F0CBE210089D0AB /* alnum.hpp */,
267 3C0631C81F0CBE210089D0AB /* alpha.hpp */,
268 3C0631C91F0CBE210089D0AB /* any.hpp */,
269 3C0631CA1F0CBE210089D0AB /* apply.hpp */,
270 3C0631CB1F0CBE210089D0AB /* apply0.hpp */,
271 3C0631CC1F0CBE210089D0AB /* at.hpp */,
272 3C0631CD1F0CBE210089D0AB /* bof.hpp */,
273 3C0631CE1F0CBE210089D0AB /* bol.hpp */,
274 3C0631CF1F0CBE210089D0AB /* bump_help.hpp */,
275 3C0631D01F0CBE210089D0AB /* bump_impl.hpp */,
276 3C0631D11F0CBE210089D0AB /* bytes.hpp */,
277 3C0631D21F0CBE210089D0AB /* control.hpp */,
278 3C0631D31F0CBE210089D0AB /* cr_crlf_eol.hpp */,
279 3C0631D41F0CBE210089D0AB /* cr_eol.hpp */,
280 3C0631D51F0CBE210089D0AB /* crlf_eol.hpp */,
281 3C0631D61F0CBE210089D0AB /* cstream_reader.hpp */,
282 3C0631D71F0CBE210089D0AB /* cstring_reader.hpp */,
283 3C0631D81F0CBE210089D0AB /* demangle.hpp */,
284 3C0631D91F0CBE210089D0AB /* demangle_cxxabi.hpp */,
285 3C0631DA1F0CBE210089D0AB /* demangle_nop.hpp */,
286 3C0631DB1F0CBE210089D0AB /* demangle_sanitise.hpp */,
287 3C0631DC1F0CBE210089D0AB /* disable.hpp */,
288 3C0631DD1F0CBE210089D0AB /* discard.hpp */,
289 3C0631DE1F0CBE210089D0AB /* dusel_mode.hpp */,
290 3C0631DF1F0CBE210089D0AB /* duseltronik.hpp */,
291 3C0631E01F0CBE210089D0AB /* enable.hpp */,
292 3C0631E11F0CBE210089D0AB /* eof.hpp */,
293 3C0631E21F0CBE210089D0AB /* eol.hpp */,
294 3C0631E31F0CBE210089D0AB /* eolf.hpp */,
295 3C0631E41F0CBE210089D0AB /* file_mapper.hpp */,
296 3C0631E51F0CBE210089D0AB /* file_opener.hpp */,
297 3C0631E61F0CBE210089D0AB /* file_reader.hpp */,
298 3C0631E71F0CBE210089D0AB /* has_apply0.hpp */,
299 3C0631E81F0CBE210089D0AB /* identifier.hpp */,
300 3C0631E91F0CBE210089D0AB /* if_apply.hpp */,
301 3C0631EA1F0CBE210089D0AB /* if_must.hpp */,
302 3C0631EB1F0CBE210089D0AB /* if_must_else.hpp */,
303 3C0631EC1F0CBE210089D0AB /* if_then_else.hpp */,
304 3C0631ED1F0CBE210089D0AB /* input_pair.hpp */,
305 3C0631EE1F0CBE210089D0AB /* integer_sequence.hpp */,
306 3C0631EF1F0CBE210089D0AB /* istream_reader.hpp */,
307 3C0631F01F0CBE210089D0AB /* istring.hpp */,
308 3C0631F11F0CBE210089D0AB /* iterator.hpp */,
309 3C0631F21F0CBE210089D0AB /* lf_crlf_eol.hpp */,
310 3C0631F31F0CBE210089D0AB /* lf_eol.hpp */,
311 3C0631F41F0CBE210089D0AB /* list.hpp */,
312 3C0631F51F0CBE210089D0AB /* list_must.hpp */,
313 3C0631F61F0CBE210089D0AB /* list_tail.hpp */,
314 3C0631F71F0CBE210089D0AB /* list_tail_pad.hpp */,
315 3C0631F81F0CBE210089D0AB /* marker.hpp */,
316 3C0631F91F0CBE210089D0AB /* minus.hpp */,
317 3C0631FA1F0CBE210089D0AB /* must.hpp */,
318 3C0631FB1F0CBE210089D0AB /* not_at.hpp */,
319 3C0631FC1F0CBE210089D0AB /* one.hpp */,
320 3C0631FD1F0CBE210089D0AB /* opt.hpp */,
321 3C0631FE1F0CBE210089D0AB /* pad.hpp */,
322 3C0631FF1F0CBE210089D0AB /* pad_opt.hpp */,
323 3C0632001F0CBE210089D0AB /* peek_char.hpp */,
324 3C0632011F0CBE210089D0AB /* peek_utf16.hpp */,
325 3C0632021F0CBE210089D0AB /* peek_utf32.hpp */,
326 3C0632031F0CBE210089D0AB /* peek_utf8.hpp */,
327 3C0632041F0CBE210089D0AB /* pegtl_string.hpp */,
328 3C0632051F0CBE210089D0AB /* plus.hpp */,
329 3C0632061F0CBE210089D0AB /* raise.hpp */,
330 3C0632071F0CBE210089D0AB /* range.hpp */,
331 3C0632081F0CBE210089D0AB /* ranges.hpp */,
332 3C0632091F0CBE210089D0AB /* rep.hpp */,
333 3C06320A1F0CBE210089D0AB /* rep_min.hpp */,
334 3C06320B1F0CBE210089D0AB /* rep_min_max.hpp */,
335 3C06320C1F0CBE210089D0AB /* rep_opt.hpp */,
336 3C06320D1F0CBE210089D0AB /* require.hpp */,
337 3C06320E1F0CBE210089D0AB /* result_on_found.hpp */,
338 3C06320F1F0CBE210089D0AB /* rule_conjunction.hpp */,
339 3C0632101F0CBE210089D0AB /* rules.hpp */,
340 3C0632111F0CBE210089D0AB /* seq.hpp */,
341 3C0632121F0CBE210089D0AB /* skip_control.hpp */,
342 3C0632131F0CBE210089D0AB /* sor.hpp */,
343 3C0632141F0CBE210089D0AB /* star.hpp */,
344 3C0632151F0CBE210089D0AB /* star_must.hpp */,
345 3C0632161F0CBE210089D0AB /* state.hpp */,
346 3C0632171F0CBE210089D0AB /* string.hpp */,
347 3C0632181F0CBE210089D0AB /* trivial.hpp */,
348 3C0632191F0CBE210089D0AB /* try_catch_type.hpp */,
349 3C06321A1F0CBE210089D0AB /* until.hpp */,
350 );
351 path = internal;
352 sourceTree = "<group>";
353 };
354 3C0F0F631EF3781E000EADDB = {
355 isa = PBXGroup;
356 children = (
357 3C0631A11F0CBE210089D0AB /* MoonParser */,
358 3C0F0F6D1EF3781E000EADDB /* Products */,
359 );
360 sourceTree = "<group>";
361 };
362 3C0F0F6D1EF3781E000EADDB /* Products */ = {
363 isa = PBXGroup;
364 children = (
365 3C0F0F6C1EF3781E000EADDB /* MoonParser */,
366 );
367 name = Products;
368 sourceTree = "<group>";
369 };
370/* End PBXGroup section */
371
372/* Begin PBXNativeTarget section */
373 3C0F0F6B1EF3781E000EADDB /* MoonParser */ = {
374 isa = PBXNativeTarget;
375 buildConfigurationList = 3C0F0F731EF3781E000EADDB /* Build configuration list for PBXNativeTarget "MoonParser" */;
376 buildPhases = (
377 3C0F0F681EF3781E000EADDB /* Sources */,
378 3C0F0F691EF3781E000EADDB /* Frameworks */,
379 3C0F0F6A1EF3781E000EADDB /* CopyFiles */,
380 );
381 buildRules = (
382 );
383 dependencies = (
384 );
385 name = MoonParser;
386 productName = PegtlStudy;
387 productReference = 3C0F0F6C1EF3781E000EADDB /* MoonParser */;
388 productType = "com.apple.product-type.tool";
389 };
390/* End PBXNativeTarget section */
391
392/* Begin PBXProject section */
393 3C0F0F641EF3781E000EADDB /* Project object */ = {
394 isa = PBXProject;
395 attributes = {
396 LastUpgradeCheck = 0820;
397 ORGANIZATIONNAME = "Li Jin";
398 TargetAttributes = {
399 3C0F0F6B1EF3781E000EADDB = {
400 CreatedOnToolsVersion = 8.2.1;
401 ProvisioningStyle = Automatic;
402 };
403 };
404 };
405 buildConfigurationList = 3C0F0F671EF3781E000EADDB /* Build configuration list for PBXProject "MoonParser" */;
406 compatibilityVersion = "Xcode 3.2";
407 developmentRegion = English;
408 hasScannedForEncodings = 0;
409 knownRegions = (
410 en,
411 );
412 mainGroup = 3C0F0F631EF3781E000EADDB;
413 productRefGroup = 3C0F0F6D1EF3781E000EADDB /* Products */;
414 projectDirPath = "";
415 projectRoot = "";
416 targets = (
417 3C0F0F6B1EF3781E000EADDB /* MoonParser */,
418 );
419 };
420/* End PBXProject section */
421
422/* Begin PBXSourcesBuildPhase section */
423 3C0F0F681EF3781E000EADDB /* Sources */ = {
424 isa = PBXSourcesBuildPhase;
425 buildActionMask = 2147483647;
426 files = (
427 3C0632301F0CBE210089D0AB /* slice.cpp in Sources */,
428 3C06322F1F0CBE210089D0AB /* main.cpp in Sources */,
429 );
430 runOnlyForDeploymentPostprocessing = 0;
431 };
432/* End PBXSourcesBuildPhase section */
433
434/* Begin XCBuildConfiguration section */
435 3C0F0F711EF3781E000EADDB /* Debug */ = {
436 isa = XCBuildConfiguration;
437 buildSettings = {
438 ALWAYS_SEARCH_USER_PATHS = NO;
439 CLANG_ANALYZER_NONNULL = YES;
440 CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
441 CLANG_CXX_LIBRARY = "libc++";
442 CLANG_ENABLE_MODULES = YES;
443 CLANG_ENABLE_OBJC_ARC = YES;
444 CLANG_WARN_BOOL_CONVERSION = YES;
445 CLANG_WARN_CONSTANT_CONVERSION = YES;
446 CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
447 CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
448 CLANG_WARN_EMPTY_BODY = YES;
449 CLANG_WARN_ENUM_CONVERSION = YES;
450 CLANG_WARN_INFINITE_RECURSION = YES;
451 CLANG_WARN_INT_CONVERSION = YES;
452 CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
453 CLANG_WARN_SUSPICIOUS_MOVE = YES;
454 CLANG_WARN_UNREACHABLE_CODE = YES;
455 CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
456 CODE_SIGN_IDENTITY = "-";
457 COPY_PHASE_STRIP = NO;
458 DEBUG_INFORMATION_FORMAT = dwarf;
459 ENABLE_STRICT_OBJC_MSGSEND = YES;
460 ENABLE_TESTABILITY = YES;
461 GCC_C_LANGUAGE_STANDARD = gnu99;
462 GCC_DYNAMIC_NO_PIC = NO;
463 GCC_NO_COMMON_BLOCKS = YES;
464 GCC_OPTIMIZATION_LEVEL = 0;
465 GCC_PREPROCESSOR_DEFINITIONS = (
466 "DEBUG=1",
467 "$(inherited)",
468 );
469 GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
470 GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
471 GCC_WARN_UNDECLARED_SELECTOR = YES;
472 GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
473 GCC_WARN_UNUSED_FUNCTION = YES;
474 GCC_WARN_UNUSED_VARIABLE = YES;
475 MACOSX_DEPLOYMENT_TARGET = 10.12;
476 MTL_ENABLE_DEBUG_INFO = YES;
477 ONLY_ACTIVE_ARCH = YES;
478 SDKROOT = macosx;
479 };
480 name = Debug;
481 };
482 3C0F0F721EF3781E000EADDB /* Release */ = {
483 isa = XCBuildConfiguration;
484 buildSettings = {
485 ALWAYS_SEARCH_USER_PATHS = NO;
486 CLANG_ANALYZER_NONNULL = YES;
487 CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
488 CLANG_CXX_LIBRARY = "libc++";
489 CLANG_ENABLE_MODULES = YES;
490 CLANG_ENABLE_OBJC_ARC = YES;
491 CLANG_WARN_BOOL_CONVERSION = YES;
492 CLANG_WARN_CONSTANT_CONVERSION = YES;
493 CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
494 CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
495 CLANG_WARN_EMPTY_BODY = YES;
496 CLANG_WARN_ENUM_CONVERSION = YES;
497 CLANG_WARN_INFINITE_RECURSION = YES;
498 CLANG_WARN_INT_CONVERSION = YES;
499 CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
500 CLANG_WARN_SUSPICIOUS_MOVE = YES;
501 CLANG_WARN_UNREACHABLE_CODE = YES;
502 CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
503 CODE_SIGN_IDENTITY = "-";
504 COPY_PHASE_STRIP = NO;
505 DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
506 ENABLE_NS_ASSERTIONS = NO;
507 ENABLE_STRICT_OBJC_MSGSEND = YES;
508 GCC_C_LANGUAGE_STANDARD = gnu99;
509 GCC_NO_COMMON_BLOCKS = YES;
510 GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
511 GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
512 GCC_WARN_UNDECLARED_SELECTOR = YES;
513 GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
514 GCC_WARN_UNUSED_FUNCTION = YES;
515 GCC_WARN_UNUSED_VARIABLE = YES;
516 MACOSX_DEPLOYMENT_TARGET = 10.12;
517 MTL_ENABLE_DEBUG_INFO = NO;
518 SDKROOT = macosx;
519 };
520 name = Release;
521 };
522 3C0F0F741EF3781E000EADDB /* Debug */ = {
523 isa = XCBuildConfiguration;
524 buildSettings = {
525 OTHER_CPLUSPLUSFLAGS = (
526 "$(OTHER_CFLAGS)",
527 "-ftemplate-depth=512",
528 );
529 PRODUCT_NAME = "$(TARGET_NAME)";
530 };
531 name = Debug;
532 };
533 3C0F0F751EF3781E000EADDB /* Release */ = {
534 isa = XCBuildConfiguration;
535 buildSettings = {
536 OTHER_CPLUSPLUSFLAGS = (
537 "$(OTHER_CFLAGS)",
538 "-ftemplate-depth=512",
539 );
540 PRODUCT_NAME = "$(TARGET_NAME)";
541 };
542 name = Release;
543 };
544/* End XCBuildConfiguration section */
545
546/* Begin XCConfigurationList section */
547 3C0F0F671EF3781E000EADDB /* Build configuration list for PBXProject "MoonParser" */ = {
548 isa = XCConfigurationList;
549 buildConfigurations = (
550 3C0F0F711EF3781E000EADDB /* Debug */,
551 3C0F0F721EF3781E000EADDB /* Release */,
552 );
553 defaultConfigurationIsVisible = 0;
554 defaultConfigurationName = Release;
555 };
556 3C0F0F731EF3781E000EADDB /* Build configuration list for PBXNativeTarget "MoonParser" */ = {
557 isa = XCConfigurationList;
558 buildConfigurations = (
559 3C0F0F741EF3781E000EADDB /* Debug */,
560 3C0F0F751EF3781E000EADDB /* Release */,
561 );
562 defaultConfigurationIsVisible = 0;
563 defaultConfigurationName = Release;
564 };
565/* End XCConfigurationList section */
566 };
567 rootObject = 3C0F0F641EF3781E000EADDB /* Project object */;
568}
diff --git a/MoonParser.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/MoonParser.xcodeproj/project.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..1effa34
--- /dev/null
+++ b/MoonParser.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<Workspace
3 version = "1.0">
4 <FileRef
5 location = "self:/Users/Jin/Workspace/PegtlStudy/MoonParser.xcodeproj">
6 </FileRef>
7</Workspace>
diff --git a/MoonParser/main.cpp b/MoonParser/main.cpp
new file mode 100644
index 0000000..332b1b4
--- /dev/null
+++ b/MoonParser/main.cpp
@@ -0,0 +1,1399 @@
1//
2// main.cpp
3// PegtlStudy
4//
5// Created by Li Jin on 2017/6/16.
6// Copyright © 2017年 Li Jin. All rights reserved.
7//
8
9#include <iostream>
10#include <unordered_set>
11#include <vector>
12#include <queue>
13#include <stack>
14#include "pegtl.hpp"
15#include "pegtl/analyze.hpp"
16#include "slice.h"
17using namespace silly;
18
19using namespace tao::pegtl;
20
21namespace helloworld // with operator precedence climbing
22{
23 struct Stack
24 {
25 Stack()
26 {
27 pushStack();
28 }
29 void pushValue(int value)
30 {
31 _values.back().push(value);
32 }
33 void pushOp(char op)
34 {
35 _ops.back().push(op);
36 }
37 void pushStack()
38 {
39 _values.emplace_back();
40 _ops.emplace_back();
41 }
42 int getPriority(char op)
43 {
44 switch (op)
45 {
46 case '+': return 1;
47 case '-': return 1;
48 case '*': return 2;
49 case '/': return 2;
50 }
51 return 0;
52 }
53 /*
54 def compute_expr(tokenizer, min_prec):
55 atom_lhs = tokenizer.get_next_token()
56
57 while True:
58 cur = tokenizer.cur_token
59 if (cur is None or OPINFO_MAP[cur.value].prec < min_prec):
60 break
61
62 op = cur.value
63 prec, assoc = OPINFO_MAP[op]
64 next_min_prec = prec + 1 if assoc == 'LEFT' else prec
65
66 atom_rhs = compute_expr(tokenizer, next_min_prec)
67
68 atom_lhs = compute_op(op, atom_lhs, atom_rhs)
69
70 return atom_lhs
71 */
72 int parseNext(int minPrecedence)
73 {
74 int lhs = _values.back().front();
75 _values.back().pop();
76
77 while (true)
78 {
79 if (_ops.back().empty())
80 {
81 break;
82 }
83 char op = _ops.back().front();
84 if (getPriority(op) < minPrecedence)
85 {
86 break;
87 }
88 _ops.back().pop();
89 int nextMinPrecedence = getPriority(op) + 1;
90 int rhs = parseNext(nextMinPrecedence);
91 switch (op)
92 {
93 case '+':
94 std::cout << lhs << " + " << rhs << " = " << lhs+rhs << '\n';
95 lhs = lhs + rhs;
96 break;
97 case '-':
98 std::cout << lhs << " - " << rhs << " = " << lhs-rhs << '\n';
99 lhs = lhs - rhs;
100 break;
101 case '*':
102 std::cout << lhs << " * " << rhs << " = " << lhs*rhs << '\n';
103 lhs = lhs * rhs;
104 break;
105 case '/':
106 std::cout << lhs << " / " << rhs << " = " << lhs/rhs << '\n';
107 lhs = lhs / rhs;
108 break;
109 }
110 }
111 return lhs;
112 }
113 void popStack()
114 {
115 int value = parseNext(0);
116 _values.pop_back();
117 if (_values.empty())
118 {
119 _values.emplace_back();
120 }
121 _ops.pop_back();
122 if (_ops.empty())
123 {
124 _ops.emplace_back();
125 }
126 pushValue(value);
127 }
128 int getValue() const
129 {
130 return _values.back().back();
131 }
132 private:
133 std::vector<std::queue<char>> _ops;
134 std::vector<std::queue<int>> _values;
135 };
136
137 struct number : seq<opt<one<'+', '-'>>, plus<digit>> { };
138
139 struct expr;
140
141 struct bracket : if_must<one<'('>, expr, one<')'>> { };
142
143 struct atomic : sor<number, bracket> { };
144
145 struct op : one<'+', '-', '*', '/'> { };
146
147 struct expr : list<atomic, op, space> { };
148
149 template<typename Rule>
150 struct action : nothing<Rule> { };
151
152 template<>
153 struct action<number>
154 {
155 template<typename Input>
156 static void apply(const Input& in, Stack& stack)
157 {
158 stack.pushValue(std::stoi(in.string()));
159 }
160 };
161
162 template<>
163 struct action<op>
164 {
165 template<typename Input>
166 static void apply(const Input& in, Stack& stack)
167 {
168 stack.pushOp(*in.begin());
169 }
170 };
171
172 template<>
173 struct action<one<'('>>
174 {
175 static void apply0(Stack& stack)
176 {
177 stack.pushStack();
178 }
179 };
180
181 template<>
182 struct action<expr>
183 {
184 template<typename Input>
185 static void apply(const Input& in, Stack& stack)
186 {
187 stack.popStack();
188 }
189 };
190
191} // namespace hello
192
193namespace moon
194{
195 struct State
196 {
197 State()
198 {
199 indents.push(0);
200 stringOpen = -1;
201 }
202 size_t stringOpen;
203 std::stack<int> indents;
204 std::stack<bool> doStack;
205 std::unordered_set<std::string> keywords =
206 {
207 "and", "while", "else", "using", "continue",
208 "local", "not", "then", "return", "from",
209 "extends", "for", "do", "or", "export",
210 "class", "in", "unless", "when", "elseif",
211 "switch", "break", "if", "with", "import"
212 };
213 };
214
215 struct White : star<one<' ', '\t', '\r', '\n'>> {};
216 struct plain_space : star<one<' ', '\t'>> {};
217 struct Break : seq<opt<one<'\r'>>, one<'\n'>> {};
218 struct Stop : sor<Break, eof> {};
219 struct Comment : seq<string<'-', '-'>, star<not_one<'\r', '\n'>>, Stop> {};
220 struct Indent : star<one<' ', '\t'>> {};
221 struct Space : seq<plain_space, opt<Comment>> {};
222 struct SomeSpace : seq<plus<blank>, opt<Comment>> {};
223 struct SpaceBreak : seq<Space, Break> {};
224 typedef SpaceBreak EmptyLine;
225 struct AlphaNum : ranges<'a', 'z', 'A', 'Z', '0', '9', '_', '_'> {};
226 struct _Name : seq<ranges<'a', 'z', 'A', 'Z', '_', '_'>, star<AlphaNum>> {};
227 struct SpaceName : seq<Space, _Name> {};
228 struct _Num : sor<
229 seq<
230 string<'0' ,'x'>,
231 plus<ranges<'0', '9', 'a', 'f', 'A', 'F'>>,
232 opt<seq<
233 opt<one<'u', 'U'>>, one<'l', 'L'>, one<'l', 'L'>
234 >>
235 >,
236 seq<
237 plus<range<'0', '9'>>,
238 seq<
239 opt<one<'u', 'U'>>, one<'l', 'L'>, one<'l', 'L'>
240 >
241 >,
242 seq<
243 sor<
244 seq<
245 plus<range<'0', '9'>>,
246 opt<seq<
247 one<'.'>, plus<range<'0', '9'>>
248 >>
249 >,
250 seq<
251 one<'.'>,
252 plus<range<'0', '9'>>
253 >
254 >,
255 opt<seq<
256 one<'e', 'E'>, opt<one<'-'>>, plus<range<'0', '9'>>
257 >>
258 >
259 > {};
260 struct Num : seq<Space, _Num> {};
261
262 struct Cut : failure {};
263
264 template<char... Cs> struct sym : seq<Space, string<Cs...>> {};
265 template<char... Cs> struct symx : string<Cs...> {};
266
267 template<typename patt, typename finally>
268 struct ensure : sor<seq<patt, finally>, seq<finally, Cut>> {};
269
270 template<char... Cs> struct key : seq<Space, string<Cs...>, not_at<AlphaNum>> {};
271 template<char... Cs> struct op : seq<Space, string<Cs...>, not_at<AlphaNum>> {};
272
273 struct Name
274 {
275 using analyze_t = analysis::generic<analysis::rule_type::ANY>;
276
277 template<apply_mode A, rewind_mode M,
278 template<typename...> class Action,
279 template<typename...> class Control,
280 typename Input>
281 static bool match(Input& in, const State& st)
282 {
283 const char* current = in.current();
284 if (SpaceName::match<A, M, Action, Control>(in, st))
285 {
286 auto name = slice::Slice(current, in.current() - current + 1);
287 name.trimSpace();
288 auto it = st.keywords.find(name);
289 if (it == st.keywords.end())
290 {
291 return true;
292 }
293 }
294 return false;
295 }
296 };
297
298 struct self : one<'@'> {};
299 struct self_name : seq<one<'@'>, _Name> {};
300 struct self_class : string<'@', '@'> {};
301 struct self_class_name : seq<string<'@', '@'>, _Name> {};
302
303 struct SelfName : seq<Space, sor<self_class_name, self_class, self_name, self>> {};
304 struct KeyName : sor<SelfName, SpaceName> {};
305 struct VarArg : seq<Space, string<'.', '.', '.'>> {};
306
307 struct CheckIndent
308 {
309 using analyze_t = analysis::generic<analysis::rule_type::ANY>;
310
311 template<apply_mode A, rewind_mode M,
312 template<typename...> class Action,
313 template<typename...> class Control,
314 typename Input>
315 static bool match(Input& in, const State& st)
316 {
317 const char* current = in.current();
318 if (Indent::match<A, M, Action, Control>(in, st))
319 {
320 int indent = 0;
321 for (const char* ch = current; ch < in.current(); ch++)
322 {
323 switch (*ch)
324 {
325 case ' ': indent++; break;
326 case '\t': indent += 4; break;
327 }
328 }
329 return st.indents.top() == indent;
330 }
331 return false;
332 }
333 };
334
335 struct Advance
336 {
337 using analyze_t = analysis::generic<analysis::rule_type::ANY>;
338
339 template<apply_mode A, rewind_mode M,
340 template<typename...> class Action,
341 template<typename...> class Control,
342 typename Input>
343 static bool match(Input& in, State& st)
344 {
345 const char* current = in.current();
346 if (Indent::match<A, M, Action, Control>(in))
347 {
348 int indent = 0;
349 for (const char* ch = current; ch < in.current(); ch++)
350 {
351 switch (*ch)
352 {
353 case ' ': indent++; break;
354 case '\t': indent += 4; break;
355 }
356 }
357 int top = st.indents.top();
358 if (top != -1 && indent > top)
359 {
360 st.indents.push(indent);
361 }
362 return true;
363 }
364 return false;
365 }
366 };
367
368 struct PushIndent
369 {
370 using analyze_t = analysis::generic<analysis::rule_type::ANY>;
371
372 template<apply_mode A, rewind_mode M,
373 template<typename...> class Action,
374 template<typename...> class Control,
375 typename Input>
376 static bool match(Input& in, State& st)
377 {
378 const char* current = in.current();
379 if (Indent::match<A, M, Action, Control>(in))
380 {
381 int indent = 0;
382 for (const char* ch = current; ch < in.current(); ch++)
383 {
384 switch (*ch)
385 {
386 case ' ': indent++; break;
387 case '\t': indent += 4; break;
388 }
389 }
390 st.indents.push(indent);
391 return true;
392 }
393 return false;
394 }
395 };
396
397 struct PreventIndent
398 {
399 using analyze_t = analysis::generic<analysis::rule_type::ANY>;
400
401 template<apply_mode A, rewind_mode M,
402 template<typename...> class Action,
403 template<typename...> class Control,
404 typename Input>
405 static bool match(Input& in, State& st)
406 {
407 st.indents.push(-1);
408 return true;
409 }
410 };
411
412 struct PopIndent
413 {
414 using analyze_t = analysis::generic<analysis::rule_type::ANY>;
415
416 template<apply_mode A, rewind_mode M,
417 template<typename...> class Action,
418 template<typename...> class Control,
419 typename Input>
420 static bool match(Input& in, State& st)
421 {
422 if (st.indents.size() > 1) st.indents.pop();
423 return true;
424 }
425 };
426
427 struct Block;
428
429 struct InBlock : seq<Advance, Block, PopIndent> {};
430
431 struct NameList;
432
433 struct Local : seq<key<'l', 'o', 'c', 'a', 'l'>, sor<sor<op<'*'>, op<'^'>>>, NameList> {};
434
435 struct colon_import_name : seq<one<'\\'>, Name> {};
436 struct ImportName : sor<colon_import_name, Name> {};
437 struct ImportNameList : seq<
438 star<SpaceBreak>,
439 ImportName,
440 star<
441 sor<plus<SpaceBreak>, seq<sym<','>, star<SpaceBreak>>>,
442 ImportName
443 >
444 > {};
445
446 struct Exp;
447
448 struct Import : seq<key<'i', 'm', 'p', 'o', 'r', 't'>, ImportNameList, star<SpaceBreak>, key<'f', 'r', 'o', 'm'>, Exp> {};
449
450 struct BreakLoop : sor<key<'b', 'r', 'e', 'a', 'k'>, key<'c', 'o', 'n', 't', 'i', 'n', 'u', 'e'>> {};
451
452 struct ExpListLow;
453
454 struct ExpList;
455 struct Assign;
456
457 struct Return : seq<key<'r', 'e', 't', 'u', 'r', 'n'>, sor<ExpListLow, success>> {};
458 struct WithExp : seq<ExpList, opt<Assign>> {};
459
460 struct DisableDo;
461 struct PopDo;
462 struct Body;
463
464 struct With : seq<key<'w', 'i', 't', 'h'>, DisableDo, ensure<WithExp, PopDo>, opt<key<'d', 'o'>>, Body> {};
465
466 struct SwitchCase : seq<key<'w', 'h', 'e', 'n'>, ExpList, opt<key<'t', 'h', 'e', 'n'>>, Body> {};
467 struct SwitchElse : seq<key<'e', 'l', 's', 'e'>, Body> {};
468 struct SwitchBlock : seq<
469 star<EmptyLine>,
470 Advance,
471 seq<
472 SwitchCase,
473 star<plus<Break>, SwitchCase>,
474 opt<plus<Break>, SwitchElse>
475 >,
476 PopIndent
477 > {};
478 struct Switch : seq<key<'s', 'w', 'i', 't', 'c', 'h'>, DisableDo, ensure<Exp, PopDo>, opt<key<'d', 'o'>>, opt<Space>, Break, SwitchBlock> {};
479
480 struct IfCond : seq<Exp, opt<Assign>> {};
481
482 struct IfElse : seq<
483 opt<Break, star<EmptyLine>, CheckIndent>,
484 string<'e', 'l', 's', 'e'>, Body
485 > {};
486 struct IfElseIf : seq<
487 opt<Break, star<EmptyLine>, CheckIndent>,
488 key<'e', 'l', 's', 'e', 'i', 'f'>, IfCond,
489 opt<key<'t', 'h', 'e', 'n'>>, Body
490 > {};
491
492 struct If : seq<key<'i', 'f'>, IfCond, opt<key<'t', 'h', 'e', 'n'>>, Body, star<IfElseIf>, opt<IfElse>> {};
493 struct Unless : seq<key<'u', 'n', 'l', 'e', 's', 's'>, IfCond, opt<key<'t', 'h', 'e', 'n'>>, Body, star<IfElseIf>, opt<IfElse>> {};
494
495 struct While : seq<key<'w', 'h', 'i', 'l', 'e'>, DisableDo, ensure<Exp, PopDo>, opt<key<'d','o'>>, Body> {};
496 struct For : seq<key<'f', 'o', 'r'>, DisableDo,
497 ensure<
498 seq<
499 Name, sym<'='>,
500 seq<Exp, sym<','>, Exp, opt<sym<','>, Exp>>
501 >,
502 PopDo
503 >,
504 opt<key<'d', 'o'>>, Body> {};
505
506 struct AssignableNameList;
507
508 struct ForEach : seq<
509 key<'f', 'o', 'r'>,
510 AssignableNameList,
511 key<'i', 'n'>,
512 DisableDo,
513 ensure<
514 sor<
515 seq<sym<'*'>, Exp>, ExpList
516 >,
517 PopDo
518 >
519 > {};
520
521 struct Do
522 {
523 using analyze_t = analysis::generic<analysis::rule_type::ANY>;
524
525 template<apply_mode A, rewind_mode M,
526 template<typename...> class Action,
527 template<typename...> class Control,
528 typename Input>
529 static bool match(Input& in, State& st)
530 {
531 if (seq<key<'d', 'o'>, Body>::match<A, M, Action, Control>(in, st))
532 {
533 if (st.doStack.empty() || st.doStack.top())
534 {
535 return true;
536 }
537 }
538 return false;
539 }
540 };
541
542 struct DisableDo
543 {
544 using analyze_t = analysis::generic<analysis::rule_type::ANY>;
545
546 template<apply_mode A, rewind_mode M,
547 template<typename...> class Action,
548 template<typename...> class Control,
549 typename Input>
550 static bool match(Input& in, State& st)
551 {
552 st.doStack.push(false);
553 return true;
554 }
555 };
556
557 struct PopDo
558 {
559 using analyze_t = analysis::generic<analysis::rule_type::ANY>;
560
561 template<apply_mode A, rewind_mode M,
562 template<typename...> class Action,
563 template<typename...> class Control,
564 typename Input>
565 static bool match(Input& in, State& st)
566 {
567 st.doStack.pop();
568 return true;
569 }
570 };
571
572 struct CompInner;
573
574 struct Comprehension : seq<sym<'['>, Exp, CompInner, sym<']'>> {};
575 struct TblComprehension : seq<sym<'{'>, seq<Exp, opt<sym<','>, Exp>>, CompInner, sym<'}'>> {};
576
577 struct CompForEach;
578 struct CompFor;
579 struct CompClause;
580
581 struct CompInner : seq<sor<CompForEach, CompFor>, star<CompClause>> {};
582 struct CompForEach : seq<
583 key<'f', 'o', 'r'>,
584 AssignableNameList,
585 key<'i', 'n'>,
586 sor<
587 seq<sym<'*'>, Exp>, Exp
588 >
589 > {};
590 struct CompFor : seq<key<'f', 'o', 'r'>, Name, sym<'='>, seq<Exp, sym<','>, Exp, opt<sym<','>, Exp>>> {};
591 struct CompClause : sor<CompFor, CompForEach, seq<key<'w', 'h', 'e', 'n'>, Exp>> {};
592
593 struct TableBlock;
594
595 struct Assign : seq<sym<'='>, sor<With, If, Switch, TableBlock, ExpListLow>> {};
596
597 struct Update : seq<sor<
598 sym<'.', '.', '='>,
599 sym<'+', '='>,
600 sym<'-', '='>,
601 sym<'*', '='>,
602 sym<'/', '='>,
603 sym<'%', '='>,
604 sym<'o', 'r', '='>,
605 sym<'a', 'n', 'd', '='>,
606 sym<'&', '='>,
607 sym<'|', '='>,
608 sym<'>', '>', '='>,
609 sym<'<', '<', '='>
610 >, Exp> {};
611
612 struct CharOperators : seq<Space, one<'+', '-', '*' ,'/', '%', '^', '>', '<', '|', '&'>> {};
613 struct WordOperators : sor<
614 op<'o', 'r'>,
615 op<'a', 'n', 'd'>,
616 op<'<', '='>,
617 op<'>', '='>,
618 op<'~', '='>,
619 op<'!', '='>,
620 op<'=', '='>,
621 op<'.', '.'>,
622 op<'<', '<'>,
623 op<'>', '>'>,
624 op<'/', '/'>> {};
625 struct BinaryOperator : seq<sor<CharOperators, WordOperators>, star<SpaceBreak>> {};
626
627 struct Chain;
628
629 struct Assignable : sor<Chain, Name, SelfName> {};
630
631 struct Value;
632
633 struct Exp : seq<Value, star<BinaryOperator, Value>> {};
634
635 struct Callable;
636 struct InvokeArgs;
637
638 struct ChainValue : seq<sor<Chain, Callable>, opt<InvokeArgs>> {};
639
640 struct KeyValueList;
641 struct String;
642 struct SimpleValue;
643
644 struct Value : sor<String, SimpleValue, KeyValueList, ChainValue> {};
645 struct SliceValue : Exp {};
646
647 struct LuaString;
648
649 struct single_string_inner : sor<string<'\\','\''>, string<'\\', '\\'>, not_one<'\''>> {};
650 struct SingleString : seq<symx<'\''>, star<single_string_inner>, sym<'\''>> {};
651 struct interp : seq<symx<'#', '{'>, Exp, sym<'}'>> {};
652 struct double_string_plain : sor<string<'\\','\"'>, string<'\\', '\\'>, not_one<'\"'>> {};
653 struct double_string_inner : plus<seq<not_at<interp>, double_string_plain>> {};
654 struct DoubleString : seq<symx<'\"'>, star<sor<double_string_inner, interp>>, sym<'\"'>> {};
655 struct String : sor<seq<Space, DoubleString>, seq<Space, SingleString>, LuaString> {};
656
657 struct lua_string_open : seq<one<'['>, star<one<'='>>, one<'['>> {};
658 struct lua_string_close : seq<one<']'>, star<one<'='>>, one<']'>> {};
659
660 struct LuaStringOpen
661 {
662 using analyze_t = analysis::generic<analysis::rule_type::ANY>;
663
664 template<apply_mode A, rewind_mode M,
665 template<typename...> class Action,
666 template<typename...> class Control,
667 typename Input>
668 static bool match(Input& in, State& st)
669 {
670 const char* current = in.current();
671 if (lua_string_open::match<A, M, Action, Control>(in, st))
672 {
673 st.stringOpen = in.current() - current + 1;
674 return true;
675 }
676 return false;
677 }
678 };
679
680 struct LuaStringClose
681 {
682 using analyze_t = analysis::generic<analysis::rule_type::ANY>;
683
684 template<apply_mode A, rewind_mode M,
685 template<typename...> class Action,
686 template<typename...> class Control,
687 typename Input>
688 static bool match(Input& in, State& st)
689 {
690 const char* current = in.current();
691 if (lua_string_close::match<A, M, Action, Control>(in, st))
692 {
693 return st.stringOpen == in.current() - current + 1;
694 }
695 return false;
696 }
697 };
698
699 struct LuaStringContent : star<not_at<LuaStringClose>, any> {};
700
701 struct LuaString
702 {
703 using analyze_t = analysis::generic<analysis::rule_type::ANY>;
704
705 template<apply_mode A, rewind_mode M,
706 template<typename...> class Action,
707 template<typename...> class Control,
708 typename Input>
709 static bool match(Input& in, State& st)
710 {
711 bool result = seq<LuaStringOpen, opt<Break>, LuaStringContent, LuaStringClose>::match<A, M, Action, Control>(in, st);
712 st.stringOpen = -1;
713 return result;
714 }
715 };
716
717 struct Parens : seq<sym<'('>, star<SpaceBreak>, Exp, star<SpaceBreak>, sym<')'>> {};
718 struct Callable : sor<Name, SelfName, VarArg, Parens> {};
719
720 struct FnArgsExpList : seq<Exp, star<sor<Break, one<','>>, White, Exp>> {};
721 struct FnArgs : sor<
722 seq<symx<'('>, star<SpaceBreak>, opt<FnArgsExpList>, star<SpaceBreak>, sym<')'>>,
723 seq<sym<'!'>, not_at<one<'='>>>
724 > {};
725
726 struct ChainItems;
727 struct DotChainItem;
728 struct ColonChain;
729
730 struct Chain : sor<
731 seq<sor<Callable, String, not_one<'.', '\\'>>, ChainItems>,
732 seq<Space,
733 sor<
734 seq<DotChainItem, opt<ChainItems>>,
735 ColonChain
736 >
737 >
738 > {};
739
740 struct ChainItem;
741
742 struct ChainItems : sor<
743 seq<plus<ChainItem>, opt<ColonChain>>,
744 ColonChain
745 > {};
746
747 struct Invoke;
748 struct Slice;
749
750 struct ChainItem : sor<
751 Invoke,
752 DotChainItem,
753 Slice,
754 seq<symx<'['>, Exp, sym<']'>>
755 > {};
756
757 struct DotChainItem : seq<symx<'.'>, _Name> {};
758 struct ColonChainItem : seq<symx<'\\'>, _Name> {};
759 struct ColonChain : seq<
760 ColonChainItem,
761 opt<Invoke, opt<ChainItems>>
762 > {};
763
764 struct SliceOne : success {};
765 struct SliceTwo : success {};
766 struct Slice : seq<
767 symx<'['>, sor<SliceValue, SliceOne>, sym<','>, sor<SliceValue, SliceTwo>, opt<sym<','>, SliceValue>, sym<']'>> {};
768
769 struct Invoke : sor<
770 FnArgs,
771 SingleString,
772 DoubleString,
773 seq<at<one<'['>>, LuaString>
774 > {};
775
776 struct KeyValue;
777 struct TableValueList;
778 struct TableLitLine;
779
780 struct TableValue : sor<KeyValue, Exp> {};
781 struct TableLit : seq<
782 sym<'{'>,
783 seq<
784 opt<TableValueList>, opt<sym<','>>,
785 opt<
786 SpaceBreak, TableLitLine,
787 star<opt<sym<','>>, SpaceBreak, TableLitLine>,
788 opt<sym<','>>
789 >
790 >,
791 White, sym<'}'>
792 > {};
793
794 struct TableValueList : seq<TableValue, star<sym<','>, TableValue>> {};
795 struct TableLitLine : sor<
796 seq<PushIndent, sor<seq<TableValueList, PopIndent>, seq<PopIndent, Cut>>>,
797 Space
798 > {};
799
800 struct KeyValueLine;
801
802 struct TableBlockInner : seq<KeyValueLine, star<plus<SpaceBreak>, KeyValueLine>> {};
803 struct TableBlock : seq<plus<SpaceBreak>, Advance, ensure<TableBlockInner, PopIndent>> {};
804
805 struct Statement;
806
807 struct ClassLine : seq<
808 CheckIndent,
809 seq<
810 sor<KeyValueList, Statement, Exp>,
811 opt<sym<','>>
812 >
813 > {};
814
815 struct ClassBlock : seq<plus<SpaceBreak>, Advance, ClassLine, star<plus<SpaceBreak>, ClassLine>, PopIndent> {};
816
817 struct class_no_derive : success {};
818 struct class_no_extend : success {};
819 struct class_no_body : success {};
820 struct ClassDecl : seq<
821 string<'c', 'l', 'a', 's', 's'>,
822 not_at<one<':'>>,
823 sor<Assignable, class_no_derive>,
824 opt<sor<string<'e', 'x', 't', 'e', 'n', 'd', 's'>, PreventIndent, ensure<Exp, PopIndent>, class_no_extend>>,
825 sor<ClassBlock, class_no_body>
826 > {};
827
828 struct Export : seq<
829 string<'e', 'x', 'p', 'o', 'r', 't'>,
830 sor<
831 ClassDecl,
832 op<'*'>,
833 op<'^'>,
834 seq<NameList, opt<sym<'='>, ExpListLow>>
835 >
836 > {};
837
838 struct KeyValue : sor<
839 seq<sym<':'>, not_at<SomeSpace>, Name>,
840 seq<
841 sor<
842 KeyName,
843 seq<sym<'['>, Exp, sym<']'>>,
844 seq<Space, DoubleString>,
845 seq<Space, SingleString>
846 >,
847 symx<':'>,
848 sor<
849 Exp, TableBlock, seq<plus<SpaceBreak>, Exp>
850 >
851 >
852 > {};
853
854 struct KeyValueList : seq<KeyValue, star<sym<','>, KeyValue>> {};
855 struct KeyValueLine : seq<CheckIndent, KeyValueList, opt<sym<','>>> {};
856
857 struct FnArgDef : seq<sor<Name, SelfName>, opt<sym<'='>, Exp>> {};
858
859 struct FnArgDefList : sor<
860 seq<
861 FnArgDef,
862 star<sor<sym<','>, Break>, White, FnArgDef>,
863 star<sor<sym<','>, Break>, White, VarArg>
864 >,
865 VarArg
866 > {};
867
868 struct outer_value_shadow : seq<string<'u', 's', 'i', 'n', 'g'>, sor<NameList, seq<Space, string<'n', 'i', 'l'>>>> {};
869 struct outer_value_no_shadowing : success {};
870 struct without_args_def : success {};
871
872 struct FnArgsDef : sor<
873 seq<sym<'('>, White, opt<FnArgDefList>,
874 sor<
875 outer_value_shadow,
876 outer_value_no_shadowing
877 >,
878 White, sym<')'>
879 >,
880 without_args_def
881 > {};
882
883 struct FunLit : seq<FnArgsDef, sor<sym<'-', '>'>, sym<'=', '>'>>, sor<Body, success>> {};
884
885 struct NameList : seq<Name, star<sym<','>, Name>> {};
886 struct NameOrDestructure : sor<Name, TableLit> {};
887 struct AssignableNameList : seq<NameOrDestructure, star<sym<','>, NameOrDestructure>> {};
888
889 struct ExpList : seq<Exp, star<sym<','>, Exp>> {};
890 struct ExpListLow : seq<Exp, star<sor<sym<','>, sym<';'>, Exp>>> {};
891
892 struct ArgLine : seq<CheckIndent, ExpList> {};
893 struct ArgBlock : seq<ArgLine, star<sym<','>, SpaceBreak, ArgLine>, PopIndent> {};
894
895 struct InvokeArgs : seq<
896 at<not_one<'-'>>,
897 sor<
898 seq<
899 ExpList,
900 opt<sor<
901 seq<
902 sym<','>,
903 sor<
904 TableBlock, seq<SpaceBreak, Advance, ArgBlock, opt<TableBlock>>
905 >
906 >,
907 TableBlock
908 >>
909 >,
910 TableBlock
911 >
912 > {};
913
914 struct SimpleValue : sor<
915 key<'n', 'i', 'l'>,
916 key<'t', 'r', 'u', 'e'>,
917 key<'f', 'a', 'l', 's', 'e'>,
918 If, Unless, Switch, With, ClassDecl, ForEach, For, While, Do,
919 seq<sym<'-'>, not_at<SomeSpace>, Exp>,
920 seq<sym<'#'>, Exp>,
921 seq<sym<'~'>, Exp>,
922 seq<key<'n', 'o', 't'>, Exp>,
923 TblComprehension,
924 TableLit,
925 Comprehension,
926 FunLit,
927 Num
928 > {};
929
930 struct Assignment : seq<
931 ExpList,
932 sor<Update, Assign>
933 > {};
934
935 struct Sentence : sor<
936 Import, While, With, For, ForEach,
937 Switch, Return, Local, Export, BreakLoop,
938 Assignment, ExpList
939 > {};
940
941 struct Statement : seq<
942 Sentence,
943 Space,
944 opt<
945 sor<
946 seq<
947 key<'i', 'f'>, Exp,
948 opt<
949 key<'e', 'l', 's', 'e'>, Exp
950 >,
951 Space
952 >,
953 seq<key<'u', 'n', 'l', 'e', 's', 's'>, Exp>,
954 CompInner
955 >,
956 Space
957 >
958 > {};
959
960 struct Body : sor<
961 seq<opt<Space>, Break, star<EmptyLine>, InBlock>,
962 Statement
963 > {};
964
965 struct Line : sor<
966 seq<CheckIndent, Statement>,
967 seq<Space, at<Stop>>
968 > {};
969
970 struct Block : seq<Line, star<plus<Break>, Line>> {};
971
972 struct BlockWithEnd : seq<Block, eolf> {};
973
974 template<typename Rule>
975 struct action : nothing<Rule> {};
976
977 template<>
978 struct action<Assignment>
979 {
980 template<typename Input>
981 static void apply(const Input& in, State&)
982 {
983 std::cout << "Assignment: " << in.string() << '\n';
984 }
985 };
986
987 template<>
988 struct action<Return>
989 {
990 template<typename Input>
991 static void apply(const Input& in, State&)
992 {
993 std::cout << "Return: " << in.string() << "\n\n";
994 }
995 };
996}
997
998int main()
999{
1000 analyze<moon::BlockWithEnd>();
1001 moon::State state;
1002 string_input<> inName(R"xoxo(
1003debug_grammar = false
1004lpeg = require "lpeg"
1005
1006lpeg.setmaxstack 10000 -- whoa
1007
1008err_msg = "Failed to parse:%s\n [%d] >> %s"
1009
1010import Stack from require "moonscript.data"
1011import trim, pos_to_line, get_line from require "moonscript.util"
1012import unpack from require "moonscript.util"
1013import wrap_env from require "moonscript.parse.env"
1014
1015{
1016 :R, :S, :V, :P, :C, :Ct, :Cmt, :Cg, :Cb, :Cc
1017} = lpeg
1018
1019{
1020 :White, :Break, :Stop, :Comment, :Space, :SomeSpace, :SpaceBreak, :EmptyLine,
1021 :AlphaNum, :Num, :Shebang, :L
1022 Name: _Name
1023} = require "moonscript.parse.literals"
1024
1025SpaceName = Space * _Name
1026Num = Space * (Num / (v) -> {"number", v})
1027
1028{
1029 :Indent, :Cut, :ensure, :extract_line, :mark, :pos, :flatten_or_mark,
1030 :is_assignable, :check_assignable, :format_assign, :format_single_assign,
1031 :sym, :symx, :simple_string, :wrap_func_arg, :join_chain,
1032 :wrap_decorator, :check_lua_string, :self_assign, :got
1033
1034} = require "moonscript.parse.util"
1035
1036
1037build_grammar = wrap_env debug_grammar, (root) ->
1038 _indent = Stack 0
1039 _do_stack = Stack 0
1040
1041 state = {
1042 -- last pos we saw, used to report error location
1043 last_pos: 0
1044 }
1045
1046 check_indent = (str, pos, indent) ->
1047 state.last_pos = pos
1048 _indent\top! == indent
1049
1050 advance_indent = (str, pos, indent) ->
1051 top = _indent\top!
1052 if top != -1 and indent > top
1053 _indent\push indent
1054 true
1055
1056 push_indent = (str, pos, indent) ->
1057 _indent\push indent
1058 true
1059
1060 pop_indent = ->
1061 assert _indent\pop!, "unexpected outdent"
1062 true
1063
1064 check_do = (str, pos, do_node) ->
1065 top = _do_stack\top!
1066 if top == nil or top
1067 return true, do_node
1068 false
1069
1070 disable_do = ->
1071 _do_stack\push false
1072 true
1073
1074 pop_do = ->
1075 assert _do_stack\pop! != nil, "unexpected do pop"
1076 true
1077
1078 DisableDo = Cmt "", disable_do
1079 PopDo = Cmt "", pop_do
1080
1081 keywords = {}
1082 key = (chars) ->
1083 keywords[chars] = true
1084 Space * chars * -AlphaNum
1085
1086 op = (chars) ->
1087 patt = Space * C chars
1088 -- it's a word, treat like keyword
1089 if chars\match "^%w*$"
1090 keywords[chars] = true
1091 patt *= -AlphaNum
1092
1093 patt
1094
1095 Name = Cmt(SpaceName, (str, pos, name) ->
1096 return false if keywords[name]
1097 true
1098 ) / trim
1099
1100 SelfName = Space * "@" * (
1101 "@" * (_Name / mark"self_class" + Cc"self.__class") +
1102 _Name / mark"self" +
1103 Cc"self" -- @ by itself
1104 )
1105
1106 KeyName = SelfName + Space * _Name / mark"key_literal"
1107 VarArg = Space * P"..." / trim
1108
1109 g = P {
1110 root or File
1111 File: Shebang^-1 * (Block + Ct"")
1112 Block: Ct(Line * (Break^1 * Line)^0)
1113 CheckIndent: Cmt(Indent, check_indent), -- validates line is in correct indent
1114 Line: (CheckIndent * Statement + Space * L(Stop))
1115
1116 Statement: pos(
1117 Import + While + With + For + ForEach + Switch + Return +
1118 Local + Export + BreakLoop +
1119 Ct(ExpList) * (Update + Assign)^-1 / format_assign
1120 ) * Space * ((
1121 -- statement decorators
1122 key"if" * Exp * (key"else" * Exp)^-1 * Space / mark"if" +
1123 key"unless" * Exp / mark"unless" +
1124 CompInner / mark"comprehension"
1125 ) * Space)^-1 / wrap_decorator
1126
1127 Body: Space^-1 * Break * EmptyLine^0 * InBlock + Ct(Statement) -- either a statement, or an indented block
1128
1129 Advance: L Cmt(Indent, advance_indent) -- Advances the indent, gives back whitespace for CheckIndent
1130 PushIndent: Cmt(Indent, push_indent)
1131 PreventIndent: Cmt(Cc(-1), push_indent)
1132 PopIndent: Cmt("", pop_indent)
1133 InBlock: Advance * Block * PopIndent
1134
1135 Local: key"local" * ((op"*" + op"^") / mark"declare_glob" + Ct(NameList) / mark"declare_with_shadows")
1136
1137 Import: key"import" * Ct(ImportNameList) * SpaceBreak^0 * key"from" * Exp / mark"import"
1138 ImportName: (sym"\\" * Ct(Cc"colon" * Name) + Name)
1139 ImportNameList: SpaceBreak^0 * ImportName * ((SpaceBreak^1 + sym"," * SpaceBreak^0) * ImportName)^0
1140
1141 BreakLoop: Ct(key"break"/trim) + Ct(key"continue"/trim)
1142
1143 Return: key"return" * (ExpListLow/mark"explist" + C"") / mark"return"
1144
1145 WithExp: Ct(ExpList) * Assign^-1 / format_assign
1146 With: key"with" * DisableDo * ensure(WithExp, PopDo) * key"do"^-1 * Body / mark"with"
1147
1148 Switch: key"switch" * DisableDo * ensure(Exp, PopDo) * key"do"^-1 * Space^-1 * Break * SwitchBlock / mark"switch"
1149
1150 SwitchBlock: EmptyLine^0 * Advance * Ct(SwitchCase * (Break^1 * SwitchCase)^0 * (Break^1 * SwitchElse)^-1) * PopIndent
1151 SwitchCase: key"when" * Ct(ExpList) * key"then"^-1 * Body / mark"case"
1152 SwitchElse: key"else" * Body / mark"else"
1153
1154 IfCond: Exp * Assign^-1 / format_single_assign
1155
1156 IfElse: (Break * EmptyLine^0 * CheckIndent)^-1 * key"else" * Body / mark"else"
1157 IfElseIf: (Break * EmptyLine^0 * CheckIndent)^-1 * key"elseif" * pos(IfCond) * key"then"^-1 * Body / mark"elseif"
1158
1159 If: key"if" * IfCond * key"then"^-1 * Body * IfElseIf^0 * IfElse^-1 / mark"if"
1160 Unless: key"unless" * IfCond * key"then"^-1 * Body * IfElseIf^0 * IfElse^-1 / mark"unless"
1161
1162 While: key"while" * DisableDo * ensure(Exp, PopDo) * key"do"^-1 * Body / mark"while"
1163
1164 For: key"for" * DisableDo * ensure(Name * sym"=" * Ct(Exp * sym"," * Exp * (sym"," * Exp)^-1), PopDo) *
1165 key"do"^-1 * Body / mark"for"
1166
1167 ForEach: key"for" * Ct(AssignableNameList) * key"in" * DisableDo * ensure(Ct(sym"*" * Exp / mark"unpack" + ExpList), PopDo) * key"do"^-1 * Body / mark"foreach"
1168
1169 Do: key"do" * Body / mark"do"
1170
1171 Comprehension: sym"[" * Exp * CompInner * sym"]" / mark"comprehension"
1172
1173 TblComprehension: sym"{" * Ct(Exp * (sym"," * Exp)^-1) * CompInner * sym"}" / mark"tblcomprehension"
1174
1175 CompInner: Ct((CompForEach + CompFor) * CompClause^0)
1176 CompForEach: key"for" * Ct(AssignableNameList) * key"in" * (sym"*" * Exp / mark"unpack" + Exp) / mark"foreach"
1177 CompFor: key "for" * Name * sym"=" * Ct(Exp * sym"," * Exp * (sym"," * Exp)^-1) / mark"for"
1178 CompClause: CompFor + CompForEach + key"when" * Exp / mark"when"
1179
1180 Assign: sym"=" * (Ct(With + If + Switch) + Ct(TableBlock + ExpListLow)) / mark"assign"
1181 Update: ((sym"..=" + sym"+=" + sym"-=" + sym"*=" + sym"/=" + sym"%=" + sym"or=" + sym"and=" + sym"&=" + sym"|=" + sym">>=" + sym"<<=") / trim) * Exp / mark"update"
1182
1183 CharOperators: Space * C(S"+-*/%^><|&")
1184 WordOperators: op"or" + op"and" + op"<=" + op">=" + op"~=" + op"!=" + op"==" + op".." + op"<<" + op">>" + op"//"
1185 BinaryOperator: (WordOperators + CharOperators) * SpaceBreak^0
1186
1187 Assignable: Cmt(Chain, check_assignable) + Name + SelfName
1188 Exp: Ct(Value * (BinaryOperator * Value)^0) / flatten_or_mark"exp"
1189
1190 SimpleValue:
1191 If + Unless +
1192 Switch +
1193 With +
1194 ClassDecl +
1195 ForEach + For + While +
1196 Cmt(Do, check_do) +
1197 sym"-" * -SomeSpace * Exp / mark"minus" +
1198 sym"#" * Exp / mark"length" +
1199 sym"~" * Exp / mark"bitnot" +
1200 key"not" * Exp / mark"not" +
1201 TblComprehension +
1202 TableLit +
1203 Comprehension +
1204 FunLit +
1205 Num
1206
1207 -- a function call or an object access
1208 ChainValue: (Chain + Callable) * Ct(InvokeArgs^-1) / join_chain
1209
1210 Value: pos(
1211 SimpleValue +
1212 Ct(KeyValueList) / mark"table" +
1213 ChainValue +
1214 String)
1215
1216 SliceValue: Exp
1217
1218 String: Space * DoubleString + Space * SingleString + LuaString
1219 SingleString: simple_string("'")
1220 DoubleString: simple_string('"', true)
1221
1222 LuaString: Cg(LuaStringOpen, "string_open") * Cb"string_open" * Break^-1 *
1223 C((1 - Cmt(C(LuaStringClose) * Cb"string_open", check_lua_string))^0) *
1224 LuaStringClose / mark"string"
1225
1226 LuaStringOpen: sym"[" * P"="^0 * "[" / trim
1227 LuaStringClose: "]" * P"="^0 * "]"
1228
1229 Callable: pos(Name / mark"ref") + SelfName + VarArg + Parens / mark"parens"
1230 Parens: sym"(" * SpaceBreak^0 * Exp * SpaceBreak^0 * sym")"
1231
1232 FnArgs: symx"(" * SpaceBreak^0 * Ct(FnArgsExpList^-1) * SpaceBreak^0 * sym")" + sym"!" * -P"=" * Ct""
1233 FnArgsExpList: Exp * ((Break + sym",") * White * Exp)^0
1234
1235 Chain: (Callable + String + -S".\\") * ChainItems / mark"chain" +
1236 Space * (DotChainItem * ChainItems^-1 + ColonChain) / mark"chain"
1237
1238 ChainItems: ChainItem^1 * ColonChain^-1 + ColonChain
1239
1240 ChainItem:
1241 Invoke +
1242 DotChainItem +
1243 Slice +
1244 symx"[" * Exp/mark"index" * sym"]"
1245
1246 DotChainItem: symx"." * _Name/mark"dot"
1247 ColonChainItem: symx"\\" * _Name / mark"colon"
1248 ColonChain: ColonChainItem * (Invoke * ChainItems^-1)^-1
1249
1250 Slice: symx"[" * (SliceValue + Cc(1)) * sym"," * (SliceValue + Cc"") *
1251 (sym"," * SliceValue)^-1 *sym"]" / mark"slice"
1252
1253 Invoke: FnArgs / mark"call" +
1254 SingleString / wrap_func_arg +
1255 DoubleString / wrap_func_arg +
1256 L(P"[") * LuaString / wrap_func_arg
1257
1258 TableValue: KeyValue + Ct(Exp)
1259
1260 TableLit: sym"{" * Ct(
1261 TableValueList^-1 * sym","^-1 *
1262 (SpaceBreak * TableLitLine * (sym","^-1 * SpaceBreak * TableLitLine)^0 * sym","^-1)^-1
1263 ) * White * sym"}" / mark"table"
1264
1265 TableValueList: TableValue * (sym"," * TableValue)^0
1266 TableLitLine: PushIndent * ((TableValueList * PopIndent) + (PopIndent * Cut)) + Space
1267
1268 -- the unbounded table
1269 TableBlockInner: Ct(KeyValueLine * (SpaceBreak^1 * KeyValueLine)^0)
1270 TableBlock: SpaceBreak^1 * Advance * ensure(TableBlockInner, PopIndent) / mark"table"
1271
1272 ClassDecl: key"class" * -P":" * (Assignable + Cc(nil)) * (key"extends" * PreventIndent * ensure(Exp, PopIndent) + C"")^-1 * (ClassBlock + Ct("")) / mark"class"
1273
1274 ClassBlock: SpaceBreak^1 * Advance *
1275 Ct(ClassLine * (SpaceBreak^1 * ClassLine)^0) * PopIndent
1276 ClassLine: CheckIndent * ((
1277 KeyValueList / mark"props" +
1278 Statement / mark"stm" +
1279 Exp / mark"stm"
1280 ) * sym","^-1)
1281
1282 Export: key"export" * (
1283 Cc"class" * ClassDecl +
1284 op"*" + op"^" +
1285 Ct(NameList) * (sym"=" * Ct(ExpListLow))^-1) / mark"export"
1286
1287 KeyValue: (sym":" * -SomeSpace * Name * lpeg.Cp!) / self_assign +
1288 Ct(
1289 (KeyName + sym"[" * Exp * sym"]" +Space * DoubleString + Space * SingleString) *
1290 symx":" *
1291 (Exp + TableBlock + SpaceBreak^1 * Exp)
1292 )
1293
1294 KeyValueList: KeyValue * (sym"," * KeyValue)^0
1295 KeyValueLine: CheckIndent * KeyValueList * sym","^-1
1296
1297 FnArgsDef: sym"(" * White * Ct(FnArgDefList^-1) *
1298 (key"using" * Ct(NameList + Space * "nil") + Ct"") *
1299 White * sym")" + Ct"" * Ct""
1300
1301 FnArgDefList: FnArgDef * ((sym"," + Break) * White * FnArgDef)^0 * ((sym"," + Break) * White * Ct(VarArg))^0 + Ct(VarArg)
1302 FnArgDef: Ct((Name + SelfName) * (sym"=" * Exp)^-1)
1303
1304 FunLit: FnArgsDef *
1305 (sym"->" * Cc"slim" + sym"=>" * Cc"fat") *
1306 (Body + Ct"") / mark"fndef"
1307
1308 NameList: Name * (sym"," * Name)^0
1309 NameOrDestructure: Name + TableLit
1310 AssignableNameList: NameOrDestructure * (sym"," * NameOrDestructure)^0
1311
1312 ExpList: Exp * (sym"," * Exp)^0
1313 ExpListLow: Exp * ((sym"," + sym";") * Exp)^0
1314
1315 -- open args
1316 InvokeArgs: -P"-" * (ExpList * (sym"," * (TableBlock + SpaceBreak * Advance * ArgBlock * TableBlock^-1) + TableBlock)^-1 + TableBlock)
1317 ArgBlock: ArgLine * (sym"," * SpaceBreak * ArgLine)^0 * PopIndent
1318 ArgLine: CheckIndent * ExpList
1319 }
1320
1321 g, state
1322
1323file_parser = ->
1324 g, state = build_grammar!
1325 file_grammar = White * g * White * -1
1326
1327 {
1328 match: (str) =>
1329 local tree
1330 _, err = xpcall (->
1331 tree = file_grammar\match str
1332 ), (err) ->
1333 debug.traceback err, 2
1334
1335 -- regular error, let it bubble up
1336 if type(err) == "string"
1337 return nil, err
1338
1339 unless tree
1340 local msg
1341 err_pos = state.last_pos
1342
1343 if err
1344 node, msg = unpack err
1345 msg = " " .. msg if msg
1346 err_pos = node[-1]
1347
1348 line_no = pos_to_line str, err_pos
1349 line_str = get_line(str, line_no) or ""
1350 return nil, err_msg\format msg or "", line_no, trim line_str
1351
1352 tree
1353 }
1354
1355{
1356 :extract_line
1357 :build_grammar
1358
1359 -- parse a string as a file
1360 -- returns tree, or nil and error message
1361 string: (str) -> file_parser!\match str
1362}
1363)xoxo", "abc");
1364 try
1365 {
1366 if (parse<must<moon::BlockWithEnd>, moon::action>(inName, state))
1367 {
1368 std::cout << "matched.\n";
1369 }
1370 else
1371 {
1372 std::cout << "not matched.\n";
1373 }
1374 }
1375 catch (parse_error e)
1376 {
1377 std::cout << e.what() << '\n';
1378 }
1379/*
1380 analyze<hello::expr>();
1381 const char* text = "1 + 2 + 3 * 4 / 2";
1382 string_input<> in(text, "abc");
1383 try
1384 {
1385 hello::Stack stack;
1386 if (parse<hello::expr, hello::action>(in, stack))
1387 {
1388 std::cout << text << " = " << stack.getValue() << '\n';
1389 }
1390 return 0;
1391 }
1392 catch (parse_error e)
1393 {
1394 std::cout << e.what() << '\n';
1395 return 1;
1396 }
1397*/
1398 return 0;
1399}
diff --git a/MoonParser/pegtl.hpp b/MoonParser/pegtl.hpp
new file mode 100644
index 0000000..e96cd79
--- /dev/null
+++ b/MoonParser/pegtl.hpp
@@ -0,0 +1,31 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_PEGTL_HPP
5#define TAOCPP_PEGTL_INCLUDE_PEGTL_HPP
6
7#include "pegtl/config.hpp"
8#include "pegtl/version.hpp"
9
10#include "pegtl/ascii.hpp"
11#include "pegtl/parse.hpp"
12#include "pegtl/rules.hpp"
13#include "pegtl/utf16.hpp"
14#include "pegtl/utf32.hpp"
15#include "pegtl/utf8.hpp"
16
17#include "pegtl/argv_input.hpp"
18#include "pegtl/buffer_input.hpp"
19#include "pegtl/cstream_input.hpp"
20#include "pegtl/file_input.hpp"
21#include "pegtl/istream_input.hpp"
22#include "pegtl/memory_input.hpp"
23#include "pegtl/read_input.hpp"
24#include "pegtl/string_input.hpp"
25
26// The following are not included by
27// default because they include <iostream>.
28
29// #include "pegtl/analyze.hpp"
30
31#endif
diff --git a/MoonParser/pegtl/analysis/analyze_cycles.hpp b/MoonParser/pegtl/analysis/analyze_cycles.hpp
new file mode 100644
index 0000000..f063ee1
--- /dev/null
+++ b/MoonParser/pegtl/analysis/analyze_cycles.hpp
@@ -0,0 +1,134 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_ANALYSIS_ANALYZE_CYCLES_HPP
5#define TAOCPP_PEGTL_INCLUDE_ANALYSIS_ANALYZE_CYCLES_HPP
6
7#include <cassert>
8
9#include <map>
10#include <set>
11
12#include <iostream>
13#include <utility>
14
15#include "../config.hpp"
16
17#include "grammar_info.hpp"
18#include "insert_guard.hpp"
19
20namespace tao
21{
22 namespace TAOCPP_PEGTL_NAMESPACE
23 {
24 namespace analysis
25 {
26 class analyze_cycles_impl
27 {
28 protected:
29 explicit analyze_cycles_impl( const bool verbose ) noexcept
30 : m_verbose( verbose ),
31 m_problems( 0 )
32 {
33 }
34
35 const bool m_verbose;
36 unsigned m_problems;
37 grammar_info m_info;
38 std::set< std::string > m_stack;
39 std::map< std::string, bool > m_cache;
40 std::map< std::string, bool > m_results;
41
42 const std::map< std::string, rule_info >::const_iterator find( const std::string& name ) const noexcept
43 {
44 const auto iter = m_info.map.find( name );
45 assert( iter != m_info.map.end() );
46 return iter;
47 }
48
49 bool work( const std::map< std::string, rule_info >::const_iterator& start, const bool accum )
50 {
51 const auto j = m_cache.find( start->first );
52
53 if( j != m_cache.end() ) {
54 return j->second;
55 }
56 if( const auto g = make_insert_guard( m_stack, start->first ) ) {
57 switch( start->second.type ) {
58 case rule_type::ANY: {
59 bool a = false;
60 for( const auto& r : start->second.rules ) {
61 a = a || work( find( r ), accum || a );
62 }
63 return m_cache[ start->first ] = true;
64 }
65 case rule_type::OPT: {
66 bool a = false;
67 for( const auto& r : start->second.rules ) {
68 a = a || work( find( r ), accum || a );
69 }
70 return m_cache[ start->first ] = false;
71 }
72 case rule_type::SEQ: {
73 bool a = false;
74 for( const auto& r : start->second.rules ) {
75 a = a || work( find( r ), accum || a );
76 }
77 return m_cache[ start->first ] = a;
78 }
79 case rule_type::SOR: {
80 bool a = true;
81 for( const auto& r : start->second.rules ) {
82 a = a && work( find( r ), accum );
83 }
84 return m_cache[ start->first ] = a;
85 }
86 }
87 throw std::runtime_error( "code should be unreachable" ); // LCOV_EXCL_LINE
88 }
89 if( !accum ) {
90 ++m_problems;
91 if( m_verbose ) {
92 std::cout << "problem: cycle without progress detected at rule class " << start->first << std::endl;
93 }
94 }
95 return m_cache[ start->first ] = accum;
96 }
97 };
98
99 template< typename Grammar >
100 class analyze_cycles
101 : private analyze_cycles_impl
102 {
103 public:
104 explicit analyze_cycles( const bool verbose )
105 : analyze_cycles_impl( verbose )
106 {
107 Grammar::analyze_t::template insert< Grammar >( m_info );
108 }
109
110 std::size_t problems()
111 {
112 for( auto i = m_info.map.begin(); i != m_info.map.end(); ++i ) {
113 m_results[ i->first ] = work( i, false );
114 m_cache.clear();
115 }
116 return m_problems;
117 }
118
119 template< typename Rule >
120 bool consumes() const noexcept
121 {
122 const auto i = m_results.find( internal::demangle< Rule >() );
123 assert( i != m_results.end() );
124 return i->second;
125 }
126 };
127
128 } // namespace analysis
129
130 } // namespace TAOCPP_PEGTL_NAMESPACE
131
132} // namespace tao
133
134#endif
diff --git a/MoonParser/pegtl/analysis/counted.hpp b/MoonParser/pegtl/analysis/counted.hpp
new file mode 100644
index 0000000..84a12ae
--- /dev/null
+++ b/MoonParser/pegtl/analysis/counted.hpp
@@ -0,0 +1,29 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_ANALYSIS_COUNTED_HPP
5#define TAOCPP_PEGTL_INCLUDE_ANALYSIS_COUNTED_HPP
6
7#include "../config.hpp"
8
9#include "generic.hpp"
10
11namespace tao
12{
13 namespace TAOCPP_PEGTL_NAMESPACE
14 {
15 namespace analysis
16 {
17 template< rule_type Type, unsigned Count, typename... Rules >
18 struct counted
19 : generic< ( Count != 0 ) ? Type : rule_type::OPT, Rules... >
20 {
21 };
22
23 } // namespace analysis
24
25 } // namespace TAOCPP_PEGTL_NAMESPACE
26
27} // namespace tao
28
29#endif
diff --git a/MoonParser/pegtl/analysis/generic.hpp b/MoonParser/pegtl/analysis/generic.hpp
new file mode 100644
index 0000000..27e0ffe
--- /dev/null
+++ b/MoonParser/pegtl/analysis/generic.hpp
@@ -0,0 +1,39 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_ANALYSIS_GENERIC_HPP
5#define TAOCPP_PEGTL_INCLUDE_ANALYSIS_GENERIC_HPP
6
7#include "../config.hpp"
8
9#include "grammar_info.hpp"
10#include "insert_rules.hpp"
11#include "rule_type.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 namespace analysis
18 {
19 template< rule_type Type, typename... Rules >
20 struct generic
21 {
22 template< typename Name >
23 static std::string insert( grammar_info& g )
24 {
25 const auto r = g.insert< Name >( Type );
26 if( r.second ) {
27 insert_rules< Rules... >::insert( g, r.first->second );
28 }
29 return r.first->first;
30 }
31 };
32
33 } // namespace analysis
34
35 } // namespace TAOCPP_PEGTL_NAMESPACE
36
37} // namespace tao
38
39#endif
diff --git a/MoonParser/pegtl/analysis/grammar_info.hpp b/MoonParser/pegtl/analysis/grammar_info.hpp
new file mode 100644
index 0000000..15c96ab
--- /dev/null
+++ b/MoonParser/pegtl/analysis/grammar_info.hpp
@@ -0,0 +1,40 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_ANALYSIS_GRAMMAR_INFO_HPP
5#define TAOCPP_PEGTL_INCLUDE_ANALYSIS_GRAMMAR_INFO_HPP
6
7#include <map>
8#include <string>
9#include <utility>
10
11#include "../config.hpp"
12#include "../internal/demangle.hpp"
13
14#include "rule_info.hpp"
15
16namespace tao
17{
18 namespace TAOCPP_PEGTL_NAMESPACE
19 {
20 namespace analysis
21 {
22 struct grammar_info
23 {
24 using map_t = std::map< std::string, rule_info >;
25 map_t map;
26
27 template< typename Name >
28 std::pair< map_t::iterator, bool > insert( const rule_type type )
29 {
30 return map.insert( map_t::value_type( internal::demangle< Name >(), rule_info( type ) ) );
31 }
32 };
33
34 } // namespace analysis
35
36 } // namespace TAOCPP_PEGTL_NAMESPACE
37
38} // namespace tao
39
40#endif
diff --git a/MoonParser/pegtl/analysis/insert_guard.hpp b/MoonParser/pegtl/analysis/insert_guard.hpp
new file mode 100644
index 0000000..9a4cc35
--- /dev/null
+++ b/MoonParser/pegtl/analysis/insert_guard.hpp
@@ -0,0 +1,66 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_ANALYSIS_INSERT_GUARD_HPP
5#define TAOCPP_PEGTL_INCLUDE_ANALYSIS_INSERT_GUARD_HPP
6
7#include <utility>
8
9#include "../config.hpp"
10
11namespace tao
12{
13 namespace TAOCPP_PEGTL_NAMESPACE
14 {
15 namespace analysis
16 {
17 template< typename C >
18 class insert_guard
19 {
20 public:
21 insert_guard( insert_guard&& other ) noexcept
22 : m_i( other.m_i ),
23 m_c( other.m_c )
24 {
25 other.m_c = nullptr;
26 }
27
28 insert_guard( C& container, const typename C::value_type& value )
29 : m_i( container.insert( value ) ),
30 m_c( &container )
31 {
32 }
33
34 ~insert_guard()
35 {
36 if( m_c && m_i.second ) {
37 m_c->erase( m_i.first );
38 }
39 }
40
41 insert_guard( const insert_guard& ) = delete;
42 void operator=( const insert_guard& ) = delete;
43
44 explicit operator bool() const noexcept
45 {
46 return m_i.second;
47 }
48
49 private:
50 const std::pair< typename C::iterator, bool > m_i;
51 C* m_c;
52 };
53
54 template< typename C >
55 insert_guard< C > make_insert_guard( C& container, const typename C::value_type& value )
56 {
57 return insert_guard< C >( container, value );
58 }
59
60 } // namespace analysis
61
62 } // namespace TAOCPP_PEGTL_NAMESPACE
63
64} // namespace tao
65
66#endif
diff --git a/MoonParser/pegtl/analysis/insert_rules.hpp b/MoonParser/pegtl/analysis/insert_rules.hpp
new file mode 100644
index 0000000..ff55f66
--- /dev/null
+++ b/MoonParser/pegtl/analysis/insert_rules.hpp
@@ -0,0 +1,45 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_ANALYSIS_INSERT_RULES_HPP
5#define TAOCPP_PEGTL_INCLUDE_ANALYSIS_INSERT_RULES_HPP
6
7#include "../config.hpp"
8
9#include "grammar_info.hpp"
10#include "rule_info.hpp"
11
12namespace tao
13{
14 namespace TAOCPP_PEGTL_NAMESPACE
15 {
16 namespace analysis
17 {
18 template< typename... >
19 struct insert_rules;
20
21 template<>
22 struct insert_rules<>
23 {
24 static void insert( grammar_info&, rule_info& )
25 {
26 }
27 };
28
29 template< typename Rule, typename... Rules >
30 struct insert_rules< Rule, Rules... >
31 {
32 static void insert( grammar_info& g, rule_info& r )
33 {
34 r.rules.push_back( Rule::analyze_t::template insert< Rule >( g ) );
35 insert_rules< Rules... >::insert( g, r );
36 }
37 };
38
39 } // namespace analysis
40
41 } // namespace TAOCPP_PEGTL_NAMESPACE
42
43} // namespace tao
44
45#endif
diff --git a/MoonParser/pegtl/analysis/rule_info.hpp b/MoonParser/pegtl/analysis/rule_info.hpp
new file mode 100644
index 0000000..22910ec
--- /dev/null
+++ b/MoonParser/pegtl/analysis/rule_info.hpp
@@ -0,0 +1,37 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_ANALYSIS_RULE_INFO_HPP
5#define TAOCPP_PEGTL_INCLUDE_ANALYSIS_RULE_INFO_HPP
6
7#include <string>
8#include <vector>
9
10#include "../config.hpp"
11
12#include "rule_type.hpp"
13
14namespace tao
15{
16 namespace TAOCPP_PEGTL_NAMESPACE
17 {
18 namespace analysis
19 {
20 struct rule_info
21 {
22 explicit rule_info( const rule_type in_type )
23 : type( in_type )
24 {
25 }
26
27 rule_type type;
28 std::vector< std::string > rules;
29 };
30
31 } // namespace analysis
32
33 } // namespace TAOCPP_PEGTL_NAMESPACE
34
35} // namespace tao
36
37#endif
diff --git a/MoonParser/pegtl/analysis/rule_type.hpp b/MoonParser/pegtl/analysis/rule_type.hpp
new file mode 100644
index 0000000..fc5d4c8
--- /dev/null
+++ b/MoonParser/pegtl/analysis/rule_type.hpp
@@ -0,0 +1,29 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_ANALYSIS_RULE_TYPE_HPP
5#define TAOCPP_PEGTL_INCLUDE_ANALYSIS_RULE_TYPE_HPP
6
7#include "../config.hpp"
8
9namespace tao
10{
11 namespace TAOCPP_PEGTL_NAMESPACE
12 {
13 namespace analysis
14 {
15 enum class rule_type : char
16 {
17 ANY, // Consumption-on-success is always true; assumes bounded repetition of conjunction of sub-rules.
18 OPT, // Consumption-on-success not necessarily true; assumes bounded repetition of conjunction of sub-rules.
19 SEQ, // Consumption-on-success depends on consumption of (non-zero bounded repetition of) conjunction of sub-rules.
20 SOR // Consumption-on-success depends on consumption of (non-zero bounded repetition of) disjunction of sub-rules.
21 };
22
23 } // namespace analysis
24
25 } // namespace TAOCPP_PEGTL_NAMESPACE
26
27} // namespace tao
28
29#endif
diff --git a/MoonParser/pegtl/analyze.hpp b/MoonParser/pegtl/analyze.hpp
new file mode 100644
index 0000000..5468a14
--- /dev/null
+++ b/MoonParser/pegtl/analyze.hpp
@@ -0,0 +1,25 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_ANALYZE_HPP
5#define TAOCPP_PEGTL_INCLUDE_ANALYZE_HPP
6
7#include "config.hpp"
8
9#include "analysis/analyze_cycles.hpp"
10
11namespace tao
12{
13 namespace TAOCPP_PEGTL_NAMESPACE
14 {
15 template< typename Rule >
16 std::size_t analyze( const bool verbose = true )
17 {
18 return analysis::analyze_cycles< Rule >( verbose ).problems();
19 }
20
21 } // namespace TAOCPP_PEGTL_NAMESPACE
22
23} // namespace tao
24
25#endif
diff --git a/MoonParser/pegtl/apply_mode.hpp b/MoonParser/pegtl/apply_mode.hpp
new file mode 100644
index 0000000..93a701b
--- /dev/null
+++ b/MoonParser/pegtl/apply_mode.hpp
@@ -0,0 +1,23 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_APPLY_MODE_HPP
5#define TAOCPP_PEGTL_INCLUDE_APPLY_MODE_HPP
6
7#include "config.hpp"
8
9namespace tao
10{
11 namespace TAOCPP_PEGTL_NAMESPACE
12 {
13 enum class apply_mode : bool
14 {
15 ACTION = true,
16 NOTHING = false
17 };
18
19 } // namespace TAOCPP_PEGTL_NAMESPACE
20
21} // namespace tao
22
23#endif
diff --git a/MoonParser/pegtl/argv_input.hpp b/MoonParser/pegtl/argv_input.hpp
new file mode 100644
index 0000000..3846975
--- /dev/null
+++ b/MoonParser/pegtl/argv_input.hpp
@@ -0,0 +1,52 @@
1// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_ARGV_INPUT_HPP
5#define TAOCPP_PEGTL_INCLUDE_ARGV_INPUT_HPP
6
7#include <cstddef>
8#include <sstream>
9#include <string>
10#include <utility>
11
12#include "config.hpp"
13#include "eol.hpp"
14#include "memory_input.hpp"
15#include "tracking_mode.hpp"
16
17namespace tao
18{
19 namespace TAOCPP_PEGTL_NAMESPACE
20 {
21 namespace internal
22 {
23 inline std::string make_argv_source( const std::size_t argn )
24 {
25 std::ostringstream os;
26 os << "argv[" << argn << ']';
27 return os.str();
28 }
29
30 } // namespace internal
31
32 template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf >
33 struct argv_input
34 : public memory_input< P, Eol >
35 {
36 template< typename T >
37 argv_input( char** argv, const std::size_t argn, T&& in_source )
38 : memory_input< P, Eol >( static_cast< const char* >( argv[ argn ] ), std::forward< T >( in_source ) )
39 {
40 }
41
42 argv_input( char** argv, const std::size_t argn )
43 : argv_input( argv, argn, internal::make_argv_source( argn ) )
44 {
45 }
46 };
47
48 } // namespace TAOCPP_PEGTL_NAMESPACE
49
50} // namespace tao
51
52#endif
diff --git a/MoonParser/pegtl/ascii.hpp b/MoonParser/pegtl/ascii.hpp
new file mode 100644
index 0000000..9158061
--- /dev/null
+++ b/MoonParser/pegtl/ascii.hpp
@@ -0,0 +1,67 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_ASCII_HPP
5#define TAOCPP_PEGTL_INCLUDE_ASCII_HPP
6
7#include "config.hpp"
8#include "eol.hpp"
9
10#include "internal/result_on_found.hpp"
11#include "internal/rules.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 inline namespace ascii
18 {
19 // clang-format off
20 struct alnum : internal::alnum {};
21 struct alpha : internal::alpha {};
22 struct any : internal::any< internal::peek_char > {};
23 struct blank : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, ' ', '\t' > {};
24 struct digit : internal::range< internal::result_on_found::SUCCESS, internal::peek_char, '0', '9' > {};
25 struct eolf : internal::eolf {};
26 struct identifier_first : internal::identifier_first {};
27 struct identifier_other : internal::identifier_other {};
28 struct identifier : internal::identifier {};
29 template< char... Cs > struct istring : internal::istring< Cs... > {};
30 template< char... Cs > struct keyword : internal::seq< internal::string< Cs... >, internal::not_at< internal::identifier_other > > {};
31 struct lower : internal::range< internal::result_on_found::SUCCESS, internal::peek_char, 'a', 'z' > {};
32 template< char... Cs > struct not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_char, Cs... > {};
33 template< char Lo, char Hi > struct not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_char, Lo, Hi > {};
34 struct nul : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, char( 0 ) > {};
35 template< char... Cs > struct one : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, Cs... > {};
36 struct print : internal::range< internal::result_on_found::SUCCESS, internal::peek_char, char( 32 ), char( 126 ) > {};
37 template< char Lo, char Hi > struct range : internal::range< internal::result_on_found::SUCCESS, internal::peek_char, Lo, Hi > {};
38 template< char... Cs > struct ranges : internal::ranges< internal::peek_char, Cs... > {};
39 struct seven : internal::range< internal::result_on_found::SUCCESS, internal::peek_char, char( 0 ), char( 127 ) > {};
40 struct shebang : internal::if_must< internal::string< '#', '!' >, internal::until< internal::eolf > > {};
41 struct space : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, ' ', '\n', '\r', '\t', '\v', '\f' > {};
42 template< char... Cs > struct string : internal::string< Cs... > {};
43 template< char C > struct two : internal::string< C, C > {};
44 struct upper : internal::range< internal::result_on_found::SUCCESS, internal::peek_char, 'A', 'Z' > {};
45 struct xdigit : internal::ranges< internal::peek_char, '0', '9', 'a', 'f', 'A', 'F' > {};
46 // clang-format on
47
48 template<>
49 struct keyword<>
50 {
51 template< typename Input >
52 static bool match( Input& ) noexcept
53 {
54 static_assert( sizeof( Input ) == 0, "empty keywords not allowed" );
55 return false;
56 }
57 };
58
59 } // namespace ascii
60
61 } // namespace TAOCPP_PEGTL_NAMESPACE
62
63} // namespace tao
64
65#include "internal/pegtl_string.hpp"
66
67#endif
diff --git a/MoonParser/pegtl/buffer_input.hpp b/MoonParser/pegtl/buffer_input.hpp
new file mode 100644
index 0000000..b65e365
--- /dev/null
+++ b/MoonParser/pegtl/buffer_input.hpp
@@ -0,0 +1,179 @@
1// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_BUFFER_INPUT_HPP
5#define TAOCPP_PEGTL_INCLUDE_BUFFER_INPUT_HPP
6
7#include <cstddef>
8#include <cstring>
9#include <memory>
10#include <string>
11
12#include "config.hpp"
13#include "eol.hpp"
14#include "memory_input.hpp"
15#include "position.hpp"
16#include "tracking_mode.hpp"
17
18#include "internal/action_input.hpp"
19#include "internal/bump_impl.hpp"
20#include "internal/iterator.hpp"
21#include "internal/marker.hpp"
22
23namespace tao
24{
25 namespace TAOCPP_PEGTL_NAMESPACE
26 {
27 template< typename Reader, typename Eol = eol::lf_crlf, typename Source = std::string >
28 class buffer_input
29 {
30 public:
31 static constexpr tracking_mode tracking_mode_v = tracking_mode::IMMEDIATE;
32 using reader_t = Reader;
33
34 using eol_t = Eol;
35 using source_t = Source;
36
37 using iterator_t = internal::iterator;
38
39 using action_t = internal::action_input< buffer_input >;
40
41 template< typename T, typename... As >
42 buffer_input( T&& in_source, const std::size_t maximum, As&&... as )
43 : m_reader( std::forward< As >( as )... ),
44 m_maximum( maximum ),
45 m_buffer( new char[ maximum ] ),
46 m_current( m_buffer.get() ),
47 m_end( m_buffer.get() ),
48 m_source( std::forward< T >( in_source ) )
49 {
50 }
51
52 buffer_input( const buffer_input& ) = delete;
53 void operator=( const buffer_input& ) = delete;
54
55 bool empty()
56 {
57 require( 1 );
58 return m_current.data == m_end;
59 }
60
61 std::size_t size( const std::size_t amount )
62 {
63 require( amount );
64 return std::size_t( m_end - m_current.data );
65 }
66
67 const char* current() const noexcept
68 {
69 return m_current.data;
70 }
71
72 const char* end( const std::size_t amount )
73 {
74 require( amount );
75 return m_end;
76 }
77
78 std::size_t byte() const noexcept
79 {
80 return m_current.byte;
81 }
82
83 std::size_t line() const noexcept
84 {
85 return m_current.line;
86 }
87
88 std::size_t byte_in_line() const noexcept
89 {
90 return m_current.byte_in_line;
91 }
92
93 const Source& source() const noexcept
94 {
95 return m_source;
96 }
97
98 char peek_char( const std::size_t offset = 0 ) const noexcept
99 {
100 return m_current.data[ offset ];
101 }
102
103 unsigned char peek_byte( const std::size_t offset = 0 ) const noexcept
104 {
105 return static_cast< unsigned char >( peek_char( offset ) );
106 }
107
108 void bump( const std::size_t in_count = 1 ) noexcept
109 {
110 internal::bump( m_current, in_count, Eol::ch );
111 }
112
113 void bump_in_this_line( const std::size_t in_count = 1 ) noexcept
114 {
115 internal::bump_in_this_line( m_current, in_count );
116 }
117
118 void bump_to_next_line( const std::size_t in_count = 1 ) noexcept
119 {
120 internal::bump_to_next_line( m_current, in_count );
121 }
122
123 void discard() noexcept
124 {
125 const auto s = m_end - m_current.data;
126 std::memmove( m_buffer.get(), m_current.data, s );
127 m_current.data = m_buffer.get();
128 m_end = m_buffer.get() + s;
129 }
130
131 void require( const std::size_t amount )
132 {
133 if( m_current.data + amount > m_end ) {
134 if( m_current.data + amount <= m_buffer.get() + m_maximum ) {
135 if( const auto r = m_reader( const_cast< char* >( m_end ), amount - std::size_t( m_end - m_current.data ) ) ) {
136 m_end += r;
137 }
138 else {
139 m_maximum = 0;
140 }
141 }
142 }
143 }
144
145 template< rewind_mode M >
146 internal::marker< iterator_t, M > mark() noexcept
147 {
148 return internal::marker< iterator_t, M >( m_current );
149 }
150
151 TAOCPP_PEGTL_NAMESPACE::position position( const iterator_t& it ) const
152 {
153 return TAOCPP_PEGTL_NAMESPACE::position( it, m_source );
154 }
155
156 TAOCPP_PEGTL_NAMESPACE::position position() const
157 {
158 return position( m_current );
159 }
160
161 const iterator_t& iterator() const noexcept
162 {
163 return m_current;
164 }
165
166 private:
167 Reader m_reader;
168 std::size_t m_maximum;
169 std::unique_ptr< char[] > m_buffer;
170 iterator_t m_current;
171 const char* m_end;
172 const Source m_source;
173 };
174
175 } // namespace TAOCPP_PEGTL_NAMESPACE
176
177} // namespace tao
178
179#endif
diff --git a/MoonParser/pegtl/config.hpp b/MoonParser/pegtl/config.hpp
new file mode 100644
index 0000000..e93f74a
--- /dev/null
+++ b/MoonParser/pegtl/config.hpp
@@ -0,0 +1,15 @@
1// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_CONFIG_HPP
5#define TAOCPP_PEGTL_INCLUDE_CONFIG_HPP
6
7#ifndef TAOCPP_PEGTL_NAMESPACE
8#define TAOCPP_PEGTL_NAMESPACE pegtl
9#endif
10
11// Enable some improvements to the readability of
12// demangled type names under some circumstances.
13// #define TAOCPP_PEGTL_PRETTY_DEMANGLE
14
15#endif
diff --git a/MoonParser/pegtl/contrib/abnf.hpp b/MoonParser/pegtl/contrib/abnf.hpp
new file mode 100644
index 0000000..15319f5
--- /dev/null
+++ b/MoonParser/pegtl/contrib/abnf.hpp
@@ -0,0 +1,43 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_ABNF_HPP
5#define TAOCPP_PEGTL_INCLUDE_CONTRIB_ABNF_HPP
6
7#include "../config.hpp"
8#include "../internal/rules.hpp"
9
10namespace tao
11{
12 namespace TAOCPP_PEGTL_NAMESPACE
13 {
14 namespace abnf
15 {
16 // Core ABNF rules according to RFC 5234, Appendix B
17
18 // clang-format off
19 struct ALPHA : internal::ranges< internal::peek_char, 'a', 'z', 'A', 'Z' > {};
20 struct BIT : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, '0', '1' > {};
21 struct CHAR : internal::range< internal::result_on_found::SUCCESS, internal::peek_char, char( 1 ), char( 127 ) > {};
22 struct CR : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, '\r' > {};
23 struct CRLF : internal::string< '\r', '\n' > {};
24 struct CTL : internal::ranges< internal::peek_char, char( 0 ), char( 31 ), char( 127 ) > {};
25 struct DIGIT : internal::range< internal::result_on_found::SUCCESS, internal::peek_char, '0', '9' > {};
26 struct DQUOTE : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, '"' > {};
27 struct HEXDIG : internal::ranges< internal::peek_char, '0', '9', 'a', 'f', 'A', 'F' > {};
28 struct HTAB : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, '\t' > {};
29 struct LF : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, '\n' > {};
30 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' > > {};
31 struct OCTET : internal::any< internal::peek_char > {};
32 struct SP : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, ' ' > {};
33 struct VCHAR : internal::range< internal::result_on_found::SUCCESS, internal::peek_char, char( 33 ), char( 126 ) > {};
34 struct WSP : internal::one< internal::result_on_found::SUCCESS, internal::peek_char, ' ', '\t' > {};
35 // clang-format on
36
37 } // namespace abnf
38
39 } // namespace TAOCPP_PEGTL_NAMESPACE
40
41} // namespace tao
42
43#endif
diff --git a/MoonParser/pegtl/contrib/alphabet.hpp b/MoonParser/pegtl/contrib/alphabet.hpp
new file mode 100644
index 0000000..c0dce42
--- /dev/null
+++ b/MoonParser/pegtl/contrib/alphabet.hpp
@@ -0,0 +1,75 @@
1// Copyright (c) 2015-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_ALPHABET_HPP
5#define TAOCPP_PEGTL_INCLUDE_CONTRIB_ALPHABET_HPP
6
7#include "../config.hpp"
8
9namespace tao
10{
11 namespace TAOCPP_PEGTL_NAMESPACE
12 {
13 inline namespace alphabet
14 {
15 static const int a = 'a';
16 static const int b = 'b';
17 static const int c = 'c';
18 static const int d = 'd';
19 static const int e = 'e';
20 static const int f = 'f';
21 static const int g = 'g';
22 static const int h = 'h';
23 static const int i = 'i';
24 static const int j = 'j';
25 static const int k = 'k';
26 static const int l = 'l';
27 static const int m = 'm';
28 static const int n = 'n';
29 static const int o = 'o';
30 static const int p = 'p';
31 static const int q = 'q';
32 static const int r = 'r';
33 static const int s = 's';
34 static const int t = 't';
35 static const int u = 'u';
36 static const int v = 'v';
37 static const int w = 'w';
38 static const int x = 'x';
39 static const int y = 'y';
40 static const int z = 'z';
41
42 static const int A = 'A';
43 static const int B = 'B';
44 static const int C = 'C';
45 static const int D = 'D';
46 static const int E = 'E';
47 static const int F = 'F';
48 static const int G = 'G';
49 static const int H = 'H';
50 static const int I = 'I';
51 static const int J = 'J';
52 static const int K = 'K';
53 static const int L = 'L';
54 static const int M = 'M';
55 static const int N = 'N';
56 static const int O = 'O';
57 static const int P = 'P';
58 static const int Q = 'Q';
59 static const int R = 'R';
60 static const int S = 'S';
61 static const int T = 'T';
62 static const int U = 'U';
63 static const int V = 'V';
64 static const int W = 'W';
65 static const int X = 'X';
66 static const int Y = 'Y';
67 static const int Z = 'Z';
68
69 } // namespace alphabet
70
71 } // namespace TAOCPP_PEGTL_NAMESPACE
72
73} // namespace tao
74
75#endif
diff --git a/MoonParser/pegtl/contrib/changes.hpp b/MoonParser/pegtl/contrib/changes.hpp
new file mode 100644
index 0000000..7b9f8dc
--- /dev/null
+++ b/MoonParser/pegtl/contrib/changes.hpp
@@ -0,0 +1,86 @@
1// Copyright (c) 2015-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_CHANGES_HPP
5#define TAOCPP_PEGTL_INCLUDE_CONTRIB_CHANGES_HPP
6
7#include <type_traits>
8
9#include "../config.hpp"
10#include "../normal.hpp"
11
12namespace tao
13{
14 namespace TAOCPP_PEGTL_NAMESPACE
15 {
16 namespace internal
17 {
18 struct dummy_disabled_state
19 {
20 template< typename... Ts >
21 void success( Ts&&... ) const noexcept
22 {
23 }
24 };
25
26 template< apply_mode A, typename State >
27 using state_disable_helper = typename std::conditional< A == apply_mode::ACTION, State, dummy_disabled_state >::type;
28
29 } // namespace internal
30
31 template< typename Rule, typename State, template< typename... > class Base = normal >
32 struct change_state
33 : public Base< Rule >
34 {
35 template< apply_mode A,
36 rewind_mode M,
37 template< typename... > class Action,
38 template< typename... > class Control,
39 typename Input,
40 typename... States >
41 static bool match( Input& in, States&&... st )
42 {
43 internal::state_disable_helper< A, State > s;
44
45 if( Base< Rule >::template match< A, M, Action, Control >( in, s ) ) {
46 s.success( st... );
47 return true;
48 }
49 return false;
50 }
51 };
52
53 template< typename Rule, template< typename... > class Action, template< typename... > class Base = normal >
54 struct change_action
55 : public Base< Rule >
56 {
57 template< apply_mode A,
58 rewind_mode M,
59 template< typename... > class,
60 template< typename... > class Control,
61 typename Input,
62 typename... States >
63 static bool match( Input& in, States&&... st )
64 {
65 return Base< Rule >::template match< A, M, Action, Control >( in, st... );
66 }
67 };
68
69 template< template< typename... > class Action, template< typename... > class Base >
70 struct change_both_helper
71 {
72 template< typename T >
73 using change_action = change_action< T, Action, Base >;
74 };
75
76 template< typename Rule, typename State, template< typename... > class Action, template< typename... > class Base = normal >
77 struct change_state_and_action
78 : public change_state< Rule, State, change_both_helper< Action, Base >::template change_action >
79 {
80 };
81
82 } // namespace TAOCPP_PEGTL_NAMESPACE
83
84} // namespace tao
85
86#endif
diff --git a/MoonParser/pegtl/contrib/counter.hpp b/MoonParser/pegtl/contrib/counter.hpp
new file mode 100644
index 0000000..52beb3b
--- /dev/null
+++ b/MoonParser/pegtl/contrib/counter.hpp
@@ -0,0 +1,58 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_COUNTER_HPP
5#define TAOCPP_PEGTL_INCLUDE_CONTRIB_COUNTER_HPP
6
7#include <cassert>
8#include <utility>
9
10#include "../config.hpp"
11#include "../normal.hpp"
12
13#include "../internal/demangle.hpp"
14
15namespace tao
16{
17 namespace TAOCPP_PEGTL_NAMESPACE
18 {
19 struct counter_data
20 {
21 unsigned start = 0;
22 unsigned success = 0;
23 unsigned failure = 0;
24 };
25
26 struct counter_state
27 {
28 std::map< std::string, counter_data > counts;
29 };
30
31 template< typename Rule >
32 struct counter
33 : normal< Rule >
34 {
35 template< typename Input >
36 static void start( const Input&, counter_state& ts )
37 {
38 ++ts.counts[ internal::demangle< Rule >() ].start;
39 }
40
41 template< typename Input >
42 static void success( const Input&, counter_state& ts )
43 {
44 ++ts.counts[ internal::demangle< Rule >() ].success;
45 }
46
47 template< typename Input >
48 static void failure( const Input&, counter_state& ts )
49 {
50 ++ts.counts[ internal::demangle< Rule >() ].failure;
51 }
52 };
53
54 } // namespace TAOCPP_PEGTL_NAMESPACE
55
56} // namespace tao
57
58#endif
diff --git a/MoonParser/pegtl/contrib/http.hpp b/MoonParser/pegtl/contrib/http.hpp
new file mode 100644
index 0000000..1446449
--- /dev/null
+++ b/MoonParser/pegtl/contrib/http.hpp
@@ -0,0 +1,152 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_HTTP_HPP
5#define TAOCPP_PEGTL_INCLUDE_CONTRIB_HTTP_HPP
6
7#include "../ascii.hpp"
8#include "../config.hpp"
9#include "../rules.hpp"
10#include "../utf8.hpp"
11#include "abnf.hpp"
12#include "uri.hpp"
13
14namespace tao
15{
16 namespace TAOCPP_PEGTL_NAMESPACE
17 {
18 namespace http
19 {
20 // HTTP 1.1 grammar according to RFC 7230.
21
22 // This grammar is a direct PEG translation of the original HTTP grammar.
23 // It should be considered experimental -- in case of any issues, in particular
24 // missing rules for attached actions, please contact the developers.
25
26 using namespace abnf;
27
28 using OWS = star< WSP >; // optional whitespace
29 using RWS = plus< WSP >; // required whitespace
30 using BWS = OWS; // "bad" whitespace
31
32 // cppcheck-suppress constStatement
33 using obs_text = not_range< 0x00, 0x7F >;
34 using obs_fold = seq< CRLF, plus< WSP > >;
35
36 // clang-format off
37 struct tchar : sor< ALPHA, DIGIT, one< '!', '#', '$', '%', '&', '\'', '*', '+', '-', '.', '^', '_', '`', '|', '~' > > {};
38 struct token : plus< tchar > {};
39
40 struct field_name : token {};
41
42 struct field_vchar : sor< VCHAR, obs_text > {};
43 struct field_content : list< field_vchar, plus< WSP > > {};
44 struct field_value : star< sor< field_content, obs_fold > > {};
45
46 struct header_field : seq< field_name, one< ':' >, OWS, field_value, OWS > {};
47
48 struct method : token {};
49
50 struct absolute_path : plus< one< '/' >, uri::segment > {};
51
52 struct origin_form : seq< absolute_path, uri::opt_query > {};
53 struct absolute_form : uri::absolute_URI {};
54 struct authority_form : uri::authority {};
55 struct asterisk_form : one< '*' > {};
56
57 struct request_target : sor< origin_form, absolute_form, authority_form, asterisk_form > {};
58
59 struct status_code : rep< 3, DIGIT > {};
60 struct reason_phrase : star< sor< VCHAR, obs_text, WSP > > {};
61
62 struct HTTP_version : if_must< TAOCPP_PEGTL_STRING( "HTTP/" ), DIGIT, one< '.' >, DIGIT > {};
63
64 struct request_line : if_must< method, SP, request_target, SP, HTTP_version, CRLF > {};
65 struct status_line : if_must< HTTP_version, SP, status_code, SP, reason_phrase, CRLF > {};
66 struct start_line : sor< status_line, request_line > {};
67
68 struct message_body : star< OCTET > {};
69 struct HTTP_message : seq< start_line, star< header_field, CRLF >, CRLF, opt< message_body > > {};
70
71 struct Content_Length : plus< DIGIT > {};
72
73 struct uri_host : uri::host {};
74 struct port : uri::port {};
75
76 struct Host : seq< uri_host, opt< one< ':' >, port > > {};
77
78 // PEG are different from CFGs! (this replaces ctext and qdtext)
79 using text = sor< HTAB, range< 0x20, 0x7E >, obs_text >;
80
81 struct quoted_pair : if_must< one< '\\' >, sor< VCHAR, obs_text, WSP > > {};
82 struct quoted_string : if_must< DQUOTE, until< DQUOTE, sor< quoted_pair, text > > > {};
83
84 struct transfer_parameter : seq< token, BWS, one< '=' >, BWS, sor< token, quoted_string > > {};
85 struct transfer_extension : seq< token, star< OWS, one< ';' >, OWS, transfer_parameter > > {};
86 struct transfer_coding : sor< TAOCPP_PEGTL_ISTRING( "chunked" ),
87 TAOCPP_PEGTL_ISTRING( "compress" ),
88 TAOCPP_PEGTL_ISTRING( "deflate" ),
89 TAOCPP_PEGTL_ISTRING( "gzip" ),
90 transfer_extension > {};
91
92 struct rank : sor< seq< one< '0' >, opt< one< '.' >, rep_opt< 3, DIGIT > > >,
93 seq< one< '1' >, opt< one< '.' >, rep_opt< 3, one< '0' > > > > > {};
94
95 struct t_ranking : seq< OWS, one< ';' >, OWS, one< 'q', 'Q' >, one< '=' >, rank > {};
96 struct t_codings : sor< TAOCPP_PEGTL_ISTRING( "trailers" ), seq< transfer_coding, opt< t_ranking > > > {};
97
98 struct TE : opt< sor< one< ',' >, t_codings >, star< OWS, one< ',' >, opt< OWS, t_codings > > > {};
99
100 template< typename T >
101 using make_comma_list = seq< star< one< ',' >, OWS >, T, star< OWS, one< ',' >, opt< OWS, T > > >;
102
103 struct connection_option : token {};
104 struct Connection : make_comma_list< connection_option > {};
105
106 struct Trailer : make_comma_list< field_name > {};
107
108 struct Transfer_Encoding : make_comma_list< transfer_coding > {};
109
110 struct protocol_name : token {};
111 struct protocol_version : token {};
112 struct protocol : seq< protocol_name, opt< one< '/' >, protocol_version > > {};
113 struct Upgrade : make_comma_list< protocol > {};
114
115 struct pseudonym : token {};
116
117 struct received_protocol : seq< opt< protocol_name, one< '/' > >, protocol_version > {};
118 struct received_by : sor< seq< uri_host, opt< one< ':' >, port > >, pseudonym > {};
119
120 struct comment : if_must< one< '(' >, until< one< ')' >, sor< comment, quoted_pair, text > > > {};
121
122 struct Via : make_comma_list< seq< received_protocol, RWS, received_by, opt< RWS, comment > > > {};
123
124 struct http_URI : if_must< TAOCPP_PEGTL_ISTRING( "http://" ), uri::authority, uri::path_abempty, uri::opt_query, uri::opt_fragment > {};
125 struct https_URI : if_must< TAOCPP_PEGTL_ISTRING( "https://" ), uri::authority, uri::path_abempty, uri::opt_query, uri::opt_fragment > {};
126
127 struct partial_URI : seq< uri::relative_part, uri::opt_query > {};
128
129 struct chunk_size : plus< HEXDIG > {};
130
131 struct chunk_ext_name : token {};
132 struct chunk_ext_val : sor< quoted_string, token > {};
133 struct chunk_ext : star< if_must< one< ';' >, chunk_ext_name, if_must< one< '=' >, chunk_ext_val > > > {};
134
135 struct chunk_data : until< at< CRLF >, OCTET > {};
136
137 struct chunk : seq< chunk_size, opt< chunk_ext >, CRLF, chunk_data, CRLF > {};
138
139 struct last_chunk : seq< plus< one< '0' > >, opt< chunk_ext >, CRLF > {};
140
141 struct trailer_part : star< header_field, CRLF > {};
142
143 struct chunked_body : seq< until< last_chunk, chunk >, trailer_part, CRLF > {};
144 // clang-format on
145
146 } // namespace http
147
148 } // namespace TAOCPP_PEGTL_NAMESPACE
149
150} // namespace tao
151
152#endif
diff --git a/MoonParser/pegtl/contrib/json.hpp b/MoonParser/pegtl/contrib/json.hpp
new file mode 100644
index 0000000..688f607
--- /dev/null
+++ b/MoonParser/pegtl/contrib/json.hpp
@@ -0,0 +1,98 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_JSON_HPP
5#define TAOCPP_PEGTL_INCLUDE_CONTRIB_JSON_HPP
6
7#include "../ascii.hpp"
8#include "../config.hpp"
9#include "../rules.hpp"
10#include "../utf8.hpp"
11
12#include "abnf.hpp"
13
14namespace tao
15{
16 namespace TAOCPP_PEGTL_NAMESPACE
17 {
18 namespace json
19 {
20 // JSON grammar according to RFC 7159 (for UTF-8 encoded JSON only).
21
22 // clang-format off
23 struct ws : one< ' ', '\t', '\n', '\r' > {};
24
25 template< typename R, typename P = ws >
26 struct padr : internal::seq< R, internal::star< P > > {};
27
28 struct begin_array : padr< one< '[' > > {};
29 struct begin_object : padr< one< '{' > > {};
30 struct end_array : one< ']' > {};
31 struct end_object : one< '}' > {};
32 struct name_separator : pad< one< ':' >, ws > {};
33 struct value_separator : padr< one< ',' > > {};
34
35 struct false_ : TAOCPP_PEGTL_STRING( "false" ) {};
36 struct null : TAOCPP_PEGTL_STRING( "null" ) {};
37 struct true_ : TAOCPP_PEGTL_STRING( "true" ) {};
38
39 struct digits : plus< abnf::DIGIT > {};
40 struct exp : seq< one< 'e', 'E' >, opt< one< '-', '+'> >, must< digits > > {};
41 struct frac : if_must< one< '.' >, digits > {};
42 struct int_ : sor< one< '0' >, digits > {};
43 struct number : seq< opt< one< '-' > >, int_, opt< frac >, opt< exp > > {};
44
45 struct xdigit : abnf::HEXDIG {};
46 struct unicode : list< seq< one< 'u' >, rep< 4, must< xdigit > > >, one< '\\' > > {};
47 struct escaped_char : one< '"', '\\', '/', 'b', 'f', 'n', 'r', 't' > {};
48 struct escaped : sor< escaped_char, unicode > {};
49 struct unescaped : utf8::range< 0x20, 0x10FFFF > {};
50 struct char_ : if_then_else< one< '\\' >, must< escaped >, unescaped > {};
51
52 struct string_content : until< at< one< '"' > >, must< char_ > > {};
53 struct string : seq< one< '"' >, must< string_content >, any >
54 {
55 using content = string_content;
56 };
57
58 struct key_content : until< at< one< '"' > >, must< char_ > > {};
59 struct key : seq< one< '"' >, must< key_content >, any >
60 {
61 using content = key_content;
62 };
63
64 struct value;
65
66 struct array_element;
67 struct array_content : opt< list_must< array_element, value_separator > > {};
68 struct array : seq< begin_array, array_content, must< end_array > >
69 {
70 using begin = begin_array;
71 using end = end_array;
72 using element = array_element;
73 using content = array_content;
74 };
75
76 struct member : if_must< key, name_separator, value > {};
77 struct object_content : opt< list_must< member, value_separator > > {};
78 struct object : seq< begin_object, object_content, must< end_object > >
79 {
80 using begin = begin_object;
81 using end = end_object;
82 using element = member;
83 using content = object_content;
84 };
85
86 struct value : padr< sor< string, number, object, array, false_, true_, null > > {};
87 struct array_element : seq< value > {};
88
89 struct text : seq< star< ws >, value > {};
90 // clang-format on
91
92 } // namespace json
93
94 } // namespace TAOCPP_PEGTL_NAMESPACE
95
96} // namespace tao
97
98#endif
diff --git a/MoonParser/pegtl/contrib/raw_string.hpp b/MoonParser/pegtl/contrib/raw_string.hpp
new file mode 100644
index 0000000..592ce5b
--- /dev/null
+++ b/MoonParser/pegtl/contrib/raw_string.hpp
@@ -0,0 +1,252 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_RAW_STRING_HPP
5#define TAOCPP_PEGTL_INCLUDE_CONTRIB_RAW_STRING_HPP
6
7#include "../apply_mode.hpp"
8#include "../config.hpp"
9#include "../nothing.hpp"
10#include "../rewind_mode.hpp"
11
12#include "../internal/iterator.hpp"
13#include "../internal/must.hpp"
14#include "../internal/skip_control.hpp"
15#include "../internal/state.hpp"
16#include "../internal/until.hpp"
17
18#include "../analysis/generic.hpp"
19
20namespace tao
21{
22 namespace TAOCPP_PEGTL_NAMESPACE
23 {
24 namespace internal
25 {
26 template< char Open, char Marker, char Close, typename... Contents >
27 struct raw_string_tag
28 {
29 };
30
31 template< bool use_action, bool use_apply0, typename Tag >
32 struct raw_string_state_apply;
33
34 template< typename Tag >
35 struct raw_string_state_apply< false, false, Tag >
36 {
37 template< template< typename... > class,
38 template< typename... > class,
39 typename State,
40 typename Input,
41 typename... States >
42 static void success( const State&, const Input&, States&&... )
43 {
44 }
45 };
46
47 template< typename Tag >
48 struct raw_string_state_apply< true, false, Tag >
49 {
50 template< template< typename... > class Action,
51 template< typename... > class Control,
52 typename State,
53 typename Input,
54 typename... States >
55 static void success( const State& s, const Input& in, States&&... st )
56 {
57 Control< Tag >::template apply< Action >( s.iter, in, st... );
58 }
59 };
60
61 template< typename Tag >
62 struct raw_string_state_apply< true, true, Tag >
63 {
64 template< template< typename... > class Action,
65 template< typename... > class Control,
66 typename State,
67 typename Input,
68 typename... States >
69 static void success( const State&, const Input& in, States&&... st )
70 {
71 Control< Tag >::template apply0< Action >( in, st... );
72 }
73 };
74
75 template< typename Tag, typename Iterator >
76 struct raw_string_state
77 {
78 template< typename Input, typename... States >
79 raw_string_state( const Input&, States&&... )
80 {
81 }
82
83 template< apply_mode A,
84 rewind_mode,
85 template< typename... > class Action,
86 template< typename... > class Control,
87 typename Input,
88 typename... States >
89 void success( Input& in, States&&... st ) const
90 {
91 constexpr bool use_action = ( A == apply_mode::ACTION ) && ( !is_nothing< Action, Tag >::value );
92 constexpr bool use_apply0 = use_action && has_apply0< Action< Tag >, type_list< States... > >::value;
93 raw_string_state_apply< use_action, use_apply0, Tag >::template success< Action, Control >( *this, in, st... );
94 in.bump_in_this_line( marker_size );
95 }
96
97 raw_string_state( const raw_string_state& ) = delete;
98 void operator=( const raw_string_state& ) = delete;
99
100 Iterator iter;
101 std::size_t marker_size = 0;
102 };
103
104 template< char Open, char Marker >
105 struct raw_string_open
106 {
107 using analyze_t = analysis::generic< analysis::rule_type::ANY >;
108
109 template< apply_mode A,
110 rewind_mode,
111 template< typename... > class Action,
112 template< typename... > class Control,
113 typename Input,
114 typename State >
115 static bool match( Input& in, State& ls )
116 {
117 if( in.empty() || ( in.peek_char( 0 ) != Open ) ) {
118 return false;
119 }
120 for( std::size_t i = 1; i < in.size( i + 1 ); ++i ) {
121 switch( const auto c = in.peek_char( i ) ) {
122 case Open:
123 ls.marker_size = i + 1;
124 in.bump( ls.marker_size );
125 eol::match( in );
126 ls.iter = in.iterator();
127 return true;
128 case Marker:
129 break;
130 default:
131 return false;
132 }
133 }
134 return false;
135 }
136 };
137
138 template< char Open, char Marker >
139 struct skip_control< raw_string_open< Open, Marker > > : std::true_type
140 {
141 };
142
143 template< char Marker, char Close >
144 struct at_raw_string_close
145 {
146 using analyze_t = analysis::generic< analysis::rule_type::ANY >;
147
148 template< apply_mode A,
149 rewind_mode,
150 template< typename... > class Action,
151 template< typename... > class Control,
152 typename Input,
153 typename State >
154 static bool match( Input& in, const State& ls )
155 {
156 if( in.size( ls.marker_size ) < ls.marker_size ) {
157 return false;
158 }
159 if( in.peek_char( 0 ) != Close ) {
160 return false;
161 }
162 if( in.peek_char( ls.marker_size - 1 ) != Close ) {
163 return false;
164 }
165 for( std::size_t i = 0; i < ls.marker_size - 2; ++i ) {
166 if( in.peek_char( i + 1 ) != Marker ) {
167 return false;
168 }
169 }
170 return true;
171 }
172 };
173
174 template< char Marker, char Close >
175 struct skip_control< at_raw_string_close< Marker, Close > > : std::true_type
176 {
177 };
178
179 template< class Tag, typename... Rules >
180 struct raw_string_switch_state
181 {
182 using analyze_t = analysis::generic< analysis::rule_type::SEQ, Rules... >;
183
184 template< apply_mode A,
185 rewind_mode M,
186 template< typename... > class Action,
187 template< typename... > class Control,
188 typename Input,
189 typename... States >
190 static bool match( Input& in, States&&... st )
191 {
192 using Iterator = typename Input::iterator_t;
193 raw_string_state< Tag, Iterator > s( const_cast< const Input& >( in ), st... );
194
195 if( duseltronik< seq< Rules... >, A, M, Action, Control >::match( in, s ) ) {
196 s.template success< A, M, Action, Control >( in, st... );
197 return true;
198 }
199 return false;
200 }
201 };
202
203 template< typename Tag, typename... Rules >
204 struct skip_control< raw_string_switch_state< Tag, Rules... > > : std::true_type
205 {
206 };
207
208 } // namespace internal
209
210 // raw_string matches Lua-style long literals.
211 //
212 // The following description was taken from the Lua documentation
213 // (see http://www.lua.org/docs.html):
214 //
215 // - An "opening long bracket of level n" is defined as an opening square
216 // bracket followed by n equal signs followed by another opening square
217 // bracket. So, an opening long bracket of level 0 is written as `[[`,
218 // an opening long bracket of level 1 is written as `[=[`, and so on.
219 // - A "closing long bracket" is defined similarly; for instance, a closing
220 // long bracket of level 4 is written as `]====]`.
221 // - A "long literal" starts with an opening long bracket of any level and
222 // ends at the first closing long bracket of the same level. It can
223 // contain any text except a closing bracket of the same level.
224 // - Literals in this bracketed form can run for several lines, do not
225 // interpret any escape sequences, and ignore long brackets of any other
226 // level.
227 // - For convenience, when the opening long bracket is immediately followed
228 // by a newline, the newline is not included in the string.
229 //
230 // Note that unlike Lua's long literal, a raw_string is customizable to use
231 // other characters than `[`, `=` and `]` for matching. Also note that Lua
232 // introduced newline-specific replacements in Lua 5.2, which we do not
233 // support on the grammar level.
234
235 template< char Open, char Marker, char Close, typename... Contents >
236 struct raw_string
237 : internal::raw_string_switch_state< internal::raw_string_tag< Open, Marker, Close >,
238 internal::raw_string_open< Open, Marker >,
239 internal::must< internal::until< internal::at_raw_string_close< Marker, Close >, Contents... > > >
240 {
241 // This is used to bind an action to the content.
242 using content = internal::raw_string_tag< Open, Marker, Close, Contents... >;
243
244 // This is used for error-reporting when a raw string is not closed properly.
245 using close = internal::until< internal::at_raw_string_close< Marker, Close > >;
246 };
247
248 } // namespace TAOCPP_PEGTL_NAMESPACE
249
250} // namespace tao
251
252#endif
diff --git a/MoonParser/pegtl/contrib/rep_one_min_max.hpp b/MoonParser/pegtl/contrib/rep_one_min_max.hpp
new file mode 100644
index 0000000..28fdbcd
--- /dev/null
+++ b/MoonParser/pegtl/contrib/rep_one_min_max.hpp
@@ -0,0 +1,72 @@
1// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_REP_ONE_MIN_MAX_HPP
5#define TAOCPP_PEGTL_INCLUDE_CONTRIB_REP_ONE_MIN_MAX_HPP
6
7#include <algorithm>
8
9#include "../config.hpp"
10
11#include "../analysis/counted.hpp"
12
13#include "../internal/bump_help.hpp"
14#include "../internal/skip_control.hpp"
15
16namespace tao
17{
18 namespace TAOCPP_PEGTL_NAMESPACE
19 {
20 namespace internal
21 {
22 template< unsigned Min, unsigned Max, char C >
23 struct rep_one_min_max
24 {
25 using analyze_t = analysis::counted< analysis::rule_type::ANY, Min >;
26
27 static_assert( Min <= Max, "invalid rep_one_min_max rule (maximum number of repetitions smaller than minimum)" );
28
29 template< typename Input >
30 static bool match( Input& in )
31 {
32 const auto size = in.size( Max + 1 );
33 if( size < Min ) {
34 return false;
35 }
36 std::size_t i = 0;
37 while( ( i < size ) && ( in.peek_char( i ) == C ) ) {
38 ++i;
39 }
40 if( ( Min <= i ) && ( i <= Max ) ) {
41 bump_help< result_on_found::SUCCESS, Input, char, C >( in, i );
42 return true;
43 }
44 return false;
45 }
46 };
47
48 template< unsigned Min, unsigned Max, char C >
49 struct skip_control< rep_one_min_max< Min, Max, C > > : std::true_type
50 {
51 };
52
53 } // namespace internal
54
55 inline namespace ascii
56 {
57 template< unsigned Min, unsigned Max, char C >
58 struct rep_one_min_max : internal::rep_one_min_max< Min, Max, C >
59 {
60 };
61
62 struct ellipsis : internal::rep_one_min_max< 3, 3, '.' >
63 {
64 };
65
66 } // namespace ascii
67
68 } // namespace TAOCPP_PEGTL_NAMESPACE
69
70} // namespace tao
71
72#endif
diff --git a/MoonParser/pegtl/contrib/to_string.hpp b/MoonParser/pegtl/contrib/to_string.hpp
new file mode 100644
index 0000000..4c19931
--- /dev/null
+++ b/MoonParser/pegtl/contrib/to_string.hpp
@@ -0,0 +1,42 @@
1// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_TO_STRING_HPP
5#define TAOCPP_PEGTL_INCLUDE_CONTRIB_TO_STRING_HPP
6
7#include <string>
8
9#include "../config.hpp"
10
11namespace tao
12{
13 namespace TAOCPP_PEGTL_NAMESPACE
14 {
15 namespace internal
16 {
17 template< typename >
18 struct to_string;
19
20 template< template< char... > class X, char... Cs >
21 struct to_string< X< Cs... > >
22 {
23 static std::string get()
24 {
25 const char s[] = { Cs..., 0 };
26 return std::string( s, sizeof...( Cs ) );
27 }
28 };
29
30 } // namespace internal
31
32 template< typename T >
33 std::string to_string()
34 {
35 return internal::to_string< T >::get();
36 }
37
38 } // namespace TAOCPP_PEGTL_NAMESPACE
39
40} // namespace tao
41
42#endif
diff --git a/MoonParser/pegtl/contrib/tracer.hpp b/MoonParser/pegtl/contrib/tracer.hpp
new file mode 100644
index 0000000..5649078
--- /dev/null
+++ b/MoonParser/pegtl/contrib/tracer.hpp
@@ -0,0 +1,111 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_TRACER_HPP
5#define TAOCPP_PEGTL_INCLUDE_CONTRIB_TRACER_HPP
6
7#include <cassert>
8#include <iomanip>
9#include <iostream>
10#include <utility>
11#include <vector>
12
13#include "../config.hpp"
14#include "../normal.hpp"
15
16#include "../internal/demangle.hpp"
17
18namespace tao
19{
20 namespace TAOCPP_PEGTL_NAMESPACE
21 {
22 struct trace_state
23 {
24 unsigned rule = 0;
25 unsigned line = 0;
26 std::vector< unsigned > stack;
27 };
28
29 template< typename Rule >
30 struct tracer
31 : normal< Rule >
32 {
33 template< typename Input, typename... States >
34 static void start( const Input& in, States&&... )
35 {
36 std::cerr << in.position() << " start " << internal::demangle< Rule >() << std::endl;
37 }
38
39 template< typename Input >
40 static void start( const Input& in, trace_state& ts )
41 {
42 std::cerr << std::setw( 6 ) << ++ts.line << " " << std::setw( 6 ) << ++ts.rule << " " << in.position() << " start " << internal::demangle< Rule >() << std::endl;
43 ts.stack.push_back( ts.rule );
44 }
45
46 template< typename Input, typename... States >
47 static void success( const Input& in, States&&... )
48 {
49 std::cerr << in.position() << " success " << internal::demangle< Rule >() << std::endl;
50 }
51
52 template< typename Input >
53 static void success( const Input& in, trace_state& ts )
54 {
55 assert( !ts.stack.empty() );
56 std::cerr << std::setw( 6 ) << ++ts.line << " " << std::setw( 6 ) << ts.stack.back() << " " << in.position() << " success " << internal::demangle< Rule >() << std::endl;
57 ts.stack.pop_back();
58 }
59
60 template< typename Input, typename... States >
61 static void failure( const Input& in, States&&... )
62 {
63 std::cerr << in.position() << " failure " << internal::demangle< Rule >() << std::endl;
64 }
65
66 template< typename Input >
67 static void failure( const Input& in, trace_state& ts )
68 {
69 assert( !ts.stack.empty() );
70 std::cerr << std::setw( 6 ) << ++ts.line << " " << std::setw( 6 ) << ts.stack.back() << " " << in.position() << " failure " << internal::demangle< Rule >() << std::endl;
71 ts.stack.pop_back();
72 }
73
74 template< template< typename... > class Action, typename Input, typename... States >
75 static void apply0( const Input&, States&&... st )
76 {
77 std::cerr << "apply0 " << internal::demangle< Action< Rule > >() << std::endl;
78 Action< Rule >::apply0( st... );
79 }
80
81 template< template< typename... > class Action, typename Input >
82 static void apply0( const Input&, trace_state& ts )
83 {
84 std::cerr << std::setw( 6 ) << ++ts.line << " " << internal::demangle< Action< Rule > >() << "::apply0()" << std::endl;
85 Action< Rule >::apply0( ts );
86 }
87
88 template< template< typename... > class Action, typename Iterator, typename Input, typename... States >
89 static void apply( const Iterator& begin, const Input& in, States&&... st )
90 {
91 std::cerr << "apply " << internal::demangle< Action< Rule > >() << std::endl;
92 using action_t = typename Input::action_t;
93 const action_t action_input( begin, in );
94 Action< Rule >::apply( action_input, st... );
95 }
96
97 template< template< typename... > class Action, typename Iterator, typename Input >
98 static void apply( const Iterator& begin, const Input& in, trace_state& ts )
99 {
100 std::cerr << std::setw( 6 ) << ++ts.line << " " << internal::demangle< Action< Rule > >() << "::apply()" << std::endl;
101 using action_t = typename Input::action_t;
102 const action_t action_input( begin, in );
103 Action< Rule >::apply( action_input, ts );
104 }
105 };
106
107 } // namespace TAOCPP_PEGTL_NAMESPACE
108
109} // namespace tao
110
111#endif
diff --git a/MoonParser/pegtl/contrib/unescape.hpp b/MoonParser/pegtl/contrib/unescape.hpp
new file mode 100644
index 0000000..2a7c53f
--- /dev/null
+++ b/MoonParser/pegtl/contrib/unescape.hpp
@@ -0,0 +1,203 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_UNESCAPE_HPP
5#define TAOCPP_PEGTL_INCLUDE_CONTRIB_UNESCAPE_HPP
6
7#include <cassert>
8#include <string>
9
10#include "../ascii.hpp"
11#include "../config.hpp"
12#include "../parse_error.hpp"
13
14namespace tao
15{
16 namespace TAOCPP_PEGTL_NAMESPACE
17 {
18 namespace unescape
19 {
20 struct state
21 {
22 std::string unescaped;
23 };
24
25 // Utility functions for the unescape actions.
26
27 inline bool utf8_append_utf32( std::string& string, const unsigned utf32 )
28 {
29 if( utf32 <= 0x7f ) {
30 string += char( utf32 & 0xff );
31 return true;
32 }
33 if( utf32 <= 0x7ff ) {
34 char tmp[] = { char( ( ( utf32 & 0x7c0 ) >> 6 ) | 0xc0 ),
35 char( ( ( utf32 & 0x03f ) ) | 0x80 ) };
36 string.append( tmp, sizeof( tmp ) );
37 return true;
38 }
39 if( utf32 <= 0xffff ) {
40 char tmp[] = { char( ( ( utf32 & 0xf000 ) >> 12 ) | 0xe0 ),
41 char( ( ( utf32 & 0x0fc0 ) >> 6 ) | 0x80 ),
42 char( ( ( utf32 & 0x003f ) ) | 0x80 ) };
43 string.append( tmp, sizeof( tmp ) );
44 return true;
45 }
46 if( utf32 <= 0x10ffff ) {
47 char tmp[] = { char( ( ( utf32 & 0x1c0000 ) >> 18 ) | 0xf0 ),
48 char( ( ( utf32 & 0x03f000 ) >> 12 ) | 0x80 ),
49 char( ( ( utf32 & 0x000fc0 ) >> 6 ) | 0x80 ),
50 char( ( ( utf32 & 0x00003f ) ) | 0x80 ) };
51 string.append( tmp, sizeof( tmp ) );
52 return true;
53 }
54 return false;
55 }
56
57 // This function MUST only be called for characters matching tao::TAOCPP_PEGTL_NAMESPACE::ascii::xdigit!
58 template< typename I >
59 I unhex_char( const char c )
60 {
61 switch( c ) {
62 case '0':
63 case '1':
64 case '2':
65 case '3':
66 case '4':
67 case '5':
68 case '6':
69 case '7':
70 case '8':
71 case '9':
72 return I( c - '0' );
73 case 'a':
74 case 'b':
75 case 'c':
76 case 'd':
77 case 'e':
78 case 'f':
79 return I( c - 'a' + 10 );
80 case 'A':
81 case 'B':
82 case 'C':
83 case 'D':
84 case 'E':
85 case 'F':
86 return I( c - 'A' + 10 );
87 }
88 throw std::runtime_error( "invalid character in unhex" ); // LCOV_EXCL_LINE
89 }
90
91 template< typename I >
92 I unhex_string( const char* begin, const char* const end )
93 {
94 I r = 0;
95 while( begin != end ) {
96 r <<= 4;
97 r += unhex_char< I >( *begin++ );
98 }
99 return r;
100 }
101
102 // Actions for common unescape situations.
103
104 struct append_all
105 {
106 template< typename Input, typename State >
107 static void apply( const Input& in, State& st )
108 {
109 st.unescaped.append( in.begin(), in.size() );
110 }
111 };
112
113 // This action MUST be called for a character matching T which MUST be tao::TAOCPP_PEGTL_NAMESPACE::one< ... >.
114 template< typename T, char... Rs >
115 struct unescape_c
116 {
117 template< typename Input, typename State >
118 static void apply( const Input& in, State& st )
119 {
120 assert( in.size() == 1 );
121 st.unescaped += apply_one( *in.begin(), static_cast< const T* >( nullptr ) );
122 }
123
124 template< char... Qs >
125 static char apply_one( const char c, const one< Qs... >* )
126 {
127 static_assert( sizeof...( Qs ) == sizeof...( Rs ), "size mismatch between escaped characters and their mappings" );
128 return apply_two( c, { Qs... }, { Rs... } );
129 }
130
131 static char apply_two( const char c, const std::initializer_list< char >& q, const std::initializer_list< char >& r )
132 {
133 for( std::size_t i = 0; i < q.size(); ++i ) {
134 if( *( q.begin() + i ) == c ) {
135 return *( r.begin() + i );
136 }
137 }
138 throw std::runtime_error( "invalid character in unescape" ); // LCOV_EXCL_LINE
139 }
140 };
141
142 // See src/example/pegtl/unescape.cpp for why the following two actions
143 // skip the first input character. They also MUST be called
144 // with non-empty matched inputs!
145
146 struct unescape_u
147 {
148 template< typename Input, typename State >
149 static void apply( const Input& in, State& st )
150 {
151 assert( !in.empty() ); // First character MUST be present, usually 'u' or 'U'.
152 if( !utf8_append_utf32( st.unescaped, unhex_string< unsigned >( in.begin() + 1, in.end() ) ) ) {
153 throw parse_error( "invalid escaped unicode code point", in );
154 }
155 }
156 };
157
158 struct unescape_x
159 {
160 template< typename Input, typename State >
161 static void apply( const Input& in, State& st )
162 {
163 assert( !in.empty() ); // First character MUST be present, usually 'x'.
164 st.unescaped += unhex_string< char >( in.begin() + 1, in.end() );
165 }
166 };
167
168 // The unescape_j action is similar to unescape_u, however unlike
169 // unescape_u it
170 // (a) assumes exactly 4 hexdigits per escape sequence,
171 // (b) accepts multiple consecutive escaped 16-bit values.
172 // When applied to more than one escape sequence, unescape_j
173 // translates UTF-16 surrogate pairs in the input into a single
174 // UTF-8 sequence in st.unescaped, as required for JSON by RFC 7159.
175
176 struct unescape_j
177 {
178 template< typename Input, typename State >
179 static void apply( const Input& in, State& st )
180 {
181 assert( ( ( in.size() + 1 ) % 6 ) == 0 ); // Expects multiple "\\u1234", starting with the first "u".
182 for( const char* b = in.begin() + 1; b < in.end(); b += 6 ) {
183 const auto c = unhex_string< unsigned >( b, b + 4 );
184 if( ( 0xd800 <= c ) && ( c <= 0xdbff ) && ( b + 6 < in.end() ) ) {
185 const auto d = unhex_string< unsigned >( b + 6, b + 10 );
186 if( ( 0xdc00 <= d ) && ( d <= 0xdfff ) ) {
187 b += 6;
188 utf8_append_utf32( st.unescaped, ( ( ( c & 0x03ff ) << 10 ) | ( d & 0x03ff ) ) + 0x10000 );
189 continue;
190 }
191 }
192 utf8_append_utf32( st.unescaped, c );
193 }
194 }
195 };
196
197 } // namespace unescape
198
199 } // namespace TAOCPP_PEGTL_NAMESPACE
200
201} // namespace tao
202
203#endif
diff --git a/MoonParser/pegtl/contrib/uri.hpp b/MoonParser/pegtl/contrib/uri.hpp
new file mode 100644
index 0000000..1401a7d
--- /dev/null
+++ b/MoonParser/pegtl/contrib/uri.hpp
@@ -0,0 +1,116 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_CONTRIB_URI_HPP
5#define TAOCPP_PEGTL_INCLUDE_CONTRIB_URI_HPP
6
7#include "../ascii.hpp"
8#include "../config.hpp"
9#include "../rules.hpp"
10#include "../utf8.hpp"
11
12#include "abnf.hpp"
13
14namespace tao
15{
16 namespace TAOCPP_PEGTL_NAMESPACE
17 {
18 namespace uri
19 {
20 // URI grammar according to RFC 3986.
21
22 // This grammar is a direct PEG translation of the original URI grammar.
23 // It should be considered experimental -- in case of any issues, in particular
24 // missing rules for attached actions, please contact the developers.
25
26 // Note that this grammar has multiple top-level rules.
27
28 using namespace abnf;
29
30 using dot = one< '.' >;
31 using colon = one< ':' >;
32
33 // clang-format off
34 struct dec_octet : sor< one< '0' >,
35 rep_min_max< 1, 2, DIGIT >,
36 seq< one< '1' >, DIGIT, DIGIT >,
37 seq< one< '2' >, range< '0', '4' >, DIGIT >,
38 seq< string< '2', '5' >, range< '0', '5' > > > {};
39
40 struct IPv4address : seq< dec_octet, dot, dec_octet, dot, dec_octet, dot, dec_octet > {};
41
42 struct h16 : rep_min_max< 1, 4, HEXDIG > {};
43 struct ls32 : sor< seq< h16, colon, h16 >, IPv4address > {};
44
45 struct dcolon : two< ':' > {};
46
47 struct IPv6address : sor< seq< rep< 6, h16, colon >, ls32 >,
48 seq< dcolon, rep< 5, h16, colon >, ls32 >,
49 seq< opt< h16 >, dcolon, rep< 4, h16, colon >, ls32 >,
50 seq< opt< h16, opt< colon, h16 > >, dcolon, rep< 3, h16, colon >, ls32 >,
51 seq< opt< h16, rep_opt< 2, colon, h16 > >, dcolon, rep< 2, h16, colon >, ls32 >,
52 seq< opt< h16, rep_opt< 3, colon, h16 > >, dcolon, h16, colon, ls32 >,
53 seq< opt< h16, rep_opt< 4, colon, h16 > >, dcolon, ls32 >,
54 seq< opt< h16, rep_opt< 5, colon, h16 > >, dcolon, h16 >,
55 seq< opt< h16, rep_opt< 6, colon, h16 > >, dcolon > > {};
56
57 struct gen_delims : one< ':', '/', '?', '#', '[', ']', '@' > {};
58 struct sub_delims : one< '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=' > {};
59
60 struct unreserved : sor< ALPHA, DIGIT, one< '-', '.', '_', '~' > > {};
61 struct reserved : sor< gen_delims, sub_delims > {};
62
63 struct IPvFuture : if_must< one< 'v' >, plus< HEXDIG >, dot, plus< sor< unreserved, sub_delims, colon > > > {};
64
65 struct IP_literal : if_must< one< '[' >, sor< IPvFuture, IPv6address >, one< ']' > > {};
66
67 struct pct_encoded : if_must< one< '%' >, HEXDIG, HEXDIG > {};
68 struct pchar : sor< unreserved, pct_encoded, sub_delims, one< ':', '@' > > {};
69
70 struct query : star< sor< pchar, one< '/', '?' > > > {};
71 struct fragment : star< sor< pchar, one< '/', '?' > > > {};
72
73 struct segment : star< pchar > {};
74 struct segment_nz : plus< pchar > {};
75 struct segment_nz_nc : plus< sor< unreserved, pct_encoded, sub_delims, one< '@' > > > {}; // non-zero-length segment without any colon ":"
76
77 struct path_abempty : star< one< '/' >, segment > {};
78 struct path_absolute : seq< one< '/' >, opt< segment_nz, star< one< '/' >, segment > > > {};
79 struct path_noscheme : seq< segment_nz_nc, star< one< '/' >, segment > > {};
80 struct path_rootless : seq< segment_nz, star< one< '/' >, segment > > {};
81 struct path_empty : success {};
82
83 struct path : sor< path_noscheme, // begins with a non-colon segment
84 path_rootless, // begins with a segment
85 path_absolute, // begins with "/" but not "//"
86 path_abempty > {}; // begins with "/" or is empty
87
88 struct reg_name : star< sor< unreserved, pct_encoded, sub_delims > > {};
89
90 struct port : star< DIGIT > {};
91 struct host : sor< IP_literal, IPv4address, reg_name > {};
92 struct userinfo : star< sor< unreserved, pct_encoded, sub_delims, colon > > {};
93 struct authority : seq< opt< userinfo, one< '@' > >, host, opt< colon, port > > {};
94
95 struct scheme : seq< ALPHA, star< sor< ALPHA, DIGIT, one< '+', '-', '.' > > > > {};
96
97 using dslash = two< '/' >;
98 using opt_query = opt< if_must< one< '?' >, query > >;
99 using opt_fragment = opt< if_must< one< '#' >, fragment > >;
100
101 struct hier_part : sor< if_must< dslash, authority, path_abempty >, path_rootless, path_absolute, path_empty > {};
102 struct relative_part : sor< if_must< dslash, authority, path_abempty >, path_noscheme, path_absolute, path_empty > {};
103 struct relative_ref : seq< relative_part, opt_query, opt_fragment > {};
104
105 struct URI : seq< scheme, one< ':' >, hier_part, opt_query, opt_fragment > {};
106 struct URI_reference : sor< URI, relative_ref > {};
107 struct absolute_URI : seq< scheme, one< ':' >, hier_part, opt_query > {};
108 // clang-format on
109
110 } // namespace uri
111
112 } // namespace TAOCPP_PEGTL_NAMESPACE
113
114} // namespace tao
115
116#endif
diff --git a/MoonParser/pegtl/cstream_input.hpp b/MoonParser/pegtl/cstream_input.hpp
new file mode 100644
index 0000000..ad520e3
--- /dev/null
+++ b/MoonParser/pegtl/cstream_input.hpp
@@ -0,0 +1,34 @@
1// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_CSTREAM_INPUT_HPP
5#define TAOCPP_PEGTL_INCLUDE_CSTREAM_INPUT_HPP
6
7#include <cstdio>
8
9#include "buffer_input.hpp"
10#include "config.hpp"
11#include "eol.hpp"
12
13#include "internal/cstream_reader.hpp"
14
15namespace tao
16{
17 namespace TAOCPP_PEGTL_NAMESPACE
18 {
19 template< typename Eol = eol::lf_crlf >
20 struct cstream_input
21 : buffer_input< internal::cstream_reader, Eol >
22 {
23 template< typename T >
24 cstream_input( std::FILE* in_stream, const std::size_t in_maximum, T&& in_source )
25 : buffer_input< internal::cstream_reader, Eol >( std::forward< T >( in_source ), in_maximum, in_stream )
26 {
27 }
28 };
29
30 } // namespace TAOCPP_PEGTL_NAMESPACE
31
32} // namespace tao
33
34#endif
diff --git a/MoonParser/pegtl/eol.hpp b/MoonParser/pegtl/eol.hpp
new file mode 100644
index 0000000..ca3e604
--- /dev/null
+++ b/MoonParser/pegtl/eol.hpp
@@ -0,0 +1,54 @@
1// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_EOL_HPP
5#define TAOCPP_PEGTL_INCLUDE_EOL_HPP
6
7#include <cstddef>
8#include <utility>
9
10#include "config.hpp"
11
12namespace tao
13{
14 namespace TAOCPP_PEGTL_NAMESPACE
15 {
16 using eol_pair = std::pair< bool, std::size_t >;
17
18 } // namespace TAOCPP_PEGTL_NAMESPACE
19
20} // namespace tao
21
22#include "internal/cr_crlf_eol.hpp"
23#include "internal/cr_eol.hpp"
24#include "internal/crlf_eol.hpp"
25#include "internal/lf_crlf_eol.hpp"
26#include "internal/lf_eol.hpp"
27
28#include "internal/eol.hpp"
29
30namespace tao
31{
32 namespace TAOCPP_PEGTL_NAMESPACE
33 {
34 inline namespace ascii
35 {
36 // this is both a rule and a pseudo-namespace for eol::cr, ...
37 struct eol : internal::eol
38 {
39 // clang-format off
40 struct cr : internal::cr_eol {};
41 struct cr_crlf : internal::cr_crlf_eol {};
42 struct crlf : internal::crlf_eol {};
43 struct lf : internal::lf_eol {};
44 struct lf_crlf : internal::lf_crlf_eol {};
45 // clang-format on
46 };
47
48 } // namespace ascii
49
50 } // namespace TAOCPP_PEGTL_NAMESPACE
51
52} // namespace tao
53
54#endif
diff --git a/MoonParser/pegtl/file_input.hpp b/MoonParser/pegtl/file_input.hpp
new file mode 100644
index 0000000..625d491
--- /dev/null
+++ b/MoonParser/pegtl/file_input.hpp
@@ -0,0 +1,37 @@
1// Copyright (c) 2015-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_FILE_INPUT_HPP
5#define TAOCPP_PEGTL_INCLUDE_FILE_INPUT_HPP
6
7#include "config.hpp"
8#include "eol.hpp"
9#include "tracking_mode.hpp"
10
11#if defined( __unix__ ) || ( defined( __APPLE__ ) && defined( __MACH__ ) )
12#include <unistd.h> // Required for _POSIX_MAPPED_FILES
13#endif
14
15#if defined( _POSIX_MAPPED_FILES )
16#include "mmap_input.hpp"
17#else
18#include "read_input.hpp"
19#endif
20
21namespace tao
22{
23 namespace TAOCPP_PEGTL_NAMESPACE
24 {
25#if defined( _POSIX_MAPPED_FILES )
26 template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf >
27 using file_input = mmap_input< P, Eol >;
28#else
29 template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf >
30 using file_input = read_input< P, Eol >;
31#endif
32
33 } // namespace TAOCPP_PEGTL_NAMESPACE
34
35} // namespace tao
36
37#endif
diff --git a/MoonParser/pegtl/input_error.hpp b/MoonParser/pegtl/input_error.hpp
new file mode 100644
index 0000000..605ce4d
--- /dev/null
+++ b/MoonParser/pegtl/input_error.hpp
@@ -0,0 +1,41 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INPUT_ERROR_HPP
5#define TAOCPP_PEGTL_INCLUDE_INPUT_ERROR_HPP
6
7#include <cerrno>
8#include <sstream>
9#include <stdexcept>
10
11#include "config.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 struct input_error
18 : std::runtime_error
19 {
20 input_error( const std::string& message, const int in_errorno )
21 : std::runtime_error( message ),
22 errorno( in_errorno )
23 {
24 }
25
26 int errorno;
27 };
28
29 } // namespace TAOCPP_PEGTL_NAMESPACE
30
31} // namespace tao
32
33#define TAOCPP_PEGTL_THROW_INPUT_ERROR( MESSAGE ) \
34 do { \
35 const int errorno = errno; \
36 std::ostringstream oss; \
37 oss << "pegtl: " << MESSAGE << " errno " << errorno; \
38 throw tao::TAOCPP_PEGTL_NAMESPACE::input_error( oss.str(), errorno ); \
39 } while( false )
40
41#endif
diff --git a/MoonParser/pegtl/internal/action.hpp b/MoonParser/pegtl/internal/action.hpp
new file mode 100644
index 0000000..933bffe
--- /dev/null
+++ b/MoonParser/pegtl/internal/action.hpp
@@ -0,0 +1,52 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_ACTION_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_ACTION_HPP
6
7#include "../config.hpp"
8
9#include "duseltronik.hpp"
10#include "seq.hpp"
11#include "skip_control.hpp"
12
13#include "../apply_mode.hpp"
14#include "../rewind_mode.hpp"
15
16#include "../analysis/generic.hpp"
17
18namespace tao
19{
20 namespace TAOCPP_PEGTL_NAMESPACE
21 {
22 namespace internal
23 {
24 template< template< typename... > class Action, typename... Rules >
25 struct action
26 {
27 using analyze_t = analysis::generic< analysis::rule_type::SEQ, Rules... >;
28
29 template< apply_mode A,
30 rewind_mode M,
31 template< typename... > class,
32 template< typename... > class Control,
33 typename Input,
34 typename... States >
35 static bool match( Input& in, States&&... st )
36 {
37 return duseltronik< seq< Rules... >, A, M, Action, Control >::match( in, st... );
38 }
39 };
40
41 template< template< typename... > class Action, typename... Rules >
42 struct skip_control< action< Action, Rules... > > : std::true_type
43 {
44 };
45
46 } // namespace internal
47
48 } // namespace TAOCPP_PEGTL_NAMESPACE
49
50} // namespace tao
51
52#endif
diff --git a/MoonParser/pegtl/internal/action_input.hpp b/MoonParser/pegtl/internal/action_input.hpp
new file mode 100644
index 0000000..db48950
--- /dev/null
+++ b/MoonParser/pegtl/internal/action_input.hpp
@@ -0,0 +1,108 @@
1// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_ACTION_INPUT_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_ACTION_INPUT_HPP
6
7#include <cstddef>
8#include <string>
9
10#include "iterator.hpp"
11
12#include "../config.hpp"
13#include "../position.hpp"
14
15namespace tao
16{
17 namespace TAOCPP_PEGTL_NAMESPACE
18 {
19 namespace internal
20 {
21 inline const char* begin_c_ptr( const char* p ) noexcept
22 {
23 return p;
24 }
25
26 inline const char* begin_c_ptr( const iterator& it ) noexcept
27 {
28 return it.data;
29 }
30
31 template< typename Input >
32 class action_input
33 {
34 public:
35 using input_t = Input;
36 using iterator_t = typename Input::iterator_t;
37
38 action_input( const iterator_t& in_begin, const Input& in_input ) noexcept
39 : m_begin( in_begin ),
40 m_input( in_input )
41 {
42 }
43
44 action_input( const action_input& ) = delete;
45 action_input& operator=( const action_input& ) = delete;
46
47 const iterator_t& iterator() const noexcept
48 {
49 return m_begin;
50 }
51
52 const Input& input() const noexcept
53 {
54 return m_input;
55 }
56
57 const char* begin() const noexcept
58 {
59 return begin_c_ptr( iterator() );
60 }
61
62 const char* end() const noexcept
63 {
64 return input().current();
65 }
66
67 bool empty() const noexcept
68 {
69 return begin() == end();
70 }
71
72 std::size_t size() const noexcept
73 {
74 return std::size_t( end() - begin() );
75 }
76
77 std::string string() const
78 {
79 return std::string( begin(), end() );
80 }
81
82 char peek_char( const std::size_t offset = 0 ) const noexcept
83 {
84 return begin()[ offset ];
85 }
86
87 unsigned char peek_byte( const std::size_t offset = 0 ) const noexcept
88 {
89 return static_cast< unsigned char >( peek_char( offset ) );
90 }
91
92 TAOCPP_PEGTL_NAMESPACE::position position() const noexcept
93 {
94 return input().position( iterator() ); // NOTE: Not efficient with LAZY inputs.
95 }
96
97 protected:
98 const iterator_t m_begin;
99 const Input& m_input;
100 };
101
102 } // namespace internal
103
104 } // namespace TAOCPP_PEGTL_NAMESPACE
105
106} // namespace tao
107
108#endif
diff --git a/MoonParser/pegtl/internal/alnum.hpp b/MoonParser/pegtl/internal/alnum.hpp
new file mode 100644
index 0000000..cdad330
--- /dev/null
+++ b/MoonParser/pegtl/internal/alnum.hpp
@@ -0,0 +1,26 @@
1// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_ALNUM_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_ALNUM_HPP
6
7#include "../config.hpp"
8
9#include "peek_char.hpp"
10#include "ranges.hpp"
11
12namespace tao
13{
14 namespace TAOCPP_PEGTL_NAMESPACE
15 {
16 namespace internal
17 {
18 using alnum = ranges< peek_char, 'a', 'z', 'A', 'Z', '0', '9' >;
19
20 } // namespace internal
21
22 } // namespace TAOCPP_PEGTL_NAMESPACE
23
24} // namespace tao
25
26#endif
diff --git a/MoonParser/pegtl/internal/alpha.hpp b/MoonParser/pegtl/internal/alpha.hpp
new file mode 100644
index 0000000..d696ca2
--- /dev/null
+++ b/MoonParser/pegtl/internal/alpha.hpp
@@ -0,0 +1,26 @@
1// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_ALPHA_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_ALPHA_HPP
6
7#include "../config.hpp"
8
9#include "peek_char.hpp"
10#include "ranges.hpp"
11
12namespace tao
13{
14 namespace TAOCPP_PEGTL_NAMESPACE
15 {
16 namespace internal
17 {
18 using alpha = ranges< peek_char, 'a', 'z', 'A', 'Z' >;
19
20 } // namespace internal
21
22 } // namespace TAOCPP_PEGTL_NAMESPACE
23
24} // namespace tao
25
26#endif
diff --git a/MoonParser/pegtl/internal/any.hpp b/MoonParser/pegtl/internal/any.hpp
new file mode 100644
index 0000000..aebe239
--- /dev/null
+++ b/MoonParser/pegtl/internal/any.hpp
@@ -0,0 +1,68 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_ANY_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_ANY_HPP
6
7#include "../config.hpp"
8
9#include "peek_char.hpp"
10#include "skip_control.hpp"
11
12#include "../analysis/generic.hpp"
13
14namespace tao
15{
16 namespace TAOCPP_PEGTL_NAMESPACE
17 {
18 namespace internal
19 {
20 template< typename Peek >
21 struct any;
22
23 template<>
24 struct any< peek_char >
25 {
26 using analyze_t = analysis::generic< analysis::rule_type::ANY >;
27
28 template< typename Input >
29 static bool match( Input& in )
30 {
31 if( !in.empty() ) {
32 in.bump();
33 return true;
34 }
35 return false;
36 }
37 };
38
39 template< typename Peek >
40 struct any
41 {
42 using analyze_t = analysis::generic< analysis::rule_type::ANY >;
43
44 template< typename Input >
45 static bool match( Input& in )
46 {
47 if( !in.empty() ) {
48 if( const auto t = Peek::peek( in ) ) {
49 in.bump( t.size );
50 return true;
51 }
52 }
53 return false;
54 }
55 };
56
57 template< typename Peek >
58 struct skip_control< any< Peek > > : std::true_type
59 {
60 };
61
62 } // namespace internal
63
64 } // namespace TAOCPP_PEGTL_NAMESPACE
65
66} // namespace tao
67
68#endif
diff --git a/MoonParser/pegtl/internal/apply.hpp b/MoonParser/pegtl/internal/apply.hpp
new file mode 100644
index 0000000..4e70255
--- /dev/null
+++ b/MoonParser/pegtl/internal/apply.hpp
@@ -0,0 +1,79 @@
1// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_APPLY_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_APPLY_HPP
6
7#include "../config.hpp"
8
9#include "skip_control.hpp"
10#include "trivial.hpp"
11
12#include "../analysis/counted.hpp"
13
14namespace tao
15{
16 namespace TAOCPP_PEGTL_NAMESPACE
17 {
18 namespace internal
19 {
20 template< apply_mode A, typename... Actions >
21 struct apply_impl;
22
23 template< typename... Actions >
24 struct apply_impl< apply_mode::ACTION, Actions... >
25 {
26 template< typename Input, typename... States >
27 static bool match( Input& in, States&&... st )
28 {
29 using action_t = typename Input::action_t;
30 const action_t i2( in.iterator(), in ); // No data -- range is from begin to begin.
31#ifdef __cpp_fold_expressions
32 ( Actions::apply( i2, st... ), ... );
33#else
34 using swallow = bool[];
35 (void)swallow{ ( Actions::apply( i2, st... ), true )..., true };
36#endif
37 return true;
38 }
39 };
40
41 template< typename... Actions >
42 struct apply_impl< apply_mode::NOTHING, Actions... >
43 {
44 template< typename Input, typename... States >
45 static bool match( Input&, States&&... )
46 {
47 return true;
48 }
49 };
50
51 template< typename... Actions >
52 struct apply
53 {
54 using analyze_t = analysis::counted< analysis::rule_type::ANY, 0 >;
55
56 template< apply_mode A,
57 rewind_mode M,
58 template< typename... > class Action,
59 template< typename... > class Control,
60 typename Input,
61 typename... States >
62 static bool match( Input& in, States&&... st )
63 {
64 return apply_impl< A, Actions... >::match( in, st... );
65 }
66 };
67
68 template< typename... Actions >
69 struct skip_control< apply< Actions... > > : std::true_type
70 {
71 };
72
73 } // namespace internal
74
75 } // namespace TAOCPP_PEGTL_NAMESPACE
76
77} // namespace tao
78
79#endif
diff --git a/MoonParser/pegtl/internal/apply0.hpp b/MoonParser/pegtl/internal/apply0.hpp
new file mode 100644
index 0000000..c8aa7aa
--- /dev/null
+++ b/MoonParser/pegtl/internal/apply0.hpp
@@ -0,0 +1,77 @@
1// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_APPLY0_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_APPLY0_HPP
6
7#include "../config.hpp"
8
9#include "skip_control.hpp"
10#include "trivial.hpp"
11
12#include "../analysis/counted.hpp"
13
14namespace tao
15{
16 namespace TAOCPP_PEGTL_NAMESPACE
17 {
18 namespace internal
19 {
20 template< apply_mode A, typename... Actions >
21 struct apply0_impl;
22
23 template< typename... Actions >
24 struct apply0_impl< apply_mode::ACTION, Actions... >
25 {
26 template< typename... States >
27 static bool match( States&&... st )
28 {
29#ifdef __cpp_fold_expressions
30 ( Actions::apply0( st... ), ... );
31#else
32 using swallow = bool[];
33 (void)swallow{ ( Actions::apply0( st... ), true )..., true };
34#endif
35 return true;
36 }
37 };
38
39 template< typename... Actions >
40 struct apply0_impl< apply_mode::NOTHING, Actions... >
41 {
42 template< typename... States >
43 static bool match( States&&... )
44 {
45 return true;
46 }
47 };
48
49 template< typename... Actions >
50 struct apply0
51 {
52 using analyze_t = analysis::counted< analysis::rule_type::ANY, 0 >;
53
54 template< apply_mode A,
55 rewind_mode M,
56 template< typename... > class Action,
57 template< typename... > class Control,
58 typename Input,
59 typename... States >
60 static bool match( Input&, States&&... st )
61 {
62 return apply0_impl< A, Actions... >::match( st... );
63 }
64 };
65
66 template< typename... Actions >
67 struct skip_control< apply0< Actions... > > : std::true_type
68 {
69 };
70
71 } // namespace internal
72
73 } // namespace TAOCPP_PEGTL_NAMESPACE
74
75} // namespace tao
76
77#endif
diff --git a/MoonParser/pegtl/internal/at.hpp b/MoonParser/pegtl/internal/at.hpp
new file mode 100644
index 0000000..d5bb455
--- /dev/null
+++ b/MoonParser/pegtl/internal/at.hpp
@@ -0,0 +1,62 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_AT_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_AT_HPP
6
7#include "../config.hpp"
8
9#include "rule_conjunction.hpp"
10#include "skip_control.hpp"
11#include "trivial.hpp"
12
13#include "../apply_mode.hpp"
14#include "../rewind_mode.hpp"
15
16#include "../analysis/generic.hpp"
17
18namespace tao
19{
20 namespace TAOCPP_PEGTL_NAMESPACE
21 {
22 namespace internal
23 {
24 template< typename... Rules >
25 struct at;
26
27 template<>
28 struct at<>
29 : trivial< true >
30 {
31 };
32
33 template< typename... Rules >
34 struct at
35 {
36 using analyze_t = analysis::generic< analysis::rule_type::OPT, Rules... >;
37
38 template< apply_mode,
39 rewind_mode,
40 template< typename... > class Action,
41 template< typename... > class Control,
42 typename Input,
43 typename... States >
44 static bool match( Input& in, States&&... st )
45 {
46 const auto m = in.template mark< rewind_mode::REQUIRED >();
47 return rule_conjunction< Rules... >::template match< apply_mode::NOTHING, rewind_mode::ACTIVE, Action, Control >( in, st... );
48 }
49 };
50
51 template< typename... Rules >
52 struct skip_control< at< Rules... > > : std::true_type
53 {
54 };
55
56 } // namespace internal
57
58 } // namespace TAOCPP_PEGTL_NAMESPACE
59
60} // namespace tao
61
62#endif
diff --git a/MoonParser/pegtl/internal/bof.hpp b/MoonParser/pegtl/internal/bof.hpp
new file mode 100644
index 0000000..8a1dde7
--- /dev/null
+++ b/MoonParser/pegtl/internal/bof.hpp
@@ -0,0 +1,41 @@
1// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_BOF_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_BOF_HPP
6
7#include "../config.hpp"
8
9#include "skip_control.hpp"
10
11#include "../analysis/generic.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 namespace internal
18 {
19 struct bof
20 {
21 using analyze_t = analysis::generic< analysis::rule_type::OPT >;
22
23 template< typename Input >
24 static bool match( Input& in ) noexcept
25 {
26 return in.byte() == 0;
27 }
28 };
29
30 template<>
31 struct skip_control< bof > : std::true_type
32 {
33 };
34
35 } // namespace internal
36
37 } // namespace TAOCPP_PEGTL_NAMESPACE
38
39} // namespace tao
40
41#endif
diff --git a/MoonParser/pegtl/internal/bol.hpp b/MoonParser/pegtl/internal/bol.hpp
new file mode 100644
index 0000000..bf3e33f
--- /dev/null
+++ b/MoonParser/pegtl/internal/bol.hpp
@@ -0,0 +1,41 @@
1// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_BOL_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_BOL_HPP
6
7#include "../config.hpp"
8
9#include "skip_control.hpp"
10
11#include "../analysis/generic.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 namespace internal
18 {
19 struct bol
20 {
21 using analyze_t = analysis::generic< analysis::rule_type::OPT >;
22
23 template< typename Input >
24 static bool match( Input& in ) noexcept
25 {
26 return in.byte_in_line() == 0;
27 }
28 };
29
30 template<>
31 struct skip_control< bol > : std::true_type
32 {
33 };
34
35 } // namespace internal
36
37 } // namespace TAOCPP_PEGTL_NAMESPACE
38
39} // namespace tao
40
41#endif
diff --git a/MoonParser/pegtl/internal/bump_help.hpp b/MoonParser/pegtl/internal/bump_help.hpp
new file mode 100644
index 0000000..577870e
--- /dev/null
+++ b/MoonParser/pegtl/internal/bump_help.hpp
@@ -0,0 +1,64 @@
1// Copyright (c) 2015-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_BUMP_UTIL_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_BUMP_UTIL_HPP
6
7#include <cstddef>
8#include <type_traits>
9
10#include "../config.hpp"
11
12#include "result_on_found.hpp"
13
14namespace tao
15{
16 namespace TAOCPP_PEGTL_NAMESPACE
17 {
18 namespace internal
19 {
20 template< bool >
21 struct bump_impl;
22
23 template<>
24 struct bump_impl< true >
25 {
26 template< typename Input >
27 static void bump( Input& in, const std::size_t count ) noexcept
28 {
29 in.bump( count );
30 }
31 };
32
33 template<>
34 struct bump_impl< false >
35 {
36 template< typename Input >
37 static void bump( Input& in, const std::size_t count ) noexcept
38 {
39 in.bump_in_this_line( count );
40 }
41 };
42
43 template< bool... >
44 struct bool_list
45 {
46 };
47
48 template< bool... Bs >
49 using bool_and = std::is_same< bool_list< Bs..., true >, bool_list< true, Bs... > >;
50
51 template< result_on_found R, typename Input, typename Char, Char... Cs >
52 void bump_help( Input& in, const std::size_t count ) noexcept
53 {
54 using eol_t = typename Input::eol_t;
55 bump_impl< bool_and< ( Cs != eol_t::ch )... >::value != bool( R ) >::bump( in, count );
56 }
57
58 } // namespace internal
59
60 } // namespace TAOCPP_PEGTL_NAMESPACE
61
62} // namespace tao
63
64#endif
diff --git a/MoonParser/pegtl/internal/bump_impl.hpp b/MoonParser/pegtl/internal/bump_impl.hpp
new file mode 100644
index 0000000..6ab9005
--- /dev/null
+++ b/MoonParser/pegtl/internal/bump_impl.hpp
@@ -0,0 +1,53 @@
1// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_BUMP_IMPL_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_BUMP_IMPL_HPP
6
7#include "../config.hpp"
8
9#include "iterator.hpp"
10
11namespace tao
12{
13 namespace TAOCPP_PEGTL_NAMESPACE
14 {
15 namespace internal
16 {
17 inline void bump( iterator& iter, const std::size_t count, const int ch ) noexcept
18 {
19 for( std::size_t i = 0; i < count; ++i ) {
20 if( iter.data[ i ] == ch ) {
21 ++iter.line;
22 iter.byte_in_line = 0;
23 }
24 else {
25 ++iter.byte_in_line;
26 }
27 }
28 iter.byte += count;
29 iter.data += count;
30 }
31
32 inline void bump_in_this_line( iterator& iter, const std::size_t count ) noexcept
33 {
34 iter.data += count;
35 iter.byte += count;
36 iter.byte_in_line += count;
37 }
38
39 inline void bump_to_next_line( iterator& iter, const std::size_t count ) noexcept
40 {
41 ++iter.line;
42 iter.byte += count;
43 iter.byte_in_line = 0;
44 iter.data += count;
45 }
46
47 } // namespace internal
48
49 } // namespace TAOCPP_PEGTL_NAMESPACE
50
51} // namespace tao
52
53#endif
diff --git a/MoonParser/pegtl/internal/bytes.hpp b/MoonParser/pegtl/internal/bytes.hpp
new file mode 100644
index 0000000..c180a68
--- /dev/null
+++ b/MoonParser/pegtl/internal/bytes.hpp
@@ -0,0 +1,46 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_BYTES_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_BYTES_HPP
6
7#include "../config.hpp"
8
9#include "skip_control.hpp"
10
11#include "../analysis/counted.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 namespace internal
18 {
19 template< unsigned Num >
20 struct bytes
21 {
22 using analyze_t = analysis::counted< analysis::rule_type::ANY, Num >;
23
24 template< typename Input >
25 static bool match( Input& in )
26 {
27 if( in.size( Num ) >= Num ) {
28 in.bump( Num );
29 return true;
30 }
31 return false;
32 }
33 };
34
35 template< unsigned Num >
36 struct skip_control< bytes< Num > > : std::true_type
37 {
38 };
39
40 } // namespace internal
41
42 } // namespace TAOCPP_PEGTL_NAMESPACE
43
44} // namespace tao
45
46#endif
diff --git a/MoonParser/pegtl/internal/control.hpp b/MoonParser/pegtl/internal/control.hpp
new file mode 100644
index 0000000..16fab5c
--- /dev/null
+++ b/MoonParser/pegtl/internal/control.hpp
@@ -0,0 +1,52 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_CONTROL_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_CONTROL_HPP
6
7#include "../config.hpp"
8
9#include "duseltronik.hpp"
10#include "seq.hpp"
11#include "skip_control.hpp"
12
13#include "../apply_mode.hpp"
14#include "../rewind_mode.hpp"
15
16#include "../analysis/generic.hpp"
17
18namespace tao
19{
20 namespace TAOCPP_PEGTL_NAMESPACE
21 {
22 namespace internal
23 {
24 template< template< typename... > class Control, typename... Rules >
25 struct control
26 {
27 using analyze_t = analysis::generic< analysis::rule_type::SEQ, Rules... >;
28
29 template< apply_mode A,
30 rewind_mode M,
31 template< typename... > class Action,
32 template< typename... > class,
33 typename Input,
34 typename... States >
35 static bool match( Input& in, States&&... st )
36 {
37 return duseltronik< seq< Rules... >, A, M, Action, Control >::match( in, st... );
38 }
39 };
40
41 template< template< typename... > class Control, typename... Rules >
42 struct skip_control< control< Control, Rules... > > : std::true_type
43 {
44 };
45
46 } // namespace internal
47
48 } // namespace TAOCPP_PEGTL_NAMESPACE
49
50} // namespace tao
51
52#endif
diff --git a/MoonParser/pegtl/internal/cr_crlf_eol.hpp b/MoonParser/pegtl/internal/cr_crlf_eol.hpp
new file mode 100644
index 0000000..ebfc75d
--- /dev/null
+++ b/MoonParser/pegtl/internal/cr_crlf_eol.hpp
@@ -0,0 +1,39 @@
1// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_CR_CRLF_EOL_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_CR_CRLF_EOL_HPP
6
7#include "../config.hpp"
8
9namespace tao
10{
11 namespace TAOCPP_PEGTL_NAMESPACE
12 {
13 namespace internal
14 {
15 struct cr_crlf_eol
16 {
17 static constexpr int ch = '\r';
18
19 template< typename Input >
20 static eol_pair match( Input& in )
21 {
22 eol_pair p = { false, in.size( 2 ) };
23 if( p.second ) {
24 if( in.peek_char() == '\r' ) {
25 in.bump_to_next_line( 1 + ( ( p.second > 1 ) && ( in.peek_char( 1 ) == '\n' ) ) );
26 p.first = true;
27 }
28 }
29 return p;
30 }
31 };
32
33 } // namespace internal
34
35 } // namespace TAOCPP_PEGTL_NAMESPACE
36
37} // namespace tao
38
39#endif
diff --git a/MoonParser/pegtl/internal/cr_eol.hpp b/MoonParser/pegtl/internal/cr_eol.hpp
new file mode 100644
index 0000000..79388eb
--- /dev/null
+++ b/MoonParser/pegtl/internal/cr_eol.hpp
@@ -0,0 +1,39 @@
1// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_CR_EOL_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_CR_EOL_HPP
6
7#include "../config.hpp"
8
9namespace tao
10{
11 namespace TAOCPP_PEGTL_NAMESPACE
12 {
13 namespace internal
14 {
15 struct cr_eol
16 {
17 static constexpr int ch = '\r';
18
19 template< typename Input >
20 static eol_pair match( Input& in )
21 {
22 eol_pair p = { false, in.size( 1 ) };
23 if( p.second ) {
24 if( in.peek_char() == '\r' ) {
25 in.bump_to_next_line();
26 p.first = true;
27 }
28 }
29 return p;
30 }
31 };
32
33 } // namespace internal
34
35 } // namespace TAOCPP_PEGTL_NAMESPACE
36
37} // namespace tao
38
39#endif
diff --git a/MoonParser/pegtl/internal/crlf_eol.hpp b/MoonParser/pegtl/internal/crlf_eol.hpp
new file mode 100644
index 0000000..621b6b3
--- /dev/null
+++ b/MoonParser/pegtl/internal/crlf_eol.hpp
@@ -0,0 +1,39 @@
1// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_CRLF_EOL_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_CRLF_EOL_HPP
6
7#include "../config.hpp"
8
9namespace tao
10{
11 namespace TAOCPP_PEGTL_NAMESPACE
12 {
13 namespace internal
14 {
15 struct crlf_eol
16 {
17 static constexpr int ch = '\n';
18
19 template< typename Input >
20 static eol_pair match( Input& in )
21 {
22 eol_pair p = { false, in.size( 2 ) };
23 if( p.second > 1 ) {
24 if( ( in.peek_char() == '\r' ) && ( in.peek_char( 1 ) == '\n' ) ) {
25 in.bump_to_next_line( 2 );
26 p.first = true;
27 }
28 }
29 return p;
30 }
31 };
32
33 } // namespace internal
34
35 } // namespace TAOCPP_PEGTL_NAMESPACE
36
37} // namespace tao
38
39#endif
diff --git a/MoonParser/pegtl/internal/cstream_reader.hpp b/MoonParser/pegtl/internal/cstream_reader.hpp
new file mode 100644
index 0000000..c1670bf
--- /dev/null
+++ b/MoonParser/pegtl/internal/cstream_reader.hpp
@@ -0,0 +1,48 @@
1// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_CSTREAM_READER_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_CSTREAM_READER_HPP
6
7#include <cstddef>
8#include <cstdio>
9
10#include "../config.hpp"
11#include "../input_error.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 namespace internal
18 {
19 struct cstream_reader
20 {
21 explicit cstream_reader( std::FILE* s ) noexcept
22 : m_cstream( s )
23 {
24 }
25
26 std::size_t operator()( char* buffer, const std::size_t length )
27 {
28 if( const auto r = std::fread( buffer, 1, length, m_cstream ) ) {
29 return r;
30 }
31 if( std::feof( m_cstream ) != 0 ) {
32 return 0;
33 }
34 // Please contact us if you know how to provoke the following exception.
35 // The example on cppreference.com doesn't work, at least not on macOS.
36 TAOCPP_PEGTL_THROW_INPUT_ERROR( "error in fread() from cstream" ); // LCOV_EXCL_LINE
37 }
38
39 std::FILE* m_cstream;
40 };
41
42 } // namespace internal
43
44 } // namespace TAOCPP_PEGTL_NAMESPACE
45
46} // namespace tao
47
48#endif
diff --git a/MoonParser/pegtl/internal/cstring_reader.hpp b/MoonParser/pegtl/internal/cstring_reader.hpp
new file mode 100644
index 0000000..ff8c11e
--- /dev/null
+++ b/MoonParser/pegtl/internal/cstring_reader.hpp
@@ -0,0 +1,49 @@
1// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_CSTRING_READER_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_CSTRING_READER_HPP
6
7#include <cassert>
8#include <cstddef>
9
10#include "../config.hpp"
11#include "../input_error.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 namespace internal
18 {
19 struct cstring_reader
20 {
21 explicit cstring_reader( const char* zero_terminated ) noexcept
22 : m_cstring( zero_terminated )
23 {
24 assert( m_cstring );
25 }
26
27 std::size_t operator()( char* buffer, const std::size_t length ) noexcept
28 {
29 std::size_t i = 0;
30 char c;
31
32 while( ( i < length ) && ( ( c = m_cstring[ i ] ) != 0 ) ) {
33 *buffer++ = c;
34 ++i;
35 }
36 m_cstring += i;
37 return i;
38 }
39
40 const char* m_cstring;
41 };
42
43 } // namespace internal
44
45 } // namespace TAOCPP_PEGTL_NAMESPACE
46
47} // namespace tao
48
49#endif
diff --git a/MoonParser/pegtl/internal/demangle.hpp b/MoonParser/pegtl/internal/demangle.hpp
new file mode 100644
index 0000000..64efe6f
--- /dev/null
+++ b/MoonParser/pegtl/internal/demangle.hpp
@@ -0,0 +1,44 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_DEMANGLE_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_DEMANGLE_HPP
6
7#include <string>
8#include <typeinfo>
9
10#include "../config.hpp"
11
12#if defined( __GLIBCXX__ )
13#include "demangle_cxxabi.hpp"
14#elif defined( __has_include )
15// clang-format off
16#if __has_include( <cxxabi.h> )
17// clang-format on
18#include "demangle_cxxabi.hpp"
19#else
20#include "demangle_nop.hpp"
21#endif
22#else
23#include "demangle_nop.hpp"
24#endif
25
26namespace tao
27{
28 namespace TAOCPP_PEGTL_NAMESPACE
29 {
30 namespace internal
31 {
32 template< typename T >
33 std::string demangle()
34 {
35 return demangle( typeid( T ).name() );
36 }
37
38 } // namespace internal
39
40 } // namespace TAOCPP_PEGTL_NAMESPACE
41
42} // namespace tao
43
44#endif
diff --git a/MoonParser/pegtl/internal/demangle_cxxabi.hpp b/MoonParser/pegtl/internal/demangle_cxxabi.hpp
new file mode 100644
index 0000000..aba72f9
--- /dev/null
+++ b/MoonParser/pegtl/internal/demangle_cxxabi.hpp
@@ -0,0 +1,41 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_DEMANGLE_CXXABI_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_DEMANGLE_CXXABI_HPP
6
7#include <cstdlib>
8#include <cxxabi.h>
9#include <memory>
10#include <string>
11
12#include "../config.hpp"
13
14#include "demangle_sanitise.hpp"
15
16namespace tao
17{
18 namespace TAOCPP_PEGTL_NAMESPACE
19 {
20 namespace internal
21 {
22 inline std::string demangle( const char* symbol )
23 {
24 const std::unique_ptr< char, decltype( &std::free ) > demangled( abi::__cxa_demangle( symbol, nullptr, nullptr, nullptr ), &std::free );
25 if( !demangled ) {
26 return symbol;
27 }
28 std::string result( demangled.get() );
29#ifdef TAOCPP_PEGTL_PRETTY_DEMANGLE
30 demangle_sanitise_chars( result );
31#endif
32 return result;
33 }
34
35 } // namespace internal
36
37 } // namespace TAOCPP_PEGTL_NAMESPACE
38
39} // namespace tao
40
41#endif
diff --git a/MoonParser/pegtl/internal/demangle_nop.hpp b/MoonParser/pegtl/internal/demangle_nop.hpp
new file mode 100644
index 0000000..70bf3ec
--- /dev/null
+++ b/MoonParser/pegtl/internal/demangle_nop.hpp
@@ -0,0 +1,28 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_DEMANGLE_NOP_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_DEMANGLE_NOP_HPP
6
7#include <string>
8
9#include "../config.hpp"
10
11namespace tao
12{
13 namespace TAOCPP_PEGTL_NAMESPACE
14 {
15 namespace internal
16 {
17 inline std::string demangle( const char* symbol )
18 {
19 return symbol;
20 }
21
22 } // namespace internal
23
24 } // namespace TAOCPP_PEGTL_NAMESPACE
25
26} // namespace tao
27
28#endif
diff --git a/MoonParser/pegtl/internal/demangle_sanitise.hpp b/MoonParser/pegtl/internal/demangle_sanitise.hpp
new file mode 100644
index 0000000..f869ea6
--- /dev/null
+++ b/MoonParser/pegtl/internal/demangle_sanitise.hpp
@@ -0,0 +1,48 @@
1// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_DEMANGLE_SANITISE_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_DEMANGLE_SANITISE_HPP
6
7#include <string>
8
9#include "../config.hpp"
10
11namespace tao
12{
13 namespace TAOCPP_PEGTL_NAMESPACE
14 {
15 namespace internal
16 {
17 inline void demangle_sanitise_chars( std::string& s )
18 {
19 std::string::size_type p;
20 while( ( p = s.find( "(char)" ) ) != std::string::npos ) {
21 int c = 0;
22 std::string::size_type q;
23 for( q = p + 6; ( q < s.size() ) && ( s[ q ] >= '0' ) && ( s[ q ] <= '9' ); ++q ) {
24 c *= 10;
25 c += s[ q ] - '0';
26 }
27 if( c == '\'' ) {
28 s.replace( p, q - p, "'\\''" );
29 }
30 else if( c == '\\' ) {
31 s.replace( p, q - p, "'\\\\'" );
32 }
33 else if( ( c < 32 ) || ( c > 126 ) ) {
34 s.replace( p, 6, std::string() );
35 }
36 else {
37 s.replace( p, q - p, std::string( 1, '\'' ) + char( c ) + '\'' );
38 }
39 }
40 }
41
42 } // namespace internal
43
44 } // namespace TAOCPP_PEGTL_NAMESPACE
45
46} // namespace tao
47
48#endif
diff --git a/MoonParser/pegtl/internal/disable.hpp b/MoonParser/pegtl/internal/disable.hpp
new file mode 100644
index 0000000..19ccb1e
--- /dev/null
+++ b/MoonParser/pegtl/internal/disable.hpp
@@ -0,0 +1,52 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_DISABLE_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_DISABLE_HPP
6
7#include "../config.hpp"
8
9#include "duseltronik.hpp"
10#include "seq.hpp"
11#include "skip_control.hpp"
12
13#include "../apply_mode.hpp"
14#include "../rewind_mode.hpp"
15
16#include "../analysis/generic.hpp"
17
18namespace tao
19{
20 namespace TAOCPP_PEGTL_NAMESPACE
21 {
22 namespace internal
23 {
24 template< typename... Rules >
25 struct disable
26 {
27 using analyze_t = analysis::generic< analysis::rule_type::SEQ, Rules... >;
28
29 template< apply_mode,
30 rewind_mode M,
31 template< typename... > class Action,
32 template< typename... > class Control,
33 typename Input,
34 typename... States >
35 static bool match( Input& in, States&&... st )
36 {
37 return duseltronik< seq< Rules... >, apply_mode::NOTHING, M, Action, Control >::match( in, st... );
38 }
39 };
40
41 template< typename... Rules >
42 struct skip_control< disable< Rules... > > : std::true_type
43 {
44 };
45
46 } // namespace internal
47
48 } // namespace TAOCPP_PEGTL_NAMESPACE
49
50} // namespace tao
51
52#endif
diff --git a/MoonParser/pegtl/internal/discard.hpp b/MoonParser/pegtl/internal/discard.hpp
new file mode 100644
index 0000000..9aac60f
--- /dev/null
+++ b/MoonParser/pegtl/internal/discard.hpp
@@ -0,0 +1,42 @@
1// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_DISCARD_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_DISCARD_HPP
6
7#include "../config.hpp"
8
9#include "skip_control.hpp"
10
11#include "../analysis/generic.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 namespace internal
18 {
19 struct discard
20 {
21 using analyze_t = analysis::generic< analysis::rule_type::OPT >;
22
23 template< typename Input >
24 static bool match( Input& in )
25 {
26 in.discard();
27 return true;
28 }
29 };
30
31 template<>
32 struct skip_control< discard > : std::true_type
33 {
34 };
35
36 } // namespace internal
37
38 } // namespace TAOCPP_PEGTL_NAMESPACE
39
40} // namespace tao
41
42#endif
diff --git a/MoonParser/pegtl/internal/dusel_mode.hpp b/MoonParser/pegtl/internal/dusel_mode.hpp
new file mode 100644
index 0000000..df757aa
--- /dev/null
+++ b/MoonParser/pegtl/internal/dusel_mode.hpp
@@ -0,0 +1,25 @@
1// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_DUSEL_MODE_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_DUSEL_MODE_HPP
6
7#include "../config.hpp"
8
9namespace tao
10{
11 namespace TAOCPP_PEGTL_NAMESPACE
12 {
13 enum class dusel_mode : char
14 {
15 NOTHING = 0,
16 CONTROL = 1,
17 CONTROL_AND_APPLY = 2,
18 CONTROL_AND_APPLY0 = 3
19 };
20
21 } // namespace TAOCPP_PEGTL_NAMESPACE
22
23} // namespace tao
24
25#endif
diff --git a/MoonParser/pegtl/internal/duseltronik.hpp b/MoonParser/pegtl/internal/duseltronik.hpp
new file mode 100644
index 0000000..23a6e1f
--- /dev/null
+++ b/MoonParser/pegtl/internal/duseltronik.hpp
@@ -0,0 +1,114 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_DUSELTRONIK_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_DUSELTRONIK_HPP
6
7#include "../apply_mode.hpp"
8#include "../config.hpp"
9#include "../rewind_mode.hpp"
10
11#include "dusel_mode.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 namespace internal
18 {
19 template< typename Rule,
20 apply_mode A,
21 rewind_mode M,
22 template< typename... > class Action,
23 template< typename... > class Control,
24 dusel_mode = dusel_mode::NOTHING >
25 struct duseltronik;
26
27 template< typename Rule,
28 apply_mode A,
29 rewind_mode M,
30 template< typename... > class Action,
31 template< typename... > class Control >
32 struct duseltronik< Rule, A, M, Action, Control, dusel_mode::NOTHING >
33 {
34 template< typename Input, typename... States >
35 static auto match( Input& in, States&&... st ) -> decltype( Rule::template match< A, M, Action, Control >( in, st... ), true )
36 {
37 return Rule::template match< A, M, Action, Control >( in, st... );
38 }
39
40 // NOTE: The additional "int = 0" is a work-around for missing expression SFINAE in VS2015.
41
42 template< typename Input, typename... States, int = 0 >
43 static auto match( Input& in, States&&... ) -> decltype( Rule::match( in ), true )
44 {
45 return Rule::match( in );
46 }
47 };
48
49 template< typename Rule,
50 apply_mode A,
51 rewind_mode M,
52 template< typename... > class Action,
53 template< typename... > class Control >
54 struct duseltronik< Rule, A, M, Action, Control, dusel_mode::CONTROL >
55 {
56 template< typename Input, typename... States >
57 static bool match( Input& in, States&&... st )
58 {
59 Control< Rule >::start( const_cast< const Input& >( in ), st... );
60
61 if( duseltronik< Rule, A, M, Action, Control, dusel_mode::NOTHING >::match( in, st... ) ) {
62 Control< Rule >::success( const_cast< const Input& >( in ), st... );
63 return true;
64 }
65 Control< Rule >::failure( const_cast< const Input& >( in ), st... );
66 return false;
67 }
68 };
69
70 template< typename Rule,
71 apply_mode A,
72 rewind_mode M,
73 template< typename... > class Action,
74 template< typename... > class Control >
75 struct duseltronik< Rule, A, M, Action, Control, dusel_mode::CONTROL_AND_APPLY >
76 {
77 template< typename Input, typename... States >
78 static bool match( Input& in, States&&... st )
79 {
80 auto m = in.template mark< rewind_mode::REQUIRED >();
81
82 if( duseltronik< Rule, A, rewind_mode::ACTIVE, Action, Control, dusel_mode::CONTROL >::match( in, st... ) ) {
83 Control< Rule >::template apply< Action >( m.iterator(), const_cast< const Input& >( in ), st... );
84 return m( true );
85 }
86 return false;
87 }
88 };
89
90 template< typename Rule,
91 apply_mode A,
92 rewind_mode M,
93 template< typename... > class Action,
94 template< typename... > class Control >
95 struct duseltronik< Rule, A, M, Action, Control, dusel_mode::CONTROL_AND_APPLY0 >
96 {
97 template< typename Input, typename... States >
98 static bool match( Input& in, States&&... st )
99 {
100 if( duseltronik< Rule, A, M, Action, Control, dusel_mode::CONTROL >::match( in, st... ) ) {
101 Control< Rule >::template apply0< Action >( const_cast< const Input& >( in ), st... );
102 return true;
103 }
104 return false;
105 }
106 };
107
108 } // namespace internal
109
110 } // namespace TAOCPP_PEGTL_NAMESPACE
111
112} // namespace tao
113
114#endif
diff --git a/MoonParser/pegtl/internal/enable.hpp b/MoonParser/pegtl/internal/enable.hpp
new file mode 100644
index 0000000..c01268c
--- /dev/null
+++ b/MoonParser/pegtl/internal/enable.hpp
@@ -0,0 +1,52 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_ENABLE_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_ENABLE_HPP
6
7#include "../config.hpp"
8
9#include "duseltronik.hpp"
10#include "seq.hpp"
11#include "skip_control.hpp"
12
13#include "../apply_mode.hpp"
14#include "../rewind_mode.hpp"
15
16#include "../analysis/generic.hpp"
17
18namespace tao
19{
20 namespace TAOCPP_PEGTL_NAMESPACE
21 {
22 namespace internal
23 {
24 template< typename... Rules >
25 struct enable
26 {
27 using analyze_t = analysis::generic< analysis::rule_type::SEQ, Rules... >;
28
29 template< apply_mode,
30 rewind_mode M,
31 template< typename... > class Action,
32 template< typename... > class Control,
33 typename Input,
34 typename... States >
35 static bool match( Input& in, States&&... st )
36 {
37 return duseltronik< seq< Rules... >, apply_mode::ACTION, M, Action, Control >::match( in, st... );
38 }
39 };
40
41 template< typename... Rules >
42 struct skip_control< enable< Rules... > > : std::true_type
43 {
44 };
45
46 } // namespace internal
47
48 } // namespace TAOCPP_PEGTL_NAMESPACE
49
50} // namespace tao
51
52#endif
diff --git a/MoonParser/pegtl/internal/eof.hpp b/MoonParser/pegtl/internal/eof.hpp
new file mode 100644
index 0000000..a702fa6
--- /dev/null
+++ b/MoonParser/pegtl/internal/eof.hpp
@@ -0,0 +1,41 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_EOF_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_EOF_HPP
6
7#include "../config.hpp"
8
9#include "skip_control.hpp"
10
11#include "../analysis/generic.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 namespace internal
18 {
19 struct eof
20 {
21 using analyze_t = analysis::generic< analysis::rule_type::OPT >;
22
23 template< typename Input >
24 static bool match( Input& in )
25 {
26 return in.empty();
27 }
28 };
29
30 template<>
31 struct skip_control< eof > : std::true_type
32 {
33 };
34
35 } // namespace internal
36
37 } // namespace TAOCPP_PEGTL_NAMESPACE
38
39} // namespace tao
40
41#endif
diff --git a/MoonParser/pegtl/internal/eol.hpp b/MoonParser/pegtl/internal/eol.hpp
new file mode 100644
index 0000000..bfd43c2
--- /dev/null
+++ b/MoonParser/pegtl/internal/eol.hpp
@@ -0,0 +1,42 @@
1// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_EOL_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_EOL_HPP
6
7#include "../config.hpp"
8
9#include "skip_control.hpp"
10
11#include "../analysis/generic.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 namespace internal
18 {
19 struct eol
20 {
21 using analyze_t = analysis::generic< analysis::rule_type::ANY >;
22
23 template< typename Input >
24 static bool match( Input& in )
25 {
26 using eol_t = typename Input::eol_t;
27 return eol_t::match( in ).first;
28 }
29 };
30
31 template<>
32 struct skip_control< eol > : std::true_type
33 {
34 };
35
36 } // namespace internal
37
38 } // namespace TAOCPP_PEGTL_NAMESPACE
39
40} // namespace tao
41
42#endif
diff --git a/MoonParser/pegtl/internal/eolf.hpp b/MoonParser/pegtl/internal/eolf.hpp
new file mode 100644
index 0000000..168311c
--- /dev/null
+++ b/MoonParser/pegtl/internal/eolf.hpp
@@ -0,0 +1,43 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_EOLF_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_EOLF_HPP
6
7#include "../config.hpp"
8
9#include "skip_control.hpp"
10
11#include "../analysis/generic.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 namespace internal
18 {
19 struct eolf
20 {
21 using analyze_t = analysis::generic< analysis::rule_type::OPT >;
22
23 template< typename Input >
24 static bool match( Input& in )
25 {
26 using eol_t = typename Input::eol_t;
27 const auto p = eol_t::match( in );
28 return p.first || ( !p.second );
29 }
30 };
31
32 template<>
33 struct skip_control< eolf > : std::true_type
34 {
35 };
36
37 } // namespace internal
38
39 } // namespace TAOCPP_PEGTL_NAMESPACE
40
41} // namespace tao
42
43#endif
diff --git a/MoonParser/pegtl/internal/file_mapper.hpp b/MoonParser/pegtl/internal/file_mapper.hpp
new file mode 100644
index 0000000..800b9df
--- /dev/null
+++ b/MoonParser/pegtl/internal/file_mapper.hpp
@@ -0,0 +1,91 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_FILE_MAPPER_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_FILE_MAPPER_HPP
6
7#include <sys/mman.h>
8#include <unistd.h>
9
10#include "../config.hpp"
11
12#include "file_opener.hpp"
13
14#include "../input_error.hpp"
15
16namespace tao
17{
18 namespace TAOCPP_PEGTL_NAMESPACE
19 {
20 namespace internal
21 {
22 class file_mapper
23 {
24 public:
25 explicit file_mapper( const char* filename )
26 : file_mapper( file_opener( filename ) )
27 {
28 }
29
30 explicit file_mapper( const file_opener& reader )
31 : m_size( reader.size() ),
32 m_data( static_cast< const char* >(::mmap( nullptr, m_size, PROT_READ, MAP_PRIVATE, reader.m_fd, 0 ) ) )
33 {
34 if( m_size && ( intptr_t( m_data ) == -1 ) ) {
35 TAOCPP_PEGTL_THROW_INPUT_ERROR( "unable to mmap() file " << reader.m_source << " descriptor " << reader.m_fd );
36 }
37 }
38
39 ~file_mapper() noexcept
40 {
41 ::munmap( const_cast< char* >( m_data ), m_size ); // Legacy C interface requires pointer-to-mutable but does not write through the pointer.
42 }
43
44 file_mapper( const file_mapper& ) = delete;
45 void operator=( const file_mapper& ) = delete;
46
47 bool empty() const noexcept
48 {
49 return m_size == 0;
50 }
51
52 std::size_t size() const noexcept
53 {
54 return m_size;
55 }
56
57 using iterator = const char*;
58 using const_iterator = const char*;
59
60 iterator data() const noexcept
61 {
62 return m_data;
63 }
64
65 iterator begin() const noexcept
66 {
67 return m_data;
68 }
69
70 iterator end() const noexcept
71 {
72 return m_data + m_size;
73 }
74
75 std::string string() const
76 {
77 return std::string( m_data, m_size );
78 }
79
80 private:
81 const std::size_t m_size;
82 const char* const m_data;
83 };
84
85 } // namespace internal
86
87 } // namespace TAOCPP_PEGTL_NAMESPACE
88
89} // namespace tao
90
91#endif
diff --git a/MoonParser/pegtl/internal/file_opener.hpp b/MoonParser/pegtl/internal/file_opener.hpp
new file mode 100644
index 0000000..0b1ad6d
--- /dev/null
+++ b/MoonParser/pegtl/internal/file_opener.hpp
@@ -0,0 +1,70 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_FILE_OPENER_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_FILE_OPENER_HPP
6
7#include <fcntl.h>
8#include <sys/stat.h>
9#include <sys/types.h>
10#include <unistd.h>
11
12#include <utility>
13
14#include "../config.hpp"
15#include "../input_error.hpp"
16
17namespace tao
18{
19 namespace TAOCPP_PEGTL_NAMESPACE
20 {
21 namespace internal
22 {
23 struct file_opener
24 {
25 explicit file_opener( const char* filename )
26 : m_source( filename ),
27 m_fd( open() )
28 {
29 }
30
31 ~file_opener() noexcept
32 {
33 ::close( m_fd );
34 }
35
36 file_opener( const file_opener& ) = delete;
37 void operator=( const file_opener& ) = delete;
38
39 std::size_t size() const
40 {
41 struct stat st;
42 errno = 0;
43 if(::fstat( m_fd, &st ) < 0 ) {
44 TAOCPP_PEGTL_THROW_INPUT_ERROR( "unable to fstat() file " << m_source << " descriptor " << m_fd );
45 }
46 return std::size_t( st.st_size );
47 }
48
49 const char* const m_source;
50 const int m_fd;
51
52 private:
53 int open() const
54 {
55 errno = 0;
56 const int fd = ::open( m_source, O_RDONLY );
57 if( fd >= 0 ) {
58 return fd;
59 }
60 TAOCPP_PEGTL_THROW_INPUT_ERROR( "unable to open() file " << m_source << " for reading" );
61 }
62 };
63
64 } // namespace internal
65
66 } // namespace TAOCPP_PEGTL_NAMESPACE
67
68} // namespace tao
69
70#endif
diff --git a/MoonParser/pegtl/internal/file_reader.hpp b/MoonParser/pegtl/internal/file_reader.hpp
new file mode 100644
index 0000000..9bcdf97
--- /dev/null
+++ b/MoonParser/pegtl/internal/file_reader.hpp
@@ -0,0 +1,96 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_FILE_READER_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_FILE_READER_HPP
6
7#include <cstdio>
8#include <memory>
9#include <string>
10#include <utility>
11
12#include "../config.hpp"
13#include "../input_error.hpp"
14
15namespace tao
16{
17 namespace TAOCPP_PEGTL_NAMESPACE
18 {
19 namespace internal
20 {
21 struct file_close
22 {
23 void operator()( FILE* f ) const
24 {
25 std::fclose( f );
26 }
27 };
28
29 class file_reader
30 {
31 public:
32 explicit file_reader( const char* filename )
33 : m_source( filename ),
34 m_file( open() )
35 {
36 }
37
38 file_reader( const file_reader& ) = delete;
39 void operator=( const file_reader& ) = delete;
40
41 std::size_t size() const
42 {
43 errno = 0;
44 if( std::fseek( m_file.get(), 0, SEEK_END ) != 0 ) {
45 TAOCPP_PEGTL_THROW_INPUT_ERROR( "unable to fseek() to end of file " << m_source ); // LCOV_EXCL_LINE
46 }
47 errno = 0;
48 const auto s = std::ftell( m_file.get() );
49 if( s < 0 ) {
50 TAOCPP_PEGTL_THROW_INPUT_ERROR( "unable to ftell() file size of file " << m_source ); // LCOV_EXCL_LINE
51 }
52 errno = 0;
53 if( std::fseek( m_file.get(), 0, SEEK_SET ) != 0 ) {
54 TAOCPP_PEGTL_THROW_INPUT_ERROR( "unable to fseek() to beginning of file " << m_source ); // LCOV_EXCL_LINE
55 }
56 return std::size_t( s );
57 }
58
59 std::string read() const
60 {
61 std::string nrv;
62 nrv.resize( size() );
63 errno = 0;
64 if( ( nrv.size() != 0 ) && ( std::fread( &nrv[ 0 ], nrv.size(), 1, m_file.get() ) != 1 ) ) {
65 TAOCPP_PEGTL_THROW_INPUT_ERROR( "unable to fread() file " << m_source << " size " << nrv.size() ); // LCOV_EXCL_LINE
66 }
67 return nrv;
68 }
69
70 private:
71 const char* const m_source;
72 const std::unique_ptr< std::FILE, file_close > m_file;
73
74 std::FILE* open() const
75 {
76 errno = 0;
77#if defined( _MSC_VER )
78 std::FILE* file;
79 if(::fopen_s( &file, m_source, "rb" ) == 0 )
80#else
81 if( auto* file = std::fopen( m_source, "rb" ) )
82#endif
83 {
84 return file;
85 }
86 TAOCPP_PEGTL_THROW_INPUT_ERROR( "unable to fopen() file " << m_source << " for reading" );
87 }
88 };
89
90 } // namespace internal
91
92 } // namespace TAOCPP_PEGTL_NAMESPACE
93
94} // namespace tao
95
96#endif
diff --git a/MoonParser/pegtl/internal/has_apply0.hpp b/MoonParser/pegtl/internal/has_apply0.hpp
new file mode 100644
index 0000000..01ef7f9
--- /dev/null
+++ b/MoonParser/pegtl/internal/has_apply0.hpp
@@ -0,0 +1,38 @@
1// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_HAS_APPLY0_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_HAS_APPLY0_HPP
6
7#include <type_traits>
8
9#include "../config.hpp"
10
11namespace tao
12{
13 namespace TAOCPP_PEGTL_NAMESPACE
14 {
15 namespace internal
16 {
17 template< typename... S >
18 struct type_list
19 {
20 };
21
22 template< typename A, typename L, typename = void >
23 struct has_apply0 : std::false_type
24 {
25 };
26
27 template< typename A, typename... S >
28 struct has_apply0< A, type_list< S... >, decltype( A::apply0( std::declval< S >()... ), void() ) > : std::true_type
29 {
30 };
31
32 } // namespace internal
33
34 } // namespace TAOCPP_PEGTL_NAMESPACE
35
36} // namespace tao
37
38#endif
diff --git a/MoonParser/pegtl/internal/identifier.hpp b/MoonParser/pegtl/internal/identifier.hpp
new file mode 100644
index 0000000..1ee4571
--- /dev/null
+++ b/MoonParser/pegtl/internal/identifier.hpp
@@ -0,0 +1,30 @@
1// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_IDENTIFIER_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_IDENTIFIER_HPP
6
7#include "../config.hpp"
8
9#include "peek_char.hpp"
10#include "ranges.hpp"
11#include "seq.hpp"
12#include "star.hpp"
13
14namespace tao
15{
16 namespace TAOCPP_PEGTL_NAMESPACE
17 {
18 namespace internal
19 {
20 using identifier_first = ranges< peek_char, 'a', 'z', 'A', 'Z', '_' >;
21 using identifier_other = ranges< peek_char, 'a', 'z', 'A', 'Z', '0', '9', '_' >;
22 using identifier = seq< identifier_first, star< identifier_other > >;
23
24 } // namespace internal
25
26 } // namespace TAOCPP_PEGTL_NAMESPACE
27
28} // namespace tao
29
30#endif
diff --git a/MoonParser/pegtl/internal/if_apply.hpp b/MoonParser/pegtl/internal/if_apply.hpp
new file mode 100644
index 0000000..1e6bb99
--- /dev/null
+++ b/MoonParser/pegtl/internal/if_apply.hpp
@@ -0,0 +1,90 @@
1// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_IF_APPLY_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_IF_APPLY_HPP
6
7#include "../config.hpp"
8
9#include "skip_control.hpp"
10
11namespace tao
12{
13 namespace TAOCPP_PEGTL_NAMESPACE
14 {
15 namespace internal
16 {
17 template< apply_mode A, typename Rule, typename... Actions >
18 struct if_apply_impl;
19
20 template< typename Rule, typename... Actions >
21 struct if_apply_impl< apply_mode::ACTION, Rule, Actions... >
22 {
23 template< rewind_mode,
24 template< typename... > class Action,
25 template< typename... > class Control,
26 typename Input,
27 typename... States >
28 static bool match( Input& in, States&&... st )
29 {
30 using action_t = typename Input::action_t;
31
32 auto m = in.template mark< rewind_mode::REQUIRED >();
33
34 if( Control< Rule >::template match< apply_mode::ACTION, rewind_mode::ACTIVE, Action, Control >( in, st... ) ) {
35 const action_t i2( m.iterator(), in );
36#ifdef __cpp_fold_expressions
37 ( Actions::apply( i2, st... ), ... );
38#else
39 using swallow = bool[];
40 (void)swallow{ ( Actions::apply( i2, st... ), true )..., true };
41#endif
42 return m( true );
43 }
44 return false;
45 }
46 };
47
48 template< typename Rule, typename... Actions >
49 struct if_apply_impl< apply_mode::NOTHING, Rule, Actions... >
50 {
51 template< rewind_mode M,
52 template< typename... > class Action,
53 template< typename... > class Control,
54 typename Input,
55 typename... States >
56 static bool match( Input& in, States&&... st )
57 {
58 return Control< Rule >::template match< apply_mode::NOTHING, M, Action, Control >( in, st... );
59 }
60 };
61
62 template< typename Rule, typename... Actions >
63 struct if_apply
64 {
65 using analyze_t = typename Rule::analyze_t;
66
67 template< apply_mode A,
68 rewind_mode M,
69 template< typename... > class Action,
70 template< typename... > class Control,
71 typename Input,
72 typename... States >
73 static bool match( Input& in, States&&... st )
74 {
75 return if_apply_impl< A, Rule, Actions... >::template match< M, Action, Control >( in, st... );
76 }
77 };
78
79 template< typename Rule, typename... Actions >
80 struct skip_control< if_apply< Rule, Actions... > > : std::true_type
81 {
82 };
83
84 } // namespace internal
85
86 } // namespace TAOCPP_PEGTL_NAMESPACE
87
88} // namespace tao
89
90#endif
diff --git a/MoonParser/pegtl/internal/if_must.hpp b/MoonParser/pegtl/internal/if_must.hpp
new file mode 100644
index 0000000..2a56d7e
--- /dev/null
+++ b/MoonParser/pegtl/internal/if_must.hpp
@@ -0,0 +1,27 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_IF_MUST_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_IF_MUST_HPP
6
7#include "../config.hpp"
8
9#include "must.hpp"
10#include "seq.hpp"
11
12namespace tao
13{
14 namespace TAOCPP_PEGTL_NAMESPACE
15 {
16 namespace internal
17 {
18 template< typename Cond, typename... Thens >
19 using if_must = seq< Cond, must< Thens... > >;
20
21 } // namespace internal
22
23 } // namespace TAOCPP_PEGTL_NAMESPACE
24
25} // namespace tao
26
27#endif
diff --git a/MoonParser/pegtl/internal/if_must_else.hpp b/MoonParser/pegtl/internal/if_must_else.hpp
new file mode 100644
index 0000000..2ccb205
--- /dev/null
+++ b/MoonParser/pegtl/internal/if_must_else.hpp
@@ -0,0 +1,27 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_IF_MUST_ELSE_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_IF_MUST_ELSE_HPP
6
7#include "../config.hpp"
8
9#include "if_then_else.hpp"
10#include "must.hpp"
11
12namespace tao
13{
14 namespace TAOCPP_PEGTL_NAMESPACE
15 {
16 namespace internal
17 {
18 template< typename Cond, typename Then, typename Else >
19 using if_must_else = if_then_else< Cond, must< Then >, must< Else > >;
20
21 } // namespace internal
22
23 } // namespace TAOCPP_PEGTL_NAMESPACE
24
25} // namespace tao
26
27#endif
diff --git a/MoonParser/pegtl/internal/if_then_else.hpp b/MoonParser/pegtl/internal/if_then_else.hpp
new file mode 100644
index 0000000..e55831f
--- /dev/null
+++ b/MoonParser/pegtl/internal/if_then_else.hpp
@@ -0,0 +1,59 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_IF_THEN_ELSE_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_IF_THEN_ELSE_HPP
6
7#include "../config.hpp"
8
9#include "not_at.hpp"
10#include "seq.hpp"
11#include "skip_control.hpp"
12#include "sor.hpp"
13
14#include "../apply_mode.hpp"
15#include "../rewind_mode.hpp"
16
17#include "../analysis/generic.hpp"
18
19namespace tao
20{
21 namespace TAOCPP_PEGTL_NAMESPACE
22 {
23 namespace internal
24 {
25 template< typename Cond, typename Then, typename Else >
26 struct if_then_else
27 {
28 using analyze_t = analysis::generic< analysis::rule_type::SOR, seq< Cond, Then >, seq< not_at< Cond >, Else > >;
29
30 template< apply_mode A,
31 rewind_mode M,
32 template< typename... > class Action,
33 template< typename... > class Control,
34 typename Input,
35 typename... States >
36 static bool match( Input& in, States&&... st )
37 {
38 auto m = in.template mark< M >();
39 using m_t = decltype( m );
40
41 if( Control< Cond >::template match< A, rewind_mode::REQUIRED, Action, Control >( in, st... ) ) {
42 return m( Control< Then >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) );
43 }
44 return m( Control< Else >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) );
45 }
46 };
47
48 template< typename Cond, typename Then, typename Else >
49 struct skip_control< if_then_else< Cond, Then, Else > > : std::true_type
50 {
51 };
52
53 } // namespace internal
54
55 } // namespace TAOCPP_PEGTL_NAMESPACE
56
57} // namespace tao
58
59#endif
diff --git a/MoonParser/pegtl/internal/input_pair.hpp b/MoonParser/pegtl/internal/input_pair.hpp
new file mode 100644
index 0000000..de4e6ba
--- /dev/null
+++ b/MoonParser/pegtl/internal/input_pair.hpp
@@ -0,0 +1,35 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_INPUT_PAIR_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_INPUT_PAIR_HPP
6
7#include "../config.hpp"
8
9namespace tao
10{
11 namespace TAOCPP_PEGTL_NAMESPACE
12 {
13 namespace internal
14 {
15 template< typename Data >
16 struct input_pair
17 {
18 Data data;
19 unsigned char size;
20
21 using data_t = Data;
22
23 explicit operator bool() const noexcept
24 {
25 return size > 0;
26 }
27 };
28
29 } // namespace internal
30
31 } // namespace TAOCPP_PEGTL_NAMESPACE
32
33} // namespace tao
34
35#endif
diff --git a/MoonParser/pegtl/internal/integer_sequence.hpp b/MoonParser/pegtl/internal/integer_sequence.hpp
new file mode 100644
index 0000000..cdcf20d
--- /dev/null
+++ b/MoonParser/pegtl/internal/integer_sequence.hpp
@@ -0,0 +1,85 @@
1// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_INTEGER_SEQUENCE_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_INTEGER_SEQUENCE_HPP
6
7#include <cstddef>
8#include <type_traits>
9#include <utility>
10
11namespace tao
12{
13 namespace TAOCPP_PEGTL_NAMESPACE
14 {
15 namespace internal
16 {
17 template< typename T, T... Ns >
18 struct integer_sequence
19 {
20 using value_type = T;
21
22 static constexpr std::size_t size() noexcept
23 {
24 return sizeof...( Ns );
25 }
26 };
27
28 template< std::size_t... Ns >
29 using index_sequence = integer_sequence< std::size_t, Ns... >;
30
31 template< typename, std::size_t, bool >
32 struct double_up;
33
34 template< typename T, T... Ns, std::size_t N >
35 struct double_up< integer_sequence< T, Ns... >, N, false >
36 {
37 using type = integer_sequence< T, Ns..., ( N + Ns )... >;
38 };
39
40 template< typename T, T... Ns, std::size_t N >
41 struct double_up< integer_sequence< T, Ns... >, N, true >
42 {
43 using type = integer_sequence< T, Ns..., ( N + Ns )..., 2 * N >;
44 };
45
46 template< typename T, T N, typename = void >
47 struct generate_sequence;
48
49 template< typename T, T N >
50 using generate_sequence_t = typename generate_sequence< T, N >::type;
51
52 template< typename T, T N, typename >
53 struct generate_sequence
54 : double_up< generate_sequence_t< T, N / 2 >, N / 2, N % 2 == 1 >
55 {
56 };
57
58 template< typename T, T N >
59 struct generate_sequence< T, N, typename std::enable_if< ( N == 0 ) >::type >
60 {
61 using type = integer_sequence< T >;
62 };
63
64 template< typename T, T N >
65 struct generate_sequence< T, N, typename std::enable_if< ( N == 1 ) >::type >
66 {
67 using type = integer_sequence< T, 0 >;
68 };
69
70 template< typename T, T N >
71 using make_integer_sequence = generate_sequence_t< T, N >;
72
73 template< std::size_t N >
74 using make_index_sequence = make_integer_sequence< std::size_t, N >;
75
76 template< typename... Ts >
77 using index_sequence_for = make_index_sequence< sizeof...( Ts ) >;
78
79 } // namespace internal
80
81 } // namespace TAOCPP_PEGTL_NAMESPACE
82
83} // namespace tao
84
85#endif
diff --git a/MoonParser/pegtl/internal/istream_reader.hpp b/MoonParser/pegtl/internal/istream_reader.hpp
new file mode 100644
index 0000000..8509080
--- /dev/null
+++ b/MoonParser/pegtl/internal/istream_reader.hpp
@@ -0,0 +1,47 @@
1// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_ISTREAM_READER_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_ISTREAM_READER_HPP
6
7#include <istream>
8
9#include "../config.hpp"
10#include "../input_error.hpp"
11
12namespace tao
13{
14 namespace TAOCPP_PEGTL_NAMESPACE
15 {
16 namespace internal
17 {
18 struct istream_reader
19 {
20 explicit istream_reader( std::istream& s ) noexcept
21 : m_istream( s )
22 {
23 }
24
25 std::size_t operator()( char* buffer, const std::size_t length )
26 {
27 m_istream.read( buffer, std::streamsize( length ) );
28
29 if( const auto r = m_istream.gcount() ) {
30 return std::size_t( r );
31 }
32 if( m_istream.eof() ) {
33 return 0;
34 }
35 TAOCPP_PEGTL_THROW_INPUT_ERROR( "error in istream.read()" );
36 }
37
38 std::istream& m_istream;
39 };
40
41 } // namespace internal
42
43 } // namespace TAOCPP_PEGTL_NAMESPACE
44
45} // namespace tao
46
47#endif
diff --git a/MoonParser/pegtl/internal/istring.hpp b/MoonParser/pegtl/internal/istring.hpp
new file mode 100644
index 0000000..3ed2835
--- /dev/null
+++ b/MoonParser/pegtl/internal/istring.hpp
@@ -0,0 +1,107 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_ISTRING_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_ISTRING_HPP
6
7#include <type_traits>
8
9#include "../config.hpp"
10
11#include "bump_help.hpp"
12#include "result_on_found.hpp"
13#include "skip_control.hpp"
14#include "trivial.hpp"
15
16#include "../analysis/counted.hpp"
17
18namespace tao
19{
20 namespace TAOCPP_PEGTL_NAMESPACE
21 {
22 namespace internal
23 {
24 template< char C >
25 using is_alpha = std::integral_constant< bool, ( ( 'a' <= C ) && ( C <= 'z' ) ) || ( ( 'A' <= C ) && ( C <= 'Z' ) ) >;
26
27 template< char C, bool A = is_alpha< C >::value >
28 struct ichar_equal;
29
30 template< char C >
31 struct ichar_equal< C, true >
32 {
33 static bool match( const char c ) noexcept
34 {
35 return ( C | 0x20 ) == ( c | 0x20 );
36 }
37 };
38
39 template< char C >
40 struct ichar_equal< C, false >
41 {
42 static bool match( const char c ) noexcept
43 {
44 return c == C;
45 }
46 };
47
48 template< char... Cs >
49 struct istring_equal;
50
51 template<>
52 struct istring_equal<>
53 {
54 static bool match( const char* ) noexcept
55 {
56 return true;
57 }
58 };
59
60 template< char C, char... Cs >
61 struct istring_equal< C, Cs... >
62 {
63 static bool match( const char* r ) noexcept
64 {
65 return ichar_equal< C >::match( *r ) && istring_equal< Cs... >::match( r + 1 );
66 }
67 };
68
69 template< char... Cs >
70 struct istring;
71
72 template<>
73 struct istring<>
74 : trivial< true >
75 {
76 };
77
78 template< char... Cs >
79 struct istring
80 {
81 using analyze_t = analysis::counted< analysis::rule_type::ANY, sizeof...( Cs ) >;
82
83 template< typename Input >
84 static bool match( Input& in )
85 {
86 if( in.size( sizeof...( Cs ) ) >= sizeof...( Cs ) ) {
87 if( istring_equal< Cs... >::match( in.current() ) ) {
88 bump_help< result_on_found::SUCCESS, Input, char, Cs... >( in, sizeof...( Cs ) );
89 return true;
90 }
91 }
92 return false;
93 }
94 };
95
96 template< char... Cs >
97 struct skip_control< istring< Cs... > > : std::true_type
98 {
99 };
100
101 } // namespace internal
102
103 } // namespace TAOCPP_PEGTL_NAMESPACE
104
105} // namespace tao
106
107#endif
diff --git a/MoonParser/pegtl/internal/iterator.hpp b/MoonParser/pegtl/internal/iterator.hpp
new file mode 100644
index 0000000..4179738
--- /dev/null
+++ b/MoonParser/pegtl/internal/iterator.hpp
@@ -0,0 +1,53 @@
1// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_ITERATOR_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_ITERATOR_HPP
6
7#include <cstdlib>
8
9#include "../config.hpp"
10
11namespace tao
12{
13 namespace TAOCPP_PEGTL_NAMESPACE
14 {
15 namespace internal
16 {
17 struct iterator
18 {
19 iterator() noexcept = default;
20
21 explicit iterator( const char* in_data ) noexcept
22 : data( in_data ),
23 byte( 0 ),
24 line( 1 ),
25 byte_in_line( 0 )
26 {
27 }
28
29 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
30 : data( in_data ),
31 byte( in_byte ),
32 line( in_line ),
33 byte_in_line( in_byte_in_line )
34 {
35 }
36
37 iterator( const iterator& ) = default;
38 iterator& operator=( const iterator& ) = default;
39
40 const char* data;
41
42 std::size_t byte;
43 std::size_t line;
44 std::size_t byte_in_line;
45 };
46
47 } // namespace internal
48
49 } // namespace TAOCPP_PEGTL_NAMESPACE
50
51} // namespace tao
52
53#endif
diff --git a/MoonParser/pegtl/internal/lf_crlf_eol.hpp b/MoonParser/pegtl/internal/lf_crlf_eol.hpp
new file mode 100644
index 0000000..90b5b03
--- /dev/null
+++ b/MoonParser/pegtl/internal/lf_crlf_eol.hpp
@@ -0,0 +1,44 @@
1// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_LF_CRLF_EOL_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_LF_CRLF_EOL_HPP
6
7#include "../config.hpp"
8
9namespace tao
10{
11 namespace TAOCPP_PEGTL_NAMESPACE
12 {
13 namespace internal
14 {
15 struct lf_crlf_eol
16 {
17 static constexpr int ch = '\n';
18
19 template< typename Input >
20 static eol_pair match( Input& in )
21 {
22 eol_pair p = { false, in.size( 2 ) };
23 if( p.second ) {
24 const auto a = in.peek_char();
25 if( a == '\n' ) {
26 in.bump_to_next_line();
27 p.first = true;
28 }
29 else if( ( a == '\r' ) && ( p.second > 1 ) && ( in.peek_char( 1 ) == '\n' ) ) {
30 in.bump_to_next_line( 2 );
31 p.first = true;
32 }
33 }
34 return p;
35 }
36 };
37
38 } // namespace internal
39
40 } // namespace TAOCPP_PEGTL_NAMESPACE
41
42} // namespace tao
43
44#endif
diff --git a/MoonParser/pegtl/internal/lf_eol.hpp b/MoonParser/pegtl/internal/lf_eol.hpp
new file mode 100644
index 0000000..438b8f0
--- /dev/null
+++ b/MoonParser/pegtl/internal/lf_eol.hpp
@@ -0,0 +1,39 @@
1// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_LF_EOL_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_LF_EOL_HPP
6
7#include "../config.hpp"
8
9namespace tao
10{
11 namespace TAOCPP_PEGTL_NAMESPACE
12 {
13 namespace internal
14 {
15 struct lf_eol
16 {
17 static constexpr int ch = '\n';
18
19 template< typename Input >
20 static eol_pair match( Input& in )
21 {
22 eol_pair p = { false, in.size( 1 ) };
23 if( p.second ) {
24 if( in.peek_char() == '\n' ) {
25 in.bump_to_next_line();
26 p.first = true;
27 }
28 }
29 return p;
30 }
31 };
32
33 } // namespace internal
34
35 } // namespace TAOCPP_PEGTL_NAMESPACE
36
37} // namespace tao
38
39#endif
diff --git a/MoonParser/pegtl/internal/list.hpp b/MoonParser/pegtl/internal/list.hpp
new file mode 100644
index 0000000..1a812fb
--- /dev/null
+++ b/MoonParser/pegtl/internal/list.hpp
@@ -0,0 +1,27 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_LIST_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_LIST_HPP
6
7#include "../config.hpp"
8
9#include "seq.hpp"
10#include "star.hpp"
11
12namespace tao
13{
14 namespace TAOCPP_PEGTL_NAMESPACE
15 {
16 namespace internal
17 {
18 template< typename Rule, typename Sep >
19 using list = seq< Rule, star< Sep, Rule > >;
20
21 } // namespace internal
22
23 } // namespace TAOCPP_PEGTL_NAMESPACE
24
25} // namespace tao
26
27#endif
diff --git a/MoonParser/pegtl/internal/list_must.hpp b/MoonParser/pegtl/internal/list_must.hpp
new file mode 100644
index 0000000..9b60311
--- /dev/null
+++ b/MoonParser/pegtl/internal/list_must.hpp
@@ -0,0 +1,28 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_LIST_MUST_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_LIST_MUST_HPP
6
7#include "../config.hpp"
8
9#include "must.hpp"
10#include "seq.hpp"
11#include "star.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 namespace internal
18 {
19 template< typename Rule, typename Sep >
20 using list_must = seq< Rule, star< Sep, must< Rule > > >;
21
22 } // namespace internal
23
24 } // namespace TAOCPP_PEGTL_NAMESPACE
25
26} // namespace tao
27
28#endif
diff --git a/MoonParser/pegtl/internal/list_tail.hpp b/MoonParser/pegtl/internal/list_tail.hpp
new file mode 100644
index 0000000..dd7b920
--- /dev/null
+++ b/MoonParser/pegtl/internal/list_tail.hpp
@@ -0,0 +1,28 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_LIST_TAIL_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_LIST_TAIL_HPP
6
7#include "../config.hpp"
8
9#include "list.hpp"
10#include "opt.hpp"
11#include "seq.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 namespace internal
18 {
19 template< typename Rule, typename Sep >
20 using list_tail = seq< list< Rule, Sep >, opt< Sep > >;
21
22 } // namespace internal
23
24 } // namespace TAOCPP_PEGTL_NAMESPACE
25
26} // namespace tao
27
28#endif
diff --git a/MoonParser/pegtl/internal/list_tail_pad.hpp b/MoonParser/pegtl/internal/list_tail_pad.hpp
new file mode 100644
index 0000000..0f3ebf6
--- /dev/null
+++ b/MoonParser/pegtl/internal/list_tail_pad.hpp
@@ -0,0 +1,30 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_LIST_TAIL_PAD_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_LIST_TAIL_PAD_HPP
6
7#include "../config.hpp"
8
9#include "list.hpp"
10#include "opt.hpp"
11#include "pad.hpp"
12#include "seq.hpp"
13#include "star.hpp"
14
15namespace tao
16{
17 namespace TAOCPP_PEGTL_NAMESPACE
18 {
19 namespace internal
20 {
21 template< typename Rule, typename Sep, typename Pad >
22 using list_tail_pad = seq< list< Rule, pad< Sep, Pad > >, opt< star< Pad >, Sep > >;
23
24 } // namespace internal
25
26 } // namespace TAOCPP_PEGTL_NAMESPACE
27
28} // namespace tao
29
30#endif
diff --git a/MoonParser/pegtl/internal/marker.hpp b/MoonParser/pegtl/internal/marker.hpp
new file mode 100644
index 0000000..76cba0e
--- /dev/null
+++ b/MoonParser/pegtl/internal/marker.hpp
@@ -0,0 +1,93 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_MARKER_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_MARKER_HPP
6
7#include "../config.hpp"
8#include "../rewind_mode.hpp"
9
10namespace tao
11{
12 namespace TAOCPP_PEGTL_NAMESPACE
13 {
14 namespace internal
15 {
16 template< typename Iterator, rewind_mode M >
17 class marker
18 {
19 public:
20 static constexpr rewind_mode next_rewind_mode = M;
21
22 explicit marker( const Iterator& ) noexcept
23 {
24 }
25
26 marker( marker&& ) noexcept
27 {
28 }
29
30 marker( const marker& ) = delete;
31 void operator=( const marker& ) = delete;
32
33 bool operator()( const bool result ) const noexcept
34 {
35 return result;
36 }
37 };
38
39 template< typename Iterator >
40 class marker< Iterator, rewind_mode::REQUIRED >
41 {
42 public:
43 static constexpr rewind_mode next_rewind_mode = rewind_mode::ACTIVE;
44
45 explicit marker( Iterator& i ) noexcept
46 : m_saved( i ),
47 m_input( &i )
48 {
49 }
50
51 marker( marker&& i ) noexcept
52 : m_saved( i.m_saved ),
53 m_input( i.m_input )
54 {
55 i.m_input = nullptr;
56 }
57
58 ~marker() noexcept
59 {
60 if( m_input != nullptr ) {
61 ( *m_input ) = m_saved;
62 }
63 }
64
65 marker( const marker& ) = delete;
66 void operator=( const marker& ) = delete;
67
68 bool operator()( const bool result ) noexcept
69 {
70 if( result ) {
71 m_input = nullptr;
72 return true;
73 }
74 return false;
75 }
76
77 const Iterator& iterator() const noexcept
78 {
79 return m_saved;
80 }
81
82 private:
83 const Iterator m_saved;
84 Iterator* m_input;
85 };
86
87 } // namespace internal
88
89 } // namespace TAOCPP_PEGTL_NAMESPACE
90
91} // namespace tao
92
93#endif
diff --git a/MoonParser/pegtl/internal/minus.hpp b/MoonParser/pegtl/internal/minus.hpp
new file mode 100644
index 0000000..88242e5
--- /dev/null
+++ b/MoonParser/pegtl/internal/minus.hpp
@@ -0,0 +1,69 @@
1// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_MINUS_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_MINUS_HPP
6
7#include "../config.hpp"
8
9#include "skip_control.hpp"
10
11#include "../apply_mode.hpp"
12#include "../memory_input.hpp"
13#include "../rewind_mode.hpp"
14
15namespace tao
16{
17 namespace TAOCPP_PEGTL_NAMESPACE
18 {
19 namespace internal
20 {
21 inline const char* source_pointer( const char* source ) noexcept
22 {
23 return source;
24 }
25
26 inline const char* source_pointer( const std::string& source ) noexcept
27 {
28 return source.c_str();
29 }
30
31 template< typename R, typename S >
32 struct minus
33 {
34 using analyze_t = typename R::analyze_t; // NOTE: S is currently ignored for analyze().
35
36 template< apply_mode A,
37 rewind_mode,
38 template< typename... > class Action,
39 template< typename... > class Control,
40 typename Input,
41 typename... States >
42 static bool match( Input& in, States&&... st )
43 {
44 auto m = in.template mark< rewind_mode::REQUIRED >();
45
46 if( !Control< R >::template match< A, rewind_mode::ACTIVE, Action, Control >( in, st... ) ) {
47 return false;
48 }
49 memory_input< tracking_mode::LAZY, typename Input::eol_t, const char* > i2( m.iterator(), in.current(), source_pointer( in.source() ) );
50
51 if( !Control< S >::template match< apply_mode::NOTHING, rewind_mode::ACTIVE, Action, Control >( i2, st... ) ) {
52 return m( true );
53 }
54 return m( !i2.empty() );
55 }
56 };
57
58 template< typename R, typename S >
59 struct skip_control< minus< R, S > > : std::true_type
60 {
61 };
62
63 } // namespace internal
64
65 } // namespace TAOCPP_PEGTL_NAMESPACE
66
67} // namespace tao
68
69#endif
diff --git a/MoonParser/pegtl/internal/must.hpp b/MoonParser/pegtl/internal/must.hpp
new file mode 100644
index 0000000..4ac9920
--- /dev/null
+++ b/MoonParser/pegtl/internal/must.hpp
@@ -0,0 +1,79 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_MUST_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_MUST_HPP
6
7#include "../config.hpp"
8
9#include "raise.hpp"
10#include "rule_conjunction.hpp"
11#include "skip_control.hpp"
12
13#include "../apply_mode.hpp"
14#include "../rewind_mode.hpp"
15
16#include "../analysis/generic.hpp"
17
18namespace tao
19{
20 namespace TAOCPP_PEGTL_NAMESPACE
21 {
22 namespace internal
23 {
24 // The general case applies must<> to each of the
25 // rules in the 'Rules' parameter pack individually.
26
27 template< typename... Rules >
28 struct must
29 {
30 using analyze_t = analysis::generic< analysis::rule_type::SEQ, Rules... >;
31
32 template< apply_mode A,
33 rewind_mode M,
34 template< typename... > class Action,
35 template< typename... > class Control,
36 typename Input,
37 typename... States >
38 static bool match( Input& in, States&&... st )
39 {
40 return rule_conjunction< must< Rules >... >::template match< A, M, Action, Control >( in, st... );
41 }
42 };
43
44 // While in theory the implementation for a single rule could
45 // be simplified to must< Rule > = sor< Rule, raise< Rule > >, this
46 // would result in some unnecessary run-time overhead.
47
48 template< typename Rule >
49 struct must< Rule >
50 {
51 using analyze_t = typename Rule::analyze_t;
52
53 template< apply_mode A,
54 rewind_mode,
55 template< typename... > class Action,
56 template< typename... > class Control,
57 typename Input,
58 typename... States >
59 static bool match( Input& in, States&&... st )
60 {
61 if( !Control< Rule >::template match< A, rewind_mode::DONTCARE, Action, Control >( in, st... ) ) {
62 raise< Rule >::template match< A, rewind_mode::DONTCARE, Action, Control >( in, st... );
63 }
64 return true;
65 }
66 };
67
68 template< typename... Rules >
69 struct skip_control< must< Rules... > > : std::true_type
70 {
71 };
72
73 } // namespace internal
74
75 } // namespace TAOCPP_PEGTL_NAMESPACE
76
77} // namespace tao
78
79#endif
diff --git a/MoonParser/pegtl/internal/not_at.hpp b/MoonParser/pegtl/internal/not_at.hpp
new file mode 100644
index 0000000..ed80c56
--- /dev/null
+++ b/MoonParser/pegtl/internal/not_at.hpp
@@ -0,0 +1,62 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_NOT_AT_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_NOT_AT_HPP
6
7#include "../config.hpp"
8
9#include "rule_conjunction.hpp"
10#include "skip_control.hpp"
11#include "trivial.hpp"
12
13#include "../apply_mode.hpp"
14#include "../rewind_mode.hpp"
15
16#include "../analysis/generic.hpp"
17
18namespace tao
19{
20 namespace TAOCPP_PEGTL_NAMESPACE
21 {
22 namespace internal
23 {
24 template< typename... Rules >
25 struct not_at;
26
27 template<>
28 struct not_at<>
29 : trivial< false >
30 {
31 };
32
33 template< typename... Rules >
34 struct not_at
35 {
36 using analyze_t = analysis::generic< analysis::rule_type::OPT, Rules... >;
37
38 template< apply_mode,
39 rewind_mode,
40 template< typename... > class Action,
41 template< typename... > class Control,
42 typename Input,
43 typename... States >
44 static bool match( Input& in, States&&... st )
45 {
46 const auto m = in.template mark< rewind_mode::REQUIRED >();
47 return !rule_conjunction< Rules... >::template match< apply_mode::NOTHING, rewind_mode::ACTIVE, Action, Control >( in, st... );
48 }
49 };
50
51 template< typename... Rules >
52 struct skip_control< not_at< Rules... > > : std::true_type
53 {
54 };
55
56 } // namespace internal
57
58 } // namespace TAOCPP_PEGTL_NAMESPACE
59
60} // namespace tao
61
62#endif
diff --git a/MoonParser/pegtl/internal/one.hpp b/MoonParser/pegtl/internal/one.hpp
new file mode 100644
index 0000000..a3941eb
--- /dev/null
+++ b/MoonParser/pegtl/internal/one.hpp
@@ -0,0 +1,81 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_ONE_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_ONE_HPP
6
7#include <algorithm>
8#include <utility>
9
10#include "../config.hpp"
11
12#include "bump_help.hpp"
13#include "result_on_found.hpp"
14#include "skip_control.hpp"
15
16#include "../analysis/generic.hpp"
17
18namespace tao
19{
20 namespace TAOCPP_PEGTL_NAMESPACE
21 {
22 namespace internal
23 {
24 template< typename Char >
25 bool contains( const Char c, const std::initializer_list< Char >& l ) noexcept
26 {
27 return std::find( l.begin(), l.end(), c ) != l.end();
28 }
29
30 template< result_on_found R, typename Peek, typename Peek::data_t... Cs >
31 struct one
32 {
33 using analyze_t = analysis::generic< analysis::rule_type::ANY >;
34
35 template< typename Input >
36 static bool match( Input& in )
37 {
38 if( !in.empty() ) {
39 if( const auto t = Peek::peek( in ) ) {
40 if( contains( t.data, { Cs... } ) == bool( R ) ) {
41 bump_help< R, Input, typename Peek::data_t, Cs... >( in, t.size );
42 return true;
43 }
44 }
45 }
46 return false;
47 }
48 };
49
50 template< result_on_found R, typename Peek, typename Peek::data_t C >
51 struct one< R, Peek, C >
52 {
53 using analyze_t = analysis::generic< analysis::rule_type::ANY >;
54
55 template< typename Input >
56 static bool match( Input& in )
57 {
58 if( !in.empty() ) {
59 if( const auto t = Peek::peek( in ) ) {
60 if( ( t.data == C ) == bool( R ) ) {
61 bump_help< R, Input, typename Peek::data_t, C >( in, t.size );
62 return true;
63 }
64 }
65 }
66 return false;
67 }
68 };
69
70 template< result_on_found R, typename Peek, typename Peek::data_t... Cs >
71 struct skip_control< one< R, Peek, Cs... > > : std::true_type
72 {
73 };
74
75 } // namespace internal
76
77 } // namespace TAOCPP_PEGTL_NAMESPACE
78
79} // namespace tao
80
81#endif
diff --git a/MoonParser/pegtl/internal/opt.hpp b/MoonParser/pegtl/internal/opt.hpp
new file mode 100644
index 0000000..a897443
--- /dev/null
+++ b/MoonParser/pegtl/internal/opt.hpp
@@ -0,0 +1,67 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_OPT_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_OPT_HPP
6
7#include <type_traits>
8
9#include "../config.hpp"
10
11#include "duseltronik.hpp"
12#include "seq.hpp"
13#include "skip_control.hpp"
14#include "trivial.hpp"
15
16#include "../apply_mode.hpp"
17#include "../rewind_mode.hpp"
18
19#include "../analysis/generic.hpp"
20
21namespace tao
22{
23 namespace TAOCPP_PEGTL_NAMESPACE
24 {
25 namespace internal
26 {
27 template< typename... Rules >
28 struct opt;
29
30 template<>
31 struct opt<>
32 : trivial< true >
33 {
34 };
35
36 template< typename... Rules >
37 struct opt
38 {
39 using analyze_t = analysis::generic< analysis::rule_type::OPT, Rules... >;
40
41 template< apply_mode A,
42 rewind_mode,
43 template< typename... > class Action,
44 template< typename... > class Control,
45 typename Input,
46 typename... States >
47 static bool match( Input& in, States&&... st )
48 {
49 if( !in.empty() ) {
50 duseltronik< seq< Rules... >, A, rewind_mode::REQUIRED, Action, Control >::match( in, st... );
51 }
52 return true;
53 }
54 };
55
56 template< typename... Rules >
57 struct skip_control< opt< Rules... > > : std::true_type
58 {
59 };
60
61 } // namespace internal
62
63 } // namespace TAOCPP_PEGTL_NAMESPACE
64
65} // namespace tao
66
67#endif
diff --git a/MoonParser/pegtl/internal/pad.hpp b/MoonParser/pegtl/internal/pad.hpp
new file mode 100644
index 0000000..fcb6e4f
--- /dev/null
+++ b/MoonParser/pegtl/internal/pad.hpp
@@ -0,0 +1,27 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_PAD_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_PAD_HPP
6
7#include "../config.hpp"
8
9#include "seq.hpp"
10#include "star.hpp"
11
12namespace tao
13{
14 namespace TAOCPP_PEGTL_NAMESPACE
15 {
16 namespace internal
17 {
18 template< typename Rule, typename Pad1, typename Pad2 = Pad1 >
19 using pad = seq< star< Pad1 >, Rule, star< Pad2 > >;
20
21 } // namespace internal
22
23 } // namespace TAOCPP_PEGTL_NAMESPACE
24
25} // namespace tao
26
27#endif
diff --git a/MoonParser/pegtl/internal/pad_opt.hpp b/MoonParser/pegtl/internal/pad_opt.hpp
new file mode 100644
index 0000000..4b7d400
--- /dev/null
+++ b/MoonParser/pegtl/internal/pad_opt.hpp
@@ -0,0 +1,28 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_PAD_OPT_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_PAD_OPT_HPP
6
7#include "../config.hpp"
8
9#include "opt.hpp"
10#include "seq.hpp"
11#include "star.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 namespace internal
18 {
19 template< typename Rule, typename Pad >
20 using pad_opt = seq< star< Pad >, opt< Rule, star< Pad > > >;
21
22 } // namespace internal
23
24 } // namespace TAOCPP_PEGTL_NAMESPACE
25
26} // namespace tao
27
28#endif
diff --git a/MoonParser/pegtl/internal/peek_char.hpp b/MoonParser/pegtl/internal/peek_char.hpp
new file mode 100644
index 0000000..064e6da
--- /dev/null
+++ b/MoonParser/pegtl/internal/peek_char.hpp
@@ -0,0 +1,35 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_PEEK_CHAR_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_PEEK_CHAR_HPP
6
7#include <cstddef>
8
9#include "input_pair.hpp"
10
11namespace tao
12{
13 namespace TAOCPP_PEGTL_NAMESPACE
14 {
15 namespace internal
16 {
17 struct peek_char
18 {
19 using data_t = char;
20 using pair_t = input_pair< char >;
21
22 template< typename Input >
23 static pair_t peek( Input& in, const std::size_t o = 0 )
24 {
25 return { in.peek_char( o ), 1 };
26 }
27 };
28
29 } // namespace internal
30
31 } // namespace TAOCPP_PEGTL_NAMESPACE
32
33} // namespace tao
34
35#endif
diff --git a/MoonParser/pegtl/internal/peek_utf16.hpp b/MoonParser/pegtl/internal/peek_utf16.hpp
new file mode 100644
index 0000000..a643b1f
--- /dev/null
+++ b/MoonParser/pegtl/internal/peek_utf16.hpp
@@ -0,0 +1,54 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_PEEK_UTF16_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_PEEK_UTF16_HPP
6
7#include <type_traits>
8
9#include "../config.hpp"
10
11#include "input_pair.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 namespace internal
18 {
19 struct peek_utf16
20 {
21 using data_t = char32_t;
22 using pair_t = input_pair< char32_t >;
23
24 using short_t = std::make_unsigned< char16_t >::type;
25
26 static_assert( sizeof( short_t ) == 2, "expected size 2 for 16bit value" );
27 static_assert( sizeof( char16_t ) == 2, "expected size 2 for 16bit value" );
28
29 template< typename Input >
30 static pair_t peek( Input& in )
31 {
32 const std::size_t s = in.size( 4 );
33 if( s >= 2 ) {
34 const char32_t t = *reinterpret_cast< const short_t* >( in.current() );
35 if( ( t < 0xd800 ) || ( t > 0xdbff ) || ( s < 4 ) ) {
36 return { t, 2 };
37 }
38 const char32_t u = *reinterpret_cast< const short_t* >( in.current() + 2 );
39 if( ( u < 0xdc00 ) || ( u > 0xdfff ) ) {
40 return { t, 2 };
41 }
42 return { ( ( ( t & 0x03ff ) << 10 ) | ( u & 0x03ff ) ) + 0x10000, 4 };
43 }
44 return { 0, 0 };
45 }
46 };
47
48 } // namespace internal
49
50 } // namespace TAOCPP_PEGTL_NAMESPACE
51
52} // namespace tao
53
54#endif
diff --git a/MoonParser/pegtl/internal/peek_utf32.hpp b/MoonParser/pegtl/internal/peek_utf32.hpp
new file mode 100644
index 0000000..f082064
--- /dev/null
+++ b/MoonParser/pegtl/internal/peek_utf32.hpp
@@ -0,0 +1,46 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_PEEK_UTF32_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_PEEK_UTF32_HPP
6
7#include <cstddef>
8
9#include "../config.hpp"
10
11#include "input_pair.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 namespace internal
18 {
19 struct peek_utf32
20 {
21 using data_t = char32_t;
22 using pair_t = input_pair< char32_t >;
23
24 static_assert( sizeof( char32_t ) == 4, "expected size 4 for 32bit value" );
25
26 template< typename Input >
27 static pair_t peek( Input& in )
28 {
29 const std::size_t s = in.size( 4 );
30 if( s >= 4 ) {
31 const char32_t t = *reinterpret_cast< const char32_t* >( in.current() );
32 if( ( 0 <= t ) && ( t <= 0x10ffff ) ) {
33 return { t, 4 };
34 }
35 }
36 return { 0, 0 };
37 }
38 };
39
40 } // namespace internal
41
42 } // namespace TAOCPP_PEGTL_NAMESPACE
43
44} // namespace tao
45
46#endif
diff --git a/MoonParser/pegtl/internal/peek_utf8.hpp b/MoonParser/pegtl/internal/peek_utf8.hpp
new file mode 100644
index 0000000..9ea0a0e
--- /dev/null
+++ b/MoonParser/pegtl/internal/peek_utf8.hpp
@@ -0,0 +1,88 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_PEEK_UTF8_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_PEEK_UTF8_HPP
6
7#include "../config.hpp"
8
9#include "input_pair.hpp"
10
11namespace tao
12{
13 namespace TAOCPP_PEGTL_NAMESPACE
14 {
15 namespace internal
16 {
17 struct peek_utf8
18 {
19 using data_t = char32_t;
20 using pair_t = input_pair< char32_t >;
21
22 template< typename Input >
23 static pair_t peek( Input& in )
24 {
25 char32_t c0 = in.peek_byte();
26
27 if( ( c0 & 0x80 ) == 0 ) {
28 return { c0, 1 };
29 }
30 if( ( c0 & 0xE0 ) == 0xC0 ) {
31 if( in.size( 2 ) >= 2 ) {
32 const char32_t c1 = in.peek_byte( 1 );
33 if( ( c1 & 0xC0 ) == 0x80 ) {
34 c0 &= 0x1F;
35 c0 <<= 6;
36 c0 |= ( c1 & 0x3F );
37 if( c0 >= 0x80 ) {
38 return { c0, 2 };
39 }
40 }
41 }
42 }
43 else if( ( c0 & 0xF0 ) == 0xE0 ) {
44 if( in.size( 3 ) >= 3 ) {
45 const char32_t c1 = in.peek_byte( 1 );
46 const char32_t c2 = in.peek_byte( 2 );
47 if( ( ( c1 & 0xC0 ) == 0x80 ) && ( ( c2 & 0xC0 ) == 0x80 ) ) {
48 c0 &= 0x0F;
49 c0 <<= 6;
50 c0 |= ( c1 & 0x3F );
51 c0 <<= 6;
52 c0 |= ( c2 & 0x3F );
53 if( c0 >= 0x800 ) {
54 return { c0, 3 };
55 }
56 }
57 }
58 }
59 else if( ( c0 & 0xF8 ) == 0xF0 ) {
60 if( in.size( 4 ) >= 4 ) {
61 const char32_t c1 = in.peek_byte( 1 );
62 const char32_t c2 = in.peek_byte( 2 );
63 const char32_t c3 = in.peek_byte( 3 );
64 if( ( ( c1 & 0xC0 ) == 0x80 ) && ( ( c2 & 0xC0 ) == 0x80 ) && ( ( c3 & 0xC0 ) == 0x80 ) ) {
65 c0 &= 0x07;
66 c0 <<= 6;
67 c0 |= ( c1 & 0x3F );
68 c0 <<= 6;
69 c0 |= ( c2 & 0x3F );
70 c0 <<= 6;
71 c0 |= ( c3 & 0x3F );
72 if( c0 >= 0x10000 && c0 <= 0x10FFFF ) {
73 return { c0, 4 };
74 }
75 }
76 }
77 }
78 return { 0, 0 };
79 }
80 };
81
82 } // namespace internal
83
84 } // namespace TAOCPP_PEGTL_NAMESPACE
85
86} // namespace tao
87
88#endif
diff --git a/MoonParser/pegtl/internal/pegtl_string.hpp b/MoonParser/pegtl/internal/pegtl_string.hpp
new file mode 100644
index 0000000..7c27fd8
--- /dev/null
+++ b/MoonParser/pegtl/internal/pegtl_string.hpp
@@ -0,0 +1,98 @@
1// Copyright (c) 2015-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_TAOCPP_PEGTL_STRING_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_TAOCPP_PEGTL_STRING_HPP
6
7#include <cstddef>
8#include <type_traits>
9
10#include "../ascii.hpp"
11#include "../config.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 // Inspired by https://github.com/irrequietus/typestring
18 // Rewritten and reduced to what is needed for the PEGTL
19 // and to work with Visual Studio 2015.
20
21 namespace internal
22 {
23 template< typename, typename, typename, typename, typename, typename, typename, typename >
24 struct string_join;
25
26 template< template< char... > class S, char... C0s, char... C1s, char... C2s, char... C3s, char... C4s, char... C5s, char... C6s, char... C7s >
27 struct string_join< S< C0s... >, S< C1s... >, S< C2s... >, S< C3s... >, S< C4s... >, S< C5s... >, S< C6s... >, S< C7s... > >
28 {
29 using type = S< C0s..., C1s..., C2s..., C3s..., C4s..., C5s..., C6s..., C7s... >;
30 };
31
32 template< template< char... > class S, char, bool >
33 struct string_at
34 {
35 using type = S<>;
36 };
37
38 template< template< char... > class S, char C >
39 struct string_at< S, C, true >
40 {
41 using type = S< C >;
42 };
43
44 template< typename T, std::size_t S >
45 struct string_max_length
46 {
47 static_assert( S <= 512, "String longer than 512 (excluding terminating \\0)!" );
48 using type = T;
49 };
50
51 } // namespace internal
52
53 } // namespace TAOCPP_PEGTL_NAMESPACE
54
55} // namespace tao
56
57#define TAOCPP_PEGTL_INTERNAL_EMPTY()
58#define TAOCPP_PEGTL_INTERNAL_DEFER( X ) X TAOCPP_PEGTL_INTERNAL_EMPTY()
59#define TAOCPP_PEGTL_INTERNAL_EXPAND( ... ) __VA_ARGS__
60
61#define TAOCPP_PEGTL_INTERNAL_STRING_AT( S, x, n ) \
62 tao::TAOCPP_PEGTL_NAMESPACE::internal::string_at< S, ( 0##n < sizeof( x ) ) ? x[ 0##n ] : 0, ( 0##n < sizeof( x ) - 1 ) >::type
63
64#define TAOCPP_PEGTL_INTERNAL_JOIN_8( M, S, x, n ) \
65 tao::TAOCPP_PEGTL_NAMESPACE::internal::string_join< TAOCPP_PEGTL_INTERNAL_DEFER( M )( S, x, n##0 ), \
66 TAOCPP_PEGTL_INTERNAL_DEFER( M )( S, x, n##1 ), \
67 TAOCPP_PEGTL_INTERNAL_DEFER( M )( S, x, n##2 ), \
68 TAOCPP_PEGTL_INTERNAL_DEFER( M )( S, x, n##3 ), \
69 TAOCPP_PEGTL_INTERNAL_DEFER( M )( S, x, n##4 ), \
70 TAOCPP_PEGTL_INTERNAL_DEFER( M )( S, x, n##5 ), \
71 TAOCPP_PEGTL_INTERNAL_DEFER( M )( S, x, n##6 ), \
72 TAOCPP_PEGTL_INTERNAL_DEFER( M )( S, x, n##7 ) >::type
73
74#define TAOCPP_PEGTL_INTERNAL_STRING_8( S, x, n ) \
75 TAOCPP_PEGTL_INTERNAL_JOIN_8( TAOCPP_PEGTL_INTERNAL_STRING_AT, S, x, n )
76
77#define TAOCPP_PEGTL_INTERNAL_STRING_64( S, x, n ) \
78 TAOCPP_PEGTL_INTERNAL_JOIN_8( TAOCPP_PEGTL_INTERNAL_STRING_8, S, x, n )
79
80#define TAOCPP_PEGTL_INTERNAL_STRING_512( S, x, n ) \
81 TAOCPP_PEGTL_INTERNAL_JOIN_8( TAOCPP_PEGTL_INTERNAL_STRING_64, S, x, n )
82
83#define TAOCPP_PEGTL_INTERNAL_STRING( S, x ) \
84 TAOCPP_PEGTL_INTERNAL_EXPAND( \
85 TAOCPP_PEGTL_INTERNAL_EXPAND( \
86 TAOCPP_PEGTL_INTERNAL_EXPAND( \
87 tao::TAOCPP_PEGTL_NAMESPACE::internal::string_max_length< TAOCPP_PEGTL_INTERNAL_STRING_512( S, x, ), sizeof( x ) - 1 >::type ) ) )
88
89#define TAOCPP_PEGTL_STRING( x ) \
90 TAOCPP_PEGTL_INTERNAL_STRING( tao::TAOCPP_PEGTL_NAMESPACE::ascii::string, x )
91
92#define TAOCPP_PEGTL_ISTRING( x ) \
93 TAOCPP_PEGTL_INTERNAL_STRING( tao::TAOCPP_PEGTL_NAMESPACE::ascii::istring, x )
94
95#define TAOCPP_PEGTL_KEYWORD( x ) \
96 TAOCPP_PEGTL_INTERNAL_STRING( tao::TAOCPP_PEGTL_NAMESPACE::ascii::keyword, x )
97
98#endif
diff --git a/MoonParser/pegtl/internal/plus.hpp b/MoonParser/pegtl/internal/plus.hpp
new file mode 100644
index 0000000..5adc1f8
--- /dev/null
+++ b/MoonParser/pegtl/internal/plus.hpp
@@ -0,0 +1,61 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_PLUS_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_PLUS_HPP
6
7#include <type_traits>
8
9#include "../config.hpp"
10
11#include "duseltronik.hpp"
12#include "opt.hpp"
13#include "seq.hpp"
14#include "skip_control.hpp"
15#include "star.hpp"
16
17#include "../apply_mode.hpp"
18#include "../rewind_mode.hpp"
19
20#include "../analysis/generic.hpp"
21
22namespace tao
23{
24 namespace TAOCPP_PEGTL_NAMESPACE
25 {
26 namespace internal
27 {
28 // While plus<> could easily be implemented with
29 // seq< Rule, Rules ..., star< Rule, Rules ... > > we
30 // provide an explicit implementation to optimise away
31 // the otherwise created input mark.
32
33 template< typename Rule, typename... Rules >
34 struct plus
35 {
36 using analyze_t = analysis::generic< analysis::rule_type::SEQ, Rule, Rules..., opt< plus > >;
37
38 template< apply_mode A,
39 rewind_mode M,
40 template< typename... > class Action,
41 template< typename... > class Control,
42 typename Input,
43 typename... States >
44 static bool match( Input& in, States&&... st )
45 {
46 return duseltronik< seq< Rule, Rules... >, A, M, Action, Control >::match( in, st... ) && duseltronik< star< Rule, Rules... >, A, M, Action, Control >::match( in, st... );
47 }
48 };
49
50 template< typename Rule, typename... Rules >
51 struct skip_control< plus< Rule, Rules... > > : std::true_type
52 {
53 };
54
55 } // namespace internal
56
57 } // namespace TAOCPP_PEGTL_NAMESPACE
58
59} // namespace tao
60
61#endif
diff --git a/MoonParser/pegtl/internal/raise.hpp b/MoonParser/pegtl/internal/raise.hpp
new file mode 100644
index 0000000..d183ce0
--- /dev/null
+++ b/MoonParser/pegtl/internal/raise.hpp
@@ -0,0 +1,57 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_RAISE_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_RAISE_HPP
6
7#include <cstdlib>
8#include <type_traits>
9
10#include "../config.hpp"
11
12#include "skip_control.hpp"
13
14#include "../analysis/generic.hpp"
15#include "../apply_mode.hpp"
16#include "../rewind_mode.hpp"
17
18namespace tao
19{
20 namespace TAOCPP_PEGTL_NAMESPACE
21 {
22 namespace internal
23 {
24 template< typename T >
25 struct raise
26 {
27 using analyze_t = analysis::generic< analysis::rule_type::ANY >;
28
29 template< apply_mode,
30 rewind_mode,
31 template< typename... > class Action,
32 template< typename... > class Control,
33 typename Input,
34 typename... States >
35 static bool match( Input& in, States&&... st )
36 {
37 Control< T >::raise( const_cast< const Input& >( in ), st... );
38#if defined( _MSC_VER )
39 __assume( false ); // LCOV_EXCL_LINE
40#else
41 std::abort(); // LCOV_EXCL_LINE
42#endif
43 }
44 };
45
46 template< typename T >
47 struct skip_control< raise< T > > : std::true_type
48 {
49 };
50
51 } // namespace internal
52
53 } // namespace TAOCPP_PEGTL_NAMESPACE
54
55} // namespace tao
56
57#endif
diff --git a/MoonParser/pegtl/internal/range.hpp b/MoonParser/pegtl/internal/range.hpp
new file mode 100644
index 0000000..227595f
--- /dev/null
+++ b/MoonParser/pegtl/internal/range.hpp
@@ -0,0 +1,60 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_RANGE_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_RANGE_HPP
6
7#include "../config.hpp"
8
9#include "bump_help.hpp"
10#include "result_on_found.hpp"
11#include "skip_control.hpp"
12
13#include "../analysis/generic.hpp"
14
15namespace tao
16{
17 namespace TAOCPP_PEGTL_NAMESPACE
18 {
19 namespace internal
20 {
21 template< result_on_found R, typename Peek, typename Peek::data_t Lo, typename Peek::data_t Hi >
22 struct range
23 {
24 using analyze_t = analysis::generic< analysis::rule_type::ANY >;
25
26 template< int Eol >
27 struct can_match_eol
28 {
29 static constexpr bool value = ( ( ( Lo <= Eol ) && ( Eol <= Hi ) ) == bool( R ) );
30 };
31
32 template< typename Input >
33 static bool match( Input& in )
34 {
35 using eol_t = typename Input::eol_t;
36
37 if( !in.empty() ) {
38 if( const auto t = Peek::peek( in ) ) {
39 if( ( ( Lo <= t.data ) && ( t.data <= Hi ) ) == bool( R ) ) {
40 bump_impl< can_match_eol< eol_t::ch >::value >::bump( in, t.size );
41 return true;
42 }
43 }
44 }
45 return false;
46 }
47 };
48
49 template< result_on_found R, typename Peek, typename Peek::data_t Lo, typename Peek::data_t Hi >
50 struct skip_control< range< R, Peek, Lo, Hi > > : std::true_type
51 {
52 };
53
54 } // namespace internal
55
56 } // namespace TAOCPP_PEGTL_NAMESPACE
57
58} // namespace tao
59
60#endif
diff --git a/MoonParser/pegtl/internal/ranges.hpp b/MoonParser/pegtl/internal/ranges.hpp
new file mode 100644
index 0000000..e3ee65c
--- /dev/null
+++ b/MoonParser/pegtl/internal/ranges.hpp
@@ -0,0 +1,102 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_RANGES_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_RANGES_HPP
6
7#include "../config.hpp"
8
9#include "bump_help.hpp"
10#include "range.hpp"
11#include "skip_control.hpp"
12
13#include "../analysis/generic.hpp"
14
15namespace tao
16{
17 namespace TAOCPP_PEGTL_NAMESPACE
18 {
19 namespace internal
20 {
21 template< int Eol, typename Char, Char... Cs >
22 struct ranges_impl;
23
24 template< int Eol, typename Char >
25 struct ranges_impl< Eol, Char >
26 {
27 static constexpr bool can_match_eol = false;
28
29 static bool match( const Char ) noexcept
30 {
31 return false;
32 }
33 };
34
35 template< int Eol, typename Char, Char Eq >
36 struct ranges_impl< Eol, Char, Eq >
37 {
38 static constexpr bool can_match_eol = ( Eq == Eol );
39
40 static bool match( const Char c ) noexcept
41 {
42 return c == Eq;
43 }
44 };
45
46 template< int Eol, typename Char, Char Lo, Char Hi, Char... Cs >
47 struct ranges_impl< Eol, Char, Lo, Hi, Cs... >
48 {
49 static constexpr bool can_match_eol = ( ( ( Lo <= Eol ) && ( Eol <= Hi ) ) || ranges_impl< Eol, Char, Cs... >::can_match_eol );
50
51 static bool match( const Char c ) noexcept
52 {
53 return ( ( Lo <= c ) && ( c <= Hi ) ) || ranges_impl< Eol, Char, Cs... >::match( c );
54 }
55 };
56
57 template< typename Peek, typename Peek::data_t... Cs >
58 struct ranges
59 {
60 using analyze_t = analysis::generic< analysis::rule_type::ANY >;
61
62 template< int Eol >
63 struct can_match_eol
64 {
65 static constexpr bool value = ranges_impl< Eol, typename Peek::data_t, Cs... >::can_match_eol;
66 };
67
68 template< typename Input >
69 static bool match( Input& in )
70 {
71 using eol_t = typename Input::eol_t;
72
73 if( !in.empty() ) {
74 if( const auto t = Peek::peek( in ) ) {
75 if( ranges_impl< eol_t::ch, typename Peek::data_t, Cs... >::match( t.data ) ) {
76 bump_impl< can_match_eol< eol_t::ch >::value >::bump( in, t.size );
77 return true;
78 }
79 }
80 }
81 return false;
82 }
83 };
84
85 template< typename Peek, typename Peek::data_t Lo, typename Peek::data_t Hi >
86 struct ranges< Peek, Lo, Hi >
87 : range< result_on_found::SUCCESS, Peek, Lo, Hi >
88 {
89 };
90
91 template< typename Peek, typename Peek::data_t... Cs >
92 struct skip_control< ranges< Peek, Cs... > > : std::true_type
93 {
94 };
95
96 } // namespace internal
97
98 } // namespace TAOCPP_PEGTL_NAMESPACE
99
100} // namespace tao
101
102#endif
diff --git a/MoonParser/pegtl/internal/rep.hpp b/MoonParser/pegtl/internal/rep.hpp
new file mode 100644
index 0000000..df66ee2
--- /dev/null
+++ b/MoonParser/pegtl/internal/rep.hpp
@@ -0,0 +1,75 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_REP_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_REP_HPP
6
7#include "../config.hpp"
8
9#include "rule_conjunction.hpp"
10#include "skip_control.hpp"
11#include "trivial.hpp"
12
13#include "../apply_mode.hpp"
14#include "../rewind_mode.hpp"
15
16#include "../analysis/counted.hpp"
17
18namespace tao
19{
20 namespace TAOCPP_PEGTL_NAMESPACE
21 {
22 namespace internal
23 {
24 template< unsigned Num, typename... Rules >
25 struct rep;
26
27 template< unsigned Num >
28 struct rep< Num >
29 : trivial< true >
30 {
31 };
32
33 template< typename Rule, typename... Rules >
34 struct rep< 0, Rule, Rules... >
35 : trivial< true >
36 {
37 };
38
39 template< unsigned Num, typename... Rules >
40 struct rep
41 {
42 using analyze_t = analysis::counted< analysis::rule_type::SEQ, Num, Rules... >;
43
44 template< apply_mode A,
45 rewind_mode M,
46 template< typename... > class Action,
47 template< typename... > class Control,
48 typename Input,
49 typename... States >
50 static bool match( Input& in, States&&... st )
51 {
52 auto m = in.template mark< M >();
53 using m_t = decltype( m );
54
55 for( unsigned i = 0; i != Num; ++i ) {
56 if( !rule_conjunction< Rules... >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ) {
57 return false;
58 }
59 }
60 return m( true );
61 }
62 };
63
64 template< unsigned Num, typename... Rules >
65 struct skip_control< rep< Num, Rules... > > : std::true_type
66 {
67 };
68
69 } // namespace internal
70
71 } // namespace TAOCPP_PEGTL_NAMESPACE
72
73} // namespace tao
74
75#endif
diff --git a/MoonParser/pegtl/internal/rep_min.hpp b/MoonParser/pegtl/internal/rep_min.hpp
new file mode 100644
index 0000000..f5e61da
--- /dev/null
+++ b/MoonParser/pegtl/internal/rep_min.hpp
@@ -0,0 +1,28 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_REP_MIN_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_REP_MIN_HPP
6
7#include "../config.hpp"
8
9#include "rep.hpp"
10#include "seq.hpp"
11#include "star.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 namespace internal
18 {
19 template< unsigned Min, typename Rule, typename... Rules >
20 using rep_min = seq< rep< Min, Rule, Rules... >, star< Rule, Rules... > >;
21
22 } // namespace internal
23
24 } // namespace TAOCPP_PEGTL_NAMESPACE
25
26} // namespace tao
27
28#endif
diff --git a/MoonParser/pegtl/internal/rep_min_max.hpp b/MoonParser/pegtl/internal/rep_min_max.hpp
new file mode 100644
index 0000000..7463398
--- /dev/null
+++ b/MoonParser/pegtl/internal/rep_min_max.hpp
@@ -0,0 +1,88 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_REP_MIN_MAX_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_REP_MIN_MAX_HPP
6
7#include <type_traits>
8
9#include "../config.hpp"
10
11#include "duseltronik.hpp"
12#include "not_at.hpp"
13#include "rule_conjunction.hpp"
14#include "seq.hpp"
15#include "skip_control.hpp"
16#include "trivial.hpp"
17
18#include "../apply_mode.hpp"
19#include "../rewind_mode.hpp"
20
21#include "../analysis/counted.hpp"
22
23namespace tao
24{
25 namespace TAOCPP_PEGTL_NAMESPACE
26 {
27 namespace internal
28 {
29 template< unsigned Min, unsigned Max, typename... Rules >
30 struct rep_min_max;
31
32 template< unsigned Min, unsigned Max >
33 struct rep_min_max< Min, Max >
34 : trivial< false >
35 {
36 static_assert( Min <= Max, "invalid rep_min_max rule (maximum number of repetitions smaller than minimum)" );
37 };
38
39 template< typename Rule, typename... Rules >
40 struct rep_min_max< 0, 0, Rule, Rules... >
41 : not_at< Rule, Rules... >
42 {
43 };
44
45 template< unsigned Min, unsigned Max, typename... Rules >
46 struct rep_min_max
47 {
48 using analyze_t = analysis::counted< analysis::rule_type::SEQ, Min, Rules... >;
49
50 static_assert( Min <= Max, "invalid rep_min_max rule (maximum number of repetitions smaller than minimum)" );
51
52 template< apply_mode A,
53 rewind_mode M,
54 template< typename... > class Action,
55 template< typename... > class Control,
56 typename Input,
57 typename... States >
58 static bool match( Input& in, States&&... st )
59 {
60 auto m = in.template mark< M >();
61 using m_t = decltype( m );
62
63 for( unsigned i = 0; i != Min; ++i ) {
64 if( !rule_conjunction< Rules... >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ) {
65 return false;
66 }
67 }
68 for( unsigned i = Min; i != Max; ++i ) {
69 if( !duseltronik< seq< Rules... >, A, rewind_mode::REQUIRED, Action, Control >::match( in, st... ) ) {
70 return m( true );
71 }
72 }
73 return m( duseltronik< not_at< Rules... >, A, m_t::next_rewind_mode, Action, Control >::match( in, st... ) ); // NOTE that not_at<> will always rewind.
74 }
75 };
76
77 template< unsigned Min, unsigned Max, typename... Rules >
78 struct skip_control< rep_min_max< Min, Max, Rules... > > : std::true_type
79 {
80 };
81
82 } // namespace internal
83
84 } // namespace TAOCPP_PEGTL_NAMESPACE
85
86} // namespace tao
87
88#endif
diff --git a/MoonParser/pegtl/internal/rep_opt.hpp b/MoonParser/pegtl/internal/rep_opt.hpp
new file mode 100644
index 0000000..55bcd47
--- /dev/null
+++ b/MoonParser/pegtl/internal/rep_opt.hpp
@@ -0,0 +1,54 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_REP_OPT_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_REP_OPT_HPP
6
7#include "../config.hpp"
8
9#include "duseltronik.hpp"
10#include "seq.hpp"
11#include "skip_control.hpp"
12
13#include "../apply_mode.hpp"
14#include "../rewind_mode.hpp"
15
16#include "../analysis/generic.hpp"
17
18namespace tao
19{
20 namespace TAOCPP_PEGTL_NAMESPACE
21 {
22 namespace internal
23 {
24 template< unsigned Max, typename... Rules >
25 struct rep_opt
26 {
27 using analyze_t = analysis::generic< analysis::rule_type::OPT, Rules... >;
28
29 template< apply_mode A,
30 rewind_mode,
31 template< typename... > class Action,
32 template< typename... > class Control,
33 typename Input,
34 typename... States >
35 static bool match( Input& in, States&&... st )
36 {
37 for( unsigned i = 0; ( i != Max ) && duseltronik< seq< Rules... >, A, rewind_mode::REQUIRED, Action, Control >::match( in, st... ); ++i ) {
38 }
39 return true;
40 }
41 };
42
43 template< unsigned Max, typename... Rules >
44 struct skip_control< rep_opt< Max, Rules... > > : std::true_type
45 {
46 };
47
48 } // namespace internal
49
50 } // namespace TAOCPP_PEGTL_NAMESPACE
51
52} // namespace tao
53
54#endif
diff --git a/MoonParser/pegtl/internal/require.hpp b/MoonParser/pegtl/internal/require.hpp
new file mode 100644
index 0000000..0506356
--- /dev/null
+++ b/MoonParser/pegtl/internal/require.hpp
@@ -0,0 +1,52 @@
1// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_REQUIRE_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_REQUIRE_HPP
6
7#include "../config.hpp"
8
9#include "skip_control.hpp"
10#include "trivial.hpp"
11
12#include "../analysis/generic.hpp"
13
14namespace tao
15{
16 namespace TAOCPP_PEGTL_NAMESPACE
17 {
18 namespace internal
19 {
20 template< unsigned Amount >
21 struct require;
22
23 template<>
24 struct require< 0 >
25 : trivial< true >
26 {
27 };
28
29 template< unsigned Amount >
30 struct require
31 {
32 using analyze_t = analysis::generic< analysis::rule_type::OPT >;
33
34 template< typename Input >
35 static bool match( Input& in )
36 {
37 return in.size( Amount ) >= Amount;
38 }
39 };
40
41 template< unsigned Amount >
42 struct skip_control< require< Amount > > : std::true_type
43 {
44 };
45
46 } // namespace internal
47
48 } // namespace TAOCPP_PEGTL_NAMESPACE
49
50} // namespace tao
51
52#endif
diff --git a/MoonParser/pegtl/internal/result_on_found.hpp b/MoonParser/pegtl/internal/result_on_found.hpp
new file mode 100644
index 0000000..e41f35c
--- /dev/null
+++ b/MoonParser/pegtl/internal/result_on_found.hpp
@@ -0,0 +1,27 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_RESULT_ON_FOUND_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_RESULT_ON_FOUND_HPP
6
7#include "../config.hpp"
8
9namespace tao
10{
11 namespace TAOCPP_PEGTL_NAMESPACE
12 {
13 namespace internal
14 {
15 enum class result_on_found : bool
16 {
17 SUCCESS = true,
18 FAILURE = false
19 };
20
21 } // namespace internal
22
23 } // namespace TAOCPP_PEGTL_NAMESPACE
24
25} // namespace tao
26
27#endif
diff --git a/MoonParser/pegtl/internal/rule_conjunction.hpp b/MoonParser/pegtl/internal/rule_conjunction.hpp
new file mode 100644
index 0000000..2eb41e2
--- /dev/null
+++ b/MoonParser/pegtl/internal/rule_conjunction.hpp
@@ -0,0 +1,63 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_RULE_CONJUNCTION_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_RULE_CONJUNCTION_HPP
6
7#include "../apply_mode.hpp"
8#include "../config.hpp"
9#include "../rewind_mode.hpp"
10
11namespace tao
12{
13 namespace TAOCPP_PEGTL_NAMESPACE
14 {
15 namespace internal
16 {
17 template< typename... Rules >
18 struct rule_conjunction;
19
20 template<>
21 struct rule_conjunction<>
22 {
23 template< apply_mode A,
24 rewind_mode M,
25 template< typename... > class Action,
26 template< typename... > class Control,
27 typename Input,
28 typename... States >
29 static bool match( Input&, States&&... )
30 {
31 return true;
32 }
33 };
34
35 template< typename... Rules >
36 struct rule_conjunction
37 {
38 template< apply_mode A,
39 rewind_mode M,
40 template< typename... > class Action,
41 template< typename... > class Control,
42 typename Input,
43 typename... States >
44 static bool match( Input& in, States&&... st )
45 {
46#ifdef __cpp_fold_expressions
47 return ( Control< Rules >::template match< A, M, Action, Control >( in, st... ) && ... );
48#else
49 bool result = true;
50 using swallow = bool[];
51 (void)swallow{ result = result && Control< Rules >::template match< A, M, Action, Control >( in, st... )... };
52 return result;
53#endif
54 }
55 };
56
57 } // namespace internal
58
59 } // namespace TAOCPP_PEGTL_NAMESPACE
60
61} // namespace tao
62
63#endif
diff --git a/MoonParser/pegtl/internal/rules.hpp b/MoonParser/pegtl/internal/rules.hpp
new file mode 100644
index 0000000..91725ae
--- /dev/null
+++ b/MoonParser/pegtl/internal/rules.hpp
@@ -0,0 +1,61 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_RULES_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_RULES_HPP
6
7#include "action.hpp"
8#include "alnum.hpp"
9#include "alpha.hpp"
10#include "any.hpp"
11#include "apply.hpp"
12#include "apply0.hpp"
13#include "at.hpp"
14#include "bof.hpp"
15#include "bol.hpp"
16#include "bytes.hpp"
17#include "control.hpp"
18#include "disable.hpp"
19#include "discard.hpp"
20#include "enable.hpp"
21#include "eof.hpp"
22#include "eol.hpp"
23#include "eolf.hpp"
24#include "identifier.hpp"
25#include "if_apply.hpp"
26#include "if_must.hpp"
27#include "if_must_else.hpp"
28#include "if_then_else.hpp"
29#include "istring.hpp"
30#include "list.hpp"
31#include "list_must.hpp"
32#include "list_tail.hpp"
33#include "list_tail_pad.hpp"
34#include "minus.hpp"
35#include "must.hpp"
36#include "not_at.hpp"
37#include "one.hpp"
38#include "opt.hpp"
39#include "pad.hpp"
40#include "pad_opt.hpp"
41#include "plus.hpp"
42#include "raise.hpp"
43#include "range.hpp"
44#include "ranges.hpp"
45#include "rep.hpp"
46#include "rep_min.hpp"
47#include "rep_min_max.hpp"
48#include "rep_opt.hpp"
49#include "require.hpp"
50#include "seq.hpp"
51#include "skip_control.hpp"
52#include "sor.hpp"
53#include "star.hpp"
54#include "star_must.hpp"
55#include "state.hpp"
56#include "string.hpp"
57#include "trivial.hpp"
58#include "try_catch_type.hpp"
59#include "until.hpp"
60
61#endif
diff --git a/MoonParser/pegtl/internal/seq.hpp b/MoonParser/pegtl/internal/seq.hpp
new file mode 100644
index 0000000..f99cc7c
--- /dev/null
+++ b/MoonParser/pegtl/internal/seq.hpp
@@ -0,0 +1,80 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_SEQ_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_SEQ_HPP
6
7#include "../config.hpp"
8
9#include "rule_conjunction.hpp"
10#include "skip_control.hpp"
11#include "trivial.hpp"
12
13#include "../apply_mode.hpp"
14#include "../rewind_mode.hpp"
15
16#include "../analysis/generic.hpp"
17
18namespace tao
19{
20 namespace TAOCPP_PEGTL_NAMESPACE
21 {
22 namespace internal
23 {
24 template< typename... Rules >
25 struct seq;
26
27 template<>
28 struct seq<>
29 : trivial< true >
30 {
31 };
32
33 template< typename Rule >
34 struct seq< Rule >
35 {
36 using analyze_t = typename Rule::analyze_t;
37
38 template< apply_mode A,
39 rewind_mode M,
40 template< typename... > class Action,
41 template< typename... > class Control,
42 typename Input,
43 typename... States >
44 static bool match( Input& in, States&&... st )
45 {
46 return Control< Rule >::template match< A, M, Action, Control >( in, st... );
47 }
48 };
49
50 template< typename... Rules >
51 struct seq
52 {
53 using analyze_t = analysis::generic< analysis::rule_type::SEQ, Rules... >;
54
55 template< apply_mode A,
56 rewind_mode M,
57 template< typename... > class Action,
58 template< typename... > class Control,
59 typename Input,
60 typename... States >
61 static bool match( Input& in, States&&... st )
62 {
63 auto m = in.template mark< M >();
64 using m_t = decltype( m );
65 return m( rule_conjunction< Rules... >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) );
66 }
67 };
68
69 template< typename... Rules >
70 struct skip_control< seq< Rules... > > : std::true_type
71 {
72 };
73
74 } // namespace internal
75
76 } // namespace TAOCPP_PEGTL_NAMESPACE
77
78} // namespace tao
79
80#endif
diff --git a/MoonParser/pegtl/internal/skip_control.hpp b/MoonParser/pegtl/internal/skip_control.hpp
new file mode 100644
index 0000000..e40ace5
--- /dev/null
+++ b/MoonParser/pegtl/internal/skip_control.hpp
@@ -0,0 +1,35 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_SKIP_CONTROL_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_SKIP_CONTROL_HPP
6
7#include <type_traits>
8
9#include "../config.hpp"
10
11namespace tao
12{
13 namespace TAOCPP_PEGTL_NAMESPACE
14 {
15 namespace internal
16 {
17 // This class is a simple tagging mechanism.
18 // By default, skip_control< Rule >::value
19 // is 'false'. Each internal (!) rule that should
20 // be hidden from the control and action class'
21 // callbacks simply specializes skip_control<>
22 // to return 'true' for the above expression.
23
24 template< typename Rule >
25 struct skip_control : std::false_type
26 {
27 };
28
29 } // namespace internal
30
31 } // namespace TAOCPP_PEGTL_NAMESPACE
32
33} // namespace tao
34
35#endif
diff --git a/MoonParser/pegtl/internal/sor.hpp b/MoonParser/pegtl/internal/sor.hpp
new file mode 100644
index 0000000..6d85a5c
--- /dev/null
+++ b/MoonParser/pegtl/internal/sor.hpp
@@ -0,0 +1,74 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_SOR_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_SOR_HPP
6
7#include "../config.hpp"
8
9#include "skip_control.hpp"
10
11#include "../apply_mode.hpp"
12#include "../rewind_mode.hpp"
13
14#include "../analysis/generic.hpp"
15
16#include "integer_sequence.hpp"
17
18namespace tao
19{
20 namespace TAOCPP_PEGTL_NAMESPACE
21 {
22 namespace internal
23 {
24 template< typename... Rules >
25 struct sor;
26
27 template<>
28 struct sor<>
29 : trivial< false >
30 {
31 };
32
33 template< typename... Rules >
34 struct sor
35 : sor< index_sequence_for< Rules... >, Rules... >
36 {
37 };
38
39 template< std::size_t... Indices, typename... Rules >
40 struct sor< index_sequence< Indices... >, Rules... >
41 {
42 using analyze_t = analysis::generic< analysis::rule_type::SOR, Rules... >;
43
44 template< apply_mode A,
45 rewind_mode M,
46 template< typename... > class Action,
47 template< typename... > class Control,
48 typename Input,
49 typename... States >
50 static bool match( Input& in, States&&... st )
51 {
52#ifdef __cpp_fold_expressions
53 return ( Control< Rules >::template match < A, ( Indices == ( sizeof...( Rules ) - 1 ) ) ? M : rewind_mode::REQUIRED, Action, Control > ( in, st... ) || ... );
54#else
55 bool result = false;
56 using swallow = bool[];
57 (void)swallow{ result = result || Control< Rules >::template match < A, ( Indices == ( sizeof...( Rules ) - 1 ) ) ? M : rewind_mode::REQUIRED, Action, Control > ( in, st... )... };
58 return result;
59#endif
60 }
61 };
62
63 template< typename... Rules >
64 struct skip_control< sor< Rules... > > : std::true_type
65 {
66 };
67
68 } // namespace internal
69
70 } // namespace TAOCPP_PEGTL_NAMESPACE
71
72} // namespace tao
73
74#endif
diff --git a/MoonParser/pegtl/internal/star.hpp b/MoonParser/pegtl/internal/star.hpp
new file mode 100644
index 0000000..854f25f
--- /dev/null
+++ b/MoonParser/pegtl/internal/star.hpp
@@ -0,0 +1,56 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_STAR_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_STAR_HPP
6
7#include <type_traits>
8
9#include "../config.hpp"
10
11#include "duseltronik.hpp"
12#include "seq.hpp"
13#include "skip_control.hpp"
14
15#include "../apply_mode.hpp"
16#include "../rewind_mode.hpp"
17
18#include "../analysis/generic.hpp"
19
20namespace tao
21{
22 namespace TAOCPP_PEGTL_NAMESPACE
23 {
24 namespace internal
25 {
26 template< typename Rule, typename... Rules >
27 struct star
28 {
29 using analyze_t = analysis::generic< analysis::rule_type::OPT, Rule, Rules..., star >;
30
31 template< apply_mode A,
32 rewind_mode,
33 template< typename... > class Action,
34 template< typename... > class Control,
35 typename Input,
36 typename... States >
37 static bool match( Input& in, States&&... st )
38 {
39 while( duseltronik< seq< Rule, Rules... >, A, rewind_mode::REQUIRED, Action, Control >::match( in, st... ) ) {
40 }
41 return true;
42 }
43 };
44
45 template< typename Rule, typename... Rules >
46 struct skip_control< star< Rule, Rules... > > : std::true_type
47 {
48 };
49
50 } // namespace internal
51
52 } // namespace TAOCPP_PEGTL_NAMESPACE
53
54} // namespace tao
55
56#endif
diff --git a/MoonParser/pegtl/internal/star_must.hpp b/MoonParser/pegtl/internal/star_must.hpp
new file mode 100644
index 0000000..baaef4f
--- /dev/null
+++ b/MoonParser/pegtl/internal/star_must.hpp
@@ -0,0 +1,27 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_STAR_MUST_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_STAR_MUST_HPP
6
7#include "../config.hpp"
8
9#include "if_must.hpp"
10#include "star.hpp"
11
12namespace tao
13{
14 namespace TAOCPP_PEGTL_NAMESPACE
15 {
16 namespace internal
17 {
18 template< typename Cond, typename... Rules >
19 using star_must = star< if_must< Cond, Rules... > >;
20
21 } // namespace internal
22
23 } // namespace TAOCPP_PEGTL_NAMESPACE
24
25} // namespace tao
26
27#endif
diff --git a/MoonParser/pegtl/internal/state.hpp b/MoonParser/pegtl/internal/state.hpp
new file mode 100644
index 0000000..7fbe921
--- /dev/null
+++ b/MoonParser/pegtl/internal/state.hpp
@@ -0,0 +1,83 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_STATE_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_STATE_HPP
6
7#include "../config.hpp"
8
9#include "duseltronik.hpp"
10#include "seq.hpp"
11#include "skip_control.hpp"
12
13#include "../apply_mode.hpp"
14#include "../rewind_mode.hpp"
15
16#include "../analysis/generic.hpp"
17
18namespace tao
19{
20 namespace TAOCPP_PEGTL_NAMESPACE
21 {
22 namespace internal
23 {
24 template< typename State, typename... Rules >
25 struct state
26 {
27 using analyze_t = analysis::generic< analysis::rule_type::SEQ, Rules... >;
28
29 template< apply_mode A,
30 rewind_mode M,
31 template< typename... > class Action,
32 template< typename... > class Control,
33 typename Input,
34 typename... States >
35 static auto success( State& s, const Input& in, States&&... st ) -> decltype( s.template success< A, M, Action, Control >( in, st... ), void() )
36 {
37 s.template success< A, M, Action, Control >( in, st... );
38 }
39
40 // NOTE: The additional "int = 0" is a work-around for missing expression SFINAE in VS2015.
41
42 template< apply_mode,
43 rewind_mode,
44 template< typename... > class Action,
45 template< typename... > class Control,
46 typename Input,
47 typename... States,
48 int = 0 >
49 static auto success( State& s, const Input& in, States&&... st ) -> decltype( s.success( in, st... ), void() )
50 {
51 s.success( in, st... );
52 }
53
54 template< apply_mode A,
55 rewind_mode M,
56 template< typename... > class Action,
57 template< typename... > class Control,
58 typename Input,
59 typename... States >
60 static bool match( Input& in, States&&... st )
61 {
62 State s( const_cast< const Input& >( in ), st... );
63
64 if( duseltronik< seq< Rules... >, A, M, Action, Control >::match( in, s ) ) {
65 success< A, M, Action, Control >( s, in, st... );
66 return true;
67 }
68 return false;
69 }
70 };
71
72 template< typename State, typename... Rules >
73 struct skip_control< state< State, Rules... > > : std::true_type
74 {
75 };
76
77 } // namespace internal
78
79 } // namespace TAOCPP_PEGTL_NAMESPACE
80
81} // namespace tao
82
83#endif
diff --git a/MoonParser/pegtl/internal/string.hpp b/MoonParser/pegtl/internal/string.hpp
new file mode 100644
index 0000000..75245e3
--- /dev/null
+++ b/MoonParser/pegtl/internal/string.hpp
@@ -0,0 +1,68 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_STRING_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_STRING_HPP
6
7#include <cstring>
8#include <utility>
9
10#include "../config.hpp"
11
12#include "bump_help.hpp"
13#include "result_on_found.hpp"
14#include "skip_control.hpp"
15#include "trivial.hpp"
16
17#include "../analysis/counted.hpp"
18
19namespace tao
20{
21 namespace TAOCPP_PEGTL_NAMESPACE
22 {
23 namespace internal
24 {
25 inline bool unsafe_equals( const char* s, const std::initializer_list< char >& l ) noexcept
26 {
27 return std::memcmp( s, &*l.begin(), l.size() ) == 0;
28 }
29
30 template< char... Cs >
31 struct string;
32
33 template<>
34 struct string<>
35 : trivial< true >
36 {
37 };
38
39 template< char... Cs >
40 struct string
41 {
42 using analyze_t = analysis::counted< analysis::rule_type::ANY, sizeof...( Cs ) >;
43
44 template< typename Input >
45 static bool match( Input& in )
46 {
47 if( in.size( sizeof...( Cs ) ) >= sizeof...( Cs ) ) {
48 if( unsafe_equals( in.current(), { Cs... } ) ) {
49 bump_help< result_on_found::SUCCESS, Input, char, Cs... >( in, sizeof...( Cs ) );
50 return true;
51 }
52 }
53 return false;
54 }
55 };
56
57 template< char... Cs >
58 struct skip_control< string< Cs... > > : std::true_type
59 {
60 };
61
62 } // namespace internal
63
64 } // namespace TAOCPP_PEGTL_NAMESPACE
65
66} // namespace tao
67
68#endif
diff --git a/MoonParser/pegtl/internal/trivial.hpp b/MoonParser/pegtl/internal/trivial.hpp
new file mode 100644
index 0000000..3416175
--- /dev/null
+++ b/MoonParser/pegtl/internal/trivial.hpp
@@ -0,0 +1,42 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_TRIVIAL_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_TRIVIAL_HPP
6
7#include "../config.hpp"
8
9#include "skip_control.hpp"
10
11#include "../analysis/counted.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 namespace internal
18 {
19 template< bool Result >
20 struct trivial
21 {
22 using analyze_t = analysis::counted< analysis::rule_type::ANY, unsigned( !Result ) >;
23
24 template< typename Input >
25 static bool match( Input& ) noexcept
26 {
27 return Result;
28 }
29 };
30
31 template< bool Result >
32 struct skip_control< trivial< Result > > : std::true_type
33 {
34 };
35
36 } // namespace internal
37
38 } // namespace TAOCPP_PEGTL_NAMESPACE
39
40} // namespace tao
41
42#endif
diff --git a/MoonParser/pegtl/internal/try_catch_type.hpp b/MoonParser/pegtl/internal/try_catch_type.hpp
new file mode 100644
index 0000000..83fddb4
--- /dev/null
+++ b/MoonParser/pegtl/internal/try_catch_type.hpp
@@ -0,0 +1,72 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_TRY_CATCH_TYPE_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_TRY_CATCH_TYPE_HPP
6
7#include <type_traits>
8
9#include "../config.hpp"
10
11#include "duseltronik.hpp"
12#include "seq.hpp"
13#include "skip_control.hpp"
14#include "trivial.hpp"
15
16#include "../apply_mode.hpp"
17#include "../rewind_mode.hpp"
18
19#include "../analysis/generic.hpp"
20
21namespace tao
22{
23 namespace TAOCPP_PEGTL_NAMESPACE
24 {
25 namespace internal
26 {
27 template< typename Exception, typename... Rules >
28 struct try_catch_type;
29
30 template< typename Exception >
31 struct try_catch_type< Exception >
32 : trivial< true >
33 {
34 };
35
36 template< typename Exception, typename... Rules >
37 struct try_catch_type
38 {
39 using analyze_t = analysis::generic< analysis::rule_type::SEQ, Rules... >;
40
41 template< apply_mode A,
42 rewind_mode M,
43 template< typename... > class Action,
44 template< typename... > class Control,
45 typename Input,
46 typename... States >
47 static bool match( Input& in, States&&... st )
48 {
49 auto m = in.template mark< M >();
50 using m_t = decltype( m );
51
52 try {
53 return m( duseltronik< seq< Rules... >, A, m_t::next_rewind_mode, Action, Control >::match( in, st... ) );
54 }
55 catch( const Exception& ) {
56 return false;
57 }
58 }
59 };
60
61 template< typename Exception, typename... Rules >
62 struct skip_control< try_catch_type< Exception, Rules... > > : std::true_type
63 {
64 };
65
66 } // namespace internal
67
68 } // namespace TAOCPP_PEGTL_NAMESPACE
69
70} // namespace tao
71
72#endif
diff --git a/MoonParser/pegtl/internal/until.hpp b/MoonParser/pegtl/internal/until.hpp
new file mode 100644
index 0000000..6a564a4
--- /dev/null
+++ b/MoonParser/pegtl/internal/until.hpp
@@ -0,0 +1,91 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_INTERNAL_UNTIL_HPP
5#define TAOCPP_PEGTL_INCLUDE_INTERNAL_UNTIL_HPP
6
7#include "../config.hpp"
8
9#include "bytes.hpp"
10#include "eof.hpp"
11#include "not_at.hpp"
12#include "rule_conjunction.hpp"
13#include "skip_control.hpp"
14#include "star.hpp"
15
16#include "../apply_mode.hpp"
17#include "../rewind_mode.hpp"
18
19#include "../analysis/generic.hpp"
20
21namespace tao
22{
23 namespace TAOCPP_PEGTL_NAMESPACE
24 {
25 namespace internal
26 {
27 template< typename Cond, typename... Rules >
28 struct until;
29
30 template< typename Cond >
31 struct until< Cond >
32 {
33 using analyze_t = analysis::generic< analysis::rule_type::SEQ, star< not_at< Cond >, not_at< eof >, bytes< 1 > >, Cond >;
34
35 template< apply_mode A,
36 rewind_mode M,
37 template< typename... > class Action,
38 template< typename... > class Control,
39 typename Input,
40 typename... States >
41 static bool match( Input& in, States&&... st )
42 {
43 auto m = in.template mark< M >();
44
45 while( !Control< Cond >::template match< A, rewind_mode::REQUIRED, Action, Control >( in, st... ) ) {
46 if( in.empty() ) {
47 return false;
48 }
49 in.bump();
50 }
51 return m( true );
52 }
53 };
54
55 template< typename Cond, typename... Rules >
56 struct until
57 {
58 using analyze_t = analysis::generic< analysis::rule_type::SEQ, star< not_at< Cond >, not_at< eof >, Rules... >, Cond >;
59
60 template< apply_mode A,
61 rewind_mode M,
62 template< typename... > class Action,
63 template< typename... > class Control,
64 typename Input,
65 typename... States >
66 static bool match( Input& in, States&&... st )
67 {
68 auto m = in.template mark< M >();
69 using m_t = decltype( m );
70
71 while( !Control< Cond >::template match< A, rewind_mode::REQUIRED, Action, Control >( in, st... ) ) {
72 if( in.empty() || ( !rule_conjunction< Rules... >::template match< A, m_t::next_rewind_mode, Action, Control >( in, st... ) ) ) {
73 return false;
74 }
75 }
76 return m( true );
77 }
78 };
79
80 template< typename Cond, typename... Rules >
81 struct skip_control< until< Cond, Rules... > > : std::true_type
82 {
83 };
84
85 } // namespace internal
86
87 } // namespace TAOCPP_PEGTL_NAMESPACE
88
89} // namespace tao
90
91#endif
diff --git a/MoonParser/pegtl/istream_input.hpp b/MoonParser/pegtl/istream_input.hpp
new file mode 100644
index 0000000..b0232f9
--- /dev/null
+++ b/MoonParser/pegtl/istream_input.hpp
@@ -0,0 +1,34 @@
1// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_ISTREAM_INPUT_HPP
5#define TAOCPP_PEGTL_INCLUDE_ISTREAM_INPUT_HPP
6
7#include <istream>
8
9#include "buffer_input.hpp"
10#include "config.hpp"
11#include "eol.hpp"
12
13#include "internal/istream_reader.hpp"
14
15namespace tao
16{
17 namespace TAOCPP_PEGTL_NAMESPACE
18 {
19 template< typename Eol = eol::lf_crlf >
20 struct istream_input
21 : buffer_input< internal::istream_reader, Eol >
22 {
23 template< typename T >
24 istream_input( std::istream& in_stream, const std::size_t in_maximum, T&& in_source )
25 : buffer_input< internal::istream_reader, Eol >( std::forward< T >( in_source ), in_maximum, in_stream )
26 {
27 }
28 };
29
30 } // namespace TAOCPP_PEGTL_NAMESPACE
31
32} // namespace tao
33
34#endif
diff --git a/MoonParser/pegtl/memory_input.hpp b/MoonParser/pegtl/memory_input.hpp
new file mode 100644
index 0000000..2d7fa42
--- /dev/null
+++ b/MoonParser/pegtl/memory_input.hpp
@@ -0,0 +1,285 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_MEMORY_INPUT_HPP
5#define TAOCPP_PEGTL_INCLUDE_MEMORY_INPUT_HPP
6
7#include <cstddef>
8#include <cstring>
9#include <string>
10#include <type_traits>
11#include <utility>
12
13#include "config.hpp"
14#include "eol.hpp"
15#include "position.hpp"
16#include "tracking_mode.hpp"
17
18#include "internal/action_input.hpp"
19#include "internal/bump_impl.hpp"
20#include "internal/iterator.hpp"
21#include "internal/marker.hpp"
22
23namespace tao
24{
25 namespace TAOCPP_PEGTL_NAMESPACE
26 {
27 namespace internal
28 {
29 template< tracking_mode, typename Eol, typename Source >
30 class memory_input_base;
31
32 template< typename Eol, typename Source >
33 class memory_input_base< tracking_mode::IMMEDIATE, Eol, Source >
34 {
35 public:
36 using iterator_t = internal::iterator;
37
38 template< typename T >
39 memory_input_base( const iterator_t& in_begin, const char* in_end, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value )
40 : m_current( in_begin ),
41 m_end( in_end ),
42 m_source( std::forward< T >( in_source ) )
43 {
44 }
45
46 template< typename T >
47 memory_input_base( const char* in_begin, const char* in_end, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value )
48 : m_current( in_begin ),
49 m_end( in_end ),
50 m_source( std::forward< T >( in_source ) )
51 {
52 }
53
54 memory_input_base( const memory_input_base& ) = delete;
55 memory_input_base operator=( const memory_input_base& ) = delete;
56
57 const char* current() const noexcept
58 {
59 return m_current.data;
60 }
61
62 const char* end( const std::size_t = 0 ) const noexcept
63 {
64 return m_end;
65 }
66
67 std::size_t byte() const noexcept
68 {
69 return m_current.byte;
70 }
71
72 std::size_t line() const noexcept
73 {
74 return m_current.line;
75 }
76
77 std::size_t byte_in_line() const noexcept
78 {
79 return m_current.byte_in_line;
80 }
81
82 void bump( const std::size_t in_count = 1 ) noexcept
83 {
84 internal::bump( m_current, in_count, Eol::ch );
85 }
86
87 void bump_in_this_line( const std::size_t in_count = 1 ) noexcept
88 {
89 internal::bump_in_this_line( m_current, in_count );
90 }
91
92 void bump_to_next_line( const std::size_t in_count = 1 ) noexcept
93 {
94 internal::bump_to_next_line( m_current, in_count );
95 }
96
97 TAOCPP_PEGTL_NAMESPACE::position position( const iterator_t& it ) const
98 {
99 return TAOCPP_PEGTL_NAMESPACE::position( it, m_source );
100 }
101
102 protected:
103 iterator_t m_current;
104 const char* const m_end;
105 const Source m_source;
106 };
107
108 template< typename Eol, typename Source >
109 class memory_input_base< tracking_mode::LAZY, Eol, Source >
110 {
111 public:
112 using iterator_t = const char*;
113
114 template< typename T >
115 memory_input_base( const internal::iterator& in_begin, const char* in_end, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value )
116 : m_begin( in_begin ),
117 m_current( in_begin.data ),
118 m_end( in_end ),
119 m_source( std::forward< T >( in_source ) )
120 {
121 }
122
123 template< typename T >
124 memory_input_base( const char* in_begin, const char* in_end, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value )
125 : m_begin( in_begin ),
126 m_current( in_begin ),
127 m_end( in_end ),
128 m_source( std::forward< T >( in_source ) )
129 {
130 }
131
132 memory_input_base( const memory_input_base& ) = delete;
133 memory_input_base operator=( const memory_input_base& ) = delete;
134
135 const char* current() const noexcept
136 {
137 return m_current;
138 }
139
140 const char* end( const std::size_t = 0 ) const noexcept
141 {
142 return m_end;
143 }
144
145 std::size_t byte() const noexcept
146 {
147 return std::size_t( current() - m_begin.data );
148 }
149
150 void bump( const std::size_t in_count = 1 ) noexcept
151 {
152 m_current += in_count;
153 }
154
155 void bump_in_this_line( const std::size_t in_count = 1 ) noexcept
156 {
157 m_current += in_count;
158 }
159
160 void bump_to_next_line( const std::size_t in_count = 1 ) noexcept
161 {
162 m_current += in_count;
163 }
164
165 TAOCPP_PEGTL_NAMESPACE::position position( const iterator_t it ) const
166 {
167 internal::iterator c( m_begin );
168 internal::bump( c, std::size_t( it - m_begin.data ), Eol::ch );
169 return TAOCPP_PEGTL_NAMESPACE::position( c, m_source );
170 }
171
172 protected:
173 const internal::iterator m_begin;
174 iterator_t m_current;
175 const char* const m_end;
176 const Source m_source;
177 };
178
179 } // namespace internal
180
181 template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf, typename Source = std::string >
182 class memory_input
183 : public internal::memory_input_base< P, Eol, Source >
184 {
185 public:
186 static constexpr tracking_mode tracking_mode_v = P;
187
188 using eol_t = Eol;
189 using source_t = Source;
190
191 using typename internal::memory_input_base< P, Eol, Source >::iterator_t;
192
193 using action_t = internal::action_input< memory_input >;
194
195 using internal::memory_input_base< P, Eol, Source >::memory_input_base;
196
197 template< typename T >
198 memory_input( const char* in_begin, const std::size_t in_size, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value )
199 : memory_input( in_begin, in_begin + in_size, std::forward< T >( in_source ) )
200 {
201 }
202
203 template< typename T >
204 memory_input( const std::string& in_string, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value )
205 : memory_input( in_string.data(), in_string.size(), std::forward< T >( in_source ) )
206 {
207 }
208
209 template< typename T >
210 memory_input( const char* in_begin, T&& in_source ) noexcept( std::is_nothrow_constructible< Source, T&& >::value )
211 : memory_input( in_begin, std::strlen( in_begin ), std::forward< T >( in_source ) )
212 {
213 }
214
215 template< typename T >
216 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 )
217 : memory_input( { in_begin, in_byte, in_line, in_byte_in_line }, in_end, std::forward< T >( in_source ) )
218 {
219 }
220
221 memory_input( const memory_input& ) = delete;
222 memory_input operator=( const memory_input& ) = delete;
223
224 const Source& source() const noexcept
225 {
226 return this->m_source;
227 }
228
229 bool empty() const noexcept
230 {
231 return this->current() == this->end();
232 }
233
234 std::size_t size( const std::size_t = 0 ) const noexcept
235 {
236 return std::size_t( this->end() - this->current() );
237 }
238
239 char peek_char( const std::size_t offset = 0 ) const noexcept
240 {
241 return this->current()[ offset ];
242 }
243
244 unsigned char peek_byte( const std::size_t offset = 0 ) const noexcept
245 {
246 return static_cast< unsigned char >( peek_char( offset ) );
247 }
248
249 iterator_t& iterator() noexcept
250 {
251 return this->m_current;
252 }
253
254 const iterator_t& iterator() const noexcept
255 {
256 return this->m_current;
257 }
258
259 using internal::memory_input_base< P, Eol, Source >::position;
260
261 TAOCPP_PEGTL_NAMESPACE::position position() const
262 {
263 return position( iterator() );
264 }
265
266 void discard() const noexcept
267 {
268 }
269
270 void require( const std::size_t ) const noexcept
271 {
272 }
273
274 template< rewind_mode M >
275 internal::marker< iterator_t, M > mark() noexcept
276 {
277 return internal::marker< iterator_t, M >( iterator() );
278 }
279 };
280
281 } // namespace TAOCPP_PEGTL_NAMESPACE
282
283} // namespace tao
284
285#endif
diff --git a/MoonParser/pegtl/mmap_input.hpp b/MoonParser/pegtl/mmap_input.hpp
new file mode 100644
index 0000000..0a112ef
--- /dev/null
+++ b/MoonParser/pegtl/mmap_input.hpp
@@ -0,0 +1,55 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_MMAP_INPUT_HPP
5#define TAOCPP_PEGTL_INCLUDE_MMAP_INPUT_HPP
6
7#include <string>
8#include <utility>
9
10#include "config.hpp"
11#include "eol.hpp"
12#include "memory_input.hpp"
13#include "tracking_mode.hpp"
14
15#include "internal/file_mapper.hpp"
16
17namespace tao
18{
19 namespace TAOCPP_PEGTL_NAMESPACE
20 {
21 namespace internal
22 {
23 struct mmap_holder
24 {
25 const std::string filename;
26 const file_mapper data;
27
28 template< typename T >
29 mmap_holder( T&& in_filename )
30 : filename( std::forward< T >( in_filename ) ),
31 data( filename.c_str() )
32 {
33 }
34 };
35
36 } // namespace internal
37
38 template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf >
39 struct mmap_input
40 : private internal::mmap_holder,
41 public memory_input< P, Eol, const char* >
42 {
43 template< typename T >
44 explicit mmap_input( T&& in_filename )
45 : internal::mmap_holder( std::forward< T >( in_filename ) ),
46 memory_input< P, Eol, const char* >( data.begin(), data.end(), filename.c_str() )
47 {
48 }
49 };
50
51 } // namespace TAOCPP_PEGTL_NAMESPACE
52
53} // namespace tao
54
55#endif
diff --git a/MoonParser/pegtl/normal.hpp b/MoonParser/pegtl/normal.hpp
new file mode 100644
index 0000000..d5752d1
--- /dev/null
+++ b/MoonParser/pegtl/normal.hpp
@@ -0,0 +1,81 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_NORMAL_HPP
5#define TAOCPP_PEGTL_INCLUDE_NORMAL_HPP
6
7#include "apply_mode.hpp"
8#include "config.hpp"
9#include "nothing.hpp"
10#include "parse_error.hpp"
11#include "rewind_mode.hpp"
12
13#include "internal/demangle.hpp"
14#include "internal/dusel_mode.hpp"
15#include "internal/duseltronik.hpp"
16#include "internal/has_apply0.hpp"
17#include "internal/skip_control.hpp"
18
19namespace tao
20{
21 namespace TAOCPP_PEGTL_NAMESPACE
22 {
23 template< typename Rule >
24 struct normal
25 {
26 template< typename Input, typename... States >
27 static void start( const Input&, States&&... ) noexcept
28 {
29 }
30
31 template< typename Input, typename... States >
32 static void success( const Input&, States&&... ) noexcept
33 {
34 }
35
36 template< typename Input, typename... States >
37 static void failure( const Input&, States&&... ) noexcept
38 {
39 }
40
41 template< typename Input, typename... States >
42 static void raise( const Input& in, States&&... )
43 {
44 throw parse_error( "parse error matching " + internal::demangle< Rule >(), in );
45 }
46
47 template< template< typename... > class Action, typename Input, typename... States >
48 static void apply0( const Input&, States&&... st )
49 {
50 Action< Rule >::apply0( st... );
51 }
52
53 template< template< typename... > class Action, typename Iterator, typename Input, typename... States >
54 static void apply( const Iterator& begin, const Input& in, States&&... st )
55 {
56 using action_t = typename Input::action_t;
57 const action_t action_input( begin, in );
58 Action< Rule >::apply( action_input, st... );
59 }
60
61 template< apply_mode A,
62 rewind_mode M,
63 template< typename... > class Action,
64 template< typename... > class Control,
65 typename Input,
66 typename... States >
67 static bool match( Input& in, States&&... st )
68 {
69 constexpr bool use_control = !internal::skip_control< Rule >::value;
70 constexpr bool use_action = use_control && ( A == apply_mode::ACTION ) && ( !is_nothing< Action, Rule >::value );
71 constexpr bool use_apply0 = use_action && internal::has_apply0< Action< Rule >, internal::type_list< States... > >::value;
72 constexpr dusel_mode mode = static_cast< dusel_mode >( static_cast< char >( use_control ) + static_cast< char >( use_action ) + static_cast< char >( use_apply0 ) );
73 return internal::duseltronik< Rule, A, M, Action, Control, mode >::match( in, st... );
74 }
75 };
76
77 } // namespace TAOCPP_PEGTL_NAMESPACE
78
79} // namespace tao
80
81#endif
diff --git a/MoonParser/pegtl/nothing.hpp b/MoonParser/pegtl/nothing.hpp
new file mode 100644
index 0000000..9b121a2
--- /dev/null
+++ b/MoonParser/pegtl/nothing.hpp
@@ -0,0 +1,27 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_NOTHING_HPP
5#define TAOCPP_PEGTL_INCLUDE_NOTHING_HPP
6
7#include <type_traits>
8
9#include "config.hpp"
10
11namespace tao
12{
13 namespace TAOCPP_PEGTL_NAMESPACE
14 {
15 template< typename Rule >
16 struct nothing
17 {
18 };
19
20 template< template< typename... > class Action, typename Rule >
21 using is_nothing = std::is_base_of< nothing< Rule >, Action< Rule > >;
22
23 } // namespace TAOCPP_PEGTL_NAMESPACE
24
25} // namespace tao
26
27#endif
diff --git a/MoonParser/pegtl/parse.hpp b/MoonParser/pegtl/parse.hpp
new file mode 100644
index 0000000..c478cfa
--- /dev/null
+++ b/MoonParser/pegtl/parse.hpp
@@ -0,0 +1,53 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_PARSE_HPP
5#define TAOCPP_PEGTL_INCLUDE_PARSE_HPP
6
7#include "apply_mode.hpp"
8#include "config.hpp"
9#include "normal.hpp"
10#include "nothing.hpp"
11#include "parse_error.hpp"
12#include "rewind_mode.hpp"
13
14namespace tao
15{
16 namespace TAOCPP_PEGTL_NAMESPACE
17 {
18 template< typename Rule,
19 template< typename... > class Action = nothing,
20 template< typename... > class Control = normal,
21 apply_mode A = apply_mode::ACTION,
22 rewind_mode M = rewind_mode::REQUIRED,
23 typename Input,
24 typename... States >
25 bool parse( Input&& in, States&&... st )
26 {
27 return Control< Rule >::template match< A, M, Action, Control >( in, st... );
28 }
29
30 template< typename Rule,
31 template< typename... > class Action = nothing,
32 template< typename... > class Control = normal,
33 apply_mode A = apply_mode::ACTION,
34 rewind_mode M = rewind_mode::REQUIRED,
35 typename Outer,
36 typename Input,
37 typename... States >
38 bool parse_nested( const Outer& oi, Input&& in, States&&... st )
39 {
40 try {
41 return parse< Rule, Action, Control, A, M >( in, st... );
42 }
43 catch( parse_error& e ) {
44 e.positions.push_back( oi.position() );
45 throw;
46 }
47 }
48
49 } // namespace TAOCPP_PEGTL_NAMESPACE
50
51} // namespace tao
52
53#endif
diff --git a/MoonParser/pegtl/parse_error.hpp b/MoonParser/pegtl/parse_error.hpp
new file mode 100644
index 0000000..e015efb
--- /dev/null
+++ b/MoonParser/pegtl/parse_error.hpp
@@ -0,0 +1,45 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_PARSE_ERROR_HPP
5#define TAOCPP_PEGTL_INCLUDE_PARSE_ERROR_HPP
6
7#include <stdexcept>
8#include <vector>
9
10#include "config.hpp"
11#include "position.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 struct parse_error
18 : public std::runtime_error
19 {
20 parse_error( const std::string& msg, std::vector< position >&& in_positions )
21 : std::runtime_error( msg ),
22 positions( std::move( in_positions ) )
23 {
24 }
25
26 template< typename Input >
27 parse_error( const std::string& msg, const Input& in )
28 : parse_error( msg, in.position() )
29 {
30 }
31
32 parse_error( const std::string& msg, const position& pos )
33 : std::runtime_error( to_string( pos ) + ": " + msg ),
34 positions( 1, pos )
35 {
36 }
37
38 std::vector< position > positions;
39 };
40
41 } // namespace TAOCPP_PEGTL_NAMESPACE
42
43} // namespace tao
44
45#endif
diff --git a/MoonParser/pegtl/position.hpp b/MoonParser/pegtl/position.hpp
new file mode 100644
index 0000000..c25225c
--- /dev/null
+++ b/MoonParser/pegtl/position.hpp
@@ -0,0 +1,54 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_POSITION_HPP
5#define TAOCPP_PEGTL_INCLUDE_POSITION_HPP
6
7#include <cstdlib>
8#include <ostream>
9#include <sstream>
10#include <string>
11#include <utility>
12
13#include "config.hpp"
14
15#include "internal/iterator.hpp"
16
17namespace tao
18{
19 namespace TAOCPP_PEGTL_NAMESPACE
20 {
21 struct position
22 {
23 template< typename T >
24 position( const internal::iterator& in_iter, T&& in_source )
25 : byte( in_iter.byte ),
26 line( in_iter.line ),
27 byte_in_line( in_iter.byte_in_line ),
28 source( std::forward< T >( in_source ) )
29 {
30 }
31
32 std::size_t byte;
33 std::size_t line;
34 std::size_t byte_in_line;
35 std::string source;
36 };
37
38 inline std::ostream& operator<<( std::ostream& o, const position& p )
39 {
40 return o << p.source << ':' << p.line << ':' << p.byte_in_line << '(' << p.byte << ')';
41 }
42
43 inline std::string to_string( const position& p )
44 {
45 std::ostringstream o;
46 o << p;
47 return o.str();
48 }
49
50 } // namespace TAOCPP_PEGTL_NAMESPACE
51
52} // namespace tao
53
54#endif
diff --git a/MoonParser/pegtl/read_input.hpp b/MoonParser/pegtl/read_input.hpp
new file mode 100644
index 0000000..9ebfaca
--- /dev/null
+++ b/MoonParser/pegtl/read_input.hpp
@@ -0,0 +1,52 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_READ_INPUT_HPP
5#define TAOCPP_PEGTL_INCLUDE_READ_INPUT_HPP
6
7#include <string>
8
9#include "config.hpp"
10#include "eol.hpp"
11#include "string_input.hpp"
12#include "tracking_mode.hpp"
13
14#include "internal/file_reader.hpp"
15
16namespace tao
17{
18 namespace TAOCPP_PEGTL_NAMESPACE
19 {
20 namespace internal
21 {
22 struct filename_holder
23 {
24 const std::string filename;
25
26 template< typename T >
27 explicit filename_holder( T&& in_filename )
28 : filename( std::forward< T >( in_filename ) )
29 {
30 }
31 };
32
33 } // namespace internal
34
35 template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf >
36 struct read_input
37 : private internal::filename_holder,
38 public string_input< P, Eol, const char* >
39 {
40 template< typename T >
41 explicit read_input( T&& in_filename )
42 : internal::filename_holder( std::forward< T >( in_filename ) ),
43 string_input< P, Eol, const char* >( internal::file_reader( filename.c_str() ).read(), filename.c_str() )
44 {
45 }
46 };
47
48 } // namespace TAOCPP_PEGTL_NAMESPACE
49
50} // namespace tao
51
52#endif
diff --git a/MoonParser/pegtl/rewind_mode.hpp b/MoonParser/pegtl/rewind_mode.hpp
new file mode 100644
index 0000000..f78edb9
--- /dev/null
+++ b/MoonParser/pegtl/rewind_mode.hpp
@@ -0,0 +1,24 @@
1// Copyright (c) 2016-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_REWIND_MODE_HPP
5#define TAOCPP_PEGTL_INCLUDE_REWIND_MODE_HPP
6
7#include "config.hpp"
8
9namespace tao
10{
11 namespace TAOCPP_PEGTL_NAMESPACE
12 {
13 enum class rewind_mode : char
14 {
15 ACTIVE,
16 REQUIRED,
17 DONTCARE
18 };
19
20 } // namespace TAOCPP_PEGTL_NAMESPACE
21
22} // namespace tao
23
24#endif
diff --git a/MoonParser/pegtl/rules.hpp b/MoonParser/pegtl/rules.hpp
new file mode 100644
index 0000000..e1c50b2
--- /dev/null
+++ b/MoonParser/pegtl/rules.hpp
@@ -0,0 +1,69 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_RULES_HPP
5#define TAOCPP_PEGTL_INCLUDE_RULES_HPP
6
7#include "config.hpp"
8#include "parse_error.hpp"
9
10#include "internal/rules.hpp"
11
12namespace tao
13{
14 namespace TAOCPP_PEGTL_NAMESPACE
15 {
16 // clang-format off
17 template< typename... Actions > struct apply : internal::apply< Actions... > {};
18 template< typename... Actions > struct apply0 : internal::apply0< Actions... > {};
19 template< template< typename... > class Action, typename... Rules > struct action : internal::action< Action, Rules... > {};
20 template< typename... Rules > struct at : internal::at< Rules... > {};
21 struct bof : internal::bof {};
22 struct bol : internal::bol {};
23 template< unsigned Num > struct bytes : internal::bytes< Num > {};
24 template< template< typename... > class Control, typename... Rules > struct control : internal::control< Control, Rules... > {};
25 template< typename... Rules > struct disable : internal::disable< Rules... > {};
26 struct discard : internal::discard {};
27 template< typename... Rules > struct enable : internal::enable< Rules... > {};
28 struct eof : internal::eof {};
29 struct failure : internal::trivial< false > {};
30 template< typename Rule, typename... Actions > struct if_apply : internal::if_apply< Rule, Actions... > {};
31 template< typename Cond, typename... Thens > struct if_must : internal::if_must< Cond, Thens... > {};
32 template< typename Cond, typename Then, typename Else > struct if_must_else : internal::if_must_else< Cond, Then, Else > {};
33 template< typename Cond, typename Then, typename Else > struct if_then_else : internal::if_then_else< Cond, Then, Else > {};
34 template< typename Rule, typename Sep, typename Pad = void > struct list : internal::list< Rule, internal::pad< Sep, Pad > > {};
35 template< typename Rule, typename Sep > struct list< Rule, Sep, void > : internal::list< Rule, Sep > {};
36 template< typename Rule, typename Sep, typename Pad = void > struct list_must : internal::list_must< Rule, internal::pad< Sep, Pad > > {};
37 template< typename Rule, typename Sep > struct list_must< Rule, Sep, void > : internal::list_must< Rule, Sep > {};
38 template< typename Rule, typename Sep, typename Pad = void > struct list_tail : internal::list_tail_pad< Rule, Sep, Pad > {};
39 template< typename Rule, typename Sep > struct list_tail< Rule, Sep, void > : internal::list_tail< Rule, Sep > {};
40 template< typename M, typename S > struct minus : internal::minus< M, S > {};
41 template< typename... Rules > struct must : internal::must< Rules... > {};
42 template< typename... Rules > struct not_at : internal::not_at< Rules... > {};
43 template< typename... Rules > struct opt : internal::opt< Rules... > {};
44 template< typename Rule, typename Pad1, typename Pad2 = Pad1 > struct pad : internal::pad< Rule, Pad1, Pad2 > {};
45 template< typename Rule, typename Pad > struct pad_opt : internal::pad_opt< Rule, Pad > {};
46 template< typename Rule, typename... Rules > struct plus : internal::plus< Rule, Rules... > {};
47 template< typename Exception > struct raise : internal::raise< Exception > {};
48 template< unsigned Num, typename... Rules > struct rep : internal::rep< Num, Rules... > {};
49 template< unsigned Max, typename... Rules > struct rep_max : internal::rep_min_max< 0, Max, Rules... > {};
50 template< unsigned Min, typename Rule, typename... Rules > struct rep_min : internal::rep_min< Min, Rule, Rules... > {};
51 template< unsigned Min, unsigned Max, typename... Rules > struct rep_min_max : internal::rep_min_max< Min, Max, Rules... > {};
52 template< unsigned Max, typename... Rules > struct rep_opt : internal::rep_opt< Max, Rules... > {};
53 template< unsigned Amount > struct require : internal::require< Amount > {};
54 template< typename... Rules > struct seq : internal::seq< Rules... > {};
55 template< typename... Rules > struct sor : internal::sor< Rules... > {};
56 template< typename Rule, typename... Rules > struct star : internal::star< Rule, Rules... > {};
57 template< typename Cond, typename... Rules > struct star_must : internal::star_must< Cond, Rules... > {};
58 template< typename State, typename... Rules > struct state : internal::state< State, Rules... > {};
59 struct success : internal::trivial< true > {};
60 template< typename... Rules > struct try_catch : internal::try_catch_type< parse_error, Rules... > {};
61 template< typename Exception, typename... Rules > struct try_catch_type : internal::try_catch_type< Exception, Rules... > {};
62 template< typename Cond, typename... Rules > struct until : internal::until< Cond, Rules... > {};
63 // clang-format on
64
65 } // namespace TAOCPP_PEGTL_NAMESPACE
66
67} // namespace tao
68
69#endif
diff --git a/MoonParser/pegtl/string_input.hpp b/MoonParser/pegtl/string_input.hpp
new file mode 100644
index 0000000..a1c1f98
--- /dev/null
+++ b/MoonParser/pegtl/string_input.hpp
@@ -0,0 +1,51 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_STRING_INPUT_HPP
5#define TAOCPP_PEGTL_INCLUDE_STRING_INPUT_HPP
6
7#include <string>
8#include <utility>
9
10#include "config.hpp"
11#include "eol.hpp"
12#include "memory_input.hpp"
13#include "tracking_mode.hpp"
14
15namespace tao
16{
17 namespace TAOCPP_PEGTL_NAMESPACE
18 {
19 namespace internal
20 {
21 struct string_holder
22 {
23 const std::string data;
24
25 template< typename T >
26 explicit string_holder( T&& in_data )
27 : data( std::forward< T >( in_data ) )
28 {
29 }
30 };
31
32 } // namespace internal
33
34 template< tracking_mode P = tracking_mode::IMMEDIATE, typename Eol = eol::lf_crlf, typename Source = std::string >
35 struct string_input
36 : private internal::string_holder,
37 public memory_input< P, Eol, Source >
38 {
39 template< typename T, typename... Ts >
40 explicit string_input( T&& in_data, Ts&&... ts )
41 : internal::string_holder( std::forward< T >( in_data ) ),
42 memory_input< P, Eol, Source >( data.data(), data.size(), std::forward< Ts >( ts )... )
43 {
44 }
45 };
46
47 } // namespace TAOCPP_PEGTL_NAMESPACE
48
49} // namespace tao
50
51#endif
diff --git a/MoonParser/pegtl/tracking_mode.hpp b/MoonParser/pegtl/tracking_mode.hpp
new file mode 100644
index 0000000..7ed945b
--- /dev/null
+++ b/MoonParser/pegtl/tracking_mode.hpp
@@ -0,0 +1,23 @@
1// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_TRACKING_MODE_HPP
5#define TAOCPP_PEGTL_INCLUDE_TRACKING_MODE_HPP
6
7#include "config.hpp"
8
9namespace tao
10{
11 namespace TAOCPP_PEGTL_NAMESPACE
12 {
13 enum class tracking_mode : bool
14 {
15 IMMEDIATE,
16 LAZY
17 };
18
19 } // namespace TAOCPP_PEGTL_NAMESPACE
20
21} // namespace tao
22
23#endif
diff --git a/MoonParser/pegtl/utf16.hpp b/MoonParser/pegtl/utf16.hpp
new file mode 100644
index 0000000..faa7180
--- /dev/null
+++ b/MoonParser/pegtl/utf16.hpp
@@ -0,0 +1,35 @@
1// Copyright (c) 2015-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_UTF16_HPP
5#define TAOCPP_PEGTL_INCLUDE_UTF16_HPP
6
7#include "config.hpp"
8
9#include "internal/peek_utf16.hpp"
10#include "internal/result_on_found.hpp"
11#include "internal/rules.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 namespace utf16
18 {
19 // clang-format off
20 struct any : internal::any< internal::peek_utf16 > {};
21 template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_utf16, Cs... > {};
22 template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_utf16, Lo, Hi > {};
23 template< char32_t... Cs > struct one : internal::one< internal::result_on_found::SUCCESS, internal::peek_utf16, Cs... > {};
24 template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::SUCCESS, internal::peek_utf16, Lo, Hi > {};
25 template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf16, Cs... > {};
26 template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_utf16, Cs >... > {};
27 // clang-format on
28
29 } // namespace utf16
30
31 } // namespace TAOCPP_PEGTL_NAMESPACE
32
33} // namespace tao
34
35#endif
diff --git a/MoonParser/pegtl/utf32.hpp b/MoonParser/pegtl/utf32.hpp
new file mode 100644
index 0000000..848137b
--- /dev/null
+++ b/MoonParser/pegtl/utf32.hpp
@@ -0,0 +1,35 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_UTF32_HPP
5#define TAOCPP_PEGTL_INCLUDE_UTF32_HPP
6
7#include "config.hpp"
8
9#include "internal/peek_utf32.hpp"
10#include "internal/result_on_found.hpp"
11#include "internal/rules.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 namespace utf32
18 {
19 // clang-format off
20 struct any : internal::any< internal::peek_utf32 > {};
21 template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_utf32, Cs... > {};
22 template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_utf32, Lo, Hi > {};
23 template< char32_t... Cs > struct one : internal::one< internal::result_on_found::SUCCESS, internal::peek_utf32, Cs... > {};
24 template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::SUCCESS, internal::peek_utf32, Lo, Hi > {};
25 template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf32, Cs... > {};
26 template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_utf32, Cs >... > {};
27 // clang-format on
28
29 } // namespace utf32
30
31 } // namespace TAOCPP_PEGTL_NAMESPACE
32
33} // namespace tao
34
35#endif
diff --git a/MoonParser/pegtl/utf8.hpp b/MoonParser/pegtl/utf8.hpp
new file mode 100644
index 0000000..9ec046e
--- /dev/null
+++ b/MoonParser/pegtl/utf8.hpp
@@ -0,0 +1,35 @@
1// Copyright (c) 2014-2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_UTF8_HPP
5#define TAOCPP_PEGTL_INCLUDE_UTF8_HPP
6
7#include "config.hpp"
8
9#include "internal/peek_utf8.hpp"
10#include "internal/result_on_found.hpp"
11#include "internal/rules.hpp"
12
13namespace tao
14{
15 namespace TAOCPP_PEGTL_NAMESPACE
16 {
17 namespace utf8
18 {
19 // clang-format off
20 struct any : internal::any< internal::peek_utf8 > {};
21 template< char32_t... Cs > struct not_one : internal::one< internal::result_on_found::FAILURE, internal::peek_utf8, Cs... > {};
22 template< char32_t Lo, char32_t Hi > struct not_range : internal::range< internal::result_on_found::FAILURE, internal::peek_utf8, Lo, Hi > {};
23 template< char32_t... Cs > struct one : internal::one< internal::result_on_found::SUCCESS, internal::peek_utf8, Cs... > {};
24 template< char32_t Lo, char32_t Hi > struct range : internal::range< internal::result_on_found::SUCCESS, internal::peek_utf8, Lo, Hi > {};
25 template< char32_t... Cs > struct ranges : internal::ranges< internal::peek_utf8, Cs... > {};
26 template< char32_t... Cs > struct string : internal::seq< internal::one< internal::result_on_found::SUCCESS, internal::peek_utf8, Cs >... > {};
27 // clang-format on
28
29 } // namespace utf8
30
31 } // namespace TAOCPP_PEGTL_NAMESPACE
32
33} // namespace tao
34
35#endif
diff --git a/MoonParser/pegtl/version.hpp b/MoonParser/pegtl/version.hpp
new file mode 100644
index 0000000..867d5e4
--- /dev/null
+++ b/MoonParser/pegtl/version.hpp
@@ -0,0 +1,13 @@
1// Copyright (c) 2017 Dr. Colin Hirsch and Daniel Frey
2// Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/
3
4#ifndef TAOCPP_PEGTL_INCLUDE_VERSION_HPP
5#define TAOCPP_PEGTL_INCLUDE_VERSION_HPP
6
7#define TAOCPP_PEGTL_VERSION "2.1.2"
8
9#define TAOCPP_PEGTL_VERSION_MAJOR 2
10#define TAOCPP_PEGTL_VERSION_MINOR 1
11#define TAOCPP_PEGTL_VERSION_PATCH 2
12
13#endif
diff --git a/MoonParser/slice.cpp b/MoonParser/slice.cpp
new file mode 100644
index 0000000..7caddbc
--- /dev/null
+++ b/MoonParser/slice.cpp
@@ -0,0 +1,119 @@
1/**
2 * Copyright (C) 2017, IppClub. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23#include "Slice.h"
24#include <cstdlib>
25
26namespace silly {
27
28namespace slice {
29
30const std::string Slice::Empty;
31
32int Slice::compare(const Slice &rhs) const {
33 int ret = 0;
34
35 // It's illegal to pass nullptr to memcmp.
36 if (str_ && rhs.str_)
37 ret = memcmp(str_, rhs.str_, len_);
38
39 if (ret == 0) {
40 // Use len_ - rhs.len_ as returned value may cause overflow
41 // of size_t type length. Therefore +1, -1 are returned here.
42 if (len_ < rhs.len_)
43 return -1;
44 else if (len_ > rhs.len_)
45 return 1;
46 }
47 return ret;
48}
49
50std::string Slice::getFilePath() const {
51 std::string filename = toString();
52 size_t pos = filename.find_last_of("/\\");
53 if (pos == std::string::npos)
54 {
55 return Slice::Empty;
56 }
57 return filename.substr(0, pos) + "/";
58}
59
60std::string Slice::getFileName() const {
61 std::string filename = toString();
62 size_t pos = filename.find_last_of("/\\");
63 if (pos == std::string::npos) {
64 return Slice::Empty;
65 }
66 return filename.substr(pos+1);
67}
68
69std::string Slice::toLower() const {
70 std::string tmp = toString();
71 for (size_t i = 0; i < tmp.length(); i++) {
72 tmp[i] = (char)tolower(tmp[i]);
73 }
74 return tmp;
75}
76
77std::string Slice::toUpper() const {
78 std::string tmp = toString();
79 for (size_t i = 0; i < tmp.length(); i++) {
80 tmp[i] = (char)toupper(tmp[i]);
81 }
82 return tmp;
83}
84
85std::string Slice::getFileExtension() const {
86 std::string filename = toString();
87 size_t pos = filename.rfind('.');
88 if (pos == std::string::npos) {
89 return Slice::Empty;
90 }
91 return Slice(filename.substr(pos + 1)).toLower();
92}
93
94std::list<Slice> Slice::split(const Slice& delims) const {
95 std::string text = toString();
96 std::string delimers = delims.toString();
97 std::list<Slice> tokens;
98 std::size_t start = text.find_first_not_of(delimers), end = 0;
99 while ((end = text.find_first_of(delimers, start)) != std::string::npos) {
100 tokens.push_back(Slice(str_ + start, end - start));
101 start = text.find_first_not_of(delimers, end);
102 }
103 if (start != std::string::npos) {
104 tokens.push_back(Slice(str_ + start));
105 }
106 return tokens;
107}
108
109float Slice::stof(const Slice& str) {
110 return static_cast<float>(std::atof(str.toString().c_str()));
111}
112
113int Slice::stoi(const Slice& str) {
114 return std::atoi(str.toString().c_str());
115}
116
117} // namespace slice
118
119} // namespace silly
diff --git a/MoonParser/slice.h b/MoonParser/slice.h
new file mode 100644
index 0000000..60e0ae1
--- /dev/null
+++ b/MoonParser/slice.h
@@ -0,0 +1,157 @@
1/**
2 * Copyright (C) 2017, IppClub. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23#pragma once
24
25#include <cassert>
26#include <cstring>
27#include <string>
28#include <list>
29
30namespace silly {
31
32namespace slice {
33// A Slice object wraps a "const char *" or a "const std::string&" but
34// without copying their contents.
35class Slice {
36 private:
37 struct TrustedInitTag {};
38 constexpr Slice(const char* s, size_t n, TrustedInitTag) : str_(s), len_(n) {}
39
40 public:
41 // implicit conversion from std::string to Slice
42 Slice(const std::string &s) : Slice(s.data(), s.size()) {}
43
44 Slice(const char *s) : Slice(s, s ? strlen(s) : 0) {}
45
46 Slice(const char *s, size_t n) : str_(s), len_(n) {}
47
48 Slice(std::pair<const char*,size_t> sp) : str_(sp.first), len_(sp.second) {}
49
50 constexpr Slice(std::nullptr_t p = nullptr) : str_(nullptr), len_(0) {}
51
52 operator std::string() const {
53 return std::string(str_, len_);
54 }
55
56 const char &operator[](size_t n) const {
57 return str_[n];
58 }
59
60 size_t size() const {
61 return len_;
62 }
63
64 const char *rawData() const {
65 return str_;
66 }
67
68 std::string toString() const {
69 return std::string(str_, len_);
70 }
71
72 bool empty() const {
73 return len_ == 0;
74 }
75
76 // similar with std::string::compare
77 // http://en.cppreference.com/w/cpp/string/basic_string/compare
78 int compare(const Slice &rhs) const;
79
80 void skip(size_t n) {
81 assert(n <= len_);
82 str_ += n;
83 len_ -= n;
84 }
85
86 void copyTo(char *dest, bool appendEndingNull = true) const {
87 memcpy(dest, str_, len_);
88 if (appendEndingNull) {
89 dest[len_] = '\0';
90 }
91 }
92
93 Slice &trimSpace() {
94 assert(len_ > 0);
95 size_t start = 0, end = len_ - 1;
96 while (start < end && isspace(str_[start])) {
97 start++;
98 }
99 while (start < end && isspace(str_[end])) {
100 end--;
101 }
102 str_ += start;
103 len_ = end - start + 1;
104 return *this;
105 }
106
107 typedef const char *const_iterator;
108
109 const_iterator begin() const {
110 return str_;
111 }
112
113 const_iterator end() const {
114 return str_ + len_;
115 }
116
117 std::string getFilePath() const;
118 std::string getFileName() const;
119 std::string getFileExtension() const;
120 std::string toLower() const;
121 std::string toUpper() const;
122 std::list<Slice> split(const Slice& delimer) const;
123
124 static const std::string Empty;
125 static float stof(const Slice& str);
126 static int stoi(const Slice& str);
127
128 constexpr friend Slice operator"" _slice(const char* s, size_t n);
129 private:
130 const char *str_;
131 size_t len_;
132};
133
134inline Slice trimSpace(const Slice &s) {
135 Slice tmp = s;
136 return tmp.trimSpace();
137}
138
139inline bool operator==(const Slice &lhs, const Slice &rhs) {
140 return lhs.compare(rhs) == 0;
141}
142
143inline bool operator!=(const Slice &lhs, const Slice &rhs) {
144 return !(lhs == rhs);
145}
146
147inline std::string operator+(const std::string& lhs, const Slice &rhs) {
148 return lhs + rhs.toString();
149}
150
151constexpr Slice operator"" _slice(const char* s, size_t n) {
152 return Slice(s, n, Slice::TrustedInitTag{});
153}
154
155} // namespace slice
156
157} // namespace silly