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