Vcsn  2.1
Be Rational
parse.hh
Go to the documentation of this file.
1 // A Bison parser, made by GNU Bison 3.0.4.19-fbaf.
2 
3 // Skeleton interface 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 
38 // C++ LALR(1) parser skeleton written by Akim Demaille.
39 
40 #ifndef YY_YY_USERS_AKIM_SRC_LRDE_2_LIB_VCSN_RAT_PARSE_HH_INCLUDED
41 # define YY_YY_USERS_AKIM_SRC_LRDE_2_LIB_VCSN_RAT_PARSE_HH_INCLUDED
42 // // "%code requires" blocks.
43 #line 16 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:377
44 
45  #include <iostream>
46  #include <tuple>
47  #include "location.hh"
49  #include <vcsn/dyn/expression.hh>
50  #include <lib/vcsn/rat/fwd.hh>
51 
52  namespace vcsn
53  {
54  namespace rat
55  {
63  {
67  bool lparen = false;
69  bool rparen = false;
71  {
72  exp = e;
73  return *this;
74  }
75  };
76 
78  using irange_type = std::tuple<int, int>;
79  }
80  }
81 
82 #line 83 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.hh" // lalr1.cc:377
83 
84 
85 # include <cstdlib> // std::abort
86 # include <iostream>
87 # include <stdexcept>
88 # include <string>
89 # include <vector>
90 # include "stack.hh"
91 # include "location.hh"
92 
93 #ifndef YYASSERT
94 # include <cassert>
95 # define YYASSERT assert
96 #endif
97 
98 
99 #ifndef YY_ATTRIBUTE
100 # if (defined __GNUC__ \
101  && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
102  || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
103 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
104 # else
105 # define YY_ATTRIBUTE(Spec) /* empty */
106 # endif
107 #endif
108 
109 #ifndef YY_ATTRIBUTE_PURE
110 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
111 #endif
112 
113 #ifndef YY_ATTRIBUTE_UNUSED
114 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
115 #endif
116 
117 #if !defined _Noreturn \
118  && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
119 # if defined _MSC_VER && 1200 <= _MSC_VER
120 # define _Noreturn __declspec (noreturn)
121 # else
122 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
123 # endif
124 #endif
125 
126 /* Suppress unused-variable warnings by "using" E. */
127 #if ! defined lint || defined __GNUC__
128 # define YYUSE(E) ((void) (E))
129 #else
130 # define YYUSE(E) /* empty */
131 #endif
132 
133 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
134 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
135 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
136  _Pragma ("GCC diagnostic push") \
137  _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
138  _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
139 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
140  _Pragma ("GCC diagnostic pop")
141 #else
142 # define YY_INITIAL_VALUE(Value) Value
143 #endif
144 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
145 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
146 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
147 #endif
148 #ifndef YY_INITIAL_VALUE
149 # define YY_INITIAL_VALUE(Value) /* Nothing. */
150 #endif
151 
152 /* Debug traces. */
153 #ifndef YYDEBUG
154 # define YYDEBUG 1
155 #endif
156 
157 #line 11 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:377
158 namespace vcsn { namespace rat {
159 #line 160 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.hh" // lalr1.cc:377
160 
161 
162 
168  template <size_t S>
169  struct variant
170  {
173 
176  {}
177 
179  template <typename T>
180  variant (const T& t)
181  {
182  YYASSERT (sizeof (T) <= S);
183  new (yyas_<T> ()) T (t);
184  }
185 
188  {}
189 
191  template <typename T>
192  T&
193  build ()
194  {
195  return *new (yyas_<T> ()) T;
196  }
197 
199  template <typename T>
200  T&
201  build (const T& t)
202  {
203  return *new (yyas_<T> ()) T (t);
204  }
205 
207  template <typename T>
208  T&
209  as ()
210  {
211  return *yyas_<T> ();
212  }
213 
215  template <typename T>
216  const T&
217  as () const
218  {
219  return *yyas_<T> ();
220  }
221 
230  template <typename T>
231  void
232  swap (self_type& other)
233  {
234  std::swap (as<T> (), other.as<T> ());
235  }
236 
240  template <typename T>
241  void
242  move (self_type& other)
243  {
244  build<T> ();
245  swap<T> (other);
246  other.destroy<T> ();
247  }
248 
250  template <typename T>
251  void
252  copy (const self_type& other)
253  {
254  build<T> (other.as<T> ());
255  }
256 
258  template <typename T>
259  void
261  {
262  as<T> ().~T ();
263  }
264 
265  private:
267  self_type& operator=(const self_type&);
268  variant (const self_type&);
269 
271  template <typename T>
272  T*
273  yyas_ ()
274  {
275  void *yyp = yybuffer_.yyraw;
276  return static_cast<T*> (yyp);
277  }
278 
280  template <typename T>
281  const T*
282  yyas_ () const
283  {
284  const void *yyp = yybuffer_.yyraw;
285  return static_cast<const T*> (yyp);
286  }
287 
288  union
289  {
291  long double yyalign_me;
293  char yyraw[S];
294  } yybuffer_;
295  };
296 
297 
299  class parser
300  {
301  public:
302 #ifndef YYSTYPE
303  union union_type
305  {
306  // input
307  // sum
308  // tuple
309  // exp
310  char dummy1[sizeof(braced_expression)];
311 
312  // class
313  char dummy2[sizeof(class_t)];
314 
315  // weights
316  char dummy3[sizeof(dyn::weight)];
317 
318  // "*"
319  char dummy4[sizeof(irange_type)];
320 
321  // "letter"
322  // "weight"
323  char dummy5[sizeof(std::string)];
324 
325  // tuple.1
326  char dummy6[sizeof(std::vector<vcsn::dyn::expression>)];
327 };
328 
331 #else
332  typedef YYSTYPE semantic_type;
333 #endif
334  typedef location location_type;
336 
338  struct syntax_error : std::runtime_error
339  {
340  syntax_error (const location_type& l, const std::string& m);
341  location_type location;
342  };
343 
345  struct token
346  {
348  {
349  END = 0,
350  AMPERSAND = 258,
352  BACKSLASH = 260,
353  CARET = 261,
354  COLON = 262,
355  COMMA = 263,
356  COMPLEMENT = 264,
357  DASH = 265,
358  DOT = 266,
359  LBRACKET = 267,
360  LPAREN = 268,
361  LT_PLUS = 269,
362  ONE = 270,
363  PERCENT = 271,
364  PIPE = 272,
365  PLUS = 273,
366  RBRACKET = 274,
367  RPAREN = 275,
368  SLASH = 276,
370  ZERO = 278,
371  STAR = 279,
372  LETTER = 280,
373  WEIGHT = 281,
374  CONCAT = 282,
375  RWEIGHT = 283,
376  LWEIGHT = 284
377  };
378  };
379 
382 
384  typedef int symbol_number_type;
385 
387  enum { empty_symbol = -2 };
388 
390  typedef unsigned char token_number_type;
391 
398  template <typename Base>
400  {
402  typedef Base super_type;
403 
405  basic_symbol ();
406 
408  basic_symbol (const basic_symbol& other);
409 
411 
412  basic_symbol (typename Base::kind_type t, const location_type& l);
413 
414  basic_symbol (typename Base::kind_type t, const braced_expression v, const location_type& l);
415 
416  basic_symbol (typename Base::kind_type t, const class_t v, const location_type& l);
417 
418  basic_symbol (typename Base::kind_type t, const dyn::weight v, const location_type& l);
419 
420  basic_symbol (typename Base::kind_type t, const irange_type v, const location_type& l);
421 
422  basic_symbol (typename Base::kind_type t, const std::string v, const location_type& l);
423 
424  basic_symbol (typename Base::kind_type t, const std::vector<vcsn::dyn::expression> v, const location_type& l);
425 
426 
428  basic_symbol (typename Base::kind_type t,
429  const semantic_type& v,
430  const location_type& l);
431 
433  ~basic_symbol ();
434 
436  void clear ();
437 
439  bool empty () const;
440 
442  void move (basic_symbol& s);
443 
445  semantic_type value;
446 
448  location_type location;
449 
450  private:
452  basic_symbol& operator= (const basic_symbol& other);
453  };
454 
456  struct by_type
457  {
459  by_type ();
460 
462  by_type (const by_type& other);
463 
465  typedef token_type kind_type;
466 
468  by_type (kind_type t);
469 
471  void clear ();
472 
474  void move (by_type& that);
475 
478  symbol_number_type type_get () const;
479 
481  token_type token () const;
482 
486  int type;
487  };
488 
491 
492  // Symbol constructors declarations.
493  static inline
494  symbol_type
495  make_END (const location_type& l);
496 
497  static inline
498  symbol_type
499  make_AMPERSAND (const location_type& l);
500 
501  static inline
502  symbol_type
503  make_AMPERSAND_COLON (const location_type& l);
504 
505  static inline
506  symbol_type
507  make_BACKSLASH (const location_type& l);
508 
509  static inline
510  symbol_type
511  make_CARET (const location_type& l);
512 
513  static inline
514  symbol_type
515  make_COLON (const location_type& l);
516 
517  static inline
518  symbol_type
519  make_COMMA (const location_type& l);
520 
521  static inline
522  symbol_type
523  make_COMPLEMENT (const location_type& l);
524 
525  static inline
526  symbol_type
527  make_DASH (const location_type& l);
528 
529  static inline
530  symbol_type
531  make_DOT (const location_type& l);
532 
533  static inline
534  symbol_type
535  make_LBRACKET (const location_type& l);
536 
537  static inline
538  symbol_type
539  make_LPAREN (const location_type& l);
540 
541  static inline
542  symbol_type
543  make_LT_PLUS (const location_type& l);
544 
545  static inline
546  symbol_type
547  make_ONE (const location_type& l);
548 
549  static inline
550  symbol_type
551  make_PERCENT (const location_type& l);
552 
553  static inline
554  symbol_type
555  make_PIPE (const location_type& l);
556 
557  static inline
558  symbol_type
559  make_PLUS (const location_type& l);
560 
561  static inline
562  symbol_type
563  make_RBRACKET (const location_type& l);
564 
565  static inline
566  symbol_type
567  make_RPAREN (const location_type& l);
568 
569  static inline
570  symbol_type
571  make_SLASH (const location_type& l);
572 
573  static inline
574  symbol_type
575  make_TRANSPOSITION (const location_type& l);
576 
577  static inline
578  symbol_type
579  make_ZERO (const location_type& l);
580 
581  static inline
582  symbol_type
583  make_STAR (const irange_type& v, const location_type& l);
584 
585  static inline
586  symbol_type
587  make_LETTER (const std::string& v, const location_type& l);
588 
589  static inline
590  symbol_type
591  make_WEIGHT (const std::string& v, const location_type& l);
592 
593  static inline
594  symbol_type
595  make_CONCAT (const location_type& l);
596 
597  static inline
598  symbol_type
599  make_RWEIGHT (const location_type& l);
600 
601  static inline
602  symbol_type
603  make_LWEIGHT (const location_type& l);
604 
605 
607  parser (driver& driver__yyarg);
608  virtual ~parser ();
609 
612  virtual int parse ();
613 
614 #if YYDEBUG
615  std::ostream& debug_stream () const YY_ATTRIBUTE_PURE;
618  void set_debug_stream (std::ostream &);
619 
621  typedef int debug_level_type;
623  debug_level_type debug_level () const YY_ATTRIBUTE_PURE;
625  void set_debug_level (debug_level_type l);
626 #endif
627 
631  virtual void error (const location_type& loc, const std::string& msg);
632 
634  void error (const syntax_error& err);
635 
636  private:
638  parser (const parser&);
639  parser& operator= (const parser&);
640 
642  typedef int state_type;
643 
647  virtual std::string yysyntax_error_ (state_type yystate,
648  const symbol_type& yyla) const;
649 
653  state_type yy_lr_goto_state_ (state_type yystate, int yysym);
654 
657  static bool yy_pact_value_is_default_ (int yyvalue);
658 
661  static bool yy_table_value_is_error_ (int yyvalue);
662 
663  static const signed char yypact_ninf_;
664  static const signed char yytable_ninf_;
665 
667  static token_number_type yytranslate_ (token_type t);
668 
669  // Tables.
670  // YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
671  // STATE-NUM.
672  static const short int yypact_[];
673 
674  // YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
675  // Performed when YYTABLE does not specify something else to do. Zero
676  // means the default is an error.
677  static const unsigned char yydefact_[];
678 
679  // YYPGOTO[NTERM-NUM].
680  static const signed char yypgoto_[];
681 
682  // YYDEFGOTO[NTERM-NUM].
683  static const signed char yydefgoto_[];
684 
685  // YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
686  // positive, shift that token. If negative, reduce the rule whose
687  // number is the opposite. If YYTABLE_NINF, syntax error.
688  static const unsigned char yytable_[];
689 
690  static const signed char yycheck_[];
691 
692  // YYSTOS[STATE-NUM] -- The (internal number of the) accessing
693  // symbol of state STATE-NUM.
694  static const unsigned char yystos_[];
695 
696  // YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
697  static const unsigned char yyr1_[];
698 
699  // YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
700  static const unsigned char yyr2_[];
701 
702 
704  static std::string yytnamerr_ (const char *n);
705 
706 
708  static const char* const yytname_[];
709 #if YYDEBUG
710  // YYRLINE[YYN] -- Source line where rule number YYN was defined.
711  static const unsigned short int yyrline_[];
713  virtual void yy_reduce_print_ (int r);
715  virtual void yystack_print_ ();
716 
717  // Debugging.
718  int yydebug_;
719  std::ostream* yycdebug_;
720 
724  template <typename Base>
725  void yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const;
726 #endif
727 
732  template <typename Base>
733  void yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const;
734 
735  private:
737  struct by_state
738  {
740  by_state ();
741 
743  typedef state_type kind_type;
744 
746  by_state (kind_type s);
747 
749  by_state (const by_state& other);
750 
752  void clear ();
753 
755  void move (by_state& that);
756 
759  symbol_number_type type_get () const;
760 
762  enum { empty_state = -1 };
763 
766  state_type state;
767  };
768 
770  struct stack_symbol_type : basic_symbol<by_state>
771  {
777  stack_symbol_type (state_type s, symbol_type& sym);
780  };
781 
784 
786  stack_type yystack_;
787 
793  void yypush_ (const char* m, stack_symbol_type& s);
794 
801  void yypush_ (const char* m, state_type s, symbol_type& sym);
802 
804  void yypop_ (unsigned int n = 1);
805 
807  enum
808  {
809  yyeof_ = 0,
810  yylast_ = 171,
811  yynnts_ = 11,
812  yyfinal_ = 5,
814  yyerrcode_ = 256,
816  };
817 
818 
819  // User arguments.
821  };
822 
823  // Symbol number corresponding to token number t.
824  inline
826  parser::yytranslate_ (token_type t)
827  {
828  static
829  const token_number_type
830  translate_table[] =
831  {
832  0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
833  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
834  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
835  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
836  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
837  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
838  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
839  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
840  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
841  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
842  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
843  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
844  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
845  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
846  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
847  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
848  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
849  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
850  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
851  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
852  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
853  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
854  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
855  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
856  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
857  2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
858  5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
859  15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
860  25, 26, 27, 28, 29
861  };
862  const unsigned int user_token_number_max_ = 284;
863  const token_number_type undef_token_ = 2;
864 
865  if (static_cast<int>(t) <= yyeof_)
866  return yyeof_;
867  else if (static_cast<unsigned int> (t) <= user_token_number_max_)
868  return translate_table[t];
869  else
870  return undef_token_;
871  }
872 
873  inline
874  parser::syntax_error::syntax_error (const location_type& l, const std::string& m)
875  : std::runtime_error (m)
876  , location (l)
877  {}
878 
879  // basic_symbol.
880  template <typename Base>
881  inline
883  : value ()
884  {}
885 
886  template <typename Base>
887  inline
889  : Base (other)
890  , value ()
891  , location (other.location)
892  {
893  switch (other.type_get ())
894  {
895  case 31: // input
896  case 33: // sum
897  case 34: // tuple
898  case 38: // exp
899  value.copy< braced_expression > (other.value);
900  break;
901 
902  case 40: // class
903  value.copy< class_t > (other.value);
904  break;
905 
906  case 39: // weights
907  value.copy< dyn::weight > (other.value);
908  break;
909 
910  case 24: // "*"
911  value.copy< irange_type > (other.value);
912  break;
913 
914  case 25: // "letter"
915  case 26: // "weight"
916  value.copy< std::string > (other.value);
917  break;
918 
919  case 36: // tuple.1
920  value.copy< std::vector<vcsn::dyn::expression> > (other.value);
921  break;
922 
923  default:
924  break;
925  }
926 
927  }
928 
929 
930  template <typename Base>
931  inline
932  parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const semantic_type& v, const location_type& l)
933  : Base (t)
934  , value ()
935  , location (l)
936  {
937  (void) v;
938  switch (this->type_get ())
939  {
940  case 31: // input
941  case 33: // sum
942  case 34: // tuple
943  case 38: // exp
945  break;
946 
947  case 40: // class
948  value.copy< class_t > (v);
949  break;
950 
951  case 39: // weights
952  value.copy< dyn::weight > (v);
953  break;
954 
955  case 24: // "*"
956  value.copy< irange_type > (v);
957  break;
958 
959  case 25: // "letter"
960  case 26: // "weight"
961  value.copy< std::string > (v);
962  break;
963 
964  case 36: // tuple.1
965  value.copy< std::vector<vcsn::dyn::expression> > (v);
966  break;
967 
968  default:
969  break;
970  }
971 }
972 
973 
974  // Implementation of basic_symbol constructor for each type.
975 
976  template <typename Base>
977  parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const location_type& l)
978  : Base (t)
979  , value ()
980  , location (l)
981  {}
982 
983  template <typename Base>
984  parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const braced_expression v, const location_type& l)
985  : Base (t)
986  , value (v)
987  , location (l)
988  {}
989 
990  template <typename Base>
991  parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const class_t v, const location_type& l)
992  : Base (t)
993  , value (v)
994  , location (l)
995  {}
996 
997  template <typename Base>
998  parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const dyn::weight v, const location_type& l)
999  : Base (t)
1000  , value (v)
1001  , location (l)
1002  {}
1003 
1004  template <typename Base>
1005  parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const irange_type v, const location_type& l)
1006  : Base (t)
1007  , value (v)
1008  , location (l)
1009  {}
1010 
1011  template <typename Base>
1012  parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const std::string v, const location_type& l)
1013  : Base (t)
1014  , value (v)
1015  , location (l)
1016  {}
1017 
1018  template <typename Base>
1019  parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, const std::vector<vcsn::dyn::expression> v, const location_type& l)
1020  : Base (t)
1021  , value (v)
1022  , location (l)
1023  {}
1024 
1025 
1026  template <typename Base>
1027  inline
1029  {
1030  clear ();
1031  }
1032 
1033  template <typename Base>
1034  inline
1035  void
1037  {
1038  // User destructor.
1039  symbol_number_type yytype = this->type_get ();
1040  basic_symbol<Base>& yysym = *this;
1041  (void) yysym;
1042  switch (yytype)
1043  {
1044  default:
1045  break;
1046  }
1047 
1048  // Type destructor.
1049  switch (yytype)
1050  {
1051  case 31: // input
1052  case 33: // sum
1053  case 34: // tuple
1054  case 38: // exp
1055  value.template destroy< braced_expression > ();
1056  break;
1057 
1058  case 40: // class
1059  value.template destroy< class_t > ();
1060  break;
1061 
1062  case 39: // weights
1063  value.template destroy< dyn::weight > ();
1064  break;
1065 
1066  case 24: // "*"
1067  value.template destroy< irange_type > ();
1068  break;
1069 
1070  case 25: // "letter"
1071  case 26: // "weight"
1072  value.template destroy< std::string > ();
1073  break;
1074 
1075  case 36: // tuple.1
1076  value.template destroy< std::vector<vcsn::dyn::expression> > ();
1077  break;
1078 
1079  default:
1080  break;
1081  }
1082 
1083  Base::clear ();
1084  }
1085 
1086  template <typename Base>
1087  inline
1088  bool
1090  {
1091  return Base::type_get () == empty_symbol;
1092  }
1093 
1094  template <typename Base>
1095  inline
1096  void
1098  {
1099  super_type::move(s);
1100  switch (this->type_get ())
1101  {
1102  case 31: // input
1103  case 33: // sum
1104  case 34: // tuple
1105  case 38: // exp
1106  value.move< braced_expression > (s.value);
1107  break;
1108 
1109  case 40: // class
1110  value.move< class_t > (s.value);
1111  break;
1112 
1113  case 39: // weights
1114  value.move< dyn::weight > (s.value);
1115  break;
1116 
1117  case 24: // "*"
1118  value.move< irange_type > (s.value);
1119  break;
1120 
1121  case 25: // "letter"
1122  case 26: // "weight"
1123  value.move< std::string > (s.value);
1124  break;
1125 
1126  case 36: // tuple.1
1127  value.move< std::vector<vcsn::dyn::expression> > (s.value);
1128  break;
1129 
1130  default:
1131  break;
1132  }
1133 
1134  location = s.location;
1135  }
1136 
1137  // by_type.
1138  inline
1140  : type (empty_symbol)
1141  {}
1142 
1143  inline
1145  : type (other.type)
1146  {}
1147 
1148  inline
1150  : type (yytranslate_ (t))
1151  {}
1152 
1153  inline
1154  void
1156  {
1157  type = empty_symbol;
1158  }
1159 
1160  inline
1161  void
1163  {
1164  type = that.type;
1165  that.clear ();
1166  }
1167 
1168  inline
1169  int
1171  {
1172  return type;
1173  }
1174 
1175  inline
1178  {
1179  // YYTOKNUM[NUM] -- (External) token number corresponding to the
1180  // (internal) symbol number NUM (which must be that of a token). */
1181  static
1182  const unsigned short int
1183  yytoken_number_[] =
1184  {
1185  0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
1186  265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
1187  275, 276, 277, 278, 279, 280, 281, 282, 283, 284
1188  };
1189  return static_cast<token_type> (yytoken_number_[type]);
1190  }
1191  // Implementation of make_symbol for each symbol type.
1193  parser::make_END (const location_type& l)
1194  {
1195  return symbol_type (token::END, l);
1196  }
1197 
1199  parser::make_AMPERSAND (const location_type& l)
1200  {
1201  return symbol_type (token::AMPERSAND, l);
1202  }
1203 
1205  parser::make_AMPERSAND_COLON (const location_type& l)
1206  {
1207  return symbol_type (token::AMPERSAND_COLON, l);
1208  }
1209 
1211  parser::make_BACKSLASH (const location_type& l)
1212  {
1213  return symbol_type (token::BACKSLASH, l);
1214  }
1215 
1217  parser::make_CARET (const location_type& l)
1218  {
1219  return symbol_type (token::CARET, l);
1220  }
1221 
1223  parser::make_COLON (const location_type& l)
1224  {
1225  return symbol_type (token::COLON, l);
1226  }
1227 
1229  parser::make_COMMA (const location_type& l)
1230  {
1231  return symbol_type (token::COMMA, l);
1232  }
1233 
1235  parser::make_COMPLEMENT (const location_type& l)
1236  {
1237  return symbol_type (token::COMPLEMENT, l);
1238  }
1239 
1241  parser::make_DASH (const location_type& l)
1242  {
1243  return symbol_type (token::DASH, l);
1244  }
1245 
1247  parser::make_DOT (const location_type& l)
1248  {
1249  return symbol_type (token::DOT, l);
1250  }
1251 
1253  parser::make_LBRACKET (const location_type& l)
1254  {
1255  return symbol_type (token::LBRACKET, l);
1256  }
1257 
1259  parser::make_LPAREN (const location_type& l)
1260  {
1261  return symbol_type (token::LPAREN, l);
1262  }
1263 
1265  parser::make_LT_PLUS (const location_type& l)
1266  {
1267  return symbol_type (token::LT_PLUS, l);
1268  }
1269 
1271  parser::make_ONE (const location_type& l)
1272  {
1273  return symbol_type (token::ONE, l);
1274  }
1275 
1277  parser::make_PERCENT (const location_type& l)
1278  {
1279  return symbol_type (token::PERCENT, l);
1280  }
1281 
1283  parser::make_PIPE (const location_type& l)
1284  {
1285  return symbol_type (token::PIPE, l);
1286  }
1287 
1289  parser::make_PLUS (const location_type& l)
1290  {
1291  return symbol_type (token::PLUS, l);
1292  }
1293 
1295  parser::make_RBRACKET (const location_type& l)
1296  {
1297  return symbol_type (token::RBRACKET, l);
1298  }
1299 
1301  parser::make_RPAREN (const location_type& l)
1302  {
1303  return symbol_type (token::RPAREN, l);
1304  }
1305 
1307  parser::make_SLASH (const location_type& l)
1308  {
1309  return symbol_type (token::SLASH, l);
1310  }
1311 
1313  parser::make_TRANSPOSITION (const location_type& l)
1314  {
1315  return symbol_type (token::TRANSPOSITION, l);
1316  }
1317 
1319  parser::make_ZERO (const location_type& l)
1320  {
1321  return symbol_type (token::ZERO, l);
1322  }
1323 
1325  parser::make_STAR (const irange_type& v, const location_type& l)
1326  {
1327  return symbol_type (token::STAR, v, l);
1328  }
1329 
1331  parser::make_LETTER (const std::string& v, const location_type& l)
1332  {
1333  return symbol_type (token::LETTER, v, l);
1334  }
1335 
1337  parser::make_WEIGHT (const std::string& v, const location_type& l)
1338  {
1339  return symbol_type (token::WEIGHT, v, l);
1340  }
1341 
1343  parser::make_CONCAT (const location_type& l)
1344  {
1345  return symbol_type (token::CONCAT, l);
1346  }
1347 
1349  parser::make_RWEIGHT (const location_type& l)
1350  {
1351  return symbol_type (token::RWEIGHT, l);
1352  }
1353 
1355  parser::make_LWEIGHT (const location_type& l)
1356  {
1357  return symbol_type (token::LWEIGHT, l);
1358  }
1359 
1360 
1361 #line 11 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:377
1362 } } // vcsn::rat
1363 #line 1364 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.hh" // lalr1.cc:377
1364 
1365 
1366 // // "%code provides" blocks.
1367 #line 56 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.yy" // lalr1.cc:377
1368 
1369  #define YY_DECL_(Class) \
1370  parser::symbol_type Class lex(driver& driver_)
1371  #define YY_DECL YY_DECL_(yyFlexLexer::)
1372 
1373 #line 1374 "/Users/akim/src/lrde/2/lib/vcsn/rat/parse.hh" // lalr1.cc:377
1374 
1375 
1376 #endif // !YY_YY_USERS_AKIM_SRC_LRDE_2_LIB_VCSN_RAT_PARSE_HH_INCLUDED
STL namespace.
void move(self_type &other)
Move the content of other to this.
Definition: parse.hh:242
void set_debug_stream(std::ostream &)
Set the current debugging stream.
Definition: parse.cc:537
static const unsigned char yydefact_[]
Definition: parse.hh:677
token_type kind_type
The symbol type as needed by the constructor.
Definition: parse.hh:465
static symbol_type make_LT_PLUS(const location_type &l)
Definition: parse.hh:1265
static symbol_type make_CARET(const location_type &l)
Definition: parse.hh:1217
char yyraw[S]
A buffer large enough to store any of the semantic values.
Definition: parse.hh:293
static const short int yypact_[]
Definition: parse.hh:672
static symbol_type make_DOT(const location_type &l)
Definition: parse.hh:1247
static std::string yytnamerr_(const char *n)
Convert the symbol name n to a form suitable for a diagnostic.
Definition: parse.cc:195
void move(basic_symbol &s)
Destructive move, s is emptied into this.
Definition: parse.hh:1097
void clear()
Destroy contents, and record that is empty.
Definition: parse.hh:1036
static symbol_type make_ONE(const location_type &l)
Definition: parse.hh:1271
basic_symbol< by_type > symbol_type
"External" symbols: returned by the scanner.
Definition: parse.hh:490
static symbol_type make_STAR(const irange_type &v, const location_type &l)
Definition: parse.hh:1325
static token_number_type yytranslate_(token_type t)
Convert a scanner token number t to a symbol number.
Definition: parse.hh:826
static symbol_type make_AMPERSAND(const location_type &l)
Definition: parse.hh:1199
An expression that "remembers" whether it was in parentheses.
Definition: parse.hh:62
stack_symbol_type()
Construct an empty symbol.
Definition: parse.cc:289
location_type location
The location.
Definition: parse.hh:448
void yy_destroy_(const char *yymsg, basic_symbol< Base > &yysym) const
Reclaim the memory associated to a symbol.
Definition: parse.cc:382
~variant()
Destruction, allowed only if empty.
Definition: parse.hh:187
Abstract a location.
Definition: location.hh:47
static symbol_type make_END(const location_type &l)
Definition: parse.hh:1193
char dummy6[sizeof(std::vector< vcsn::dyn::expression >)]
Definition: parse.hh:326
static symbol_type make_TRANSPOSITION(const location_type &l)
Definition: parse.hh:1313
static symbol_type make_COLON(const location_type &l)
Definition: parse.hh:1223
Last index in yytable_.
Definition: parse.hh:810
symbol_number_type type_get() const
The (internal) type number (corresponding to type).
Definition: parse.hh:1170
static const unsigned char yytable_[]
Definition: parse.hh:688
static const unsigned char yyr1_[]
Definition: parse.hh:697
virtual int parse()
Parse.
Definition: parse.cc:579
void destroy()
Destroy the stored T.
Definition: parse.hh:260
dyn::expression exp
The expression parsed so far.
Definition: parse.hh:65
int debug_level_type
Type for debugging levels.
Definition: parse.hh:621
bool lparen
Whether there was a left-paren.
Definition: parse.hh:67
virtual void yy_reduce_print_(int r)
Report on the debug stream that the rule r is going to be reduced.
Definition: parse.cc:1408
static symbol_type make_LPAREN(const location_type &l)
Definition: parse.hh:1259
std::string type(const automaton &a)
The implementation type of a.
Definition: others.cc:197
unsigned char token_number_type
Internal symbol number for tokens (subsumed by symbol_number_type).
Definition: parse.hh:390
void clear()
Record that this symbol is empty.
Definition: parse.cc:260
static const unsigned char yystos_[]
Definition: parse.hh:694
static bool yy_pact_value_is_default_(int yyvalue)
Whether the given yypact_ value indicates a defaulted state.
Definition: parse.cc:567
virtual void error(const location_type &loc, const std::string &msg)
Report a syntax error.
Definition: parse.cc:1441
token::yytokentype token_type
(External) token type, as returned by yylex.
Definition: parse.hh:381
basic_symbol & operator=(const basic_symbol &other)
Assignment operator.
void destroy()
Destroy the stored T.
Definition: parse.hh:266
virtual ~parser()
Definition: parse.cc:237
std::set< std::pair< std::string, std::string >> class_t
A set of label ranges.
Definition: fwd.hh:12
static symbol_type make_DASH(const location_type &l)
Definition: parse.hh:1241
state_type yy_lr_goto_state_(state_type yystate, int yysym)
Compute post-reduction state.
Definition: parse.cc:557
static symbol_type make_PLUS(const location_type &l)
Definition: parse.hh:1289
state_type kind_type
The symbol type as needed by the constructor.
Definition: parse.hh:743
static const char *const yytname_[]
For a symbol, its name in clear.
Definition: parse.hh:708
T & as()
Accessor to a built T.
Definition: parse.hh:215
State and public interface for rational expression parsing.
Definition: driver.hh:17
T & build()
Instantiate an empty T in here.
Definition: parse.hh:193
by_type()
Default constructor.
Definition: parse.hh:1139
stack< stack_symbol_type > stack_type
Stack type.
Definition: parse.hh:783
void set_debug_level(debug_level_type l)
Set the current debugging level.
Definition: parse.cc:550
A char[S] buffer to store and retrieve objects.
Definition: parse.hh:169
virtual void yystack_print_()
Print the state stack on the debug stream.
Definition: parse.cc:1395
T * yyas_()
Accessor to raw memory as T.
Definition: parse.hh:273
#define YYASSERT
Definition: parse.hh:95
static symbol_type make_WEIGHT(const std::string &v, const location_type &l)
Definition: parse.hh:1337
std::ostream & debug_stream() const
The current debugging stream.
Definition: parse.cc:531
int type
The symbol type.
Definition: parse.hh:486
std::shared_ptr< const detail::weight_base > weight
Definition: fwd.hh:86
static const unsigned char yyr2_[]
Definition: parse.hh:700
A Bison parser.
Definition: parse.hh:299
void move(by_state &that)
Steal the symbol type from that.
Definition: parse.cc:267
static symbol_type make_AMPERSAND_COLON(const location_type &l)
Definition: parse.hh:1205
Termination state number.
Definition: parse.hh:812
T & build(const T &t)
Instantiate a T in here from t.
Definition: parse.hh:201
std::tuple< int, int > irange_type
An integer range, for quantifiers/exponents.
Definition: parse.hh:78
Type access provider for state based symbols.
Definition: parse.hh:737
Provide a variadic mul on top of a binary mul(), and one().
Definition: fwd.hh:46
Base super_type
Alias to Base.
Definition: parse.hh:402
char dummy4[sizeof(irange_type)]
Definition: parse.hh:319
An auxiliary type to compute the largest semantic type.
Definition: parse.hh:304
union vcsn::rat::variant::@5 yybuffer_
braced_expression & operator=(dyn::expression e)
Definition: parse.hh:70
void swap(self_type &other)
Swap the content with other, of same type.
Definition: parse.hh:232
symbol_number_type type_get() const
The (internal) type number (corresponding to state).
Definition: parse.cc:280
Number of tokens.
Definition: parse.hh:815
#define YY_ATTRIBUTE_PURE
Definition: parse.hh:110
const T * yyas_() const
Const accessor to raw memory as T.
Definition: parse.hh:282
Define the vcsn::rat::stack class.
static symbol_type make_COMPLEMENT(const location_type &l)
Definition: parse.hh:1235
by_state()
Default constructor.
Definition: parse.cc:249
semantic_type value
The semantic value.
Definition: parse.hh:445
variant()
Empty construction.
Definition: parse.hh:175
static symbol_type make_RBRACKET(const location_type &l)
Definition: parse.hh:1295
stack_symbol_type & operator=(const stack_symbol_type &that)
Assignment, needed by push_back.
Definition: parse.cc:337
void move(by_type &that)
Steal the symbol type from that.
Definition: parse.hh:1162
A char[S] buffer to store and retrieve objects.
Definition: parse.hh:175
static symbol_type make_LETTER(const std::string &v, const location_type &l)
Definition: parse.hh:1331
static symbol_type make_ZERO(const location_type &l)
Definition: parse.hh:1319
A complete symbol.
Definition: parse.hh:399
static symbol_type make_PERCENT(const location_type &l)
Definition: parse.hh:1277
syntax_error(const location_type &l, const std::string &m)
Definition: parse.hh:874
virtual std::string yysyntax_error_(state_type yystate, const symbol_type &yyla) const
Generate an error message.
Definition: parse.cc:1158
void copy(const self_type &other)
Copy the content of other to this.
Definition: parse.hh:252
basic_symbol< by_state > super_type
Superclass.
Definition: parse.hh:773
static const signed char yypgoto_[]
Definition: parse.hh:680
const T & as() const
Const accessor to a built T (for printer).
Definition: parse.hh:217
static symbol_type make_CONCAT(const location_type &l)
Definition: parse.hh:1343
stack_type yystack_
The stack.
Definition: parse.hh:786
char dummy5[sizeof(std::string)]
Definition: parse.hh:323
basic_symbol()
Default constructor.
Definition: parse.hh:882
long double yyalign_me
Strongest alignment constraints.
Definition: parse.hh:291
void yypop_(unsigned int n=1)
Pop n symbols the three stacks.
Definition: parse.cc:524
static const signed char yytable_ninf_
Definition: parse.hh:664
"Internal" symbol: element of the stack.
Definition: parse.hh:770
state_type state
The state.
Definition: parse.hh:766
static symbol_type make_LBRACKET(const location_type &l)
Definition: parse.hh:1253
bool rparen
Whether there was a right-paren.
Definition: parse.hh:69
bool empty() const
Whether empty.
Definition: parse.hh:1089
location location_type
Symbol locations.
Definition: parse.hh:335
Type access provider for token (enum) based symbols.
Definition: parse.hh:456
char dummy1[sizeof(braced_expression)]
Definition: parse.hh:310
static symbol_type make_LWEIGHT(const location_type &l)
Definition: parse.hh:1355
char dummy2[sizeof(class_t)]
Definition: parse.hh:313
static const signed char yypact_ninf_
Definition: parse.hh:663
static symbol_type make_COMMA(const location_type &l)
Definition: parse.hh:1229
char dummy3[sizeof(dyn::weight)]
Definition: parse.hh:316
std::shared_ptr< detail::expression_base > expression
Definition: expression.hh:78
static symbol_type make_PIPE(const location_type &l)
Definition: parse.hh:1283
T & as()
Accessor to a built T.
Definition: parse.hh:209
int state_type
State numbers.
Definition: parse.hh:642
void yy_print_(std::ostream &yyo, const basic_symbol< Base > &yysym) const
Display a symbol type, value and location.
Definition: parse.cc:391
void clear()
Record that this symbol is empty.
Definition: parse.hh:1155
variant< S > self_type
Type of *this.
Definition: parse.hh:172
void yypush_(const char *m, stack_symbol_type &s)
Push a new state on the stack.
Definition: parse.cc:515
variant< sizeof(union_type)> semantic_type
Symbol semantic values.
Definition: parse.hh:330
debug_level_type debug_level() const
The current debugging level.
Definition: parse.cc:544
static symbol_type make_SLASH(const location_type &l)
Definition: parse.hh:1307
int symbol_number_type
Symbol type: an internal symbol number.
Definition: parse.hh:384
Syntax errors thrown from user actions.
Definition: parse.hh:338
parser(driver &driver__yyarg)
Build a parser object.
Definition: parse.cc:228
static bool yy_table_value_is_error_(int yyvalue)
Whether the given yytable_ value indicates a syntax error.
Definition: parse.cc:573
self_type & operator=(const self_type &)
Prohibit blind copies.
token_type token() const
The token.
Definition: parse.hh:1177
static symbol_type make_RWEIGHT(const location_type &l)
Definition: parse.hh:1349
driver & driver_
Definition: parse.hh:820
~basic_symbol()
Destroy the symbol.
Definition: parse.hh:1028
Number of nonterminal symbols.
Definition: parse.hh:811
variant(const T &t)
Construct and fill.
Definition: parse.hh:180
static symbol_type make_RPAREN(const location_type &l)
Definition: parse.hh:1301
static const unsigned short int yyrline_[]
Definition: parse.hh:711
static const signed char yycheck_[]
Definition: parse.hh:690
static symbol_type make_BACKSLASH(const location_type &l)
Definition: parse.hh:1211
Define the vcsn::rat::location class.
static const signed char yydefgoto_[]
Definition: parse.hh:683
parser & operator=(const parser &)
std::ostream * yycdebug_
Definition: parse.hh:719