Vcsn  2.4
Be Rational
parse.cc
Go to the documentation of this file.
1 // A Bison parser, made by GNU Bison 3.0.4.19-fbaf-dirty.
2 
3 // Skeleton implementation for Bison LALR(1) parsers in C++
4 
5 // Copyright (C) 2002-2015 Free Software Foundation, Inc.
6 
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 
20 // As a special exception, you may create a larger work that contains
21 // part or all of the Bison parser skeleton and distribute that work
22 // under terms of your choice, so long as that work isn't itself a
23 // parser generator using the skeleton or a modified version thereof
24 // as a parser skeleton. Alternatively, if you modify or redistribute
25 // the parser skeleton itself, you may (at your option) remove this
26 // special exception, which will cause the skeleton and the resulting
27 // Bison output files to be licensed under the GNU General Public
28 // License without this special exception.
29 
30 // This special exception was added by the Free Software Foundation in
31 // version 2.2 of Bison.
32 
33 
34 // First part of user declarations.
35 
36 #line 37 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:404
37 
38 # ifndef YY_NULLPTR
39 # if defined __cplusplus && 201103L <= __cplusplus
40 # define YY_NULLPTR nullptr
41 # else
42 # define YY_NULLPTR 0
43 # endif
44 # endif
45 
46 #include "parse.hh"
47 
48 // User implementation prologue.
49 
50 #line 51 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:412
51 // Unqualified %code blocks.
52 #line 63 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:413
53 
54  #include <lib/vcsn/rat/driver.hh>
55  #include <lib/vcsn/rat/scan.hh>
56  #include <vcsn/dyn/algos.hh>
57  #include <vcsn/misc/stream.hh>
58  #include <vcsn/dyn/context.hh>
59 
60 #define TRY(Loc, Stm) \
61  try \
62  { \
63  Stm; \
64  } \
65  catch (std::exception& e) \
66  { \
67  error(Loc, e.what()); \
68  YYERROR; \
69  }
70 
71  namespace vcsn
72  {
73  namespace rat
74  {
76  static inline
78  const dyn::expression& f);
79 
81  static inline
83  {
84  return d.context();
85  }
86 
88  static inline
89  identities ids(const driver& d)
90  {
91  return d.identities();
92  }
93 
95  static inline
97  {
98  return d.scanner_->lex(d);
99  }
100  }
101  }
102 
103 #line 104 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:413
104 
105 
106 #ifndef YY_
107 # if defined YYENABLE_NLS && YYENABLE_NLS
108 # if ENABLE_NLS
109 # include <libintl.h> // FIXME: INFRINGES ON USER NAME SPACE.
110 # define YY_(msgid) dgettext ("bison-runtime", msgid)
111 # endif
112 # endif
113 # ifndef YY_
114 # define YY_(msgid) msgid
115 # endif
116 #endif
117 
118 #define YYRHSLOC(Rhs, K) ((Rhs)[K].location)
119 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
120  If N is 0, then set CURRENT to the empty location which ends
121  the previous symbol: RHS[0] (always defined). */
122 
123 # ifndef YYLLOC_DEFAULT
124 # define YYLLOC_DEFAULT(Current, Rhs, N) \
125  do \
126  if (N) \
127  { \
128  (Current).begin = YYRHSLOC (Rhs, 1).begin; \
129  (Current).end = YYRHSLOC (Rhs, N).end; \
130  } \
131  else \
132  { \
133  (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
134  } \
135  while (/*CONSTCOND*/ false)
136 # endif
137 
138 
139 // Suppress unused-variable warnings by "using" E.
140 #define YYUSE(E) ((void) (E))
141 
142 // Enable debugging if requested.
143 #if YYDEBUG
144 
145 // A pseudo ostream that takes yydebug_ into account.
146 # define YYCDEBUG if (yydebug_) (*yycdebug_)
147 
148 # define YY_SYMBOL_PRINT(Title, Symbol) \
149  do { \
150  if (yydebug_) \
151  { \
152  *yycdebug_ << Title << ' '; \
153  yy_print_ (*yycdebug_, Symbol); \
154  *yycdebug_ << std::endl; \
155  } \
156  } while (false)
157 
158 # define YY_REDUCE_PRINT(Rule) \
159  do { \
160  if (yydebug_) \
161  yy_reduce_print_ (Rule); \
162  } while (false)
163 
164 # define YY_STACK_PRINT() \
165  do { \
166  if (yydebug_) \
167  yystack_print_ (); \
168  } while (false)
169 
170 #else // !YYDEBUG
171 
172 # define YYCDEBUG if (false) std::cerr
173 # define YY_SYMBOL_PRINT(Title, Symbol) YYUSE(Symbol)
174 # define YY_REDUCE_PRINT(Rule) static_cast<void>(0)
175 # define YY_STACK_PRINT() static_cast<void>(0)
176 
177 #endif // !YYDEBUG
178 
179 #define yyerrok (yyerrstatus_ = 0)
180 #define yyclearin (yyla.clear ())
181 
182 #define YYACCEPT goto yyacceptlab
183 #define YYABORT goto yyabortlab
184 #define YYERROR goto yyerrorlab
185 #define YYRECOVERING() (!!yyerrstatus_)
186 
187 #line 11 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:479
188 namespace vcsn { namespace rat {
189 #line 190 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:479
190 
191  /* Return YYSTR after stripping away unnecessary quotes and
192  backslashes, so that it's suitable for yyerror. The heuristic is
193  that double-quoting is unnecessary unless the string contains an
194  apostrophe, a comma, or backslash (other than backslash-backslash).
195  YYSTR is taken from yytname. */
196  std::string
197  parser::yytnamerr_ (const char *yystr)
198  {
199  if (*yystr == '"')
200  {
201  std::string yyr = "";
202  char const *yyp = yystr;
203 
204  for (;;)
205  switch (*++yyp)
206  {
207  case '\'':
208  case ',':
209  goto do_not_strip_quotes;
210 
211  case '\\':
212  if (*++yyp != '\\')
213  goto do_not_strip_quotes;
214  // Fall through.
215  default:
216  yyr += *yyp;
217  break;
218 
219  case '"':
220  return yyr;
221  }
222  do_not_strip_quotes: ;
223  }
224 
225  return yystr;
226  }
227 
228 
230  parser::parser (driver& driver__yyarg)
231  :
232 #if YYDEBUG
233  yydebug_ (false),
234  yycdebug_ (&std::cerr),
235 #endif
236  driver_ (driver__yyarg)
237  {}
238 
240  {}
241 
242 
243  /*---------------.
244  | Symbol types. |
245  `---------------*/
246 
247 
248 
249  // by_state.
250  inline
252  : state (empty_state)
253  {}
254 
255  inline
257  : state (other.state)
258  {}
259 
260  inline
261  void
263  {
264  state = empty_state;
265  }
266 
267  inline
268  void
270  {
271  state = that.state;
272  that.clear ();
273  }
274 
275  inline
277  : state (s)
278  {}
279 
280  inline
283  {
284  if (state == empty_state)
285  return empty_symbol;
286  else
287  return yystos_[state];
288  }
289 
290  inline
292  {}
293 
294 
295  inline
297  : super_type (s, that.location)
298  {
299  switch (that.type_get ())
300  {
301  case 34: // input
302  case 36: // add
303  case 37: // tuple
304  case 41: // exp
305  value.move< braced_expression > (that.value);
306  break;
307 
308  case 43: // class
309  value.move< class_t > (that.value);
310  break;
311 
312  case 42: // weights
313  value.move< dyn::weight > (that.value);
314  break;
315 
316  case 27: // "*"
317  value.move< irange_type > (that.value);
318  break;
319 
320  case 28: // "letter"
321  case 29: // "weight"
322  value.move< std::string > (that.value);
323  break;
324 
325  case 39: // tuple.1
326  value.move< std::vector<vcsn::dyn::expression> > (that.value);
327  break;
328 
329  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 34: // input
345  case 36: // add
346  case 37: // tuple
347  case 41: // exp
348  value.copy< braced_expression > (that.value);
349  break;
350 
351  case 43: // class
352  value.copy< class_t > (that.value);
353  break;
354 
355  case 42: // weights
356  value.copy< dyn::weight > (that.value);
357  break;
358 
359  case 27: // "*"
360  value.copy< irange_type > (that.value);
361  break;
362 
363  case 28: // "letter"
364  case 29: // "weight"
365  value.copy< std::string > (that.value);
366  break;
367 
368  case 39: // 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 28: // "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 29: // "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 34: // 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 36: // add
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 37: // 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 39: // 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 41: // 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 42: // 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 43: // 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 34: // input
705  case 36: // add
706  case 37: // tuple
707  case 41: // exp
708  yylhs.value.build< braced_expression > ();
709  break;
710 
711  case 43: // class
712  yylhs.value.build< class_t > ();
713  break;
714 
715  case 42: // weights
716  yylhs.value.build< dyn::weight > ();
717  break;
718 
719  case 27: // "*"
720  yylhs.value.build< irange_type > ();
721  break;
722 
723  case 28: // "letter"
724  case 29: // "weight"
725  yylhs.value.build< std::string > ();
726  break;
727 
728  case 39: // 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 206 "/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 224 "/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 225 "/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 226 "/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 230 "/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 231 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
795  { yylhs.value.as< braced_expression > () = dyn::add(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 232 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
801  { yylhs.value.as< braced_expression > () = dyn::compose(yystack_[2].value.as< braced_expression > ().exp, yystack_[0].value.as< braced_expression > ().exp); }
802 #line 803 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:859
803  break;
804 
805  case 9:
806 #line 238 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
807  { driver_.tape_push(); }
808 #line 809 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:859
809  break;
810 
811  case 10:
812 #line 239 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
813  {
814  driver_.tape_pop();
815  if (yystack_[0].value.as< std::vector<vcsn::dyn::expression> > ().size() == 1)
816  yylhs.value.as< braced_expression > () = yystack_[0].value.as< std::vector<vcsn::dyn::expression> > ().back();
817  else if (yystack_[0].value.as< std::vector<vcsn::dyn::expression> > ().size() == driver_.tape_ctx_.size())
818  yylhs.value.as< braced_expression > () = vcsn::dyn::tuple(yystack_[0].value.as< std::vector<vcsn::dyn::expression> > ());
819  else
820  throw syntax_error(yylhs.location,
821  "not enough tapes: "
822  + std::to_string(yystack_[0].value.as< std::vector<vcsn::dyn::expression> > ().size())
823  + " expected "
824  + std::to_string(driver_.tape_ctx_.size()));
825  }
826 #line 827 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:859
827  break;
828 
829  case 11:
830 #line 256 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
831  {
832  yylhs.value.as< std::vector<vcsn::dyn::expression> > ().emplace_back(yystack_[0].value.as< braced_expression > ().exp);
833  }
834 #line 835 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:859
835  break;
836 
837  case 12:
838 #line 259 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
839  { driver_.tape_inc(yystack_[0].location); }
840 #line 841 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:859
841  break;
842 
843  case 13:
844 #line 260 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
845  {
846  yylhs.value.as< std::vector<vcsn::dyn::expression> > () = yystack_[3].value.as< std::vector<vcsn::dyn::expression> > ();
847  yylhs.value.as< std::vector<vcsn::dyn::expression> > ().emplace_back(yystack_[0].value.as< braced_expression > ().exp);
848  }
849 #line 850 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:859
850  break;
851 
852  case 14:
853 #line 267 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
854  { yylhs.value.as< braced_expression > () = dyn::multiply(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 268 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
860  { yylhs.value.as< braced_expression > () = dyn::conjunction(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 269 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
866  { yylhs.value.as< braced_expression > () = dyn::shuffle(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 270 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
872  { yylhs.value.as< braced_expression > () = dyn::infiltrate(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 271 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
878  { yylhs.value.as< braced_expression > () = prefer(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 272 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
884  { yylhs.value.as< braced_expression > () = dyn::ldivide(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 273 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
890  { yylhs.value.as< braced_expression > () = dyn::rdivide(yystack_[2].value.as< braced_expression > ().exp, yystack_[0].value.as< braced_expression > ().exp); }
891 #line 892 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:859
892  break;
893 
894  case 21:
895 #line 274 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
896  { yylhs.value.as< braced_expression > () = dyn::conjunction(yystack_[2].value.as< braced_expression > ().exp,
897  dyn::complement(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 276 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
903  { yylhs.value.as< braced_expression > () = dyn::lweight(yystack_[1].value.as< dyn::weight > (), 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 23:
908 #line 277 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
909  { yylhs.value.as< braced_expression > () = dyn::rweight(yystack_[1].value.as< braced_expression > ().exp, yystack_[0].value.as< dyn::weight > ()); }
910 #line 911 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:859
911  break;
912 
913  case 24:
914 #line 279 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
915  {
916  // See README.txt.
917  if (!yystack_[1].value.as< braced_expression > ().rparen && !yystack_[0].value.as< braced_expression > ().lparen)
918  yylhs.value.as< braced_expression > () = dyn::concatenate(yystack_[1].value.as< braced_expression > ().exp, yystack_[0].value.as< braced_expression > ().exp);
919  else
920  {
921  yylhs.value.as< braced_expression > ().exp = dyn::multiply(yystack_[1].value.as< braced_expression > ().exp, yystack_[0].value.as< braced_expression > ().exp);
922  yylhs.value.as< braced_expression > ().lparen = yystack_[1].value.as< braced_expression > ().lparen;
923  yylhs.value.as< braced_expression > ().rparen = yystack_[0].value.as< braced_expression > ().rparen;
924  }
925  }
926 #line 927 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:859
927  break;
928 
929  case 25:
930 #line 290 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
931  { TRY(yylhs.location,
932  yylhs.value.as< braced_expression > () =
933  dyn::multiply(yystack_[1].value.as< braced_expression > ().exp,
934  std::get<0>(yystack_[0].value.as< irange_type > ()), std::get<1>(yystack_[0].value.as< irange_type > ()))); }
935 #line 936 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:859
936  break;
937 
938  case 26:
939 #line 294 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
940  { yylhs.value.as< braced_expression > () = dyn::complement(yystack_[1].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 295 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
946  { yylhs.value.as< braced_expression > () = dyn::complement(yystack_[0].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 296 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
952  { yylhs.value.as< braced_expression > () = dyn::transposition(yystack_[1].value.as< braced_expression > ().exp); }
953 #line 954 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:859
954  break;
955 
956  case 29:
957 #line 297 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
958  { yylhs.value.as< braced_expression > () = dyn::transpose(yystack_[1].value.as< braced_expression > ().exp); }
959 #line 960 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:859
960  break;
961 
962  case 30:
963 #line 298 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
965 #line 966 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:859
966  break;
967 
968  case 31:
969 #line 299 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
971 #line 972 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:859
972  break;
973 
974  case 32:
975 #line 300 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
976  { yylhs.value.as< braced_expression > () = driver_.make_atom(yystack_[0].location, yystack_[0].value.as< std::string > ()); }
977 #line 978 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:859
978  break;
979 
980  case 33:
981 #line 301 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
982  { yylhs.value.as< braced_expression > () = driver_.make_expression(yylhs.location, yystack_[1].value.as< class_t > (), 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< braced_expression > () = driver_.make_expression(yylhs.location, yystack_[1].value.as< class_t > (), false); }
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< braced_expression > ().exp = yystack_[1].value.as< braced_expression > ().exp; yylhs.value.as< braced_expression > ().lparen = yylhs.value.as< braced_expression > ().rparen = true; }
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  { yylhs.value.as< dyn::weight > () = driver_.make_weight(yystack_[0].location, yystack_[0].value.as< std::string > ()); }
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< dyn::weight > () = dyn::multiply(driver_.make_weight(yystack_[1].location, yystack_[1].value.as< std::string > ()), yystack_[0].value.as< dyn::weight > ()); }
1007 #line 1008 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:859
1008  break;
1009 
1010  case 38:
1011 #line 312 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
1012  {}
1013 #line 1014 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:859
1014  break;
1015 
1016  case 39:
1017 #line 313 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
1018  { 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 > ()); }
1019 #line 1020 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:859
1020  break;
1021 
1022  case 40:
1023 #line 314 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:859
1024  { 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 > ()); }
1025 #line 1026 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:859
1026  break;
1027 
1028 
1029 #line 1030 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:859
1030  default:
1031  break;
1032  }
1033  }
1034  catch (const syntax_error& yyexc)
1035  {
1036  error (yyexc);
1037  YYERROR;
1038  }
1039  YY_SYMBOL_PRINT ("-> $$ =", yylhs);
1040  yypop_ (yylen);
1041  yylen = 0;
1042  YY_STACK_PRINT ();
1043 
1044  // Shift the result of the reduction.
1045  yypush_ (YY_NULLPTR, yylhs);
1046  }
1047  goto yynewstate;
1048 
1049  /*--------------------------------------.
1050  | yyerrlab -- here on detecting error. |
1051  `--------------------------------------*/
1052  yyerrlab:
1053  // If not already recovering from an error, report this error.
1054  if (!yyerrstatus_)
1055  {
1056  ++yynerrs_;
1057  error (yyla.location, yysyntax_error_ (yystack_[0].state, yyla));
1058  }
1059 
1060 
1061  yyerror_range[1].location = yyla.location;
1062  if (yyerrstatus_ == 3)
1063  {
1064  /* If just tried and failed to reuse lookahead token after an
1065  error, discard it. */
1066 
1067  // Return failure if at end of input.
1068  if (yyla.type_get () == yyeof_)
1069  YYABORT;
1070  else if (!yyla.empty ())
1071  {
1072  yy_destroy_ ("Error: discarding", yyla);
1073  yyla.clear ();
1074  }
1075  }
1076 
1077  // Else will try to reuse lookahead token after shifting the error token.
1078  goto yyerrlab1;
1079 
1080 
1081  /*---------------------------------------------------.
1082  | yyerrorlab -- error raised explicitly by YYERROR. |
1083  `---------------------------------------------------*/
1084  yyerrorlab:
1085 
1086  /* Pacify compilers like GCC when the user code never invokes
1087  YYERROR and the label yyerrorlab therefore never appears in user
1088  code. */
1089  if (false)
1090  goto yyerrorlab;
1091  yyerror_range[1].location = yystack_[yylen].location;
1092  /* Do not reclaim the symbols of the rule whose action triggered
1093  this YYERROR. */
1094  yypop_ (yylen);
1095  yylen = 0;
1096  goto yyerrlab1;
1097 
1098  /*-------------------------------------------------------------.
1099  | yyerrlab1 -- common code for both syntax error and YYERROR. |
1100  `-------------------------------------------------------------*/
1101  yyerrlab1:
1102  yyerrstatus_ = 3; // Each real token shifted decrements this.
1103  {
1104  stack_symbol_type error_token;
1105  for (;;)
1106  {
1107  yyn = yypact_[yystack_[0].state];
1108  if (!yy_pact_value_is_default_ (yyn))
1109  {
1110  yyn += yyterror_;
1111  if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
1112  {
1113  yyn = yytable_[yyn];
1114  if (0 < yyn)
1115  break;
1116  }
1117  }
1118 
1119  // Pop the current state because it cannot handle the error token.
1120  if (yystack_.size () == 1)
1121  YYABORT;
1122 
1123  yyerror_range[1].location = yystack_[0].location;
1124  yy_destroy_ ("Error: popping", yystack_[0]);
1125  yypop_ ();
1126  YY_STACK_PRINT ();
1127  }
1128 
1129  yyerror_range[2].location = yyla.location;
1130  YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);
1131 
1132  // Shift the error token.
1133  error_token.state = yyn;
1134  yypush_ ("Shifting", error_token);
1135  }
1136  goto yynewstate;
1137 
1138  // Accept.
1139  yyacceptlab:
1140  yyresult = 0;
1141  goto yyreturn;
1142 
1143  // Abort.
1144  yyabortlab:
1145  yyresult = 1;
1146  goto yyreturn;
1147 
1148  yyreturn:
1149  if (!yyla.empty ())
1150  yy_destroy_ ("Cleanup: discarding lookahead", yyla);
1151 
1152  /* Do not reclaim the symbols of the rule whose action triggered
1153  this YYABORT or YYACCEPT. */
1154  yypop_ (yylen);
1155  while (1 < yystack_.size ())
1156  {
1157  yy_destroy_ ("Cleanup: popping", yystack_[0]);
1158  yypop_ ();
1159  }
1160 
1161  return yyresult;
1162  }
1163  catch (...)
1164  {
1165  YYCDEBUG << "Exception caught: cleaning lookahead and stack"
1166  << std::endl;
1167  // Do not try to display the values of the reclaimed symbols,
1168  // as their printer might throw an exception.
1169  if (!yyla.empty ())
1170  yy_destroy_ (YY_NULLPTR, yyla);
1171 
1172  while (1 < yystack_.size ())
1173  {
1175  yypop_ ();
1176  }
1177  throw;
1178  }
1179  }
1180 
1181  void
1183  {
1184  error (yyexc.location, yyexc.what());
1185  }
1186 
1187  // Generate an error message.
1188  std::string
1189  parser::yysyntax_error_ (state_type yystate, const symbol_type& yyla) const
1190  {
1191  // Number of reported tokens (one for the "unexpected", one per
1192  // "expected").
1193  size_t yycount = 0;
1194  // Its maximum.
1195  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1196  // Arguments of yyformat.
1197  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1198 
1199  /* There are many possibilities here to consider:
1200  - If this state is a consistent state with a default action, then
1201  the only way this function was invoked is if the default action
1202  is an error action. In that case, don't check for expected
1203  tokens because there are none.
1204  - The only way there can be no lookahead present (in yyla) is
1205  if this state is a consistent state with a default action.
1206  Thus, detecting the absence of a lookahead is sufficient to
1207  determine that there is no unexpected or expected token to
1208  report. In that case, just report a simple "syntax error".
1209  - Don't assume there isn't a lookahead just because this state is
1210  a consistent state with a default action. There might have
1211  been a previous inconsistent state, consistent state with a
1212  non-default action, or user semantic action that manipulated
1213  yyla. (However, yyla is currently not documented for users.)
1214  - Of course, the expected token list depends on states to have
1215  correct lookahead information, and it depends on the parser not
1216  to perform extra reductions after fetching a lookahead from the
1217  scanner and before detecting a syntax error. Thus, state
1218  merging (from LALR or IELR) and default reductions corrupt the
1219  expected token list. However, the list is correct for
1220  canonical LR with one exception: it will still contain any
1221  token that will not be accepted due to an error action in a
1222  later state.
1223  */
1224  if (!yyla.empty ())
1225  {
1226  int yytoken = yyla.type_get ();
1227  yyarg[yycount++] = yytname_[yytoken];
1228  int yyn = yypact_[yystate];
1229  if (!yy_pact_value_is_default_ (yyn))
1230  {
1231  /* Start YYX at -YYN if negative to avoid negative indexes in
1232  YYCHECK. In other words, skip the first -YYN actions for
1233  this state because they are default actions. */
1234  int yyxbegin = yyn < 0 ? -yyn : 0;
1235  // Stay within bounds of both yycheck and yytname.
1236  int yychecklim = yylast_ - yyn + 1;
1237  int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
1238  for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
1239  if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_
1240  && !yy_table_value_is_error_ (yytable_[yyx + yyn]))
1241  {
1242  if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1243  {
1244  yycount = 1;
1245  break;
1246  }
1247  else
1248  yyarg[yycount++] = yytname_[yyx];
1249  }
1250  }
1251  }
1252 
1253  char const* yyformat = YY_NULLPTR;
1254  switch (yycount)
1255  {
1256 #define YYCASE_(N, S) \
1257  case N: \
1258  yyformat = S; \
1259  break
1260  YYCASE_(0, YY_("syntax error"));
1261  YYCASE_(1, YY_("syntax error, unexpected %s"));
1262  YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1263  YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1264  YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1265  YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1266 #undef YYCASE_
1267  }
1268 
1269  std::string yyres;
1270  // Argument number.
1271  size_t yyi = 0;
1272  for (char const* yyp = yyformat; *yyp; ++yyp)
1273  if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
1274  {
1275  yyres += yytnamerr_ (yyarg[yyi++]);
1276  ++yyp;
1277  }
1278  else
1279  yyres += *yyp;
1280  return yyres;
1281  }
1282 
1283 
1284  const signed char parser::yypact_ninf_ = -26;
1285 
1286  const signed char parser::yytable_ninf_ = -1;
1287 
1288  const short int
1289  parser::yypact_[] =
1290  {
1291  -26, 2, 14, -26, -6, -26, -26, -26, -26, -26,
1292  -26, -6, 4, -26, -26, -26, -26, -25, -5, 52,
1293  -6, -26, 13, 173, -26, -15, 40, -26, -26, -6,
1294  -6, -6, -6, -26, -6, -6, -6, -6, -26, -26,
1295  -26, 192, 149, 100, 43, -26, 17, -26, -6, 130,
1296  130, 154, 130, 192, 79, 106, 154, -26, 7, 52,
1297  -26
1298  };
1299 
1300  const unsigned char
1301  parser::yydefact_[] =
1302  {
1303  9, 0, 3, 6, 0, 1, 9, 4, 9, 5,
1304  2, 0, 38, 9, 31, 30, 32, 36, 10, 11,
1305  0, 8, 7, 27, 38, 0, 0, 37, 12, 0,
1306  0, 0, 0, 26, 0, 0, 0, 0, 28, 29,
1307  25, 24, 23, 22, 0, 33, 39, 35, 0, 15,
1308  17, 19, 16, 14, 18, 21, 20, 34, 0, 13,
1309  40
1310  };
1311 
1312  const signed char
1313  parser::yypgoto_[] =
1314  {
1315  -26, -26, -26, -3, -26, -26, -26, -26, -4, -2,
1316  16
1317  };
1318 
1319  const signed char
1320  parser::yydefgoto_[] =
1321  {
1322  -1, 1, 10, 2, 3, 4, 18, 48, 41, 20,
1323  25
1324  };
1325 
1326  const unsigned char
1327  parser::yytable_[] =
1328  {
1329  19, 11, 5, 21, 17, 22, 45, 23, 12, 13,
1330  26, 14, 24, 46, 28, 27, 43, 42, 6, 6,
1331  15, 42, 16, 17, 7, 49, 50, 51, 52, 58,
1332  53, 54, 55, 56, 8, 60, 9, 0, 43, 42,
1333  44, 42, 0, 0, 59, 6, 0, 42, 42, 42,
1334  42, 42, 42, 42, 42, 29, 30, 42, 31, 11,
1335  8, 32, 47, 33, 57, 34, 12, 13, 35, 14,
1336  36, 46, 0, 0, 0, 37, 38, 39, 15, 40,
1337  16, 17, 29, 30, 0, 31, 11, 0, 32, 0,
1338  33, 0, 34, 12, 13, 0, 14, 36, 0, 0,
1339  0, 0, 37, 38, 39, 15, 40, 16, 17, 29,
1340  30, 33, 31, 11, 0, 32, 0, 33, 0, 34,
1341  12, 13, 0, 14, 38, 39, 0, 40, 0, 37,
1342  38, 39, 15, 40, 16, 17, 31, 11, 0, 0,
1343  0, 33, 0, 34, 12, 13, 0, 14, 0, 0,
1344  0, 0, 0, 37, 38, 39, 15, 40, 16, 17,
1345  31, 11, 0, 12, 13, 33, 14, 34, 12, 13,
1346  0, 14, 0, 0, 0, 15, 0, 16, 38, 39,
1347  15, 40, 16, 17, 33, 0, 34, 12, 13, 0,
1348  14, 0, 0, 0, 0, 0, 0, 38, 39, 15,
1349  40, 16, 17, 33, 0, 0, 12, 13, 0, 14,
1350  0, 0, 0, 0, 0, 0, 38, 39, 15, 40,
1351  16, 17
1352  };
1353 
1354  const signed char
1355  parser::yycheck_[] =
1356  {
1357  4, 7, 0, 6, 29, 8, 21, 11, 14, 15,
1358  13, 17, 8, 28, 19, 17, 20, 19, 5, 5,
1359  26, 23, 28, 29, 10, 29, 30, 31, 32, 12,
1360  34, 35, 36, 37, 20, 28, 22, -1, 42, 41,
1361  24, 43, -1, -1, 48, 5, -1, 49, 50, 51,
1362  52, 53, 54, 55, 56, 3, 4, 59, 6, 7,
1363  20, 9, 22, 11, 21, 13, 14, 15, 16, 17,
1364  18, 28, -1, -1, -1, 23, 24, 25, 26, 27,
1365  28, 29, 3, 4, -1, 6, 7, -1, 9, -1,
1366  11, -1, 13, 14, 15, -1, 17, 18, -1, -1,
1367  -1, -1, 23, 24, 25, 26, 27, 28, 29, 3,
1368  4, 11, 6, 7, -1, 9, -1, 11, -1, 13,
1369  14, 15, -1, 17, 24, 25, -1, 27, -1, 23,
1370  24, 25, 26, 27, 28, 29, 6, 7, -1, -1,
1371  -1, 11, -1, 13, 14, 15, -1, 17, -1, -1,
1372  -1, -1, -1, 23, 24, 25, 26, 27, 28, 29,
1373  6, 7, -1, 14, 15, 11, 17, 13, 14, 15,
1374  -1, 17, -1, -1, -1, 26, -1, 28, 24, 25,
1375  26, 27, 28, 29, 11, -1, 13, 14, 15, -1,
1376  17, -1, -1, -1, -1, -1, -1, 24, 25, 26,
1377  27, 28, 29, 11, -1, -1, 14, 15, -1, 17,
1378  -1, -1, -1, -1, -1, -1, 24, 25, 26, 27,
1379  28, 29
1380  };
1381 
1382  const unsigned char
1383  parser::yystos_[] =
1384  {
1385  0, 34, 36, 37, 38, 0, 5, 10, 20, 22,
1386  35, 7, 14, 15, 17, 26, 28, 29, 39, 41,
1387  42, 36, 36, 41, 8, 43, 36, 42, 19, 3,
1388  4, 6, 9, 11, 13, 16, 18, 23, 24, 25,
1389  27, 41, 42, 41, 43, 21, 28, 22, 40, 41,
1390  41, 41, 41, 41, 41, 41, 41, 21, 12, 41,
1391  28
1392  };
1393 
1394  const unsigned char
1395  parser::yyr1_[] =
1396  {
1397  0, 33, 34, 35, 35, 35, 36, 36, 36, 38,
1398  37, 39, 40, 39, 41, 41, 41, 41, 41, 41,
1399  41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
1400  41, 41, 41, 41, 41, 41, 42, 42, 43, 43,
1401  43
1402  };
1403 
1404  const unsigned char
1405  parser::yyr2_[] =
1406  {
1407  0, 2, 2, 0, 1, 1, 1, 3, 3, 0,
1408  2, 1, 0, 4, 3, 3, 3, 3, 3, 3,
1409  3, 3, 2, 2, 2, 2, 2, 2, 2, 2,
1410  1, 1, 1, 3, 4, 3, 1, 2, 0, 2,
1411  4
1412  };
1413 
1414 
1415 
1416  // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1417  // First, the terminals, then, starting at \a yyntokens_, nonterminals.
1418  const char*
1419  const parser::yytname_[] =
1420  {
1421  "\"end\"", "error", "$undefined", "\"&\"", "\"&:\"", "\"@\"",
1422  "\"{\\\\}\"", "\"!\"", "\"^\"", "\":\"", "\",\"", "\"{c}\"", "\"-\"",
1423  "\".\"", "\"[\"", "\"(\"", "\"<+\"", "\"\\\\e\"", "\"%\"", "\"|\"",
1424  "\"+\"", "\"]\"", "\")\"", "\"{/}\"", "\"{T}\"", "\"{t}\"", "\"\\\\z\"",
1425  "\"*\"", "\"letter\"", "\"weight\"", "CONCAT", "RWEIGHT", "LWEIGHT",
1426  "$accept", "input", "terminator.opt", "add", "tuple", "$@1", "tuple.1",
1427  "$@2", "exp", "weights", "class", YY_NULLPTR
1428  };
1429 
1430 #if YYDEBUG
1431  const unsigned short int
1432  parser::yyrline_[] =
1433  {
1434  0, 205, 205, 224, 225, 226, 230, 231, 232, 238,
1435  238, 255, 259, 259, 267, 268, 269, 270, 271, 272,
1436  273, 274, 276, 277, 278, 290, 294, 295, 296, 297,
1437  298, 299, 300, 301, 302, 303, 307, 308, 312, 313,
1438  314
1439  };
1440 
1441  // Print the state stack on the debug stream.
1442  void
1444  {
1445  *yycdebug_ << "Stack now";
1447  i = yystack_.begin (),
1448  i_end = yystack_.end ();
1449  i != i_end; ++i)
1450  *yycdebug_ << ' ' << i->state;
1451  *yycdebug_ << std::endl;
1452  }
1453 
1454  // Report on the debug stream that the rule \a yyrule is going to be reduced.
1455  void
1457  {
1458  unsigned int yylno = yyrline_[yyrule];
1459  int yynrhs = yyr2_[yyrule];
1460  // Print the symbols being reduced, and their result.
1461  *yycdebug_ << "Reducing stack by rule " << yyrule - 1
1462  << " (line " << yylno << "):" << std::endl;
1463  // The symbols being reduced.
1464  for (int yyi = 0; yyi < yynrhs; yyi++)
1465  YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
1466  yystack_[(yynrhs) - (yyi + 1)]);
1467  }
1468 #endif // YYDEBUG
1469 
1470 
1471 #line 11 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:1167
1472 } } // vcsn::rat
1473 #line 1474 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.cc" // lalr1.cc:1167
1474 #line 317 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:1168
1475 
1476 
1477 namespace vcsn
1478 {
1479  namespace rat
1480  {
1481  // "e <+ f = e + (f % e) = e + e{c} & f".
1482  static
1484  {
1485  return dyn::add(e, dyn::conjunction(dyn::complement(e), f));
1486  }
1487 
1488  void
1489  vcsn::rat::parser::error(const location_type& l, const std::string& m)
1490  {
1491  driver_.error(l, m);
1492  }
1493  }
1494 }
static const unsigned char yyr1_[]
Definition: parse.hh:712
STL namespace.
#define YYCDEBUG
Definition: parse.cc:146
stack_symbol_type()
Construct an empty symbol.
Definition: parse.cc:291
bool lparen
Whether there was a left-paren.
Definition: parse.hh:67
static dyn::context ctx(const driver &d)
Get the context of the driver.
Definition: parse.cc:82
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
automaton tuple(const automaton &lhs, const automaton &rhs)
Build a two-tape automaton from two automata.
Definition: others.cc:219
void tape_push()
Push a new tape number on the stack.
Definition: driver.cc:54
int debug_level_type
Type for debugging levels.
Definition: parse.hh:636
std::ostream * yycdebug_
Definition: parse.hh:734
#define YYABORT
Definition: parse.cc:183
const_iterator end() const
Definition: stack.hh:119
"Internal" symbol: element of the stack.
Definition: parse.hh:785
void push(T &t)
Steal the contents of t.
Definition: stack.hh:83
#define YYERROR
Definition: parse.cc:184
static const signed char yycheck_[]
Definition: parse.hh:705
Present a slice of the top of a stack.
Definition: stack.hh:133
static identities ids(const driver &d)
Get the identities of the driver.
Definition: parse.cc:89
#define YY_(msgid)
Definition: parse.cc:114
std::ostream & debug_stream() const
The current debugging stream.
Definition: parse.cc:533
location(const position &b, const position &e)
Construct a location from b to e.
Definition: location.hh:52
A complete symbol.
Definition: parse.hh:402
Number of tokens.
Definition: parse.hh:830
stack_symbol_type & operator=(const stack_symbol_type &that)
Assignment, needed by push_back.
Definition: parse.cc:339
#define YYLLOC_DEFAULT(Current, Rhs, N)
Definition: parse.cc:124
expression expression_zero(const context &c, identities ids)
The expression for \\z.
Definition: constant.hh:24
virtual std::string yysyntax_error_(state_type yystate, const symbol_type &yyla) const
Generate an error message.
Definition: parse.cc:1189
const_iterator begin() const
Definition: stack.hh:112
void move(self_type &other)
Move the content of other to this.
Definition: parse.hh:248
symbol_number_type type_get() const
The (internal) type number (corresponding to state).
Definition: parse.cc:282
std::set< std::pair< std::string, std::string >> class_t
A set of label ranges.
Definition: fwd.hh:12
if(exp.max==-1)
Definition: multiply.hh:381
automaton rdivide(const automaton &lhs, const automaton &rhs)
Right-division of two automata (lhs / rhs).
Definition: conjunction.hh:767
void tape_inc(const location &l)
Increment the top most tape.
Definition: driver.cc:64
virtual int parse()
Parse.
Definition: parse.cc:581
Syntax errors thrown from user actions.
Definition: parse.hh:338
static const short int yypact_[]
Definition: parse.hh:687
Last index in yytable_.
Definition: parse.hh:825
static const unsigned char yystos_[]
Definition: parse.hh:709
virtual void yy_reduce_print_(int r)
Report on the debug stream that the rule r is going to be reduced.
Definition: parse.cc:1456
T & as()
Accessor to a built T.
Definition: parse.hh:209
#define YYCASE_(N, S)
dyn::expression result_
The parsed expression.
Definition: driver.hh:83
int symbol_number_type
Symbol type: an internal symbol number.
Definition: parse.hh:387
debug_level_type debug_level() const
The current debugging level.
Definition: parse.cc:546
location location_
The inital location.
Definition: driver.hh:77
static const unsigned char yyr2_[]
Definition: parse.hh:715
dyn::weight make_weight(const location &loc, const std::string &s)
From a string, generate a weight.
Definition: driver.cc:182
static const unsigned short int yyrline_[]
Definition: parse.hh:726
static const signed char yytable_ninf_
Definition: parse.hh:679
dyn::expression make_atom(const location &loc, const std::string &s)
From a string, generate an expression.
Definition: driver.cc:143
#define TRY(Loc, Stm)
Definition: parse.cc:60
State and public interface for rational expression parsing.
Definition: driver.hh:18
void yy_print_(std::ostream &yyo, const basic_symbol< Base > &yysym) const
Display a symbol type, value and location.
Definition: parse.cc:393
Definition: a-star.hh:8
std::unique_ptr< yyFlexLexer > scanner_
The scanner.
Definition: driver.hh:57
static bool yy_table_value_is_error_(int yyvalue)
Whether the given yytable_ value indicates a syntax error.
Definition: parse.cc:575
#define YY_SYMBOL_PRINT(Title, Symbol)
Definition: parse.cc:148
virtual void error(const location_type &loc, const std::string &msg)
Report a syntax error.
Definition: parse.cc:1489
bool empty() const
Whether empty.
Definition: parse.hh:1104
Template-less root for contexts.
Definition: context.hh:16
S::size_type size() const
Definition: stack.hh:105
rat::identities identities() const
Get the identities.
Definition: driver.cc:49
location_type location
The location.
Definition: parse.hh:451
static const signed char yypgoto_[]
Definition: parse.hh:695
An expression that "remembers" whether it was in parentheses.
Definition: parse.hh:62
static parser::symbol_type yylex(driver &d)
Use our local scanner object.
Definition: parse.cc:96
std::size_t num_tapes(const context &ctx)
The number of input tapes.
std::vector< stack_symbol_type >::const_reverse_iterator const_iterator
Definition: stack.hh:52
#define YYACCEPT
Definition: parse.cc:182
void yypush_(const char *m, stack_symbol_type &s)
Push a new state on the stack.
Definition: parse.cc:517
void yy_destroy_(const char *yymsg, basic_symbol< Base > &yysym) const
Reclaim the memory associated to a symbol.
Definition: parse.cc:384
virtual void yystack_print_()
Print the state stack on the debug stream.
Definition: parse.cc:1443
void move(by_state &that)
Steal the symbol type from that.
Definition: parse.cc:269
std::tuple< int, int > irange_type
An integer range, for quantifiers/exponents.
Definition: parse.hh:78
static const unsigned char yytable_[]
Definition: parse.hh:703
dyn::context ctx_
The context used to read the expression.
Definition: driver.hh:79
void clear()
Destroy contents, and record that is empty.
Definition: parse.hh:1051
expression expression_one(const context &c, identities ids)
The expression for \\e.
Definition: constant.hh:15
Type access provider for state based symbols.
Definition: parse.hh:752
static std::string yytnamerr_(const char *n)
Convert the symbol name n to a form suitable for a diagnostic.
Definition: parse.cc:197
void set_debug_stream(std::ostream &)
Set the current debugging stream.
Definition: parse.cc:539
static const signed char yydefgoto_[]
Definition: parse.hh:698
stack_type yystack_
The stack.
Definition: parse.hh:801
static const signed char yypact_ninf_
Definition: parse.hh:678
void context(const dyn::context &ctx)
Set the expressionset to use from this context.
Definition: driver.cc:32
#define YYDEBUG
Definition: parse.hh:160
An expressionset can implement several different sets of identities on expressions.
Definition: identities.hh:21
#define YYUSE(E)
Definition: parse.cc:140
expression concatenate(const expression &lhs, const expression &rhs)
Concatenate two expressions.
state_type state
The state.
Definition: parse.hh:781
parser(driver &driver__yyarg)
Build a parser object.
Definition: parse.cc:230
automaton multiply(const automaton &lhs, const automaton &rhs, const std::string &algo="auto")
Multiply (concatenate) two automata.
Definition: multiply.hh:169
auto & as()
Extract wrapped typed value.
Definition: value.hh:53
#define YY_NULLPTR
Definition: parse.cc:42
void clear()
Definition: stack.hh:98
dyn::expression exp
The expression parsed so far.
Definition: parse.hh:65
void set_debug_level(debug_level_type l)
Set the current debugging level.
Definition: parse.cc:552
state_type yy_lr_goto_state_(state_type yystate, int yysym)
Compute post-reduction state.
Definition: parse.cc:559
virtual ~parser()
Definition: parse.cc:239
Container::value_type back(const Container &container)
The last member of this Container.
Definition: algorithm.hh:37
context context_of(const automaton &a)
The context of this automaton.
Definition: make-context.hh:63
#define YY_REDUCE_PRINT(Rule)
Definition: parse.cc:158
void pop(unsigned int n=1)
Definition: stack.hh:91
A dyn Value/ValueSet.
Definition: fwd.hh:23
Termination state number.
Definition: parse.hh:827
void clear()
Record that this symbol is empty.
Definition: parse.cc:262
value_impl< detail::expression_tag > expression
Definition: fwd.hh:25
bool rparen
Whether there was a right-paren.
Definition: parse.hh:69
#define YY_STACK_PRINT()
Definition: parse.cc:164
automaton transpose(automaton &aut)
Transpose aut.
Definition: transpose.hh:273
driver & driver_
Definition: parse.hh:835
void move(basic_symbol &s)
Destructive move, s is emptied into this.
Definition: parse.hh:1112
static bool yy_pact_value_is_default_(int yyvalue)
Whether the given yypact_ value indicates a defaulted state.
Definition: parse.cc:569
int state_type
State numbers.
Definition: parse.hh:657
std::vector< dyn::context > tape_ctx_
The context for each tape. If single-tape, [0] is ctx_.
Definition: driver.hh:92
dyn::expression make_expression(const location &loc, const class_t &c, bool accept)
From a label class, generate an expression.
Definition: driver.cc:160
static const unsigned char yydefact_[]
Definition: parse.hh:692
by_state()
Default constructor.
Definition: parse.cc:251
static const char *const yytname_[]
For a symbol, its name in clear.
Definition: parse.hh:723
void tape_pop()
Pop the tape stack.
Definition: driver.cc:59
std::string to_string(identities i)
Wrapper around operator<<.
Definition: identities.cc:42
Abstract a location.
Definition: location.hh:47
semantic_type value
The semantic value.
Definition: parse.hh:448
static dyn::expression prefer(const dyn::expression &e, const dyn::expression &f)
Generate an expression for "e <+ f = e % f + f".
Definition: parse.cc:1483
Define the vcsn::rat::parser class.
T & build()
Instantiate an empty T in here.
Definition: parse.hh:193
void yypop_(unsigned int n=1)
Pop n symbols the three stacks.
Definition: parse.cc:526
The abstract, non-parameterized, root for all rational expression node types.
Definition: expression.hh:20