Vcsn  2.0
Be Rational
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
parse.cc
Go to the documentation of this file.
1 // A Bison parser, made by GNU Bison 3.0.2.13-aa0e.
2 
3 // Skeleton implementation for Bison LALR(1) parsers in C++
4 
5 // Copyright (C) 2002-2013 Free Software Foundation, Inc.
6 
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 
20 // As a special exception, you may create a larger work that contains
21 // part or all of the Bison parser skeleton and distribute that work
22 // under terms of your choice, so long as that work isn't itself a
23 // parser generator using the skeleton or a modified version thereof
24 // as a parser skeleton. Alternatively, if you modify or redistribute
25 // the parser skeleton itself, you may (at your option) remove this
26 // special exception, which will cause the skeleton and the resulting
27 // Bison output files to be licensed under the GNU General Public
28 // License without this special exception.
29 
30 // This special exception was added by the Free Software Foundation in
31 // version 2.2 of Bison.
32 // // "%code top" blocks.
33 #line 89 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:392
34 
35  #include <cassert>
36 
38 #define MAKE(Kind, ...) \
39  driver_.ratexpset_->Kind(__VA_ARGS__)
40 
42 #define TRY(Loc, Stm) \
43  try \
44  { \
45  Stm; \
46  } \
47  catch (std::exception& e) \
48  { \
49  error(Loc, e.what()); \
50  YYERROR; \
51  }
52 
53 #line 54 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:392
54 
55 
56 // First part of user declarations.
57 
58 #line 59 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:399
59 
60 # ifndef YY_NULLPTR
61 # if defined __cplusplus && 201103L <= __cplusplus
62 # define YY_NULLPTR nullptr
63 # else
64 # define YY_NULLPTR 0
65 # endif
66 # endif
67 
68 #include "parse.hh"
69 
70 // User implementation prologue.
71 
72 #line 73 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:407
73 // Unqualified %code blocks.
74 #line 57 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:408
75 
76  #include <vcsn/dyn/ratexpset.hh>
77  #include <lib/vcsn/rat/driver.hh>
78  #include <lib/vcsn/rat/scan.hh>
79 
80  namespace vcsn
81  {
82  namespace rat
83  {
85  static
86  exp_t power(const dyn::ratexpset& rs, exp_t e, std::tuple<int, int> range);
87 
89  static
90  exp_t prefer(const dyn::ratexpset& rs, exp_t e, exp_t f);
91 
93  static
94  inline
96  yylex(driver& driver_)
97  {
98  return driver_.scanner_->lex(driver_);
99  }
100  }
101  }
102 
103 #line 104 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:408
104 
105 
106 #ifndef YY_
107 # if defined YYENABLE_NLS && YYENABLE_NLS
108 # if ENABLE_NLS
109 # include <libintl.h> // FIXME: INFRINGES ON USER NAME SPACE.
110 # define YY_(msgid) dgettext ("bison-runtime", msgid)
111 # endif
112 # endif
113 # ifndef YY_
114 # define YY_(msgid) msgid
115 # endif
116 #endif
117 
118 #define YYRHSLOC(Rhs, K) ((Rhs)[K].location)
119 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
120  If N is 0, then set CURRENT to the empty location which ends
121  the previous symbol: RHS[0] (always defined). */
122 
123 # ifndef YYLLOC_DEFAULT
124 # define YYLLOC_DEFAULT(Current, Rhs, N) \
125  do \
126  if (N) \
127  { \
128  (Current).begin = YYRHSLOC (Rhs, 1).begin; \
129  (Current).end = YYRHSLOC (Rhs, N).end; \
130  } \
131  else \
132  { \
133  (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
134  } \
135  while (/*CONSTCOND*/ false)
136 # endif
137 
138 
139 // Suppress unused-variable warnings by "using" E.
140 #define YYUSE(E) ((void) (E))
141 
142 // Enable debugging if requested.
143 #if YYDEBUG
144 
145 // A pseudo ostream that takes yydebug_ into account.
146 # define YYCDEBUG if (yydebug_) (*yycdebug_)
147 
148 # define YY_SYMBOL_PRINT(Title, Symbol) \
149  do { \
150  if (yydebug_) \
151  { \
152  *yycdebug_ << Title << ' '; \
153  yy_print_ (*yycdebug_, Symbol); \
154  *yycdebug_ << std::endl; \
155  } \
156  } while (false)
157 
158 # define YY_REDUCE_PRINT(Rule) \
159  do { \
160  if (yydebug_) \
161  yy_reduce_print_ (Rule); \
162  } while (false)
163 
164 # define YY_STACK_PRINT() \
165  do { \
166  if (yydebug_) \
167  yystack_print_ (); \
168  } while (false)
169 
170 #else // !YYDEBUG
171 
172 # define YYCDEBUG if (false) std::cerr
173 # define YY_SYMBOL_PRINT(Title, Symbol) YYUSE(Symbol)
174 # define YY_REDUCE_PRINT(Rule) static_cast<void>(0)
175 # define YY_STACK_PRINT() static_cast<void>(0)
176 
177 #endif // !YYDEBUG
178 
179 #define yyerrok (yyerrstatus_ = 0)
180 #define yyclearin (yyempty = true)
181 
182 #define YYACCEPT goto yyacceptlab
183 #define YYABORT goto yyabortlab
184 #define YYERROR goto yyerrorlab
185 #define YYRECOVERING() (!!yyerrstatus_)
186 
187 #line 11 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:474
188 namespace vcsn { namespace rat {
189 #line 190 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:474
190 
191  /* Return YYSTR after stripping away unnecessary quotes and
192  backslashes, so that it's suitable for yyerror. The heuristic is
193  that double-quoting is unnecessary unless the string contains an
194  apostrophe, a comma, or backslash (other than backslash-backslash).
195  YYSTR is taken from yytname. */
196  std::string
197  parser::yytnamerr_ (const char *yystr)
198  {
199  if (*yystr == '"')
200  {
201  std::string yyr = "";
202  char const *yyp = yystr;
203 
204  for (;;)
205  switch (*++yyp)
206  {
207  case '\'':
208  case ',':
209  goto do_not_strip_quotes;
210 
211  case '\\':
212  if (*++yyp != '\\')
213  goto do_not_strip_quotes;
214  // Fall through.
215  default:
216  yyr += *yyp;
217  break;
218 
219  case '"':
220  return yyr;
221  }
222  do_not_strip_quotes: ;
223  }
224 
225  return yystr;
226  }
227 
228 
230  parser::parser (driver& driver__yyarg)
231  :
232 #if YYDEBUG
233  yydebug_ (false),
234  yycdebug_ (&std::cerr),
235 #endif
236  driver_ (driver__yyarg)
237  {}
238 
240  {}
241 
242 
243  /*---------------.
244  | Symbol types. |
245  `---------------*/
246 
247 
248 
249  // by_state.
250  inline
252  : state (empty)
253  {}
254 
255  inline
257  : state (other.state)
258  {}
259 
260  inline
261  void
263  {
264  state = that.state;
265  that.state = empty;
266  }
267 
268  inline
270  : state (s)
271  {}
272 
273  inline
276  {
277  return state == empty ? 0 : yystos_[state];
278  }
279 
280  inline
282  {}
283 
284 
285  inline
287  : super_type (s, that.location)
288  {
289  switch (that.type_get ())
290  {
291  case 29: // input
292  case 31: // exp
293  case 32: // weights
294  value.move< braced_ratexp > (that.value);
295  break;
296 
297  case 22: // "*"
298  value.move< irange_type > (that.value);
299  break;
300 
301  case 33: // class
302  value.move< std::set<std::pair<std::string,std::string>> > (that.value);
303  break;
304 
305  case 23: // "letter"
306  case 24: // "weight"
307  value.move< std::string > (that.value);
308  break;
309 
310  default:
311  break;
312  }
313 
314  // that is emptied.
315  that.type = empty;
316  }
317 
318  inline
321  {
322  state = that.state;
323  switch (that.type_get ())
324  {
325  case 29: // input
326  case 31: // exp
327  case 32: // weights
328  value.copy< braced_ratexp > (that.value);
329  break;
330 
331  case 22: // "*"
332  value.copy< irange_type > (that.value);
333  break;
334 
335  case 33: // class
336  value.copy< std::set<std::pair<std::string,std::string>> > (that.value);
337  break;
338 
339  case 23: // "letter"
340  case 24: // "weight"
341  value.copy< std::string > (that.value);
342  break;
343 
344  default:
345  break;
346  }
347 
348  location = that.location;
349  return *this;
350  }
351 
352 
353  template <typename Base>
354  inline
355  void
356  parser::yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const
357  {
358  if (yymsg)
359  YY_SYMBOL_PRINT (yymsg, yysym);
360  }
361 
362 #if YYDEBUG
363  template <typename Base>
364  void
365  parser::yy_print_ (std::ostream& yyo,
366  const basic_symbol<Base>& yysym) const
367  {
368  std::ostream& yyoutput = yyo;
369  YYUSE (yyoutput);
370  symbol_number_type yytype = yysym.type_get ();
371  yyo << (yytype < yyntokens_ ? "token" : "nterm")
372  << ' ' << yytname_[yytype] << " ("
373  << yysym.location << ": ";
374  switch (yytype)
375  {
376  case 23: // "letter"
377 
378 #line 114 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:617
379  { yyo << '"' << yysym.value.template as< std::string > () << '"'; }
380 #line 381 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:617
381  break;
382 
383  case 24: // "weight"
384 
385 #line 121 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:617
386  { yyo << '<' << yysym.value.template as< std::string > () << '>'; }
387 #line 388 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:617
388  break;
389 
390  case 29: // input
391 //-
392 //-#line 123 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:617
393 //- {
394 //- driver_.ratexpset_->print(yysym.value.template as< braced_ratexp > ().exp, yyo);
395 //- yyo << (yysym.value.template as< braced_ratexp > ().lparen ? " (lpar, " : " (no lpar, ");
396 //- yyo << (yysym.value.template as< braced_ratexp > ().rparen ? "rpar)" : "no rpar)");
397 //-}
398 //-#line 399 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:617
399 //- break;
400 
401  case 31: // exp
402 //-
403 //-#line 123 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:617
404 //- {
405 //- driver_.ratexpset_->print(yysym.value.template as< braced_ratexp > ().exp, yyo);
406 //- yyo << (yysym.value.template as< braced_ratexp > ().lparen ? " (lpar, " : " (no lpar, ");
407 //- yyo << (yysym.value.template as< braced_ratexp > ().rparen ? "rpar)" : "no rpar)");
408 //-}
409 //-#line 410 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:617
410 //- break;
411 
412  case 32: // weights
413 
414 #line 123 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:617
415  {
416  driver_.ratexpset_->print(yysym.value.template as< braced_ratexp > ().exp, yyo);
417  yyo << (yysym.value.template as< braced_ratexp > ().lparen ? " (lpar, " : " (no lpar, ");
418  yyo << (yysym.value.template as< braced_ratexp > ().rparen ? "rpar)" : "no rpar)");
419 }
420 #line 421 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:617
421  break;
422 
423  case 33: // class
424 
425 #line 116 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:617
426  {
427  yyo << '[';
428  for (auto c: yysym.value.template as< std::set<std::pair<std::string,std::string>> > ()) yyo << c.first << "-" << c.second;
429  yyo << ']';
430 }
431 #line 432 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:617
432  break;
433 
434 
435  default:
436  break;
437  }
438  yyo << ')';
439  }
440 #endif
441 
442  inline
443  void
444  parser::yypush_ (const char* m, state_type s, symbol_type& sym)
445  {
446  stack_symbol_type t (s, sym);
447  yypush_ (m, t);
448  }
449 
450  inline
451  void
452  parser::yypush_ (const char* m, stack_symbol_type& s)
453  {
454  if (m)
455  YY_SYMBOL_PRINT (m, s);
456  yystack_.push (s);
457  }
458 
459  inline
460  void
461  parser::yypop_ (unsigned int n)
462  {
463  yystack_.pop (n);
464  }
465 
466 #if YYDEBUG
467  std::ostream&
469  {
470  return *yycdebug_;
471  }
472 
473  void
474  parser::set_debug_stream (std::ostream& o)
475  {
476  yycdebug_ = &o;
477  }
478 
479 
482  {
483  return yydebug_;
484  }
485 
486  void
488  {
489  yydebug_ = l;
490  }
491 #endif // YYDEBUG
492 
493  inline parser::state_type
495  {
496  int yyr = yypgoto_[yysym - yyntokens_] + yystate;
497  if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
498  return yytable_[yyr];
499  else
500  return yydefgoto_[yysym - yyntokens_];
501  }
502 
503  inline bool
505  {
506  return yyvalue == yypact_ninf_;
507  }
508 
509  inline bool
511  {
512  return yyvalue == yytable_ninf_;
513  }
514 
515  int
517  {
519  bool yyempty = true;
520 
521  // State.
522  int yyn;
524  int yylen = 0;
525 
526  // Error handling.
527  int yynerrs_ = 0;
528  int yyerrstatus_ = 0;
529 
531  symbol_type yyla;
532 
534  stack_symbol_type yyerror_range[3];
535 
537  int yyresult;
538 
539  // FIXME: This shoud be completely indented. It is not yet to
540  // avoid gratuitous conflicts when merging into the master branch.
541  try
542  {
543  YYCDEBUG << "Starting parse" << std::endl;
544 
545 
546  // User initialization code.
547  #line 110 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:725
548 {
549  yyla.location = driver_.location_;
550 }
551 
552 #line 553 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:725
553 
554  /* Initialize the stack. The initial state will be set in
555  yynewstate, since the latter expects the semantical and the
556  location values to have been already stored, initialize these
557  stacks with a primary value. */
558  yystack_.clear ();
559  yypush_ (YY_NULLPTR, 0, yyla);
560 
561  // A new symbol was pushed on the stack.
562  yynewstate:
563  YYCDEBUG << "Entering state " << yystack_[0].state << std::endl;
564 
565  // Accept?
566  if (yystack_[0].state == yyfinal_)
567  goto yyacceptlab;
568 
569  goto yybackup;
570 
571  // Backup.
572  yybackup:
573 
574  // Try to take a decision without lookahead.
575  yyn = yypact_[yystack_[0].state];
576  if (yy_pact_value_is_default_ (yyn))
577  goto yydefault;
578 
579  // Read a lookahead token.
580  if (yyempty)
581  {
582  YYCDEBUG << "Reading a token: ";
583  try
584  {
585  symbol_type yylookahead (yylex (driver_));
586  yyla.move (yylookahead);
587  }
588  catch (const syntax_error& yyexc)
589  {
590  error (yyexc);
591  goto yyerrlab1;
592  }
593  yyempty = false;
594  }
595  YY_SYMBOL_PRINT ("Next token is", yyla);
596 
597  /* If the proper action on seeing token YYLA.TYPE is to reduce or
598  to detect an error, take that action. */
599  yyn += yyla.type_get ();
600  if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.type_get ())
601  goto yydefault;
602 
603  // Reduce or error.
604  yyn = yytable_[yyn];
605  if (yyn <= 0)
606  {
607  if (yy_table_value_is_error_ (yyn))
608  goto yyerrlab;
609  yyn = -yyn;
610  goto yyreduce;
611  }
612 
613  // Discard the token being shifted.
614  yyempty = true;
615 
616  // Count tokens shifted since error; after three, turn off error status.
617  if (yyerrstatus_)
618  --yyerrstatus_;
619 
620  // Shift the lookahead token.
621  yypush_ ("Shifting", yyn, yyla);
622  goto yynewstate;
623 
624  /*-----------------------------------------------------------.
625  | yydefault -- do the default action for the current state. |
626  `-----------------------------------------------------------*/
627  yydefault:
628  yyn = yydefact_[yystack_[0].state];
629  if (yyn == 0)
630  goto yyerrlab;
631  goto yyreduce;
632 
633  /*-----------------------------.
634  | yyreduce -- Do a reduction. |
635  `-----------------------------*/
636  yyreduce:
637  yylen = yyr2_[yyn];
638  {
639  stack_symbol_type yylhs;
640  yylhs.state = yy_lr_goto_state_(yystack_[yylen].state, yyr1_[yyn]);
641  /* Variants are always initialized to an empty instance of the
642  correct type. The default '$$ = $1' action is NOT applied
643  when using variants. */
644  switch (yyr1_[yyn])
645  {
646  case 29: // input
647  case 31: // exp
648  case 32: // weights
649  yylhs.value.build< braced_ratexp > ();
650  break;
651 
652  case 22: // "*"
653  yylhs.value.build< irange_type > ();
654  break;
655 
656  case 33: // class
657  yylhs.value.build< std::set<std::pair<std::string,std::string>> > ();
658  break;
659 
660  case 23: // "letter"
661  case 24: // "weight"
662  yylhs.value.build< std::string > ();
663  break;
664 
665  default:
666  break;
667  }
668 
669 
670  // Compute the default @$.
671  {
673  YYLLOC_DEFAULT (yylhs.location, slice, yylen);
674  }
675 
676  // Perform the reduction.
677  YY_REDUCE_PRINT (yyn);
678  try
679  {
680  switch (yyn)
681  {
682  case 2:
683 #line 178 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
684  {
685  driver_.result_ = yystack_[0].value.as< braced_ratexp > ().exp;
686  yylhs.value.as< braced_ratexp > ().exp = yystack_[0].value.as< braced_ratexp > ().exp;
687  }
688 #line 689 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
689  break;
690 
691  case 3:
692 #line 182 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
693  {
694  driver_.result_ = yystack_[1].value.as< braced_ratexp > ().exp;
695  yylhs.value.as< braced_ratexp > ().exp = yystack_[1].value.as< braced_ratexp > ().exp;
696  YYACCEPT;
697  }
698 #line 699 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
699  break;
700 
701  case 4:
702 #line 190 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
703  { driver_.scanner_->yyin->putback(','); }
704 #line 705 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
705  break;
706 
707  case 5:
708 #line 191 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
709  { driver_.scanner_->yyin->putback(')'); }
710 #line 711 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
711  break;
712 
713  case 6:
714 #line 195 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
715  { yylhs.value.as< braced_ratexp > () = MAKE(mul, yystack_[2].value.as< braced_ratexp > ().exp, yystack_[0].value.as< braced_ratexp > ().exp); }
716 #line 717 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
717  break;
718 
719  case 7:
720 #line 196 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
721  { yylhs.value.as< braced_ratexp > () = MAKE(conjunction, yystack_[2].value.as< braced_ratexp > ().exp, yystack_[0].value.as< braced_ratexp > ().exp); }
722 #line 723 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
723  break;
724 
725  case 8:
726 #line 197 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
727  { yylhs.value.as< braced_ratexp > () = MAKE(shuffle, yystack_[2].value.as< braced_ratexp > ().exp, yystack_[0].value.as< braced_ratexp > ().exp); }
728 #line 729 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
729  break;
730 
731  case 9:
732 #line 198 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
733  { yylhs.value.as< braced_ratexp > () = MAKE(add, yystack_[2].value.as< braced_ratexp > ().exp, yystack_[0].value.as< braced_ratexp > ().exp); }
734 #line 735 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
735  break;
736 
737  case 10:
738 #line 199 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
739  { yylhs.value.as< braced_ratexp > () = prefer(driver_.ratexpset_, yystack_[2].value.as< braced_ratexp > ().exp, yystack_[0].value.as< braced_ratexp > ().exp); }
740 #line 741 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
741  break;
742 
743  case 11:
744 #line 200 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
745  { yylhs.value.as< braced_ratexp > () = MAKE(ldiv, yystack_[2].value.as< braced_ratexp > ().exp, yystack_[0].value.as< braced_ratexp > ().exp); }
746 #line 747 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
747  break;
748 
749  case 12:
750 #line 201 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
751  { yylhs.value.as< braced_ratexp > () = MAKE(rdiv, yystack_[2].value.as< braced_ratexp > ().exp, yystack_[0].value.as< braced_ratexp > ().exp); }
752 #line 753 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
753  break;
754 
755  case 13:
756 #line 202 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
757  { yylhs.value.as< braced_ratexp > () = MAKE(conjunction,
758  yystack_[2].value.as< braced_ratexp > ().exp, MAKE(complement, yystack_[0].value.as< braced_ratexp > ().exp)); }
759 #line 760 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
760  break;
761 
762  case 14:
763 //-#line 204 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
764 //- { yylhs.value.as< braced_ratexp > () = MAKE(mul, yystack_[1].value.as< braced_ratexp > ().exp, yystack_[0].value.as< braced_ratexp > ().exp); }
765 //-#line 766 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
766 //- break;
767 
768  case 15:
769 #line 205 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
770  { yylhs.value.as< braced_ratexp > () = MAKE(mul, yystack_[1].value.as< braced_ratexp > ().exp, yystack_[0].value.as< braced_ratexp > ().exp); }
771 #line 772 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
772  break;
773 
774  case 16:
775 #line 207 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
776  {
777  // See README.txt.
778  if (!yystack_[1].value.as< braced_ratexp > ().rparen && !yystack_[0].value.as< braced_ratexp > ().lparen
779  // This is very ugly, but lets us parse "<2>abcd" as <2>(abcd)
780  // rather than (<2>a)(bcd).
781  && driver_.ratexpset_->identities() != rat::identities::series)
782  yylhs.value.as< braced_ratexp > () = MAKE(concat, yystack_[1].value.as< braced_ratexp > ().exp, yystack_[0].value.as< braced_ratexp > ().exp);
783  else
784  {
785  yylhs.value.as< braced_ratexp > ().exp = MAKE(mul, yystack_[1].value.as< braced_ratexp > ().exp, yystack_[0].value.as< braced_ratexp > ().exp);
786  yylhs.value.as< braced_ratexp > ().lparen = yystack_[1].value.as< braced_ratexp > ().lparen;
787  yylhs.value.as< braced_ratexp > ().rparen = yystack_[0].value.as< braced_ratexp > ().rparen;
788  }
789  }
790 #line 791 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
791  break;
792 
793  case 17:
794 #line 221 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
795  { yylhs.value.as< braced_ratexp > () = power(driver_.ratexpset_, yystack_[1].value.as< braced_ratexp > ().exp, yystack_[0].value.as< irange_type > ()); }
796 #line 797 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
797  break;
798 
799  case 18:
800 #line 222 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
801  { yylhs.value.as< braced_ratexp > () = MAKE(complement, yystack_[1].value.as< braced_ratexp > ().exp); }
802 #line 803 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
803  break;
804 
805  case 19:
806 #line 223 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
807  { yylhs.value.as< braced_ratexp > () = MAKE(transposition, yystack_[1].value.as< braced_ratexp > ().exp); }
808 #line 809 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
809  break;
810 
811  case 20:
812 #line 224 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
813  { yylhs.value.as< braced_ratexp > () = MAKE(zero); }
814 #line 815 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
815  break;
816 
817  case 21:
818 #line 225 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
819  { yylhs.value.as< braced_ratexp > () = MAKE(one); }
820 #line 821 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
821  break;
822 
823  case 22:
824 #line 226 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
825  { TRY(yylhs.location, yylhs.value.as< braced_ratexp > () = MAKE(atom, yystack_[0].value.as< std::string > ())); }
826 #line 827 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
827  break;
828 
829  case 23:
830 #line 227 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
831  { yylhs.value.as< braced_ratexp > () = MAKE(letter_class, yystack_[1].value.as< std::set<std::pair<std::string,std::string>> > (), true); }
832 #line 833 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
833  break;
834 
835  case 24:
836 #line 228 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
837  { yylhs.value.as< braced_ratexp > () = MAKE(letter_class, yystack_[1].value.as< std::set<std::pair<std::string,std::string>> > (), false); }
838 #line 839 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
839  break;
840 
841  case 25:
842 #line 229 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
843  { yylhs.value.as< braced_ratexp > ().exp = yystack_[1].value.as< braced_ratexp > ().exp; yylhs.value.as< braced_ratexp > ().lparen = yylhs.value.as< braced_ratexp > ().rparen = true; }
844 #line 845 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
845  break;
846 
847  case 26:
848 #line 233 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
849  { TRY(yylhs.location + 1, yylhs.value.as< braced_ratexp > () = MAKE(lmul, yystack_[0].value.as< std::string > (), MAKE(one))); }
850 #line 851 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
851  break;
852 
853  case 27:
854 #line 234 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
855  { TRY(yylhs.location + 1, yylhs.value.as< braced_ratexp > () = MAKE(lmul, yystack_[1].value.as< std::string > (), yystack_[0].value.as< braced_ratexp > ().exp)); }
856 #line 857 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
857  break;
858 
859  case 28:
860 #line 238 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
861  {}
862 #line 863 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
863  break;
864 
865  case 29:
866 #line 239 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
867  { yylhs.value.as< std::set<std::pair<std::string,std::string>> > () = yystack_[1].value.as< std::set<std::pair<std::string,std::string>> > (); yylhs.value.as< std::set<std::pair<std::string,std::string>> > ().emplace(yystack_[0].value.as< std::string > (), yystack_[0].value.as< std::string > ()); }
868 #line 869 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
869  break;
870 
871  case 30:
872 #line 240 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:847
873  { yylhs.value.as< std::set<std::pair<std::string,std::string>> > () = yystack_[3].value.as< std::set<std::pair<std::string,std::string>> > (); yylhs.value.as< std::set<std::pair<std::string,std::string>> > ().emplace(yystack_[2].value.as< std::string > (), yystack_[0].value.as< std::string > ()); }
874 #line 875 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
875  break;
876 
877 
878 #line 879 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:847
879  default:
880  break;
881  }
882  }
883  catch (const syntax_error& yyexc)
884  {
885  error (yyexc);
886  YYERROR;
887  }
888  YY_SYMBOL_PRINT ("-> $$ =", yylhs);
889  yypop_ (yylen);
890  yylen = 0;
891  YY_STACK_PRINT ();
892 
893  // Shift the result of the reduction.
894  yypush_ (YY_NULLPTR, yylhs);
895  }
896  goto yynewstate;
897 
898  /*--------------------------------------.
899  | yyerrlab -- here on detecting error. |
900  `--------------------------------------*/
901  yyerrlab:
902  // If not already recovering from an error, report this error.
903  if (!yyerrstatus_)
904  {
905  ++yynerrs_;
906  error (yyla.location, yysyntax_error_ (yystack_[0].state,
907  yyempty ? yyempty_ : yyla.type_get ()));
908  }
909 
910 
911  yyerror_range[1].location = yyla.location;
912  if (yyerrstatus_ == 3)
913  {
914  /* If just tried and failed to reuse lookahead token after an
915  error, discard it. */
916 
917  // Return failure if at end of input.
918  if (yyla.type_get () == yyeof_)
919  YYABORT;
920  else if (!yyempty)
921  {
922  yy_destroy_ ("Error: discarding", yyla);
923  yyempty = true;
924  }
925  }
926 
927  // Else will try to reuse lookahead token after shifting the error token.
928  goto yyerrlab1;
929 
930 
931  /*---------------------------------------------------.
932  | yyerrorlab -- error raised explicitly by YYERROR. |
933  `---------------------------------------------------*/
934  yyerrorlab:
935 
936  /* Pacify compilers like GCC when the user code never invokes
937  YYERROR and the label yyerrorlab therefore never appears in user
938  code. */
939  if (false)
940  goto yyerrorlab;
941  yyerror_range[1].location = yystack_[yylen - 1].location;
942  /* Do not reclaim the symbols of the rule whose action triggered
943  this YYERROR. */
944  yypop_ (yylen);
945  yylen = 0;
946  goto yyerrlab1;
947 
948  /*-------------------------------------------------------------.
949  | yyerrlab1 -- common code for both syntax error and YYERROR. |
950  `-------------------------------------------------------------*/
951  yyerrlab1:
952  yyerrstatus_ = 3; // Each real token shifted decrements this.
953  {
954  stack_symbol_type error_token;
955  for (;;)
956  {
957  yyn = yypact_[yystack_[0].state];
958  if (!yy_pact_value_is_default_ (yyn))
959  {
960  yyn += yyterror_;
961  if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
962  {
963  yyn = yytable_[yyn];
964  if (0 < yyn)
965  break;
966  }
967  }
968 
969  // Pop the current state because it cannot handle the error token.
970  if (yystack_.size () == 1)
971  YYABORT;
972 
973  yyerror_range[1].location = yystack_[0].location;
974  yy_destroy_ ("Error: popping", yystack_[0]);
975  yypop_ ();
976  YY_STACK_PRINT ();
977  }
978 
979  yyerror_range[2].location = yyla.location;
980  YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);
981 
982  // Shift the error token.
983  error_token.state = yyn;
984  yypush_ ("Shifting", error_token);
985  }
986  goto yynewstate;
987 
988  // Accept.
989  yyacceptlab:
990  yyresult = 0;
991  goto yyreturn;
992 
993  // Abort.
994  yyabortlab:
995  yyresult = 1;
996  goto yyreturn;
997 
998  yyreturn:
999  if (!yyempty)
1000  yy_destroy_ ("Cleanup: discarding lookahead", yyla);
1001 
1002  /* Do not reclaim the symbols of the rule whose action triggered
1003  this YYABORT or YYACCEPT. */
1004  yypop_ (yylen);
1005  while (1 < yystack_.size ())
1006  {
1007  yy_destroy_ ("Cleanup: popping", yystack_[0]);
1008  yypop_ ();
1009  }
1010 
1011  return yyresult;
1012  }
1013  catch (...)
1014  {
1015  YYCDEBUG << "Exception caught: cleaning lookahead and stack"
1016  << std::endl;
1017  // Do not try to display the values of the reclaimed symbols,
1018  // as their printer might throw an exception.
1019  if (!yyempty)
1020  yy_destroy_ (YY_NULLPTR, yyla);
1021 
1022  while (1 < yystack_.size ())
1023  {
1025  yypop_ ();
1026  }
1027  throw;
1028  }
1029  }
1030 
1031  void
1033  {
1034  error (yyexc.location, yyexc.what());
1035  }
1036 
1037  // Generate an error message.
1038  std::string
1040  {
1041  std::string yyres;
1042  // Number of reported tokens (one for the "unexpected", one per
1043  // "expected").
1044  size_t yycount = 0;
1045  // Its maximum.
1046  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1047  // Arguments of yyformat.
1048  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1049 
1050  /* There are many possibilities here to consider:
1051  - If this state is a consistent state with a default action, then
1052  the only way this function was invoked is if the default action
1053  is an error action. In that case, don't check for expected
1054  tokens because there are none.
1055  - The only way there can be no lookahead present (in yytoken) is
1056  if this state is a consistent state with a default action.
1057  Thus, detecting the absence of a lookahead is sufficient to
1058  determine that there is no unexpected or expected token to
1059  report. In that case, just report a simple "syntax error".
1060  - Don't assume there isn't a lookahead just because this state is
1061  a consistent state with a default action. There might have
1062  been a previous inconsistent state, consistent state with a
1063  non-default action, or user semantic action that manipulated
1064  yyla. (However, yyla is currently not documented for users.)
1065  - Of course, the expected token list depends on states to have
1066  correct lookahead information, and it depends on the parser not
1067  to perform extra reductions after fetching a lookahead from the
1068  scanner and before detecting a syntax error. Thus, state
1069  merging (from LALR or IELR) and default reductions corrupt the
1070  expected token list. However, the list is correct for
1071  canonical LR with one exception: it will still contain any
1072  token that will not be accepted due to an error action in a
1073  later state.
1074  */
1075  if (yytoken != yyempty_)
1076  {
1077  yyarg[yycount++] = yytname_[yytoken];
1078  int yyn = yypact_[yystate];
1079  if (!yy_pact_value_is_default_ (yyn))
1080  {
1081  /* Start YYX at -YYN if negative to avoid negative indexes in
1082  YYCHECK. In other words, skip the first -YYN actions for
1083  this state because they are default actions. */
1084  int yyxbegin = yyn < 0 ? -yyn : 0;
1085  // Stay within bounds of both yycheck and yytname.
1086  int yychecklim = yylast_ - yyn + 1;
1087  int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
1088  for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
1089  if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_
1090  && !yy_table_value_is_error_ (yytable_[yyx + yyn]))
1091  {
1092  if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1093  {
1094  yycount = 1;
1095  break;
1096  }
1097  else
1098  yyarg[yycount++] = yytname_[yyx];
1099  }
1100  }
1101  }
1102 
1103  char const* yyformat = YY_NULLPTR;
1104  switch (yycount)
1105  {
1106 #define YYCASE_(N, S) \
1107  case N: \
1108  yyformat = S; \
1109  break
1110  YYCASE_(0, YY_("syntax error"));
1111  YYCASE_(1, YY_("syntax error, unexpected %s"));
1112  YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1113  YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1114  YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1115  YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1116 #undef YYCASE_
1117  }
1118 
1119  // Argument number.
1120  size_t yyi = 0;
1121  for (char const* yyp = yyformat; *yyp; ++yyp)
1122  if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
1123  {
1124  yyres += yytnamerr_ (yyarg[yyi++]);
1125  ++yyp;
1126  }
1127  else
1128  yyres += *yyp;
1129  return yyres;
1130  }
1131 
1132 
1133  const signed char parser::yypact_ninf_ = -21;
1134 
1135  const signed char parser::yytable_ninf_ = -1;
1136 
1137  const short int
1138  parser::yypact_[] =
1139  {
1140  167, -2, 167, -21, -21, -21, -20, 11, 59, 167,
1141  -21, 22, 81, -21, -21, 167, 167, 167, -21, -21,
1142  167, 167, 167, 167, -21, -21, 167, -21, -21, 5,
1143  -11, 133, 25, -21, 6, -21, -3, 146, -3, 163,
1144  125, 103, 103, 146, -21, -9, -21
1145  };
1146 
1147  const unsigned char
1148  parser::yydefact_[] =
1149  {
1150  0, 28, 0, 21, 20, 22, 26, 0, 2, 0,
1151  28, 0, 0, 27, 1, 0, 0, 0, 4, 18,
1152  0, 0, 0, 0, 5, 19, 0, 17, 3, 16,
1153  15, 14, 0, 23, 29, 25, 7, 11, 8, 6,
1154  13, 9, 10, 12, 24, 0, 30
1155  };
1156 
1157  const signed char
1158  parser::yypgoto_[] =
1159  {
1160  -21, -21, -21, 38, -6, 12
1161  };
1162 
1163  const signed char
1164  parser::yydefgoto_[] =
1165  {
1166  -1, 7, 28, 29, 9, 11
1167  };
1168 
1169  const unsigned char
1170  parser::yytable_[] =
1171  {
1172  13, 16, 30, 10, 6, 19, 30, 20, 1, 2,
1173  3, 14, 5, 19, 46, 45, 25, 26, 4, 27,
1174  5, 6, 32, 30, 25, 30, 0, 27, 5, 6,
1175  30, 30, 30, 30, 30, 30, 30, 30, 8, 33,
1176  12, 0, 44, 0, 0, 34, 0, 31, 34, 0,
1177  0, 0, 0, 36, 37, 38, 0, 0, 39, 40,
1178  41, 42, 15, 16, 43, 17, 18, 19, 31, 20,
1179  1, 2, 3, 21, 22, 23, 0, 24, 25, 26,
1180  4, 27, 5, 6, 15, 16, 0, 17, 0, 19,
1181  0, 20, 1, 2, 3, 21, 22, 23, 0, 35,
1182  25, 26, 4, 27, 5, 6, 15, 16, 0, 17,
1183  0, 19, 0, 20, 1, 2, 3, 21, 0, 0,
1184  0, 0, 25, 26, 4, 27, 5, 6, 15, 16,
1185  0, 17, 0, 19, 0, 20, 1, 2, 3, 0,
1186  0, 19, 0, 0, 25, 26, 4, 27, 5, 6,
1187  16, 0, 25, 0, 19, 27, 20, 1, 2, 3,
1188  0, 0, 0, 0, 0, 25, 0, 4, 27, 5,
1189  6, 19, 0, 0, 1, 2, 3, 0, 1, 2,
1190  3, 0, 25, 0, 4, 27, 5, 6, 4, 0,
1191  5, 6
1192  };
1193 
1194  const signed char
1195  parser::yycheck_[] =
1196  {
1197  6, 4, 8, 5, 24, 8, 12, 10, 11, 12,
1198  13, 0, 23, 8, 23, 9, 19, 20, 21, 22,
1199  23, 24, 10, 29, 19, 31, -1, 22, 23, 24,
1200  36, 37, 38, 39, 40, 41, 42, 43, 0, 17,
1201  2, -1, 17, -1, -1, 23, -1, 9, 23, -1,
1202  -1, -1, -1, 15, 16, 17, -1, -1, 20, 21,
1203  22, 23, 3, 4, 26, 6, 7, 8, 30, 10,
1204  11, 12, 13, 14, 15, 16, -1, 18, 19, 20,
1205  21, 22, 23, 24, 3, 4, -1, 6, -1, 8,
1206  -1, 10, 11, 12, 13, 14, 15, 16, -1, 18,
1207  19, 20, 21, 22, 23, 24, 3, 4, -1, 6,
1208  -1, 8, -1, 10, 11, 12, 13, 14, -1, -1,
1209  -1, -1, 19, 20, 21, 22, 23, 24, 3, 4,
1210  -1, 6, -1, 8, -1, 10, 11, 12, 13, -1,
1211  -1, 8, -1, -1, 19, 20, 21, 22, 23, 24,
1212  4, -1, 19, -1, 8, 22, 10, 11, 12, 13,
1213  -1, -1, -1, -1, -1, 19, -1, 21, 22, 23,
1214  24, 8, -1, -1, 11, 12, 13, -1, 11, 12,
1215  13, -1, 19, -1, 21, 22, 23, 24, 21, -1,
1216  23, 24
1217  };
1218 
1219  const unsigned char
1220  parser::yystos_[] =
1221  {
1222  0, 11, 12, 13, 21, 23, 24, 29, 31, 32,
1223  5, 33, 31, 32, 0, 3, 4, 6, 7, 8,
1224  10, 14, 15, 16, 18, 19, 20, 22, 30, 31,
1225  32, 31, 33, 17, 23, 18, 31, 31, 31, 31,
1226  31, 31, 31, 31, 17, 9, 23
1227  };
1228 
1229  const unsigned char
1230  parser::yyr1_[] =
1231  {
1232  0, 28, 29, 29, 30, 30, 31, 31, 31, 31,
1233  31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
1234  31, 31, 31, 31, 31, 31, 32, 32, 33, 33,
1235  33
1236  };
1237 
1238  const unsigned char
1239  parser::yyr2_[] =
1240  {
1241  0, 2, 1, 2, 1, 1, 3, 3, 3, 3,
1242  3, 3, 3, 3, 2, 2, 2, 2, 2, 2,
1243  1, 1, 1, 3, 4, 3, 1, 2, 0, 2,
1244  4
1245  };
1246 
1247 
1248 
1249  // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1250  // First, the terminals, then, starting at \a yyntokens_, nonterminals.
1251  const char*
1252  const parser::yytname_[] =
1253  {
1254  "\"end\"", "error", "$undefined", "\"&\"", "\"{\\\\}\"", "\"^\"",
1255  "\":\"", "\",\"", "\"{c}\"", "\"-\"", "\".\"", "\"[\"", "\"(\"",
1256  "\"\\\\e\"", "\"%\"", "\"+\"", "\"<+\"", "\"]\"", "\")\"", "\"{T}\"",
1257  "\"{/}\"", "\"\\\\z\"", "\"*\"", "\"letter\"", "\"weight\"", "CONCAT",
1258  "RWEIGHT", "LWEIGHT", "$accept", "input", "terminator", "exp", "weights",
1259  "class", YY_NULLPTR
1260  };
1261 
1262 #if YYDEBUG
1263  const unsigned char
1264  parser::yyrline_[] =
1265  {
1266  0, 178, 178, 182, 190, 191, 195, 196, 197, 198,
1267  199, 200, 201, 202, 204, 205, 206, 221, 222, 223,
1268  224, 225, 226, 227, 228, 229, 233, 234, 238, 239,
1269  240
1270  };
1271 
1272  // Print the state stack on the debug stream.
1273  void
1275  {
1276  *yycdebug_ << "Stack now";
1278  i = yystack_.begin (),
1279  i_end = yystack_.end ();
1280  i != i_end; ++i)
1281  *yycdebug_ << ' ' << i->state;
1282  *yycdebug_ << std::endl;
1283  }
1284 
1285  // Report on the debug stream that the rule \a yyrule is going to be reduced.
1286  void
1288  {
1289  unsigned int yylno = yyrline_[yyrule];
1290  int yynrhs = yyr2_[yyrule];
1291  // Print the symbols being reduced, and their result.
1292  *yycdebug_ << "Reducing stack by rule " << yyrule - 1
1293  << " (line " << yylno << "):" << std::endl;
1294  // The symbols being reduced.
1295  for (int yyi = 0; yyi < yynrhs; yyi++)
1296  YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
1297  yystack_[(yynrhs) - (yyi + 1)]);
1298  }
1299 #endif // YYDEBUG
1300 
1301 
1302 #line 11 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:1155
1303 } } // vcsn::rat
1304 #line 1305 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.cc" // lalr1.cc:1155
1305 #line 243 "/Users/akim/src/lrde/vaucanson2/lib/vcsn/rat/parse.yy" // lalr1.cc:1156
1306 
1307 
1308 namespace vcsn
1309 {
1310  namespace rat
1311  {
1312  static
1313  exp_t
1314  power(const dyn::ratexpset& es, exp_t e, int min, int max)
1315  {
1316  exp_t res;
1317  if (max == -1)
1318  {
1319  res = es->star(e);
1320  if (min != -1)
1321  res = es->mul(power(es, e, min, min), res);
1322  }
1323  else
1324  {
1325  if (min == -1)
1326  min = 0;
1327  if (min == 0)
1328  res = es->one();
1329  else
1330  {
1331  res = e;
1332  for (int n = 1; n < min; ++n)
1333  res = es->mul(res, e);
1334  }
1335  if (min < max)
1336  {
1337  exp_t sum = es->one();
1338  for (int n = 1; n <= max - min; ++n)
1339  sum = es->add(sum, power(es, e, n, n));
1340  res = es->mul(res, sum);
1341  }
1342  }
1343  return res;
1344  }
1345 
1346  static
1347  exp_t
1348  power(const dyn::ratexpset& es, exp_t e, std::tuple<int, int> range)
1349  {
1350  return power(es, e, std::get<0>(range), std::get<1>(range));
1351  }
1352 
1353  // "e <+ f = e + (f % e) = e + e{c} & f".
1354  static
1356  {
1357  return rs->add(e, rs->conjunction(rs->complement(e), f));
1358  }
1359 
1360  void
1361  vcsn::rat::parser::error(const location_type& l, const std::string& m)
1362  {
1363  driver_.error(l, m);
1364  }
1365  }
1366 }
#define YYLLOC_DEFAULT(Current, Rhs, N)
Definition: parse.cc:124
virtual std::string yysyntax_error_(state_type yystate, symbol_number_type yytoken) const
Generate an error message.
Definition: parse.cc:1039
symbol_number_type type_get() const
The (internal) type number (corresponding to state).
Definition: parse.cc:275
void set_debug_level(debug_level_type l)
Set the current debugging level.
Definition: parse.cc:487
virtual void yystack_print_()
Print the state stack on the debug stream.
Definition: parse.cc:1274
Syntax errors thrown from user actions.
Definition: parse.hh:324
An inner node with multiple children.
Definition: fwd.hh:123
Number of tokens.
Definition: parse.hh:771
void move(self_type &other)
Move the content of other to this.
Definition: parse.hh:249
static exp_t prefer(const dyn::ratexpset &rs, exp_t e, exp_t f)
Generate a ratexp for "e <+ f = e % f + f".
Definition: parse.cc:1355
"Internal" symbol: element of the stack.
Definition: parse.hh:725
#define YYERROR
Definition: parse.cc:184
#define YYACCEPT
Definition: parse.cc:182
static const unsigned char yyr2_[]
Definition: parse.hh:660
bool rparen
Whether there was a right-paren.
Definition: parse.hh:64
location_type location
The location.
Definition: parse.hh:418
by_state()
Default constructor.
Definition: parse.cc:251
static const signed char yytable_ninf_
Definition: parse.hh:624
Termination state number.
Definition: parse.hh:768
void push(T &t)
Steal the contents of t.
Definition: stack.hh:83
#define YYABORT
Definition: parse.cc:183
#define YY_(msgid)
Definition: parse.cc:114
#define YY_SYMBOL_PRINT(Title, Symbol)
Definition: parse.cc:148
state_type state
The state.
Definition: parse.hh:721
static const signed char yypact_ninf_
Definition: parse.hh:623
const_iterator end() const
Definition: stack.hh:119
Type access provider for state based symbols.
Definition: parse.hh:697
Define the vcsn::rat::parser class.
int state_type
State numbers.
Definition: parse.hh:602
const_iterator begin() const
Definition: stack.hh:112
void yy_print_(std::ostream &yyo, const basic_symbol< Base > &yysym) const
Display a symbol type, value and location.
Definition: parse.cc:365
#define TRY(Loc, Stm)
Run Stm, and bounces exceptions into parse errors at Loc.
Definition: parse.cc:42
static const signed char yypgoto_[]
Definition: parse.hh:640
stack_type yystack_
The stack.
Definition: parse.hh:741
#define YYCDEBUG
Definition: parse.cc:146
#define YY_REDUCE_PRINT(Rule)
Definition: parse.cc:158
static bool yy_table_value_is_error_(int yyvalue)
Whether the given yytable_ value indicates a syntax error.
Definition: parse.cc:510
driver & driver_
Definition: parse.hh:776
location location_
The inital location.
Definition: driver.hh:44
location(const position &b, const position &e)
Construct a location from b to e.
Definition: location.hh:52
vcsn::rat::exp_t result_
Definition: driver.hh:46
void yypop_(unsigned int n=1)
Pop n symbols the three stacks.
Definition: parse.cc:461
void move(basic_symbol &s)
Destructive move, s is emptied into this.
Definition: parse.hh:995
stack_symbol_type & operator=(const stack_symbol_type &that)
Assignment, needed by push_back.
Definition: parse.cc:320
S::const_reverse_iterator const_iterator
Definition: stack.hh:52
static const signed char yycheck_[]
Definition: parse.hh:650
#define MAKE(Kind,...)
Call the factory to make a Kind.
Definition: parse.cc:38
bool lparen
Whether there was a left-paren.
Definition: parse.hh:62
static const signed char yydefgoto_[]
Definition: parse.hh:643
The abstract, non-parameterized, root for all rational expression node types.
Definition: ratexp.hh:20
#define YY_STACK_PRINT()
Definition: parse.cc:164
State and public interface for rational expression parsing.
Definition: driver.hh:19
#define YY_NULLPTR
Definition: parse.cc:64
#define YYUSE(E)
Definition: parse.cc:140
static const short int yypact_[]
Definition: parse.hh:632
static std::string yytnamerr_(const char *n)
Convert the symbol name n to a form suitable for a diagnostic.
Definition: parse.cc:197
void yypush_(const char *m, stack_symbol_type &s)
Push a new state on the stack.
Definition: parse.cc:452
Trivial identities plus series identities.
T & build()
Instantiate an empty T in here.
Definition: parse.hh:186
debug_level_type debug_level() const
The current debugging level.
Definition: parse.cc:481
int symbol_number_type
Internal symbol number.
Definition: parse.hh:368
semantic_type value
The semantic value.
Definition: parse.hh:415
parser(driver &driver__yyarg)
Build a parser object.
Definition: parse.cc:230
std::shared_ptr< const detail::ratexpset_base > ratexpset
Definition: fwd.hh:73
static const unsigned char yyr1_[]
Definition: parse.hh:657
virtual int parse()
Parse.
Definition: parse.cc:516
virtual void yy_reduce_print_(int r)
Report on the debug stream that the rule r is going to be reduced.
Definition: parse.cc:1287
void clear()
Definition: stack.hh:98
std::ostream * yycdebug_
Definition: parse.hh:679
Abstract a location.
Definition: location.hh:47
void pop(unsigned int n=1)
Definition: stack.hh:91
void set_debug_stream(std::ostream &)
Set the current debugging stream.
Definition: parse.cc:474
static const unsigned char yydefact_[]
Definition: parse.hh:637
stack_symbol_type()
Construct an empty symbol.
Definition: parse.cc:281
std::unique_ptr< yyFlexLexer > scanner_
The scanner.
Definition: driver.hh:40
static const unsigned char yystos_[]
Definition: parse.hh:654
virtual void error(const location_type &loc, const std::string &msg)
Report a syntax error.
Definition: parse.cc:1361
basic_symbol< by_type > symbol_type
"External" symbols: returned by the scanner.
Definition: parse.hh:458
void move(by_state &that)
Steal the symbol type from that.
Definition: parse.cc:262
std::shared_ptr< const exp > exp_t
Definition: fwd.hh:16
static const unsigned char yyrline_[]
Definition: parse.hh:671
void yy_destroy_(const char *yymsg, basic_symbol< Base > &yysym) const
Reclaim the memory associated to a symbol.
Definition: parse.cc:356
state_type yy_lr_goto_state_(state_type yystate, int yysym)
Compute post-reduction state.
Definition: parse.cc:494
exp_t exp
The expression parsed so far.
Definition: parse.hh:60
static const char *const yytname_[]
For a symbol, its name in clear.
Definition: parse.hh:668
static const unsigned char yytable_[]
Definition: parse.hh:648
int debug_level_type
Type for debugging levels.
Definition: parse.hh:581
T & as()
Accessor to a built T.
Definition: parse.hh:202
#define YYCASE_(N, S)
static exp_t power(const dyn::ratexpset &rs, exp_t e, std::tuple< int, int > range)
Generate a ratexp for "e{range.first, range.second}".
Definition: parse.cc:1348
std::tuple< int, int > irange_type
Definition: parse.hh:72
S::size_type size() const
Definition: stack.hh:105
std::ostream & debug_stream() const
The current debugging stream.
Definition: parse.cc:468
dyn::ratexpset ratexpset_
Definition: driver.hh:45
static bool yy_pact_value_is_default_(int yyvalue)
Whether the given yypact_ value indicates a defaulted state.
Definition: parse.cc:504
#define YYDEBUG
Definition: parse.hh:161
virtual ~parser()
Definition: parse.cc:239
static parser::symbol_type yylex(driver &driver_)
Use our local scanner object.
Definition: parse.cc:96
Last index in yytable_.
Definition: parse.hh:765
A complete symbol.
Definition: parse.hh:380
Present a slice of the top of a stack.
Definition: stack.hh:133