spot  1.99.6
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
parseaut.hh
Go to the documentation of this file.
1 // A Bison parser, made by GNU Bison 3.0.2.
2 
3 // Skeleton interface 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 
38 // C++ LALR(1) parser skeleton written by Akim Demaille.
39 
40 #ifndef YY_HOAYY_PARSEAUT_HH_INCLUDED
41 # define YY_HOAYY_PARSEAUT_HH_INCLUDED
42 // // "%code requires" blocks.
43 #line 31 "parseaut.yy" // lalr1.cc:372
44 
45 #include "config.h"
46 #include "misc/common.hh"
47 #include <string>
48 #include <cstring>
49 #include <sstream>
50 #include <unordered_map>
51 #include <algorithm>
52 #include "twa/formula2bdd.hh"
53 #include "public.hh"
54 #include "priv/accmap.hh"
55 #include "tl/parse.hh"
56 
57 #ifndef HAVE_STRVERSCMP
58 // If the libc does not have this, a version is compiled in lib/.
59 extern "C" int strverscmp(const char *s1, const char *s2);
60 #endif
61 
62 // Work around Bison not letting us write
63 // %lex-param { res.h->errors }
64 #define PARSE_ERROR_LIST res.h->errors
65 
66  inline namespace hoayy_support
67  {
68  typedef std::map<int, bdd> map_t;
69 
70  /* Cache parsed formulae. Labels on arcs are frequently identical
71  and it would be a waste of time to parse them to formula
72  over and over, and to register all their atomic_propositions in
73  the bdd_dict. Keep the bdd result around so we can reuse
74  it. */
75  typedef std::map<std::string, bdd> formula_cache;
76 
77  typedef std::pair<int, std::string*> pair;
78  typedef spot::twa_graph::namer<std::string> named_tgba_t;
79 
80  // Note: because this parser is meant to be used on a stream of
81  // automata, it tries hard to recover from errors, so that we get a
82  // chance to reach the end of the current automaton in order to
83  // process the next one. Several variables below are used to keep
84  // track of various error conditions.
85  enum label_style_t { Mixed_Labels, State_Labels, Trans_Labels,
86  Implicit_Labels };
87  enum acc_style_t { Mixed_Acc, State_Acc, Trans_Acc };
88 
89  struct result_
90  {
91  struct state_info
92  {
93  bool declared = false;
94  bool used = false;
95  spot::location used_loc;
96  };
97  spot::parsed_aut_ptr h;
98  spot::twa_ptr aut_or_ks;
100  std::string format_version;
101  spot::location format_version_loc;
102  spot::environment* env;
103  formula_cache fcache;
104  named_tgba_t* namer = nullptr;
105  spot::acc_mapper_int* acc_mapper = nullptr;
106  std::vector<int> ap;
107  std::vector<bdd> guards;
108  std::vector<bdd>::const_iterator cur_guard;
109  map_t dest_map;
110  std::vector<state_info> info_states; // States declared and used.
111  std::vector<std::pair<spot::location, unsigned>> start; // Initial states;
112  std::unordered_map<std::string, bdd> alias;
113  std::unordered_map<std::string, spot::location> props;
114  spot::location states_loc;
115  spot::location ap_loc;
116  spot::location state_label_loc;
117  spot::location accset_loc;
118  spot::acc_cond::mark_t acc_state;
119  spot::acc_cond::mark_t neg_acc_sets = 0U;
120  spot::acc_cond::mark_t pos_acc_sets = 0U;
121  int plus;
122  int minus;
123  std::vector<std::string>* state_names = nullptr;
124  std::map<unsigned, unsigned> states_map;
125  std::set<int> ap_set;
126  unsigned cur_state;
127  int states = -1;
128  int ap_count = -1;
129  int accset = -1;
130  bdd state_label;
131  bdd cur_label;
132  bool has_state_label = false;
133  bool ignore_more_ap = false; // Set to true after the first "AP:"
134  // line has been read.
135  bool ignore_acc = false; // Set to true in case of missing
136  // Acceptance: lines.
137  bool ignore_acc_silent = false;
138  bool ignore_more_acc = false; // Set to true after the first
139  // "Acceptance:" line has been read.
140 
141  label_style_t label_style = Mixed_Labels;
142  acc_style_t acc_style = Mixed_Acc;
143 
144  bool accept_all_needed = false;
145  bool accept_all_seen = false;
146  bool aliased_states = false;
147 
148  bool deterministic = false;
149  bool complete = false;
150  bool trans_acc_seen = false;
151 
152  std::map<std::string, spot::location> labels;
153 
154  ~result_()
155  {
156  delete namer;
157  delete acc_mapper;
158  }
159  };
160  }
161 
162 #line 163 "parseaut.hh" // lalr1.cc:372
163 
164 
165 # include <vector>
166 # include <iostream>
167 # include <stdexcept>
168 # include <string>
169 # include "stack.hh"
170 
171 
172 
173 #ifndef YY_ATTRIBUTE
174 # if (defined __GNUC__ \
175  && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
176  || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
177 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
178 # else
179 # define YY_ATTRIBUTE(Spec) /* empty */
180 # endif
181 #endif
182 
183 #ifndef YY_ATTRIBUTE_PURE
184 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
185 #endif
186 
187 #ifndef YY_ATTRIBUTE_UNUSED
188 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
189 #endif
190 
191 #if !defined _Noreturn \
192  && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
193 # if defined _MSC_VER && 1200 <= _MSC_VER
194 # define _Noreturn __declspec (noreturn)
195 # else
196 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
197 # endif
198 #endif
199 
200 /* Suppress unused-variable warnings by "using" E. */
201 #if ! defined lint || defined __GNUC__
202 # define YYUSE(E) ((void) (E))
203 #else
204 # define YYUSE(E) /* empty */
205 #endif
206 
207 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
208 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
209 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
210  _Pragma ("GCC diagnostic push") \
211  _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
212  _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
213 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
214  _Pragma ("GCC diagnostic pop")
215 #else
216 # define YY_INITIAL_VALUE(Value) Value
217 #endif
218 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
219 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
220 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
221 #endif
222 #ifndef YY_INITIAL_VALUE
223 # define YY_INITIAL_VALUE(Value) /* Nothing. */
224 #endif
225 
226 /* Debug traces. */
227 #ifndef YYDEBUG
228 # define YYDEBUG 1
229 #endif
230 
231 
232 namespace hoayy {
233 #line 234 "parseaut.hh" // lalr1.cc:372
234 
235 
236 
237 
238 
240  class parser
241  {
242  public:
243 #ifndef YYSTYPE
244  union semantic_type
246  {
247  #line 156 "parseaut.yy" // lalr1.cc:372
248 
249  std::string* str;
250  unsigned int num;
251  int b;
253  pair* p;
254  std::list<pair>* list;
256 
257 #line 258 "parseaut.hh" // lalr1.cc:372
258  };
259 #else
260  typedef YYSTYPE semantic_type;
261 #endif
262  typedef spot::location location_type;
264 
266  struct syntax_error : std::runtime_error
267  {
268  syntax_error (const location_type& l, const std::string& m);
269  location_type location;
270  };
271 
273  struct token
274  {
275  enum yytokentype
276  {
277  ENDOFFILE = 0,
278  HOA = 258,
279  STATES = 259,
280  START = 260,
281  AP = 261,
282  ALIAS = 262,
283  ACCEPTANCE = 263,
284  ACCNAME = 264,
285  TOOL = 265,
286  NAME = 266,
287  PROPERTIES = 267,
288  BODY = 268,
289  END = 269,
290  STATE = 270,
291  IDENTIFIER = 271,
292  HEADERNAME = 272,
293  ANAME = 273,
294  STRING = 274,
295  INT = 275,
296  DRA = 276,
297  DSA = 277,
298  V2 = 278,
299  EXPLICIT = 279,
300  ACCPAIRS = 280,
301  ACCSIG = 281,
302  ENDOFHEADER = 282,
303  NEVER = 283,
304  SKIP = 284,
305  IF = 285,
306  FI = 286,
307  DO = 287,
308  OD = 288,
309  ARROW = 289,
310  GOTO = 290,
311  FALSE = 291,
312  ATOMIC = 292,
313  ASSERT = 293,
314  FORMULA = 294,
315  ENDAUT = 295,
316  ENDDSTAR = 296,
317  LBTT = 297,
318  INT_S = 298,
319  LBTT_EMPTY = 299,
320  ACC = 300,
321  STATE_NUM = 301,
322  DEST_NUM = 302
323  };
324  };
325 
327  typedef token::yytokentype token_type;
328 
330  typedef int symbol_number_type;
331 
333  typedef unsigned char token_number_type;
334 
341  template <typename Base>
342  struct basic_symbol : Base
343  {
345  typedef Base super_type;
346 
348  basic_symbol ();
349 
351  basic_symbol (const basic_symbol& other);
352 
354  basic_symbol (typename Base::kind_type t,
355  const location_type& l);
356 
358  basic_symbol (typename Base::kind_type t,
359  const semantic_type& v,
360  const location_type& l);
361 
362  ~basic_symbol ();
363 
365  void move (basic_symbol& s);
366 
368  semantic_type value;
369 
371  location_type location;
372 
373  private:
375  basic_symbol& operator= (const basic_symbol& other);
376  };
377 
379  struct by_type
380  {
382  by_type ();
383 
385  by_type (const by_type& other);
386 
388  typedef token_type kind_type;
389 
391  by_type (kind_type t);
392 
394  void move (by_type& that);
395 
398  symbol_number_type type_get () const;
399 
401  token_type token () const;
402 
403  enum { empty = 0 };
404 
407  token_number_type type;
408  };
409 
412 
413 
415  parser (result_& res_yyarg, spot::location initial_loc_yyarg);
416  virtual ~parser ();
417 
420  virtual int parse ();
421 
422 #if YYDEBUG
423  std::ostream& debug_stream () const YY_ATTRIBUTE_PURE;
426  void set_debug_stream (std::ostream &);
427 
429  typedef int debug_level_type;
431  debug_level_type debug_level () const YY_ATTRIBUTE_PURE;
433  void set_debug_level (debug_level_type l);
434 #endif
435 
439  virtual void error (const location_type& loc, const std::string& msg);
440 
442  void error (const syntax_error& err);
443 
444  private:
446  parser (const parser&);
447  parser& operator= (const parser&);
448 
450  typedef int state_type;
451 
455  virtual std::string yysyntax_error_ (state_type yystate,
456  symbol_number_type yytoken) const;
457 
461  state_type yy_lr_goto_state_ (state_type yystate, int yysym);
462 
465  static bool yy_pact_value_is_default_ (int yyvalue);
466 
469  static bool yy_table_value_is_error_ (int yyvalue);
470 
471  static const short int yypact_ninf_;
472  static const signed char yytable_ninf_;
473 
475  static token_number_type yytranslate_ (int t);
476 
477  // Tables.
478  // YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
479  // STATE-NUM.
480  static const short int yypact_[];
481 
482  // YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
483  // Performed when YYTABLE does not specify something else to do. Zero
484  // means the default is an error.
485  static const unsigned char yydefact_[];
486 
487  // YYPGOTO[NTERM-NUM].
488  static const short int yypgoto_[];
489 
490  // YYDEFGOTO[NTERM-NUM].
491  static const short int yydefgoto_[];
492 
493  // YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
494  // positive, shift that token. If negative, reduce the rule whose
495  // number is the opposite. If YYTABLE_NINF, syntax error.
496  static const short int yytable_[];
497 
498  static const short int yycheck_[];
499 
500  // YYSTOS[STATE-NUM] -- The (internal number of the) accessing
501  // symbol of state STATE-NUM.
502  static const unsigned char yystos_[];
503 
504  // YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
505  static const unsigned char yyr1_[];
506 
507  // YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
508  static const unsigned char yyr2_[];
509 
510 
512  static std::string yytnamerr_ (const char *n);
513 
514 
516  static const char* const yytname_[];
517 #if YYDEBUG
518  // YYRLINE[YYN] -- Source line where rule number YYN was defined.
519  static const unsigned short int yyrline_[];
521  virtual void yy_reduce_print_ (int r);
523  virtual void yystack_print_ ();
524 
525  // Debugging.
526  int yydebug_;
527  std::ostream* yycdebug_;
528 
532  template <typename Base>
533  void yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const;
534 #endif
535 
540  template <typename Base>
541  void yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const;
542 
543  private:
545  struct by_state
546  {
548  by_state ();
549 
551  typedef state_type kind_type;
552 
554  by_state (kind_type s);
555 
557  by_state (const by_state& other);
558 
560  void move (by_state& that);
561 
564  symbol_number_type type_get () const;
565 
566  enum { empty = 0 };
567 
569  state_type state;
570  };
571 
573  struct stack_symbol_type : basic_symbol<by_state>
574  {
576  typedef basic_symbol<by_state> super_type;
578  stack_symbol_type ();
580  stack_symbol_type (state_type s, symbol_type& sym);
582  stack_symbol_type& operator= (const stack_symbol_type& that);
583  };
584 
586  typedef stack<stack_symbol_type> stack_type;
587 
589  stack_type yystack_;
590 
596  void yypush_ (const char* m, stack_symbol_type& s);
597 
604  void yypush_ (const char* m, state_type s, symbol_type& sym);
605 
607  void yypop_ (unsigned int n = 1);
608 
609  // Constants.
610  enum
611  {
612  yyeof_ = 0,
613  yylast_ = 220,
614  yynnts_ = 77,
615  yyempty_ = -2,
616  yyfinal_ = 24,
617  yyterror_ = 1,
618  yyerrcode_ = 256,
619  yyntokens_ = 63
620  };
621 
622 
623  // User arguments.
624  result_& res;
625  spot::location initial_loc;
626  };
627 
628 
629 
630 } // hoayy
631 #line 632 "parseaut.hh" // lalr1.cc:372
632 
633 
634 
635 
636 #endif // !YY_HOAYY_PARSEAUT_HH_INCLUDED
token_number_type type
Definition: parseaut.hh:407
void move(by_type &that)
Steal the symbol type from that.
debug_level_type debug_level() const
The current debugging level.
Definition: parseaut.hh:89
An environment that describes atomic propositions.
Definition: environment.hh:32
Symbol semantic values.
Definition: parseaut.hh:245
semantic_type value
The semantic value.
Definition: parseaut.hh:368
void move(basic_symbol &s)
Destructive move, s is emptied into this.
Syntax errors thrown from user actions.
Definition: parseaut.hh:266
void set_debug_level(debug_level_type l)
Set the current debugging level.
Definition: formula.hh:1543
Definition: parseaut.hh:91
virtual void error(const location_type &loc, const std::string &msg)
token_type token() const
The token.
Definition: ngraph.hh:32
token::yytokentype token_type
(External) token type, as returned by yylex.
Definition: parseaut.hh:327
Definition: parseaut.hh:232
virtual int parse()
Definition: public.hh:92
Tokens.
Definition: parseaut.hh:273
std::ostream & debug_stream() const
The current debugging stream.
Type access provider for token (enum) based symbols.
Definition: parseaut.hh:379
token_type kind_type
The symbol type as needed by the constructor.
Definition: parseaut.hh:388
Base super_type
Alias to Base.
Definition: parseaut.hh:345
symbol_number_type type_get() const
unsigned char token_number_type
Internal symbol number for tokens (subsumed by symbol_number_type).
Definition: parseaut.hh:333
basic_symbol< by_type > symbol_type
"External" symbols: returned by the scanner.
Definition: parseaut.hh:411
basic_symbol()
Default constructor.
spot::location location_type
Symbol locations.
Definition: parseaut.hh:263
Definition: parseaut.hh:66
A Bison parser.
Definition: parseaut.hh:240
parser(result_ &res_yyarg, spot::location initial_loc_yyarg)
Build a parser object.
Definition: parseaut.hh:342
void set_debug_stream(std::ostream &)
Set the current debugging stream.
by_type()
Default constructor.
Definition: acc.hh:300
location_type location
The location.
Definition: parseaut.hh:371
int symbol_number_type
Internal symbol number.
Definition: parseaut.hh:330
Definition: acc.hh:34
int debug_level_type
Type for debugging levels.
Definition: parseaut.hh:429

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Fri Dec 4 2015 07:31:52 for spot by doxygen 1.8.8