diff options
| author | Li Jin <dragon-fly@qq.com> | 2017-07-13 16:03:11 +0800 |
|---|---|---|
| committer | Li Jin <dragon-fly@qq.com> | 2017-07-13 16:03:11 +0800 |
| commit | cb906e739f27931e9798510cd83725131ed55209 (patch) | |
| tree | 52b465c5eb2250dec3ed3d5f02b86db79653b838 /MoonParser | |
| parent | 975c3c7dfa032229272c3b225de1127f1605e2d2 (diff) | |
| download | yuescript-cb906e739f27931e9798510cd83725131ed55209.tar.gz yuescript-cb906e739f27931e9798510cd83725131ed55209.tar.bz2 yuescript-cb906e739f27931e9798510cd83725131ed55209.zip | |
rewrite parsing codes with parserlib.
Diffstat (limited to 'MoonParser')
142 files changed, 2905 insertions, 9966 deletions
diff --git a/MoonParser/ast.cpp b/MoonParser/ast.cpp new file mode 100644 index 0000000..66f6493 --- /dev/null +++ b/MoonParser/ast.cpp | |||
| @@ -0,0 +1,68 @@ | |||
| 1 | #include <cassert> | ||
| 2 | #include "ast.hpp" | ||
| 3 | |||
| 4 | |||
| 5 | namespace parserlib { | ||
| 6 | |||
| 7 | |||
| 8 | //current AST container. | ||
| 9 | static ast_container *_current = 0; | ||
| 10 | |||
| 11 | |||
| 12 | /** sets the container under construction to be this. | ||
| 13 | */ | ||
| 14 | ast_container::ast_container() { | ||
| 15 | _current = this; | ||
| 16 | } | ||
| 17 | |||
| 18 | |||
| 19 | /** sets the container under construction to be this. | ||
| 20 | @param src source object. | ||
| 21 | */ | ||
| 22 | ast_container::ast_container(const ast_container &src) { | ||
| 23 | _current = this; | ||
| 24 | } | ||
| 25 | |||
| 26 | |||
| 27 | /** Asks all members to construct themselves from the stack. | ||
| 28 | The members are asked to construct themselves in reverse order. | ||
| 29 | from a node stack. | ||
| 30 | @param st stack. | ||
| 31 | */ | ||
| 32 | void ast_container::construct(ast_stack &st) { | ||
| 33 | for(ast_member_vector::reverse_iterator it = m_members.rbegin(); | ||
| 34 | it != m_members.rend(); | ||
| 35 | ++it) | ||
| 36 | { | ||
| 37 | ast_member *member = *it; | ||
| 38 | member->construct(st); | ||
| 39 | } | ||
| 40 | } | ||
| 41 | |||
| 42 | |||
| 43 | //register the AST member to the current container. | ||
| 44 | void ast_member::_init() { | ||
| 45 | assert(_current); | ||
| 46 | m_container = _current; | ||
| 47 | _current->m_members.push_back(this); | ||
| 48 | } | ||
| 49 | |||
| 50 | |||
| 51 | /** parses the given input. | ||
| 52 | @param i input. | ||
| 53 | @param g root rule of grammar. | ||
| 54 | @param ws whitespace rule. | ||
| 55 | @param el list of errors. | ||
| 56 | @param ud user data, passed to the parse procedures. | ||
| 57 | @return pointer to ast node created, or null if there was an error. | ||
| 58 | The return object must be deleted by the caller. | ||
| 59 | */ | ||
| 60 | ast_node *parse(input &i, rule &g, error_list &el, void* ud) { | ||
| 61 | ast_stack st; | ||
| 62 | if (!parse(i, g, el, &st, ud)) return 0; | ||
| 63 | assert(st.size() == 1); | ||
| 64 | return st[0]; | ||
| 65 | } | ||
| 66 | |||
| 67 | |||
| 68 | } //namespace parserlib | ||
diff --git a/MoonParser/ast.hpp b/MoonParser/ast.hpp new file mode 100644 index 0000000..5d87db9 --- /dev/null +++ b/MoonParser/ast.hpp | |||
| @@ -0,0 +1,437 @@ | |||
| 1 | #ifndef AST_HPP | ||
| 2 | #define AST_HPP | ||
| 3 | |||
| 4 | |||
| 5 | #include <cassert> | ||
| 6 | #include <list> | ||
| 7 | #include <stdexcept> | ||
| 8 | #include "parser.hpp" | ||
| 9 | |||
| 10 | |||
| 11 | namespace parserlib { | ||
| 12 | |||
| 13 | |||
| 14 | class ast_node; | ||
| 15 | template <class T, bool OPT> class ast_ptr; | ||
| 16 | template <class T> class ast_list; | ||
| 17 | template <class T> class ast; | ||
| 18 | |||
| 19 | |||
| 20 | /** type of AST node stack. | ||
| 21 | */ | ||
| 22 | typedef std::vector<ast_node *> ast_stack; | ||
| 23 | |||
| 24 | |||
| 25 | /** Base class for AST nodes. | ||
| 26 | */ | ||
| 27 | class ast_node : public input_range { | ||
| 28 | public: | ||
| 29 | ///constructor. | ||
| 30 | ast_node() : m_parent(0) {} | ||
| 31 | |||
| 32 | /** copy constructor. | ||
| 33 | @param n source object. | ||
| 34 | */ | ||
| 35 | ast_node(const ast_node &n) : m_parent(0) {} | ||
| 36 | |||
| 37 | ///destructor. | ||
| 38 | virtual ~ast_node() {} | ||
| 39 | |||
| 40 | /** assignment operator. | ||
| 41 | @param n source object. | ||
| 42 | @return reference to this. | ||
| 43 | */ | ||
| 44 | ast_node &operator = (const ast_node &n) { return *this; } | ||
| 45 | |||
| 46 | /** get the parent node. | ||
| 47 | @return the parent node, if there is one. | ||
| 48 | */ | ||
| 49 | ast_node *parent() const { return m_parent; } | ||
| 50 | |||
| 51 | /** interface for filling the contents of the node | ||
| 52 | from a node stack. | ||
| 53 | @param st stack. | ||
| 54 | */ | ||
| 55 | virtual void construct(ast_stack &st) {} | ||
| 56 | |||
| 57 | private: | ||
| 58 | //parent | ||
| 59 | ast_node *m_parent; | ||
| 60 | |||
| 61 | template <class T, bool OPT> friend class ast_ptr; | ||
| 62 | template <class T> friend class ast_list; | ||
| 63 | template <class T> friend class ast; | ||
| 64 | }; | ||
| 65 | |||
| 66 | |||
| 67 | class ast_member; | ||
| 68 | |||
| 69 | |||
| 70 | /** type of ast member vector. | ||
| 71 | */ | ||
| 72 | typedef std::vector<ast_member *> ast_member_vector; | ||
| 73 | |||
| 74 | |||
| 75 | /** base class for AST nodes with children. | ||
| 76 | */ | ||
| 77 | class ast_container : public ast_node { | ||
| 78 | public: | ||
| 79 | /** sets the container under construction to be this. | ||
| 80 | */ | ||
| 81 | ast_container(); | ||
| 82 | |||
| 83 | /** sets the container under construction to be this. | ||
| 84 | Members are not copied. | ||
| 85 | @param src source object. | ||
| 86 | */ | ||
| 87 | ast_container(const ast_container &src); | ||
| 88 | |||
| 89 | /** the assignment operator. | ||
| 90 | The members are not copied. | ||
| 91 | @param src source object. | ||
| 92 | @return reference to this. | ||
| 93 | */ | ||
| 94 | ast_container &operator = (const ast_container &src) { | ||
| 95 | return *this; | ||
| 96 | } | ||
| 97 | |||
| 98 | /** returns the vector of AST members. | ||
| 99 | @return the vector of AST members. | ||
| 100 | */ | ||
| 101 | const ast_member_vector &members() const { | ||
| 102 | return m_members; | ||
| 103 | } | ||
| 104 | |||
| 105 | /** Asks all members to construct themselves from the stack. | ||
| 106 | The members are asked to construct themselves in reverse order. | ||
| 107 | from a node stack. | ||
| 108 | @param st stack. | ||
| 109 | */ | ||
| 110 | virtual void construct(ast_stack &st); | ||
| 111 | |||
| 112 | private: | ||
| 113 | ast_member_vector m_members; | ||
| 114 | |||
| 115 | friend class ast_member; | ||
| 116 | }; | ||
| 117 | |||
| 118 | |||
| 119 | /** Base class for children of ast_container. | ||
| 120 | */ | ||
| 121 | class ast_member { | ||
| 122 | public: | ||
| 123 | /** automatically registers itself to the container under construction. | ||
| 124 | */ | ||
| 125 | ast_member() { _init(); } | ||
| 126 | |||
| 127 | /** automatically registers itself to the container under construction. | ||
| 128 | @param src source object. | ||
| 129 | */ | ||
| 130 | ast_member(const ast_member &src) { _init(); } | ||
| 131 | |||
| 132 | /** the assignment operator. | ||
| 133 | @param src source object. | ||
| 134 | @return reference to this. | ||
| 135 | */ | ||
| 136 | ast_member &operator = (const ast_member &src) { | ||
| 137 | return *this; | ||
| 138 | } | ||
| 139 | |||
| 140 | /** returns the container this belongs to. | ||
| 141 | @return the container this belongs to. | ||
| 142 | */ | ||
| 143 | ast_container *container() const { return m_container; } | ||
| 144 | |||
| 145 | /** interface for filling the the member from a node stack. | ||
| 146 | @param st stack. | ||
| 147 | */ | ||
| 148 | virtual void construct(ast_stack &st) = 0; | ||
| 149 | |||
| 150 | private: | ||
| 151 | //the container this belongs to. | ||
| 152 | ast_container *m_container; | ||
| 153 | |||
| 154 | //register the AST member to the current container. | ||
| 155 | void _init(); | ||
| 156 | }; | ||
| 157 | |||
| 158 | |||
| 159 | /** pointer to an AST object. | ||
| 160 | It assumes ownership of the object. | ||
| 161 | It pops an object of the given type from the stack. | ||
| 162 | @tparam T type of object to control. | ||
| 163 | @tparam OPT if true, the object becomes optional. | ||
| 164 | */ | ||
| 165 | template <class T, bool OPT = false> class ast_ptr : public ast_member { | ||
| 166 | public: | ||
| 167 | /** the default constructor. | ||
| 168 | @param obj object. | ||
| 169 | */ | ||
| 170 | ast_ptr(T *obj = 0) : m_ptr(obj) { | ||
| 171 | _set_parent(); | ||
| 172 | } | ||
| 173 | |||
| 174 | /** the copy constructor. | ||
| 175 | It duplicates the underlying object. | ||
| 176 | @param src source object. | ||
| 177 | */ | ||
| 178 | ast_ptr(const ast_ptr<T, OPT> &src) : | ||
| 179 | m_ptr(src.m_ptr ? new T(*src.m_ptr) : 0) | ||
| 180 | { | ||
| 181 | _set_parent(); | ||
| 182 | } | ||
| 183 | |||
| 184 | /** deletes the underlying object. | ||
| 185 | */ | ||
| 186 | ~ast_ptr() { | ||
| 187 | delete m_ptr; | ||
| 188 | } | ||
| 189 | |||
| 190 | /** copies the given object. | ||
| 191 | The old object is deleted. | ||
| 192 | @param obj new object. | ||
| 193 | @return reference to this. | ||
| 194 | */ | ||
| 195 | ast_ptr<T, OPT> &operator = (const T *obj) { | ||
| 196 | delete m_ptr; | ||
| 197 | m_ptr = obj ? new T(*obj) : 0; | ||
| 198 | _set_parent(); | ||
| 199 | return *this; | ||
| 200 | } | ||
| 201 | |||
| 202 | /** copies the underlying object. | ||
| 203 | The old object is deleted. | ||
| 204 | @param src source object. | ||
| 205 | @return reference to this. | ||
| 206 | */ | ||
| 207 | ast_ptr<T, OPT> &operator = (const ast_ptr<T, OPT> &src) { | ||
| 208 | delete m_ptr; | ||
| 209 | m_ptr = src.m_ptr ? new T(*src.m_ptr) : 0; | ||
| 210 | _set_parent(); | ||
| 211 | return *this; | ||
| 212 | } | ||
| 213 | |||
| 214 | /** gets the underlying ptr value. | ||
| 215 | @return the underlying ptr value. | ||
| 216 | */ | ||
| 217 | T *get() const { | ||
| 218 | return m_ptr; | ||
| 219 | } | ||
| 220 | |||
| 221 | /** auto conversion to the underlying object ptr. | ||
| 222 | @return the underlying ptr value. | ||
| 223 | */ | ||
| 224 | operator T *() const { | ||
| 225 | return m_ptr; | ||
| 226 | } | ||
| 227 | |||
| 228 | /** member access. | ||
| 229 | @return the underlying ptr value. | ||
| 230 | */ | ||
| 231 | T *operator ->() const { | ||
| 232 | assert(m_ptr); | ||
| 233 | return m_ptr; | ||
| 234 | } | ||
| 235 | |||
| 236 | /** Pops a node from the stack. | ||
| 237 | @param st stack. | ||
| 238 | @exception std::logic_error thrown if the node is not of the appropriate type; | ||
| 239 | thrown only if OPT == false or if the stack is empty. | ||
| 240 | */ | ||
| 241 | virtual void construct(ast_stack &st) { | ||
| 242 | //check the stack node | ||
| 243 | if (st.empty()) throw std::logic_error("invalid AST stack"); | ||
| 244 | |||
| 245 | //get the node | ||
| 246 | ast_node *node = st.back(); | ||
| 247 | |||
| 248 | //get the object | ||
| 249 | T *obj = dynamic_cast<T *>(node); | ||
| 250 | |||
| 251 | //if the object is optional, simply return | ||
| 252 | if (OPT) { | ||
| 253 | if (!obj) return; | ||
| 254 | } | ||
| 255 | |||
| 256 | //else if the object is mandatory, throw an exception | ||
| 257 | else { | ||
| 258 | if (!obj) throw std::logic_error("invalid AST node"); | ||
| 259 | } | ||
| 260 | |||
| 261 | //pop the node from the stack | ||
| 262 | st.pop_back(); | ||
| 263 | |||
| 264 | //set the new object | ||
| 265 | delete m_ptr; | ||
| 266 | m_ptr = obj; | ||
| 267 | _set_parent(); | ||
| 268 | } | ||
| 269 | |||
| 270 | private: | ||
| 271 | //ptr | ||
| 272 | T *m_ptr; | ||
| 273 | |||
| 274 | //set parent of object | ||
| 275 | void _set_parent() { | ||
| 276 | if (m_ptr) m_ptr->m_parent = container(); | ||
| 277 | } | ||
| 278 | }; | ||
| 279 | |||
| 280 | |||
| 281 | /** A list of objects. | ||
| 282 | It pops objects of the given type from the ast stack, until no more objects can be popped. | ||
| 283 | It assumes ownership of objects. | ||
| 284 | @tparam T type of object to control. | ||
| 285 | */ | ||
| 286 | template <class T> class ast_list : public ast_member { | ||
| 287 | public: | ||
| 288 | ///list type. | ||
| 289 | typedef std::list<T *> container; | ||
| 290 | |||
| 291 | ///the default constructor. | ||
| 292 | ast_list() {} | ||
| 293 | |||
| 294 | /** duplicates the objects of the given list. | ||
| 295 | @param src source object. | ||
| 296 | */ | ||
| 297 | ast_list(const ast_list<T> &src) { | ||
| 298 | _dup(src); | ||
| 299 | } | ||
| 300 | |||
| 301 | /** deletes the objects. | ||
| 302 | */ | ||
| 303 | ~ast_list() { | ||
| 304 | _clear(); | ||
| 305 | } | ||
| 306 | |||
| 307 | /** deletes the objects of this list and duplicates the given one. | ||
| 308 | @param src source object. | ||
| 309 | @return reference to this. | ||
| 310 | */ | ||
| 311 | ast_list<T> &operator = (const ast_list<T> &src) { | ||
| 312 | if (&src != this) { | ||
| 313 | _clear(); | ||
| 314 | _dup(src); | ||
| 315 | } | ||
| 316 | return *this; | ||
| 317 | } | ||
| 318 | |||
| 319 | /** returns the container of objects. | ||
| 320 | @return the container of objects. | ||
| 321 | */ | ||
| 322 | const container &objects() const { | ||
| 323 | return m_objects; | ||
| 324 | } | ||
| 325 | |||
| 326 | /** Pops objects of type T from the stack until no more objects can be popped. | ||
| 327 | @param st stack. | ||
| 328 | */ | ||
| 329 | virtual void construct(ast_stack &st) { | ||
| 330 | for(;;) { | ||
| 331 | //if the stack is empty | ||
| 332 | if (st.empty()) break; | ||
| 333 | |||
| 334 | //get the node | ||
| 335 | ast_node *node = st.back(); | ||
| 336 | |||
| 337 | //get the object | ||
| 338 | T *obj = dynamic_cast<T *>(node); | ||
| 339 | |||
| 340 | //if the object was not not of the appropriate type, | ||
| 341 | //end the list parsing | ||
| 342 | if (!obj) return; | ||
| 343 | |||
| 344 | //remove the node from the stack | ||
| 345 | st.pop_back(); | ||
| 346 | |||
| 347 | //insert the object in the list, in reverse order | ||
| 348 | m_objects.push_front(obj); | ||
| 349 | |||
| 350 | //set the object's parent | ||
| 351 | obj->m_parent = ast_member::container(); | ||
| 352 | } | ||
| 353 | } | ||
| 354 | |||
| 355 | private: | ||
| 356 | //objects | ||
| 357 | container m_objects; | ||
| 358 | |||
| 359 | //deletes the objects of this list. | ||
| 360 | void _clear() { | ||
| 361 | while (!m_objects.empty()) { | ||
| 362 | delete m_objects.back(); | ||
| 363 | m_objects.pop_back(); | ||
| 364 | } | ||
| 365 | } | ||
| 366 | |||
| 367 | //duplicate the given list. | ||
| 368 | void _dup(const ast_list<T> &src) { | ||
| 369 | for(typename container::const_iterator it = src.m_objects.begin(); | ||
| 370 | it != src.m_objects.end(); | ||
| 371 | ++it) | ||
| 372 | { | ||
| 373 | T *obj = new T(*it); | ||
| 374 | m_objects.push_back(obj); | ||
| 375 | obj->m_parent = ast_member::container(); | ||
| 376 | } | ||
| 377 | } | ||
| 378 | }; | ||
| 379 | |||
| 380 | |||
| 381 | /** AST function which creates an object of type T | ||
| 382 | and pushes it to the node stack. | ||
| 383 | */ | ||
| 384 | template <class T> class ast { | ||
| 385 | public: | ||
| 386 | /** constructor. | ||
| 387 | @param r rule to attach the AST function to. | ||
| 388 | */ | ||
| 389 | ast(rule &r) { | ||
| 390 | r.set_parse_proc(&_parse_proc); | ||
| 391 | } | ||
| 392 | |||
| 393 | private: | ||
| 394 | //parse proc | ||
| 395 | static void _parse_proc(const pos &b, const pos &e, void *d) { | ||
| 396 | ast_stack *st = reinterpret_cast<ast_stack *>(d); | ||
| 397 | T *obj = new T; | ||
| 398 | obj->m_begin = b; | ||
| 399 | obj->m_end = e; | ||
| 400 | obj->construct(*st); | ||
| 401 | st->push_back(obj); | ||
| 402 | } | ||
| 403 | }; | ||
| 404 | |||
| 405 | |||
| 406 | /** parses the given input. | ||
| 407 | @param i input. | ||
| 408 | @param g root rule of grammar. | ||
| 409 | @param el list of errors. | ||
| 410 | @param ud user data, passed to the parse procedures. | ||
| 411 | @return pointer to ast node created, or null if there was an error. | ||
| 412 | The return object must be deleted by the caller. | ||
| 413 | */ | ||
| 414 | ast_node *parse(input &i, rule &g, error_list &el, void* ud); | ||
| 415 | |||
| 416 | |||
| 417 | /** parses the given input. | ||
| 418 | @param i input. | ||
| 419 | @param g root rule of grammar. | ||
| 420 | @param el list of errors. | ||
| 421 | @param ast result pointer to created ast. | ||
| 422 | @param ud user data, passed to the parse procedures. | ||
| 423 | @return true on success, false on error. | ||
| 424 | */ | ||
| 425 | template <class T> bool parse(input &i, rule &g, error_list &el, T *&ast, void* ud = nullptr) { | ||
| 426 | ast_node *node = parse(i, g, el, ud); | ||
| 427 | ast = dynamic_cast<T *>(node); | ||
| 428 | if (ast) return true; | ||
| 429 | delete node; | ||
| 430 | return false; | ||
| 431 | } | ||
| 432 | |||
| 433 | |||
| 434 | } //namespace parserlib | ||
| 435 | |||
| 436 | |||
| 437 | #endif //AST_HPP | ||
diff --git a/MoonParser/main.cpp b/MoonParser/main.cpp index e692732..cf7bc2d 100644 --- a/MoonParser/main.cpp +++ b/MoonParser/main.cpp | |||
| @@ -1,1698 +1,581 @@ | |||
| 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> | 1 | #include <iostream> |
| 2 | using std::cout; | ||
| 3 | #include <string> | ||
| 4 | using std::string; | ||
| 10 | #include <unordered_set> | 5 | #include <unordered_set> |
| 11 | #include <vector> | 6 | using std::unordered_set; |
| 12 | #include <queue> | ||
| 13 | #include <stack> | 7 | #include <stack> |
| 14 | #include <memory> | 8 | using std::stack; |
| 15 | #include "pegtl.hpp" | 9 | #include <algorithm> |
| 16 | #include "pegtl/analyze.hpp" | 10 | #include <sstream> |
| 17 | #include "slice.h" | 11 | using std::stringstream; |
| 18 | using namespace silly; | 12 | #include "parserlib.hpp" |
| 19 | 13 | using namespace parserlib; | |
| 20 | using namespace tao::pegtl; | 14 | |
| 21 | 15 | #define p(expr) user(expr, [](const item_t& item) \ | |
| 22 | namespace helloworld // with operator precedence climbing | 16 | { \ |
| 17 | stringstream stream; \ | ||
| 18 | for (input_it i = item.begin; i != item.end; ++i) stream << static_cast<char>(*i); \ | ||
| 19 | cout << #expr << ": [" << stream.str() << "]\n"; \ | ||
| 20 | return true; \ | ||
| 21 | }) | ||
| 22 | |||
| 23 | struct State | ||
| 23 | { | 24 | { |
| 24 | struct Stack | 25 | State() |
| 25 | { | 26 | { |
| 26 | Stack() | 27 | indents.push(0); |
| 27 | { | 28 | stringOpen = -1; |
| 28 | pushStack(); | 29 | } |
| 29 | } | 30 | size_t stringOpen; |
| 30 | void pushValue(int value) | 31 | stack<int> indents; |
| 31 | { | 32 | stack<bool> doStack; |
| 32 | _values.back().push(value); | 33 | unordered_set<string> keywords = { |
| 33 | } | 34 | "and", "while", "else", "using", "continue", |
| 34 | void pushOp(char op) | 35 | "local", "not", "then", "return", "from", |
| 35 | { | 36 | "extends", "for", "do", "or", "export", |
| 36 | _ops.back().push(op); | 37 | "class", "in", "unless", "when", "elseif", |
| 37 | } | 38 | "switch", "break", "if", "with", "import" |
| 38 | void pushStack() | ||
| 39 | { | ||
| 40 | _values.emplace_back(); | ||
| 41 | _ops.emplace_back(); | ||
| 42 | } | ||
| 43 | int getPriority(char op) | ||
| 44 | { | ||
| 45 | switch (op) | ||
| 46 | { | ||
| 47 | case '+': return 1; | ||
| 48 | case '-': return 1; | ||
| 49 | case '*': return 2; | ||
| 50 | case '/': return 2; | ||
| 51 | } | ||
| 52 | return 0; | ||
| 53 | } | ||
| 54 | /* | ||
| 55 | def compute_expr(tokenizer, min_prec): | ||
| 56 | atom_lhs = tokenizer.get_next_token() | ||
| 57 | |||
| 58 | while True: | ||
| 59 | cur = tokenizer.cur_token | ||
| 60 | if (cur is None or OPINFO_MAP[cur.value].prec < min_prec): | ||
| 61 | break | ||
| 62 | |||
| 63 | op = cur.value | ||
| 64 | prec, assoc = OPINFO_MAP[op] | ||
| 65 | next_min_prec = prec + 1 if assoc == 'LEFT' else prec | ||
| 66 | |||
| 67 | atom_rhs = compute_expr(tokenizer, next_min_prec) | ||
| 68 | |||
| 69 | atom_lhs = compute_op(op, atom_lhs, atom_rhs) | ||
| 70 | |||
| 71 | return atom_lhs | ||
| 72 | */ | ||
| 73 | int parseNext(int minPrecedence) | ||
| 74 | { | ||
| 75 | int lhs = _values.back().front(); | ||
| 76 | _values.back().pop(); | ||
| 77 | |||
| 78 | while (true) | ||
| 79 | { | ||
| 80 | if (_ops.back().empty()) | ||
| 81 | { | ||
| 82 | break; | ||
| 83 | } | ||
| 84 | char op = _ops.back().front(); | ||
| 85 | if (getPriority(op) < minPrecedence) | ||
| 86 | { | ||
| 87 | break; | ||
| 88 | } | ||
| 89 | _ops.back().pop(); | ||
| 90 | int nextMinPrecedence = getPriority(op) + 1; | ||
| 91 | int rhs = parseNext(nextMinPrecedence); | ||
| 92 | switch (op) | ||
| 93 | { | ||
| 94 | case '+': | ||
| 95 | std::cout << lhs << " + " << rhs << " = " << lhs+rhs << '\n'; | ||
| 96 | lhs = lhs + rhs; | ||
| 97 | break; | ||
| 98 | case '-': | ||
| 99 | std::cout << lhs << " - " << rhs << " = " << lhs-rhs << '\n'; | ||
| 100 | lhs = lhs - rhs; | ||
| 101 | break; | ||
| 102 | case '*': | ||
| 103 | std::cout << lhs << " * " << rhs << " = " << lhs*rhs << '\n'; | ||
| 104 | lhs = lhs * rhs; | ||
| 105 | break; | ||
| 106 | case '/': | ||
| 107 | std::cout << lhs << " / " << rhs << " = " << lhs/rhs << '\n'; | ||
| 108 | lhs = lhs / rhs; | ||
| 109 | break; | ||
| 110 | } | ||
| 111 | } | ||
| 112 | return lhs; | ||
| 113 | } | ||
| 114 | void popStack() | ||
| 115 | { | ||
| 116 | int value = parseNext(0); | ||
| 117 | _values.pop_back(); | ||
| 118 | if (_values.empty()) | ||
| 119 | { | ||
| 120 | _values.emplace_back(); | ||
| 121 | } | ||
| 122 | _ops.pop_back(); | ||
| 123 | if (_ops.empty()) | ||
| 124 | { | ||
| 125 | _ops.emplace_back(); | ||
| 126 | } | ||
| 127 | pushValue(value); | ||
| 128 | } | ||
| 129 | int getValue() const | ||
| 130 | { | ||
| 131 | return _values.back().back(); | ||
| 132 | } | ||
| 133 | private: | ||
| 134 | std::vector<std::queue<char>> _ops; | ||
| 135 | std::vector<std::queue<int>> _values; | ||
| 136 | }; | 39 | }; |
| 137 | 40 | }; | |
| 138 | struct number : seq<opt<one<'+', '-'>>, plus<digit>> { }; | 41 | |
| 139 | 42 | rule Any = any(); | |
| 140 | struct expr; | 43 | rule White = *set(" \t\r\n"); |
| 141 | 44 | rule plain_space = *set(" \t"); | |
| 142 | struct bracket : if_must<one<'('>, expr, one<')'>> { }; | 45 | rule Break = nl(-expr('\r') >> '\n'); |
| 143 | 46 | rule Stop = Break | eof(); | |
| 144 | struct atomic : sor<number, bracket> { }; | 47 | rule Comment = "--" >> *(not_(set("\r\n")) >> Any) >> and_(Stop); |
| 145 | 48 | rule Indent = *set(" \t"); | |
| 146 | struct op : one<'+', '-', '*', '/'> { }; | 49 | rule Space = plain_space >> -Comment; |
| 147 | 50 | rule SomeSpace = +set(" \t") >> -Comment; | |
| 148 | struct expr : list<atomic, op, space> { }; | 51 | rule SpaceBreak = Space >> Break; |
| 149 | 52 | rule EmptyLine = SpaceBreak; | |
| 150 | template<typename Rule> | 53 | rule AlphaNum = range('a', 'z') | range('A', 'Z') | range('0', '9') | '_'; |
| 151 | struct action : nothing<Rule> { }; | 54 | rule _Name = (range('a', 'z') | range('A', 'Z') | '_') >> *AlphaNum; |
| 152 | 55 | rule SpaceName = Space >> _Name; | |
| 153 | template<> | 56 | rule _Num = |
| 154 | struct action<number> | 57 | ( |
| 58 | "0x" >> | ||
| 59 | +(range('0', '9') | range('a', 'f') | range('A', 'F')) >> | ||
| 60 | -(-set("uU") >> set("lL") >> set("lL")) | ||
| 61 | ) | ( | ||
| 62 | +range('0', '9') >> -set("uU") >> set("lL") >> set("lL") | ||
| 63 | ) | ( | ||
| 64 | ( | ||
| 65 | (+range('0', '9') >> -('.' >> +range('0', '9'))) | | ||
| 66 | ('.' >> +range('0', '9')) | ||
| 67 | ) >> -(set("eE") >> -expr('-') >> +range('0', '9')) | ||
| 68 | ); | ||
| 69 | rule Num = Space >> _Num; | ||
| 70 | rule Cut = false_(); | ||
| 71 | rule Nothing = true_(); | ||
| 72 | |||
| 73 | #define sym(str) (Space >> str) | ||
| 74 | #define symx(str) expr(str) | ||
| 75 | #define ensure(patt, finally) (((patt) >> (finally)) | ((finally) >> (Cut))) | ||
| 76 | #define key(str) (Space >> str >> not_(AlphaNum)) | ||
| 77 | #define opWord(str) (Space >> str >> not_(AlphaNum)) | ||
| 78 | #define op(str) (Space >> str) | ||
| 79 | |||
| 80 | rule Name = user(SpaceName, [](const item_t& item) | ||
| 81 | { | ||
| 82 | stringstream stream; | ||
| 83 | for (input_it i = item.begin; i != item.end; ++i) stream << static_cast<char>(*i); | ||
| 84 | string name; | ||
| 85 | stream >> name; | ||
| 86 | State* st = reinterpret_cast<State*>(item.user_data); | ||
| 87 | auto it = st->keywords.find(name); | ||
| 88 | return it == st->keywords.end(); | ||
| 89 | }); | ||
| 90 | |||
| 91 | rule self = expr('@'); | ||
| 92 | rule self_name = '@' >> _Name; | ||
| 93 | rule self_class = expr("@@"); | ||
| 94 | rule self_class_name = "@@" >> _Name; | ||
| 95 | |||
| 96 | rule SelfName = Space >> (self_class_name | self_class | self_name | self); | ||
| 97 | rule KeyName = SelfName | Space >> _Name; | ||
| 98 | rule VarArg = Space >> "..."; | ||
| 99 | |||
| 100 | rule check_indent = user(Indent, [](const item_t& item) | ||
| 101 | { | ||
| 102 | int indent = 0; | ||
| 103 | for (input_it i = item.begin; i != item.end; ++i) | ||
| 155 | { | 104 | { |
| 156 | template<typename Input> | 105 | switch (*i) |
| 157 | static void apply(const Input& in, Stack& stack) | ||
| 158 | { | 106 | { |
| 159 | stack.pushValue(std::stoi(in.string())); | 107 | case ' ': indent++; break; |
| 108 | case '\t': indent += 4; break; | ||
| 160 | } | 109 | } |
| 161 | }; | 110 | } |
| 111 | State* st = reinterpret_cast<State*>(item.user_data); | ||
| 112 | return st->indents.top() == indent; | ||
| 113 | }); | ||
| 114 | rule CheckIndent = and_(check_indent); | ||
| 162 | 115 | ||
| 163 | template<> | 116 | rule advance = user(Indent, [](const item_t& item) |
| 164 | struct action<op> | 117 | { |
| 118 | int indent = 0; | ||
| 119 | for (input_it i = item.begin; i != item.end; ++i) | ||
| 165 | { | 120 | { |
| 166 | template<typename Input> | 121 | switch (*i) |
| 167 | static void apply(const Input& in, Stack& stack) | ||
| 168 | { | 122 | { |
| 169 | stack.pushOp(*in.begin()); | 123 | case ' ': indent++; break; |
| 124 | case '\t': indent += 4; break; | ||
| 170 | } | 125 | } |
| 171 | }; | 126 | } |
| 172 | 127 | State* st = reinterpret_cast<State*>(item.user_data); | |
| 173 | template<> | 128 | int top = st->indents.top(); |
| 174 | struct action<one<'('>> | 129 | if (top != -1 && indent > top) |
| 175 | { | 130 | { |
| 176 | static void apply0(Stack& stack) | 131 | st->indents.push(indent); |
| 177 | { | 132 | return true; |
| 178 | stack.pushStack(); | 133 | } |
| 179 | } | 134 | return false; |
| 180 | }; | 135 | }); |
| 136 | rule Advance = and_(advance); | ||
| 181 | 137 | ||
| 182 | template<> | 138 | rule push_indent = user(Indent, [](const item_t& item) |
| 183 | struct action<expr> | 139 | { |
| 140 | int indent = 0; | ||
| 141 | for (input_it i = item.begin; i != item.end; ++i) | ||
| 184 | { | 142 | { |
| 185 | template<typename Input> | 143 | switch (*i) |
| 186 | static void apply(const Input& in, Stack& stack) | ||
| 187 | { | 144 | { |
| 188 | stack.popStack(); | 145 | case ' ': indent++; break; |
| 146 | case '\t': indent += 4; break; | ||
| 189 | } | 147 | } |
| 190 | }; | 148 | } |
| 149 | State* st = reinterpret_cast<State*>(item.user_data); | ||
| 150 | st->indents.push(indent); | ||
| 151 | return true; | ||
| 152 | }); | ||
| 153 | rule PushIndent = and_(push_indent); | ||
| 191 | 154 | ||
| 192 | } // namespace hello | 155 | rule PreventIndent = user(true_(), [](const item_t& item) |
| 156 | { | ||
| 157 | State* st = reinterpret_cast<State*>(item.user_data); | ||
| 158 | st->indents.push(-1); | ||
| 159 | return true; | ||
| 160 | }); | ||
| 193 | 161 | ||
| 194 | namespace moon | 162 | rule PopIndent = user(true_(), [](const item_t& item) |
| 195 | { | 163 | { |
| 196 | int moonType = 0; | 164 | State* st = reinterpret_cast<State*>(item.user_data); |
| 165 | st->indents.pop(); | ||
| 166 | return true; | ||
| 167 | }); | ||
| 197 | 168 | ||
| 198 | template <class T> | 169 | extern rule Block; |
| 199 | int MoonType() | ||
| 200 | { | ||
| 201 | static int type = moonType++; | ||
| 202 | return type; | ||
| 203 | } | ||
| 204 | 170 | ||
| 205 | struct Node | 171 | rule InBlock = Advance >> Block >> PopIndent; |
| 206 | { | ||
| 207 | virtual ~Node() {} | ||
| 208 | slice::Slice token; | ||
| 209 | }; | ||
| 210 | 172 | ||
| 211 | struct State | 173 | extern rule NameList; |
| 212 | { | ||
| 213 | State() | ||
| 214 | { | ||
| 215 | indents.push(0); | ||
| 216 | stringOpen = -1; | ||
| 217 | astStack.emplace_back(); | ||
| 218 | } | ||
| 219 | size_t stringOpen; | ||
| 220 | std::stack<int> indents; | ||
| 221 | std::stack<bool> doStack; | ||
| 222 | std::unordered_set<std::string> keywords = | ||
| 223 | { | ||
| 224 | "and", "while", "else", "using", "continue", | ||
| 225 | "local", "not", "then", "return", "from", | ||
| 226 | "extends", "for", "do", "or", "export", | ||
| 227 | "class", "in", "unless", "when", "elseif", | ||
| 228 | "switch", "break", "if", "with", "import" | ||
| 229 | }; | ||
| 230 | std::stack<size_t> indexStack; | ||
| 231 | std::vector<std::vector<std::shared_ptr<Node>>> astStack; | ||
| 232 | }; | ||
| 233 | 174 | ||
| 234 | struct White : star<one<' ', '\t', '\r', '\n'>> {}; | 175 | rule Local = key("local") >> (op('*') | op('^') | NameList); |
| 235 | struct plain_space : star<one<' ', '\t'>> {}; | ||
| 236 | struct Break : seq<opt<one<'\r'>>, one<'\n'>> {}; | ||
| 237 | struct Stop : sor<Break, eof> {}; | ||
| 238 | struct Comment : seq<string<'-', '-'>, star<not_at<one<'\r', '\n'>>, any>, at<Stop>> {}; | ||
| 239 | struct Indent : star<one<' ', '\t'>> {}; | ||
| 240 | struct Space : seq<plain_space, opt<Comment>> {}; | ||
| 241 | struct SomeSpace : seq<plus<blank>, opt<Comment>> {}; | ||
| 242 | struct SpaceBreak : seq<Space, Break> {}; | ||
| 243 | typedef SpaceBreak EmptyLine; | ||
| 244 | struct AlphaNum : ranges<'a', 'z', 'A', 'Z', '0', '9', '_', '_'> {}; | ||
| 245 | struct _Name : seq<ranges<'a', 'z', 'A', 'Z', '_', '_'>, star<AlphaNum>> {}; | ||
| 246 | struct SpaceName : seq<Space, _Name> {}; | ||
| 247 | struct _Num : sor< | ||
| 248 | seq< | ||
| 249 | string<'0' ,'x'>, | ||
| 250 | plus<ranges<'0', '9', 'a', 'f', 'A', 'F'>>, | ||
| 251 | opt<seq< | ||
| 252 | opt<one<'u', 'U'>>, one<'l', 'L'>, one<'l', 'L'> | ||
| 253 | >> | ||
| 254 | >, | ||
| 255 | seq< | ||
| 256 | plus<range<'0', '9'>>, | ||
| 257 | seq< | ||
| 258 | opt<one<'u', 'U'>>, one<'l', 'L'>, one<'l', 'L'> | ||
| 259 | > | ||
| 260 | >, | ||
| 261 | seq< | ||
| 262 | sor< | ||
| 263 | seq< | ||
| 264 | plus<range<'0', '9'>>, | ||
| 265 | opt<seq< | ||
| 266 | one<'.'>, plus<range<'0', '9'>> | ||
| 267 | >> | ||
| 268 | >, | ||
| 269 | seq< | ||
| 270 | one<'.'>, | ||
| 271 | plus<range<'0', '9'>> | ||
| 272 | > | ||
| 273 | >, | ||
| 274 | opt<seq< | ||
| 275 | one<'e', 'E'>, opt<one<'-'>>, plus<range<'0', '9'>> | ||
| 276 | >> | ||
| 277 | > | ||
| 278 | > {}; | ||
| 279 | struct Num : seq<Space, _Num> {}; | ||
| 280 | |||
| 281 | struct Cut : failure {}; | ||
| 282 | |||
| 283 | template<char... Cs> struct sym : seq<Space, string<Cs...>> {}; | ||
| 284 | template<char... Cs> struct symx : string<Cs...> {}; | ||
| 285 | |||
| 286 | template<typename patt, typename finally> | ||
| 287 | struct ensure : sor<seq<patt, finally>, seq<finally, Cut>> {}; | ||
| 288 | |||
| 289 | template<char... Cs> struct key : seq<Space, string<Cs...>, not_at<AlphaNum>> {}; | ||
| 290 | template<char... Cs> struct opWord : seq<Space, string<Cs...>, not_at<AlphaNum>> {}; | ||
| 291 | template<char... Cs> struct op : seq<Space, string<Cs...>> {}; | ||
| 292 | |||
| 293 | struct Name | ||
| 294 | { | ||
| 295 | using analyze_t = analysis::generic<analysis::rule_type::ANY>; | ||
| 296 | 176 | ||
| 297 | template<apply_mode A, rewind_mode M, | 177 | rule colon_import_name = sym('\\') >> Name; |
| 298 | template<typename...> class Action, | 178 | rule ImportName = colon_import_name | Name; |
| 299 | template<typename...> class Control, | 179 | rule ImportNameList = *SpaceBreak >> ImportName >> *((+SpaceBreak | sym(',') >> *SpaceBreak) >> ImportName); |
| 300 | typename Input> | ||
| 301 | static bool match(Input& in, State& st) | ||
| 302 | { | ||
| 303 | const char* current = in.current(); | ||
| 304 | memory_input<> memIn(current, in.end() - current, current); | ||
| 305 | if (SpaceName::match<A, M, Action, Control>(memIn, st)) | ||
| 306 | { | ||
| 307 | auto name = slice::Slice(current, memIn.current() - current); | ||
| 308 | auto trimed = name; | ||
| 309 | trimed.trimSpace(); | ||
| 310 | auto it = st.keywords.find(trimed); | ||
| 311 | if (it == st.keywords.end()) | ||
| 312 | { | ||
| 313 | in.bump(name.size()); | ||
| 314 | return true; | ||
| 315 | } | ||
| 316 | } | ||
| 317 | return false; | ||
| 318 | } | ||
| 319 | }; | ||
| 320 | 180 | ||
| 321 | struct self : one<'@'> {}; | 181 | extern rule Exp; |
| 322 | struct self_name : seq<one<'@'>, _Name> {}; | ||
| 323 | struct self_class : string<'@', '@'> {}; | ||
| 324 | struct self_class_name : seq<string<'@', '@'>, _Name> {}; | ||
| 325 | 182 | ||
| 326 | struct SelfName : seq<Space, sor<self_class_name, self_class, self_name, self>> {}; | 183 | rule Import = key("import") >> ImportNameList >> *SpaceBreak >> key("from") >> Exp; |
| 327 | struct KeyName : sor<SelfName, seq<Space, _Name>> {}; | 184 | rule BreakLoop = key("break") | key("continue"); |
| 328 | struct VarArg : seq<Space, string<'.', '.', '.'>> {}; | ||
| 329 | 185 | ||
| 330 | struct CheckIndentBump | 186 | extern rule ExpListLow, ExpList, Assign; |
| 331 | { | ||
| 332 | using analyze_t = analysis::generic<analysis::rule_type::ANY>; | ||
| 333 | 187 | ||
| 334 | template<apply_mode A, rewind_mode M, | 188 | rule Return = key("return") >> (ExpListLow | Nothing); |
| 335 | template<typename...> class Action, | 189 | rule WithExp = ExpList >> -Assign; |
| 336 | template<typename...> class Control, | ||
| 337 | typename Input> | ||
| 338 | static bool match(Input& in, State& st) | ||
| 339 | { | ||
| 340 | const char* current = in.current(); | ||
| 341 | if (Indent::match<A, M, Action, Control>(in, st)) | ||
| 342 | { | ||
| 343 | int indent = 0; | ||
| 344 | for (const char* ch = current; ch < in.current(); ch++) | ||
| 345 | { | ||
| 346 | switch (*ch) | ||
| 347 | { | ||
| 348 | case ' ': indent++; break; | ||
| 349 | case '\t': indent += 4; break; | ||
| 350 | } | ||
| 351 | } | ||
| 352 | return st.indents.top() == indent; | ||
| 353 | } | ||
| 354 | return false; | ||
| 355 | } | ||
| 356 | }; | ||
| 357 | struct CheckIndent : at<CheckIndentBump> {}; | ||
| 358 | 190 | ||
| 359 | struct AdvanceBump | 191 | extern rule DisableDo, PopDo, Body; |
| 360 | { | ||
| 361 | using analyze_t = analysis::generic<analysis::rule_type::ANY>; | ||
| 362 | 192 | ||
| 363 | template<apply_mode A, rewind_mode M, | 193 | rule With = key("with") >> DisableDo >> ensure(WithExp, PopDo) >> -key("do") >> Body; |
| 364 | template<typename...> class Action, | 194 | rule SwitchCase = key("when") >> ExpList >> -key("then") >> Body; |
| 365 | template<typename...> class Control, | 195 | rule SwitchElse = key("else") >> Body; |
| 366 | typename Input> | ||
| 367 | static bool match(Input& in, State& st) | ||
| 368 | { | ||
| 369 | const char* current = in.current(); | ||
| 370 | if (Indent::match<A, M, Action, Control>(in, st)) | ||
| 371 | { | ||
| 372 | int indent = 0; | ||
| 373 | for (const char* ch = current; ch < in.current(); ch++) | ||
| 374 | { | ||
| 375 | switch (*ch) | ||
| 376 | { | ||
| 377 | case ' ': indent++; break; | ||
| 378 | case '\t': indent += 4; break; | ||
| 379 | } | ||
| 380 | } | ||
| 381 | int top = st.indents.top(); | ||
| 382 | if (top != -1 && indent > top) | ||
| 383 | { | ||
| 384 | st.indents.push(indent); | ||
| 385 | return true; | ||
| 386 | } | ||
| 387 | return false; | ||
| 388 | } | ||
| 389 | return false; | ||
| 390 | } | ||
| 391 | }; | ||
| 392 | struct Advance : at<AdvanceBump> {}; | ||
| 393 | 196 | ||
| 394 | struct PushIndentBump | 197 | rule SwitchBlock = *EmptyLine >> |
| 395 | { | 198 | Advance >> |
| 396 | using analyze_t = analysis::generic<analysis::rule_type::ANY>; | 199 | SwitchCase >> |
| 200 | *(+Break >> SwitchCase) >> | ||
| 201 | -(+Break >> SwitchElse) >> | ||
| 202 | PopIndent; | ||
| 397 | 203 | ||
| 398 | template<apply_mode A, rewind_mode M, | 204 | rule Switch = key("switch") >> |
| 399 | template<typename...> class Action, | 205 | DisableDo >> ensure(Exp, PopDo) >> |
| 400 | template<typename...> class Control, | 206 | -key("do") >> -Space >> Break >> SwitchBlock; |
| 401 | typename Input> | ||
| 402 | static bool match(Input& in, State& st) | ||
| 403 | { | ||
| 404 | const char* current = in.current(); | ||
| 405 | if (Indent::match<A, M, Action, Control>(in, st)) | ||
| 406 | { | ||
| 407 | int indent = 0; | ||
| 408 | for (const char* ch = current; ch < in.current(); ch++) | ||
| 409 | { | ||
| 410 | switch (*ch) | ||
| 411 | { | ||
| 412 | case ' ': indent++; break; | ||
| 413 | case '\t': indent += 4; break; | ||
| 414 | } | ||
| 415 | } | ||
| 416 | st.indents.push(indent); | ||
| 417 | return true; | ||
| 418 | } | ||
| 419 | return false; | ||
| 420 | } | ||
| 421 | }; | ||
| 422 | struct PushIndent : at<PushIndentBump> {}; | ||
| 423 | 207 | ||
| 424 | struct PreventIndentBump | 208 | rule IfCond = Exp >> -Assign; |
| 425 | { | 209 | rule IfElseIf = -(Break >> *EmptyLine >> CheckIndent) >> key("elseif") >> IfCond >> -key("then") >> Body; |
| 426 | using analyze_t = analysis::generic<analysis::rule_type::ANY>; | 210 | rule IfElse = -(Break >> *EmptyLine >> CheckIndent) >> key("else") >> Body; |
| 211 | rule If = key("if") >> IfCond >> -key("then") >> Body >> *IfElseIf >> -IfElse; | ||
| 212 | rule Unless = key("unless") >> IfCond >> -key("then") >> Body >> *IfElseIf >> -IfElse; | ||
| 427 | 213 | ||
| 428 | template<apply_mode A, rewind_mode M, | 214 | rule While = key("while") >> DisableDo >> ensure(Exp, PopDo) >> -key("do") >> Body; |
| 429 | template<typename...> class Action, | ||
| 430 | template<typename...> class Control, | ||
| 431 | typename Input> | ||
| 432 | static bool match(Input& in, State& st) | ||
| 433 | { | ||
| 434 | st.indents.push(-1); | ||
| 435 | return true; | ||
| 436 | } | ||
| 437 | }; | ||
| 438 | struct PreventIndent : at<PreventIndentBump> {}; | ||
| 439 | 215 | ||
| 440 | struct PopIndentBump | 216 | rule for_args = Name >> sym('=') >> Exp >> sym(',') >> Exp >> (sym(',') >> Exp | Nothing); |
| 441 | { | ||
| 442 | using analyze_t = analysis::generic<analysis::rule_type::ANY>; | ||
| 443 | 217 | ||
| 444 | template<apply_mode A, rewind_mode M, | 218 | rule For = key("for") >> DisableDo >> |
| 445 | template<typename...> class Action, | 219 | ensure(for_args, PopDo) >> |
| 446 | template<typename...> class Control, | 220 | -key("do") >> Body; |
| 447 | typename Input> | ||
| 448 | static bool match(Input& in, State& st) | ||
| 449 | { | ||
| 450 | st.indents.pop(); | ||
| 451 | return true; | ||
| 452 | } | ||
| 453 | }; | ||
| 454 | struct PopIndent : at<PopIndentBump> {}; | ||
| 455 | |||
| 456 | struct Block; | ||
| 457 | |||
| 458 | struct InBlock : seq<Advance, Block, PopIndent> {}; | ||
| 459 | |||
| 460 | struct NameList; | ||
| 461 | |||
| 462 | struct Local : seq< | ||
| 463 | key<'l', 'o', 'c', 'a', 'l'>, | ||
| 464 | sor< | ||
| 465 | sor<op<'*'>, op<'^'>>, | ||
| 466 | NameList | ||
| 467 | > | ||
| 468 | > {}; | ||
| 469 | |||
| 470 | struct colon_import_name : seq<sym<'\\'>, Name> {}; | ||
| 471 | struct ImportName : sor<colon_import_name, Name> {}; | ||
| 472 | struct ImportNameList : seq< | ||
| 473 | star<SpaceBreak>, | ||
| 474 | ImportName, | ||
| 475 | star< | ||
| 476 | sor< | ||
| 477 | plus<SpaceBreak>, | ||
| 478 | seq<sym<','>, star<SpaceBreak>> | ||
| 479 | >, | ||
| 480 | ImportName | ||
| 481 | > | ||
| 482 | > {}; | ||
| 483 | |||
| 484 | struct Exp; | ||
| 485 | |||
| 486 | struct Import : seq<key<'i', 'm', 'p', 'o', 'r', 't'>, ImportNameList, star<SpaceBreak>, key<'f', 'r', 'o', 'm'>, Exp> {}; | ||
| 487 | |||
| 488 | struct BreakLoop : sor<key<'b', 'r', 'e', 'a', 'k'>, key<'c', 'o', 'n', 't', 'i', 'n', 'u', 'e'>> {}; | ||
| 489 | |||
| 490 | struct ExpListLow; | ||
| 491 | |||
| 492 | struct ExpList; | ||
| 493 | struct Assign; | ||
| 494 | |||
| 495 | struct Return : seq<key<'r', 'e', 't', 'u', 'r', 'n'>, sor<ExpListLow, success>> {}; | ||
| 496 | struct WithExp : seq<ExpList, opt<Assign>> {}; | ||
| 497 | |||
| 498 | struct DisableDo; | ||
| 499 | struct PopDo; | ||
| 500 | struct Body; | ||
| 501 | |||
| 502 | struct With : seq<key<'w', 'i', 't', 'h'>, DisableDo, ensure<WithExp, PopDo>, opt<key<'d', 'o'>>, Body> {}; | ||
| 503 | |||
| 504 | struct SwitchCase : seq<key<'w', 'h', 'e', 'n'>, ExpList, opt<key<'t', 'h', 'e', 'n'>>, Body> {}; | ||
| 505 | struct SwitchElse : seq<key<'e', 'l', 's', 'e'>, Body> {}; | ||
| 506 | struct SwitchBlock : seq< | ||
| 507 | star<EmptyLine>, | ||
| 508 | Advance, | ||
| 509 | seq< | ||
| 510 | SwitchCase, | ||
| 511 | star<plus<Break>, SwitchCase>, | ||
| 512 | opt<plus<Break>, SwitchElse> | ||
| 513 | >, | ||
| 514 | PopIndent | ||
| 515 | > {}; | ||
| 516 | struct Switch : seq<key<'s', 'w', 'i', 't', 'c', 'h'>, DisableDo, ensure<Exp, PopDo>, opt<key<'d', 'o'>>, opt<Space>, Break, SwitchBlock> {}; | ||
| 517 | |||
| 518 | struct IfCond : seq<Exp, opt<Assign>> {}; | ||
| 519 | |||
| 520 | struct IfElse : seq< | ||
| 521 | opt<Break, star<EmptyLine>, CheckIndent>, | ||
| 522 | key<'e', 'l', 's', 'e'>, Body | ||
| 523 | > {}; | ||
| 524 | |||
| 525 | struct IfElseIf : seq< | ||
| 526 | opt<Break, star<EmptyLine>, CheckIndent>, | ||
| 527 | key<'e', 'l', 's', 'e', 'i', 'f'>, IfCond, | ||
| 528 | opt<key<'t', 'h', 'e', 'n'>>, Body | ||
| 529 | > {}; | ||
| 530 | |||
| 531 | struct If : seq<key<'i', 'f'>, IfCond, opt<key<'t', 'h', 'e', 'n'>>, Body, star<IfElseIf>, opt<IfElse>> {}; | ||
| 532 | struct Unless : seq<key<'u', 'n', 'l', 'e', 's', 's'>, IfCond, opt<key<'t', 'h', 'e', 'n'>>, Body, star<IfElseIf>, opt<IfElse>> {}; | ||
| 533 | |||
| 534 | struct While : seq<key<'w', 'h', 'i', 'l', 'e'>, DisableDo, ensure<Exp, PopDo>, opt<key<'d','o'>>, Body> {}; | ||
| 535 | struct For : seq<key<'f', 'o', 'r'>, DisableDo, | ||
| 536 | ensure< | ||
| 537 | seq< | ||
| 538 | Name, sym<'='>, | ||
| 539 | seq<Exp, sym<','>, Exp, opt<sym<','>, Exp>> | ||
| 540 | >, | ||
| 541 | PopDo | ||
| 542 | >, | ||
| 543 | opt<key<'d', 'o'>>, Body> {}; | ||
| 544 | |||
| 545 | struct AssignableNameList; | ||
| 546 | |||
| 547 | struct ForEach : seq< | ||
| 548 | key<'f', 'o', 'r'>, | ||
| 549 | AssignableNameList, | ||
| 550 | key<'i', 'n'>, | ||
| 551 | DisableDo, | ||
| 552 | ensure< | ||
| 553 | sor< | ||
| 554 | seq<sym<'*'>, Exp>, ExpList | ||
| 555 | >, | ||
| 556 | PopDo | ||
| 557 | >, | ||
| 558 | opt<key<'d', 'o'>>, | ||
| 559 | Body | ||
| 560 | > {}; | ||
| 561 | |||
| 562 | struct Do | ||
| 563 | { | ||
| 564 | using analyze_t = analysis::generic<analysis::rule_type::ANY>; | ||
| 565 | 221 | ||
| 566 | template<apply_mode A, rewind_mode M, | 222 | extern rule AssignableNameList; |
| 567 | template<typename...> class Action, | ||
| 568 | template<typename...> class Control, | ||
| 569 | typename Input> | ||
| 570 | static bool match(Input& in, State& st) | ||
| 571 | { | ||
| 572 | if (at<seq<key<'d', 'o'>, Body>>::match<A, M, Action, Control>(in, st)) | ||
| 573 | { | ||
| 574 | if (st.doStack.empty() || st.doStack.top()) | ||
| 575 | { | ||
| 576 | return true; | ||
| 577 | } | ||
| 578 | } | ||
| 579 | return false; | ||
| 580 | } | ||
| 581 | }; | ||
| 582 | 223 | ||
| 583 | struct DisableDo | 224 | rule for_in = sym('*') >> Exp | ExpList; |
| 584 | { | ||
| 585 | using analyze_t = analysis::generic<analysis::rule_type::ANY>; | ||
| 586 | 225 | ||
| 587 | template<apply_mode A, rewind_mode M, | 226 | rule ForEach = key("for") >> AssignableNameList >> key("in") >> |
| 588 | template<typename...> class Action, | 227 | DisableDo >> ensure(for_in, PopDo) >> |
| 589 | template<typename...> class Control, | 228 | -key("do") >> Body; |
| 590 | typename Input> | ||
| 591 | static bool match(Input& in, State& st) | ||
| 592 | { | ||
| 593 | st.doStack.push(false); | ||
| 594 | return true; | ||
| 595 | } | ||
| 596 | }; | ||
| 597 | 229 | ||
| 598 | struct PopDo | 230 | rule Do = user(key("do") >> Body, [](const item_t& item) |
| 599 | { | 231 | { |
| 600 | using analyze_t = analysis::generic<analysis::rule_type::ANY>; | 232 | State* st = reinterpret_cast<State*>(item.user_data); |
| 233 | return st->doStack.empty() || st->doStack.top(); | ||
| 234 | }); | ||
| 601 | 235 | ||
| 602 | template<apply_mode A, rewind_mode M, | 236 | rule DisableDo = user(true_(), [](const item_t& item) |
| 603 | template<typename...> class Action, | 237 | { |
| 604 | template<typename...> class Control, | 238 | State* st = reinterpret_cast<State*>(item.user_data); |
| 605 | typename Input> | 239 | st->doStack.push(false); |
| 606 | static bool match(Input& in, State& st) | 240 | return true; |
| 607 | { | 241 | }); |
| 608 | st.doStack.pop(); | ||
| 609 | return true; | ||
| 610 | } | ||
| 611 | }; | ||
| 612 | 242 | ||
| 613 | struct CompInner; | 243 | rule PopDo = user(true_(), [](const item_t& item) |
| 614 | 244 | { | |
| 615 | struct Comprehension : seq<sym<'['>, Exp, CompInner, sym<']'>> {}; | 245 | State* st = reinterpret_cast<State*>(item.user_data); |
| 616 | struct TblComprehension : seq<sym<'{'>, seq<Exp, opt<sym<','>, Exp>>, CompInner, sym<'}'>> {}; | 246 | st->doStack.pop(); |
| 617 | 247 | return true; | |
| 618 | struct CompForEach; | 248 | }); |
| 619 | struct CompFor; | ||
| 620 | struct CompClause; | ||
| 621 | |||
| 622 | struct CompInner : seq<sor<CompForEach, CompFor>, star<CompClause>> {}; | ||
| 623 | struct CompForEach : seq< | ||
| 624 | key<'f', 'o', 'r'>, | ||
| 625 | AssignableNameList, | ||
| 626 | key<'i', 'n'>, | ||
| 627 | sor< | ||
| 628 | seq<sym<'*'>, Exp>, Exp | ||
| 629 | > | ||
| 630 | > {}; | ||
| 631 | struct CompFor : seq<key<'f', 'o', 'r'>, Name, sym<'='>, seq<Exp, sym<','>, Exp, opt<sym<','>, Exp>>> {}; | ||
| 632 | struct CompClause : sor<CompFor, CompForEach, seq<key<'w', 'h', 'e', 'n'>, Exp>> {}; | ||
| 633 | |||
| 634 | struct TableBlock; | ||
| 635 | |||
| 636 | struct Assign : seq<sym<'='>, sor<With, If, Switch, TableBlock, ExpListLow>> {}; | ||
| 637 | |||
| 638 | struct Update : seq<sor< | ||
| 639 | sym<'.', '.', '='>, | ||
| 640 | sym<'+', '='>, | ||
| 641 | sym<'-', '='>, | ||
| 642 | sym<'*', '='>, | ||
| 643 | sym<'/', '='>, | ||
| 644 | sym<'%', '='>, | ||
| 645 | sym<'o', 'r', '='>, | ||
| 646 | sym<'a', 'n', 'd', '='>, | ||
| 647 | sym<'&', '='>, | ||
| 648 | sym<'|', '='>, | ||
| 649 | sym<'>', '>', '='>, | ||
| 650 | sym<'<', '<', '='> | ||
| 651 | >, Exp> {}; | ||
| 652 | |||
| 653 | struct CharOperators : seq<Space, one<'+', '-', '*' ,'/', '%', '^', '>', '<', '|', '&'>> {}; | ||
| 654 | struct WordOperators : sor< | ||
| 655 | opWord<'o', 'r'>, | ||
| 656 | opWord<'a', 'n', 'd'>, | ||
| 657 | op<'<', '='>, | ||
| 658 | op<'>', '='>, | ||
| 659 | op<'~', '='>, | ||
| 660 | op<'!', '='>, | ||
| 661 | op<'=', '='>, | ||
| 662 | op<'.', '.'>, | ||
| 663 | op<'<', '<'>, | ||
| 664 | op<'>', '>'>, | ||
| 665 | op<'/', '/'>> {}; | ||
| 666 | struct BinaryOperator : seq<sor<WordOperators, CharOperators>, star<SpaceBreak>> {}; | ||
| 667 | |||
| 668 | struct Chain; | ||
| 669 | |||
| 670 | struct Assignable : sor<at<Chain>, Name, SelfName> {}; | ||
| 671 | |||
| 672 | struct Value; | ||
| 673 | |||
| 674 | struct Exp : seq<Value, star<BinaryOperator, Value>> {}; | ||
| 675 | |||
| 676 | struct Callable; | ||
| 677 | struct InvokeArgs; | ||
| 678 | |||
| 679 | struct ChainValue : seq<sor<Chain, Callable>, opt<InvokeArgs>> {}; | ||
| 680 | |||
| 681 | struct KeyValueList; | ||
| 682 | struct String; | ||
| 683 | struct SimpleValue; | ||
| 684 | |||
| 685 | struct Value : sor<SimpleValue, KeyValueList, ChainValue, String> {}; | ||
| 686 | struct SliceValue : Exp {}; | ||
| 687 | |||
| 688 | struct LuaString; | ||
| 689 | |||
| 690 | struct single_string_inner : sor<string<'\\', '\''>, string<'\\', '\\'>, not_one<'\''>> {}; | ||
| 691 | struct SingleString : seq<symx<'\''>, star<single_string_inner>, sym<'\''>> {}; | ||
| 692 | struct interp : seq<symx<'#', '{'>, Exp, sym<'}'>> {}; | ||
| 693 | struct double_string_plain : sor<string<'\\', '\"'>, string<'\\', '\\'>, not_one<'\"'>> {}; | ||
| 694 | struct double_string_inner : plus<seq<not_at<interp>, double_string_plain>> {}; | ||
| 695 | struct DoubleString : seq<symx<'\"'>, star<sor<double_string_inner, interp>>, sym<'\"'>> {}; | ||
| 696 | struct String : sor<seq<Space, DoubleString>, seq<Space, SingleString>, LuaString> {}; | ||
| 697 | |||
| 698 | struct lua_string_open : seq<one<'['>, star<one<'='>>, one<'['>> {}; | ||
| 699 | struct lua_string_close : seq<one<']'>, star<one<'='>>, one<']'>> {}; | ||
| 700 | |||
| 701 | struct LuaStringOpen | ||
| 702 | { | ||
| 703 | using analyze_t = analysis::generic<analysis::rule_type::ANY>; | ||
| 704 | 249 | ||
| 705 | template<apply_mode A, rewind_mode M, | 250 | extern rule CompInner; |
| 706 | template<typename...> class Action, | ||
| 707 | template<typename...> class Control, | ||
| 708 | typename Input> | ||
| 709 | static bool match(Input& in, State& st) | ||
| 710 | { | ||
| 711 | const char* current = in.current(); | ||
| 712 | if (lua_string_open::match<A, M, Action, Control>(in, st)) | ||
| 713 | { | ||
| 714 | st.stringOpen = in.current() - current + 1; | ||
| 715 | return true; | ||
| 716 | } | ||
| 717 | return false; | ||
| 718 | } | ||
| 719 | }; | ||
| 720 | 251 | ||
| 721 | struct LuaStringClose | 252 | rule Comprehension = sym('[') >> Exp >> CompInner >> sym(']'); |
| 722 | { | 253 | rule TblComprehension = sym('{') >> (Exp >> -(sym(',') >> Exp)) >> CompInner >> sym('}'); |
| 723 | using analyze_t = analysis::generic<analysis::rule_type::ANY>; | ||
| 724 | 254 | ||
| 725 | template<apply_mode A, rewind_mode M, | 255 | extern rule CompForEach, CompFor, CompClause; |
| 726 | template<typename...> class Action, | ||
| 727 | template<typename...> class Control, | ||
| 728 | typename Input> | ||
| 729 | static bool match(Input& in, State& st) | ||
| 730 | { | ||
| 731 | const char* current = in.current(); | ||
| 732 | if (lua_string_close::match<A, M, Action, Control>(in, st)) | ||
| 733 | { | ||
| 734 | return st.stringOpen == in.current() - current + 1; | ||
| 735 | } | ||
| 736 | return false; | ||
| 737 | } | ||
| 738 | }; | ||
| 739 | 256 | ||
| 740 | struct LuaStringContent : star<not_at<LuaStringClose>, any> {}; | 257 | rule CompInner = (CompForEach | CompFor) >> *CompClause; |
| 258 | rule CompForEach = key("for") >> AssignableNameList >> key("in") >> (sym('*') >> Exp | Exp); | ||
| 259 | rule CompFor = key("for") >> Name >> sym('=') >> Exp >> sym(',') >> Exp >> (sym(',') >> Exp | Nothing); | ||
| 260 | rule CompClause = CompFor | CompForEach | key("when") >> Exp; | ||
| 741 | 261 | ||
| 742 | struct LuaString | 262 | extern rule TableBlock; |
| 743 | { | ||
| 744 | using analyze_t = analysis::generic<analysis::rule_type::ANY>; | ||
| 745 | 263 | ||
| 746 | template<apply_mode A, rewind_mode M, | 264 | rule Assign = sym('=') >> (With | If | Switch | TableBlock | ExpListLow); |
| 747 | template<typename...> class Action, | ||
| 748 | template<typename...> class Control, | ||
| 749 | typename Input> | ||
| 750 | static bool match(Input& in, State& st) | ||
| 751 | { | ||
| 752 | bool result = seq<LuaStringOpen, opt<Break>, LuaStringContent, LuaStringClose>::match<A, M, Action, Control>(in, st); | ||
| 753 | st.stringOpen = -1; | ||
| 754 | return result; | ||
| 755 | } | ||
| 756 | }; | ||
| 757 | 265 | ||
| 758 | struct Parens : seq<sym<'('>, star<SpaceBreak>, Exp, star<SpaceBreak>, sym<')'>> {}; | 266 | rule Update = |
| 759 | struct Callable : sor<Name, SelfName, VarArg, Parens> {}; | 267 | ( |
| 760 | 268 | sym("..=") | | |
| 761 | struct FnArgsExpList : seq< | 269 | sym("+=") | |
| 762 | Exp, | 270 | sym("-=") | |
| 763 | star< | 271 | sym("*=") | |
| 764 | sor<Break, sym<','>>, | 272 | sym("/=") | |
| 765 | White, Exp | 273 | sym("%=") | |
| 766 | > | 274 | sym("or=") | |
| 767 | > {}; | 275 | sym("and=") | |
| 768 | 276 | sym("&=") | | |
| 769 | struct FnArgs : sor< | 277 | sym("|=") | |
| 770 | seq<symx<'('>, star<SpaceBreak>, opt<FnArgsExpList>, star<SpaceBreak>, sym<')'>>, | 278 | sym(">>=") | |
| 771 | seq<sym<'!'>, not_at<one<'='>>> | 279 | sym("<<=") |
| 772 | > {}; | 280 | ) >> Exp; |
| 773 | |||
| 774 | struct ChainItems; | ||
| 775 | struct DotChainItem; | ||
| 776 | struct ColonChain; | ||
| 777 | |||
| 778 | struct Chain : sor< | ||
| 779 | seq< | ||
| 780 | sor<Callable, String, not_at<one<'.', '\\'>>>, | ||
| 781 | ChainItems | ||
| 782 | >, | ||
| 783 | seq<Space, | ||
| 784 | sor< | ||
| 785 | seq<DotChainItem, opt<ChainItems>>, | ||
| 786 | ColonChain | ||
| 787 | > | ||
| 788 | > | ||
| 789 | > {}; | ||
| 790 | |||
| 791 | struct ChainItem; | ||
| 792 | |||
| 793 | struct ChainItems : sor< | ||
| 794 | seq<plus<ChainItem>, opt<ColonChain>>, | ||
| 795 | ColonChain | ||
| 796 | > {}; | ||
| 797 | |||
| 798 | struct Invoke; | ||
| 799 | struct Slice; | ||
| 800 | |||
| 801 | struct ChainItem : sor< | ||
| 802 | Invoke, | ||
| 803 | DotChainItem, | ||
| 804 | Slice, | ||
| 805 | seq<symx<'['>, Exp, sym<']'>> | ||
| 806 | > {}; | ||
| 807 | |||
| 808 | struct DotChainItem : seq<symx<'.'>, _Name> {}; | ||
| 809 | struct ColonChainItem : seq<symx<'\\'>, _Name> {}; | ||
| 810 | struct ColonChain : seq< | ||
| 811 | ColonChainItem, | ||
| 812 | opt<Invoke, opt<ChainItems>> | ||
| 813 | > {}; | ||
| 814 | |||
| 815 | struct SliceOne : success {}; | ||
| 816 | struct SliceTwo : success {}; | ||
| 817 | struct Slice : seq< | ||
| 818 | symx<'['>, sor<SliceValue, SliceOne>, sym<','>, sor<SliceValue, SliceTwo>, opt<sym<','>, SliceValue>, sym<']'>> {}; | ||
| 819 | |||
| 820 | struct Invoke : sor< | ||
| 821 | FnArgs, | ||
| 822 | SingleString, | ||
| 823 | DoubleString, | ||
| 824 | seq<at<one<'['>>, LuaString> | ||
| 825 | > {}; | ||
| 826 | |||
| 827 | struct KeyValue; | ||
| 828 | struct TableValueList; | ||
| 829 | struct TableLitLine; | ||
| 830 | |||
| 831 | struct TableValue : sor<KeyValue, Exp> {}; | ||
| 832 | struct TableLit : seq< | ||
| 833 | sym<'{'>, | ||
| 834 | seq< | ||
| 835 | opt<TableValueList>, opt<sym<','>>, | ||
| 836 | opt< | ||
| 837 | SpaceBreak, TableLitLine, | ||
| 838 | star<opt<sym<','>>, SpaceBreak, TableLitLine>, | ||
| 839 | opt<sym<','>> | ||
| 840 | > | ||
| 841 | >, | ||
| 842 | White, sym<'}'> | ||
| 843 | > {}; | ||
| 844 | |||
| 845 | struct TableValueList : seq<TableValue, star<sym<','>, TableValue>> {}; | ||
| 846 | struct TableLitLine : sor< | ||
| 847 | seq<PushIndent, sor<seq<TableValueList, PopIndent>, seq<PopIndent, Cut>>>, | ||
| 848 | Space | ||
| 849 | > {}; | ||
| 850 | |||
| 851 | struct KeyValueLine; | ||
| 852 | |||
| 853 | struct TableBlockInner : seq<KeyValueLine, star<plus<SpaceBreak>, KeyValueLine>> {}; | ||
| 854 | struct TableBlock : seq<plus<SpaceBreak>, Advance, ensure<TableBlockInner, PopIndent>> {}; | ||
| 855 | |||
| 856 | struct Statement; | ||
| 857 | |||
| 858 | struct ClassLine : seq< | ||
| 859 | CheckIndent, | ||
| 860 | seq< | ||
| 861 | sor<KeyValueList, Statement, Exp>, | ||
| 862 | opt<sym<','>> | ||
| 863 | > | ||
| 864 | > {}; | ||
| 865 | |||
| 866 | struct ClassBlock : seq<plus<SpaceBreak>, Advance, ClassLine, star<plus<SpaceBreak>, ClassLine>, PopIndent> {}; | ||
| 867 | |||
| 868 | struct class_no_derive : success {}; | ||
| 869 | struct class_no_extend : success {}; | ||
| 870 | struct class_no_body : success {}; | ||
| 871 | struct ClassDecl : seq< | ||
| 872 | string<'c', 'l', 'a', 's', 's'>, | ||
| 873 | not_at<one<':'>>, | ||
| 874 | sor<Assignable, class_no_derive>, | ||
| 875 | opt<sor<string<'e', 'x', 't', 'e', 'n', 'd', 's'>, PreventIndent, ensure<Exp, PopIndent>, class_no_extend>>, | ||
| 876 | sor<ClassBlock, class_no_body> | ||
| 877 | > {}; | ||
| 878 | |||
| 879 | struct Export : seq< | ||
| 880 | string<'e', 'x', 'p', 'o', 'r', 't'>, | ||
| 881 | sor< | ||
| 882 | ClassDecl, | ||
| 883 | op<'*'>, | ||
| 884 | op<'^'>, | ||
| 885 | seq<NameList, opt<sym<'='>, ExpListLow>> | ||
| 886 | > | ||
| 887 | > {}; | ||
| 888 | |||
| 889 | struct KeyValue : sor< | ||
| 890 | seq<sym<':'>, not_at<SomeSpace>, Name>, | ||
| 891 | seq< | ||
| 892 | sor< | ||
| 893 | KeyName, | ||
| 894 | seq<sym<'['>, Exp, sym<']'>>, | ||
| 895 | seq<Space, DoubleString>, | ||
| 896 | seq<Space, SingleString> | ||
| 897 | >, | ||
| 898 | symx<':'>, | ||
| 899 | sor< | ||
| 900 | Exp, TableBlock, seq<plus<SpaceBreak>, Exp> | ||
| 901 | > | ||
| 902 | > | ||
| 903 | > {}; | ||
| 904 | |||
| 905 | struct KeyValueList : seq<KeyValue, star<sym<','>, KeyValue>> {}; | ||
| 906 | struct KeyValueLine : seq<CheckIndent, KeyValueList, opt<sym<','>>> {}; | ||
| 907 | |||
| 908 | struct FnArgDef : seq<sor<Name, SelfName>, opt<sym<'='>, Exp>> {}; | ||
| 909 | |||
| 910 | struct FnArgDefList : sor< | ||
| 911 | seq< | ||
| 912 | FnArgDef, | ||
| 913 | star<sor<sym<','>, Break>, White, FnArgDef>, | ||
| 914 | star<sor<sym<','>, Break>, White, VarArg> | ||
| 915 | >, | ||
| 916 | VarArg | ||
| 917 | > {}; | ||
| 918 | |||
| 919 | struct outer_value_shadow : seq<string<'u', 's', 'i', 'n', 'g'>, sor<NameList, seq<Space, string<'n', 'i', 'l'>>>> {}; | ||
| 920 | struct outer_value_no_shadow : success {}; | ||
| 921 | struct without_args_def : success {}; | ||
| 922 | |||
| 923 | struct FnArgsDef : sor< | ||
| 924 | seq<sym<'('>, White, opt<FnArgDefList>, | ||
| 925 | sor< | ||
| 926 | outer_value_shadow, | ||
| 927 | outer_value_no_shadow | ||
| 928 | >, | ||
| 929 | White, sym<')'> | ||
| 930 | >, | ||
| 931 | without_args_def | ||
| 932 | > {}; | ||
| 933 | |||
| 934 | struct FunLit : seq< | ||
| 935 | FnArgsDef, | ||
| 936 | sor< | ||
| 937 | sym<'-', '>'>, | ||
| 938 | sym<'=', '>'> | ||
| 939 | >, | ||
| 940 | sor<Body, success> | ||
| 941 | > {}; | ||
| 942 | |||
| 943 | struct NameList : seq<Name, star<sym<','>, Name>> {}; | ||
| 944 | struct NameOrDestructure : sor<Name, TableLit> {}; | ||
| 945 | struct AssignableNameList : seq<NameOrDestructure, star<sym<','>, NameOrDestructure>> {}; | ||
| 946 | |||
| 947 | struct ExpList : seq<Exp, star<sym<','>, Exp>> {}; | ||
| 948 | struct ExpListLow : seq<Exp, star<sor<sym<','>, sym<';'>>, Exp>> {}; | ||
| 949 | |||
| 950 | struct ArgLine : seq<CheckIndent, ExpList> {}; | ||
| 951 | struct ArgBlock : seq<ArgLine, star<sym<','>, SpaceBreak, ArgLine>, PopIndent> {}; | ||
| 952 | |||
| 953 | struct InvokeArgs : seq< | ||
| 954 | not_at<one<'-'>>, | ||
| 955 | sor< | ||
| 956 | seq< | ||
| 957 | ExpList, | ||
| 958 | opt<sor< | ||
| 959 | seq< | ||
| 960 | sym<','>, | ||
| 961 | sor< | ||
| 962 | TableBlock, seq<SpaceBreak, Advance, ArgBlock, opt<TableBlock>> | ||
| 963 | > | ||
| 964 | >, | ||
| 965 | TableBlock | ||
| 966 | >> | ||
| 967 | >, | ||
| 968 | TableBlock | ||
| 969 | > | ||
| 970 | > {}; | ||
| 971 | |||
| 972 | struct SimpleValue : sor< | ||
| 973 | key<'n', 'i', 'l'>, | ||
| 974 | key<'t', 'r', 'u', 'e'>, | ||
| 975 | key<'f', 'a', 'l', 's', 'e'>, | ||
| 976 | If, Unless, Switch, With, ClassDecl, ForEach, For, While, Do, | ||
| 977 | seq<sym<'-'>, not_at<SomeSpace>, Exp>, | ||
| 978 | seq<sym<'#'>, Exp>, | ||
| 979 | seq<sym<'~'>, Exp>, | ||
| 980 | seq<key<'n', 'o', 't'>, Exp>, | ||
| 981 | TblComprehension, | ||
| 982 | TableLit, | ||
| 983 | Comprehension, | ||
| 984 | FunLit, | ||
| 985 | Num | ||
| 986 | > {}; | ||
| 987 | |||
| 988 | struct Assignment : seq< | ||
| 989 | ExpList, | ||
| 990 | sor<Update, Assign> | ||
| 991 | > {}; | ||
| 992 | |||
| 993 | struct Statement : seq< | ||
| 994 | sor< | ||
| 995 | Import, While, With, For, ForEach, | ||
| 996 | Switch, Return, Local, Export, BreakLoop, | ||
| 997 | Assignment, ExpList | ||
| 998 | >, | ||
| 999 | Space, | ||
| 1000 | opt< | ||
| 1001 | sor< | ||
| 1002 | seq< | ||
| 1003 | key<'i', 'f'>, Exp, | ||
| 1004 | opt< | ||
| 1005 | key<'e', 'l', 's', 'e'>, Exp | ||
| 1006 | >, | ||
| 1007 | Space | ||
| 1008 | >, | ||
| 1009 | seq<key<'u', 'n', 'l', 'e', 's', 's'>, Exp>, | ||
| 1010 | CompInner | ||
| 1011 | >, | ||
| 1012 | Space | ||
| 1013 | > | ||
| 1014 | > {}; | ||
| 1015 | |||
| 1016 | struct Body : sor< | ||
| 1017 | seq<opt<Space>, Break, star<EmptyLine>, InBlock>, | ||
| 1018 | Statement | ||
| 1019 | > {}; | ||
| 1020 | |||
| 1021 | struct Line : sor< | ||
| 1022 | seq<CheckIndent, Statement>, | ||
| 1023 | seq<Space, at<Stop>> | ||
| 1024 | > {}; | ||
| 1025 | |||
| 1026 | struct Block : seq<Line, star<plus<Break>, Line>> {}; | ||
| 1027 | |||
| 1028 | struct BlockWithEnd : seq<Block, eof> {}; | ||
| 1029 | |||
| 1030 | template <class T> | ||
| 1031 | struct NodeBase : Node | ||
| 1032 | { | ||
| 1033 | static int id; | ||
| 1034 | }; | ||
| 1035 | 281 | ||
| 1036 | template <class T> | 282 | rule CharOperators = Space >> set("+-*/%^><|&"); |
| 1037 | int NodeBase<T>::id = MoonType<T>(); | 283 | rule WordOperators = |
| 284 | opWord("or") | | ||
| 285 | opWord("and") | | ||
| 286 | op("<=") | | ||
| 287 | op(">=") | | ||
| 288 | op("~=") | | ||
| 289 | op("!=") | | ||
| 290 | op("==") | | ||
| 291 | op("..") | | ||
| 292 | op("<<") | | ||
| 293 | op(">>") | | ||
| 294 | op("//"); | ||
| 1038 | 295 | ||
| 1039 | struct ImportNameNode : Node | 296 | rule BinaryOperator = (WordOperators | CharOperators) >> *SpaceBreak; |
| 1040 | { | ||
| 1041 | }; | ||
| 1042 | 297 | ||
| 1043 | struct ImportNameListNode : NodeBase<ImportNameListNode> | 298 | extern rule Chain; |
| 1044 | { | ||
| 1045 | std::vector<std::shared_ptr<Node>> names; | ||
| 1046 | }; | ||
| 1047 | 299 | ||
| 1048 | struct ImportNode : NodeBase<ImportNode> | 300 | rule Assignable = Chain | Name | SelfName; |
| 1049 | { | ||
| 1050 | std::shared_ptr<Node> nameList; | ||
| 1051 | std::shared_ptr<Node> exp; | ||
| 1052 | }; | ||
| 1053 | 301 | ||
| 1054 | template<typename Rule> | 302 | extern rule Value; |
| 1055 | struct action : nothing<Rule> {}; | ||
| 1056 | 303 | ||
| 1057 | template<> | 304 | rule Exp = Value >> *(BinaryOperator >> Value); |
| 1058 | struct action<ImportName> | ||
| 1059 | { | ||
| 1060 | template<typename Input> | ||
| 1061 | static void apply(const Input& in, State& st) | ||
| 1062 | { | ||
| 1063 | auto node = std::make_shared<ImportNameNode>(); | ||
| 1064 | node->token = slice::Slice(in.begin(), in.end() - in.begin()); | ||
| 1065 | node->token.trimSpace(); | ||
| 1066 | st.astStack.pop_back(); | ||
| 1067 | st.astStack.back().push_back(node); | ||
| 1068 | } | ||
| 1069 | }; | ||
| 1070 | 305 | ||
| 1071 | template<> | 306 | extern rule Callable, InvokeArgs; |
| 1072 | struct action<Exp> | ||
| 1073 | { | ||
| 1074 | template<typename Input> | ||
| 1075 | static void apply(const Input& in, State& st) | ||
| 1076 | { | ||
| 1077 | auto node = std::make_shared<Node>(); | ||
| 1078 | node->token = slice::Slice(in.begin(), in.end() - in.begin()); | ||
| 1079 | node->token.trimSpace(); | ||
| 1080 | st.astStack.pop_back(); | ||
| 1081 | st.astStack.back().push_back(node); | ||
| 1082 | } | ||
| 1083 | }; | ||
| 1084 | 307 | ||
| 1085 | template<> | 308 | rule ChainValue = (Chain | Callable) >> (InvokeArgs | Nothing); |
| 1086 | struct action<Import> | ||
| 1087 | { | ||
| 1088 | template<typename Input> | ||
| 1089 | static void apply(const Input& in, State& st) | ||
| 1090 | { | ||
| 1091 | auto node = std::make_shared<ImportNode>(); | ||
| 1092 | node->exp = st.astStack.back().back(); | ||
| 1093 | st.astStack.back().pop_back(); | ||
| 1094 | node->nameList = st.astStack.back().back(); | ||
| 1095 | st.astStack.back().pop_back(); | ||
| 1096 | st.astStack.pop_back(); | ||
| 1097 | st.astStack.back().push_back(node); | ||
| 1098 | } | ||
| 1099 | }; | ||
| 1100 | 309 | ||
| 1101 | template<> | 310 | extern rule KeyValueList, String, SimpleValue; |
| 1102 | struct action<ImportNameListNode> | ||
| 1103 | { | ||
| 1104 | template<typename Input> | ||
| 1105 | static void apply(const Input& in, State& st) | ||
| 1106 | { | ||
| 1107 | auto node = std::make_shared<ImportNameListNode>(); | ||
| 1108 | node->names = std::move(st.astStack.back()); | ||
| 1109 | st.astStack.pop_back(); | ||
| 1110 | st.astStack.back().push_back(node); | ||
| 1111 | } | ||
| 1112 | }; | ||
| 1113 | 311 | ||
| 1114 | template<typename Rule> | 312 | rule Value = SimpleValue | KeyValueList | ChainValue | String; |
| 1115 | struct control : normal<Rule> {}; | 313 | rule SliceValue = Exp; |
| 1116 | 314 | ||
| 1117 | template<> | 315 | extern rule LuaString; |
| 1118 | struct control<ImportNameListNode> : normal<ImportNameListNode> | ||
| 1119 | { | ||
| 1120 | template<typename Input> | ||
| 1121 | static void start(Input& in, State& st) | ||
| 1122 | { | ||
| 1123 | st.astStack.emplace_back(); | ||
| 1124 | } | ||
| 1125 | 316 | ||
| 1126 | template<typename Input> | 317 | rule single_string_inner = expr("\\'") | "\\\\" | not_(expr('\'')) >> Any; |
| 1127 | static void failure(Input& /*unused*/, State& st) | 318 | rule SingleString = symx('\'') >> *single_string_inner >> sym('\''); |
| 1128 | { | 319 | rule interp = symx("#{") >> Exp >> sym('}'); |
| 1129 | st.astStack.pop_back(); | 320 | rule double_string_plain = expr("\\\"") | "\\\\" | not_(expr('"')) >> Any; |
| 1130 | } | 321 | rule double_string_inner = +(not_(interp) >> double_string_plain); |
| 322 | rule DoubleString = symx('"') >> *(double_string_inner | interp) >> sym('"'); | ||
| 323 | rule String = Space >> (DoubleString | SingleString | LuaString); | ||
| 1131 | 324 | ||
| 1132 | template<typename Input> | 325 | rule lua_string_open = '[' >> *expr('=') >> '['; |
| 1133 | static void success(Input& /*unused*/, State& st) | 326 | rule lua_string_close = ']' >> *expr('=') >> ']'; |
| 1134 | { | ||
| 1135 | } | ||
| 1136 | }; | ||
| 1137 | } | ||
| 1138 | 327 | ||
| 1139 | int main() | 328 | rule LuaStringOpen = user(lua_string_open, [](const item_t& item) |
| 1140 | { | 329 | { |
| 1141 | analyze<moon::BlockWithEnd>(); | 330 | size_t count = std::distance(item.begin, item.end); |
| 1142 | moon::State state; | 331 | State* st = reinterpret_cast<State*>(item.user_data); |
| 1143 | string_input<> inName(R"xoxox( | 332 | st->stringOpen = count; |
| 1144 | 333 | return true; | |
| 1145 | Dorothy! | 334 | }); |
| 1146 | EditMenuView = require "View.Control.Operation.EditMenu" | 335 | |
| 1147 | MessageBox = require "Control.Basic.MessageBox" | 336 | rule LuaStringClose = user(lua_string_close, [](const item_t& item) |
| 1148 | 337 | { | |
| 1149 | -- [no signals] | 338 | size_t count = std::distance(item.begin, item.end); |
| 1150 | -- [no params] | 339 | State* st = reinterpret_cast<State*>(item.user_data); |
| 1151 | Class EditMenuView, | 340 | return st->stringOpen == count; |
| 1152 | __init:=> | 341 | }); |
| 1153 | {:width} = CCDirector.winSize | 342 | |
| 1154 | isHide = false | 343 | rule LuaStringContent = *(not_(LuaStringClose) >> Any); |
| 1155 | |||
| 1156 | @itemArea\setupMenuScroll @itemMenu | ||
| 1157 | @itemArea.viewSize = @itemMenu\alignItems! | ||
| 1158 | |||
| 1159 | for child in *@itemMenu.children | ||
| 1160 | child.positionX = -35 | ||
| 1161 | child.visible = false | ||
| 1162 | child.displayed = false | ||
| 1163 | @showItemButtons {"graphic","physics","logic","data"},true,true | ||
| 1164 | |||
| 1165 | buttonNames = { | ||
| 1166 | "sprite","model","body" | ||
| 1167 | "effect","layer","world" | ||
| 1168 | } | ||
| 1169 | 344 | ||
| 1170 | clearSelection = -> | 345 | rule LuaString = user(LuaStringOpen >> -Break >> LuaStringContent >> LuaStringClose, [](const item_t& item) |
| 1171 | for name in *buttonNames | 346 | { |
| 1172 | with @[name.."Btn"] | 347 | State* st = reinterpret_cast<State*>(item.user_data); |
| 1173 | if .selected | 348 | st->stringOpen = -1; |
| 1174 | .selected = false | 349 | return true; |
| 1175 | .color = ccColor3 0x00ffff | 350 | }); |
| 1176 | .scaleX = 0 | 351 | |
| 1177 | .scaleY = 0 | 352 | rule Parens = sym('(') >> *SpaceBreak >> Exp >> *SpaceBreak >> sym(')'); |
| 1178 | \perform oScale 0.3,1,1,oEase.OutBack | 353 | rule Callable = Name | SelfName | VarArg | Parens; |
| 1179 | emit .event,nil | 354 | rule FnArgsExpList = Exp >> *((Break | sym(',')) >> White >> Exp); |
| 1180 | 355 | ||
| 1181 | for name in *buttonNames | 356 | rule FnArgs = |
| 1182 | with @[name.."Btn"] | 357 | ( |
| 1183 | .selected = false | 358 | symx('(') >> *SpaceBreak >> (FnArgsExpList | Nothing) >> *SpaceBreak >> sym(')') |
| 1184 | upperName = name\sub(1,1)\upper!..name\sub(2,-1) | 359 | ) | ( |
| 1185 | .event = "Scene."..upperName.."Selected" | 360 | sym('!') >> not_(expr('=')) >> Nothing |
| 1186 | @gslot .event,(item)-> | 361 | ); |
| 1187 | if item | 362 | |
| 1188 | .selected = true | 363 | extern rule ChainItems, DotChainItem, ColonChain; |
| 1189 | .color = ccColor3 0xff0088 | 364 | |
| 1190 | .scaleX = 0 | 365 | rule chain_call = (Callable | String) >> ChainItems; |
| 1191 | .scaleY = 0 | 366 | rule chain_item = not_(set(".\\")) >> ChainItems; |
| 1192 | \perform oScale 0.3,1,1,oEase.OutBack | 367 | rule chain_dot_chain = DotChainItem >> (ChainItems | Nothing); |
| 1193 | \slot "Tapped",-> | 368 | |
| 1194 | if not .selected | 369 | rule Chain = |
| 1195 | emit "Scene.View"..upperName | 370 | chain_call | |
| 1196 | clearSelection! | 371 | chain_item | |
| 1197 | else | 372 | Space >> (chain_dot_chain | ColonChain); |
| 1198 | .selected = false | 373 | |
| 1199 | .color = ccColor3 0x00ffff | 374 | extern rule ChainItem; |
| 1200 | emit .event,nil | 375 | |
| 1201 | 376 | rule chain_items = +ChainItem >> (ColonChain | Nothing); | |
| 1202 | @triggerBtn\slot "Tapped",-> | 377 | rule ChainItems = chain_items | ColonChain; |
| 1203 | clearSelection! | 378 | |
| 1204 | if @pickPanel.visible | 379 | extern rule Invoke, Slice; |
| 1205 | MessageBox text:"Pick An Item First",okOnly:true | 380 | |
| 1206 | else | 381 | rule ChainItem = Invoke | DotChainItem | Slice | symx('[') >> Exp >> sym(']'); |
| 1207 | emit "Scene.Trigger.Open" | 382 | rule DotChainItem = symx('.') >> _Name; |
| 1208 | 383 | rule ColonChainItem = symx('\\') >> _Name; | |
| 1209 | @actionBtn\slot "Tapped",-> | 384 | rule ColonChain = ColonChainItem >> ((Invoke >> (ChainItems | Nothing)) | Nothing >> Nothing); |
| 1210 | clearSelection! | 385 | |
| 1211 | if @pickPanel.visible | 386 | rule Slice = |
| 1212 | MessageBox text:"Pick An Item First",okOnly:true | 387 | symx('[') >> |
| 1213 | else | 388 | (SliceValue | Nothing) >> |
| 1214 | emit "Scene.Action.Open" | 389 | sym(',') >> |
| 1215 | 390 | (SliceValue | Nothing) >> | |
| 1216 | @aiBtn\slot "Tapped",-> | 391 | (sym(',') >> |
| 1217 | clearSelection! | 392 | SliceValue | Nothing) >> |
| 1218 | if @pickPanel.visible | 393 | sym(']'); |
| 1219 | MessageBox text:"Pick An Item First",okOnly:true | 394 | |
| 1220 | else | 395 | rule Invoke = |
| 1221 | emit "Scene.AITree.Open" | 396 | FnArgs | |
| 1222 | 397 | SingleString | | |
| 1223 | @unitBtn\slot "Tapped",-> | 398 | DoubleString | |
| 1224 | clearSelection! | 399 | and_(expr('[')) >> LuaString; |
| 1225 | if @pickPanel.visible | 400 | |
| 1226 | MessageBox text:"Pick An Item First",okOnly:true | 401 | extern rule KeyValue, TableValueList, TableLitLine; |
| 1227 | else | 402 | |
| 1228 | emit "Scene.Unit.Open" | 403 | rule TableValue = KeyValue | Exp; |
| 1229 | 404 | ||
| 1230 | @delBtn\slot "Tapped",-> | 405 | rule table_lit_lines = SpaceBreak >> TableLitLine >> *(-sym(',') >> SpaceBreak >> TableLitLine) >> -sym(','); |
| 1231 | clearSelection! | 406 | |
| 1232 | emit "Scene.EditMenu.Delete" | 407 | rule TableLit = |
| 1233 | 408 | sym('{') >> | |
| 1234 | mode = 0 | 409 | (TableValueList | Nothing) >> |
| 1235 | @zoomBtn\slot "Tapped",-> | 410 | -sym(',') >> |
| 1236 | scale = switch mode | 411 | (table_lit_lines | Nothing) >> |
| 1237 | when 0 then 2 | 412 | White >> sym('}'); |
| 1238 | when 1 then 0.5 | 413 | |
| 1239 | when 2 then 1 | 414 | rule TableValueList = TableValue >> *(sym(',') >> TableValue); |
| 1240 | mode += 1 | 415 | |
| 1241 | mode %= 3 | 416 | rule TableLitLine = |
| 1242 | @zoomBtn.text = string.format("%d%%",scale*100) | 417 | ( |
| 1243 | emit "Scene.ViewArea.ScaleTo",scale | 418 | PushIndent >> (TableValueList >> PopIndent | PopIndent) |
| 1244 | 419 | ) | ( | |
| 1245 | @originBtn\slot "Tapped",-> editor\moveTo oVec2.zero | 420 | Space >> Nothing |
| 1246 | 421 | ); | |
| 1247 | @progressUp.visible = false | 422 | |
| 1248 | @progressDown.visible = false | 423 | extern rule KeyValueLine; |
| 1249 | 424 | ||
| 1250 | with @upBtn | 425 | rule TableBlockInner = KeyValueLine >> *(+(SpaceBreak) >> KeyValueLine); |
| 1251 | .visible = false | 426 | rule TableBlock = +(SpaceBreak) >> Advance >> ensure(TableBlockInner, PopIndent); |
| 1252 | .enabled = false | 427 | |
| 1253 | \slot "TapBegan",-> | 428 | extern rule Statement; |
| 1254 | clearSelection! | 429 | |
| 1255 | \schedule once -> | 430 | rule ClassLine = CheckIndent >> (KeyValueList | Statement | Exp) >> -sym(','); |
| 1256 | sleep 0.4 | 431 | rule ClassBlock = +(SpaceBreak) >> Advance >> ClassLine >> *(+(SpaceBreak) >> ClassLine) >> PopIndent; |
| 1257 | @progressUp.visible = true | 432 | |
| 1258 | @progressUp\play! | 433 | rule ClassDecl = |
| 1259 | \slot "Tapped",-> | 434 | key("class") >> not_(expr(':')) >> |
| 1260 | if @progressUp.visible | 435 | (Assignable | Nothing) >> |
| 1261 | if @progressUp.done | 436 | (key("extends") >> PreventIndent >> ensure(Exp, PopIndent) | Nothing) >> |
| 1262 | emit "Scene.EditMenu.Top" | 437 | (ClassBlock | Nothing); |
| 1263 | else | 438 | |
| 1264 | emit "Scene.EditMenu.Up" | 439 | rule export_values = sym('=') >> ExpListLow; |
| 1265 | \slot "TapEnded",-> | 440 | rule Export = key("export") >> (ClassDecl | op('*') | op('^') | NameList >> (export_values | Nothing)); |
| 1266 | \unschedule! | 441 | |
| 1267 | if @progressUp.visible | 442 | rule KeyValue = |
| 1268 | @progressUp.visible = false | 443 | ( |
| 1269 | 444 | sym(':') >> not_(SomeSpace) >> Name | |
| 1270 | with @downBtn | 445 | ) | ( |
| 1271 | .visible = false | 446 | (KeyName | |
| 1272 | .enabled = false | 447 | sym('[') >> Exp >> sym(']') | |
| 1273 | \slot "TapBegan",-> | 448 | Space >> DoubleString | |
| 1274 | clearSelection! | 449 | Space >> SingleString |
| 1275 | \schedule once -> | 450 | ) >> |
| 1276 | sleep 0.4 | 451 | symx(':') >> |
| 1277 | @progressDown.visible = true | 452 | (Exp | TableBlock | +(SpaceBreak) >> Exp) |
| 1278 | @progressDown\play! | 453 | ); |
| 1279 | \slot "Tapped",-> | 454 | |
| 1280 | if @progressDown.visible | 455 | rule KeyValueList = KeyValue >> *(sym(',') >> KeyValue); |
| 1281 | if @progressDown.done | 456 | rule KeyValueLine = CheckIndent >> KeyValueList >> -sym(','); |
| 1282 | emit "Scene.EditMenu.Bottom" | 457 | |
| 1283 | else | 458 | rule FnArgDef = (Name | SelfName) >> (sym('=') >> Exp | Nothing); |
| 1284 | emit "Scene.EditMenu.Down" | 459 | |
| 1285 | \slot "TapEnded",-> | 460 | rule FnArgDefList = |
| 1286 | \unschedule! | 461 | ( |
| 1287 | if @progressDown.visible | 462 | FnArgDef >> |
| 1288 | @progressDown.visible = false | 463 | *((sym(',') | Break) >> White >> FnArgDef) >> |
| 1289 | 464 | ((sym(',') | Break) >> White >> VarArg | Nothing) | |
| 1290 | with @foldBtn | 465 | ) | ( |
| 1291 | .visible = false | 466 | VarArg |
| 1292 | .enabled = false | 467 | ); |
| 1293 | \slot "Tapped",-> | 468 | |
| 1294 | clearSelection! | 469 | rule outer_value_shadow = key("using") >> (NameList | Space >> expr("nil")); |
| 1295 | emit "Scene.ViewPanel.Fold",editor.currentData | 470 | |
| 1296 | 471 | rule normal_fn_args_def = | |
| 1297 | with @editBtn | 472 | sym('(') >> White >> (FnArgDefList | Nothing) >> (outer_value_shadow | Nothing) >> White >> sym(')'); |
| 1298 | .visible = false | 473 | |
| 1299 | .enabled = false | 474 | rule FnArgsDef = normal_fn_args_def | Nothing; |
| 1300 | \slot "Tapped",-> | 475 | rule fn_arrow = sym("->"); |
| 1301 | emit "Scene.SettingPanel.Edit",nil | 476 | rule fat_arrow = sym("=>"); |
| 1302 | editor\editCurrentItemInPlace! | 477 | rule FunLit = FnArgsDef >> (fn_arrow | fat_arrow) >> (Body | Nothing); |
| 1303 | 478 | ||
| 1304 | with @menuBtn | 479 | rule NameList = Name >> *(sym(',') >> Name); |
| 1305 | .dirty = false | 480 | rule NameOrDestructure = Name | TableLit; |
| 1306 | \slot "Tapped",-> | 481 | rule AssignableNameList = NameOrDestructure >> *(sym(',') >> NameOrDestructure); |
| 1307 | clearSelection! | 482 | |
| 1308 | if .dirty | 483 | rule ExpList = Exp >> *(sym(',') >> Exp); |
| 1309 | editor\save! | 484 | rule ExpListLow = Exp >> *((sym(',') | sym(';')) >> Exp); |
| 1310 | emit "Scene.Dirty",false | 485 | |
| 1311 | else | 486 | rule ArgLine = CheckIndent >> ExpList; |
| 1312 | ScenePanel = require "Control.Item.ScenePanel" | 487 | rule ArgBlock = ArgLine >> *(sym(',') >> SpaceBreak >> ArgLine) >> PopIndent; |
| 1313 | ScenePanel! | 488 | |
| 1314 | emit "Scene.SettingPanel.Edit",nil | 489 | rule invoke_args_with_table = |
| 1315 | 490 | sym(',') >> | |
| 1316 | with @undoBtn | 491 | ( |
| 1317 | .visible = false | 492 | TableBlock >> Nothing | |
| 1318 | \slot "Tapped",-> | 493 | SpaceBreak>> Advance >> ArgBlock >> (TableBlock | Nothing) |
| 1319 | clearSelection! | 494 | ); |
| 1320 | editor.currentSceneFile = editor.currentSceneFile | 495 | |
| 1321 | emit "Scene.Dirty",false | 496 | rule InvokeArgs = |
| 1322 | 497 | not_(expr('-')) >> | |
| 1323 | with @xFixBtn | 498 | ( |
| 1324 | .visible = false | 499 | ExpList >> (invoke_args_with_table | TableBlock | Nothing) | |
| 1325 | \slot "Tapped",(button)-> | 500 | TableBlock >> Nothing |
| 1326 | editor.xFix = not editor.xFix | 501 | ); |
| 1327 | if editor.yFix | 502 | |
| 1328 | editor.yFix = false | 503 | rule SimpleValue = |
| 1329 | @yFixBtn.color = ccColor3 0x00ffff | 504 | key("nil") | key("true") | key("false") | |
| 1330 | button.color = ccColor3 editor.xFix and 0xff0088 or 0x00ffff | 505 | If | Unless | Switch | With | ClassDecl | ForEach | For | While | Do | |
| 1331 | emit "Scene.FixChange" | 506 | sym('-') >> not_(SomeSpace) >> Exp | |
| 1332 | 507 | sym('#') >> Exp | | |
| 1333 | with @yFixBtn | 508 | sym('~') >> Exp | |
| 1334 | .visible = false | 509 | key("not") >> Exp | |
| 1335 | \slot "Tapped",(button)-> | 510 | TblComprehension | TableLit | Comprehension | FunLit | Num; |
| 1336 | editor.yFix = not editor.yFix | 511 | |
| 1337 | if editor.xFix | 512 | rule Assignment = ExpList >> (Update | Assign); |
| 1338 | editor.xFix = false | 513 | |
| 1339 | @xFixBtn.color = ccColor3 0x00ffff | 514 | rule if_else_line = key("if") >> Exp >> (key("else") >> Exp | Nothing); |
| 1340 | button.color = ccColor3 editor.yFix and 0xff0088 or 0x00ffff | 515 | rule unless_line = key("unless") >> Exp; |
| 1341 | emit "Scene.FixChange" | 516 | |
| 1342 | 517 | rule Statement = | |
| 1343 | @iconCam.visible = false | 518 | ( |
| 1344 | 519 | Import | While | With | For | ForEach | | |
| 1345 | currentSubCam = nil | 520 | Switch | Return | Local | Export | BreakLoop | |
| 1346 | with @camBtn | 521 | Assignment | ExpList |
| 1347 | .visible = false | 522 | ) >> Space >> |
| 1348 | .editing = false | 523 | ( |
| 1349 | \gslot "Scene.Camera.Select",(subCam)-> | 524 | (if_else_line | unless_line | CompInner) >> Space | Nothing |
| 1350 | currentSubCam = subCam | 525 | ); |
| 1351 | \slot "Tapped",-> | 526 | |
| 1352 | .editing = not .editing | 527 | rule Body = -Space >> Break >> *EmptyLine >> InBlock | Statement; |
| 1353 | if .editing | 528 | |
| 1354 | emit "Scene.Camera.Activate",currentSubCam | 529 | rule empty_line_stop = Space >> and_(Stop); |
| 1355 | else | 530 | rule Line = CheckIndent >> Statement | empty_line_stop; |
| 1356 | emit "Scene.Camera.Activate",nil | 531 | rule Block = Line >> *(+Break >> Line); |
| 1357 | 532 | rule BlockWithEnd = Block >> eof(); | |
| 1358 | with @zoomEditBtn | 533 | |
| 1359 | .visible = false | 534 | class AstNode : public ast_container |
| 1360 | .editing = false | 535 | { |
| 1361 | \slot "Tapped",-> | 536 | public: |
| 1362 | .editing = not .editing | 537 | virtual void construct(ast_stack& st) |
| 1363 | if .editing and currentSubCam | ||
| 1364 | emit "Scene.Edit.ShowRuler", {currentSubCam.zoom,0.5,10,1,(value)-> | ||
| 1365 | emit "Scene.ViewArea.Scale",value | ||
| 1366 | } | ||
| 1367 | else | ||
| 1368 | emit "Scene.Edit.ShowRuler",nil | ||
| 1369 | |||
| 1370 | @playBtn\slot "Tapped",-> | ||
| 1371 | settings = editor\getSettings! | ||
| 1372 | sceneFile = if settings.StartupScene | ||
| 1373 | editor.sceneFullPath..settings.StartupScene..".scene" | ||
| 1374 | else | ||
| 1375 | nil | ||
| 1376 | if not sceneFile or not oContent\exist sceneFile | ||
| 1377 | MessageBox text:"Startup Scene\nIs Required!",okOnly:true | ||
| 1378 | return | ||
| 1379 | @menuBtn\emit "Tapped" if @menuBtn.dirty | ||
| 1380 | -- test codes below | ||
| 1381 | Game = require "Lib.Game.Game" | ||
| 1382 | game = Game editor.game,false | ||
| 1383 | editorData = editor\getEditorData! | ||
| 1384 | editorData.lastScene = editor.lastScene | ||
| 1385 | emit "Scene.EditorData",editorData | ||
| 1386 | editor\emit "Quit",game\loadScene! | ||
| 1387 | |||
| 1388 | setupItemButton = (button,groupLine,subItems)-> | ||
| 1389 | groupLine.data = button | ||
| 1390 | with button | ||
| 1391 | .showItem = false | ||
| 1392 | \slot "Tapped",-> | ||
| 1393 | return if .scheduled | ||
| 1394 | .showItem = not .showItem | ||
| 1395 | if .showItem | ||
| 1396 | groupLine.visible = true | ||
| 1397 | groupLine.opacity = 0 | ||
| 1398 | groupLine\perform oOpacity 0.3,1 | ||
| 1399 | groupLine.position = button.position-oVec2 25,25 | ||
| 1400 | else | ||
| 1401 | \schedule once -> | ||
| 1402 | groupLine\perform oOpacity 0.3,0 | ||
| 1403 | sleep 0.3 | ||
| 1404 | groupLine.visible = false | ||
| 1405 | @showItemButtons subItems,.showItem | ||
| 1406 | setupItemButton @graphicBtn,@graphicLine,{"sprite","model","effect","layer"} | ||
| 1407 | setupItemButton @physicsBtn,@physicsLine,{"body","world"} | ||
| 1408 | setupItemButton @logicBtn,@logicLine,{"trigger","action","ai"} | ||
| 1409 | setupItemButton @dataBtn,@dataLine,{"unit"} | ||
| 1410 | |||
| 1411 | @gslot "Scene.ShowFix",(value)-> | ||
| 1412 | editor.xFix = false | ||
| 1413 | editor.yFix = false | ||
| 1414 | emit "Scene.FixChange" | ||
| 1415 | if value | ||
| 1416 | with @xFixBtn | ||
| 1417 | .visible = true | ||
| 1418 | .color = ccColor3 0x00ffff | ||
| 1419 | .scaleX = 0 | ||
| 1420 | .scaleY = 0 | ||
| 1421 | \perform oScale 0.5,1,1,oEase.OutBack | ||
| 1422 | with @yFixBtn | ||
| 1423 | .visible = true | ||
| 1424 | .color = ccColor3 0x00ffff | ||
| 1425 | .scaleX = 0 | ||
| 1426 | .scaleY = 0 | ||
| 1427 | \perform oScale 0.5,1,1,oEase.OutBack | ||
| 1428 | else | ||
| 1429 | @xFixBtn.visible = false | ||
| 1430 | @yFixBtn.visible = false | ||
| 1431 | |||
| 1432 | @gslot "Scene.Dirty",(dirty)-> | ||
| 1433 | with @menuBtn | ||
| 1434 | if .dirty ~= dirty | ||
| 1435 | .dirty = dirty | ||
| 1436 | if dirty | ||
| 1437 | .text = "Save" | ||
| 1438 | with @undoBtn | ||
| 1439 | if not .visible | ||
| 1440 | .enabled = true | ||
| 1441 | .visible = true | ||
| 1442 | .scaleX = 0 | ||
| 1443 | .scaleY = 0 | ||
| 1444 | \perform oScale 0.3,1,1,oEase.OutBack | ||
| 1445 | else | ||
| 1446 | .color = ccColor3 0x00ffff | ||
| 1447 | .text = "Menu" | ||
| 1448 | with @undoBtn | ||
| 1449 | if .visible | ||
| 1450 | .enabled = false | ||
| 1451 | \perform CCSequence { | ||
| 1452 | oScale 0.3,0,0,oEase.InBack | ||
| 1453 | CCHide! | ||
| 1454 | } | ||
| 1455 | |||
| 1456 | itemChoosed = (itemData)-> | ||
| 1457 | return if isHide | ||
| 1458 | if @camBtn.visible or @iconCam.visible | ||
| 1459 | @iconCam.visible = false | ||
| 1460 | @camBtn.visible = false | ||
| 1461 | emit "Scene.Camera.Activate",nil | ||
| 1462 | emit "Scene.Camera.Select",nil | ||
| 1463 | emit "Scene.ViewPanel.FoldState",{ | ||
| 1464 | itemData:itemData | ||
| 1465 | handler:(state)-> | ||
| 1466 | if state ~= nil | ||
| 1467 | @setButtonVisible @foldBtn,true | ||
| 1468 | switch itemData.typeName | ||
| 1469 | when "Body","Model","Effect" | ||
| 1470 | @setButtonVisible @editBtn,true | ||
| 1471 | else | ||
| 1472 | @setButtonVisible @editBtn,false | ||
| 1473 | text = @foldBtn.text | ||
| 1474 | targetText = state and "Un\nFold" or "Fold" | ||
| 1475 | if text ~= targetText | ||
| 1476 | @foldBtn.text = targetText | ||
| 1477 | if @foldBtn.scale.done | ||
| 1478 | @setButtonVisible @foldBtn,true | ||
| 1479 | else | ||
| 1480 | @setButtonVisible @foldBtn,false | ||
| 1481 | @setButtonVisible @upBtn,false | ||
| 1482 | @setButtonVisible @downBtn,false | ||
| 1483 | @setButtonVisible @editBtn,false | ||
| 1484 | } | ||
| 1485 | return unless itemData | ||
| 1486 | switch itemData.typeName | ||
| 1487 | when "Camera","PlatformWorld","UILayer" | ||
| 1488 | @setButtonVisible @upBtn,false | ||
| 1489 | @setButtonVisible @downBtn,false | ||
| 1490 | {:x,:y} = @upBtn.position | ||
| 1491 | @foldBtn\runAction oPos 0.3,x,y,oEase.OutQuad | ||
| 1492 | if itemData.typeName == "Camera" | ||
| 1493 | clearSelection! | ||
| 1494 | with @iconCam | ||
| 1495 | .visible = true | ||
| 1496 | .scaleX = 0 | ||
| 1497 | .scaleY = 0 | ||
| 1498 | \perform oScale 0.3,0.5,0.5,oEase.OutBack | ||
| 1499 | else | ||
| 1500 | item = editor\getItem itemData | ||
| 1501 | hasChildren = false | ||
| 1502 | if itemData.typeName == "World" | ||
| 1503 | hasChildren = #item.parent.parent.children > 1 | ||
| 1504 | else | ||
| 1505 | hasChildren = #item.parent.children > 1 | ||
| 1506 | if item.parent.children and hasChildren | ||
| 1507 | @setButtonVisible @upBtn,true | ||
| 1508 | @setButtonVisible @downBtn,true | ||
| 1509 | {:x,:y} = @downBtn.position | ||
| 1510 | @foldBtn\runAction oPos 0.3,x,y-60,oEase.OutQuad | ||
| 1511 | @editBtn\runAction oPos 0.3,x,y-120,oEase.OutQuad | ||
| 1512 | else | ||
| 1513 | @setButtonVisible @upBtn,false | ||
| 1514 | @setButtonVisible @downBtn,false | ||
| 1515 | {:x,:y} = @upBtn.position | ||
| 1516 | @foldBtn\runAction oPos 0.3,x,y,oEase.OutQuad | ||
| 1517 | @editBtn\runAction oPos 0.3,x,y-60,oEase.OutQuad | ||
| 1518 | @gslot "Scene.ViewPanel.Pick",itemChoosed | ||
| 1519 | @gslot "Scene.ViewPanel.Select",itemChoosed | ||
| 1520 | |||
| 1521 | @gslot "Scene.ViewArea.Scale",(scale)-> | ||
| 1522 | mode = 2 if scale ~= 1 | ||
| 1523 | @zoomBtn.text = string.format("%d%%",scale*100) | ||
| 1524 | @gslot "Scene.ViewArea.ScaleReset",-> | ||
| 1525 | mode = 0 | ||
| 1526 | @zoomBtn.text = "100%" | ||
| 1527 | emit "Scene.ViewArea.ScaleTo",1 | ||
| 1528 | |||
| 1529 | @gslot "Scene.Camera.Select",(subCam)-> | ||
| 1530 | if subCam and not @camBtn.visible | ||
| 1531 | @iconCam.opacity = 0 | ||
| 1532 | with @camBtn | ||
| 1533 | .visible = true | ||
| 1534 | .scaleX = 0 | ||
| 1535 | .scaleY = 0 | ||
| 1536 | \perform oScale 0.3,1,1,oEase.OutBack | ||
| 1537 | else | ||
| 1538 | @camBtn.visible = false | ||
| 1539 | with @iconCam | ||
| 1540 | .opacity = 1 | ||
| 1541 | .scaleX = 0 | ||
| 1542 | .scaleY = 0 | ||
| 1543 | \perform oScale 0.3,0.5,0.5,oEase.OutBack | ||
| 1544 | |||
| 1545 | changeDisplay = (child)-> | ||
| 1546 | if child.positionX < width/2 | ||
| 1547 | child\perform oPos 0.5,-child.positionX,child.positionY,oEase.OutQuad | ||
| 1548 | else | ||
| 1549 | child\perform oPos 0.5,width*2-child.positionX,child.positionY,oEase.OutQuad | ||
| 1550 | |||
| 1551 | @gslot "Scene.HideEditor",(args)-> | ||
| 1552 | {hide,all} = args | ||
| 1553 | return if isHide == hide | ||
| 1554 | isHide = hide | ||
| 1555 | @enabled = @camBtn.editing or not hide | ||
| 1556 | for i = 1,#@children | ||
| 1557 | child = @children[i] | ||
| 1558 | switch child | ||
| 1559 | when @camBtn | ||
| 1560 | posX = @camBtn.editing and width-35 or width-345 | ||
| 1561 | child\perform oPos 0.5,posX,child.positionY,oEase.OutQuad | ||
| 1562 | when @menuBtn,@undoBtn,@zoomEditBtn,@iconCam | ||
| 1563 | if all | ||
| 1564 | changeDisplay child | ||
| 1565 | else | ||
| 1566 | continue | ||
| 1567 | else | ||
| 1568 | changeDisplay child | ||
| 1569 | |||
| 1570 | @gslot "Scene.Camera.Activate",(subCam)-> | ||
| 1571 | editor.isFixed = not @camBtn.editing | ||
| 1572 | if subCam | ||
| 1573 | with @zoomEditBtn | ||
| 1574 | .scaleX = 0 | ||
| 1575 | .scaleY = 0 | ||
| 1576 | .visible = true | ||
| 1577 | \perform CCSequence { | ||
| 1578 | CCDelay 0.5 | ||
| 1579 | oScale 0.3,1,1,oEase.OutBack | ||
| 1580 | } | ||
| 1581 | else | ||
| 1582 | @zoomEditBtn.visible = false | ||
| 1583 | @zoomEditBtn.editing = false | ||
| 1584 | emit "Scene.Edit.ShowRuler",nil | ||
| 1585 | |||
| 1586 | @gslot "Scene.EditMenu.ClearSelection",clearSelection | ||
| 1587 | |||
| 1588 | setButtonVisible:(button,visible)=> | ||
| 1589 | return if visible == button.enabled | ||
| 1590 | button.enabled = visible | ||
| 1591 | if visible | ||
| 1592 | if not button.visible | ||
| 1593 | button.visible = true | ||
| 1594 | button.scaleX = 0 | ||
| 1595 | button.scaleY = 0 | ||
| 1596 | button\perform oScale 0.3,1,1,oEase.OutBack | ||
| 1597 | else | ||
| 1598 | button\perform CCSequence { | ||
| 1599 | oScale 0.3,0,0,oEase.InBack | ||
| 1600 | CCHide! | ||
| 1601 | } | ||
| 1602 | |||
| 1603 | showItemButtons:(names,visible,instant=false)=> | ||
| 1604 | buttonSet = {@["#{name}Btn"],true for name in *names} | ||
| 1605 | posX = 35 | ||
| 1606 | posY = @itemMenu.height-25 | ||
| 1607 | if visible | ||
| 1608 | offset = @itemArea.offset | ||
| 1609 | firstItem = nil | ||
| 1610 | for child in *@itemMenu.children | ||
| 1611 | isTarget = buttonSet[child] | ||
| 1612 | firstItem = child if isTarget and not firstItem | ||
| 1613 | if child.displayed or isTarget | ||
| 1614 | offsetX = switch child | ||
| 1615 | when @graphicBtn,@physicsBtn,@logicBtn,@dataBtn then 0 | ||
| 1616 | else 20 | ||
| 1617 | child.position = offset+oVec2(posX+offsetX,posY) | ||
| 1618 | if isTarget | ||
| 1619 | child.displayed = true | ||
| 1620 | child.visible = true | ||
| 1621 | if not instant | ||
| 1622 | child.face.scaleY = 0 | ||
| 1623 | child.face\perform oScale 0.3,1,1,oEase.OutBack | ||
| 1624 | posY -= 60 | ||
| 1625 | elseif child.data -- data is parentButton | ||
| 1626 | child.position = child.data.position-oVec2(25,25) | ||
| 1627 | @itemArea.viewSize = CCSize 70,@itemArea.height-posY-35 | ||
| 1628 | @itemArea\scrollToPosY firstItem.positionY | ||
| 1629 | else | ||
| 1630 | @itemMenu\schedule once -> | ||
| 1631 | if not instant | ||
| 1632 | for child in *@itemMenu.children | ||
| 1633 | if buttonSet[child] | ||
| 1634 | child.face\perform oScale 0.3,1,0,oEase.OutQuad | ||
| 1635 | sleep 0.3 | ||
| 1636 | offset = @itemArea.offset | ||
| 1637 | lastPosY = nil | ||
| 1638 | for child in *@itemMenu.children | ||
| 1639 | if buttonSet[child] | ||
| 1640 | child.positionX = -35 | ||
| 1641 | child.displayed = false | ||
| 1642 | child.visible = false | ||
| 1643 | lastPosY = child.positionY | ||
| 1644 | elseif child.displayed | ||
| 1645 | if lastPosY and child.positionY < lastPosY | ||
| 1646 | child.face.scaleY = 0 | ||
| 1647 | child.face\perform oScale 0.3,1,1,oEase.OutBack | ||
| 1648 | offsetX = switch child | ||
| 1649 | when @graphicBtn,@physicsBtn,@logicBtn,@dataBtn then 0 | ||
| 1650 | else 20 | ||
| 1651 | child.position = offset+oVec2(posX+offsetX,posY) | ||
| 1652 | posY -= 60 | ||
| 1653 | elseif lastPosY and child.data and child.positionY < lastPosY | ||
| 1654 | child.opacity = 0 | ||
| 1655 | child\perform oOpacity 0.3,1 | ||
| 1656 | child.position = child.data.position-oVec2(25,25) | ||
| 1657 | @itemArea.viewSize = CCSize 70,@itemArea.height-posY-35 | ||
| 1658 | |||
| 1659 | )xoxox", "abc"); | ||
| 1660 | |||
| 1661 | string_input<> in(R"PIG(import Path, Struct from require "utils")PIG", "bcd"); | ||
| 1662 | try | ||
| 1663 | { | 538 | { |
| 1664 | if (parse<must<moon::Import, eof>, moon::action, moon::control>(in, state)) | 539 | stringstream stream; |
| 540 | for (input::iterator it = m_begin.m_it; it != m_end.m_it; ++it) | ||
| 1665 | { | 541 | { |
| 1666 | std::cout << "matched.\n"; | 542 | stream << (char)*it; |
| 1667 | } | ||
| 1668 | else | ||
| 1669 | { | ||
| 1670 | std::cout << "not matched.\n"; | ||
| 1671 | } | 543 | } |
| 544 | _value = stream.str(); | ||
| 1672 | } | 545 | } |
| 1673 | catch (parse_error e) | 546 | void print() |
| 1674 | { | 547 | { |
| 1675 | std::cout << "not matched.\n"; | 548 | cout << _value << '\n'; |
| 1676 | std::cout << e.what() << '\n'; | ||
| 1677 | } | 549 | } |
| 1678 | /* | 550 | private: |
| 1679 | analyze<hello::expr>(); | 551 | string _value; |
| 1680 | const char* text = "1 + 2 + 3 * 4 / 2"; | 552 | }; |
| 1681 | string_input<> in(text, "abc"); | 553 | |
| 1682 | try | 554 | rule ExprEnd = Block >> eof(); |
| 555 | |||
| 556 | ast<AstNode> testNode(ExprEnd); | ||
| 557 | |||
| 558 | int main() | ||
| 559 | { | ||
| 560 | string s = R"baddog()baddog"; | ||
| 561 | input i(s.begin(), s.end()); | ||
| 562 | |||
| 563 | error_list el; | ||
| 564 | AstNode* root = nullptr; | ||
| 565 | State st; | ||
| 566 | if (parse(i, ExprEnd, el, root, &st)) | ||
| 1683 | { | 567 | { |
| 1684 | hello::Stack stack; | 568 | cout << "matched!\n"; |
| 1685 | if (parse<hello::expr, hello::action>(in, stack)) | ||
| 1686 | { | ||
| 1687 | std::cout << text << " = " << stack.getValue() << '\n'; | ||
| 1688 | } | ||
| 1689 | return 0; | ||
| 1690 | } | 569 | } |
| 1691 | catch (parse_error e) | 570 | else |
| 1692 | { | 571 | { |
| 1693 | std::cout << e.what() << '\n'; | 572 | cout << "not matched!\n"; |
| 1694 | return 1; | 573 | for (error_list::iterator it = el.begin(); it != el.end(); ++it) |
| 574 | { | ||
| 575 | const error& err = *it; | ||
| 576 | cout << "line " << err.m_begin.m_line << ", col " << err.m_begin.m_col << ": syntax error\n"; | ||
| 577 | } | ||
| 1695 | } | 578 | } |
| 1696 | */ | 579 | system("pause"); |
| 1697 | return 0; | 580 | return 0; |
| 1698 | } | 581 | } |
diff --git a/MoonParser/parser.cpp b/MoonParser/parser.cpp new file mode 100644 index 0000000..5a7da73 --- /dev/null +++ b/MoonParser/parser.cpp | |||
| @@ -0,0 +1,1462 @@ | |||
| 1 | #include <cstdlib> | ||
| 2 | #include <cstring> | ||
| 3 | #include <cassert> | ||
| 4 | #include <stdexcept> | ||
| 5 | #include <unordered_map> | ||
| 6 | #include "parser.hpp" | ||
| 7 | |||
| 8 | |||
| 9 | namespace parserlib { | ||
| 10 | |||
| 11 | |||
| 12 | //internal map from rules to parse procs | ||
| 13 | typedef std::unordered_map<rule *, parse_proc> _parse_proc_map_t; | ||
| 14 | |||
| 15 | //on exit, it deletes the parse proc map | ||
| 16 | static _parse_proc_map_t& _get_parse_proc_map() { | ||
| 17 | static _parse_proc_map_t _parse_proc_map; | ||
| 18 | return _parse_proc_map; | ||
| 19 | } | ||
| 20 | |||
| 21 | |||
| 22 | //get the parse proc from the map | ||
| 23 | static parse_proc _get_parse_proc(rule *r) { | ||
| 24 | _parse_proc_map_t& _parse_proc_map = _get_parse_proc_map(); | ||
| 25 | _parse_proc_map_t::iterator it = _parse_proc_map.find(r); | ||
| 26 | if (it == _parse_proc_map.end()) return 0; | ||
| 27 | return it->second; | ||
| 28 | } | ||
| 29 | |||
| 30 | |||
| 31 | //internal private class that manages access to the public classes' internals. | ||
| 32 | class _private { | ||
| 33 | public: | ||
| 34 | //get the internal expression object from the expression. | ||
| 35 | static _expr *get_expr(const expr &e) { | ||
| 36 | return e.m_expr; | ||
| 37 | } | ||
| 38 | |||
| 39 | //create new expression from given expression | ||
| 40 | static expr construct_expr(_expr *e) { | ||
| 41 | return e; | ||
| 42 | } | ||
| 43 | |||
| 44 | //get the internal expression object from the rule. | ||
| 45 | static _expr *get_expr(rule &r) { | ||
| 46 | return r.m_expr; | ||
| 47 | } | ||
| 48 | |||
| 49 | //get the internal parse proc from the rule. | ||
| 50 | static parse_proc get_parse_proc(rule &r) { | ||
| 51 | return r.m_parse_proc; | ||
| 52 | } | ||
| 53 | }; | ||
| 54 | |||
| 55 | |||
| 56 | class _context; | ||
| 57 | |||
| 58 | |||
| 59 | //parser state | ||
| 60 | class _state { | ||
| 61 | public: | ||
| 62 | //position | ||
| 63 | pos m_pos; | ||
| 64 | |||
| 65 | //size of match vector | ||
| 66 | size_t m_matches; | ||
| 67 | |||
| 68 | //constructor | ||
| 69 | _state(_context &con); | ||
| 70 | }; | ||
| 71 | |||
| 72 | |||
| 73 | //match | ||
| 74 | class _match { | ||
| 75 | public: | ||
| 76 | //rule matched | ||
| 77 | rule *m_rule; | ||
| 78 | |||
| 79 | //begin position | ||
| 80 | pos m_begin; | ||
| 81 | |||
| 82 | //end position | ||
| 83 | pos m_end; | ||
| 84 | |||
| 85 | //null constructor | ||
| 86 | _match() {} | ||
| 87 | |||
| 88 | //constructor from parameters | ||
| 89 | _match(rule *r, const pos &b, const pos &e) : | ||
| 90 | m_rule(r), | ||
| 91 | m_begin(b), | ||
| 92 | m_end(e) | ||
| 93 | { | ||
| 94 | } | ||
| 95 | }; | ||
| 96 | |||
| 97 | |||
| 98 | //match vector | ||
| 99 | typedef std::vector<_match> _match_vector; | ||
| 100 | |||
| 101 | |||
| 102 | //parsing context | ||
| 103 | class _context { | ||
| 104 | public: | ||
| 105 | //user data | ||
| 106 | void* m_user_data; | ||
| 107 | |||
| 108 | //current position | ||
| 109 | pos m_pos; | ||
| 110 | |||
| 111 | //error position | ||
| 112 | pos m_error_pos; | ||
| 113 | |||
| 114 | //input begin | ||
| 115 | input::iterator m_begin; | ||
| 116 | |||
| 117 | //input end | ||
| 118 | input::iterator m_end; | ||
| 119 | |||
| 120 | //matches | ||
| 121 | _match_vector m_matches; | ||
| 122 | |||
| 123 | //constructor | ||
| 124 | _context(input &i, void* ud) : | ||
| 125 | m_user_data(ud), | ||
| 126 | m_pos(i), | ||
| 127 | m_error_pos(i), | ||
| 128 | m_begin(i.begin()), | ||
| 129 | m_end(i.end()) | ||
| 130 | { | ||
| 131 | } | ||
| 132 | |||
| 133 | //check if the end is reached | ||
| 134 | bool end() const { | ||
| 135 | return m_pos.m_it == m_end; | ||
| 136 | } | ||
| 137 | |||
| 138 | //get the current symbol | ||
| 139 | int symbol() const { | ||
| 140 | assert(!end()); | ||
| 141 | return *m_pos.m_it; | ||
| 142 | } | ||
| 143 | |||
| 144 | //set the longest possible error | ||
| 145 | void set_error_pos() { | ||
| 146 | if (m_pos.m_it > m_error_pos.m_it) { | ||
| 147 | m_error_pos = m_pos; | ||
| 148 | } | ||
| 149 | } | ||
| 150 | |||
| 151 | //next column | ||
| 152 | void next_col() { | ||
| 153 | ++m_pos.m_it; | ||
| 154 | ++m_pos.m_col; | ||
| 155 | } | ||
| 156 | |||
| 157 | //next line | ||
| 158 | void next_line() { | ||
| 159 | ++m_pos.m_line; | ||
| 160 | m_pos.m_col = 1; | ||
| 161 | } | ||
| 162 | |||
| 163 | //restore the state | ||
| 164 | void restore(const _state &st) { | ||
| 165 | m_pos = st.m_pos; | ||
| 166 | m_matches.resize(st.m_matches); | ||
| 167 | } | ||
| 168 | |||
| 169 | //parse non-term rule. | ||
| 170 | bool parse_non_term(rule &r); | ||
| 171 | |||
| 172 | //parse term rule. | ||
| 173 | bool parse_term(rule &r); | ||
| 174 | |||
| 175 | //execute all the parse procs | ||
| 176 | void do_parse_procs(void *d) const { | ||
| 177 | for(_match_vector::const_iterator it = m_matches.begin(); | ||
| 178 | it != m_matches.end(); | ||
| 179 | ++it) | ||
| 180 | { | ||
| 181 | const _match &m = *it; | ||
| 182 | parse_proc p = _private::get_parse_proc(*m.m_rule); | ||
| 183 | p(m.m_begin, m.m_end, d); | ||
| 184 | } | ||
| 185 | } | ||
| 186 | |||
| 187 | private: | ||
| 188 | //parse non-term rule. | ||
| 189 | bool _parse_non_term(rule &r); | ||
| 190 | |||
| 191 | //parse term rule. | ||
| 192 | bool _parse_term(rule &r); | ||
| 193 | }; | ||
| 194 | |||
| 195 | |||
| 196 | //base class for expressions | ||
| 197 | class _expr { | ||
| 198 | public: | ||
| 199 | //destructor. | ||
| 200 | virtual ~_expr() { | ||
| 201 | } | ||
| 202 | |||
| 203 | //parse with whitespace | ||
| 204 | virtual bool parse_non_term(_context &con) const = 0; | ||
| 205 | |||
| 206 | //parse terminal | ||
| 207 | virtual bool parse_term(_context &con) const = 0; | ||
| 208 | }; | ||
| 209 | |||
| 210 | |||
| 211 | //single character expression. | ||
| 212 | class _char : public _expr { | ||
| 213 | public: | ||
| 214 | //constructor. | ||
| 215 | _char(int c) : | ||
| 216 | m_char(c) | ||
| 217 | { | ||
| 218 | } | ||
| 219 | |||
| 220 | //parse with whitespace | ||
| 221 | virtual bool parse_non_term(_context &con) const { | ||
| 222 | return _parse(con); | ||
| 223 | } | ||
| 224 | |||
| 225 | //parse terminal | ||
| 226 | virtual bool parse_term(_context &con) const { | ||
| 227 | return _parse(con); | ||
| 228 | } | ||
| 229 | |||
| 230 | private: | ||
| 231 | //character | ||
| 232 | int m_char; | ||
| 233 | |||
| 234 | //internal parse | ||
| 235 | bool _parse(_context &con) const { | ||
| 236 | if (!con.end()) { | ||
| 237 | int ch = con.symbol(); | ||
| 238 | if (ch == m_char) { | ||
| 239 | con.next_col(); | ||
| 240 | return true; | ||
| 241 | } | ||
| 242 | } | ||
| 243 | con.set_error_pos(); | ||
| 244 | return false; | ||
| 245 | } | ||
| 246 | }; | ||
| 247 | |||
| 248 | |||
| 249 | //string expression. | ||
| 250 | class _string : public _expr { | ||
| 251 | public: | ||
| 252 | //constructor from ansi string. | ||
| 253 | _string(const char *s) : | ||
| 254 | m_string(s, s + strlen(s)) | ||
| 255 | { | ||
| 256 | } | ||
| 257 | |||
| 258 | //constructor from wide string. | ||
| 259 | _string(const wchar_t *s) : | ||
| 260 | m_string(s, s + wcslen(s)) | ||
| 261 | { | ||
| 262 | } | ||
| 263 | |||
| 264 | //parse with whitespace | ||
| 265 | virtual bool parse_non_term(_context &con) const { | ||
| 266 | return _parse(con); | ||
| 267 | } | ||
| 268 | |||
| 269 | //parse terminal | ||
| 270 | virtual bool parse_term(_context &con) const { | ||
| 271 | return _parse(con); | ||
| 272 | } | ||
| 273 | |||
| 274 | private: | ||
| 275 | //string | ||
| 276 | std::vector<int> m_string; | ||
| 277 | |||
| 278 | //parse the string | ||
| 279 | bool _parse(_context &con) const { | ||
| 280 | for(std::vector<int>::const_iterator it = m_string.begin(), | ||
| 281 | end = m_string.end();;) | ||
| 282 | { | ||
| 283 | if (it == end) return true; | ||
| 284 | if (con.end()) break; | ||
| 285 | if (con.symbol() != *it) break; | ||
| 286 | ++it; | ||
| 287 | con.next_col(); | ||
| 288 | } | ||
| 289 | con.set_error_pos(); | ||
| 290 | return false; | ||
| 291 | } | ||
| 292 | }; | ||
| 293 | |||
| 294 | |||
| 295 | //set expression. | ||
| 296 | class _set : public _expr { | ||
| 297 | public: | ||
| 298 | //constructor from ansi string. | ||
| 299 | _set(const char *s) { | ||
| 300 | for(; *s; ++s) { | ||
| 301 | _add(*s); | ||
| 302 | } | ||
| 303 | } | ||
| 304 | |||
| 305 | //constructor from wide string. | ||
| 306 | _set(const wchar_t *s) { | ||
| 307 | for(; *s; ++s) { | ||
| 308 | _add(*s); | ||
| 309 | } | ||
| 310 | } | ||
| 311 | |||
| 312 | //constructor from range. | ||
| 313 | _set(int min, int max) { | ||
| 314 | assert(min >= 0); | ||
| 315 | assert(min <= max); | ||
| 316 | m_set.resize((size_t)max + 1U); | ||
| 317 | for(; min <= max; ++min) { | ||
| 318 | m_set[(size_t)min] = true; | ||
| 319 | } | ||
| 320 | } | ||
| 321 | |||
| 322 | //parse with whitespace | ||
| 323 | virtual bool parse_non_term(_context &con) const { | ||
| 324 | return _parse(con); | ||
| 325 | } | ||
| 326 | |||
| 327 | //parse terminal | ||
| 328 | virtual bool parse_term(_context &con) const { | ||
| 329 | return _parse(con); | ||
| 330 | } | ||
| 331 | |||
| 332 | private: | ||
| 333 | //set is kept as an array of flags, for quick access | ||
| 334 | std::vector<bool> m_set; | ||
| 335 | |||
| 336 | //add character | ||
| 337 | void _add(size_t i) { | ||
| 338 | if (i >= m_set.size()) { | ||
| 339 | m_set.resize(i + 1); | ||
| 340 | } | ||
| 341 | m_set[i] = true; | ||
| 342 | } | ||
| 343 | |||
| 344 | //internal parse | ||
| 345 | bool _parse(_context &con) const { | ||
| 346 | if (!con.end()) { | ||
| 347 | size_t ch = con.symbol(); | ||
| 348 | if (ch < m_set.size() && m_set[ch]) { | ||
| 349 | con.next_col(); | ||
| 350 | return true; | ||
| 351 | } | ||
| 352 | } | ||
| 353 | con.set_error_pos(); | ||
| 354 | return false; | ||
| 355 | } | ||
| 356 | }; | ||
| 357 | |||
| 358 | |||
| 359 | //base class for unary expressions | ||
| 360 | class _unary : public _expr { | ||
| 361 | public: | ||
| 362 | //constructor. | ||
| 363 | _unary(_expr *e) : | ||
| 364 | m_expr(e) | ||
| 365 | { | ||
| 366 | } | ||
| 367 | |||
| 368 | //destructor. | ||
| 369 | virtual ~_unary() { | ||
| 370 | delete m_expr; | ||
| 371 | } | ||
| 372 | |||
| 373 | protected: | ||
| 374 | //expression | ||
| 375 | _expr *m_expr; | ||
| 376 | }; | ||
| 377 | |||
| 378 | |||
| 379 | //terminal | ||
| 380 | class _term : public _unary { | ||
| 381 | public: | ||
| 382 | //constructor. | ||
| 383 | _term(_expr *e) : | ||
| 384 | _unary(e) | ||
| 385 | { | ||
| 386 | } | ||
| 387 | |||
| 388 | //parse with whitespace | ||
| 389 | virtual bool parse_non_term(_context &con) const { | ||
| 390 | return m_expr->parse_term(con); | ||
| 391 | } | ||
| 392 | |||
| 393 | //parse terminal | ||
| 394 | virtual bool parse_term(_context &con) const { | ||
| 395 | return m_expr->parse_term(con); | ||
| 396 | } | ||
| 397 | }; | ||
| 398 | |||
| 399 | |||
| 400 | //user | ||
| 401 | class _user : public _unary { | ||
| 402 | public: | ||
| 403 | //constructor. | ||
| 404 | _user(_expr *e, const user_handler &callback) : | ||
| 405 | _unary(e), | ||
| 406 | m_handler(callback) | ||
| 407 | { | ||
| 408 | } | ||
| 409 | |||
| 410 | //parse with whitespace | ||
| 411 | virtual bool parse_non_term(_context &con) const { | ||
| 412 | pos pos = con.m_pos; | ||
| 413 | if (m_expr->parse_non_term(con)) { | ||
| 414 | item_t item = {pos.m_it, con.m_pos.m_it, con.m_user_data}; | ||
| 415 | return m_handler(item); | ||
| 416 | } | ||
| 417 | return false; | ||
| 418 | } | ||
| 419 | |||
| 420 | //parse terminal | ||
| 421 | virtual bool parse_term(_context &con) const { | ||
| 422 | pos pos = con.m_pos; | ||
| 423 | if (m_expr->parse_term(con)) { | ||
| 424 | item_t item = {pos.m_it, con.m_pos.m_it, con.m_user_data}; | ||
| 425 | return m_handler(item); | ||
| 426 | } | ||
| 427 | return false; | ||
| 428 | } | ||
| 429 | private: | ||
| 430 | user_handler m_handler; | ||
| 431 | }; | ||
| 432 | |||
| 433 | |||
| 434 | //loop 0 | ||
| 435 | class _loop0 : public _unary { | ||
| 436 | public: | ||
| 437 | //constructor. | ||
| 438 | _loop0(_expr *e) : | ||
| 439 | _unary(e) | ||
| 440 | { | ||
| 441 | } | ||
| 442 | |||
| 443 | //parse with whitespace | ||
| 444 | virtual bool parse_non_term(_context &con) const { | ||
| 445 | //if parsing of the first fails, restore the context and stop | ||
| 446 | _state st(con); | ||
| 447 | if (!m_expr->parse_non_term(con)) { | ||
| 448 | con.restore(st); | ||
| 449 | return true; | ||
| 450 | } | ||
| 451 | |||
| 452 | //parse the rest | ||
| 453 | for(;;) { | ||
| 454 | _state st(con); | ||
| 455 | if (!m_expr->parse_non_term(con)) { | ||
| 456 | con.restore(st); | ||
| 457 | break; | ||
| 458 | } | ||
| 459 | } | ||
| 460 | |||
| 461 | return true; | ||
| 462 | } | ||
| 463 | |||
| 464 | //parse terminal | ||
| 465 | virtual bool parse_term(_context &con) const { | ||
| 466 | //if parsing of the first fails, restore the context and stop | ||
| 467 | _state st(con); | ||
| 468 | if (!m_expr->parse_term(con)) { | ||
| 469 | con.restore(st); | ||
| 470 | return true; | ||
| 471 | } | ||
| 472 | |||
| 473 | //parse the rest until no more parsing is possible | ||
| 474 | for(;;) { | ||
| 475 | _state st(con); | ||
| 476 | if (!m_expr->parse_term(con)) { | ||
| 477 | con.restore(st); | ||
| 478 | break; | ||
| 479 | } | ||
| 480 | } | ||
| 481 | |||
| 482 | return true; | ||
| 483 | } | ||
| 484 | }; | ||
| 485 | |||
| 486 | |||
| 487 | //loop 1 | ||
| 488 | class _loop1 : public _unary { | ||
| 489 | public: | ||
| 490 | //constructor. | ||
| 491 | _loop1(_expr *e) : | ||
| 492 | _unary(e) | ||
| 493 | { | ||
| 494 | } | ||
| 495 | |||
| 496 | //parse with whitespace | ||
| 497 | virtual bool parse_non_term(_context &con) const { | ||
| 498 | //parse the first; if the first fails, stop | ||
| 499 | if (!m_expr->parse_non_term(con)) return false; | ||
| 500 | |||
| 501 | //parse the rest until no more parsing is possible | ||
| 502 | for(;;) { | ||
| 503 | _state st(con); | ||
| 504 | if (!m_expr->parse_non_term(con)) { | ||
| 505 | con.restore(st); | ||
| 506 | break; | ||
| 507 | } | ||
| 508 | } | ||
| 509 | |||
| 510 | return true; | ||
| 511 | } | ||
| 512 | |||
| 513 | //parse terminal | ||
| 514 | virtual bool parse_term(_context &con) const { | ||
| 515 | //parse the first; if the first fails, stop | ||
| 516 | if (!m_expr->parse_term(con)) return false; | ||
| 517 | |||
| 518 | //parse the rest until no more parsing is possible | ||
| 519 | for(;;) { | ||
| 520 | _state st(con); | ||
| 521 | if (!m_expr->parse_term(con)) { | ||
| 522 | con.restore(st); | ||
| 523 | break; | ||
| 524 | } | ||
| 525 | } | ||
| 526 | |||
| 527 | return true; | ||
| 528 | } | ||
| 529 | }; | ||
| 530 | |||
| 531 | |||
| 532 | //optional | ||
| 533 | class _optional : public _unary { | ||
| 534 | public: | ||
| 535 | //constructor. | ||
| 536 | _optional(_expr *e) : | ||
| 537 | _unary(e) | ||
| 538 | { | ||
| 539 | } | ||
| 540 | |||
| 541 | //parse with whitespace | ||
| 542 | virtual bool parse_non_term(_context &con) const { | ||
| 543 | _state st(con); | ||
| 544 | if (!m_expr->parse_non_term(con)) con.restore(st); | ||
| 545 | return true; | ||
| 546 | } | ||
| 547 | |||
| 548 | //parse terminal | ||
| 549 | virtual bool parse_term(_context &con) const { | ||
| 550 | _state st(con); | ||
| 551 | if (!m_expr->parse_term(con)) con.restore(st); | ||
| 552 | return true; | ||
| 553 | } | ||
| 554 | }; | ||
| 555 | |||
| 556 | |||
| 557 | //and | ||
| 558 | class _and : public _unary { | ||
| 559 | public: | ||
| 560 | //constructor. | ||
| 561 | _and(_expr *e) : | ||
| 562 | _unary(e) | ||
| 563 | { | ||
| 564 | } | ||
| 565 | |||
| 566 | //parse with whitespace | ||
| 567 | virtual bool parse_non_term(_context &con) const { | ||
| 568 | _state st(con); | ||
| 569 | bool ok = m_expr->parse_non_term(con); | ||
| 570 | con.restore(st); | ||
| 571 | return ok; | ||
| 572 | } | ||
| 573 | |||
| 574 | //parse terminal | ||
| 575 | virtual bool parse_term(_context &con) const { | ||
| 576 | _state st(con); | ||
| 577 | bool ok = m_expr->parse_term(con); | ||
| 578 | con.restore(st); | ||
| 579 | return ok; | ||
| 580 | } | ||
| 581 | }; | ||
| 582 | |||
| 583 | |||
| 584 | //not | ||
| 585 | class _not : public _unary { | ||
| 586 | public: | ||
| 587 | //constructor. | ||
| 588 | _not(_expr *e) : | ||
| 589 | _unary(e) | ||
| 590 | { | ||
| 591 | } | ||
| 592 | |||
| 593 | //parse with whitespace | ||
| 594 | virtual bool parse_non_term(_context &con) const { | ||
| 595 | _state st(con); | ||
| 596 | bool ok = !m_expr->parse_non_term(con); | ||
| 597 | con.restore(st); | ||
| 598 | return ok; | ||
| 599 | } | ||
| 600 | |||
| 601 | //parse terminal | ||
| 602 | virtual bool parse_term(_context &con) const { | ||
| 603 | _state st(con); | ||
| 604 | bool ok = !m_expr->parse_term(con); | ||
| 605 | con.restore(st); | ||
| 606 | return ok; | ||
| 607 | } | ||
| 608 | }; | ||
| 609 | |||
| 610 | |||
| 611 | //newline | ||
| 612 | class _nl : public _unary { | ||
| 613 | public: | ||
| 614 | //constructor. | ||
| 615 | _nl(_expr *e) : | ||
| 616 | _unary(e) | ||
| 617 | { | ||
| 618 | } | ||
| 619 | |||
| 620 | //parse with whitespace | ||
| 621 | virtual bool parse_non_term(_context &con) const { | ||
| 622 | if (!m_expr->parse_non_term(con)) return false; | ||
| 623 | con.next_line(); | ||
| 624 | return true; | ||
| 625 | } | ||
| 626 | |||
| 627 | //parse terminal | ||
| 628 | virtual bool parse_term(_context &con) const { | ||
| 629 | if (!m_expr->parse_term(con)) return false; | ||
| 630 | con.next_line(); | ||
| 631 | return true; | ||
| 632 | } | ||
| 633 | }; | ||
| 634 | |||
| 635 | |||
| 636 | //base class for binary expressions | ||
| 637 | class _binary : public _expr { | ||
| 638 | public: | ||
| 639 | //constructor. | ||
| 640 | _binary(_expr *left, _expr *right) : | ||
| 641 | m_left(left), m_right(right) | ||
| 642 | { | ||
| 643 | } | ||
| 644 | |||
| 645 | //destructor. | ||
| 646 | virtual ~_binary() { | ||
| 647 | delete m_left; | ||
| 648 | delete m_right; | ||
| 649 | } | ||
| 650 | |||
| 651 | protected: | ||
| 652 | //left and right expressions | ||
| 653 | _expr *m_left, *m_right; | ||
| 654 | }; | ||
| 655 | |||
| 656 | |||
| 657 | //sequence | ||
| 658 | class _seq : public _binary { | ||
| 659 | public: | ||
| 660 | //constructor. | ||
| 661 | _seq(_expr *left, _expr *right) : | ||
| 662 | _binary(left, right) | ||
| 663 | { | ||
| 664 | } | ||
| 665 | |||
| 666 | //parse with whitespace | ||
| 667 | virtual bool parse_non_term(_context &con) const { | ||
| 668 | if (!m_left->parse_non_term(con)) return false; | ||
| 669 | return m_right->parse_non_term(con); | ||
| 670 | } | ||
| 671 | |||
| 672 | //parse terminal | ||
| 673 | virtual bool parse_term(_context &con) const { | ||
| 674 | if (!m_left->parse_term(con)) return false; | ||
| 675 | return m_right->parse_term(con); | ||
| 676 | } | ||
| 677 | }; | ||
| 678 | |||
| 679 | |||
| 680 | //choice | ||
| 681 | class _choice : public _binary { | ||
| 682 | public: | ||
| 683 | //constructor. | ||
| 684 | _choice(_expr *left, _expr *right) : | ||
| 685 | _binary(left, right) | ||
| 686 | { | ||
| 687 | } | ||
| 688 | |||
| 689 | //parse with whitespace | ||
| 690 | virtual bool parse_non_term(_context &con) const { | ||
| 691 | _state st(con); | ||
| 692 | if (m_left->parse_non_term(con)) return true; | ||
| 693 | con.restore(st); | ||
| 694 | return m_right->parse_non_term(con); | ||
| 695 | } | ||
| 696 | |||
| 697 | //parse terminal | ||
| 698 | virtual bool parse_term(_context &con) const { | ||
| 699 | _state st(con); | ||
| 700 | if (m_left->parse_term(con)) return true; | ||
| 701 | con.restore(st); | ||
| 702 | return m_right->parse_term(con); | ||
| 703 | } | ||
| 704 | }; | ||
| 705 | |||
| 706 | |||
| 707 | //reference to rule | ||
| 708 | class _ref : public _expr { | ||
| 709 | public: | ||
| 710 | //constructor. | ||
| 711 | _ref(rule &r) : | ||
| 712 | m_rule(r) | ||
| 713 | { | ||
| 714 | } | ||
| 715 | |||
| 716 | //parse with whitespace | ||
| 717 | virtual bool parse_non_term(_context &con) const { | ||
| 718 | return con.parse_non_term(m_rule); | ||
| 719 | } | ||
| 720 | |||
| 721 | //parse terminal | ||
| 722 | virtual bool parse_term(_context &con) const { | ||
| 723 | return con.parse_term(m_rule); | ||
| 724 | } | ||
| 725 | |||
| 726 | private: | ||
| 727 | //reference | ||
| 728 | rule &m_rule; | ||
| 729 | }; | ||
| 730 | |||
| 731 | |||
| 732 | //eof | ||
| 733 | class _eof : public _expr { | ||
| 734 | public: | ||
| 735 | //parse with whitespace | ||
| 736 | virtual bool parse_non_term(_context &con) const { | ||
| 737 | return parse_term(con); | ||
| 738 | } | ||
| 739 | |||
| 740 | //parse terminal | ||
| 741 | virtual bool parse_term(_context &con) const { | ||
| 742 | return con.end(); | ||
| 743 | } | ||
| 744 | }; | ||
| 745 | |||
| 746 | |||
| 747 | //any | ||
| 748 | class _any : public _expr { | ||
| 749 | public: | ||
| 750 | //parse with whitespace | ||
| 751 | virtual bool parse_non_term(_context &con) const { | ||
| 752 | return parse_term(con); | ||
| 753 | } | ||
| 754 | |||
| 755 | //parse terminal | ||
| 756 | virtual bool parse_term(_context &con) const { | ||
| 757 | if (!con.end()) { | ||
| 758 | con.next_col(); | ||
| 759 | return true; | ||
| 760 | } | ||
| 761 | con.set_error_pos(); | ||
| 762 | return false; | ||
| 763 | } | ||
| 764 | }; | ||
| 765 | |||
| 766 | |||
| 767 | //true | ||
| 768 | class _true : public _expr { | ||
| 769 | public: | ||
| 770 | //parse with whitespace | ||
| 771 | virtual bool parse_non_term(_context &con) const { | ||
| 772 | return true; | ||
| 773 | } | ||
| 774 | |||
| 775 | //parse terminal | ||
| 776 | virtual bool parse_term(_context &con) const { | ||
| 777 | return true; | ||
| 778 | } | ||
| 779 | }; | ||
| 780 | |||
| 781 | |||
| 782 | //false | ||
| 783 | class _false: public _expr { | ||
| 784 | public: | ||
| 785 | //parse with whitespace | ||
| 786 | virtual bool parse_non_term(_context &con) const { | ||
| 787 | return false; | ||
| 788 | } | ||
| 789 | |||
| 790 | //parse terminal | ||
| 791 | virtual bool parse_term(_context &con) const { | ||
| 792 | return false; | ||
| 793 | } | ||
| 794 | }; | ||
| 795 | |||
| 796 | //exception thrown when left recursion terminates successfully | ||
| 797 | struct _lr_ok { | ||
| 798 | rule *m_rule; | ||
| 799 | _lr_ok(rule *r) : m_rule(r) {} | ||
| 800 | }; | ||
| 801 | |||
| 802 | |||
| 803 | //constructor | ||
| 804 | _state::_state(_context &con) : | ||
| 805 | m_pos(con.m_pos), | ||
| 806 | m_matches(con.m_matches.size()) | ||
| 807 | { | ||
| 808 | } | ||
| 809 | |||
| 810 | |||
| 811 | //parse non-term rule. | ||
| 812 | bool _context::parse_non_term(rule &r) { | ||
| 813 | //save the state of the rule | ||
| 814 | rule::_state old_state = r.m_state; | ||
| 815 | |||
| 816 | //success/failure result | ||
| 817 | bool ok; | ||
| 818 | |||
| 819 | //compute the new position | ||
| 820 | size_t new_pos = m_pos.m_it - m_begin; | ||
| 821 | |||
| 822 | //check if we have left recursion | ||
| 823 | bool lr = new_pos == r.m_state.m_pos; | ||
| 824 | |||
| 825 | //update the rule's state | ||
| 826 | r.m_state.m_pos = new_pos; | ||
| 827 | |||
| 828 | //handle the mode of the rule | ||
| 829 | switch (r.m_state.m_mode) { | ||
| 830 | //normal parse | ||
| 831 | case rule::_PARSE: | ||
| 832 | if (lr) { | ||
| 833 | //first try to parse the rule by rejecting it, so alternative branches are examined | ||
| 834 | r.m_state.m_mode = rule::_REJECT; | ||
| 835 | ok = _parse_non_term(r); | ||
| 836 | |||
| 837 | //if the first try is successful, try accepting the rule, | ||
| 838 | //so other elements of the sequence are parsed | ||
| 839 | if (ok) { | ||
| 840 | r.m_state.m_mode = rule::_ACCEPT; | ||
| 841 | |||
| 842 | //loop until no more parsing can be done | ||
| 843 | for(;;) { | ||
| 844 | //store the correct state, in order to backtrack if the call fails | ||
| 845 | _state st(*this); | ||
| 846 | |||
| 847 | //update the rule position to the current position, | ||
| 848 | //because at this state the rule is resolving the left recursion | ||
| 849 | r.m_state.m_pos = m_pos.m_it - m_begin; | ||
| 850 | |||
| 851 | //if parsing fails, restore the last good state and stop | ||
| 852 | if (!_parse_non_term(r)) { | ||
| 853 | restore(st); | ||
| 854 | break; | ||
| 855 | } | ||
| 856 | } | ||
| 857 | |||
| 858 | //since the left recursion was resolved successfully, | ||
| 859 | //return via a non-local exit | ||
| 860 | r.m_state = old_state; | ||
| 861 | throw _lr_ok(r.this_ptr()); | ||
| 862 | } | ||
| 863 | } | ||
| 864 | else { | ||
| 865 | try { | ||
| 866 | ok = _parse_non_term(r); | ||
| 867 | } | ||
| 868 | catch (const _lr_ok &ex) { | ||
| 869 | //since left recursions may be mutual, we must test which rule's left recursion | ||
| 870 | //was ended successfully | ||
| 871 | if (ex.m_rule == r.this_ptr()) { | ||
| 872 | ok = true; | ||
| 873 | } | ||
| 874 | else { | ||
| 875 | r.m_state = old_state; | ||
| 876 | throw; | ||
| 877 | } | ||
| 878 | } | ||
| 879 | } | ||
| 880 | break; | ||
| 881 | |||
| 882 | //reject the left recursive rule | ||
| 883 | case rule::_REJECT: | ||
| 884 | if (lr) { | ||
| 885 | ok = false; | ||
| 886 | } | ||
| 887 | else { | ||
| 888 | r.m_state.m_mode = rule::_PARSE; | ||
| 889 | ok = _parse_non_term(r); | ||
| 890 | r.m_state.m_mode = rule::_REJECT; | ||
| 891 | } | ||
| 892 | break; | ||
| 893 | |||
| 894 | //accept the left recursive rule | ||
| 895 | case rule::_ACCEPT: | ||
| 896 | if (lr) { | ||
| 897 | ok = true; | ||
| 898 | } | ||
| 899 | else { | ||
| 900 | r.m_state.m_mode = rule::_PARSE; | ||
| 901 | ok = _parse_non_term(r); | ||
| 902 | r.m_state.m_mode = rule::_ACCEPT; | ||
| 903 | } | ||
| 904 | break; | ||
| 905 | } | ||
| 906 | |||
| 907 | //restore the rule's state | ||
| 908 | r.m_state = old_state; | ||
| 909 | |||
| 910 | return ok; | ||
| 911 | } | ||
| 912 | |||
| 913 | |||
| 914 | //parse term rule. | ||
| 915 | bool _context::parse_term(rule &r) { | ||
| 916 | //save the state of the rule | ||
| 917 | rule::_state old_state = r.m_state; | ||
| 918 | |||
| 919 | //success/failure result | ||
| 920 | bool ok; | ||
| 921 | |||
| 922 | //compute the new position | ||
| 923 | size_t new_pos = m_pos.m_it - m_begin; | ||
| 924 | |||
| 925 | //check if we have left recursion | ||
| 926 | bool lr = new_pos == r.m_state.m_pos; | ||
| 927 | |||
| 928 | //update the rule's state | ||
| 929 | r.m_state.m_pos = new_pos; | ||
| 930 | |||
| 931 | //handle the mode of the rule | ||
| 932 | switch (r.m_state.m_mode) { | ||
| 933 | //normal parse | ||
| 934 | case rule::_PARSE: | ||
| 935 | if (lr) { | ||
| 936 | //first try to parse the rule by rejecting it, so alternative branches are examined | ||
| 937 | r.m_state.m_mode = rule::_REJECT; | ||
| 938 | ok = _parse_term(r); | ||
| 939 | |||
| 940 | //if the first try is successful, try accepting the rule, | ||
| 941 | //so other elements of the sequence are parsed | ||
| 942 | if (ok) { | ||
| 943 | r.m_state.m_mode = rule::_ACCEPT; | ||
| 944 | |||
| 945 | //loop until no more parsing can be done | ||
| 946 | for(;;) { | ||
| 947 | //store the correct state, in order to backtrack if the call fails | ||
| 948 | _state st(*this); | ||
| 949 | |||
| 950 | //update the rule position to the current position, | ||
| 951 | //because at this state the rule is resolving the left recursion | ||
| 952 | r.m_state.m_pos = m_pos.m_it - m_begin; | ||
| 953 | |||
| 954 | //if parsing fails, restore the last good state and stop | ||
| 955 | if (!_parse_term(r)) { | ||
| 956 | restore(st); | ||
| 957 | break; | ||
| 958 | } | ||
| 959 | } | ||
| 960 | |||
| 961 | //since the left recursion was resolved successfully, | ||
| 962 | //return via a non-local exit | ||
| 963 | r.m_state = old_state; | ||
| 964 | throw _lr_ok(r.this_ptr()); | ||
| 965 | } | ||
| 966 | } | ||
| 967 | else { | ||
| 968 | try { | ||
| 969 | ok = _parse_term(r); | ||
| 970 | } | ||
| 971 | catch (const _lr_ok &ex) { | ||
| 972 | //since left recursions may be mutual, we must test which rule's left recursion | ||
| 973 | //was ended successfully | ||
| 974 | if (ex.m_rule == r.this_ptr()) { | ||
| 975 | ok = true; | ||
| 976 | } | ||
| 977 | else { | ||
| 978 | r.m_state = old_state; | ||
| 979 | throw; | ||
| 980 | } | ||
| 981 | } | ||
| 982 | } | ||
| 983 | break; | ||
| 984 | |||
| 985 | //reject the left recursive rule | ||
| 986 | case rule::_REJECT: | ||
| 987 | if (lr) { | ||
| 988 | ok = false; | ||
| 989 | } | ||
| 990 | else { | ||
| 991 | r.m_state.m_mode = rule::_PARSE; | ||
| 992 | ok = _parse_term(r); | ||
| 993 | r.m_state.m_mode = rule::_REJECT; | ||
| 994 | } | ||
| 995 | break; | ||
| 996 | |||
| 997 | //accept the left recursive rule | ||
| 998 | case rule::_ACCEPT: | ||
| 999 | if (lr) { | ||
| 1000 | ok = true; | ||
| 1001 | } | ||
| 1002 | else { | ||
| 1003 | r.m_state.m_mode = rule::_PARSE; | ||
| 1004 | ok = _parse_term(r); | ||
| 1005 | r.m_state.m_mode = rule::_ACCEPT; | ||
| 1006 | } | ||
| 1007 | break; | ||
| 1008 | } | ||
| 1009 | |||
| 1010 | //restore the rule's state | ||
| 1011 | r.m_state = old_state; | ||
| 1012 | |||
| 1013 | return ok; | ||
| 1014 | } | ||
| 1015 | |||
| 1016 | |||
| 1017 | //parse non-term rule internal. | ||
| 1018 | bool _context::_parse_non_term(rule &r) { | ||
| 1019 | bool ok; | ||
| 1020 | if (_private::get_parse_proc(r)) { | ||
| 1021 | pos b = m_pos; | ||
| 1022 | ok = _private::get_expr(r)->parse_non_term(*this); | ||
| 1023 | if (ok) { | ||
| 1024 | m_matches.push_back(_match(r.this_ptr(), b, m_pos)); | ||
| 1025 | } | ||
| 1026 | } | ||
| 1027 | else { | ||
| 1028 | ok = _private::get_expr(r)->parse_non_term(*this); | ||
| 1029 | } | ||
| 1030 | return ok; | ||
| 1031 | } | ||
| 1032 | |||
| 1033 | |||
| 1034 | //parse term rule internal. | ||
| 1035 | bool _context::_parse_term(rule &r) { | ||
| 1036 | bool ok; | ||
| 1037 | if (_private::get_parse_proc(r)) { | ||
| 1038 | pos b = m_pos; | ||
| 1039 | ok = _private::get_expr(r)->parse_term(*this); | ||
| 1040 | if (ok) { | ||
| 1041 | m_matches.push_back(_match(r.this_ptr(), b, m_pos)); | ||
| 1042 | } | ||
| 1043 | } | ||
| 1044 | else { | ||
| 1045 | ok = _private::get_expr(r)->parse_term(*this); | ||
| 1046 | } | ||
| 1047 | return ok; | ||
| 1048 | } | ||
| 1049 | |||
| 1050 | |||
| 1051 | //get syntax error | ||
| 1052 | static error _syntax_error(_context &con) { | ||
| 1053 | return error(con.m_error_pos, con.m_error_pos, ERROR_SYNTAX_ERROR); | ||
| 1054 | } | ||
| 1055 | |||
| 1056 | |||
| 1057 | //get eof error | ||
| 1058 | static error _eof_error(_context &con) { | ||
| 1059 | return error(con.m_error_pos, con.m_error_pos, ERROR_INVALID_EOF); | ||
| 1060 | } | ||
| 1061 | |||
| 1062 | |||
| 1063 | /** constructor from input. | ||
| 1064 | @param i input. | ||
| 1065 | */ | ||
| 1066 | pos::pos(input &i) : | ||
| 1067 | m_it(i.begin()), | ||
| 1068 | m_line(1), | ||
| 1069 | m_col(1) | ||
| 1070 | { | ||
| 1071 | } | ||
| 1072 | |||
| 1073 | |||
| 1074 | /** character terminal constructor. | ||
| 1075 | @param c character. | ||
| 1076 | */ | ||
| 1077 | expr::expr(int c) : | ||
| 1078 | m_expr(new _char(c)) | ||
| 1079 | { | ||
| 1080 | } | ||
| 1081 | |||
| 1082 | |||
| 1083 | /** null-terminated string terminal constructor. | ||
| 1084 | @param s null-terminated string. | ||
| 1085 | */ | ||
| 1086 | expr::expr(const char *s) : | ||
| 1087 | m_expr(new _string(s)) | ||
| 1088 | { | ||
| 1089 | } | ||
| 1090 | |||
| 1091 | |||
| 1092 | /** null-terminated wide string terminal constructor. | ||
| 1093 | @param s null-terminated string. | ||
| 1094 | */ | ||
| 1095 | expr::expr(const wchar_t *s) : | ||
| 1096 | m_expr(new _string(s)) | ||
| 1097 | { | ||
| 1098 | } | ||
| 1099 | |||
| 1100 | |||
| 1101 | /** rule reference constructor. | ||
| 1102 | @param r rule. | ||
| 1103 | */ | ||
| 1104 | expr::expr(rule &r) : | ||
| 1105 | m_expr(new _ref(r)) | ||
| 1106 | { | ||
| 1107 | } | ||
| 1108 | |||
| 1109 | |||
| 1110 | /** creates a zero-or-more loop out of this expression. | ||
| 1111 | @return a zero-or-more loop expression. | ||
| 1112 | */ | ||
| 1113 | expr expr::operator *() const { | ||
| 1114 | return _private::construct_expr(new _loop0(m_expr)); | ||
| 1115 | } | ||
| 1116 | |||
| 1117 | |||
| 1118 | /** creates a one-or-more loop out of this expression. | ||
| 1119 | @return a one-or-more loop expression. | ||
| 1120 | */ | ||
| 1121 | expr expr::operator +() const { | ||
| 1122 | return _private::construct_expr(new _loop1(m_expr)); | ||
| 1123 | } | ||
| 1124 | |||
| 1125 | |||
| 1126 | /** creates an optional out of this expression. | ||
| 1127 | @return an optional expression. | ||
| 1128 | */ | ||
| 1129 | expr expr::operator -() const { | ||
| 1130 | return _private::construct_expr(new _optional(m_expr)); | ||
| 1131 | } | ||
| 1132 | |||
| 1133 | |||
| 1134 | /** creates an AND-expression. | ||
| 1135 | @return an AND-expression. | ||
| 1136 | */ | ||
| 1137 | expr expr::operator &() const { | ||
| 1138 | return _private::construct_expr((new _and(m_expr))); | ||
| 1139 | } | ||
| 1140 | |||
| 1141 | |||
| 1142 | /** creates a NOT-expression. | ||
| 1143 | @return a NOT-expression. | ||
| 1144 | */ | ||
| 1145 | expr expr::operator !() const { | ||
| 1146 | return _private::construct_expr(new _not(m_expr)); | ||
| 1147 | } | ||
| 1148 | |||
| 1149 | |||
| 1150 | /** constructor. | ||
| 1151 | @param b begin position. | ||
| 1152 | @param e end position. | ||
| 1153 | */ | ||
| 1154 | input_range::input_range(const pos &b, const pos &e) : | ||
| 1155 | m_begin(b), | ||
| 1156 | m_end(e) | ||
| 1157 | { | ||
| 1158 | } | ||
| 1159 | |||
| 1160 | |||
| 1161 | /** constructor. | ||
| 1162 | @param b begin position. | ||
| 1163 | @param e end position. | ||
| 1164 | @param t error type. | ||
| 1165 | */ | ||
| 1166 | error::error(const pos &b, const pos &e, int t) : | ||
| 1167 | input_range(b, e), | ||
| 1168 | m_type(t) | ||
| 1169 | { | ||
| 1170 | } | ||
| 1171 | |||
| 1172 | |||
| 1173 | /** compare on begin position. | ||
| 1174 | @param e the other error to compare this with. | ||
| 1175 | @return true if this comes before the previous error, false otherwise. | ||
| 1176 | */ | ||
| 1177 | bool error::operator < (const error &e) const { | ||
| 1178 | return m_begin.m_it < e.m_begin.m_it; | ||
| 1179 | } | ||
| 1180 | |||
| 1181 | |||
| 1182 | /** character terminal constructor. | ||
| 1183 | @param c character. | ||
| 1184 | */ | ||
| 1185 | rule::rule(int c) : | ||
| 1186 | m_expr(new _char(c)) | ||
| 1187 | { | ||
| 1188 | m_parse_proc = _get_parse_proc(this); | ||
| 1189 | } | ||
| 1190 | |||
| 1191 | |||
| 1192 | /** null-terminated string terminal constructor. | ||
| 1193 | @param s null-terminated string. | ||
| 1194 | */ | ||
| 1195 | rule::rule(const char *s) : | ||
| 1196 | m_expr(new _string(s)) | ||
| 1197 | { | ||
| 1198 | m_parse_proc = _get_parse_proc(this); | ||
| 1199 | } | ||
| 1200 | |||
| 1201 | |||
| 1202 | /** null-terminated wide string terminal constructor. | ||
| 1203 | @param s null-terminated string. | ||
| 1204 | */ | ||
| 1205 | rule::rule(const wchar_t *s) : | ||
| 1206 | m_expr(new _string(s)) | ||
| 1207 | { | ||
| 1208 | m_parse_proc = _get_parse_proc(this); | ||
| 1209 | } | ||
| 1210 | |||
| 1211 | |||
| 1212 | /** constructor from expression. | ||
| 1213 | @param e expression. | ||
| 1214 | */ | ||
| 1215 | rule::rule(const expr &e) : | ||
| 1216 | m_expr(_private::get_expr(e)) | ||
| 1217 | { | ||
| 1218 | m_parse_proc = _get_parse_proc(this); | ||
| 1219 | } | ||
| 1220 | |||
| 1221 | |||
| 1222 | /** constructor from rule. | ||
| 1223 | @param r rule. | ||
| 1224 | */ | ||
| 1225 | rule::rule(rule &r) : | ||
| 1226 | m_expr(new _ref(r)), | ||
| 1227 | m_parse_proc(0) | ||
| 1228 | { | ||
| 1229 | m_parse_proc = _get_parse_proc(this); | ||
| 1230 | } | ||
| 1231 | |||
| 1232 | |||
| 1233 | /** invalid constructor from rule (required by gcc). | ||
| 1234 | @param r rule. | ||
| 1235 | @exception std::logic_error always thrown. | ||
| 1236 | */ | ||
| 1237 | rule::rule(const rule &r) { | ||
| 1238 | throw std::logic_error("invalid operation"); | ||
| 1239 | } | ||
| 1240 | |||
| 1241 | |||
| 1242 | /** deletes the internal object that represents the expression. | ||
| 1243 | */ | ||
| 1244 | rule::~rule() { | ||
| 1245 | delete m_expr; | ||
| 1246 | } | ||
| 1247 | |||
| 1248 | |||
| 1249 | /** creates a zero-or-more loop out of this rule. | ||
| 1250 | @return a zero-or-more loop rule. | ||
| 1251 | */ | ||
| 1252 | expr rule::operator *() { | ||
| 1253 | return _private::construct_expr(new _loop0(new _ref(*this))); | ||
| 1254 | } | ||
| 1255 | |||
| 1256 | |||
| 1257 | /** creates a one-or-more loop out of this rule. | ||
| 1258 | @return a one-or-more loop rule. | ||
| 1259 | */ | ||
| 1260 | expr rule::operator +() { | ||
| 1261 | return _private::construct_expr(new _loop1(new _ref(*this))); | ||
| 1262 | } | ||
| 1263 | |||
| 1264 | |||
| 1265 | /** creates an optional out of this rule. | ||
| 1266 | @return an optional rule. | ||
| 1267 | */ | ||
| 1268 | expr rule::operator -() { | ||
| 1269 | return _private::construct_expr(new _optional(new _ref(*this))); | ||
| 1270 | } | ||
| 1271 | |||
| 1272 | |||
| 1273 | /** creates an AND-expression out of this rule. | ||
| 1274 | @return an AND-expression out of this rule. | ||
| 1275 | */ | ||
| 1276 | expr rule::operator &() { | ||
| 1277 | return _private::construct_expr(new _and(new _ref(*this))); | ||
| 1278 | } | ||
| 1279 | |||
| 1280 | |||
| 1281 | /** creates a NOT-expression out of this rule. | ||
| 1282 | @return a NOT-expression out of this rule. | ||
| 1283 | */ | ||
| 1284 | expr rule::operator !() { | ||
| 1285 | return _private::construct_expr(new _not(new _ref(*this))); | ||
| 1286 | } | ||
| 1287 | |||
| 1288 | |||
| 1289 | /** sets the parse procedure. | ||
| 1290 | @param p procedure. | ||
| 1291 | */ | ||
| 1292 | void rule::set_parse_proc(parse_proc p) { | ||
| 1293 | assert(p); | ||
| 1294 | m_parse_proc = p; | ||
| 1295 | _parse_proc_map_t& _parse_proc_map = _get_parse_proc_map(); | ||
| 1296 | _parse_proc_map[this] = p; | ||
| 1297 | } | ||
| 1298 | |||
| 1299 | |||
| 1300 | /** creates a sequence of expressions. | ||
| 1301 | @param left left operand. | ||
| 1302 | @param right right operand. | ||
| 1303 | @return an expression which parses a sequence. | ||
| 1304 | */ | ||
| 1305 | expr operator >> (const expr &left, const expr &right) { | ||
| 1306 | return _private::construct_expr( | ||
| 1307 | new _seq(_private::get_expr(left), _private::get_expr(right))); | ||
| 1308 | } | ||
| 1309 | |||
| 1310 | |||
| 1311 | /** creates a choice of expressions. | ||
| 1312 | @param left left operand. | ||
| 1313 | @param right right operand. | ||
| 1314 | @return an expression which parses a choice. | ||
| 1315 | */ | ||
| 1316 | expr operator | (const expr &left, const expr &right) { | ||
| 1317 | return _private::construct_expr( | ||
| 1318 | new _choice(_private::get_expr(left), _private::get_expr(right))); | ||
| 1319 | } | ||
| 1320 | |||
| 1321 | |||
| 1322 | /** converts a parser expression into a terminal. | ||
| 1323 | @param e expression. | ||
| 1324 | @return an expression which parses a terminal. | ||
| 1325 | */ | ||
| 1326 | expr term(const expr &e) { | ||
| 1327 | return _private::construct_expr( | ||
| 1328 | new _term(_private::get_expr(e))); | ||
| 1329 | } | ||
| 1330 | |||
| 1331 | |||
| 1332 | /** creates a set expression from a null-terminated string. | ||
| 1333 | @param s null-terminated string with characters of the set. | ||
| 1334 | @return an expression which parses a single character out of a set. | ||
| 1335 | */ | ||
| 1336 | expr set(const char *s) { | ||
| 1337 | return _private::construct_expr(new _set(s)); | ||
| 1338 | } | ||
| 1339 | |||
| 1340 | |||
| 1341 | /** creates a set expression from a null-terminated wide string. | ||
| 1342 | @param s null-terminated string with characters of the set. | ||
| 1343 | @return an expression which parses a single character out of a set. | ||
| 1344 | */ | ||
| 1345 | expr set(const wchar_t *s) { | ||
| 1346 | return _private::construct_expr(new _set(s)); | ||
| 1347 | } | ||
| 1348 | |||
| 1349 | |||
| 1350 | /** creates a range expression. | ||
| 1351 | @param min min character. | ||
| 1352 | @param max max character. | ||
| 1353 | @return an expression which parses a single character out of range. | ||
| 1354 | */ | ||
| 1355 | expr range(int min, int max) { | ||
| 1356 | return _private::construct_expr(new _set(min, max)); | ||
| 1357 | } | ||
| 1358 | |||
| 1359 | |||
| 1360 | /** creates an expression which increments the line counter | ||
| 1361 | and resets the column counter when the given expression | ||
| 1362 | is parsed successfully; used for newline characters. | ||
| 1363 | @param e expression to wrap into a newline parser. | ||
| 1364 | @return an expression that handles newlines. | ||
| 1365 | */ | ||
| 1366 | expr nl(const expr &e) { | ||
| 1367 | return _private::construct_expr(new _nl(_private::get_expr(e))); | ||
| 1368 | } | ||
| 1369 | |||
| 1370 | |||
| 1371 | /** creates an expression which tests for the end of input. | ||
| 1372 | @return an expression that handles the end of input. | ||
| 1373 | */ | ||
| 1374 | expr eof() { | ||
| 1375 | return _private::construct_expr(new _eof()); | ||
| 1376 | } | ||
| 1377 | |||
| 1378 | |||
| 1379 | /** creates a not expression. | ||
| 1380 | @param e expression. | ||
| 1381 | @return the appropriate expression. | ||
| 1382 | */ | ||
| 1383 | expr not_(const expr &e) { | ||
| 1384 | return !e; | ||
| 1385 | } | ||
| 1386 | |||
| 1387 | |||
| 1388 | /** creates an and expression. | ||
| 1389 | @param e expression. | ||
| 1390 | @return the appropriate expression. | ||
| 1391 | */ | ||
| 1392 | expr and_(const expr &e) { | ||
| 1393 | return &e; | ||
| 1394 | } | ||
| 1395 | |||
| 1396 | |||
| 1397 | /** creates an expression that parses any character. | ||
| 1398 | @return the appropriate expression. | ||
| 1399 | */ | ||
| 1400 | expr any() { | ||
| 1401 | return _private::construct_expr(new _any()); | ||
| 1402 | } | ||
| 1403 | |||
| 1404 | |||
| 1405 | /** parsing succeeds without consuming any input. | ||
| 1406 | */ | ||
| 1407 | expr true_() { | ||
| 1408 | return _private::construct_expr(new _true()); | ||
| 1409 | } | ||
| 1410 | |||
| 1411 | |||
| 1412 | /** parsing fails without consuming any input. | ||
| 1413 | */ | ||
| 1414 | expr false_() { | ||
| 1415 | return _private::construct_expr(new _false()); | ||
| 1416 | } | ||
| 1417 | |||
| 1418 | |||
| 1419 | /** parse with target expression and let user handle result. | ||
| 1420 | */ | ||
| 1421 | expr user(const expr &e, const user_handler& handler) { | ||
| 1422 | return _private::construct_expr(new _user(_private::get_expr(e), handler)); | ||
| 1423 | } | ||
| 1424 | |||
| 1425 | |||
| 1426 | /** parses the given input. | ||
| 1427 | The parse procedures of each rule parsed are executed | ||
| 1428 | before this function returns, if parsing succeeds. | ||
| 1429 | @param i input. | ||
| 1430 | @param g root rule of grammar. | ||
| 1431 | @param el list of errors. | ||
| 1432 | @param d user data, passed to the parse procedures. | ||
| 1433 | @return true on parsing success, false on failure. | ||
| 1434 | */ | ||
| 1435 | bool parse(input &i, rule &g, error_list &el, void *d, void* ud) { | ||
| 1436 | //prepare context | ||
| 1437 | _context con(i, ud); | ||
| 1438 | |||
| 1439 | //parse grammar | ||
| 1440 | if (!con.parse_non_term(g)) { | ||
| 1441 | el.push_back(_syntax_error(con)); | ||
| 1442 | return false; | ||
| 1443 | } | ||
| 1444 | |||
| 1445 | //if end is not reached, there was an error | ||
| 1446 | if (!con.end()) { | ||
| 1447 | if (con.m_error_pos.m_it < con.m_end) { | ||
| 1448 | el.push_back(_syntax_error(con)); | ||
| 1449 | } | ||
| 1450 | else { | ||
| 1451 | el.push_back(_eof_error(con)); | ||
| 1452 | } | ||
| 1453 | return false; | ||
| 1454 | } | ||
| 1455 | |||
| 1456 | //success; execute the parse procedures | ||
| 1457 | con.do_parse_procs(d); | ||
| 1458 | return true; | ||
| 1459 | } | ||
| 1460 | |||
| 1461 | |||
| 1462 | } //namespace parserlib | ||
diff --git a/MoonParser/parser.hpp b/MoonParser/parser.hpp new file mode 100644 index 0000000..540a51c --- /dev/null +++ b/MoonParser/parser.hpp | |||
| @@ -0,0 +1,428 @@ | |||
| 1 | #ifndef PARSER_HPP | ||
| 2 | #define PARSER_HPP | ||
| 3 | |||
| 4 | |||
| 5 | //gcc chokes without rule::rule(const rule &), | ||
| 6 | //msvc complains when rule::rule(const rule &) is defined. | ||
| 7 | #ifdef _MSC_VER | ||
| 8 | #pragma warning (disable: 4521) | ||
| 9 | #endif | ||
| 10 | |||
| 11 | |||
| 12 | #include <vector> | ||
| 13 | #include <string> | ||
| 14 | #include <list> | ||
| 15 | #include <functional> | ||
| 16 | |||
| 17 | |||
| 18 | namespace parserlib { | ||
| 19 | |||
| 20 | |||
| 21 | class _private; | ||
| 22 | class _expr; | ||
| 23 | class _context; | ||
| 24 | class rule; | ||
| 25 | |||
| 26 | |||
| 27 | ///type of the parser's input. | ||
| 28 | typedef std::vector<int> input; | ||
| 29 | typedef input::iterator input_it; | ||
| 30 | struct item_t | ||
| 31 | { | ||
| 32 | input_it begin; | ||
| 33 | input_it end; | ||
| 34 | void* user_data; | ||
| 35 | }; | ||
| 36 | typedef std::function<bool(const item_t&)> user_handler; | ||
| 37 | |||
| 38 | |||
| 39 | ///position into the input. | ||
| 40 | class pos { | ||
| 41 | public: | ||
| 42 | ///interator into the input. | ||
| 43 | input::iterator m_it; | ||
| 44 | |||
| 45 | ///line. | ||
| 46 | int m_line; | ||
| 47 | |||
| 48 | ///column. | ||
| 49 | int m_col; | ||
| 50 | |||
| 51 | ///null constructor. | ||
| 52 | pos() {} | ||
| 53 | |||
| 54 | /** constructor from input. | ||
| 55 | @param i input. | ||
| 56 | */ | ||
| 57 | pos(input &i); | ||
| 58 | }; | ||
| 59 | |||
| 60 | |||
| 61 | /** a grammar expression. | ||
| 62 | */ | ||
| 63 | class expr { | ||
| 64 | public: | ||
| 65 | /** character terminal constructor. | ||
| 66 | @param c character. | ||
| 67 | */ | ||
| 68 | expr(int c); | ||
| 69 | |||
| 70 | /** null-terminated string terminal constructor. | ||
| 71 | @param s null-terminated string. | ||
| 72 | */ | ||
| 73 | expr(const char *s); | ||
| 74 | |||
| 75 | /** null-terminated wide string terminal constructor. | ||
| 76 | @param s null-terminated string. | ||
| 77 | */ | ||
| 78 | expr(const wchar_t *s); | ||
| 79 | |||
| 80 | /** rule reference constructor. | ||
| 81 | @param r rule. | ||
| 82 | */ | ||
| 83 | expr(rule &r); | ||
| 84 | |||
| 85 | /** creates a zero-or-more loop out of this expression. | ||
| 86 | @return a zero-or-more loop expression. | ||
| 87 | */ | ||
| 88 | expr operator *() const; | ||
| 89 | |||
| 90 | /** creates a one-or-more loop out of this expression. | ||
| 91 | @return a one-or-more loop expression. | ||
| 92 | */ | ||
| 93 | expr operator +() const; | ||
| 94 | |||
| 95 | /** creates an optional out of this expression. | ||
| 96 | @return an optional expression. | ||
| 97 | */ | ||
| 98 | expr operator -() const; | ||
| 99 | |||
| 100 | /** creates an AND-expression. | ||
| 101 | @return an AND-expression. | ||
| 102 | */ | ||
| 103 | expr operator &() const; | ||
| 104 | |||
| 105 | /** creates a NOT-expression. | ||
| 106 | @return a NOT-expression. | ||
| 107 | */ | ||
| 108 | expr operator !() const; | ||
| 109 | |||
| 110 | private: | ||
| 111 | //internal expression | ||
| 112 | _expr *m_expr; | ||
| 113 | |||
| 114 | //internal constructor from internal expression | ||
| 115 | expr(_expr *e) : m_expr(e) {} | ||
| 116 | |||
| 117 | //assignment not allowed | ||
| 118 | expr &operator = (expr &); | ||
| 119 | |||
| 120 | friend class _private; | ||
| 121 | }; | ||
| 122 | |||
| 123 | |||
| 124 | /** type of procedure to invoke when a rule is successfully parsed. | ||
| 125 | @param b begin position of input. | ||
| 126 | @param e end position of input. | ||
| 127 | @param d pointer to user data. | ||
| 128 | */ | ||
| 129 | typedef void (*parse_proc)(const pos &b, const pos &e, void *d); | ||
| 130 | |||
| 131 | |||
| 132 | ///input range. | ||
| 133 | class input_range { | ||
| 134 | public: | ||
| 135 | ///begin position. | ||
| 136 | pos m_begin; | ||
| 137 | |||
| 138 | ///end position. | ||
| 139 | pos m_end; | ||
| 140 | |||
| 141 | ///empty constructor. | ||
| 142 | input_range() {} | ||
| 143 | |||
| 144 | /** constructor. | ||
| 145 | @param b begin position. | ||
| 146 | @param e end position. | ||
| 147 | */ | ||
| 148 | input_range(const pos &b, const pos &e); | ||
| 149 | }; | ||
| 150 | |||
| 151 | |||
| 152 | ///enum with error types. | ||
| 153 | enum ERROR_TYPE { | ||
| 154 | ///syntax error | ||
| 155 | ERROR_SYNTAX_ERROR = 1, | ||
| 156 | |||
| 157 | ///invalid end of file | ||
| 158 | ERROR_INVALID_EOF, | ||
| 159 | |||
| 160 | ///first user error | ||
| 161 | ERROR_USER = 100 | ||
| 162 | }; | ||
| 163 | |||
| 164 | |||
| 165 | ///error. | ||
| 166 | class error : public input_range { | ||
| 167 | public: | ||
| 168 | ///type | ||
| 169 | int m_type; | ||
| 170 | |||
| 171 | /** constructor. | ||
| 172 | @param b begin position. | ||
| 173 | @param e end position. | ||
| 174 | @param t type. | ||
| 175 | */ | ||
| 176 | error(const pos &b, const pos &e, int t); | ||
| 177 | |||
| 178 | /** compare on begin position. | ||
| 179 | @param e the other error to compare this with. | ||
| 180 | @return true if this comes before the previous error, false otherwise. | ||
| 181 | */ | ||
| 182 | bool operator < (const error &e) const; | ||
| 183 | }; | ||
| 184 | |||
| 185 | |||
| 186 | ///type of error list. | ||
| 187 | typedef std::list<error> error_list; | ||
| 188 | |||
| 189 | |||
| 190 | /** represents a rule. | ||
| 191 | */ | ||
| 192 | class rule { | ||
| 193 | public: | ||
| 194 | /** character terminal constructor. | ||
| 195 | @param c character. | ||
| 196 | */ | ||
| 197 | rule(int c); | ||
| 198 | |||
| 199 | /** null-terminated string terminal constructor. | ||
| 200 | @param s null-terminated string. | ||
| 201 | */ | ||
| 202 | rule(const char *s); | ||
| 203 | |||
| 204 | /** null-terminated wide string terminal constructor. | ||
| 205 | @param s null-terminated string. | ||
| 206 | */ | ||
| 207 | rule(const wchar_t *s); | ||
| 208 | |||
| 209 | /** constructor from expression. | ||
| 210 | @param e expression. | ||
| 211 | */ | ||
| 212 | rule(const expr &e); | ||
| 213 | |||
| 214 | /** constructor from rule. | ||
| 215 | @param r rule. | ||
| 216 | */ | ||
| 217 | rule(rule &r); | ||
| 218 | |||
| 219 | /** invalid constructor from rule (required by gcc). | ||
| 220 | @param r rule. | ||
| 221 | @exception std::logic_error always thrown. | ||
| 222 | */ | ||
| 223 | rule(const rule &r); | ||
| 224 | |||
| 225 | /** deletes the internal object that represents the expression. | ||
| 226 | */ | ||
| 227 | ~rule(); | ||
| 228 | |||
| 229 | /** creates a zero-or-more loop out of this rule. | ||
| 230 | @return a zero-or-more loop rule. | ||
| 231 | */ | ||
| 232 | expr operator *(); | ||
| 233 | |||
| 234 | /** creates a one-or-more loop out of this rule. | ||
| 235 | @return a one-or-more loop rule. | ||
| 236 | */ | ||
| 237 | expr operator +(); | ||
| 238 | |||
| 239 | /** creates an optional out of this rule. | ||
| 240 | @return an optional rule. | ||
| 241 | */ | ||
| 242 | expr operator -(); | ||
| 243 | |||
| 244 | /** creates an AND-expression out of this rule. | ||
| 245 | @return an AND-expression out of this rule. | ||
| 246 | */ | ||
| 247 | expr operator &(); | ||
| 248 | |||
| 249 | /** creates a NOT-expression out of this rule. | ||
| 250 | @return a NOT-expression out of this rule. | ||
| 251 | */ | ||
| 252 | expr operator !(); | ||
| 253 | |||
| 254 | /** sets the parse procedure. | ||
| 255 | @param p procedure. | ||
| 256 | */ | ||
| 257 | void set_parse_proc(parse_proc p); | ||
| 258 | |||
| 259 | /** get the this ptr (since operator & is overloaded). | ||
| 260 | @return pointer to this. | ||
| 261 | */ | ||
| 262 | rule *this_ptr() { return this; } | ||
| 263 | |||
| 264 | private: | ||
| 265 | //mode | ||
| 266 | enum _MODE { | ||
| 267 | _PARSE, | ||
| 268 | _REJECT, | ||
| 269 | _ACCEPT | ||
| 270 | }; | ||
| 271 | |||
| 272 | //state | ||
| 273 | struct _state { | ||
| 274 | //position in source code, relative to start | ||
| 275 | size_t m_pos; | ||
| 276 | |||
| 277 | //mode | ||
| 278 | _MODE m_mode; | ||
| 279 | |||
| 280 | //constructor | ||
| 281 | _state(size_t pos = -1, _MODE mode = _PARSE) : | ||
| 282 | m_pos(pos), m_mode(mode) {} | ||
| 283 | }; | ||
| 284 | |||
| 285 | //internal expression | ||
| 286 | _expr *m_expr; | ||
| 287 | |||
| 288 | //associated parse procedure. | ||
| 289 | parse_proc m_parse_proc; | ||
| 290 | |||
| 291 | //state | ||
| 292 | _state m_state; | ||
| 293 | |||
| 294 | //assignment not allowed | ||
| 295 | rule &operator = (rule &); | ||
| 296 | |||
| 297 | friend class _private; | ||
| 298 | friend class _context; | ||
| 299 | }; | ||
| 300 | |||
| 301 | |||
| 302 | /** creates a sequence of expressions. | ||
| 303 | @param left left operand. | ||
| 304 | @param right right operand. | ||
| 305 | @return an expression which parses a sequence. | ||
| 306 | */ | ||
| 307 | expr operator >> (const expr &left, const expr &right); | ||
| 308 | |||
| 309 | |||
| 310 | /** creates a choice of expressions. | ||
| 311 | @param left left operand. | ||
| 312 | @param right right operand. | ||
| 313 | @return an expression which parses a choice. | ||
| 314 | */ | ||
| 315 | expr operator | (const expr &left, const expr &right); | ||
| 316 | |||
| 317 | |||
| 318 | /** converts a parser expression into a terminal. | ||
| 319 | @param e expression. | ||
| 320 | @return an expression which parses a terminal. | ||
| 321 | */ | ||
| 322 | expr term(const expr &e); | ||
| 323 | |||
| 324 | |||
| 325 | /** creates a set expression from a null-terminated string. | ||
| 326 | @param s null-terminated string with characters of the set. | ||
| 327 | @return an expression which parses a single character out of a set. | ||
| 328 | */ | ||
| 329 | expr set(const char *s); | ||
| 330 | |||
| 331 | |||
| 332 | /** creates a set expression from a null-terminated wide string. | ||
| 333 | @param s null-terminated string with characters of the set. | ||
| 334 | @return an expression which parses a single character out of a set. | ||
| 335 | */ | ||
| 336 | expr set(const wchar_t *s); | ||
| 337 | |||
| 338 | |||
| 339 | /** creates a range expression. | ||
| 340 | @param min min character. | ||
| 341 | @param max max character. | ||
| 342 | @return an expression which parses a single character out of range. | ||
| 343 | */ | ||
| 344 | expr range(int min, int max); | ||
| 345 | |||
| 346 | |||
| 347 | /** creates an expression which increments the line counter | ||
| 348 | and resets the column counter when the given expression | ||
| 349 | is parsed successfully; used for newline characters. | ||
| 350 | @param e expression to wrap into a newline parser. | ||
| 351 | @return an expression that handles newlines. | ||
| 352 | */ | ||
| 353 | expr nl(const expr &e); | ||
| 354 | |||
| 355 | |||
| 356 | /** creates an expression which tests for the end of input. | ||
| 357 | @return an expression that handles the end of input. | ||
| 358 | */ | ||
| 359 | expr eof(); | ||
| 360 | |||
| 361 | |||
| 362 | /** creates a not expression. | ||
| 363 | @param e expression. | ||
| 364 | @return the appropriate expression. | ||
| 365 | */ | ||
| 366 | expr not_(const expr &e); | ||
| 367 | |||
| 368 | |||
| 369 | /** creates an and expression. | ||
| 370 | @param e expression. | ||
| 371 | @return the appropriate expression. | ||
| 372 | */ | ||
| 373 | expr and_(const expr &e); | ||
| 374 | |||
| 375 | |||
| 376 | /** creates an expression that parses any character. | ||
| 377 | @return the appropriate expression. | ||
| 378 | */ | ||
| 379 | expr any(); | ||
| 380 | |||
| 381 | |||
| 382 | /** parsing succeeds without consuming any input. | ||
| 383 | */ | ||
| 384 | expr true_(); | ||
| 385 | |||
| 386 | |||
| 387 | /** parsing fails without consuming any input. | ||
| 388 | */ | ||
| 389 | expr false_(); | ||
| 390 | |||
| 391 | |||
| 392 | /** parse with target expression and let user handle result. | ||
| 393 | */ | ||
| 394 | expr user(const expr &e, const user_handler& handler); | ||
| 395 | |||
| 396 | |||
| 397 | /** parses the given input. | ||
| 398 | The parse procedures of each rule parsed are executed | ||
| 399 | before this function returns, if parsing succeeds. | ||
| 400 | @param i input. | ||
| 401 | @param g root rule of grammar. | ||
| 402 | @param el list of errors. | ||
| 403 | @param d user data, passed to the parse procedures. | ||
| 404 | @return true on parsing success, false on failure. | ||
| 405 | */ | ||
| 406 | bool parse(input &i, rule &g, error_list &el, void *d, void* ud); | ||
| 407 | |||
| 408 | |||
| 409 | /** output the specific input range to the specific stream. | ||
| 410 | @param stream stream. | ||
| 411 | @param ir input range. | ||
| 412 | @return the stream. | ||
| 413 | */ | ||
| 414 | template <class T> T &operator << (T &stream, const input_range &ir) { | ||
| 415 | for(input::const_iterator it = ir.m_begin.m_it; | ||
| 416 | it != ir.m_end.m_it; | ||
| 417 | ++it) | ||
| 418 | { | ||
| 419 | stream << (typename T::char_type)*it; | ||
| 420 | } | ||
| 421 | return stream; | ||
| 422 | } | ||
| 423 | |||
| 424 | |||
| 425 | } //namespace parserlib | ||
| 426 | |||
| 427 | |||
| 428 | #endif //PARSER_HPP | ||
diff --git a/MoonParser/parserlib.hpp b/MoonParser/parserlib.hpp new file mode 100644 index 0000000..afbd1f0 --- /dev/null +++ b/MoonParser/parserlib.hpp | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | #ifndef PARSERLIB_HPP | ||
| 2 | #define PARSERLIB_HPP | ||
| 3 | |||
| 4 | |||
| 5 | #include "ast.hpp" | ||
| 6 | |||
| 7 | |||
| 8 | #endif //PARSERLIB_HPP | ||
diff --git a/MoonParser/pegtl.hpp b/MoonParser/pegtl.hpp deleted file mode 100644 index e96cd79..0000000 --- a/MoonParser/pegtl.hpp +++ /dev/null | |||
| @@ -1,31 +0,0 @@ | |||
| 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 deleted file mode 100644 index f063ee1..0000000 --- a/MoonParser/pegtl/analysis/analyze_cycles.hpp +++ /dev/null | |||
| @@ -1,134 +0,0 @@ | |||
| 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 | |||
| 20 | namespace 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 deleted file mode 100644 index 84a12ae..0000000 --- a/MoonParser/pegtl/analysis/counted.hpp +++ /dev/null | |||
| @@ -1,29 +0,0 @@ | |||
| 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 | |||
| 11 | namespace 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 deleted file mode 100644 index 27e0ffe..0000000 --- a/MoonParser/pegtl/analysis/generic.hpp +++ /dev/null | |||
| @@ -1,39 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index 15c96ab..0000000 --- a/MoonParser/pegtl/analysis/grammar_info.hpp +++ /dev/null | |||
| @@ -1,40 +0,0 @@ | |||
| 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 | |||
| 16 | namespace 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 deleted file mode 100644 index 9a4cc35..0000000 --- a/MoonParser/pegtl/analysis/insert_guard.hpp +++ /dev/null | |||
| @@ -1,66 +0,0 @@ | |||
| 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 | |||
| 11 | namespace 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 deleted file mode 100644 index ff55f66..0000000 --- a/MoonParser/pegtl/analysis/insert_rules.hpp +++ /dev/null | |||
| @@ -1,45 +0,0 @@ | |||
| 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 | |||
| 12 | namespace 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 deleted file mode 100644 index 22910ec..0000000 --- a/MoonParser/pegtl/analysis/rule_info.hpp +++ /dev/null | |||
| @@ -1,37 +0,0 @@ | |||
| 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 | |||
| 14 | namespace 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 deleted file mode 100644 index fc5d4c8..0000000 --- a/MoonParser/pegtl/analysis/rule_type.hpp +++ /dev/null | |||
| @@ -1,29 +0,0 @@ | |||
| 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 | |||
| 9 | namespace 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 deleted file mode 100644 index 5468a14..0000000 --- a/MoonParser/pegtl/analyze.hpp +++ /dev/null | |||
| @@ -1,25 +0,0 @@ | |||
| 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 | |||
| 11 | namespace 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 deleted file mode 100644 index 93a701b..0000000 --- a/MoonParser/pegtl/apply_mode.hpp +++ /dev/null | |||
| @@ -1,23 +0,0 @@ | |||
| 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 | |||
| 9 | namespace 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 deleted file mode 100644 index 3846975..0000000 --- a/MoonParser/pegtl/argv_input.hpp +++ /dev/null | |||
| @@ -1,52 +0,0 @@ | |||
| 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 | |||
| 17 | namespace 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 deleted file mode 100644 index 9158061..0000000 --- a/MoonParser/pegtl/ascii.hpp +++ /dev/null | |||
| @@ -1,67 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index b65e365..0000000 --- a/MoonParser/pegtl/buffer_input.hpp +++ /dev/null | |||
| @@ -1,179 +0,0 @@ | |||
| 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 | |||
| 23 | namespace 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 deleted file mode 100644 index e93f74a..0000000 --- a/MoonParser/pegtl/config.hpp +++ /dev/null | |||
| @@ -1,15 +0,0 @@ | |||
| 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 deleted file mode 100644 index 15319f5..0000000 --- a/MoonParser/pegtl/contrib/abnf.hpp +++ /dev/null | |||
| @@ -1,43 +0,0 @@ | |||
| 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 | |||
| 10 | namespace 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 deleted file mode 100644 index c0dce42..0000000 --- a/MoonParser/pegtl/contrib/alphabet.hpp +++ /dev/null | |||
| @@ -1,75 +0,0 @@ | |||
| 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 | |||
| 9 | namespace 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 deleted file mode 100644 index 7b9f8dc..0000000 --- a/MoonParser/pegtl/contrib/changes.hpp +++ /dev/null | |||
| @@ -1,86 +0,0 @@ | |||
| 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 | |||
| 12 | namespace 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 deleted file mode 100644 index 52beb3b..0000000 --- a/MoonParser/pegtl/contrib/counter.hpp +++ /dev/null | |||
| @@ -1,58 +0,0 @@ | |||
| 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 | |||
| 15 | namespace 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 deleted file mode 100644 index 1446449..0000000 --- a/MoonParser/pegtl/contrib/http.hpp +++ /dev/null | |||
| @@ -1,152 +0,0 @@ | |||
| 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 | |||
| 14 | namespace 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 deleted file mode 100644 index 688f607..0000000 --- a/MoonParser/pegtl/contrib/json.hpp +++ /dev/null | |||
| @@ -1,98 +0,0 @@ | |||
| 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 | |||
| 14 | namespace 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 deleted file mode 100644 index 592ce5b..0000000 --- a/MoonParser/pegtl/contrib/raw_string.hpp +++ /dev/null | |||
| @@ -1,252 +0,0 @@ | |||
| 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 | |||
| 20 | namespace 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 deleted file mode 100644 index 28fdbcd..0000000 --- a/MoonParser/pegtl/contrib/rep_one_min_max.hpp +++ /dev/null | |||
| @@ -1,72 +0,0 @@ | |||
| 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 | |||
| 16 | namespace 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 deleted file mode 100644 index 4c19931..0000000 --- a/MoonParser/pegtl/contrib/to_string.hpp +++ /dev/null | |||
| @@ -1,42 +0,0 @@ | |||
| 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 | |||
| 11 | namespace 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 deleted file mode 100644 index 5649078..0000000 --- a/MoonParser/pegtl/contrib/tracer.hpp +++ /dev/null | |||
| @@ -1,111 +0,0 @@ | |||
| 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 | |||
| 18 | namespace 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 deleted file mode 100644 index 2a7c53f..0000000 --- a/MoonParser/pegtl/contrib/unescape.hpp +++ /dev/null | |||
| @@ -1,203 +0,0 @@ | |||
| 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 | |||
| 14 | namespace 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 deleted file mode 100644 index 1401a7d..0000000 --- a/MoonParser/pegtl/contrib/uri.hpp +++ /dev/null | |||
| @@ -1,116 +0,0 @@ | |||
| 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 | |||
| 14 | namespace 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 deleted file mode 100644 index ad520e3..0000000 --- a/MoonParser/pegtl/cstream_input.hpp +++ /dev/null | |||
| @@ -1,34 +0,0 @@ | |||
| 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 | |||
| 15 | namespace 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 deleted file mode 100644 index ca3e604..0000000 --- a/MoonParser/pegtl/eol.hpp +++ /dev/null | |||
| @@ -1,54 +0,0 @@ | |||
| 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 | |||
| 12 | namespace 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 | |||
| 30 | namespace 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 deleted file mode 100644 index 625d491..0000000 --- a/MoonParser/pegtl/file_input.hpp +++ /dev/null | |||
| @@ -1,37 +0,0 @@ | |||
| 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 | |||
| 21 | namespace 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 deleted file mode 100644 index 605ce4d..0000000 --- a/MoonParser/pegtl/input_error.hpp +++ /dev/null | |||
| @@ -1,41 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index 933bffe..0000000 --- a/MoonParser/pegtl/internal/action.hpp +++ /dev/null | |||
| @@ -1,52 +0,0 @@ | |||
| 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 | |||
| 18 | namespace 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 deleted file mode 100644 index db48950..0000000 --- a/MoonParser/pegtl/internal/action_input.hpp +++ /dev/null | |||
| @@ -1,108 +0,0 @@ | |||
| 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 | |||
| 15 | namespace 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 deleted file mode 100644 index cdad330..0000000 --- a/MoonParser/pegtl/internal/alnum.hpp +++ /dev/null | |||
| @@ -1,26 +0,0 @@ | |||
| 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 | |||
| 12 | namespace 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 deleted file mode 100644 index d696ca2..0000000 --- a/MoonParser/pegtl/internal/alpha.hpp +++ /dev/null | |||
| @@ -1,26 +0,0 @@ | |||
| 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 | |||
| 12 | namespace 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 deleted file mode 100644 index aebe239..0000000 --- a/MoonParser/pegtl/internal/any.hpp +++ /dev/null | |||
| @@ -1,68 +0,0 @@ | |||
| 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 | |||
| 14 | namespace 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 deleted file mode 100644 index 4e70255..0000000 --- a/MoonParser/pegtl/internal/apply.hpp +++ /dev/null | |||
| @@ -1,79 +0,0 @@ | |||
| 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 | |||
| 14 | namespace 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 deleted file mode 100644 index c8aa7aa..0000000 --- a/MoonParser/pegtl/internal/apply0.hpp +++ /dev/null | |||
| @@ -1,77 +0,0 @@ | |||
| 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 | |||
| 14 | namespace 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 deleted file mode 100644 index d5bb455..0000000 --- a/MoonParser/pegtl/internal/at.hpp +++ /dev/null | |||
| @@ -1,62 +0,0 @@ | |||
| 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 | |||
| 18 | namespace 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 deleted file mode 100644 index 8a1dde7..0000000 --- a/MoonParser/pegtl/internal/bof.hpp +++ /dev/null | |||
| @@ -1,41 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index bf3e33f..0000000 --- a/MoonParser/pegtl/internal/bol.hpp +++ /dev/null | |||
| @@ -1,41 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index 577870e..0000000 --- a/MoonParser/pegtl/internal/bump_help.hpp +++ /dev/null | |||
| @@ -1,64 +0,0 @@ | |||
| 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 | |||
| 14 | namespace 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 deleted file mode 100644 index 6ab9005..0000000 --- a/MoonParser/pegtl/internal/bump_impl.hpp +++ /dev/null | |||
| @@ -1,53 +0,0 @@ | |||
| 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 | |||
| 11 | namespace 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 deleted file mode 100644 index c180a68..0000000 --- a/MoonParser/pegtl/internal/bytes.hpp +++ /dev/null | |||
| @@ -1,46 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index 16fab5c..0000000 --- a/MoonParser/pegtl/internal/control.hpp +++ /dev/null | |||
| @@ -1,52 +0,0 @@ | |||
| 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 | |||
| 18 | namespace 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 deleted file mode 100644 index ebfc75d..0000000 --- a/MoonParser/pegtl/internal/cr_crlf_eol.hpp +++ /dev/null | |||
| @@ -1,39 +0,0 @@ | |||
| 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 | |||
| 9 | namespace 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 deleted file mode 100644 index 79388eb..0000000 --- a/MoonParser/pegtl/internal/cr_eol.hpp +++ /dev/null | |||
| @@ -1,39 +0,0 @@ | |||
| 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 | |||
| 9 | namespace 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 deleted file mode 100644 index 621b6b3..0000000 --- a/MoonParser/pegtl/internal/crlf_eol.hpp +++ /dev/null | |||
| @@ -1,39 +0,0 @@ | |||
| 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 | |||
| 9 | namespace 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 deleted file mode 100644 index c1670bf..0000000 --- a/MoonParser/pegtl/internal/cstream_reader.hpp +++ /dev/null | |||
| @@ -1,48 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index ff8c11e..0000000 --- a/MoonParser/pegtl/internal/cstring_reader.hpp +++ /dev/null | |||
| @@ -1,49 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index 64efe6f..0000000 --- a/MoonParser/pegtl/internal/demangle.hpp +++ /dev/null | |||
| @@ -1,44 +0,0 @@ | |||
| 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 | |||
| 26 | namespace 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 deleted file mode 100644 index aba72f9..0000000 --- a/MoonParser/pegtl/internal/demangle_cxxabi.hpp +++ /dev/null | |||
| @@ -1,41 +0,0 @@ | |||
| 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 | |||
| 16 | namespace 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 deleted file mode 100644 index 70bf3ec..0000000 --- a/MoonParser/pegtl/internal/demangle_nop.hpp +++ /dev/null | |||
| @@ -1,28 +0,0 @@ | |||
| 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 | |||
| 11 | namespace 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 deleted file mode 100644 index f869ea6..0000000 --- a/MoonParser/pegtl/internal/demangle_sanitise.hpp +++ /dev/null | |||
| @@ -1,48 +0,0 @@ | |||
| 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 | |||
| 11 | namespace 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 deleted file mode 100644 index 19ccb1e..0000000 --- a/MoonParser/pegtl/internal/disable.hpp +++ /dev/null | |||
| @@ -1,52 +0,0 @@ | |||
| 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 | |||
| 18 | namespace 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 deleted file mode 100644 index 9aac60f..0000000 --- a/MoonParser/pegtl/internal/discard.hpp +++ /dev/null | |||
| @@ -1,42 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index df757aa..0000000 --- a/MoonParser/pegtl/internal/dusel_mode.hpp +++ /dev/null | |||
| @@ -1,25 +0,0 @@ | |||
| 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 | |||
| 9 | namespace 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 deleted file mode 100644 index 23a6e1f..0000000 --- a/MoonParser/pegtl/internal/duseltronik.hpp +++ /dev/null | |||
| @@ -1,114 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index c01268c..0000000 --- a/MoonParser/pegtl/internal/enable.hpp +++ /dev/null | |||
| @@ -1,52 +0,0 @@ | |||
| 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 | |||
| 18 | namespace 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 deleted file mode 100644 index a702fa6..0000000 --- a/MoonParser/pegtl/internal/eof.hpp +++ /dev/null | |||
| @@ -1,41 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index bfd43c2..0000000 --- a/MoonParser/pegtl/internal/eol.hpp +++ /dev/null | |||
| @@ -1,42 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index 168311c..0000000 --- a/MoonParser/pegtl/internal/eolf.hpp +++ /dev/null | |||
| @@ -1,43 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index 800b9df..0000000 --- a/MoonParser/pegtl/internal/file_mapper.hpp +++ /dev/null | |||
| @@ -1,91 +0,0 @@ | |||
| 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 | |||
| 16 | namespace 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 deleted file mode 100644 index 0b1ad6d..0000000 --- a/MoonParser/pegtl/internal/file_opener.hpp +++ /dev/null | |||
| @@ -1,70 +0,0 @@ | |||
| 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 | |||
| 17 | namespace 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 deleted file mode 100644 index 9bcdf97..0000000 --- a/MoonParser/pegtl/internal/file_reader.hpp +++ /dev/null | |||
| @@ -1,96 +0,0 @@ | |||
| 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 | |||
| 15 | namespace 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 deleted file mode 100644 index 01ef7f9..0000000 --- a/MoonParser/pegtl/internal/has_apply0.hpp +++ /dev/null | |||
| @@ -1,38 +0,0 @@ | |||
| 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 | |||
| 11 | namespace 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 deleted file mode 100644 index 1ee4571..0000000 --- a/MoonParser/pegtl/internal/identifier.hpp +++ /dev/null | |||
| @@ -1,30 +0,0 @@ | |||
| 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 | |||
| 14 | namespace 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 deleted file mode 100644 index 1e6bb99..0000000 --- a/MoonParser/pegtl/internal/if_apply.hpp +++ /dev/null | |||
| @@ -1,90 +0,0 @@ | |||
| 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 | |||
| 11 | namespace 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 deleted file mode 100644 index 2a56d7e..0000000 --- a/MoonParser/pegtl/internal/if_must.hpp +++ /dev/null | |||
| @@ -1,27 +0,0 @@ | |||
| 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 | |||
| 12 | namespace 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 deleted file mode 100644 index 2ccb205..0000000 --- a/MoonParser/pegtl/internal/if_must_else.hpp +++ /dev/null | |||
| @@ -1,27 +0,0 @@ | |||
| 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 | |||
| 12 | namespace 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 deleted file mode 100644 index e55831f..0000000 --- a/MoonParser/pegtl/internal/if_then_else.hpp +++ /dev/null | |||
| @@ -1,59 +0,0 @@ | |||
| 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 | |||
| 19 | namespace 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 deleted file mode 100644 index de4e6ba..0000000 --- a/MoonParser/pegtl/internal/input_pair.hpp +++ /dev/null | |||
| @@ -1,35 +0,0 @@ | |||
| 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 | |||
| 9 | namespace 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 deleted file mode 100644 index cdcf20d..0000000 --- a/MoonParser/pegtl/internal/integer_sequence.hpp +++ /dev/null | |||
| @@ -1,85 +0,0 @@ | |||
| 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 | |||
| 11 | namespace 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 deleted file mode 100644 index 8509080..0000000 --- a/MoonParser/pegtl/internal/istream_reader.hpp +++ /dev/null | |||
| @@ -1,47 +0,0 @@ | |||
| 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 | |||
| 12 | namespace 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 deleted file mode 100644 index 3ed2835..0000000 --- a/MoonParser/pegtl/internal/istring.hpp +++ /dev/null | |||
| @@ -1,107 +0,0 @@ | |||
| 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 | |||
| 18 | namespace 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 deleted file mode 100644 index 4179738..0000000 --- a/MoonParser/pegtl/internal/iterator.hpp +++ /dev/null | |||
| @@ -1,53 +0,0 @@ | |||
| 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 | |||
| 11 | namespace 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 deleted file mode 100644 index 90b5b03..0000000 --- a/MoonParser/pegtl/internal/lf_crlf_eol.hpp +++ /dev/null | |||
| @@ -1,44 +0,0 @@ | |||
| 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 | |||
| 9 | namespace 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 deleted file mode 100644 index 438b8f0..0000000 --- a/MoonParser/pegtl/internal/lf_eol.hpp +++ /dev/null | |||
| @@ -1,39 +0,0 @@ | |||
| 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 | |||
| 9 | namespace 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 deleted file mode 100644 index 1a812fb..0000000 --- a/MoonParser/pegtl/internal/list.hpp +++ /dev/null | |||
| @@ -1,27 +0,0 @@ | |||
| 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 | |||
| 12 | namespace 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 deleted file mode 100644 index 9b60311..0000000 --- a/MoonParser/pegtl/internal/list_must.hpp +++ /dev/null | |||
| @@ -1,28 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index dd7b920..0000000 --- a/MoonParser/pegtl/internal/list_tail.hpp +++ /dev/null | |||
| @@ -1,28 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index 0f3ebf6..0000000 --- a/MoonParser/pegtl/internal/list_tail_pad.hpp +++ /dev/null | |||
| @@ -1,30 +0,0 @@ | |||
| 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 | |||
| 15 | namespace 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 deleted file mode 100644 index 76cba0e..0000000 --- a/MoonParser/pegtl/internal/marker.hpp +++ /dev/null | |||
| @@ -1,93 +0,0 @@ | |||
| 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 | |||
| 10 | namespace 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 deleted file mode 100644 index 88242e5..0000000 --- a/MoonParser/pegtl/internal/minus.hpp +++ /dev/null | |||
| @@ -1,69 +0,0 @@ | |||
| 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 | |||
| 15 | namespace 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 deleted file mode 100644 index 4ac9920..0000000 --- a/MoonParser/pegtl/internal/must.hpp +++ /dev/null | |||
| @@ -1,79 +0,0 @@ | |||
| 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 | |||
| 18 | namespace 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 deleted file mode 100644 index ed80c56..0000000 --- a/MoonParser/pegtl/internal/not_at.hpp +++ /dev/null | |||
| @@ -1,62 +0,0 @@ | |||
| 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 | |||
| 18 | namespace 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 deleted file mode 100644 index a3941eb..0000000 --- a/MoonParser/pegtl/internal/one.hpp +++ /dev/null | |||
| @@ -1,81 +0,0 @@ | |||
| 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 | |||
| 18 | namespace 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 deleted file mode 100644 index a897443..0000000 --- a/MoonParser/pegtl/internal/opt.hpp +++ /dev/null | |||
| @@ -1,67 +0,0 @@ | |||
| 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 | |||
| 21 | namespace 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 deleted file mode 100644 index fcb6e4f..0000000 --- a/MoonParser/pegtl/internal/pad.hpp +++ /dev/null | |||
| @@ -1,27 +0,0 @@ | |||
| 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 | |||
| 12 | namespace 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 deleted file mode 100644 index 4b7d400..0000000 --- a/MoonParser/pegtl/internal/pad_opt.hpp +++ /dev/null | |||
| @@ -1,28 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index 064e6da..0000000 --- a/MoonParser/pegtl/internal/peek_char.hpp +++ /dev/null | |||
| @@ -1,35 +0,0 @@ | |||
| 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 | |||
| 11 | namespace 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 deleted file mode 100644 index a643b1f..0000000 --- a/MoonParser/pegtl/internal/peek_utf16.hpp +++ /dev/null | |||
| @@ -1,54 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index f082064..0000000 --- a/MoonParser/pegtl/internal/peek_utf32.hpp +++ /dev/null | |||
| @@ -1,46 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index 9ea0a0e..0000000 --- a/MoonParser/pegtl/internal/peek_utf8.hpp +++ /dev/null | |||
| @@ -1,88 +0,0 @@ | |||
| 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 | |||
| 11 | namespace 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 deleted file mode 100644 index 7c27fd8..0000000 --- a/MoonParser/pegtl/internal/pegtl_string.hpp +++ /dev/null | |||
| @@ -1,98 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index 5adc1f8..0000000 --- a/MoonParser/pegtl/internal/plus.hpp +++ /dev/null | |||
| @@ -1,61 +0,0 @@ | |||
| 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 | |||
| 22 | namespace 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 deleted file mode 100644 index d183ce0..0000000 --- a/MoonParser/pegtl/internal/raise.hpp +++ /dev/null | |||
| @@ -1,57 +0,0 @@ | |||
| 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 | |||
| 18 | namespace 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 deleted file mode 100644 index 227595f..0000000 --- a/MoonParser/pegtl/internal/range.hpp +++ /dev/null | |||
| @@ -1,60 +0,0 @@ | |||
| 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 | |||
| 15 | namespace 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 deleted file mode 100644 index e3ee65c..0000000 --- a/MoonParser/pegtl/internal/ranges.hpp +++ /dev/null | |||
| @@ -1,102 +0,0 @@ | |||
| 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 | |||
| 15 | namespace 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 deleted file mode 100644 index df66ee2..0000000 --- a/MoonParser/pegtl/internal/rep.hpp +++ /dev/null | |||
| @@ -1,75 +0,0 @@ | |||
| 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 | |||
| 18 | namespace 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 deleted file mode 100644 index f5e61da..0000000 --- a/MoonParser/pegtl/internal/rep_min.hpp +++ /dev/null | |||
| @@ -1,28 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index 7463398..0000000 --- a/MoonParser/pegtl/internal/rep_min_max.hpp +++ /dev/null | |||
| @@ -1,88 +0,0 @@ | |||
| 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 | |||
| 23 | namespace 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 deleted file mode 100644 index 55bcd47..0000000 --- a/MoonParser/pegtl/internal/rep_opt.hpp +++ /dev/null | |||
| @@ -1,54 +0,0 @@ | |||
| 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 | |||
| 18 | namespace 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 deleted file mode 100644 index 0506356..0000000 --- a/MoonParser/pegtl/internal/require.hpp +++ /dev/null | |||
| @@ -1,52 +0,0 @@ | |||
| 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 | |||
| 14 | namespace 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 deleted file mode 100644 index e41f35c..0000000 --- a/MoonParser/pegtl/internal/result_on_found.hpp +++ /dev/null | |||
| @@ -1,27 +0,0 @@ | |||
| 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 | |||
| 9 | namespace 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 deleted file mode 100644 index 2eb41e2..0000000 --- a/MoonParser/pegtl/internal/rule_conjunction.hpp +++ /dev/null | |||
| @@ -1,63 +0,0 @@ | |||
| 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 | |||
| 11 | namespace 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 deleted file mode 100644 index 91725ae..0000000 --- a/MoonParser/pegtl/internal/rules.hpp +++ /dev/null | |||
| @@ -1,61 +0,0 @@ | |||
| 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 deleted file mode 100644 index f99cc7c..0000000 --- a/MoonParser/pegtl/internal/seq.hpp +++ /dev/null | |||
| @@ -1,80 +0,0 @@ | |||
| 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 | |||
| 18 | namespace 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 deleted file mode 100644 index e40ace5..0000000 --- a/MoonParser/pegtl/internal/skip_control.hpp +++ /dev/null | |||
| @@ -1,35 +0,0 @@ | |||
| 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 | |||
| 11 | namespace 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 deleted file mode 100644 index 6d85a5c..0000000 --- a/MoonParser/pegtl/internal/sor.hpp +++ /dev/null | |||
| @@ -1,74 +0,0 @@ | |||
| 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 | |||
| 18 | namespace 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 deleted file mode 100644 index 854f25f..0000000 --- a/MoonParser/pegtl/internal/star.hpp +++ /dev/null | |||
| @@ -1,56 +0,0 @@ | |||
| 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 | |||
| 20 | namespace 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 deleted file mode 100644 index baaef4f..0000000 --- a/MoonParser/pegtl/internal/star_must.hpp +++ /dev/null | |||
| @@ -1,27 +0,0 @@ | |||
| 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 | |||
| 12 | namespace 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 deleted file mode 100644 index 7fbe921..0000000 --- a/MoonParser/pegtl/internal/state.hpp +++ /dev/null | |||
| @@ -1,83 +0,0 @@ | |||
| 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 | |||
| 18 | namespace 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 deleted file mode 100644 index 75245e3..0000000 --- a/MoonParser/pegtl/internal/string.hpp +++ /dev/null | |||
| @@ -1,68 +0,0 @@ | |||
| 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 | |||
| 19 | namespace 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 deleted file mode 100644 index 3416175..0000000 --- a/MoonParser/pegtl/internal/trivial.hpp +++ /dev/null | |||
| @@ -1,42 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index 83fddb4..0000000 --- a/MoonParser/pegtl/internal/try_catch_type.hpp +++ /dev/null | |||
| @@ -1,72 +0,0 @@ | |||
| 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 | |||
| 21 | namespace 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 deleted file mode 100644 index 6a564a4..0000000 --- a/MoonParser/pegtl/internal/until.hpp +++ /dev/null | |||
| @@ -1,91 +0,0 @@ | |||
| 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 | |||
| 21 | namespace 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 deleted file mode 100644 index b0232f9..0000000 --- a/MoonParser/pegtl/istream_input.hpp +++ /dev/null | |||
| @@ -1,34 +0,0 @@ | |||
| 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 | |||
| 15 | namespace 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 deleted file mode 100644 index 2d7fa42..0000000 --- a/MoonParser/pegtl/memory_input.hpp +++ /dev/null | |||
| @@ -1,285 +0,0 @@ | |||
| 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 | |||
| 23 | namespace 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 deleted file mode 100644 index 0a112ef..0000000 --- a/MoonParser/pegtl/mmap_input.hpp +++ /dev/null | |||
| @@ -1,55 +0,0 @@ | |||
| 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 | |||
| 17 | namespace 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 deleted file mode 100644 index d5752d1..0000000 --- a/MoonParser/pegtl/normal.hpp +++ /dev/null | |||
| @@ -1,81 +0,0 @@ | |||
| 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 | |||
| 19 | namespace 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 deleted file mode 100644 index 9b121a2..0000000 --- a/MoonParser/pegtl/nothing.hpp +++ /dev/null | |||
| @@ -1,27 +0,0 @@ | |||
| 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 | |||
| 11 | namespace 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 deleted file mode 100644 index c478cfa..0000000 --- a/MoonParser/pegtl/parse.hpp +++ /dev/null | |||
| @@ -1,53 +0,0 @@ | |||
| 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 | |||
| 14 | namespace 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 deleted file mode 100644 index e015efb..0000000 --- a/MoonParser/pegtl/parse_error.hpp +++ /dev/null | |||
| @@ -1,45 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index c25225c..0000000 --- a/MoonParser/pegtl/position.hpp +++ /dev/null | |||
| @@ -1,54 +0,0 @@ | |||
| 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 | |||
| 17 | namespace 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 deleted file mode 100644 index 9ebfaca..0000000 --- a/MoonParser/pegtl/read_input.hpp +++ /dev/null | |||
| @@ -1,52 +0,0 @@ | |||
| 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 | |||
| 16 | namespace 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 deleted file mode 100644 index f78edb9..0000000 --- a/MoonParser/pegtl/rewind_mode.hpp +++ /dev/null | |||
| @@ -1,24 +0,0 @@ | |||
| 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 | |||
| 9 | namespace 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 deleted file mode 100644 index e1c50b2..0000000 --- a/MoonParser/pegtl/rules.hpp +++ /dev/null | |||
| @@ -1,69 +0,0 @@ | |||
| 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 | |||
| 12 | namespace 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 deleted file mode 100644 index a1c1f98..0000000 --- a/MoonParser/pegtl/string_input.hpp +++ /dev/null | |||
| @@ -1,51 +0,0 @@ | |||
| 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 | |||
| 15 | namespace 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 deleted file mode 100644 index 7ed945b..0000000 --- a/MoonParser/pegtl/tracking_mode.hpp +++ /dev/null | |||
| @@ -1,23 +0,0 @@ | |||
| 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 | |||
| 9 | namespace 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 deleted file mode 100644 index faa7180..0000000 --- a/MoonParser/pegtl/utf16.hpp +++ /dev/null | |||
| @@ -1,35 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index 848137b..0000000 --- a/MoonParser/pegtl/utf32.hpp +++ /dev/null | |||
| @@ -1,35 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index 9ec046e..0000000 --- a/MoonParser/pegtl/utf8.hpp +++ /dev/null | |||
| @@ -1,35 +0,0 @@ | |||
| 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 | |||
| 13 | namespace 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 deleted file mode 100644 index 867d5e4..0000000 --- a/MoonParser/pegtl/version.hpp +++ /dev/null | |||
| @@ -1,13 +0,0 @@ | |||
| 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 deleted file mode 100644 index 7caddbc..0000000 --- a/MoonParser/slice.cpp +++ /dev/null | |||
| @@ -1,119 +0,0 @@ | |||
| 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 | |||
| 26 | namespace silly { | ||
| 27 | |||
| 28 | namespace slice { | ||
| 29 | |||
| 30 | const std::string Slice::Empty; | ||
| 31 | |||
| 32 | int 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 | |||
| 50 | std::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 | |||
| 60 | std::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 | |||
| 69 | std::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 | |||
| 77 | std::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 | |||
| 85 | std::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 | |||
| 94 | std::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 | |||
| 109 | float Slice::stof(const Slice& str) { | ||
| 110 | return static_cast<float>(std::atof(str.toString().c_str())); | ||
| 111 | } | ||
| 112 | |||
| 113 | int 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 deleted file mode 100644 index 60e0ae1..0000000 --- a/MoonParser/slice.h +++ /dev/null | |||
| @@ -1,157 +0,0 @@ | |||
| 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 | |||
| 30 | namespace silly { | ||
| 31 | |||
| 32 | namespace slice { | ||
| 33 | // A Slice object wraps a "const char *" or a "const std::string&" but | ||
| 34 | // without copying their contents. | ||
| 35 | class 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 | |||
| 134 | inline Slice trimSpace(const Slice &s) { | ||
| 135 | Slice tmp = s; | ||
| 136 | return tmp.trimSpace(); | ||
| 137 | } | ||
| 138 | |||
| 139 | inline bool operator==(const Slice &lhs, const Slice &rhs) { | ||
| 140 | return lhs.compare(rhs) == 0; | ||
| 141 | } | ||
| 142 | |||
| 143 | inline bool operator!=(const Slice &lhs, const Slice &rhs) { | ||
| 144 | return !(lhs == rhs); | ||
| 145 | } | ||
| 146 | |||
| 147 | inline std::string operator+(const std::string& lhs, const Slice &rhs) { | ||
| 148 | return lhs + rhs.toString(); | ||
| 149 | } | ||
| 150 | |||
| 151 | constexpr 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 | ||
