17 #ifndef AWALI_ALGOS_JS_PARSER_DEPRECATED_HH
18 # define AWALI_ALGOS_JS_PARSER_DEPRECATED_HH
22 #include <awali/common/json/parser.cc>
35 namespace deprecated {
39 template<
typename RatExpSet>
44 using ratexp_t =
typename ratexpset_t::value_t;
69 throw std::runtime_error(
"Json parser: ratexp");
71 else if(key ==
"Prod") {
85 throw std::runtime_error(
"Json parser: ratexp");
87 else if(key ==
"Star") {
90 else if(key ==
"Label") {
91 e= rs_.atom(ls_.value_from_json<1>(i_));
93 else if(key ==
"LWeight") {
94 auto w = ws_.value_from_json<1>(i_);
99 else if(key ==
"RWeight") {
100 auto w = ws_.value_from_json<1>(i_);
105 else if(key ==
"One") {
108 throw std::runtime_error(
"Json parser: ratexp");
111 else if(key ==
"Zero") {
114 throw std::runtime_error(
"Json parser: ratexp");
118 throw std::runtime_error(
"Json parser: ratexp");
138 template <
typename RatExpSet>
140 typename RatExpSet::ratexp_t
148 template <
typename Context>
157 std::unordered_map<unsigned,state_t>
states;
161 throw std::runtime_error(
"json: Content");
165 throw std::runtime_error(
"json: States");
174 throw std::runtime_error(
"json: State Id");
176 states[s]=aut->add_state();
179 throw std::runtime_error(
"json: Name");
182 aut->set_state_name(
states[s],key);
186 if(tmp ==
"History") {
188 auto history=aut->history();
190 history=std::make_shared<string_history>();
191 aut->set_history(history);
203 throw std::runtime_error(
"json: States ]");
212 if(key ==
"Initial States") {
217 aut->set_initial(
states[s]);
222 throw std::runtime_error(
"json: IState Id");
226 typename Context::labelset_t::value_t l{};
232 l=ls->template value_from_json<1>(node);
235 aut->new_transition(
states[s], aut->post(), l);
242 throw std::runtime_error(
"json: FWeight");
245 auto w = ws->template value_from_json<1>(node);
248 aut->new_transition(
states[s], aut->post(), l, w);
250 aut->set_initial(
states[s], w);
253 aut->set_initial(
states[s]);
259 throw std::runtime_error(
"json: IStates ]");
271 if(key ==
"Final States") {
276 aut->set_final(
states[s]);
281 throw std::runtime_error(
"json: FState Id");
285 typename Context::labelset_t::value_t l{};
291 l=ls->template value_from_json<1>(node);
293 aut->new_transition(
states[s], aut->post(), l);
300 throw std::runtime_error(
"json: FWeight");
303 auto w=ws->template value_from_json<1>(node);
306 aut->new_transition(
states[s], aut->post(), l, w);
308 aut->set_final(
states[s], w);
311 aut->set_final(
states[s]);
317 throw std::runtime_error(
"json: FStates ]");
329 if(key ==
"Transitions") {
344 throw std::runtime_error(
"json: Src");
349 throw std::runtime_error(
"json: Dst");
359 typename Context::labelset_t::value_t l{};
363 l = ls->template value_from_json<1>(node);
376 throw std::runtime_error(
"json: Weight");
378 auto w = ws->template value_from_json<1>(node);
388 throw std::runtime_error(
"json: Trans ]");
The semiring of complex numbers.
Definition: c.hh:44
carries the algebraic settings of automata
Definition: context.hh:40
const weightset_ptr & weightset() const
Definition: context.hh:157
const labelset_ptr & labelset() const
Definition: context.hh:152
Definition: string_history.hh:29
void add_state(state_t s, const std::string &str)
Definition: string_history.hh:89
@ NO_HISTORY
The state has no history.
bool has_label(automaton_t tdc, unsigned i, std::string const &l)
std::vector< state_t > states(abstract_automaton_t const *aut, bool all)
static char parsecst(std::istream &i)
Definition: utils.hh:216
static char peek(std::istream &i)
peeks the next character
Definition: utils.hh:139
static std::string parsestring(std::istream &i)
Definition: utils.hh:152
static int parseint(std::istream &i)
Definition: utils.hh:237
static std::string get_first_attr(std::istream &i)
Definition: utils.hh:245
static void parseignore(std::istream &i)
Definition: utils.hh:254
static void check(std::istream &i, char e, std::string oth="")
checks the next character
Definition: utils.hh:116
node_t * parse(std::istream &, bool stop_after_metadata=false)
mutable_automaton< Context > js_parse_aut_content(const Context &context, std::istream &i)
Definition: js_parser_deprecated.hh:150
RatExpSet::ratexp_t js_parse_exp_content(const RatExpSet &rs, std::istream &i)
Definition: js_parser_deprecated.hh:141
typename internal::context_t_of_impl< internal::base_t< ValueSet > >::type context_t_of
Helper to retrieve the type of the context of a value set.
Definition: traits.hh:66
typename internal::labelset_t_of_impl< internal::base_t< ValueSet > >::type labelset_t_of
Helper to retrieve the type of the labelset of a value set.
Definition: traits.hh:76
mutable_automaton< Context > make_mutable_automaton(const Context &ctx)
Definition: mutable_automaton.hh:915
transition_t new_epsilon_trans(Aut a, state_t src, state_t dst, weight_t_of< Aut > w)
Helper to create a new epsilon transition.
Definition: add_epsilon_trans.hh:165
std::shared_ptr< internal::mutable_automaton_impl< Context > > mutable_automaton
Definition: mutable_automaton.hh:45
typename internal::weightset_t_of_impl< internal::base_t< ValueSet > >::type weightset_t_of
Helper to retrieve the type of the weightset of a value set.
Definition: traits.hh:86
Main namespace of Awali.
Definition: ato.hh:22
Definition: js_parser_deprecated.hh:40
weightset_t_of< ratexpset_t > weightset_t
Definition: js_parser_deprecated.hh:45
typename ratexpset_t::value_t ratexp_t
Definition: js_parser_deprecated.hh:44
labelset_t_of< context_t > labelset_t
Definition: js_parser_deprecated.hh:43
ratexp_t parseNode(const std::string &key)
Definition: js_parser_deprecated.hh:51
ratexp_t parseNode()
Definition: js_parser_deprecated.hh:122
js_exp_parser(const ratexpset_t &rs, std::istream &i)
Definition: js_parser_deprecated.hh:47
RatExpSet ratexpset_t
Definition: js_parser_deprecated.hh:41
context_t_of< ratexpset_t > context_t
Definition: js_parser_deprecated.hh:42