summaryrefslogtreecommitdiff
path: root/src/lib/eolian_cxx/grammar/indentation.hpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib/eolian_cxx/grammar/indentation.hpp35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/lib/eolian_cxx/grammar/indentation.hpp b/src/lib/eolian_cxx/grammar/indentation.hpp
index 897be03c3b..347974fa01 100644
--- a/src/lib/eolian_cxx/grammar/indentation.hpp
+++ b/src/lib/eolian_cxx/grammar/indentation.hpp
@@ -8,22 +8,36 @@ namespace efl { namespace eolian { namespace grammar {
8 8
9struct scope_tab_generator 9struct scope_tab_generator
10{ 10{
11 scope_tab_generator(int n) 11 constexpr scope_tab_generator(int n, int m = 4)
12 : n(n) {} 12 : n(n)
13 13 , m(m)
14 {}
15 constexpr scope_tab_generator(scope_tab_generator const&) = default;
16 scope_tab_generator& operator=(scope_tab_generator const&) = default;
17
14 template <typename OutputIterator, typename Context> 18 template <typename OutputIterator, typename Context>
15 bool generate(OutputIterator sink, attributes::unused_type, Context const&) const 19 bool generate(OutputIterator sink, attributes::unused_type, Context const&) const
16 { 20 {
17 for(int i = 0; i != n; ++i) 21 for(int i = 0; i != n; ++i)
18 { 22 {
19 *sink++ = ' '; 23 for(int j = 0; j != m; ++j)
20 *sink++ = ' '; 24 *sink++ = ' ';
21 *sink++ = ' ';
22 } 25 }
23 return true; 26 return true;
24 } 27 }
25 28
29 constexpr scope_tab_generator inc(int nplus = 1) const
30 {
31 return {n+nplus, m};
32 }
33
34 constexpr scope_tab_generator dec(int nminus = 1) const
35 {
36 return {n-nminus, m};
37 }
38
26 int n; 39 int n;
40 int m;
27}; 41};
28 42
29template <> 43template <>
@@ -33,9 +47,14 @@ struct is_generator<scope_tab_generator> : std::true_type {};
33 47
34struct scope_tab_terminal 48struct scope_tab_terminal
35{ 49{
36 scope_tab_generator operator()(int n) const 50 scope_tab_generator operator()(int n, int m = 4) const
51 {
52 return {n, m};
53 }
54
55 operator scope_tab_generator() const
37 { 56 {
38 return scope_tab_generator(n); 57 return {1};
39 } 58 }
40} const scope_tab = {}; 59} const scope_tab = {};
41 60