spot  1.99.3
 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 "ltlast/constant.hh"
51 #include "twa/formula2bdd.hh"
52 #include "public.hh"
53 #include "priv/accmap.hh"
54 #include "ltlparse/public.hh"
55 
56  inline namespace hoayy_support
57  {
58  /* Cache parsed formulae. Labels on arcs are frequently identical
59  and it would be a waste of time to parse them to formula* over and
60  over, and to register all their atomic_propositions in the
61  bdd_dict. Keep the bdd result around so we can reuse it. */
62  typedef std::map<std::string, bdd> formula_cache;
63 
64  typedef std::pair<int, std::string*> pair;
65  typedef spot::twa_graph::namer<std::string> named_tgba_t;
66 
67  // Note: because this parser is meant to be used on a stream of
68  // automata, it tries hard to recover from errors, so that we get a
69  // chance to reach the end of the current automaton in order to
70  // process the next one. Several variables below are used to keep
71  // track of various error conditions.
72  enum label_style_t { Mixed_Labels, State_Labels, Trans_Labels,
73  Implicit_Labels };
74  enum acc_style_t { Mixed_Acc, State_Acc, Trans_Acc };
75 
76  struct result_
77  {
78  struct state_info
79  {
80  bool declared = false;
81  bool used = false;
82  spot::location used_loc;
83  };
84  spot::parsed_aut_ptr h;
86  formula_cache fcache;
87  named_tgba_t* namer = nullptr;
88  spot::acc_mapper_int* acc_mapper = nullptr;
89  std::vector<int> ap;
90  std::vector<bdd> guards;
91  std::vector<bdd>::const_iterator cur_guard;
92  std::vector<state_info> info_states; // States declared and used.
93  std::vector<std::pair<spot::location, unsigned>> start; // Initial states;
94  std::unordered_map<std::string, bdd> alias;
95  std::unordered_map<std::string, spot::location> props;
96  spot::location states_loc;
97  spot::location ap_loc;
98  spot::location state_label_loc;
99  spot::location accset_loc;
100  spot::acc_cond::mark_t acc_state;
101  spot::acc_cond::mark_t neg_acc_sets = 0U;
102  spot::acc_cond::mark_t pos_acc_sets = 0U;
103  std::vector<std::string>* state_names = nullptr;
104  std::map<unsigned, unsigned> states_map;
105  std::set<int> ap_set;
106  unsigned cur_state;
107  int states = -1;
108  int ap_count = -1;
109  int accset = -1;
110  bdd state_label;
111  bdd cur_label;
112  bool has_state_label = false;
113  bool ignore_more_ap = false; // Set to true after the first "AP:"
114  // line has been read.
115  bool ignore_acc = false; // Set to true in case of missing
116  // Acceptance: lines.
117  bool ignore_acc_silent = false;
118  bool ignore_more_acc = false; // Set to true after the first
119  // "Acceptance:" line has been read.
120 
121  label_style_t label_style = Mixed_Labels;
122  acc_style_t acc_style = Mixed_Acc;
123 
124  bool accept_all_needed = false;
125  bool accept_all_seen = false;
126  bool aliased_states = false;
127 
128  bool deterministic = false;
129  bool complete = false;
130  bool trans_acc_seen = false;
131 
132  std::map<std::string, spot::location> labels;
133 
134  ~result_()
135  {
136  delete namer;
137  delete acc_mapper;
138  }
139  };
140  }
141 
142 #line 143 "parseaut.hh" // lalr1.cc:372
143 
144 
145 # include <vector>
146 # include <iostream>
147 # include <stdexcept>
148 # include <string>
149 # include "stack.hh"
150 
151 
152 
153 #ifndef YY_ATTRIBUTE
154 # if (defined __GNUC__ \
155  && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
156  || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
157 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
158 # else
159 # define YY_ATTRIBUTE(Spec) /* empty */
160 # endif
161 #endif
162 
163 #ifndef YY_ATTRIBUTE_PURE
164 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
165 #endif
166 
167 #ifndef YY_ATTRIBUTE_UNUSED
168 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
169 #endif
170 
171 #if !defined _Noreturn \
172  && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
173 # if defined _MSC_VER && 1200 <= _MSC_VER
174 # define _Noreturn __declspec (noreturn)
175 # else
176 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
177 # endif
178 #endif
179 
180 /* Suppress unused-variable warnings by "using" E. */
181 #if ! defined lint || defined __GNUC__
182 # define YYUSE(E) ((void) (E))
183 #else
184 # define YYUSE(E) /* empty */
185 #endif
186 
187 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
188 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
189 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
190  _Pragma ("GCC diagnostic push") \
191  _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
192  _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
193 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
194  _Pragma ("GCC diagnostic pop")
195 #else
196 # define YY_INITIAL_VALUE(Value) Value
197 #endif
198 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
199 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
200 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
201 #endif
202 #ifndef YY_INITIAL_VALUE
203 # define YY_INITIAL_VALUE(Value) /* Nothing. */
204 #endif
205 
206 /* Debug traces. */
207 #ifndef YYDEBUG
208 # define YYDEBUG 1
209 #endif
210 
211 
212 namespace hoayy {
213 #line 214 "parseaut.hh" // lalr1.cc:372
214 
215 
216 
217 
218 
220  class parser
221  {
222  public:
223 #ifndef YYSTYPE
224  union semantic_type
226  {
227  #line 137 "parseaut.yy" // lalr1.cc:372
228 
229  std::string* str;
230  unsigned int num;
231  int b;
233  pair* p;
234  std::list<pair>* list;
236 
237 #line 238 "parseaut.hh" // lalr1.cc:372
238  };
239 #else
240  typedef YYSTYPE semantic_type;
241 #endif
242  typedef spot::location location_type;
244 
246  struct syntax_error : std::runtime_error
247  {
248  syntax_error (const location_type& l, const std::string& m);
249  location_type location;
250  };
251 
253  struct token
254  {
255  enum yytokentype
256  {
257  ENDOFFILE = 0,
258  HOA = 258,
259  STATES = 259,
260  START = 260,
261  AP = 261,
262  ALIAS = 262,
263  ACCEPTANCE = 263,
264  ACCNAME = 264,
265  TOOL = 265,
266  NAME = 266,
267  PROPERTIES = 267,
268  BODY = 268,
269  END = 269,
270  STATE = 270,
271  IDENTIFIER = 271,
272  HEADERNAME = 272,
273  ANAME = 273,
274  STRING = 274,
275  INT = 275,
276  NEVER = 276,
277  SKIP = 277,
278  IF = 278,
279  FI = 279,
280  DO = 280,
281  OD = 281,
282  ARROW = 282,
283  GOTO = 283,
284  FALSE = 284,
285  ATOMIC = 285,
286  ASSERT = 286,
287  FORMULA = 287,
288  ENDAUT = 288,
289  LBTT = 289,
290  INT_S = 290,
291  LBTT_EMPTY = 291,
292  ACC = 292,
293  STATE_NUM = 293,
294  DEST_NUM = 294
295  };
296  };
297 
299  typedef token::yytokentype token_type;
300 
302  typedef int symbol_number_type;
303 
305  typedef unsigned char token_number_type;
306 
313  template <typename Base>
314  struct basic_symbol : Base
315  {
317  typedef Base super_type;
318 
320  basic_symbol ();
321 
323  basic_symbol (const basic_symbol& other);
324 
326  basic_symbol (typename Base::kind_type t,
327  const location_type& l);
328 
330  basic_symbol (typename Base::kind_type t,
331  const semantic_type& v,
332  const location_type& l);
333 
334  ~basic_symbol ();
335 
337  void move (basic_symbol& s);
338 
340  semantic_type value;
341 
343  location_type location;
344 
345  private:
347  basic_symbol& operator= (const basic_symbol& other);
348  };
349 
351  struct by_type
352  {
354  by_type ();
355 
357  by_type (const by_type& other);
358 
360  typedef token_type kind_type;
361 
363  by_type (kind_type t);
364 
366  void move (by_type& that);
367 
370  symbol_number_type type_get () const;
371 
373  token_type token () const;
374 
375  enum { empty = 0 };
376 
379  token_number_type type;
380  };
381 
384 
385 
387  parser (spot::parse_aut_error_list& error_list_yyarg, result_& res_yyarg, spot::location initial_loc_yyarg);
388  virtual ~parser ();
389 
392  virtual int parse ();
393 
394 #if YYDEBUG
395  std::ostream& debug_stream () const YY_ATTRIBUTE_PURE;
398  void set_debug_stream (std::ostream &);
399 
401  typedef int debug_level_type;
403  debug_level_type debug_level () const YY_ATTRIBUTE_PURE;
405  void set_debug_level (debug_level_type l);
406 #endif
407 
411  virtual void error (const location_type& loc, const std::string& msg);
412 
414  void error (const syntax_error& err);
415 
416  private:
418  parser (const parser&);
419  parser& operator= (const parser&);
420 
422  typedef int state_type;
423 
427  virtual std::string yysyntax_error_ (state_type yystate,
428  symbol_number_type yytoken) const;
429 
433  state_type yy_lr_goto_state_ (state_type yystate, int yysym);
434 
437  static bool yy_pact_value_is_default_ (int yyvalue);
438 
441  static bool yy_table_value_is_error_ (int yyvalue);
442 
443  static const short int yypact_ninf_;
444  static const signed char yytable_ninf_;
445 
447  static token_number_type yytranslate_ (int t);
448 
449  // Tables.
450  // YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
451  // STATE-NUM.
452  static const short int yypact_[];
453 
454  // YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
455  // Performed when YYTABLE does not specify something else to do. Zero
456  // means the default is an error.
457  static const unsigned char yydefact_[];
458 
459  // YYPGOTO[NTERM-NUM].
460  static const short int yypgoto_[];
461 
462  // YYDEFGOTO[NTERM-NUM].
463  static const short int yydefgoto_[];
464 
465  // YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
466  // positive, shift that token. If negative, reduce the rule whose
467  // number is the opposite. If YYTABLE_NINF, syntax error.
468  static const short int yytable_[];
469 
470  static const short int yycheck_[];
471 
472  // YYSTOS[STATE-NUM] -- The (internal number of the) accessing
473  // symbol of state STATE-NUM.
474  static const unsigned char yystos_[];
475 
476  // YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
477  static const unsigned char yyr1_[];
478 
479  // YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
480  static const unsigned char yyr2_[];
481 
482 
484  static std::string yytnamerr_ (const char *n);
485 
486 
488  static const char* const yytname_[];
489 #if YYDEBUG
490  // YYRLINE[YYN] -- Source line where rule number YYN was defined.
491  static const unsigned short int yyrline_[];
493  virtual void yy_reduce_print_ (int r);
495  virtual void yystack_print_ ();
496 
497  // Debugging.
498  int yydebug_;
499  std::ostream* yycdebug_;
500 
504  template <typename Base>
505  void yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const;
506 #endif
507 
512  template <typename Base>
513  void yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const;
514 
515  private:
517  struct by_state
518  {
520  by_state ();
521 
523  typedef state_type kind_type;
524 
526  by_state (kind_type s);
527 
529  by_state (const by_state& other);
530 
532  void move (by_state& that);
533 
536  symbol_number_type type_get () const;
537 
538  enum { empty = 0 };
539 
541  state_type state;
542  };
543 
545  struct stack_symbol_type : basic_symbol<by_state>
546  {
548  typedef basic_symbol<by_state> super_type;
550  stack_symbol_type ();
552  stack_symbol_type (state_type s, symbol_type& sym);
554  stack_symbol_type& operator= (const stack_symbol_type& that);
555  };
556 
558  typedef stack<stack_symbol_type> stack_type;
559 
561  stack_type yystack_;
562 
568  void yypush_ (const char* m, stack_symbol_type& s);
569 
576  void yypush_ (const char* m, state_type s, symbol_type& sym);
577 
579  void yypop_ (unsigned int n = 1);
580 
581  // Constants.
582  enum
583  {
584  yyeof_ = 0,
585  yylast_ = 186,
586  yynnts_ = 67,
587  yyempty_ = -2,
588  yyfinal_ = 20,
589  yyterror_ = 1,
590  yyerrcode_ = 256,
591  yyntokens_ = 53
592  };
593 
594 
595  // User arguments.
596  spot::parse_aut_error_list& error_list;
597  result_& res;
598  spot::location initial_loc;
599  };
600 
601 
602 
603 } // hoayy
604 #line 605 "parseaut.hh" // lalr1.cc:372
605 
606 
607 
608 
609 #endif // !YY_HOAYY_PARSEAUT_HH_INCLUDED
token_number_type type
Definition: parseaut.hh:379
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.
Definition: parseaut.hh:76
Symbol semantic values.
Definition: parseaut.hh:225
semantic_type value
The semantic value.
Definition: parseaut.hh:340
void move(basic_symbol &s)
Destructive move, s is emptied into this.
std::ostream & debug_stream() const YY_ATTRIBUTE_PURE
The current debugging stream.
LTL constants.
Syntax errors thrown from user actions.
Definition: parseaut.hh:246
void set_debug_level(debug_level_type l)
Set the current debugging level.
Definition: formula.hh:515
Definition: parseaut.hh:78
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:299
Definition: parseaut.hh:212
virtual int parse()
Tokens.
Definition: parseaut.hh:253
Type access provider for token (enum) based symbols.
Definition: parseaut.hh:351
token_type kind_type
The symbol type as needed by the constructor.
Definition: parseaut.hh:360
Base super_type
Alias to Base.
Definition: parseaut.hh:317
symbol_number_type type_get() const
unsigned char token_number_type
Internal symbol number for tokens (subsumed by symbol_number_type).
Definition: parseaut.hh:305
basic_symbol< by_type > symbol_type
"External" symbols: returned by the scanner.
Definition: parseaut.hh:383
basic_symbol()
Default constructor.
spot::location location_type
Symbol locations.
Definition: parseaut.hh:243
Definition: parseaut.hh:56
An environment that describes atomic propositions.
Definition: environment.hh:34
A Bison parser.
Definition: parseaut.hh:220
debug_level_type debug_level() const YY_ATTRIBUTE_PURE
The current debugging level.
Definition: parseaut.hh:314
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:343
int symbol_number_type
Internal symbol number.
Definition: parseaut.hh:302
Definition: acc.hh:34
int debug_level_type
Type for debugging levels.
Definition: parseaut.hh:401

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Wed Aug 26 2015 08:42:37 for spot by doxygen 1.8.8