Awali
Another Weighted Automata library
info.hxx
Go to the documentation of this file.
1 // This file is part of Awali.
2 // Copyright 2016-2022 Sylvain Lombardy, Victor Marsault, Jacques Sakarovitch
3 //
4 // Awali is a free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef AWALI_CORE_RAT_INFO_HXX
18 # define AWALI_CORE_RAT_INFO_HXX
19 
20 namespace awali { namespace sttc
21 {
22  namespace rat
23  {
24 
25 # define DEFINE \
26  template <typename RatExpSet> \
27  inline \
28  auto \
29  info<RatExpSet>
30 
31  DEFINE::operator()(const node_t& v)
32  -> void
33  {
34  atom = 0;
35  complement = 0;
36  conjunction = 0;
37  lweight = 0;
38  ldiv = 0;
39  one = 0;
40  prod = 0;
41  rweight = 0;
42  shuffle = 0;
43  star = 0;
44  sum = 0;
45  transposition = 0;
46  zero = 0;
47  v.accept(*this);
48  }
49 
50 # define VISIT(Type) \
51  DEFINE::visit(const Type ## _t& v) \
52  -> void
53 
54  VISIT(sum)
55  {
56  ++sum;
57  for (const auto& c: v)
58  c->accept(*this);
59  }
60 
61  VISIT(prod)
62  {
63  ++prod;
64  for (const auto& c: v)
65  c->accept(*this);
66  }
67 
69  {
70  ++conjunction;
71  for (const auto& c: v)
72  c->accept(*this);
73  }
74 
75  VISIT(shuffle)
76  {
77  ++shuffle;
78  for (const auto& c: v)
79  c->accept(*this);
80  }
81 
82 
83  VISIT(ldiv)
84  {
85  ++ldiv;
86  for (const auto& c: v)
87  c->accept(*this);
88  }
89 
90  VISIT(star)
91  {
92  ++star;
93  v.sub()->accept(*this);
94  }
95 
97  {
98  ++complement;
99  v.sub()->accept(*this);
100  }
101 
103  {
104  ++transposition;
105  v.sub()->accept(*this);
106  }
107 
108  VISIT(zero)
109  {
110  (void) v;
111  ++zero;
112  }
113 
114  VISIT(one)
115  {
116  (void) v;
117  ++one;
118  }
119 
120  VISIT(atom)
121  {
122  (void) v;
123  ++atom;
124  }
125 
126  VISIT(lweight)
127  {
128  ++lweight;
129  v.sub()->accept(*this);
130  }
131 
132  VISIT(rweight)
133  {
134  ++rweight;
135  v.sub()->accept(*this);
136  }
137 
138 # undef VISIT
139 # undef DEFINE
140 
141  } // namespace rat
142 }}//end of ns awali::stc
143 
144 #endif // !AWALI_CORE_RAT_INFO_HXX
Definition: ratexp.hh:280
Definition: ratexp.hh:262
virtual void accept(typename node_t::const_visitor &v) const override
Definition: ratexp.hxx:208
typename ratexpset_t::node_t node_t
Definition: info.hh:34
Definition: ratexp.hh:176
An inner node with multiple children.
Definition: ratexp.hh:115
An inner node implementing a weight.
Definition: ratexp.hh:208
#define VISIT(Type)
Definition: info.hxx:50
variadic< type_t::sum, Label, Weight > sum
Definition: fwd.hh:154
weight_node< type_t::lweight, Label, Weight > lweight
Definition: fwd.hh:164
unary< type_t::star, Label, Weight > star
Definition: fwd.hh:129
constant< type_t::zero, Label, Weight > zero
Definition: fwd.hh:113
variadic< type_t::ldiv, Label, Weight > ldiv
Definition: fwd.hh:148
variadic< type_t::conjunction, Label, Weight > conjunction
Definition: fwd.hh:145
variadic< type_t::shuffle, Label, Weight > shuffle
Definition: fwd.hh:151
weight_node< type_t::rweight, Label, Weight > rweight
Definition: fwd.hh:167
unary< type_t::transposition, Label, Weight > transposition
Definition: fwd.hh:132
constant< type_t::one, Label, Weight > one
Definition: fwd.hh:116
unary< type_t::complement, Label, Weight > complement
Definition: fwd.hh:126
variadic< type_t::prod, Label, Weight > prod
Definition: fwd.hh:142
Main namespace of Awali.
Definition: ato.hh:22