spot  2.3.3.dev
parseaut.hh
Go to the documentation of this file.
1 // A Bison parser, made by GNU Bison 3.3.2.
2 
3 // Skeleton interface for Bison LALR(1) parsers in C++
4 
5 // Copyright (C) 2002-2015, 2018-2019 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 
39 // C++ LALR(1) parser skeleton written by Akim Demaille.
40 
41 // Undocumented macros, especially those whose name start with YY_,
42 // are private implementation details. Do not rely on them.
43 
44 #ifndef YY_HOAYY_PARSEAUT_HH_INCLUDED
45 # define YY_HOAYY_PARSEAUT_HH_INCLUDED
46 // // "%code requires" blocks.
47 #line 31 "parseaut.yy" // lalr1.cc:401
48 
49 #include "config.h"
50 #include <spot/misc/common.hh>
51 #include <string>
52 #include <cstring>
53 #include <sstream>
54 #include <unordered_map>
55 #include <algorithm>
56 #include <spot/twa/formula2bdd.hh>
57 #include <spot/parseaut/public.hh>
58 #include "spot/priv/accmap.hh"
59 #include <spot/tl/parse.hh>
60 #include <spot/twaalgos/alternation.hh>
61 
62 #ifndef HAVE_STRVERSCMP
63 // If the libc does not have this, a version is compiled in lib/.
64 extern "C" int strverscmp(const char *s1, const char *s2);
65 #endif
66 
67 // Work around Bison not letting us write
68 // %lex-param { res.h->errors }
69 #define PARSE_ERROR_LIST res.h->errors
70 
71  inline namespace hoayy_support
72  {
73  typedef std::map<int, bdd> map_t;
74 
75  /* Cache parsed formulae. Labels on arcs are frequently identical
76  and it would be a waste of time to parse them to formula
77  over and over, and to register all their atomic_propositions in
78  the bdd_dict. Keep the bdd result around so we can reuse
79  it. */
80  typedef std::map<std::string, bdd> formula_cache;
81 
82  typedef std::pair<int, std::string*> pair;
83  typedef spot::twa_graph::namer<std::string> named_tgba_t;
84 
85  // Note: because this parser is meant to be used on a stream of
86  // automata, it tries hard to recover from errors, so that we get a
87  // chance to reach the end of the current automaton in order to
88  // process the next one. Several variables below are used to keep
89  // track of various error conditions.
90  enum label_style_t { Mixed_Labels, State_Labels, Trans_Labels,
91  Implicit_Labels };
92  enum acc_style_t { Mixed_Acc, State_Acc, Trans_Acc };
93 
94  struct result_
95  {
96  struct state_info
97  {
98  bool declared = false;
99  bool used = false;
100  spot::location used_loc;
101  };
102  spot::parsed_aut_ptr h;
103  spot::twa_ptr aut_or_ks;
105  std::string format_version;
106  spot::location format_version_loc;
107  spot::environment* env;
108  formula_cache fcache;
109  named_tgba_t* namer = nullptr;
110  spot::acc_mapper_int* acc_mapper = nullptr;
111  std::vector<int> ap;
112  std::vector<bdd> guards;
113  std::vector<bdd>::const_iterator cur_guard;
114  map_t dest_map;
115  std::vector<state_info> info_states; // States declared and used.
116  std::vector<std::pair<spot::location,
117  std::vector<unsigned>>> start; // Initial states;
118  std::unordered_map<std::string, bdd> alias;
119  struct prop_info
120  {
121  spot::location loc;
122  bool val;
123  operator bool() const
124  {
125  return val;
126  };
127  };
128  std::unordered_map<std::string, prop_info> props;
129  spot::location states_loc;
130  spot::location ap_loc;
131  spot::location state_label_loc;
132  spot::location accset_loc;
133  spot::acc_cond::mark_t acc_state;
134  spot::acc_cond::mark_t neg_acc_sets = 0U;
135  spot::acc_cond::mark_t pos_acc_sets = 0U;
136  int plus;
137  int minus;
138  std::vector<std::string>* state_names = nullptr;
139  std::map<unsigned, unsigned>* highlight_edges = nullptr;
140  std::map<unsigned, unsigned>* highlight_states = nullptr;
141  std::map<unsigned, unsigned> states_map;
142  std::set<int> ap_set;
143  unsigned cur_state;
144  int states = -1;
145  int ap_count = -1;
146  int accset = -1;
147  bdd state_label;
148  bdd cur_label;
149  bool has_state_label = false;
150  bool ignore_more_ap = false; // Set to true after the first "AP:"
151  // line has been read.
152  bool ignore_acc = false; // Set to true in case of missing
153  // Acceptance: lines.
154  bool ignore_acc_silent = false;
155  bool ignore_more_acc = false; // Set to true after the first
156  // "Acceptance:" line has been read.
157 
158  label_style_t label_style = Mixed_Labels;
159  acc_style_t acc_style = Mixed_Acc;
160 
161  bool accept_all_needed = false;
162  bool accept_all_seen = false;
163  bool aliased_states = false;
164 
165  spot::trival deterministic = spot::trival::maybe();
166  spot::trival complete = spot::trival::maybe();
167  bool trans_acc_seen = false;
168 
169  std::map<std::string, spot::location> labels;
170 
171  prop_info prop_is_true(const std::string& p)
172  {
173  auto i = props.find(p);
174  if (i == props.end())
175  return prop_info{spot::location(), false};
176  return i->second;
177  }
178 
179  prop_info prop_is_false(const std::string& p)
180  {
181  auto i = props.find(p);
182  if (i == props.end())
183  return prop_info{spot::location(), false};
184  return prop_info{i->second.loc, !i->second.val};
185  }
186 
187  ~result_()
188  {
189  delete namer;
190  delete acc_mapper;
191  }
192  };
193  }
194 
195 #line 196 "parseaut.hh" // lalr1.cc:401
196 
197 
198 # include <cstdlib> // std::abort
199 # include <iostream>
200 # include <stdexcept>
201 # include <string>
202 # include <vector>
203 
204 #if defined __cplusplus
205 # define YY_CPLUSPLUS __cplusplus
206 #else
207 # define YY_CPLUSPLUS 199711L
208 #endif
209 
210 // Support move semantics when possible.
211 #if 201103L <= YY_CPLUSPLUS
212 # define YY_MOVE std::move
213 # define YY_MOVE_OR_COPY move
214 # define YY_MOVE_REF(Type) Type&&
215 # define YY_RVREF(Type) Type&&
216 # define YY_COPY(Type) Type
217 #else
218 # define YY_MOVE
219 # define YY_MOVE_OR_COPY copy
220 # define YY_MOVE_REF(Type) Type&
221 # define YY_RVREF(Type) const Type&
222 # define YY_COPY(Type) const Type&
223 #endif
224 
225 // Support noexcept when possible.
226 #if 201103L <= YY_CPLUSPLUS
227 # define YY_NOEXCEPT noexcept
228 # define YY_NOTHROW
229 #else
230 # define YY_NOEXCEPT
231 # define YY_NOTHROW throw ()
232 #endif
233 
234 // Support constexpr when possible.
235 #if 201703 <= YY_CPLUSPLUS
236 # define YY_CONSTEXPR constexpr
237 #else
238 # define YY_CONSTEXPR
239 #endif
240 
241 
242 
243 #ifndef YY_ATTRIBUTE
244 # if (defined __GNUC__ \
245  && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
246  || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
247 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
248 # else
249 # define YY_ATTRIBUTE(Spec) /* empty */
250 # endif
251 #endif
252 
253 #ifndef YY_ATTRIBUTE_PURE
254 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
255 #endif
256 
257 #ifndef YY_ATTRIBUTE_UNUSED
258 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
259 #endif
260 
261 /* Suppress unused-variable warnings by "using" E. */
262 #if ! defined lint || defined __GNUC__
263 # define YYUSE(E) ((void) (E))
264 #else
265 # define YYUSE(E) /* empty */
266 #endif
267 
268 #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
269 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
270 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
271  _Pragma ("GCC diagnostic push") \
272  _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
273  _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
274 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
275  _Pragma ("GCC diagnostic pop")
276 #else
277 # define YY_INITIAL_VALUE(Value) Value
278 #endif
279 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
280 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
281 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
282 #endif
283 #ifndef YY_INITIAL_VALUE
284 # define YY_INITIAL_VALUE(Value) /* Nothing. */
285 #endif
286 
287 # ifndef YY_NULLPTR
288 # if defined __cplusplus
289 # if 201103L <= __cplusplus
290 # define YY_NULLPTR nullptr
291 # else
292 # define YY_NULLPTR 0
293 # endif
294 # else
295 # define YY_NULLPTR ((void*)0)
296 # endif
297 # endif
298 
299 /* Debug traces. */
300 #ifndef YYDEBUG
301 # define YYDEBUG 1
302 #endif
303 
304 
305 namespace hoayy {
306 #line 307 "parseaut.hh" // lalr1.cc:401
307 
308 
309 
311  class parser
312  {
313  public:
314 #ifndef YYSTYPE
315  union semantic_type
317  {
318  #line 185 "parseaut.yy" // lalr1.cc:401
319 
320  std::string* str;
321  unsigned int num;
322  int b;
324  pair* p;
325  std::list<pair>* list;
327  std::vector<unsigned>* states;
328 
329 #line 330 "parseaut.hh" // lalr1.cc:401
330  };
331 #else
332  typedef YYSTYPE semantic_type;
333 #endif
334  typedef spot::location location_type;
336 
338  struct syntax_error : std::runtime_error
339  {
340  syntax_error (const location_type& l, const std::string& m)
341  : std::runtime_error (m)
342  , location (l)
343  {}
344 
345  syntax_error (const syntax_error& s)
346  : std::runtime_error (s.what ())
347  , location (s.location)
348  {}
349 
350  ~syntax_error () YY_NOEXCEPT YY_NOTHROW;
351 
352  location_type location;
353  };
354 
356  struct token
357  {
358  enum yytokentype
359  {
360  ENDOFFILE = 0,
361  HOA = 258,
362  STATES = 259,
363  START = 260,
364  AP = 261,
365  ALIAS = 262,
366  ACCEPTANCE = 263,
367  ACCNAME = 264,
368  TOOL = 265,
369  NAME = 266,
370  PROPERTIES = 267,
371  BODY = 268,
372  END = 269,
373  STATE = 270,
374  SPOT_HIGHLIGHT_EDGES = 271,
375  SPOT_HIGHLIGHT_STATES = 272,
376  IDENTIFIER = 273,
377  HEADERNAME = 274,
378  ANAME = 275,
379  STRING = 276,
380  INT = 277,
381  DRA = 278,
382  DSA = 279,
383  V2 = 280,
384  EXPLICIT = 281,
385  ACCPAIRS = 282,
386  ACCSIG = 283,
387  ENDOFHEADER = 284,
388  NEVER = 285,
389  SKIP = 286,
390  IF = 287,
391  FI = 288,
392  DO = 289,
393  OD = 290,
394  ARROW = 291,
395  GOTO = 292,
396  FALSE = 293,
397  ATOMIC = 294,
398  ASSERT = 295,
399  FORMULA = 296,
400  ENDAUT = 297,
401  ENDDSTAR = 298,
402  LBTT = 299,
403  INT_S = 300,
404  LBTT_EMPTY = 301,
405  ACC = 302,
406  STATE_NUM = 303,
407  DEST_NUM = 304
408  };
409  };
410 
412  typedef token::yytokentype token_type;
413 
415  typedef int symbol_number_type;
416 
418  enum { empty_symbol = -2 };
419 
421  typedef unsigned char token_number_type;
422 
429  template <typename Base>
430  struct basic_symbol : Base
431  {
433  typedef Base super_type;
434 
437  : value ()
438  , location ()
439  {}
440 
441 #if 201103L <= YY_CPLUSPLUS
442  basic_symbol (basic_symbol&& that);
444 #endif
445 
447  basic_symbol (const basic_symbol& that);
449  basic_symbol (typename Base::kind_type t,
450  YY_MOVE_REF (location_type) l);
451 
453  basic_symbol (typename Base::kind_type t,
454  YY_RVREF (semantic_type) v,
455  YY_RVREF (location_type) l);
456 
459  {
460  clear ();
461  }
462 
464  void clear ()
465  {
466  Base::clear ();
467  }
468 
470  bool empty () const YY_NOEXCEPT;
471 
473  void move (basic_symbol& s);
474 
476  semantic_type value;
477 
479  location_type location;
480 
481  private:
482 #if YY_CPLUSPLUS < 201103L
483  basic_symbol& operator= (const basic_symbol& that);
485 #endif
486  };
487 
489  struct by_type
490  {
492  by_type ();
493 
494 #if 201103L <= YY_CPLUSPLUS
495  by_type (by_type&& that);
497 #endif
498 
500  by_type (const by_type& that);
501 
503  typedef token_type kind_type;
504 
506  by_type (kind_type t);
507 
509  void clear ();
510 
512  void move (by_type& that);
513 
516  symbol_number_type type_get () const YY_NOEXCEPT;
517 
519  token_type token () const YY_NOEXCEPT;
520 
524  int type;
525  };
526 
529  {};
530 
532  parser (result_& res_yyarg, spot::location initial_loc_yyarg);
533  virtual ~parser ();
534 
537  int operator() ();
538 
541  virtual int parse ();
542 
543 #if YYDEBUG
544  std::ostream& debug_stream () const YY_ATTRIBUTE_PURE;
547  void set_debug_stream (std::ostream &);
548 
550  typedef int debug_level_type;
552  debug_level_type debug_level () const YY_ATTRIBUTE_PURE;
554  void set_debug_level (debug_level_type l);
555 #endif
556 
560  virtual void error (const location_type& loc, const std::string& msg);
561 
563  void error (const syntax_error& err);
564 
565 
566 
567  private:
569  parser (const parser&);
570  parser& operator= (const parser&);
571 
573  typedef int state_type;
574 
578  virtual std::string yysyntax_error_ (state_type yystate,
579  const symbol_type& yyla) const;
580 
584  state_type yy_lr_goto_state_ (state_type yystate, int yysym);
585 
588  static bool yy_pact_value_is_default_ (int yyvalue);
589 
592  static bool yy_table_value_is_error_ (int yyvalue);
593 
594  static const short yypact_ninf_;
595  static const signed char yytable_ninf_;
596 
598  static token_number_type yytranslate_ (int t);
599 
600  // Tables.
601  // YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
602  // STATE-NUM.
603  static const short yypact_[];
604 
605  // YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
606  // Performed when YYTABLE does not specify something else to do. Zero
607  // means the default is an error.
608  static const unsigned char yydefact_[];
609 
610  // YYPGOTO[NTERM-NUM].
611  static const short yypgoto_[];
612 
613  // YYDEFGOTO[NTERM-NUM].
614  static const short yydefgoto_[];
615 
616  // YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
617  // positive, shift that token. If negative, reduce the rule whose
618  // number is the opposite. If YYTABLE_NINF, syntax error.
619  static const short yytable_[];
620 
621  static const short yycheck_[];
622 
623  // YYSTOS[STATE-NUM] -- The (internal number of the) accessing
624  // symbol of state STATE-NUM.
625  static const unsigned char yystos_[];
626 
627  // YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
628  static const unsigned char yyr1_[];
629 
630  // YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
631  static const unsigned char yyr2_[];
632 
633 
635  static std::string yytnamerr_ (const char *n);
636 
637 
639  static const char* const yytname_[];
640 #if YYDEBUG
641  // YYRLINE[YYN] -- Source line where rule number YYN was defined.
642  static const unsigned short yyrline_[];
644  virtual void yy_reduce_print_ (int r);
646  virtual void yystack_print_ ();
647 
649  int yydebug_;
651  std::ostream* yycdebug_;
652 
656  template <typename Base>
657  void yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const;
658 #endif
659 
664  template <typename Base>
665  void yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const;
666 
667  private:
669  struct by_state
670  {
672  by_state () YY_NOEXCEPT;
673 
675  typedef state_type kind_type;
676 
678  by_state (kind_type s) YY_NOEXCEPT;
679 
681  by_state (const by_state& that) YY_NOEXCEPT;
682 
684  void clear () YY_NOEXCEPT;
685 
687  void move (by_state& that);
688 
691  symbol_number_type type_get () const YY_NOEXCEPT;
692 
694  enum { empty_state = -1 };
695 
698  state_type state;
699  };
700 
702  struct stack_symbol_type : basic_symbol<by_state>
703  {
705  typedef basic_symbol<by_state> super_type;
707  stack_symbol_type ();
709  stack_symbol_type (YY_RVREF (stack_symbol_type) that);
711  stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) sym);
712 #if YY_CPLUSPLUS < 201103L
713  stack_symbol_type& operator= (stack_symbol_type& that);
716 #endif
717  };
718 
720  template <typename T, typename S = std::vector<T> >
721  class stack
722  {
723  public:
724  // Hide our reversed order.
725  typedef typename S::reverse_iterator iterator;
726  typedef typename S::const_reverse_iterator const_iterator;
727  typedef typename S::size_type size_type;
728 
729  stack (size_type n = 200)
730  : seq_ (n)
731  {}
732 
736  T&
737  operator[] (size_type i)
738  {
739  return seq_[size () - 1 - i];
740  }
741 
745  T&
746  operator[] (int i)
747  {
748  return operator[] (size_type (i));
749  }
750 
754  const T&
755  operator[] (size_type i) const
756  {
757  return seq_[size () - 1 - i];
758  }
759 
763  const T&
764  operator[] (int i) const
765  {
766  return operator[] (size_type (i));
767  }
768 
772  void
773  push (YY_MOVE_REF (T) t)
774  {
775  seq_.push_back (T ());
776  operator[] (0).move (t);
777  }
778 
780  void
781  pop (int n = 1) YY_NOEXCEPT
782  {
783  for (; 0 < n; --n)
784  seq_.pop_back ();
785  }
786 
788  void
789  clear () YY_NOEXCEPT
790  {
791  seq_.clear ();
792  }
793 
795  size_type
796  size () const YY_NOEXCEPT
797  {
798  return seq_.size ();
799  }
800 
802  const_iterator
803  begin () const YY_NOEXCEPT
804  {
805  return seq_.rbegin ();
806  }
807 
809  const_iterator
810  end () const YY_NOEXCEPT
811  {
812  return seq_.rend ();
813  }
814 
816  class slice
817  {
818  public:
819  slice (const stack& stack, int range)
820  : stack_ (stack)
821  , range_ (range)
822  {}
823 
824  const T&
825  operator[] (int i) const
826  {
827  return stack_[range_ - i];
828  }
829 
830  private:
831  const stack& stack_;
832  int range_;
833  };
834 
835  private:
836  stack (const stack&);
837  stack& operator= (const stack&);
839  S seq_;
840  };
841 
842 
844  typedef stack<stack_symbol_type> stack_type;
845 
847  stack_type yystack_;
848 
854  void yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym);
855 
862  void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym);
863 
865  void yypop_ (int n = 1);
866 
868  enum
869  {
870  yyeof_ = 0,
871  yylast_ = 235,
872  yynnts_ = 82,
873  yyfinal_ = 24,
874  yyterror_ = 1,
875  yyerrcode_ = 256,
876  yyntokens_ = 65
877  };
878 
879 
880  // User arguments.
881  result_& res;
882  spot::location initial_loc;
883  };
884 
885 
886 
887 } // hoayy
888 #line 889 "parseaut.hh" // lalr1.cc:401
889 
890 
891 
892 
893 #endif // !YY_HOAYY_PARSEAUT_HH_INCLUDED
Definition: parseaut.hh:94
An environment that describes atomic propositions.
Definition: environment.hh:32
Symbol semantic values.
Definition: parseaut.hh:316
semantic_type value
The semantic value.
Definition: parseaut.hh:476
Syntax errors thrown from user actions.
Definition: parseaut.hh:338
Definition: parseaut.hh:96
Definition: ngraph.hh:32
token::yytokentype token_type
(External) token type, as returned by yylex.
Definition: parseaut.hh:412
Definition: parseaut.hh:305
Definition: public.hh:92
Definition: parseaut.hh:119
Tokens.
Definition: parseaut.hh:356
Type access provider for token (enum) based symbols.
Definition: parseaut.hh:489
token_type kind_type
The symbol type as needed by the constructor.
Definition: parseaut.hh:503
Base super_type
Alias to Base.
Definition: parseaut.hh:433
unsigned char token_number_type
Internal symbol number for tokens (subsumed by symbol_number_type).
Definition: parseaut.hh:421
A class implementing Kleene&#39;s three-valued logic.
Definition: trival.hh:33
~basic_symbol()
Destroy the symbol.
Definition: parseaut.hh:458
basic_symbol()
Default constructor.
Definition: parseaut.hh:436
spot::location location_type
Symbol locations.
Definition: parseaut.hh:335
Definition: parseaut.hh:71
A Bison parser.
Definition: parseaut.hh:311
"External" symbols: returned by the scanner.
Definition: parseaut.hh:528
Present a slice of the top of a stack.
Definition: parseaut.hh:816
void clear()
Destroy contents, and record that is empty.
Definition: parseaut.hh:464
Definition: parseaut.hh:430
Definition: acc.hh:325
location_type location
The location.
Definition: parseaut.hh:479
int symbol_number_type
Symbol type: an internal symbol number.
Definition: parseaut.hh:415
Definition: acc.hh:34
int debug_level_type
Type for debugging levels.
Definition: parseaut.hh:550

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Mon Jul 29 2019 10:30:37 for spot by doxygen 1.8.13