Vcsn  2.2
Be Rational
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
parse.cc
Go to the documentation of this file.
1 // A Bison parser, made by GNU Bison 3.0.2.
2 
3 // Skeleton implementation for Bison LALR(1) parsers in C++
4 
5 // Copyright (C) 2002-2013 Free Software Foundation, Inc.
6 
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 
20 // As a special exception, you may create a larger work that contains
21 // part or all of the Bison parser skeleton and distribute that work
22 // under terms of your choice, so long as that work isn't itself a
23 // parser generator using the skeleton or a modified version thereof
24 // as a parser skeleton. Alternatively, if you modify or redistribute
25 // the parser skeleton itself, you may (at your option) remove this
26 // special exception, which will cause the skeleton and the resulting
27 // Bison output files to be licensed under the GNU General Public
28 // License without this special exception.
29 
30 // This special exception was added by the Free Software Foundation in
31 // version 2.2 of Bison.
32 
33 
34 // First part of user declarations.
35 
36 #line 37 "./lib/vcsn/rat/parse.cc" // lalr1.cc:399
37 
38 # ifndef YY_NULLPTR
39 # if defined __cplusplus && 201103L <= __cplusplus
40 # define YY_NULLPTR nullptr
41 # else
42 # define YY_NULLPTR 0
43 # endif
44 # endif
45 
46 #include "parse.hh"
47 
48 // User implementation prologue.
49 
50 #line 51 "./lib/vcsn/rat/parse.cc" // lalr1.cc:407
51 // Unqualified %code blocks.
52 #line 63 "lib/vcsn/rat/parse.yy" // lalr1.cc:408
53 
54  #include <lib/vcsn/rat/driver.hh>
55  #include <lib/vcsn/rat/scan.hh>
56  #include <vcsn/dyn/algos.hh>
57  #include <vcsn/misc/stream.hh>
58  #include <vcsn/dyn/context.hh>
59 
60 #define TRY(Loc, Stm) \
61  try \
62  { \
63  Stm; \
64  } \
65  catch (std::exception& e) \
66  { \
67  error(Loc, e.what()); \
68  YYERROR; \
69  }
70 
71  namespace vcsn
72  {
73  namespace rat
74  {
76  static inline
78  const dyn::expression& f);
79 
81  static inline
83  {
84  return d.context();
85  }
86 
88  static inline
89  identities ids(const driver& d)
90  {
91  return d.identities();
92  }
93 
95  static inline
97  {
98  return d.scanner_->lex(d);
99  }
100  }
101  }
102 
103 #line 104 "./lib/vcsn/rat/parse.cc" // lalr1.cc:408
104 
105 
106 #ifndef YY_
107 # if defined YYENABLE_NLS && YYENABLE_NLS
108 # if ENABLE_NLS
109 # include <libintl.h> // FIXME: INFRINGES ON USER NAME SPACE.
110 # define YY_(msgid) dgettext ("bison-runtime", msgid)
111 # endif
112 # endif
113 # ifndef YY_
114 # define YY_(msgid) msgid
115 # endif
116 #endif
117 
118 #define YYRHSLOC(Rhs, K) ((Rhs)[K].location)
119 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
120  If N is 0, then set CURRENT to the empty location which ends
121  the previous symbol: RHS[0] (always defined). */
122 
123 # ifndef YYLLOC_DEFAULT
124 # define YYLLOC_DEFAULT(Current, Rhs, N) \
125  do \
126  if (N) \
127  { \
128  (Current).begin = YYRHSLOC (Rhs, 1).begin; \
129  (Current).end = YYRHSLOC (Rhs, N).end; \
130  } \
131  else \
132  { \
133  (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
134  } \
135  while (/*CONSTCOND*/ false)
136 # endif
137 
138 
139 // Suppress unused-variable warnings by "using" E.
140 #define YYUSE(E) ((void) (E))
141 
142 // Enable debugging if requested.
143 #if YYDEBUG
144 
145 // A pseudo ostream that takes yydebug_ into account.
146 # define YYCDEBUG if (yydebug_) (*yycdebug_)
147 
148 # define YY_SYMBOL_PRINT(Title, Symbol) \
149  do { \
150  if (yydebug_) \
151  { \
152  *yycdebug_ << Title << ' '; \
153  yy_print_ (*yycdebug_, Symbol); \
154  *yycdebug_ << std::endl; \
155  } \
156  } while (false)
157 
158 # define YY_REDUCE_PRINT(Rule) \
159  do { \
160  if (yydebug_) \
161  yy_reduce_print_ (Rule); \
162  } while (false)
163 
164 # define YY_STACK_PRINT() \
165  do { \
166  if (yydebug_) \
167  yystack_print_ (); \
168  } while (false)
169 
170 #else // !YYDEBUG
171 
172 # define YYCDEBUG if (false) std::cerr
173 # define YY_SYMBOL_PRINT(Title, Symbol) YYUSE(Symbol)
174 # define YY_REDUCE_PRINT(Rule) static_cast<void>(0)
175 # define YY_STACK_PRINT() static_cast<void>(0)
176 
177 #endif // !YYDEBUG
178 
179 #define yyerrok (yyerrstatus_ = 0)
180 #define yyclearin (yyempty = true)
181 
182 #define YYACCEPT goto yyacceptlab
183 #define YYABORT goto yyabortlab
184 #define YYERROR goto yyerrorlab
185 #define YYRECOVERING() (!!yyerrstatus_)
186 
187 #line 11 "lib/vcsn/rat/parse.yy" // lalr1.cc:474
188 namespace vcsn { namespace rat {
189 #line 190 "./lib/vcsn/rat/parse.cc" // lalr1.cc:474
190 
191  /* Return YYSTR after stripping away unnecessary quotes and
192  backslashes, so that it's suitable for yyerror. The heuristic is
193  that double-quoting is unnecessary unless the string contains an
194  apostrophe, a comma, or backslash (other than backslash-backslash).
195  YYSTR is taken from yytname. */
196  std::string
197  parser::yytnamerr_ (const char *yystr)
198  {
199  if (*yystr == '"')
200  {
201  std::string yyr = "";
202  char const *yyp = yystr;
203 
204  for (;;)
205  switch (*++yyp)
206  {
207  case '\'':
208  case ',':
209  goto do_not_strip_quotes;
210 
211  case '\\':
212  if (*++yyp != '\\')
213  goto do_not_strip_quotes;
214  // Fall through.
215  default:
216  yyr += *yyp;
217  break;
218 
219  case '"':
220  return yyr;
221  }
222  do_not_strip_quotes: ;
223  }
224 
225  return yystr;
226  }
227 
228 
230  parser::parser (driver& driver__yyarg)
231  :
232 #if YYDEBUG
233  yydebug_ (false),
234  yycdebug_ (&std::cerr),
235 #endif
236  driver_ (driver__yyarg)
237  {}
238 
240  {}
241 
242 
243  /*---------------.
244  | Symbol types. |
245  `---------------*/
246 
247 
248 
249  // by_state.
250  inline
252  : state (empty)
253  {}
254 
255  inline
257  : state (other.state)
258  {}
259 
260  inline
261  void
263  {
264  state = that.state;
265  that.state = empty;
266  }
267 
268  inline
270  : state (s)
271  {}
272 
273  inline
276  {
277  return state == empty ? 0 : yystos_[state];
278  }
279 
280  inline
282  {}
283 
284 
285  inline
287  : super_type (s, that.location)
288  {
289  switch (that.type_get ())
290  {
291  case 32: // input
292  case 34: // sum
293  case 35: // tuple
294  case 39: // exp
295  value.move< braced_expression > (that.value);
296  break;
297 
298  case 41: // class
299  value.move< class_t > (that.value);
300  break;
301 
302  case 40: // weights
303  value.move< dyn::weight > (that.value);
304  break;
305 
306  case 25: // "*"
307  value.move< irange_type > (that.value);
308  break;
309 
310  case 26: // "letter"
311  case 27: // "weight"
312  value.move< std::string > (that.value);
313  break;
314 
315  case 37: // tuple.1
316  value.move< std::vector<vcsn::dyn::expression> > (that.value);
317  break;
318 
319  default:
320  break;
321  }
322 
323  // that is emptied.
324  that.type = empty;
325  }
326 
327  inline
330  {
331  state = that.state;
332  switch (that.type_get ())
333  {
334  case 32: // input
335  case 34: // sum
336  case 35: // tuple
337  case 39: // exp
338  value.copy< braced_expression > (that.value);
339  break;
340 
341  case 41: // class
342  value.copy< class_t > (that.value);
343  break;
344 
345  case 40: // weights
346  value.copy< dyn::weight > (that.value);
347  break;
348 
349  case 25: // "*"
350  value.copy< irange_type > (that.value);
351  break;
352 
353  case 26: // "letter"
354  case 27: // "weight"
355  value.copy< std::string > (that.value);
356  break;
357 
358  case 37: // tuple.1
359  value.copy< std::vector<vcsn::dyn::expression> > (that.value);
360  break;
361 
362  default:
363  break;
364  }
365 
366  location = that.location;
367  return *this;
368  }
369 
370 
371  template <typename Base>
372  inline
373  void
374  parser::yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const
375  {
376  if (yymsg)
377  YY_SYMBOL_PRINT (yymsg, yysym);
378  }
379 
380 #if YYDEBUG
381  template <typename Base>
382  void
383  parser::yy_print_ (std::ostream& yyo,
384  const basic_symbol<Base>& yysym) const
385  {
386  std::ostream& yyoutput = yyo;
387  YYUSE (yyoutput);
388  symbol_number_type yytype = yysym.type_get ();
389  yyo << (yytype < yyntokens_ ? "token" : "nterm")
390  << ' ' << yytname_[yytype] << " ("
391  << yysym.location << ": ";
392  switch (yytype)
393  {
394  case 26: // "letter"
395 
396 #line 121 "lib/vcsn/rat/parse.yy" // lalr1.cc:617
397  { yyo << '"' << yysym.value.template as< std::string > () << '"'; }
398 #line 399 "./lib/vcsn/rat/parse.cc" // lalr1.cc:617
399  break;
400 
401  case 27: // "weight"
402 
403 #line 128 "lib/vcsn/rat/parse.yy" // lalr1.cc:617
404  { yyo << '<' << yysym.value.template as< std::string > () << '>'; }
405 #line 406 "./lib/vcsn/rat/parse.cc" // lalr1.cc:617
406  break;
407 
408  case 32: // input
409 //-
410 //-#line 130 "lib/vcsn/rat/parse.yy" // lalr1.cc:617
411 //- {
412 //- dyn::print(yysym.value.template as< braced_expression > ().exp, yyo);
413 //- yyo << (yysym.value.template as< braced_expression > ().lparen ? " (lpar, " : " (no lpar, ");
414 //- yyo << (yysym.value.template as< braced_expression > ().rparen ? "rpar)" : "no rpar)");
415 //-}
416 //-#line 417 "./lib/vcsn/rat/parse.cc" // lalr1.cc:617
417 //- break;
418 
419  case 34: // sum
420 //-
421 //-#line 130 "lib/vcsn/rat/parse.yy" // lalr1.cc:617
422 //- {
423 //- dyn::print(yysym.value.template as< braced_expression > ().exp, yyo);
424 //- yyo << (yysym.value.template as< braced_expression > ().lparen ? " (lpar, " : " (no lpar, ");
425 //- yyo << (yysym.value.template as< braced_expression > ().rparen ? "rpar)" : "no rpar)");
426 //-}
427 //-#line 428 "./lib/vcsn/rat/parse.cc" // lalr1.cc:617
428 //- break;
429 
430  case 35: // tuple
431 
432 #line 130 "lib/vcsn/rat/parse.yy" // lalr1.cc:617
433  {
434  dyn::print(yysym.value.template as< braced_expression > ().exp, yyo);
435  yyo << (yysym.value.template as< braced_expression > ().lparen ? " (lpar, " : " (no lpar, ");
436  yyo << (yysym.value.template as< braced_expression > ().rparen ? "rpar)" : "no rpar)");
437 }
438 #line 439 "./lib/vcsn/rat/parse.cc" // lalr1.cc:617
439  break;
440 
441  case 37: // tuple.1
442 
443 #line 136 "lib/vcsn/rat/parse.yy" // lalr1.cc:617
444  {
445  const char* sep = "[[";
446  for (auto e: yysym.value.template as< std::vector<vcsn::dyn::expression> > ())
447  {
448  yyo << sep << e;
449  sep = " || ";
450  }
451  yyo << "]]";
452 }
453 #line 454 "./lib/vcsn/rat/parse.cc" // lalr1.cc:617
454  break;
455 
456  case 39: // exp
457 
458 #line 130 "lib/vcsn/rat/parse.yy" // lalr1.cc:617
459  {
460  dyn::print(yysym.value.template as< braced_expression > ().exp, yyo);
461  yyo << (yysym.value.template as< braced_expression > ().lparen ? " (lpar, " : " (no lpar, ");
462  yyo << (yysym.value.template as< braced_expression > ().rparen ? "rpar)" : "no rpar)");
463 }
464 #line 465 "./lib/vcsn/rat/parse.cc" // lalr1.cc:617
465  break;
466 
467  case 40: // weights
468 
469 #line 146 "lib/vcsn/rat/parse.yy" // lalr1.cc:617
470  { dyn::print(yysym.value.template as< dyn::weight > (), yyo); }
471 #line 472 "./lib/vcsn/rat/parse.cc" // lalr1.cc:617
472  break;
473 
474  case 41: // class
475 
476 #line 123 "lib/vcsn/rat/parse.yy" // lalr1.cc:617
477  {
478  yyo << '[';
479  for (auto c: yysym.value.template as< class_t > ()) yyo << c.first << "-" << c.second;
480  yyo << ']';
481 }
482 #line 483 "./lib/vcsn/rat/parse.cc" // lalr1.cc:617
483  break;
484 
485 
486  default:
487  break;
488  }
489  yyo << ')';
490  }
491 #endif
492 
493  inline
494  void
495  parser::yypush_ (const char* m, state_type s, symbol_type& sym)
496  {
497  stack_symbol_type t (s, sym);
498  yypush_ (m, t);
499  }
500 
501  inline
502  void
503  parser::yypush_ (const char* m, stack_symbol_type& s)
504  {
505  if (m)
506  YY_SYMBOL_PRINT (m, s);
507  yystack_.push (s);
508  }
509 
510  inline
511  void
512  parser::yypop_ (unsigned int n)
513  {
514  yystack_.pop (n);
515  }
516 
517 #if YYDEBUG
518  std::ostream&
519  parser::debug_stream () const
520  {
521  return *yycdebug_;
522  }
523 
524  void
525  parser::set_debug_stream (std::ostream& o)
526  {
527  yycdebug_ = &o;
528  }
529 
530 
532  parser::debug_level () const
533  {
534  return yydebug_;
535  }
536 
537  void
539  {
540  yydebug_ = l;
541  }
542 #endif // YYDEBUG
543 
544  inline parser::state_type
546  {
547  int yyr = yypgoto_[yysym - yyntokens_] + yystate;
548  if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
549  return yytable_[yyr];
550  else
551  return yydefgoto_[yysym - yyntokens_];
552  }
553 
554  inline bool
556  {
557  return yyvalue == yypact_ninf_;
558  }
559 
560  inline bool
562  {
563  return yyvalue == yytable_ninf_;
564  }
565 
566  int
568  {
570  bool yyempty = true;
571 
572  // State.
573  int yyn;
575  int yylen = 0;
576 
577  // Error handling.
578  int yynerrs_ = 0;
579  int yyerrstatus_ = 0;
580 
582  symbol_type yyla;
583 
585  stack_symbol_type yyerror_range[3];
586 
588  int yyresult;
589 
590  // FIXME: This shoud be completely indented. It is not yet to
591  // avoid gratuitous conflicts when merging into the master branch.
592  try
593  {
594  YYCDEBUG << "Starting parse" << std::endl;
595 
596 
597  // User initialization code.
598  #line 117 "lib/vcsn/rat/parse.yy" // lalr1.cc:725
599 {
600  yyla.location = driver_.location_;
601 }
602 
603 #line 604 "./lib/vcsn/rat/parse.cc" // lalr1.cc:725
604 
605  /* Initialize the stack. The initial state will be set in
606  yynewstate, since the latter expects the semantical and the
607  location values to have been already stored, initialize these
608  stacks with a primary value. */
609  yystack_.clear ();
610  yypush_ (YY_NULLPTR, 0, yyla);
611 
612  // A new symbol was pushed on the stack.
613  yynewstate:
614  YYCDEBUG << "Entering state " << yystack_[0].state << std::endl;
615 
616  // Accept?
617  if (yystack_[0].state == yyfinal_)
618  goto yyacceptlab;
619 
620  goto yybackup;
621 
622  // Backup.
623  yybackup:
624 
625  // Try to take a decision without lookahead.
626  yyn = yypact_[yystack_[0].state];
627  if (yy_pact_value_is_default_ (yyn))
628  goto yydefault;
629 
630  // Read a lookahead token.
631  if (yyempty)
632  {
633  YYCDEBUG << "Reading a token: ";
634  try
635  {
636  symbol_type yylookahead (yylex (driver_));
637  yyla.move (yylookahead);
638  }
639  catch (const syntax_error& yyexc)
640  {
641  error (yyexc);
642  goto yyerrlab1;
643  }
644  yyempty = false;
645  }
646  YY_SYMBOL_PRINT ("Next token is", yyla);
647 
648  /* If the proper action on seeing token YYLA.TYPE is to reduce or
649  to detect an error, take that action. */
650  yyn += yyla.type_get ();
651  if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.type_get ())
652  goto yydefault;
653 
654  // Reduce or error.
655  yyn = yytable_[yyn];
656  if (yyn <= 0)
657  {
658  if (yy_table_value_is_error_ (yyn))
659  goto yyerrlab;
660  yyn = -yyn;
661  goto yyreduce;
662  }
663 
664  // Discard the token being shifted.
665  yyempty = true;
666 
667  // Count tokens shifted since error; after three, turn off error status.
668  if (yyerrstatus_)
669  --yyerrstatus_;
670 
671  // Shift the lookahead token.
672  yypush_ ("Shifting", yyn, yyla);
673  goto yynewstate;
674 
675  /*-----------------------------------------------------------.
676  | yydefault -- do the default action for the current state. |
677  `-----------------------------------------------------------*/
678  yydefault:
679  yyn = yydefact_[yystack_[0].state];
680  if (yyn == 0)
681  goto yyerrlab;
682  goto yyreduce;
683 
684  /*-----------------------------.
685  | yyreduce -- Do a reduction. |
686  `-----------------------------*/
687  yyreduce:
688  yylen = yyr2_[yyn];
689  {
690  stack_symbol_type yylhs;
691  yylhs.state = yy_lr_goto_state_(yystack_[yylen].state, yyr1_[yyn]);
692  /* Variants are always initialized to an empty instance of the
693  correct type. The default '$$ = $1' action is NOT applied
694  when using variants. */
695  switch (yyr1_[yyn])
696  {
697  case 32: // input
698  case 34: // sum
699  case 35: // tuple
700  case 39: // exp
701  yylhs.value.build< braced_expression > ();
702  break;
703 
704  case 41: // class
705  yylhs.value.build< class_t > ();
706  break;
707 
708  case 40: // weights
709  yylhs.value.build< dyn::weight > ();
710  break;
711 
712  case 25: // "*"
713  yylhs.value.build< irange_type > ();
714  break;
715 
716  case 26: // "letter"
717  case 27: // "weight"
718  yylhs.value.build< std::string > ();
719  break;
720 
721  case 37: // tuple.1
722  yylhs.value.build< std::vector<vcsn::dyn::expression> > ();
723  break;
724 
725  default:
726  break;
727  }
728 
729 
730  // Compute the default @$.
731  {
733  YYLLOC_DEFAULT (yylhs.location, slice, yylen);
734  }
735 
736  // Perform the reduction.
737  YY_REDUCE_PRINT (yyn);
738  try
739  {
740  switch (yyn)
741  {
742  case 2:
743 #line 203 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
744  {
745  auto dim_exp = dyn::num_tapes(dyn::context_of(yystack_[1].value.as< braced_expression > ().exp));
746  auto dim_ctx = dyn::num_tapes(driver_.ctx_);
747  if (dim_exp != dim_ctx)
748  // num_tapes returns 0 on non lat. In this case, 1 is clearer.
749  throw syntax_error(yylhs.location,
750  "not enough tapes: "
751  + std::to_string(std::max(size_t{1}, dim_exp))
752  + " expected "
753  + std::to_string(std::max(size_t{1}, dim_ctx)));
754  // Provide a value for $$ only for sake of traces: shows the result.
755  yylhs.value.as< braced_expression > () = yystack_[1].value.as< braced_expression > ();
757  YYACCEPT;
758  }
759 #line 760 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
760  break;
761 
762  case 3:
763 #line 221 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
764  {}
765 #line 766 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
766  break;
767 
768  case 4:
769 #line 222 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
770  { driver_.scanner_->putback(','); }
771 #line 772 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
772  break;
773 
774  case 5:
775 #line 223 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
776  { driver_.scanner_->putback(')'); }
777 #line 778 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
778  break;
779 
780  case 6:
781 #line 227 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
782  { yylhs.value.as< braced_expression > () = yystack_[0].value.as< braced_expression > (); }
783 #line 784 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
784  break;
785 
786  case 7:
787 #line 228 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
788  { yylhs.value.as< braced_expression > () = dyn::sum(yystack_[2].value.as< braced_expression > ().exp, yystack_[0].value.as< braced_expression > ().exp); }
789 #line 790 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
790  break;
791 
792  case 8:
793 #line 234 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
794  { driver_.tape_push(); }
795 #line 796 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
796  break;
797 
798  case 9:
799 #line 235 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
800  {
801  driver_.tape_pop();
802  if (yystack_[0].value.as< std::vector<vcsn::dyn::expression> > ().size() == 1)
803  yylhs.value.as< braced_expression > () = yystack_[0].value.as< std::vector<vcsn::dyn::expression> > ().back();
804  else if (yystack_[0].value.as< std::vector<vcsn::dyn::expression> > ().size() == driver_.tape_ctx_.size())
805  yylhs.value.as< braced_expression > () = vcsn::dyn::tuple(yystack_[0].value.as< std::vector<vcsn::dyn::expression> > ());
806  else
807  throw syntax_error(yylhs.location,
808  "not enough tapes: "
809  + std::to_string(yystack_[0].value.as< std::vector<vcsn::dyn::expression> > ().size())
810  + " expected "
811  + std::to_string(driver_.tape_ctx_.size()));
812  }
813 #line 814 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
814  break;
815 
816  case 10:
817 #line 252 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
818  {
819  yylhs.value.as< std::vector<vcsn::dyn::expression> > ().emplace_back(yystack_[0].value.as< braced_expression > ().exp);
820  }
821 #line 822 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
822  break;
823 
824  case 11:
825 #line 255 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
826  { driver_.tape_inc(yystack_[0].location); }
827 #line 828 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
828  break;
829 
830  case 12:
831 #line 256 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
832  {
833  yylhs.value.as< std::vector<vcsn::dyn::expression> > () = yystack_[3].value.as< std::vector<vcsn::dyn::expression> > ();
834  yylhs.value.as< std::vector<vcsn::dyn::expression> > ().emplace_back(yystack_[0].value.as< braced_expression > ().exp);
835  }
836 #line 837 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
837  break;
838 
839  case 13:
840 #line 263 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
841  { yylhs.value.as< braced_expression > () = dyn::multiply(yystack_[2].value.as< braced_expression > ().exp, yystack_[0].value.as< braced_expression > ().exp); }
842 #line 843 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
843  break;
844 
845  case 14:
846 #line 264 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
847  { yylhs.value.as< braced_expression > () = dyn::conjunction(yystack_[2].value.as< braced_expression > ().exp, yystack_[0].value.as< braced_expression > ().exp); }
848 #line 849 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
849  break;
850 
851  case 15:
852 #line 265 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
853  { yylhs.value.as< braced_expression > () = dyn::shuffle(yystack_[2].value.as< braced_expression > ().exp, yystack_[0].value.as< braced_expression > ().exp); }
854 #line 855 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
855  break;
856 
857  case 16:
858 #line 266 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
859  { yylhs.value.as< braced_expression > () = dyn::infiltration(yystack_[2].value.as< braced_expression > ().exp, yystack_[0].value.as< braced_expression > ().exp); }
860 #line 861 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
861  break;
862 
863  case 17:
864 #line 267 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
865  { yylhs.value.as< braced_expression > () = prefer(yystack_[2].value.as< braced_expression > ().exp, yystack_[0].value.as< braced_expression > ().exp); }
866 #line 867 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
867  break;
868 
869  case 18:
870 #line 268 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
871  { yylhs.value.as< braced_expression > () = dyn::ldiv(yystack_[2].value.as< braced_expression > ().exp, yystack_[0].value.as< braced_expression > ().exp); }
872 #line 873 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
873  break;
874 
875  case 19:
876 #line 269 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
877  { yylhs.value.as< braced_expression > () = dyn::rdiv(yystack_[2].value.as< braced_expression > ().exp, yystack_[0].value.as< braced_expression > ().exp); }
878 #line 879 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
879  break;
880 
881  case 20:
882 #line 270 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
883  { yylhs.value.as< braced_expression > () = dyn::conjunction(yystack_[2].value.as< braced_expression > ().exp,
884  dyn::complement(yystack_[0].value.as< braced_expression > ().exp)); }
885 #line 886 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
886  break;
887 
888  case 21:
889 #line 272 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
890  { yylhs.value.as< braced_expression > () = dyn::left_mult(yystack_[1].value.as< dyn::weight > (), yystack_[0].value.as< braced_expression > ().exp); }
891 #line 892 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
892  break;
893 
894  case 22:
895 #line 273 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
896  { yylhs.value.as< braced_expression > () = dyn::right_mult(yystack_[1].value.as< braced_expression > ().exp, yystack_[0].value.as< dyn::weight > ()); }
897 #line 898 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
898  break;
899 
900  case 23:
901 #line 275 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
902  {
903  // See README.txt.
904  if (!yystack_[1].value.as< braced_expression > ().rparen && !yystack_[0].value.as< braced_expression > ().lparen)
905  yylhs.value.as< braced_expression > () = dyn::concatenate(yystack_[1].value.as< braced_expression > ().exp, yystack_[0].value.as< braced_expression > ().exp);
906  else
907  {
908  yylhs.value.as< braced_expression > ().exp = dyn::multiply(yystack_[1].value.as< braced_expression > ().exp, yystack_[0].value.as< braced_expression > ().exp);
909  yylhs.value.as< braced_expression > ().lparen = yystack_[1].value.as< braced_expression > ().lparen;
910  yylhs.value.as< braced_expression > ().rparen = yystack_[0].value.as< braced_expression > ().rparen;
911  }
912  }
913 #line 914 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
914  break;
915 
916  case 24:
917 #line 286 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
918  { TRY(yylhs.location,
919  yylhs.value.as< braced_expression > () =
920  dyn::multiply(yystack_[1].value.as< braced_expression > ().exp,
921  std::get<0>(yystack_[0].value.as< irange_type > ()), std::get<1>(yystack_[0].value.as< irange_type > ()))); }
922 #line 923 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
923  break;
924 
925  case 25:
926 #line 290 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
927  { yylhs.value.as< braced_expression > () = dyn::complement(yystack_[1].value.as< braced_expression > ().exp); }
928 #line 929 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
929  break;
930 
931  case 26:
932 #line 291 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
933  { yylhs.value.as< braced_expression > () = dyn::complement(yystack_[0].value.as< braced_expression > ().exp); }
934 #line 935 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
935  break;
936 
937  case 27:
938 #line 292 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
939  { yylhs.value.as< braced_expression > () = dyn::transposition(yystack_[1].value.as< braced_expression > ().exp); }
940 #line 941 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
941  break;
942 
943  case 28:
944 #line 293 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
946 #line 947 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
947  break;
948 
949  case 29:
950 #line 294 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
952 #line 953 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
953  break;
954 
955  case 30:
956 #line 295 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
957  { yylhs.value.as< braced_expression > () = driver_.make_atom(yystack_[0].location, yystack_[0].value.as< std::string > ()); }
958 #line 959 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
959  break;
960 
961  case 31:
962 #line 296 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
963  { yylhs.value.as< braced_expression > () = driver_.make_expression(yylhs.location, yystack_[1].value.as< class_t > (), true); }
964 #line 965 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
965  break;
966 
967  case 32:
968 #line 297 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
969  { yylhs.value.as< braced_expression > () = driver_.make_expression(yylhs.location, yystack_[1].value.as< class_t > (), false); }
970 #line 971 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
971  break;
972 
973  case 33:
974 #line 298 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
975  { yylhs.value.as< braced_expression > ().exp = yystack_[1].value.as< braced_expression > ().exp; yylhs.value.as< braced_expression > ().lparen = yylhs.value.as< braced_expression > ().rparen = true; }
976 #line 977 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
977  break;
978 
979  case 34:
980 #line 302 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
981  { yylhs.value.as< dyn::weight > () = driver_.make_weight(yystack_[0].location, yystack_[0].value.as< std::string > ()); }
982 #line 983 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
983  break;
984 
985  case 35:
986 #line 303 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
987  { yylhs.value.as< dyn::weight > () = dyn::multiply(driver_.make_weight(yystack_[1].location, yystack_[1].value.as< std::string > ()), yystack_[0].value.as< dyn::weight > ()); }
988 #line 989 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
989  break;
990 
991  case 36:
992 #line 307 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
993  {}
994 #line 995 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
995  break;
996 
997  case 37:
998 #line 308 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
999  { yylhs.value.as< class_t > () = yystack_[1].value.as< class_t > (); yylhs.value.as< class_t > ().emplace(yystack_[0].value.as< std::string > (), yystack_[0].value.as< std::string > ()); }
1000 #line 1001 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
1001  break;
1002 
1003  case 38:
1004 #line 309 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
1005  { yylhs.value.as< class_t > () = yystack_[3].value.as< class_t > (); yylhs.value.as< class_t > ().emplace(yystack_[2].value.as< std::string > (), yystack_[0].value.as< std::string > ()); }
1006 #line 1007 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
1007  break;
1008 
1009 
1010 #line 1011 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
1011  default:
1012  break;
1013  }
1014  }
1015  catch (const syntax_error& yyexc)
1016  {
1017  error (yyexc);
1018  YYERROR;
1019  }
1020  YY_SYMBOL_PRINT ("-> $$ =", yylhs);
1021  yypop_ (yylen);
1022  yylen = 0;
1023  YY_STACK_PRINT ();
1024 
1025  // Shift the result of the reduction.
1026  yypush_ (YY_NULLPTR, yylhs);
1027  }
1028  goto yynewstate;
1029 
1030  /*--------------------------------------.
1031  | yyerrlab -- here on detecting error. |
1032  `--------------------------------------*/
1033  yyerrlab:
1034  // If not already recovering from an error, report this error.
1035  if (!yyerrstatus_)
1036  {
1037  ++yynerrs_;
1038  error (yyla.location, yysyntax_error_ (yystack_[0].state,
1039  yyempty ? yyempty_ : yyla.type_get ()));
1040  }
1041 
1042 
1043  yyerror_range[1].location = yyla.location;
1044  if (yyerrstatus_ == 3)
1045  {
1046  /* If just tried and failed to reuse lookahead token after an
1047  error, discard it. */
1048 
1049  // Return failure if at end of input.
1050  if (yyla.type_get () == yyeof_)
1051  YYABORT;
1052  else if (!yyempty)
1053  {
1054  yy_destroy_ ("Error: discarding", yyla);
1055  yyempty = true;
1056  }
1057  }
1058 
1059  // Else will try to reuse lookahead token after shifting the error token.
1060  goto yyerrlab1;
1061 
1062 
1063  /*---------------------------------------------------.
1064  | yyerrorlab -- error raised explicitly by YYERROR. |
1065  `---------------------------------------------------*/
1066  yyerrorlab:
1067 
1068  /* Pacify compilers like GCC when the user code never invokes
1069  YYERROR and the label yyerrorlab therefore never appears in user
1070  code. */
1071  if (false)
1072  goto yyerrorlab;
1073  yyerror_range[1].location = yystack_[yylen].location;
1074  /* Do not reclaim the symbols of the rule whose action triggered
1075  this YYERROR. */
1076  yypop_ (yylen);
1077  yylen = 0;
1078  goto yyerrlab1;
1079 
1080  /*-------------------------------------------------------------.
1081  | yyerrlab1 -- common code for both syntax error and YYERROR. |
1082  `-------------------------------------------------------------*/
1083  yyerrlab1:
1084  yyerrstatus_ = 3; // Each real token shifted decrements this.
1085  {
1086  stack_symbol_type error_token;
1087  for (;;)
1088  {
1089  yyn = yypact_[yystack_[0].state];
1090  if (!yy_pact_value_is_default_ (yyn))
1091  {
1092  yyn += yyterror_;
1093  if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
1094  {
1095  yyn = yytable_[yyn];
1096  if (0 < yyn)
1097  break;
1098  }
1099  }
1100 
1101  // Pop the current state because it cannot handle the error token.
1102  if (yystack_.size () == 1)
1103  YYABORT;
1104 
1105  yyerror_range[1].location = yystack_[0].location;
1106  yy_destroy_ ("Error: popping", yystack_[0]);
1107  yypop_ ();
1108  YY_STACK_PRINT ();
1109  }
1110 
1111  yyerror_range[2].location = yyla.location;
1112  YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);
1113 
1114  // Shift the error token.
1115  error_token.state = yyn;
1116  yypush_ ("Shifting", error_token);
1117  }
1118  goto yynewstate;
1119 
1120  // Accept.
1121  yyacceptlab:
1122  yyresult = 0;
1123  goto yyreturn;
1124 
1125  // Abort.
1126  yyabortlab:
1127  yyresult = 1;
1128  goto yyreturn;
1129 
1130  yyreturn:
1131  if (!yyempty)
1132  yy_destroy_ ("Cleanup: discarding lookahead", yyla);
1133 
1134  /* Do not reclaim the symbols of the rule whose action triggered
1135  this YYABORT or YYACCEPT. */
1136  yypop_ (yylen);
1137  while (1 < yystack_.size ())
1138  {
1139  yy_destroy_ ("Cleanup: popping", yystack_[0]);
1140  yypop_ ();
1141  }
1142 
1143  return yyresult;
1144  }
1145  catch (...)
1146  {
1147  YYCDEBUG << "Exception caught: cleaning lookahead and stack"
1148  << std::endl;
1149  // Do not try to display the values of the reclaimed symbols,
1150  // as their printer might throw an exception.
1151  if (!yyempty)
1152  yy_destroy_ (YY_NULLPTR, yyla);
1153 
1154  while (1 < yystack_.size ())
1155  {
1157  yypop_ ();
1158  }
1159  throw;
1160  }
1161  }
1162 
1163  void
1165  {
1166  error (yyexc.location, yyexc.what());
1167  }
1168 
1169  // Generate an error message.
1170  std::string
1172  {
1173  std::string yyres;
1174  // Number of reported tokens (one for the "unexpected", one per
1175  // "expected").
1176  size_t yycount = 0;
1177  // Its maximum.
1178  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1179  // Arguments of yyformat.
1180  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1181 
1182  /* There are many possibilities here to consider:
1183  - If this state is a consistent state with a default action, then
1184  the only way this function was invoked is if the default action
1185  is an error action. In that case, don't check for expected
1186  tokens because there are none.
1187  - The only way there can be no lookahead present (in yytoken) is
1188  if this state is a consistent state with a default action.
1189  Thus, detecting the absence of a lookahead is sufficient to
1190  determine that there is no unexpected or expected token to
1191  report. In that case, just report a simple "syntax error".
1192  - Don't assume there isn't a lookahead just because this state is
1193  a consistent state with a default action. There might have
1194  been a previous inconsistent state, consistent state with a
1195  non-default action, or user semantic action that manipulated
1196  yyla. (However, yyla is currently not documented for users.)
1197  - Of course, the expected token list depends on states to have
1198  correct lookahead information, and it depends on the parser not
1199  to perform extra reductions after fetching a lookahead from the
1200  scanner and before detecting a syntax error. Thus, state
1201  merging (from LALR or IELR) and default reductions corrupt the
1202  expected token list. However, the list is correct for
1203  canonical LR with one exception: it will still contain any
1204  token that will not be accepted due to an error action in a
1205  later state.
1206  */
1207  if (yytoken != yyempty_)
1208  {
1209  yyarg[yycount++] = yytname_[yytoken];
1210  int yyn = yypact_[yystate];
1211  if (!yy_pact_value_is_default_ (yyn))
1212  {
1213  /* Start YYX at -YYN if negative to avoid negative indexes in
1214  YYCHECK. In other words, skip the first -YYN actions for
1215  this state because they are default actions. */
1216  int yyxbegin = yyn < 0 ? -yyn : 0;
1217  // Stay within bounds of both yycheck and yytname.
1218  int yychecklim = yylast_ - yyn + 1;
1219  int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
1220  for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
1221  if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_
1222  && !yy_table_value_is_error_ (yytable_[yyx + yyn]))
1223  {
1224  if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1225  {
1226  yycount = 1;
1227  break;
1228  }
1229  else
1230  yyarg[yycount++] = yytname_[yyx];
1231  }
1232  }
1233  }
1234 
1235  char const* yyformat = YY_NULLPTR;
1236  switch (yycount)
1237  {
1238 #define YYCASE_(N, S) \
1239  case N: \
1240  yyformat = S; \
1241  break
1242  YYCASE_(0, YY_("syntax error"));
1243  YYCASE_(1, YY_("syntax error, unexpected %s"));
1244  YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1245  YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1246  YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1247  YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1248 #undef YYCASE_
1249  }
1250 
1251  // Argument number.
1252  size_t yyi = 0;
1253  for (char const* yyp = yyformat; *yyp; ++yyp)
1254  if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
1255  {
1256  yyres += yytnamerr_ (yyarg[yyi++]);
1257  ++yyp;
1258  }
1259  else
1260  yyres += *yyp;
1261  return yyres;
1262  }
1263 
1264 
1265  const signed char parser::yypact_ninf_ = -19;
1266 
1267  const signed char parser::yytable_ninf_ = -1;
1268 
1269  const short int
1270  parser::yypact_[] =
1271  {
1272  -19, 4, -8, -19, 153, -19, -19, -19, -19, -19,
1273  153, 3, -19, -19, -19, -19, -10, 9, 52, 153,
1274  -19, 171, -19, -18, 13, -19, -19, 153, 153, 153,
1275  153, -19, 153, 153, 153, 153, -19, -19, 176, 120,
1276  -5, -17, -19, 10, -19, 153, 125, 125, 148, 125,
1277  176, 77, 102, 148, -19, 7, 52, -19
1278  };
1279 
1280  const unsigned char
1281  parser::yydefact_[] =
1282  {
1283  8, 0, 3, 6, 0, 1, 4, 8, 5, 2,
1284  0, 36, 8, 29, 28, 30, 34, 9, 10, 0,
1285  7, 26, 36, 0, 0, 35, 11, 0, 0, 0,
1286  0, 25, 0, 0, 0, 0, 27, 24, 23, 22,
1287  21, 0, 31, 37, 33, 0, 14, 16, 18, 15,
1288  13, 17, 20, 19, 32, 0, 12, 38
1289  };
1290 
1291  const signed char
1292  parser::yypgoto_[] =
1293  {
1294  -19, -19, -19, 0, -19, -19, -19, -19, -4, -2,
1295  15
1296  };
1297 
1298  const signed char
1299  parser::yydefgoto_[] =
1300  {
1301  -1, 1, 9, 2, 3, 4, 17, 45, 38, 19,
1302  23
1303  };
1304 
1305  const unsigned char
1306  parser::yytable_[] =
1307  {
1308  18, 6, 42, 54, 5, 31, 21, 20, 43, 43,
1309  22, 7, 24, 8, 25, 40, 39, 16, 36, 39,
1310  37, 55, 0, 46, 47, 48, 49, 26, 50, 51,
1311  52, 53, 7, 57, 44, 40, 39, 41, 39, 0,
1312  0, 56, 0, 0, 39, 39, 39, 39, 39, 39,
1313  39, 39, 0, 0, 39, 27, 28, 29, 10, 0,
1314  30, 0, 31, 0, 32, 11, 12, 33, 13, 34,
1315  0, 0, 0, 0, 35, 36, 14, 37, 15, 16,
1316  27, 28, 29, 10, 0, 30, 0, 31, 0, 32,
1317  11, 12, 0, 13, 34, 0, 0, 0, 0, 35,
1318  36, 14, 37, 15, 16, 27, 28, 29, 10, 0,
1319  30, 0, 31, 0, 32, 11, 12, 0, 13, 0,
1320  0, 0, 0, 0, 35, 36, 14, 37, 15, 16,
1321  29, 10, 0, 11, 12, 31, 13, 32, 11, 12,
1322  0, 13, 0, 0, 14, 0, 15, 35, 36, 14,
1323  37, 15, 16, 29, 10, 0, 0, 0, 31, 10,
1324  32, 11, 12, 0, 13, 0, 11, 12, 0, 13,
1325  0, 36, 14, 37, 15, 16, 0, 14, 0, 15,
1326  16, 31, 0, 32, 11, 12, 31, 13, 0, 11,
1327  12, 0, 13, 0, 36, 14, 37, 15, 16, 36,
1328  14, 37, 15, 16
1329  };
1330 
1331  const signed char
1332  parser::yycheck_[] =
1333  {
1334  4, 9, 20, 20, 0, 10, 10, 7, 26, 26,
1335  7, 19, 12, 21, 16, 19, 18, 27, 23, 21,
1336  25, 11, -1, 27, 28, 29, 30, 18, 32, 33,
1337  34, 35, 19, 26, 21, 39, 38, 22, 40, -1,
1338  -1, 45, -1, -1, 46, 47, 48, 49, 50, 51,
1339  52, 53, -1, -1, 56, 3, 4, 5, 6, -1,
1340  8, -1, 10, -1, 12, 13, 14, 15, 16, 17,
1341  -1, -1, -1, -1, 22, 23, 24, 25, 26, 27,
1342  3, 4, 5, 6, -1, 8, -1, 10, -1, 12,
1343  13, 14, -1, 16, 17, -1, -1, -1, -1, 22,
1344  23, 24, 25, 26, 27, 3, 4, 5, 6, -1,
1345  8, -1, 10, -1, 12, 13, 14, -1, 16, -1,
1346  -1, -1, -1, -1, 22, 23, 24, 25, 26, 27,
1347  5, 6, -1, 13, 14, 10, 16, 12, 13, 14,
1348  -1, 16, -1, -1, 24, -1, 26, 22, 23, 24,
1349  25, 26, 27, 5, 6, -1, -1, -1, 10, 6,
1350  12, 13, 14, -1, 16, -1, 13, 14, -1, 16,
1351  -1, 23, 24, 25, 26, 27, -1, 24, -1, 26,
1352  27, 10, -1, 12, 13, 14, 10, 16, -1, 13,
1353  14, -1, 16, -1, 23, 24, 25, 26, 27, 23,
1354  24, 25, 26, 27
1355  };
1356 
1357  const unsigned char
1358  parser::yystos_[] =
1359  {
1360  0, 32, 34, 35, 36, 0, 9, 19, 21, 33,
1361  6, 13, 14, 16, 24, 26, 27, 37, 39, 40,
1362  34, 39, 7, 41, 34, 40, 18, 3, 4, 5,
1363  8, 10, 12, 15, 17, 22, 23, 25, 39, 40,
1364  39, 41, 20, 26, 21, 38, 39, 39, 39, 39,
1365  39, 39, 39, 39, 20, 11, 39, 26
1366  };
1367 
1368  const unsigned char
1369  parser::yyr1_[] =
1370  {
1371  0, 31, 32, 33, 33, 33, 34, 34, 36, 35,
1372  37, 38, 37, 39, 39, 39, 39, 39, 39, 39,
1373  39, 39, 39, 39, 39, 39, 39, 39, 39, 39,
1374  39, 39, 39, 39, 40, 40, 41, 41, 41
1375  };
1376 
1377  const unsigned char
1378  parser::yyr2_[] =
1379  {
1380  0, 2, 2, 0, 1, 1, 1, 3, 0, 2,
1381  1, 0, 4, 3, 3, 3, 3, 3, 3, 3,
1382  3, 2, 2, 2, 2, 2, 2, 2, 1, 1,
1383  1, 3, 4, 3, 1, 2, 0, 2, 4
1384  };
1385 
1386 
1387 
1388  // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1389  // First, the terminals, then, starting at \a yyntokens_, nonterminals.
1390  const char*
1391  const parser::yytname_[] =
1392  {
1393  "\"end\"", "error", "$undefined", "\"&\"", "\"&:\"", "\"{\\\\}\"",
1394  "\"!\"", "\"^\"", "\":\"", "\",\"", "\"{c}\"", "\"-\"", "\".\"", "\"[\"",
1395  "\"(\"", "\"<+\"", "\"\\\\e\"", "\"%\"", "\"|\"", "\"+\"", "\"]\"",
1396  "\")\"", "\"{/}\"", "\"{T}\"", "\"\\\\z\"", "\"*\"", "\"letter\"",
1397  "\"weight\"", "CONCAT", "RWEIGHT", "LWEIGHT", "$accept", "input",
1398  "terminator.opt", "sum", "tuple", "$@1", "tuple.1", "$@2", "exp",
1399  "weights", "class", YY_NULLPTR
1400  };
1401 
1402 #if YYDEBUG
1403  const unsigned short int
1404  parser::yyrline_[] =
1405  {
1406  0, 202, 202, 221, 222, 223, 227, 228, 234, 234,
1407  251, 255, 255, 263, 264, 265, 266, 267, 268, 269,
1408  270, 272, 273, 274, 286, 290, 291, 292, 293, 294,
1409  295, 296, 297, 298, 302, 303, 307, 308, 309
1410  };
1411 
1412  // Print the state stack on the debug stream.
1413  void
1415  {
1416  *yycdebug_ << "Stack now";
1418  i = yystack_.begin (),
1419  i_end = yystack_.end ();
1420  i != i_end; ++i)
1421  *yycdebug_ << ' ' << i->state;
1422  *yycdebug_ << std::endl;
1423  }
1424 
1425  // Report on the debug stream that the rule \a yyrule is going to be reduced.
1426  void
1427  parser::yy_reduce_print_ (int yyrule)
1428  {
1429  unsigned int yylno = yyrline_[yyrule];
1430  int yynrhs = yyr2_[yyrule];
1431  // Print the symbols being reduced, and their result.
1432  *yycdebug_ << "Reducing stack by rule " << yyrule - 1
1433  << " (line " << yylno << "):" << std::endl;
1434  // The symbols being reduced.
1435  for (int yyi = 0; yyi < yynrhs; yyi++)
1436  YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
1437  yystack_[(yynrhs) - (yyi + 1)]);
1438  }
1439 #endif // YYDEBUG
1440 
1441 
1442 #line 11 "lib/vcsn/rat/parse.yy" // lalr1.cc:1155
1443 } } // vcsn::rat
1444 #line 1445 "./lib/vcsn/rat/parse.cc" // lalr1.cc:1155
1445 #line 312 "lib/vcsn/rat/parse.yy" // lalr1.cc:1156
1446 
1447 
1448 namespace vcsn
1449 {
1450  namespace rat
1451  {
1452  // "e <+ f = e + (f % e) = e + e{c} & f".
1453  static
1455  {
1456  return dyn::sum(e, dyn::conjunction(dyn::complement(e), f));
1457  }
1458 
1459  void
1460  vcsn::rat::parser::error(const location_type& l, const std::string& m)
1461  {
1462  driver_.error(l, m);
1463  }
1464  }
1465 }
std::shared_ptr< const detail::weight_base > weight
Definition: fwd.hh:88
A complete symbol.
Definition: parse.hh:396
#define YYCDEBUG
Definition: parse.cc:172
#define YY_(msgid)
Definition: parse.cc:114
#define YYABORT
Definition: parse.cc:183
expression rdiv(const expression &lhs, const expression &rhs)
Right-division of two expressions (lhs \ rhs).
Definition: algos.cc:1090
int state_type
State numbers.
Definition: parse.hh:634
T & build()
Instantiate an empty T in here.
Definition: parse.hh:192
void move(by_state &that)
Steal the symbol type from that.
Definition: parse.cc:262
expression expression_zero(const context &c, rat::identities ids)
The expression for \z.
Definition: algos.cc:424
static bool yy_pact_value_is_default_(int yyvalue)
Whether the given yypact_ value indicates a defaulted state.
Definition: parse.cc:555
bool lparen
Whether there was a left-paren.
Definition: parse.hh:67
S::const_reverse_iterator const_iterator
Definition: stack.hh:52
void clear()
Definition: stack.hh:98
Definition: a-star.hh:8
#define YYACCEPT
Definition: parse.cc:182
stack_symbol_type & operator=(const stack_symbol_type &that)
Assignment, needed by push_back.
Definition: parse.cc:329
void yy_print_(std::ostream &yyo, const basic_symbol< Base > &yysym) const
Display a symbol type, value and location.
void set_debug_level(debug_level_type l)
Set the current debugging level.
dyn::context ctx_
The context used to read the expression.
Definition: driver.hh:78
#define YYLLOC_DEFAULT(Current, Rhs, N)
Definition: parse.cc:124
driver & driver_
Definition: parse.hh:808
T & as()
Accessor to a built T.
Definition: parse.hh:208
virtual void yystack_print_()
Print the state stack on the debug stream.
static const signed char yypact_ninf_
Definition: parse.hh:655
symbol_number_type type_get() const
The (internal) type number (corresponding to state).
Definition: parse.cc:275
The abstract, non-parameterized, root for all rational expression node types.
Definition: expression.hh:20
#define YYDEBUG
Definition: parse.hh:159
location location_
The inital location.
Definition: driver.hh:76
void push(T &t)
Steal the contents of t.
Definition: stack.hh:83
Last index in yytable_.
Definition: parse.hh:797
static const unsigned short int yyrline_[]
Definition: parse.hh:703
virtual void error(const location_type &loc, const std::string &msg)
Report a syntax error.
Definition: parse.cc:1460
virtual std::string yysyntax_error_(state_type yystate, symbol_number_type yytoken) const
Generate an error message.
Definition: parse.cc:1171
static parser::symbol_type yylex(driver &d)
Use our local scanner object.
Definition: parse.cc:96
An expressionset can implement several different sets of identities on expressions.
Definition: identities.hh:21
Define the vcsn::rat::parser class.
dyn::expression make_atom(const location &loc, const std::string &s)
From a string, generate an expression.
Definition: driver.cc:142
dyn::expression exp
The expression parsed so far.
Definition: parse.hh:65
rat::identities identities() const
Get the identities.
Definition: driver.cc:48
virtual int parse()
Parse.
Definition: parse.cc:567
automaton right_mult(const automaton &aut, const weight &w, const std::string &algo="auto")
The right-mult automaton with w as weight.
Definition: algos.cc:1135
void yypop_(unsigned int n=1)
Pop n symbols the three stacks.
Definition: parse.cc:512
static dyn::context ctx(const driver &d)
Get the context of the driver.
Definition: parse.cc:82
Termination state number.
Definition: parse.hh:800
#define YY_REDUCE_PRINT(Rule)
Definition: parse.cc:174
automaton multiply(const automaton &lhs, const automaton &rhs, const std::string &algo="auto")
Multiply (concatenate) two automata.
Definition: algos.cc:910
semantic_type value
The semantic value.
Definition: parse.hh:435
location(const position &b, const position &e)
Construct a location from b to e.
Definition: location.hh:52
#define YY_NULLPTR
Definition: parse.cc:42
static identities ids(const driver &d)
Get the identities of the driver.
Definition: parse.cc:89
int debug_level_type
Type for debugging levels.
Definition: parse.hh:613
dyn::expression result_
The parsed expression.
Definition: driver.hh:82
dyn::expression make_expression(const location &loc, const class_t &c, bool accept)
From a label class, generate an expression.
Definition: driver.cc:159
virtual ~parser()
Definition: parse.cc:239
int symbol_number_type
Internal symbol number.
Definition: parse.hh:384
static bool yy_table_value_is_error_(int yyvalue)
Whether the given yytable_ value indicates a syntax error.
Definition: parse.cc:561
debug_level_type debug_level() const
The current debugging level.
#define YYERROR
Definition: parse.cc:184
Abstract a location.
Definition: location.hh:47
by_state()
Default constructor.
Definition: parse.cc:251
#define YYUSE(E)
Definition: parse.cc:140
std::unique_ptr< yyFlexLexer > scanner_
The scanner.
Definition: driver.hh:56
"Internal" symbol: element of the stack.
Definition: parse.hh:757
state_type yy_lr_goto_state_(state_type yystate, int yysym)
Compute post-reduction state.
Definition: parse.cc:545
std::set< std::pair< std::string, std::string >> class_t
A set of label ranges.
Definition: fwd.hh:12
void tape_pop()
Pop the tape stack.
Definition: driver.cc:58
void move(basic_symbol &s)
Destructive move, s is emptied into this.
Definition: parse.hh:1066
State and public interface for rational expression parsing.
Definition: driver.hh:17
virtual void yy_reduce_print_(int r)
Report on the debug stream that the rule r is going to be reduced.
static const unsigned char yytable_[]
Definition: parse.hh:680
static const unsigned char yystos_[]
Definition: parse.hh:686
bool rparen
Whether there was a right-paren.
Definition: parse.hh:69
expansion tuple(const std::vector< expansion > &rs)
Build a k-tape expansion from k expansions.
Definition: algos.cc:1459
void tape_inc(const location &l)
Increment the top most tape.
Definition: driver.cc:63
static const unsigned char yydefact_[]
Definition: parse.hh:669
void tape_push()
Push a new tape number on the stack.
Definition: driver.cc:53
static const signed char yydefgoto_[]
Definition: parse.hh:675
S::size_type size() const
Definition: stack.hh:105
expression concatenate(const expression &lhs, const expression &rhs)
Concatenate two expressions.
Definition: algos.cc:154
state_type state
The state.
Definition: parse.hh:753
static const short int yypact_[]
Definition: parse.hh:664
void move(self_type &other)
Move the content of other to this.
Definition: parse.hh:247
STL namespace.
std::size_t num_tapes(const context &ctx)
The number of input tapes.
Definition: algos.cc:1000
context context_of(const automaton &a)
The context of this automaton.
Definition: algos.cc:226
Syntax errors thrown from user actions.
Definition: parse.hh:337
#define YY_SYMBOL_PRINT(Title, Symbol)
Definition: parse.cc:173
stack_symbol_type()
Construct an empty symbol.
Definition: parse.cc:281
dyn::weight make_weight(const location &loc, const std::string &s)
From a string, generate a weight.
Definition: driver.cc:181
std::vector< dyn::context > tape_ctx_
The context for each tape. If single-tape, [0] is ctx_.
Definition: driver.hh:91
static const unsigned char yyr2_[]
Definition: parse.hh:692
void pop(unsigned int n=1)
Definition: stack.hh:91
static const signed char yytable_ninf_
Definition: parse.hh:656
std::string to_string(identities i)
Wrapper around operator<<.
Definition: identities.cc:17
parser(driver &driver__yyarg)
Build a parser object.
Definition: parse.cc:230
static const signed char yycheck_[]
Definition: parse.hh:682
static dyn::expression prefer(const dyn::expression &e, const dyn::expression &f)
Generate an expression for "e <+ f = e % f + f".
Definition: parse.cc:1454
const_iterator begin() const
Definition: stack.hh:112
#define YYCASE_(N, S)
Type access provider for state based symbols.
Definition: parse.hh:729
void set_debug_stream(std::ostream &)
Set the current debugging stream.
void context(const dyn::context &ctx)
Set the expressionset to use from this context.
Definition: driver.cc:31
std::tuple< int, int > irange_type
An integer range, for quantifiers/exponents.
Definition: parse.hh:78
stack_type yystack_
The stack.
Definition: parse.hh:773
void yypush_(const char *m, stack_symbol_type &s)
Push a new state on the stack.
Definition: parse.cc:503
Present a slice of the top of a stack.
Definition: stack.hh:133
Number of tokens.
Definition: parse.hh:803
#define TRY(Loc, Stm)
Definition: parse.cc:60
std::shared_ptr< detail::expression_base > expression
Definition: expression.hh:92
An expression that "remembers" whether it was in parentheses.
Definition: parse.hh:62
static const unsigned char yyr1_[]
Definition: parse.hh:689
static const signed char yypgoto_[]
Definition: parse.hh:672
std::shared_ptr< const detail::context_base > context
A dyn::context.
Definition: fwd.hh:43
void yy_destroy_(const char *yymsg, basic_symbol< Base > &yysym) const
Reclaim the memory associated to a symbol.
Definition: parse.cc:374
location_type location
The location.
Definition: parse.hh:438
#define YY_STACK_PRINT()
Definition: parse.cc:175
expression expression_one(const context &c, rat::identities ids)
The expression for \e.
Definition: algos.cc:415
automaton left_mult(const weight &w, const automaton &aut, const std::string &algo="auto")
The left-multiplication of an automaton with w as weight.
Definition: algos.cc:793
std::ostream * yycdebug_
Definition: parse.hh:711
const_iterator end() const
Definition: stack.hh:119
static std::string yytnamerr_(const char *n)
Convert the symbol name n to a form suitable for a diagnostic.
Definition: parse.cc:197
std::ostream & debug_stream() const
The current debugging stream.
Container::value_type back(const Container &container)
The last member of this Container.
Definition: algorithm.hh:27
static const char *const yytname_[]
For a symbol, its name in clear.
Definition: parse.hh:700
std::ostream & print(const automaton &aut, std::ostream &out, const std::string &format="default")
Print automaton a on o using format format.
Definition: algos.cc:1036