Vcsn  2.4
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 34: // input
292  case 36: // add
293  case 37: // tuple
294  case 41: // exp
295  value.move< braced_expression > (that.value);
296  break;
297 
298  case 43: // class
299  value.move< class_t > (that.value);
300  break;
301 
302  case 42: // weights
303  value.move< dyn::weight > (that.value);
304  break;
305 
306  case 27: // "*"
307  value.move< irange_type > (that.value);
308  break;
309 
310  case 28: // "letter"
311  case 29: // "weight"
312  value.move< std::string > (that.value);
313  break;
314 
315  case 39: // 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 34: // input
335  case 36: // add
336  case 37: // tuple
337  case 41: // exp
338  value.copy< braced_expression > (that.value);
339  break;
340 
341  case 43: // class
342  value.copy< class_t > (that.value);
343  break;
344 
345  case 42: // weights
346  value.copy< dyn::weight > (that.value);
347  break;
348 
349  case 27: // "*"
350  value.copy< irange_type > (that.value);
351  break;
352 
353  case 28: // "letter"
354  case 29: // "weight"
355  value.copy< std::string > (that.value);
356  break;
357 
358  case 39: // 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 28: // "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 29: // "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 34: // 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 36: // add
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 37: // 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 39: // 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 41: // 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 42: // 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 43: // 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 34: // input
698  case 36: // add
699  case 37: // tuple
700  case 41: // exp
701  yylhs.value.build< braced_expression > ();
702  break;
703 
704  case 43: // class
705  yylhs.value.build< class_t > ();
706  break;
707 
708  case 42: // weights
709  yylhs.value.build< dyn::weight > ();
710  break;
711 
712  case 27: // "*"
713  yylhs.value.build< irange_type > ();
714  break;
715 
716  case 28: // "letter"
717  case 29: // "weight"
718  yylhs.value.build< std::string > ();
719  break;
720 
721  case 39: // 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 206 "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 224 "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 225 "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 226 "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 230 "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 231 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
788  { yylhs.value.as< braced_expression > () = dyn::add(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 232 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
794  { yylhs.value.as< braced_expression > () = dyn::compose(yystack_[2].value.as< braced_expression > ().exp, yystack_[0].value.as< braced_expression > ().exp); }
795 #line 796 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
796  break;
797 
798  case 9:
799 #line 238 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
800  { driver_.tape_push(); }
801 #line 802 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
802  break;
803 
804  case 10:
805 #line 239 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
806  {
807  driver_.tape_pop();
808  if (yystack_[0].value.as< std::vector<vcsn::dyn::expression> > ().size() == 1)
809  yylhs.value.as< braced_expression > () = yystack_[0].value.as< std::vector<vcsn::dyn::expression> > ().back();
810  else if (yystack_[0].value.as< std::vector<vcsn::dyn::expression> > ().size() == driver_.tape_ctx_.size())
811  yylhs.value.as< braced_expression > () = vcsn::dyn::tuple(yystack_[0].value.as< std::vector<vcsn::dyn::expression> > ());
812  else
813  throw syntax_error(yylhs.location,
814  "not enough tapes: "
815  + std::to_string(yystack_[0].value.as< std::vector<vcsn::dyn::expression> > ().size())
816  + " expected "
817  + std::to_string(driver_.tape_ctx_.size()));
818  }
819 #line 820 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
820  break;
821 
822  case 11:
823 #line 256 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
824  {
825  yylhs.value.as< std::vector<vcsn::dyn::expression> > ().emplace_back(yystack_[0].value.as< braced_expression > ().exp);
826  }
827 #line 828 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
828  break;
829 
830  case 12:
831 #line 259 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
832  { driver_.tape_inc(yystack_[0].location); }
833 #line 834 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
834  break;
835 
836  case 13:
837 #line 260 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
838  {
839  yylhs.value.as< std::vector<vcsn::dyn::expression> > () = yystack_[3].value.as< std::vector<vcsn::dyn::expression> > ();
840  yylhs.value.as< std::vector<vcsn::dyn::expression> > ().emplace_back(yystack_[0].value.as< braced_expression > ().exp);
841  }
842 #line 843 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
843  break;
844 
845  case 14:
846 #line 267 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
847  { yylhs.value.as< braced_expression > () = dyn::multiply(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 268 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
853  { yylhs.value.as< braced_expression > () = dyn::conjunction(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 269 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
859  { yylhs.value.as< braced_expression > () = dyn::shuffle(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 270 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
865  { yylhs.value.as< braced_expression > () = dyn::infiltrate(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 271 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
871  { yylhs.value.as< braced_expression > () = prefer(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 272 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
877  { yylhs.value.as< braced_expression > () = dyn::ldivide(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 273 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
883  { yylhs.value.as< braced_expression > () = dyn::rdivide(yystack_[2].value.as< braced_expression > ().exp, yystack_[0].value.as< braced_expression > ().exp); }
884 #line 885 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
885  break;
886 
887  case 21:
888 #line 274 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
889  { yylhs.value.as< braced_expression > () = dyn::conjunction(yystack_[2].value.as< braced_expression > ().exp,
890  dyn::complement(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 276 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
896  { yylhs.value.as< braced_expression > () = dyn::lweight(yystack_[1].value.as< dyn::weight > (), yystack_[0].value.as< braced_expression > ().exp); }
897 #line 898 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
898  break;
899 
900  case 23:
901 #line 277 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
902  { yylhs.value.as< braced_expression > () = dyn::rweight(yystack_[1].value.as< braced_expression > ().exp, yystack_[0].value.as< dyn::weight > ()); }
903 #line 904 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
904  break;
905 
906  case 24:
907 #line 279 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
908  {
909  // See README.txt.
910  if (!yystack_[1].value.as< braced_expression > ().rparen && !yystack_[0].value.as< braced_expression > ().lparen)
911  yylhs.value.as< braced_expression > () = dyn::concatenate(yystack_[1].value.as< braced_expression > ().exp, yystack_[0].value.as< braced_expression > ().exp);
912  else
913  {
914  yylhs.value.as< braced_expression > ().exp = dyn::multiply(yystack_[1].value.as< braced_expression > ().exp, yystack_[0].value.as< braced_expression > ().exp);
915  yylhs.value.as< braced_expression > ().lparen = yystack_[1].value.as< braced_expression > ().lparen;
916  yylhs.value.as< braced_expression > ().rparen = yystack_[0].value.as< braced_expression > ().rparen;
917  }
918  }
919 #line 920 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
920  break;
921 
922  case 25:
923 #line 290 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
924  { TRY(yylhs.location,
925  yylhs.value.as< braced_expression > () =
926  dyn::multiply(yystack_[1].value.as< braced_expression > ().exp,
927  std::get<0>(yystack_[0].value.as< irange_type > ()), std::get<1>(yystack_[0].value.as< irange_type > ()))); }
928 #line 929 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
929  break;
930 
931  case 26:
932 #line 294 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
933  { yylhs.value.as< braced_expression > () = dyn::complement(yystack_[1].value.as< braced_expression > ().exp); }
934 #line 935 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
935  break;
936 
937  case 27:
938 #line 295 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
939  { yylhs.value.as< braced_expression > () = dyn::complement(yystack_[0].value.as< braced_expression > ().exp); }
940 #line 941 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
941  break;
942 
943  case 28:
944 #line 296 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
945  { yylhs.value.as< braced_expression > () = dyn::transposition(yystack_[1].value.as< braced_expression > ().exp); }
946 #line 947 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
947  break;
948 
949  case 29:
950 #line 297 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
951  { yylhs.value.as< braced_expression > () = dyn::transpose(yystack_[1].value.as< braced_expression > ().exp); }
952 #line 953 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
953  break;
954 
955  case 30:
956 #line 298 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
958 #line 959 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
959  break;
960 
961  case 31:
962 #line 299 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
964 #line 965 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
965  break;
966 
967  case 32:
968 #line 300 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
969  { yylhs.value.as< braced_expression > () = driver_.make_atom(yystack_[0].location, yystack_[0].value.as< std::string > ()); }
970 #line 971 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
971  break;
972 
973  case 33:
974 #line 301 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
975  { yylhs.value.as< braced_expression > () = driver_.make_expression(yylhs.location, yystack_[1].value.as< class_t > (), 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< braced_expression > () = driver_.make_expression(yylhs.location, yystack_[1].value.as< class_t > (), false); }
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< braced_expression > ().exp = yystack_[1].value.as< braced_expression > ().exp; yylhs.value.as< braced_expression > ().lparen = yylhs.value.as< braced_expression > ().rparen = true; }
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  { yylhs.value.as< dyn::weight > () = driver_.make_weight(yystack_[0].location, yystack_[0].value.as< std::string > ()); }
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< dyn::weight > () = dyn::multiply(driver_.make_weight(yystack_[1].location, yystack_[1].value.as< std::string > ()), yystack_[0].value.as< dyn::weight > ()); }
1000 #line 1001 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
1001  break;
1002 
1003  case 38:
1004 #line 312 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
1005  {}
1006 #line 1007 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
1007  break;
1008 
1009  case 39:
1010 #line 313 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
1011  { 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 > ()); }
1012 #line 1013 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
1013  break;
1014 
1015  case 40:
1016 #line 314 "lib/vcsn/rat/parse.yy" // lalr1.cc:847
1017  { 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 > ()); }
1018 #line 1019 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
1019  break;
1020 
1021 
1022 #line 1023 "./lib/vcsn/rat/parse.cc" // lalr1.cc:847
1023  default:
1024  break;
1025  }
1026  }
1027  catch (const syntax_error& yyexc)
1028  {
1029  error (yyexc);
1030  YYERROR;
1031  }
1032  YY_SYMBOL_PRINT ("-> $$ =", yylhs);
1033  yypop_ (yylen);
1034  yylen = 0;
1035  YY_STACK_PRINT ();
1036 
1037  // Shift the result of the reduction.
1038  yypush_ (YY_NULLPTR, yylhs);
1039  }
1040  goto yynewstate;
1041 
1042  /*--------------------------------------.
1043  | yyerrlab -- here on detecting error. |
1044  `--------------------------------------*/
1045  yyerrlab:
1046  // If not already recovering from an error, report this error.
1047  if (!yyerrstatus_)
1048  {
1049  ++yynerrs_;
1050  error (yyla.location, yysyntax_error_ (yystack_[0].state,
1051  yyempty ? yyempty_ : yyla.type_get ()));
1052  }
1053 
1054 
1055  yyerror_range[1].location = yyla.location;
1056  if (yyerrstatus_ == 3)
1057  {
1058  /* If just tried and failed to reuse lookahead token after an
1059  error, discard it. */
1060 
1061  // Return failure if at end of input.
1062  if (yyla.type_get () == yyeof_)
1063  YYABORT;
1064  else if (!yyempty)
1065  {
1066  yy_destroy_ ("Error: discarding", yyla);
1067  yyempty = true;
1068  }
1069  }
1070 
1071  // Else will try to reuse lookahead token after shifting the error token.
1072  goto yyerrlab1;
1073 
1074 
1075  /*---------------------------------------------------.
1076  | yyerrorlab -- error raised explicitly by YYERROR. |
1077  `---------------------------------------------------*/
1078  yyerrorlab:
1079 
1080  /* Pacify compilers like GCC when the user code never invokes
1081  YYERROR and the label yyerrorlab therefore never appears in user
1082  code. */
1083  if (false)
1084  goto yyerrorlab;
1085  yyerror_range[1].location = yystack_[yylen].location;
1086  /* Do not reclaim the symbols of the rule whose action triggered
1087  this YYERROR. */
1088  yypop_ (yylen);
1089  yylen = 0;
1090  goto yyerrlab1;
1091 
1092  /*-------------------------------------------------------------.
1093  | yyerrlab1 -- common code for both syntax error and YYERROR. |
1094  `-------------------------------------------------------------*/
1095  yyerrlab1:
1096  yyerrstatus_ = 3; // Each real token shifted decrements this.
1097  {
1098  stack_symbol_type error_token;
1099  for (;;)
1100  {
1101  yyn = yypact_[yystack_[0].state];
1102  if (!yy_pact_value_is_default_ (yyn))
1103  {
1104  yyn += yyterror_;
1105  if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
1106  {
1107  yyn = yytable_[yyn];
1108  if (0 < yyn)
1109  break;
1110  }
1111  }
1112 
1113  // Pop the current state because it cannot handle the error token.
1114  if (yystack_.size () == 1)
1115  YYABORT;
1116 
1117  yyerror_range[1].location = yystack_[0].location;
1118  yy_destroy_ ("Error: popping", yystack_[0]);
1119  yypop_ ();
1120  YY_STACK_PRINT ();
1121  }
1122 
1123  yyerror_range[2].location = yyla.location;
1124  YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);
1125 
1126  // Shift the error token.
1127  error_token.state = yyn;
1128  yypush_ ("Shifting", error_token);
1129  }
1130  goto yynewstate;
1131 
1132  // Accept.
1133  yyacceptlab:
1134  yyresult = 0;
1135  goto yyreturn;
1136 
1137  // Abort.
1138  yyabortlab:
1139  yyresult = 1;
1140  goto yyreturn;
1141 
1142  yyreturn:
1143  if (!yyempty)
1144  yy_destroy_ ("Cleanup: discarding lookahead", yyla);
1145 
1146  /* Do not reclaim the symbols of the rule whose action triggered
1147  this YYABORT or YYACCEPT. */
1148  yypop_ (yylen);
1149  while (1 < yystack_.size ())
1150  {
1151  yy_destroy_ ("Cleanup: popping", yystack_[0]);
1152  yypop_ ();
1153  }
1154 
1155  return yyresult;
1156  }
1157  catch (...)
1158  {
1159  YYCDEBUG << "Exception caught: cleaning lookahead and stack"
1160  << std::endl;
1161  // Do not try to display the values of the reclaimed symbols,
1162  // as their printer might throw an exception.
1163  if (!yyempty)
1164  yy_destroy_ (YY_NULLPTR, yyla);
1165 
1166  while (1 < yystack_.size ())
1167  {
1169  yypop_ ();
1170  }
1171  throw;
1172  }
1173  }
1174 
1175  void
1177  {
1178  error (yyexc.location, yyexc.what());
1179  }
1180 
1181  // Generate an error message.
1182  std::string
1184  {
1185  std::string yyres;
1186  // Number of reported tokens (one for the "unexpected", one per
1187  // "expected").
1188  size_t yycount = 0;
1189  // Its maximum.
1190  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1191  // Arguments of yyformat.
1192  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1193 
1194  /* There are many possibilities here to consider:
1195  - If this state is a consistent state with a default action, then
1196  the only way this function was invoked is if the default action
1197  is an error action. In that case, don't check for expected
1198  tokens because there are none.
1199  - The only way there can be no lookahead present (in yytoken) is
1200  if this state is a consistent state with a default action.
1201  Thus, detecting the absence of a lookahead is sufficient to
1202  determine that there is no unexpected or expected token to
1203  report. In that case, just report a simple "syntax error".
1204  - Don't assume there isn't a lookahead just because this state is
1205  a consistent state with a default action. There might have
1206  been a previous inconsistent state, consistent state with a
1207  non-default action, or user semantic action that manipulated
1208  yyla. (However, yyla is currently not documented for users.)
1209  - Of course, the expected token list depends on states to have
1210  correct lookahead information, and it depends on the parser not
1211  to perform extra reductions after fetching a lookahead from the
1212  scanner and before detecting a syntax error. Thus, state
1213  merging (from LALR or IELR) and default reductions corrupt the
1214  expected token list. However, the list is correct for
1215  canonical LR with one exception: it will still contain any
1216  token that will not be accepted due to an error action in a
1217  later state.
1218  */
1219  if (yytoken != yyempty_)
1220  {
1221  yyarg[yycount++] = yytname_[yytoken];
1222  int yyn = yypact_[yystate];
1223  if (!yy_pact_value_is_default_ (yyn))
1224  {
1225  /* Start YYX at -YYN if negative to avoid negative indexes in
1226  YYCHECK. In other words, skip the first -YYN actions for
1227  this state because they are default actions. */
1228  int yyxbegin = yyn < 0 ? -yyn : 0;
1229  // Stay within bounds of both yycheck and yytname.
1230  int yychecklim = yylast_ - yyn + 1;
1231  int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
1232  for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
1233  if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_
1234  && !yy_table_value_is_error_ (yytable_[yyx + yyn]))
1235  {
1236  if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1237  {
1238  yycount = 1;
1239  break;
1240  }
1241  else
1242  yyarg[yycount++] = yytname_[yyx];
1243  }
1244  }
1245  }
1246 
1247  char const* yyformat = YY_NULLPTR;
1248  switch (yycount)
1249  {
1250 #define YYCASE_(N, S) \
1251  case N: \
1252  yyformat = S; \
1253  break
1254  YYCASE_(0, YY_("syntax error"));
1255  YYCASE_(1, YY_("syntax error, unexpected %s"));
1256  YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1257  YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1258  YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1259  YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1260 #undef YYCASE_
1261  }
1262 
1263  // Argument number.
1264  size_t yyi = 0;
1265  for (char const* yyp = yyformat; *yyp; ++yyp)
1266  if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
1267  {
1268  yyres += yytnamerr_ (yyarg[yyi++]);
1269  ++yyp;
1270  }
1271  else
1272  yyres += *yyp;
1273  return yyres;
1274  }
1275 
1276 
1277  const signed char parser::yypact_ninf_ = -26;
1278 
1279  const signed char parser::yytable_ninf_ = -1;
1280 
1281  const short int
1282  parser::yypact_[] =
1283  {
1284  -26, 2, 14, -26, -6, -26, -26, -26, -26, -26,
1285  -26, -6, 4, -26, -26, -26, -26, -25, -5, 52,
1286  -6, -26, 13, 173, -26, -15, 40, -26, -26, -6,
1287  -6, -6, -6, -26, -6, -6, -6, -6, -26, -26,
1288  -26, 192, 149, 100, 43, -26, 17, -26, -6, 130,
1289  130, 154, 130, 192, 79, 106, 154, -26, 7, 52,
1290  -26
1291  };
1292 
1293  const unsigned char
1294  parser::yydefact_[] =
1295  {
1296  9, 0, 3, 6, 0, 1, 9, 4, 9, 5,
1297  2, 0, 38, 9, 31, 30, 32, 36, 10, 11,
1298  0, 8, 7, 27, 38, 0, 0, 37, 12, 0,
1299  0, 0, 0, 26, 0, 0, 0, 0, 28, 29,
1300  25, 24, 23, 22, 0, 33, 39, 35, 0, 15,
1301  17, 19, 16, 14, 18, 21, 20, 34, 0, 13,
1302  40
1303  };
1304 
1305  const signed char
1306  parser::yypgoto_[] =
1307  {
1308  -26, -26, -26, -3, -26, -26, -26, -26, -4, -2,
1309  16
1310  };
1311 
1312  const signed char
1313  parser::yydefgoto_[] =
1314  {
1315  -1, 1, 10, 2, 3, 4, 18, 48, 41, 20,
1316  25
1317  };
1318 
1319  const unsigned char
1320  parser::yytable_[] =
1321  {
1322  19, 11, 5, 21, 17, 22, 45, 23, 12, 13,
1323  26, 14, 24, 46, 28, 27, 43, 42, 6, 6,
1324  15, 42, 16, 17, 7, 49, 50, 51, 52, 58,
1325  53, 54, 55, 56, 8, 60, 9, 0, 43, 42,
1326  44, 42, 0, 0, 59, 6, 0, 42, 42, 42,
1327  42, 42, 42, 42, 42, 29, 30, 42, 31, 11,
1328  8, 32, 47, 33, 57, 34, 12, 13, 35, 14,
1329  36, 46, 0, 0, 0, 37, 38, 39, 15, 40,
1330  16, 17, 29, 30, 0, 31, 11, 0, 32, 0,
1331  33, 0, 34, 12, 13, 0, 14, 36, 0, 0,
1332  0, 0, 37, 38, 39, 15, 40, 16, 17, 29,
1333  30, 33, 31, 11, 0, 32, 0, 33, 0, 34,
1334  12, 13, 0, 14, 38, 39, 0, 40, 0, 37,
1335  38, 39, 15, 40, 16, 17, 31, 11, 0, 0,
1336  0, 33, 0, 34, 12, 13, 0, 14, 0, 0,
1337  0, 0, 0, 37, 38, 39, 15, 40, 16, 17,
1338  31, 11, 0, 12, 13, 33, 14, 34, 12, 13,
1339  0, 14, 0, 0, 0, 15, 0, 16, 38, 39,
1340  15, 40, 16, 17, 33, 0, 34, 12, 13, 0,
1341  14, 0, 0, 0, 0, 0, 0, 38, 39, 15,
1342  40, 16, 17, 33, 0, 0, 12, 13, 0, 14,
1343  0, 0, 0, 0, 0, 0, 38, 39, 15, 40,
1344  16, 17
1345  };
1346 
1347  const signed char
1348  parser::yycheck_[] =
1349  {
1350  4, 7, 0, 6, 29, 8, 21, 11, 14, 15,
1351  13, 17, 8, 28, 19, 17, 20, 19, 5, 5,
1352  26, 23, 28, 29, 10, 29, 30, 31, 32, 12,
1353  34, 35, 36, 37, 20, 28, 22, -1, 42, 41,
1354  24, 43, -1, -1, 48, 5, -1, 49, 50, 51,
1355  52, 53, 54, 55, 56, 3, 4, 59, 6, 7,
1356  20, 9, 22, 11, 21, 13, 14, 15, 16, 17,
1357  18, 28, -1, -1, -1, 23, 24, 25, 26, 27,
1358  28, 29, 3, 4, -1, 6, 7, -1, 9, -1,
1359  11, -1, 13, 14, 15, -1, 17, 18, -1, -1,
1360  -1, -1, 23, 24, 25, 26, 27, 28, 29, 3,
1361  4, 11, 6, 7, -1, 9, -1, 11, -1, 13,
1362  14, 15, -1, 17, 24, 25, -1, 27, -1, 23,
1363  24, 25, 26, 27, 28, 29, 6, 7, -1, -1,
1364  -1, 11, -1, 13, 14, 15, -1, 17, -1, -1,
1365  -1, -1, -1, 23, 24, 25, 26, 27, 28, 29,
1366  6, 7, -1, 14, 15, 11, 17, 13, 14, 15,
1367  -1, 17, -1, -1, -1, 26, -1, 28, 24, 25,
1368  26, 27, 28, 29, 11, -1, 13, 14, 15, -1,
1369  17, -1, -1, -1, -1, -1, -1, 24, 25, 26,
1370  27, 28, 29, 11, -1, -1, 14, 15, -1, 17,
1371  -1, -1, -1, -1, -1, -1, 24, 25, 26, 27,
1372  28, 29
1373  };
1374 
1375  const unsigned char
1376  parser::yystos_[] =
1377  {
1378  0, 34, 36, 37, 38, 0, 5, 10, 20, 22,
1379  35, 7, 14, 15, 17, 26, 28, 29, 39, 41,
1380  42, 36, 36, 41, 8, 43, 36, 42, 19, 3,
1381  4, 6, 9, 11, 13, 16, 18, 23, 24, 25,
1382  27, 41, 42, 41, 43, 21, 28, 22, 40, 41,
1383  41, 41, 41, 41, 41, 41, 41, 21, 12, 41,
1384  28
1385  };
1386 
1387  const unsigned char
1388  parser::yyr1_[] =
1389  {
1390  0, 33, 34, 35, 35, 35, 36, 36, 36, 38,
1391  37, 39, 40, 39, 41, 41, 41, 41, 41, 41,
1392  41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
1393  41, 41, 41, 41, 41, 41, 42, 42, 43, 43,
1394  43
1395  };
1396 
1397  const unsigned char
1398  parser::yyr2_[] =
1399  {
1400  0, 2, 2, 0, 1, 1, 1, 3, 3, 0,
1401  2, 1, 0, 4, 3, 3, 3, 3, 3, 3,
1402  3, 3, 2, 2, 2, 2, 2, 2, 2, 2,
1403  1, 1, 1, 3, 4, 3, 1, 2, 0, 2,
1404  4
1405  };
1406 
1407 
1408 
1409  // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1410  // First, the terminals, then, starting at \a yyntokens_, nonterminals.
1411  const char*
1412  const parser::yytname_[] =
1413  {
1414  "\"end\"", "error", "$undefined", "\"&\"", "\"&:\"", "\"@\"",
1415  "\"{\\\\}\"", "\"!\"", "\"^\"", "\":\"", "\",\"", "\"{c}\"", "\"-\"",
1416  "\".\"", "\"[\"", "\"(\"", "\"<+\"", "\"\\\\e\"", "\"%\"", "\"|\"",
1417  "\"+\"", "\"]\"", "\")\"", "\"{/}\"", "\"{T}\"", "\"{t}\"", "\"\\\\z\"",
1418  "\"*\"", "\"letter\"", "\"weight\"", "CONCAT", "RWEIGHT", "LWEIGHT",
1419  "$accept", "input", "terminator.opt", "add", "tuple", "$@1", "tuple.1",
1420  "$@2", "exp", "weights", "class", YY_NULLPTR
1421  };
1422 
1423 #if YYDEBUG
1424  const unsigned short int
1425  parser::yyrline_[] =
1426  {
1427  0, 205, 205, 224, 225, 226, 230, 231, 232, 238,
1428  238, 255, 259, 259, 267, 268, 269, 270, 271, 272,
1429  273, 274, 276, 277, 278, 290, 294, 295, 296, 297,
1430  298, 299, 300, 301, 302, 303, 307, 308, 312, 313,
1431  314
1432  };
1433 
1434  // Print the state stack on the debug stream.
1435  void
1437  {
1438  *yycdebug_ << "Stack now";
1440  i = yystack_.begin (),
1441  i_end = yystack_.end ();
1442  i != i_end; ++i)
1443  *yycdebug_ << ' ' << i->state;
1444  *yycdebug_ << std::endl;
1445  }
1446 
1447  // Report on the debug stream that the rule \a yyrule is going to be reduced.
1448  void
1449  parser::yy_reduce_print_ (int yyrule)
1450  {
1451  unsigned int yylno = yyrline_[yyrule];
1452  int yynrhs = yyr2_[yyrule];
1453  // Print the symbols being reduced, and their result.
1454  *yycdebug_ << "Reducing stack by rule " << yyrule - 1
1455  << " (line " << yylno << "):" << std::endl;
1456  // The symbols being reduced.
1457  for (int yyi = 0; yyi < yynrhs; yyi++)
1458  YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
1459  yystack_[(yynrhs) - (yyi + 1)]);
1460  }
1461 #endif // YYDEBUG
1462 
1463 
1464 #line 11 "lib/vcsn/rat/parse.yy" // lalr1.cc:1155
1465 } } // vcsn::rat
1466 #line 1467 "./lib/vcsn/rat/parse.cc" // lalr1.cc:1155
1467 #line 317 "lib/vcsn/rat/parse.yy" // lalr1.cc:1156
1468 
1469 
1470 namespace vcsn
1471 {
1472  namespace rat
1473  {
1474  // "e <+ f = e + (f % e) = e + e{c} & f".
1475  static
1477  {
1478  return dyn::add(e, dyn::conjunction(dyn::complement(e), f));
1479  }
1480 
1481  void
1482  vcsn::rat::parser::error(const location_type& l, const std::string& m)
1483  {
1484  driver_.error(l, m);
1485  }
1486  }
1487 }
auto & as()
Extract wrapped typed value.
Definition: value.hh:53
std::ostream * yycdebug_
Definition: parse.hh:721
driver & driver_
Definition: parse.hh:818
bool lparen
Whether there was a left-paren.
Definition: parse.hh:67
static const unsigned char yydefact_[]
Definition: parse.hh:679
automaton transpose(automaton &aut)
Transpose aut.
Definition: algos.cc:1590
void tape_push()
Push a new tape number on the stack.
Definition: driver.cc:54
expression expression_one(const context &c, identities ids)
The expression for \\e.
Definition: algos.cc:510
std::size_t num_tapes(const context &ctx)
The number of input tapes.
Definition: algos.cc:1158
#define YYCASE_(N, S)
Last index in yytable_.
Definition: parse.hh:807
context context_of(const automaton &a)
The context of this automaton.
Definition: algos.cc:303
int debug_level_type
Type for debugging levels.
Definition: parse.hh:623
virtual void error(const location_type &loc, const std::string &msg)
Report a syntax error.
Definition: parse.cc:1482
S::size_type size() const
Definition: stack.hh:105
#define YYACCEPT
Definition: parse.cc:182
void yypop_(unsigned int n=1)
Pop n symbols the three stacks.
Definition: parse.cc:512
Container::value_type back(const Container &container)
The last member of this Container.
Definition: algorithm.hh:37
A complete symbol.
Definition: parse.hh:398
Definition: a-star.hh:8
static const short int yypact_[]
Definition: parse.hh:674
void clear()
Definition: stack.hh:98
automaton tuple(const automaton &lhs, const automaton &rhs)
Build a two-tape automaton from two automata.
Definition: others.cc:219
static parser::symbol_type yylex(driver &d)
Use our local scanner object.
Definition: parse.cc:96
std::ostream & print(const automaton &aut, std::ostream &out=std::cout, const std::string &format="default")
Print automaton a on out using format format.
Definition: algos.cc:1203
void yy_print_(std::ostream &yyo, const basic_symbol< Base > &yysym) const
Display a symbol type, value and location.
stack_symbol_type()
Construct an empty symbol.
Definition: parse.cc:281
Termination state number.
Definition: parse.hh:810
if(exp.max==-1)
Definition: multiply.hh:381
Syntax errors thrown from user actions.
Definition: parse.hh:337
std::tuple< int, int > irange_type
An integer range, for quantifiers/exponents.
Definition: parse.hh:78
symbol_number_type type_get() const
The (internal) type number (corresponding to state).
Definition: parse.cc:275
virtual void yy_reduce_print_(int r)
Report on the debug stream that the rule r is going to be reduced.
static const signed char yypact_ninf_
Definition: parse.hh:665
void tape_inc(const location &l)
Increment the top most tape.
Definition: driver.cc:64
virtual std::string yysyntax_error_(state_type yystate, symbol_number_type yytoken) const
Generate an error message.
Definition: parse.cc:1183
#define YY_NULLPTR
Definition: parse.cc:42
#define YY_REDUCE_PRINT(Rule)
Definition: parse.cc:174
int state_type
State numbers.
Definition: parse.hh:644
int symbol_number_type
Internal symbol number.
Definition: parse.hh:386
stack_symbol_type & operator=(const stack_symbol_type &that)
Assignment, needed by push_back.
Definition: parse.cc:329
void yypush_(const char *m, stack_symbol_type &s)
Push a new state on the stack.
Definition: parse.cc:503
dyn::expression result_
The parsed expression.
Definition: driver.hh:83
location(const position &b, const position &e)
Construct a location from b to e.
Definition: location.hh:52
location location_
The inital location.
Definition: driver.hh:77
void pop(unsigned int n=1)
Definition: stack.hh:91
dyn::weight make_weight(const location &loc, const std::string &s)
From a string, generate a weight.
Definition: driver.cc:182
static dyn::context ctx(const driver &d)
Get the context of the driver.
Definition: parse.cc:82
static const signed char yypgoto_[]
Definition: parse.hh:682
dyn::expression make_atom(const location &loc, const std::string &s)
From a string, generate an expression.
Definition: driver.cc:143
State and public interface for rational expression parsing.
Definition: driver.hh:18
static const unsigned char yystos_[]
Definition: parse.hh:696
#define TRY(Loc, Stm)
Definition: parse.cc:60
#define YY_SYMBOL_PRINT(Title, Symbol)
Definition: parse.cc:173
expression expression_zero(const context &c, identities ids)
The expression for \\z.
Definition: algos.cc:519
#define YYCDEBUG
Definition: parse.cc:172
expression concatenate(const expression &lhs, const expression &rhs)
Concatenate two expressions.
Definition: algos.cc:222
parser(driver &driver__yyarg)
Build a parser object.
Definition: parse.cc:230
std::unique_ptr< yyFlexLexer > scanner_
The scanner.
Definition: driver.hh:57
automaton multiply(const automaton &lhs, const automaton &rhs, const std::string &algo="auto")
Multiply (concatenate) two automata.
Definition: algos.cc:1059
virtual int parse()
Parse.
Definition: parse.cc:567
static const char *const yytname_[]
For a symbol, its name in clear.
Definition: parse.hh:710
Template-less root for contexts.
Definition: context.hh:16
void set_debug_stream(std::ostream &)
Set the current debugging stream.
rat::identities identities() const
Get the identities.
Definition: driver.cc:49
virtual ~parser()
Definition: parse.cc:239
location_type location
The location.
Definition: parse.hh:440
Define the vcsn::rat::parser class.
An expression that "remembers" whether it was in parentheses.
Definition: parse.hh:62
#define YYERROR
Definition: parse.cc:184
void move(by_state &that)
Steal the symbol type from that.
Definition: parse.cc:262
#define YY_(msgid)
Definition: parse.cc:114
std::string to_string(identities i)
Wrapper around operator<<.
Definition: identities.cc:42
T & as()
Accessor to a built T.
Definition: parse.hh:208
static const unsigned char yyr1_[]
Definition: parse.hh:699
#define YYABORT
Definition: parse.cc:183
T & build()
Instantiate an empty T in here.
Definition: parse.hh:192
dyn::context ctx_
The context used to read the expression.
Definition: driver.hh:79
static dyn::expression prefer(const dyn::expression &e, const dyn::expression &f)
Generate an expression for "e <+ f = e % f + f".
Definition: parse.cc:1476
void yy_destroy_(const char *yymsg, basic_symbol< Base > &yysym) const
Reclaim the memory associated to a symbol.
Definition: parse.cc:374
state_type yy_lr_goto_state_(state_type yystate, int yysym)
Compute post-reduction state.
Definition: parse.cc:545
Type access provider for state based symbols.
Definition: parse.hh:739
"Internal" symbol: element of the stack.
Definition: parse.hh:767
static const unsigned char yytable_[]
Definition: parse.hh:690
const_iterator end() const
Definition: stack.hh:119
#define YY_STACK_PRINT()
Definition: parse.cc:175
virtual void yystack_print_()
Print the state stack on the debug stream.
void context(const dyn::context &ctx)
Set the expressionset to use from this context.
Definition: driver.cc:32
Present a slice of the top of a stack.
Definition: stack.hh:133
static std::string yytnamerr_(const char *n)
Convert the symbol name n to a form suitable for a diagnostic.
Definition: parse.cc:197
void push(T &t)
Steal the contents of t.
Definition: stack.hh:83
static const signed char yydefgoto_[]
Definition: parse.hh:685
static const unsigned short int yyrline_[]
Definition: parse.hh:713
state_type state
The state.
Definition: parse.hh:763
STL namespace.
static identities ids(const driver &d)
Get the identities of the driver.
Definition: parse.cc:89
dyn::expression exp
The expression parsed so far.
Definition: parse.hh:65
static bool yy_pact_value_is_default_(int yyvalue)
Whether the given yypact_ value indicates a defaulted state.
Definition: parse.cc:555
void move(self_type &other)
Move the content of other to this.
Definition: parse.hh:247
Abstract a location.
Definition: location.hh:47
static const unsigned char yyr2_[]
Definition: parse.hh:702
const_iterator begin() const
Definition: stack.hh:112
bool rparen
Whether there was a right-paren.
Definition: parse.hh:69
static const signed char yytable_ninf_
Definition: parse.hh:666
automaton rdivide(const automaton &lhs, const automaton &rhs)
Right-division of two automata (lhs / rhs).
Definition: algos.cc:1284
#define YYDEBUG
Definition: parse.hh:159
#define YYUSE(E)
Definition: parse.cc:140
std::ostream & debug_stream() const
The current debugging stream.
static const signed char yycheck_[]
Definition: parse.hh:692
stack_type yystack_
The stack.
Definition: parse.hh:783
std::set< std::pair< std::string, std::string >> class_t
A set of label ranges.
Definition: fwd.hh:12
void move(basic_symbol &s)
Destructive move, s is emptied into this.
Definition: parse.hh:1076
An expressionset can implement several different sets of identities on expressions.
Definition: identities.hh:21
std::vector< dyn::context > tape_ctx_
The context for each tape. If single-tape, [0] is ctx_.
Definition: driver.hh:92
dyn::expression make_expression(const location &loc, const class_t &c, bool accept)
From a label class, generate an expression.
Definition: driver.cc:160
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.
by_state()
Default constructor.
Definition: parse.cc:251
void tape_pop()
Pop the tape stack.
Definition: driver.cc:59
A dyn Value/ValueSet.
Definition: fwd.hh:23
value_impl< detail::expression_tag > expression
Definition: fwd.hh:25
Number of tokens.
Definition: parse.hh:813
S::const_reverse_iterator const_iterator
Definition: stack.hh:52
semantic_type value
The semantic value.
Definition: parse.hh:437
void set_debug_level(debug_level_type l)
Set the current debugging level.
#define YYLLOC_DEFAULT(Current, Rhs, N)
Definition: parse.cc:124
The abstract, non-parameterized, root for all rational expression node types.
Definition: expression.hh:20