spot  1.99.7
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 "config.h"
46 #include <spot/misc/common.hh>
47 #include <string>
48 #include <cstring>
49 #include <sstream>
50 #include <unordered_map>
51 #include <algorithm>
52 #include <spot/twa/formula2bdd.hh>
53 #include <spot/parseaut/public.hh>
54 #include "spot/priv/accmap.hh"
55 #include <spot/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  struct prop_info
114  {
115  spot::location loc;
116  bool val;
117  operator bool() const
118  {
119  return val;
120  };
121  };
122  std::unordered_map<std::string, prop_info> props;
123  spot::location states_loc;
124  spot::location ap_loc;
125  spot::location state_label_loc;
126  spot::location accset_loc;
127  spot::acc_cond::mark_t acc_state;
128  spot::acc_cond::mark_t neg_acc_sets = 0U;
129  spot::acc_cond::mark_t pos_acc_sets = 0U;
130  int plus;
131  int minus;
132  std::vector<std::string>* state_names = nullptr;
133  std::map<unsigned, unsigned> states_map;
134  std::set<int> ap_set;
135  unsigned cur_state;
136  int states = -1;
137  int ap_count = -1;
138  int accset = -1;
139  bdd state_label;
140  bdd cur_label;
141  bool has_state_label = false;
142  bool ignore_more_ap = false; // Set to true after the first "AP:"
143  // line has been read.
144  bool ignore_acc = false; // Set to true in case of missing
145  // Acceptance: lines.
146  bool ignore_acc_silent = false;
147  bool ignore_more_acc = false; // Set to true after the first
148  // "Acceptance:" line has been read.
149 
150  label_style_t label_style = Mixed_Labels;
151  acc_style_t acc_style = Mixed_Acc;
152 
153  bool accept_all_needed = false;
154  bool accept_all_seen = false;
155  bool aliased_states = false;
156 
157  spot::trival deterministic = spot::trival::maybe();
158  bool complete = false;
159  bool trans_acc_seen = false;
160 
161  std::map<std::string, spot::location> labels;
162 
163  prop_info prop_is_true(const std::string& p)
164  {
165  auto i = props.find(p);
166  if (i == props.end())
167  return prop_info{spot::location(), false};
168  return i->second;
169  }
170 
171  ~result_()
172  {
173  delete namer;
174  delete acc_mapper;
175  }
176  };
177  }
178 
179 #line 180 "parseaut.hh" // lalr1.cc:377
180 
181 
182 # include <cstdlib> // std::abort
183 # include <iostream>
184 # include <stdexcept>
185 # include <string>
186 # include <vector>
187 # include "stack.hh"
188 
189 
190 
191 #ifndef YY_ATTRIBUTE
192 # if (defined __GNUC__ \
193  && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
194  || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
195 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
196 # else
197 # define YY_ATTRIBUTE(Spec) /* empty */
198 # endif
199 #endif
200 
201 #ifndef YY_ATTRIBUTE_PURE
202 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
203 #endif
204 
205 #ifndef YY_ATTRIBUTE_UNUSED
206 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
207 #endif
208 
209 #if !defined _Noreturn \
210  && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
211 # if defined _MSC_VER && 1200 <= _MSC_VER
212 # define _Noreturn __declspec (noreturn)
213 # else
214 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
215 # endif
216 #endif
217 
218 /* Suppress unused-variable warnings by "using" E. */
219 #if ! defined lint || defined __GNUC__
220 # define YYUSE(E) ((void) (E))
221 #else
222 # define YYUSE(E) /* empty */
223 #endif
224 
225 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
226 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
227 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
228  _Pragma ("GCC diagnostic push") \
229  _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
230  _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
231 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
232  _Pragma ("GCC diagnostic pop")
233 #else
234 # define YY_INITIAL_VALUE(Value) Value
235 #endif
236 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
237 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
238 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
239 #endif
240 #ifndef YY_INITIAL_VALUE
241 # define YY_INITIAL_VALUE(Value) /* Nothing. */
242 #endif
243 
244 /* Debug traces. */
245 #ifndef YYDEBUG
246 # define YYDEBUG 1
247 #endif
248 
249 
250 namespace hoayy {
251 #line 252 "parseaut.hh" // lalr1.cc:377
252 
253 
254 
255 
256 
258  class parser
259  {
260  public:
261 #ifndef YYSTYPE
262  union semantic_type
264  {
265  #line 173 "parseaut.yy" // lalr1.cc:377
266 
267  std::string* str;
268  unsigned int num;
269  int b;
271  pair* p;
272  std::list<pair>* list;
274 
275 #line 276 "parseaut.hh" // lalr1.cc:377
276  };
277 #else
278  typedef YYSTYPE semantic_type;
279 #endif
280  typedef spot::location location_type;
282 
284  struct syntax_error : std::runtime_error
285  {
286  syntax_error (const location_type& l, const std::string& m);
287  location_type location;
288  };
289 
291  struct token
292  {
293  enum yytokentype
294  {
295  ENDOFFILE = 0,
296  HOA = 258,
297  STATES = 259,
298  START = 260,
299  AP = 261,
300  ALIAS = 262,
301  ACCEPTANCE = 263,
302  ACCNAME = 264,
303  TOOL = 265,
304  NAME = 266,
305  PROPERTIES = 267,
306  BODY = 268,
307  END = 269,
308  STATE = 270,
309  IDENTIFIER = 271,
310  HEADERNAME = 272,
311  ANAME = 273,
312  STRING = 274,
313  INT = 275,
314  DRA = 276,
315  DSA = 277,
316  V2 = 278,
317  EXPLICIT = 279,
318  ACCPAIRS = 280,
319  ACCSIG = 281,
320  ENDOFHEADER = 282,
321  NEVER = 283,
322  SKIP = 284,
323  IF = 285,
324  FI = 286,
325  DO = 287,
326  OD = 288,
327  ARROW = 289,
328  GOTO = 290,
329  FALSE = 291,
330  ATOMIC = 292,
331  ASSERT = 293,
332  FORMULA = 294,
333  ENDAUT = 295,
334  ENDDSTAR = 296,
335  LBTT = 297,
336  INT_S = 298,
337  LBTT_EMPTY = 299,
338  ACC = 300,
339  STATE_NUM = 301,
340  DEST_NUM = 302
341  };
342  };
343 
345  typedef token::yytokentype token_type;
346 
348  typedef int symbol_number_type;
349 
351  enum { empty_symbol = -2 };
352 
354  typedef unsigned char token_number_type;
355 
362  template <typename Base>
363  struct basic_symbol : Base
364  {
366  typedef Base super_type;
367 
369  basic_symbol ();
370 
372  basic_symbol (const basic_symbol& other);
373 
375  basic_symbol (typename Base::kind_type t,
376  const location_type& l);
377 
379  basic_symbol (typename Base::kind_type t,
380  const semantic_type& v,
381  const location_type& l);
382 
384  ~basic_symbol ();
385 
387  void clear ();
388 
390  bool empty () const;
391 
393  void move (basic_symbol& s);
394 
396  semantic_type value;
397 
399  location_type location;
400 
401  private:
403  basic_symbol& operator= (const basic_symbol& other);
404  };
405 
407  struct by_type
408  {
410  by_type ();
411 
413  by_type (const by_type& other);
414 
416  typedef token_type kind_type;
417 
419  by_type (kind_type t);
420 
422  void clear ();
423 
425  void move (by_type& that);
426 
429  symbol_number_type type_get () const;
430 
432  token_type token () const;
433 
437  int type;
438  };
439 
442 
443 
445  parser (result_& res_yyarg, spot::location initial_loc_yyarg);
446  virtual ~parser ();
447 
450  virtual int parse ();
451 
452 #if YYDEBUG
453  std::ostream& debug_stream () const YY_ATTRIBUTE_PURE;
456  void set_debug_stream (std::ostream &);
457 
459  typedef int debug_level_type;
461  debug_level_type debug_level () const YY_ATTRIBUTE_PURE;
463  void set_debug_level (debug_level_type l);
464 #endif
465 
469  virtual void error (const location_type& loc, const std::string& msg);
470 
472  void error (const syntax_error& err);
473 
474  private:
476  parser (const parser&);
477  parser& operator= (const parser&);
478 
480  typedef int state_type;
481 
485  virtual std::string yysyntax_error_ (state_type yystate,
486  const symbol_type& yyla) const;
487 
491  state_type yy_lr_goto_state_ (state_type yystate, int yysym);
492 
495  static bool yy_pact_value_is_default_ (int yyvalue);
496 
499  static bool yy_table_value_is_error_ (int yyvalue);
500 
501  static const short int yypact_ninf_;
502  static const signed char yytable_ninf_;
503 
505  static token_number_type yytranslate_ (int t);
506 
507  // Tables.
508  // YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
509  // STATE-NUM.
510  static const short int yypact_[];
511 
512  // YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
513  // Performed when YYTABLE does not specify something else to do. Zero
514  // means the default is an error.
515  static const unsigned char yydefact_[];
516 
517  // YYPGOTO[NTERM-NUM].
518  static const short int yypgoto_[];
519 
520  // YYDEFGOTO[NTERM-NUM].
521  static const short int yydefgoto_[];
522 
523  // YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
524  // positive, shift that token. If negative, reduce the rule whose
525  // number is the opposite. If YYTABLE_NINF, syntax error.
526  static const short int yytable_[];
527 
528  static const short int yycheck_[];
529 
530  // YYSTOS[STATE-NUM] -- The (internal number of the) accessing
531  // symbol of state STATE-NUM.
532  static const unsigned char yystos_[];
533 
534  // YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
535  static const unsigned char yyr1_[];
536 
537  // YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
538  static const unsigned char yyr2_[];
539 
540 
542  static std::string yytnamerr_ (const char *n);
543 
544 
546  static const char* const yytname_[];
547 #if YYDEBUG
548  // YYRLINE[YYN] -- Source line where rule number YYN was defined.
549  static const unsigned short int yyrline_[];
551  virtual void yy_reduce_print_ (int r);
553  virtual void yystack_print_ ();
554 
555  // Debugging.
556  int yydebug_;
557  std::ostream* yycdebug_;
558 
562  template <typename Base>
563  void yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const;
564 #endif
565 
570  template <typename Base>
571  void yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const;
572 
573  private:
575  struct by_state
576  {
578  by_state ();
579 
581  typedef state_type kind_type;
582 
584  by_state (kind_type s);
585 
587  by_state (const by_state& other);
588 
590  void clear ();
591 
593  void move (by_state& that);
594 
597  symbol_number_type type_get () const;
598 
600  enum { empty_state = -1 };
601 
604  state_type state;
605  };
606 
608  struct stack_symbol_type : basic_symbol<by_state>
609  {
611  typedef basic_symbol<by_state> super_type;
613  stack_symbol_type ();
615  stack_symbol_type (state_type s, symbol_type& sym);
617  stack_symbol_type& operator= (const stack_symbol_type& that);
618  };
619 
621  typedef stack<stack_symbol_type> stack_type;
622 
624  stack_type yystack_;
625 
631  void yypush_ (const char* m, stack_symbol_type& s);
632 
639  void yypush_ (const char* m, state_type s, symbol_type& sym);
640 
642  void yypop_ (unsigned int n = 1);
643 
645  enum
646  {
647  yyeof_ = 0,
648  yylast_ = 224,
649  yynnts_ = 77,
650  yyfinal_ = 24,
651  yyterror_ = 1,
652  yyerrcode_ = 256,
653  yyntokens_ = 63
654  };
655 
656 
657  // User arguments.
658  result_& res;
659  spot::location initial_loc;
660  };
661 
662 
663 
664 } // hoayy
665 #line 666 "parseaut.hh" // lalr1.cc:377
666 
667 
668 
669 
670 #endif // !YY_HOAYY_PARSEAUT_HH_INCLUDED
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:263
semantic_type value
The semantic value.
Definition: parseaut.hh:396
void move(basic_symbol &s)
Destructive move, s is emptied into this.
Syntax errors thrown from user actions.
Definition: parseaut.hh:284
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:345
Definition: parseaut.hh:250
virtual int parse()
Definition: public.hh:92
Definition: parseaut.hh:113
void clear()
Record that this symbol is empty.
Tokens.
Definition: parseaut.hh:291
std::ostream & debug_stream() const
The current debugging stream.
Type access provider for token (enum) based symbols.
Definition: parseaut.hh:407
token_type kind_type
The symbol type as needed by the constructor.
Definition: parseaut.hh:416
Base super_type
Alias to Base.
Definition: parseaut.hh:366
symbol_number_type type_get() const
unsigned char token_number_type
Internal symbol number for tokens (subsumed by symbol_number_type).
Definition: parseaut.hh:354
A class implementing Kleene's three-valued logic.
Definition: trival.hh:33
~basic_symbol()
Destroy the symbol.
int type
Definition: parseaut.hh:437
basic_symbol< by_type > symbol_type
"External" symbols: returned by the scanner.
Definition: parseaut.hh:441
basic_symbol()
Default constructor.
spot::location location_type
Symbol locations.
Definition: parseaut.hh:281
Definition: parseaut.hh:66
A Bison parser.
Definition: parseaut.hh:258
parser(result_ &res_yyarg, spot::location initial_loc_yyarg)
Build a parser object.
void clear()
Destroy contents, and record that is empty.
Definition: parseaut.hh:363
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:399
bool empty() const
Whether empty.
int symbol_number_type
Symbol type: an internal symbol number.
Definition: parseaut.hh:348
Definition: acc.hh:34
int debug_level_type
Type for debugging levels.
Definition: parseaut.hh:459

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Fri Jan 15 2016 13:01:49 for spot by doxygen 1.8.9.1