Awali
Another Weighted Automata library
info.hxx
Go to the documentation of this file.
1 // This file is part of Awali.
2 // Copyright 2016-2023 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  maybe = 0;
45  plus = 0;
46  sum = 0;
47  transposition = 0;
48  zero = 0;
49  v.accept(*this);
50  }
51 
52 # define VISIT(Type) \
53  DEFINE::visit(const Type ## _t& v) \
54  -> void
55 
56  VISIT(sum)
57  {
58  ++sum;
59  for (const auto& c: v)
60  c->accept(*this);
61  }
62 
63  VISIT(prod)
64  {
65  ++prod;
66  for (const auto& c: v)
67  c->accept(*this);
68  }
69 
71  {
72  ++conjunction;
73  for (const auto& c: v)
74  c->accept(*this);
75  }
76 
77  VISIT(shuffle)
78  {
79  ++shuffle;
80  for (const auto& c: v)
81  c->accept(*this);
82  }
83 
84 
85  VISIT(ldiv)
86  {
87  ++ldiv;
88  for (const auto& c: v)
89  c->accept(*this);
90  }
91 
92  VISIT(star)
93  {
94  ++star;
95  v.sub()->accept(*this);
96  }
97 
98  VISIT(maybe)
99  {
100  ++maybe;
101  v.sub()->accept(*this);
102  }
103 
104  VISIT(plus)
105  {
106  ++plus;
107  v.sub()->accept(*this);
108  }
109 
111  {
112  ++complement;
113  v.sub()->accept(*this);
114  }
115 
117  {
118  ++transposition;
119  v.sub()->accept(*this);
120  }
121 
122  VISIT(zero)
123  {
124  (void) v;
125  ++zero;
126  }
127 
128  VISIT(one)
129  {
130  (void) v;
131  ++one;
132  }
133 
134  VISIT(atom)
135  {
136  (void) v;
137  ++atom;
138  }
139 
140  VISIT(lweight)
141  {
142  ++lweight;
143  v.sub()->accept(*this);
144  }
145 
146  VISIT(rweight)
147  {
148  ++rweight;
149  v.sub()->accept(*this);
150  }
151 
152 # undef VISIT
153 # undef DEFINE
154 
155  } // namespace rat
156 }}//end of ns awali::stc
157 
158 #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:52
variadic< type_t::sum, Label, Weight > sum
Definition: fwd.hh:164
weight_node< type_t::lweight, Label, Weight > lweight
Definition: fwd.hh:174
unary< type_t::star, Label, Weight > star
Definition: fwd.hh:133
constant< type_t::zero, Label, Weight > zero
Definition: fwd.hh:117
unary< type_t::plus, Label, Weight > plus
Definition: fwd.hh:139
variadic< type_t::ldiv, Label, Weight > ldiv
Definition: fwd.hh:158
variadic< type_t::conjunction, Label, Weight > conjunction
Definition: fwd.hh:155
variadic< type_t::shuffle, Label, Weight > shuffle
Definition: fwd.hh:161
weight_node< type_t::rweight, Label, Weight > rweight
Definition: fwd.hh:177
unary< type_t::transposition, Label, Weight > transposition
Definition: fwd.hh:142
constant< type_t::one, Label, Weight > one
Definition: fwd.hh:120
unary< type_t::complement, Label, Weight > complement
Definition: fwd.hh:130
variadic< type_t::prod, Label, Weight > prod
Definition: fwd.hh:152
unary< type_t::maybe, Label, Weight > maybe
Definition: fwd.hh:136
Main namespace of Awali.
Definition: ato.hh:22