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