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