spot  1.99.4
 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 <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:372
148 
149 
150 # include <vector>
151 # include <iostream>
152 # include <stdexcept>
153 # include <string>
154 # include "stack.hh"
155 
156 
157 
158 #ifndef YY_ATTRIBUTE
159 # if (defined __GNUC__ \
160  && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
161  || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
162 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
163 # else
164 # define YY_ATTRIBUTE(Spec) /* empty */
165 # endif
166 #endif
167 
168 #ifndef YY_ATTRIBUTE_PURE
169 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
170 #endif
171 
172 #ifndef YY_ATTRIBUTE_UNUSED
173 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
174 #endif
175 
176 #if !defined _Noreturn \
177  && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
178 # if defined _MSC_VER && 1200 <= _MSC_VER
179 # define _Noreturn __declspec (noreturn)
180 # else
181 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
182 # endif
183 #endif
184 
185 /* Suppress unused-variable warnings by "using" E. */
186 #if ! defined lint || defined __GNUC__
187 # define YYUSE(E) ((void) (E))
188 #else
189 # define YYUSE(E) /* empty */
190 #endif
191 
192 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
193 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
194 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
195  _Pragma ("GCC diagnostic push") \
196  _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
197  _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
198 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
199  _Pragma ("GCC diagnostic pop")
200 #else
201 # define YY_INITIAL_VALUE(Value) Value
202 #endif
203 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
204 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
205 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
206 #endif
207 #ifndef YY_INITIAL_VALUE
208 # define YY_INITIAL_VALUE(Value) /* Nothing. */
209 #endif
210 
211 /* Debug traces. */
212 #ifndef YYDEBUG
213 # define YYDEBUG 1
214 #endif
215 
216 
217 namespace hoayy {
218 #line 219 "parseaut.hh" // lalr1.cc:372
219 
220 
221 
222 
223 
225  class parser
226  {
227  public:
228 #ifndef YYSTYPE
229  union semantic_type
231  {
232  #line 142 "parseaut.yy" // lalr1.cc:372
233 
234  std::string* str;
235  unsigned int num;
236  int b;
238  pair* p;
239  std::list<pair>* list;
241 
242 #line 243 "parseaut.hh" // lalr1.cc:372
243  };
244 #else
245  typedef YYSTYPE semantic_type;
246 #endif
247  typedef spot::location location_type;
249 
251  struct syntax_error : std::runtime_error
252  {
253  syntax_error (const location_type& l, const std::string& m);
254  location_type location;
255  };
256 
258  struct token
259  {
260  enum yytokentype
261  {
262  ENDOFFILE = 0,
263  HOA = 258,
264  STATES = 259,
265  START = 260,
266  AP = 261,
267  ALIAS = 262,
268  ACCEPTANCE = 263,
269  ACCNAME = 264,
270  TOOL = 265,
271  NAME = 266,
272  PROPERTIES = 267,
273  BODY = 268,
274  END = 269,
275  STATE = 270,
276  IDENTIFIER = 271,
277  HEADERNAME = 272,
278  ANAME = 273,
279  STRING = 274,
280  INT = 275,
281  DRA = 276,
282  DSA = 277,
283  V2 = 278,
284  EXPLICIT = 279,
285  ACCPAIRS = 280,
286  ACCSIG = 281,
287  ENDOFHEADER = 282,
288  NEVER = 283,
289  SKIP = 284,
290  IF = 285,
291  FI = 286,
292  DO = 287,
293  OD = 288,
294  ARROW = 289,
295  GOTO = 290,
296  FALSE = 291,
297  ATOMIC = 292,
298  ASSERT = 293,
299  FORMULA = 294,
300  ENDAUT = 295,
301  ENDDSTAR = 296,
302  LBTT = 297,
303  INT_S = 298,
304  LBTT_EMPTY = 299,
305  ACC = 300,
306  STATE_NUM = 301,
307  DEST_NUM = 302
308  };
309  };
310 
312  typedef token::yytokentype token_type;
313 
315  typedef int symbol_number_type;
316 
318  typedef unsigned char token_number_type;
319 
326  template <typename Base>
327  struct basic_symbol : Base
328  {
330  typedef Base super_type;
331 
333  basic_symbol ();
334 
336  basic_symbol (const basic_symbol& other);
337 
339  basic_symbol (typename Base::kind_type t,
340  const location_type& l);
341 
343  basic_symbol (typename Base::kind_type t,
344  const semantic_type& v,
345  const location_type& l);
346 
347  ~basic_symbol ();
348 
350  void move (basic_symbol& s);
351 
353  semantic_type value;
354 
356  location_type location;
357 
358  private:
360  basic_symbol& operator= (const basic_symbol& other);
361  };
362 
364  struct by_type
365  {
367  by_type ();
368 
370  by_type (const by_type& other);
371 
373  typedef token_type kind_type;
374 
376  by_type (kind_type t);
377 
379  void move (by_type& that);
380 
383  symbol_number_type type_get () const;
384 
386  token_type token () const;
387 
388  enum { empty = 0 };
389 
392  token_number_type type;
393  };
394 
397 
398 
400  parser (spot::parse_aut_error_list& error_list_yyarg, result_& res_yyarg, spot::location initial_loc_yyarg);
401  virtual ~parser ();
402 
405  virtual int parse ();
406 
407 #if YYDEBUG
408  std::ostream& debug_stream () const YY_ATTRIBUTE_PURE;
411  void set_debug_stream (std::ostream &);
412 
414  typedef int debug_level_type;
416  debug_level_type debug_level () const YY_ATTRIBUTE_PURE;
418  void set_debug_level (debug_level_type l);
419 #endif
420 
424  virtual void error (const location_type& loc, const std::string& msg);
425 
427  void error (const syntax_error& err);
428 
429  private:
431  parser (const parser&);
432  parser& operator= (const parser&);
433 
435  typedef int state_type;
436 
440  virtual std::string yysyntax_error_ (state_type yystate,
441  symbol_number_type yytoken) const;
442 
446  state_type yy_lr_goto_state_ (state_type yystate, int yysym);
447 
450  static bool yy_pact_value_is_default_ (int yyvalue);
451 
454  static bool yy_table_value_is_error_ (int yyvalue);
455 
456  static const short int yypact_ninf_;
457  static const signed char yytable_ninf_;
458 
460  static token_number_type yytranslate_ (int t);
461 
462  // Tables.
463  // YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
464  // STATE-NUM.
465  static const short int yypact_[];
466 
467  // YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
468  // Performed when YYTABLE does not specify something else to do. Zero
469  // means the default is an error.
470  static const unsigned char yydefact_[];
471 
472  // YYPGOTO[NTERM-NUM].
473  static const short int yypgoto_[];
474 
475  // YYDEFGOTO[NTERM-NUM].
476  static const short int yydefgoto_[];
477 
478  // YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
479  // positive, shift that token. If negative, reduce the rule whose
480  // number is the opposite. If YYTABLE_NINF, syntax error.
481  static const short int yytable_[];
482 
483  static const short int yycheck_[];
484 
485  // YYSTOS[STATE-NUM] -- The (internal number of the) accessing
486  // symbol of state STATE-NUM.
487  static const unsigned char yystos_[];
488 
489  // YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
490  static const unsigned char yyr1_[];
491 
492  // YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
493  static const unsigned char yyr2_[];
494 
495 
497  static std::string yytnamerr_ (const char *n);
498 
499 
501  static const char* const yytname_[];
502 #if YYDEBUG
503  // YYRLINE[YYN] -- Source line where rule number YYN was defined.
504  static const unsigned short int yyrline_[];
506  virtual void yy_reduce_print_ (int r);
508  virtual void yystack_print_ ();
509 
510  // Debugging.
511  int yydebug_;
512  std::ostream* yycdebug_;
513 
517  template <typename Base>
518  void yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const;
519 #endif
520 
525  template <typename Base>
526  void yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const;
527 
528  private:
530  struct by_state
531  {
533  by_state ();
534 
536  typedef state_type kind_type;
537 
539  by_state (kind_type s);
540 
542  by_state (const by_state& other);
543 
545  void move (by_state& that);
546 
549  symbol_number_type type_get () const;
550 
551  enum { empty = 0 };
552 
554  state_type state;
555  };
556 
558  struct stack_symbol_type : basic_symbol<by_state>
559  {
561  typedef basic_symbol<by_state> super_type;
563  stack_symbol_type ();
565  stack_symbol_type (state_type s, symbol_type& sym);
567  stack_symbol_type& operator= (const stack_symbol_type& that);
568  };
569 
571  typedef stack<stack_symbol_type> stack_type;
572 
574  stack_type yystack_;
575 
581  void yypush_ (const char* m, stack_symbol_type& s);
582 
589  void yypush_ (const char* m, state_type s, symbol_type& sym);
590 
592  void yypop_ (unsigned int n = 1);
593 
594  // Constants.
595  enum
596  {
597  yyeof_ = 0,
598  yylast_ = 220,
599  yynnts_ = 77,
600  yyempty_ = -2,
601  yyfinal_ = 24,
602  yyterror_ = 1,
603  yyerrcode_ = 256,
604  yyntokens_ = 63
605  };
606 
607 
608  // User arguments.
609  spot::parse_aut_error_list& error_list;
610  result_& res;
611  spot::location initial_loc;
612  };
613 
614 
615 
616 } // hoayy
617 #line 618 "parseaut.hh" // lalr1.cc:372
618 
619 
620 
621 
622 #endif // !YY_HOAYY_PARSEAUT_HH_INCLUDED
token_number_type type
Definition: parseaut.hh:392
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:230
semantic_type value
The semantic value.
Definition: parseaut.hh:353
void move(basic_symbol &s)
Destructive move, s is emptied into this.
Syntax errors thrown from user actions.
Definition: parseaut.hh:251
void set_debug_level(debug_level_type l)
Set the current debugging level.
Definition: formula.hh:1539
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:312
Definition: parseaut.hh:217
virtual int parse()
Tokens.
Definition: parseaut.hh:258
std::ostream & debug_stream() const
The current debugging stream.
Type access provider for token (enum) based symbols.
Definition: parseaut.hh:364
token_type kind_type
The symbol type as needed by the constructor.
Definition: parseaut.hh:373
Base super_type
Alias to Base.
Definition: parseaut.hh:330
symbol_number_type type_get() const
unsigned char token_number_type
Internal symbol number for tokens (subsumed by symbol_number_type).
Definition: parseaut.hh:318
basic_symbol< by_type > symbol_type
"External" symbols: returned by the scanner.
Definition: parseaut.hh:396
basic_symbol()
Default constructor.
spot::location location_type
Symbol locations.
Definition: parseaut.hh:248
Definition: parseaut.hh:55
A Bison parser.
Definition: parseaut.hh:225
Definition: parseaut.hh:327
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:356
int symbol_number_type
Internal symbol number.
Definition: parseaut.hh:315
Definition: acc.hh:34
int debug_level_type
Type for debugging levels.
Definition: parseaut.hh:414

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Thu Oct 1 2015 05:49:14 for spot by doxygen 1.8.8