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

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Sun Oct 11 2015 10:50:08 for spot by doxygen 1.8.9.1