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