Awali
Another Weighted Automata library
fwd.hh
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_FWD_HH
18 # define AWALI_CORE_RAT_FWD_HH
19 
20 # include <memory>
21 
24 
25 namespace awali { namespace sttc
26 {
27  namespace rat
28  {
29 
31  class exp;
32  using exp_t = std::shared_ptr<const exp>;
33 
34  // info.hh
35  template <typename Context>
36  class info;
37 
38  // printer.hh.
39  template <typename Context>
40  class printer;
41 
47  enum class type_t
48  {
49  zero,
50  one,
51  atom,
52  sum,
53  prod,
54  ldiv,
56  shuffle,
57  star,
58  maybe,
59  plus,
61  lweight,
62  rweight,
63  complement,
64  };
65 
67  inline constexpr bool is_constant(type_t t)
68  {
69  return (t == type_t::one
70  || t == type_t::zero);
71  }
72 
74  inline constexpr bool is_unary(type_t t)
75  {
76  return (t == type_t::complement
77  || t == type_t::star
78  || t == type_t::maybe
79  || t == type_t::plus
80  || t == type_t::transposition);
81  }
82 
84  inline constexpr bool is_variadic(type_t t)
85  {
86  return (t == type_t::conjunction
87  || t == type_t::ldiv
88  || t == type_t::prod
89  || t == type_t::shuffle
90  || t == type_t::sum);
91  }
92 
93  std::ostream&
94  operator<<(std::ostream& o, type_t t);
95 
96 # define DEFINE(Node) \
97  template <typename Label, typename Weight> \
98  class Node
99 
100  DEFINE(node);
101  DEFINE(leaf);
102  DEFINE(atom);
103  DEFINE(inner);
104 
105  DEFINE(const_visitor);
106 
107 # undef DEFINE
108 
109  /*-----------.
110  | constant. |
111  `-----------*/
112 
113  template <type_t Type, typename Label, typename Weight>
114  class constant;
115 
116  template <typename Label, typename Weight>
118 
119  template <typename Label, typename Weight>
121 
122  /*--------.
123  | unary. |
124  `--------*/
125 
126  template <type_t Type, typename Label, typename Weight>
127  class unary;
128 
129  template <typename Label, typename Weight>
131 
132  template <typename Label, typename Weight>
134 
135  template <typename Label, typename Weight>
137 
138  template <typename Label, typename Weight>
140 
141  template <typename Label, typename Weight>
143 
144  /*-----------.
145  | variadic. |
146  `-----------*/
147 
148  template <type_t Type, typename Label, typename Weight>
149  class variadic;
150 
151  template <typename Label, typename Weight>
153 
154  template <typename Label, typename Weight>
156 
157  template <typename Label, typename Weight>
159 
160  template <typename Label, typename Weight>
162 
163  template <typename Label, typename Weight>
165 
166  /*--------------.
167  | weight_node. |
168  `--------------*/
169 
170  template <type_t Type, typename Label, typename Weight>
171  class weight_node;
172 
173  template <typename Label, typename Weight>
175 
176  template <typename Label, typename Weight>
178 
179 
180 
181  template <typename Label, typename Weight>
182  using ratexp = std::shared_ptr<const node<Label, Weight>>;
183 
184 
185  // ratexpset.hh.
186  template <typename Context>
187  class ratexpset_impl;
188 
189  } // namespace rat
190 
191  template <typename Context>
193 
194 }}//end of ns awali::stc
195 
196 #endif // !AWALI_CORE_RAT_FWD_HH
Definition: ratexp.hh:262
Definition: info.hh:31
Definition: printer.hh:36
A typed ratexp set.
Definition: ratexpset.hh:46
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 DEFINE(Node)
Definition: fwd.hh:96
constexpr bool is_unary(type_t t)
Whether star, complement.
Definition: fwd.hh:74
constexpr bool is_constant(type_t t)
Whether is a constant (\z or \e).
Definition: fwd.hh:67
type_t
The possible types of ratexps.
Definition: fwd.hh:48
constexpr bool is_variadic(type_t t)
Whether one of the variadic types.
Definition: fwd.hh:84
std::shared_ptr< const node< Label, Weight > > ratexp
Definition: fwd.hh:182
std::ostream & operator<<(std::ostream &o, type_t t)
Definition: printer.hxx:31
std::shared_ptr< const exp > exp_t
Definition: fwd.hh:32
Main namespace of Awali.
Definition: ato.hh:22
Provide a variadic mul on top of a binary mul(), and one().
Definition: weightset.hh:38