-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmyparser_common.hpp
93 lines (74 loc) · 1.98 KB
/
myparser_common.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#pragma once
// option list
#if !defined(MYPARSER_CUSTOMIZED)
#define MYPARSER_AST_CCC
#if defined(__GNUC__) || defined(__clang__)
#define MYPARSER_FORCE_INLINE
#endif
#define MYPARSER_STD_REGEX
#endif
// library
#include <limits>
#include <string>
#include <vector>
#include <iostream>
#include <sstream>
#include <fstream>
#if defined(MYPARSER_BOOST_REGEX)
#include <boost/regex.hpp>
namespace regex_lib = boost;
#elif defined(MYPARSER_BOOST_XPRESSIVE)
#include <boost/xpressive/xpressive_dynamic.hpp>
namespace regex_lib = boost::xpressive;
#elif defined(MYPARSER_STD_REGEX)
#include <regex>
namespace regex_lib = std;
#else
// Error!
#endif
#if defined(MYPARSER_AST_CCC)
#include "lib/ccc.hpp"
#endif
#if defined(MYPARSER_FORCE_INLINE)
#define MYPARSER_INLINE __attribute__((__always_inline__)) inline
#else
#define MYPARSER_INLINE inline
#endif
namespace myparser {
#if defined(MYPARSER_DEBUG)
template <class T>
inline void mpDebug(T value) {
std::cerr << value << std::endl;
}
#else
template <class T>
inline void mpDebug(T) {}
#endif
#if defined(MYPARSER_AST_CCC)
const auto style_normal = ccc::d_all;
const auto style_underline = ccc::s_underline_single;
const auto style_error = ccc::cf_red + ccc::s_bold;
const auto style_space = ccc::s_faint;
const auto style_keyword = ccc::cf_blue + ccc::s_bold;
const auto style_data = ccc::cf_magenta + ccc::s_bold;
const auto style_string = ccc::cf_yellow + ccc::s_bold;
#else
const auto style_normal = "";
const auto style_underline = "";
const auto style_error = "";
const auto style_space = "";
const auto style_keyword = "";
const auto style_data = "";
const auto style_string = "";
#endif
enum {
PASS_REPR,
PASS_HIGHLIGHT,
PASS_MESSAGE, // TODO // input [(list, message), ...] output [lineno:pos message]
PASS_USER,
PASS_FIN = 64
};
// forward declaration
template <size_t>
class Pass;
}