spot  1.99.5
 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;
99  std::string format_version;
100  spot::location format_version_loc;
101  spot::environment* env;
102  formula_cache fcache;
103  named_tgba_t* namer = nullptr;
104  spot::acc_mapper_int* acc_mapper = nullptr;
105  std::vector<int> ap;
106  std::vector<bdd> guards;
107  std::vector<bdd>::const_iterator cur_guard;
108  map_t dest_map;
109  std::vector<state_info> info_states; // States declared and used.
110  std::vector<std::pair<spot::location, unsigned>> start; // Initial states;
111  std::unordered_map<std::string, bdd> alias;
112  std::unordered_map<std::string, spot::location> props;
113  spot::location states_loc;
114  spot::location ap_loc;
115  spot::location state_label_loc;
116  spot::location accset_loc;
117  spot::acc_cond::mark_t acc_state;
118  spot::acc_cond::mark_t neg_acc_sets = 0U;
119  spot::acc_cond::mark_t pos_acc_sets = 0U;
120  int plus;
121  int minus;
122  std::vector<std::string>* state_names = nullptr;
123  std::map<unsigned, unsigned> states_map;
124  std::set<int> ap_set;
125  unsigned cur_state;
126  int states = -1;
127  int ap_count = -1;
128  int accset = -1;
129  bdd state_label;
130  bdd cur_label;
131  bool has_state_label = false;
132  bool ignore_more_ap = false; // Set to true after the first "AP:"
133  // line has been read.
134  bool ignore_acc = false; // Set to true in case of missing
135  // Acceptance: lines.
136  bool ignore_acc_silent = false;
137  bool ignore_more_acc = false; // Set to true after the first
138  // "Acceptance:" line has been read.
139 
140  label_style_t label_style = Mixed_Labels;
141  acc_style_t acc_style = Mixed_Acc;
142 
143  bool accept_all_needed = false;
144  bool accept_all_seen = false;
145  bool aliased_states = false;
146 
147  bool deterministic = false;
148  bool complete = false;
149  bool trans_acc_seen = false;
150 
151  std::map<std::string, spot::location> labels;
152 
153  ~result_()
154  {
155  delete namer;
156  delete acc_mapper;
157  }
158  };
159  }
160 
161 #line 162 "parseaut.hh" // lalr1.cc:372
162 
163 
164 # include <vector>
165 # include <iostream>
166 # include <stdexcept>
167 # include <string>
168 # include "stack.hh"
169 
170 
171 
172 #ifndef YY_ATTRIBUTE
173 # if (defined __GNUC__ \
174  && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
175  || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
176 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
177 # else
178 # define YY_ATTRIBUTE(Spec) /* empty */
179 # endif
180 #endif
181 
182 #ifndef YY_ATTRIBUTE_PURE
183 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
184 #endif
185 
186 #ifndef YY_ATTRIBUTE_UNUSED
187 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
188 #endif
189 
190 #if !defined _Noreturn \
191  && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
192 # if defined _MSC_VER && 1200 <= _MSC_VER
193 # define _Noreturn __declspec (noreturn)
194 # else
195 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
196 # endif
197 #endif
198 
199 /* Suppress unused-variable warnings by "using" E. */
200 #if ! defined lint || defined __GNUC__
201 # define YYUSE(E) ((void) (E))
202 #else
203 # define YYUSE(E) /* empty */
204 #endif
205 
206 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
207 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
208 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
209  _Pragma ("GCC diagnostic push") \
210  _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
211  _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
212 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
213  _Pragma ("GCC diagnostic pop")
214 #else
215 # define YY_INITIAL_VALUE(Value) Value
216 #endif
217 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
218 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
219 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
220 #endif
221 #ifndef YY_INITIAL_VALUE
222 # define YY_INITIAL_VALUE(Value) /* Nothing. */
223 #endif
224 
225 /* Debug traces. */
226 #ifndef YYDEBUG
227 # define YYDEBUG 1
228 #endif
229 
230 
231 namespace hoayy {
232 #line 233 "parseaut.hh" // lalr1.cc:372
233 
234 
235 
236 
237 
239  class parser
240  {
241  public:
242 #ifndef YYSTYPE
243  union semantic_type
245  {
246  #line 155 "parseaut.yy" // lalr1.cc:372
247 
248  std::string* str;
249  unsigned int num;
250  int b;
252  pair* p;
253  std::list<pair>* list;
255 
256 #line 257 "parseaut.hh" // lalr1.cc:372
257  };
258 #else
259  typedef YYSTYPE semantic_type;
260 #endif
261  typedef spot::location location_type;
263 
265  struct syntax_error : std::runtime_error
266  {
267  syntax_error (const location_type& l, const std::string& m);
268  location_type location;
269  };
270 
272  struct token
273  {
274  enum yytokentype
275  {
276  ENDOFFILE = 0,
277  HOA = 258,
278  STATES = 259,
279  START = 260,
280  AP = 261,
281  ALIAS = 262,
282  ACCEPTANCE = 263,
283  ACCNAME = 264,
284  TOOL = 265,
285  NAME = 266,
286  PROPERTIES = 267,
287  BODY = 268,
288  END = 269,
289  STATE = 270,
290  IDENTIFIER = 271,
291  HEADERNAME = 272,
292  ANAME = 273,
293  STRING = 274,
294  INT = 275,
295  DRA = 276,
296  DSA = 277,
297  V2 = 278,
298  EXPLICIT = 279,
299  ACCPAIRS = 280,
300  ACCSIG = 281,
301  ENDOFHEADER = 282,
302  NEVER = 283,
303  SKIP = 284,
304  IF = 285,
305  FI = 286,
306  DO = 287,
307  OD = 288,
308  ARROW = 289,
309  GOTO = 290,
310  FALSE = 291,
311  ATOMIC = 292,
312  ASSERT = 293,
313  FORMULA = 294,
314  ENDAUT = 295,
315  ENDDSTAR = 296,
316  LBTT = 297,
317  INT_S = 298,
318  LBTT_EMPTY = 299,
319  ACC = 300,
320  STATE_NUM = 301,
321  DEST_NUM = 302
322  };
323  };
324 
326  typedef token::yytokentype token_type;
327 
329  typedef int symbol_number_type;
330 
332  typedef unsigned char token_number_type;
333 
340  template <typename Base>
341  struct basic_symbol : Base
342  {
344  typedef Base super_type;
345 
347  basic_symbol ();
348 
350  basic_symbol (const basic_symbol& other);
351 
353  basic_symbol (typename Base::kind_type t,
354  const location_type& l);
355 
357  basic_symbol (typename Base::kind_type t,
358  const semantic_type& v,
359  const location_type& l);
360 
361  ~basic_symbol ();
362 
364  void move (basic_symbol& s);
365 
367  semantic_type value;
368 
370  location_type location;
371 
372  private:
374  basic_symbol& operator= (const basic_symbol& other);
375  };
376 
378  struct by_type
379  {
381  by_type ();
382 
384  by_type (const by_type& other);
385 
387  typedef token_type kind_type;
388 
390  by_type (kind_type t);
391 
393  void move (by_type& that);
394 
397  symbol_number_type type_get () const;
398 
400  token_type token () const;
401 
402  enum { empty = 0 };
403 
406  token_number_type type;
407  };
408 
411 
412 
414  parser (result_& res_yyarg, spot::location initial_loc_yyarg);
415  virtual ~parser ();
416 
419  virtual int parse ();
420 
421 #if YYDEBUG
422  std::ostream& debug_stream () const YY_ATTRIBUTE_PURE;
425  void set_debug_stream (std::ostream &);
426 
428  typedef int debug_level_type;
430  debug_level_type debug_level () const YY_ATTRIBUTE_PURE;
432  void set_debug_level (debug_level_type l);
433 #endif
434 
438  virtual void error (const location_type& loc, const std::string& msg);
439 
441  void error (const syntax_error& err);
442 
443  private:
445  parser (const parser&);
446  parser& operator= (const parser&);
447 
449  typedef int state_type;
450 
454  virtual std::string yysyntax_error_ (state_type yystate,
455  symbol_number_type yytoken) const;
456 
460  state_type yy_lr_goto_state_ (state_type yystate, int yysym);
461 
464  static bool yy_pact_value_is_default_ (int yyvalue);
465 
468  static bool yy_table_value_is_error_ (int yyvalue);
469 
470  static const short int yypact_ninf_;
471  static const signed char yytable_ninf_;
472 
474  static token_number_type yytranslate_ (int t);
475 
476  // Tables.
477  // YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
478  // STATE-NUM.
479  static const short int yypact_[];
480 
481  // YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
482  // Performed when YYTABLE does not specify something else to do. Zero
483  // means the default is an error.
484  static const unsigned char yydefact_[];
485 
486  // YYPGOTO[NTERM-NUM].
487  static const short int yypgoto_[];
488 
489  // YYDEFGOTO[NTERM-NUM].
490  static const short int yydefgoto_[];
491 
492  // YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
493  // positive, shift that token. If negative, reduce the rule whose
494  // number is the opposite. If YYTABLE_NINF, syntax error.
495  static const short int yytable_[];
496 
497  static const short int yycheck_[];
498 
499  // YYSTOS[STATE-NUM] -- The (internal number of the) accessing
500  // symbol of state STATE-NUM.
501  static const unsigned char yystos_[];
502 
503  // YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
504  static const unsigned char yyr1_[];
505 
506  // YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
507  static const unsigned char yyr2_[];
508 
509 
511  static std::string yytnamerr_ (const char *n);
512 
513 
515  static const char* const yytname_[];
516 #if YYDEBUG
517  // YYRLINE[YYN] -- Source line where rule number YYN was defined.
518  static const unsigned short int yyrline_[];
520  virtual void yy_reduce_print_ (int r);
522  virtual void yystack_print_ ();
523 
524  // Debugging.
525  int yydebug_;
526  std::ostream* yycdebug_;
527 
531  template <typename Base>
532  void yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const;
533 #endif
534 
539  template <typename Base>
540  void yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const;
541 
542  private:
544  struct by_state
545  {
547  by_state ();
548 
550  typedef state_type kind_type;
551 
553  by_state (kind_type s);
554 
556  by_state (const by_state& other);
557 
559  void move (by_state& that);
560 
563  symbol_number_type type_get () const;
564 
565  enum { empty = 0 };
566 
568  state_type state;
569  };
570 
572  struct stack_symbol_type : basic_symbol<by_state>
573  {
575  typedef basic_symbol<by_state> super_type;
577  stack_symbol_type ();
579  stack_symbol_type (state_type s, symbol_type& sym);
581  stack_symbol_type& operator= (const stack_symbol_type& that);
582  };
583 
585  typedef stack<stack_symbol_type> stack_type;
586 
588  stack_type yystack_;
589 
595  void yypush_ (const char* m, stack_symbol_type& s);
596 
603  void yypush_ (const char* m, state_type s, symbol_type& sym);
604 
606  void yypop_ (unsigned int n = 1);
607 
608  // Constants.
609  enum
610  {
611  yyeof_ = 0,
612  yylast_ = 220,
613  yynnts_ = 77,
614  yyempty_ = -2,
615  yyfinal_ = 24,
616  yyterror_ = 1,
617  yyerrcode_ = 256,
618  yyntokens_ = 63
619  };
620 
621 
622  // User arguments.
623  result_& res;
624  spot::location initial_loc;
625  };
626 
627 
628 
629 } // hoayy
630 #line 631 "parseaut.hh" // lalr1.cc:372
631 
632 
633 
634 
635 #endif // !YY_HOAYY_PARSEAUT_HH_INCLUDED
token_number_type type
Definition: parseaut.hh:406
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:244
semantic_type value
The semantic value.
Definition: parseaut.hh:367
void move(basic_symbol &s)
Destructive move, s is emptied into this.
Syntax errors thrown from user actions.
Definition: parseaut.hh:265
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:326
Definition: parseaut.hh:231
virtual int parse()
Definition: public.hh:83
Tokens.
Definition: parseaut.hh:272
std::ostream & debug_stream() const
The current debugging stream.
Type access provider for token (enum) based symbols.
Definition: parseaut.hh:378
token_type kind_type
The symbol type as needed by the constructor.
Definition: parseaut.hh:387
Base super_type
Alias to Base.
Definition: parseaut.hh:344
symbol_number_type type_get() const
unsigned char token_number_type
Internal symbol number for tokens (subsumed by symbol_number_type).
Definition: parseaut.hh:332
basic_symbol< by_type > symbol_type
"External" symbols: returned by the scanner.
Definition: parseaut.hh:410
basic_symbol()
Default constructor.
spot::location location_type
Symbol locations.
Definition: parseaut.hh:262
Definition: parseaut.hh:66
A Bison parser.
Definition: parseaut.hh:239
parser(result_ &res_yyarg, spot::location initial_loc_yyarg)
Build a parser object.
Definition: parseaut.hh:341
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:370
int symbol_number_type
Internal symbol number.
Definition: parseaut.hh:329
Definition: acc.hh:34
int debug_level_type
Type for debugging levels.
Definition: parseaut.hh:428

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Tue Nov 3 2015 13:13:26 for spot by doxygen 1.8.8