spot  1.99.8
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>* highlight_edges = nullptr;
134  std::map<unsigned, unsigned>* highlight_states = nullptr;
135  std::map<unsigned, unsigned> states_map;
136  std::set<int> ap_set;
137  unsigned cur_state;
138  int states = -1;
139  int ap_count = -1;
140  int accset = -1;
141  bdd state_label;
142  bdd cur_label;
143  bool has_state_label = false;
144  bool ignore_more_ap = false; // Set to true after the first "AP:"
145  // line has been read.
146  bool ignore_acc = false; // Set to true in case of missing
147  // Acceptance: lines.
148  bool ignore_acc_silent = false;
149  bool ignore_more_acc = false; // Set to true after the first
150  // "Acceptance:" line has been read.
151 
152  label_style_t label_style = Mixed_Labels;
153  acc_style_t acc_style = Mixed_Acc;
154 
155  bool accept_all_needed = false;
156  bool accept_all_seen = false;
157  bool aliased_states = false;
158 
159  spot::trival deterministic = spot::trival::maybe();
160  bool complete = false;
161  bool trans_acc_seen = false;
162 
163  std::map<std::string, spot::location> labels;
164 
165  prop_info prop_is_true(const std::string& p)
166  {
167  auto i = props.find(p);
168  if (i == props.end())
169  return prop_info{spot::location(), false};
170  return i->second;
171  }
172 
173  ~result_()
174  {
175  delete namer;
176  delete acc_mapper;
177  }
178  };
179  }
180 
181 #line 182 "parseaut.hh" // lalr1.cc:377
182 
183 
184 # include <cstdlib> // std::abort
185 # include <iostream>
186 # include <stdexcept>
187 # include <string>
188 # include <vector>
189 # include "stack.hh"
190 
191 
192 
193 #ifndef YY_ATTRIBUTE
194 # if (defined __GNUC__ \
195  && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
196  || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
197 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
198 # else
199 # define YY_ATTRIBUTE(Spec) /* empty */
200 # endif
201 #endif
202 
203 #ifndef YY_ATTRIBUTE_PURE
204 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
205 #endif
206 
207 #ifndef YY_ATTRIBUTE_UNUSED
208 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
209 #endif
210 
211 #if !defined _Noreturn \
212  && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
213 # if defined _MSC_VER && 1200 <= _MSC_VER
214 # define _Noreturn __declspec (noreturn)
215 # else
216 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
217 # endif
218 #endif
219 
220 /* Suppress unused-variable warnings by "using" E. */
221 #if ! defined lint || defined __GNUC__
222 # define YYUSE(E) ((void) (E))
223 #else
224 # define YYUSE(E) /* empty */
225 #endif
226 
227 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
228 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
229 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
230  _Pragma ("GCC diagnostic push") \
231  _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
232  _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
233 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
234  _Pragma ("GCC diagnostic pop")
235 #else
236 # define YY_INITIAL_VALUE(Value) Value
237 #endif
238 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
239 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
240 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
241 #endif
242 #ifndef YY_INITIAL_VALUE
243 # define YY_INITIAL_VALUE(Value) /* Nothing. */
244 #endif
245 
246 /* Debug traces. */
247 #ifndef YYDEBUG
248 # define YYDEBUG 1
249 #endif
250 
251 
252 namespace hoayy {
253 #line 254 "parseaut.hh" // lalr1.cc:377
254 
255 
256 
257 
258 
260  class parser
261  {
262  public:
263 #ifndef YYSTYPE
264  union semantic_type
266  {
267  #line 175 "parseaut.yy" // lalr1.cc:377
268 
269  std::string* str;
270  unsigned int num;
271  int b;
273  pair* p;
274  std::list<pair>* list;
276 
277 #line 278 "parseaut.hh" // lalr1.cc:377
278  };
279 #else
280  typedef YYSTYPE semantic_type;
281 #endif
282  typedef spot::location location_type;
284 
286  struct syntax_error : std::runtime_error
287  {
288  syntax_error (const location_type& l, const std::string& m);
289  location_type location;
290  };
291 
293  struct token
294  {
295  enum yytokentype
296  {
297  ENDOFFILE = 0,
298  HOA = 258,
299  STATES = 259,
300  START = 260,
301  AP = 261,
302  ALIAS = 262,
303  ACCEPTANCE = 263,
304  ACCNAME = 264,
305  TOOL = 265,
306  NAME = 266,
307  PROPERTIES = 267,
308  BODY = 268,
309  END = 269,
310  STATE = 270,
311  SPOT_HIGHLIGHT_EDGES = 271,
312  SPOT_HIGHLIGHT_STATES = 272,
313  IDENTIFIER = 273,
314  HEADERNAME = 274,
315  ANAME = 275,
316  STRING = 276,
317  INT = 277,
318  DRA = 278,
319  DSA = 279,
320  V2 = 280,
321  EXPLICIT = 281,
322  ACCPAIRS = 282,
323  ACCSIG = 283,
324  ENDOFHEADER = 284,
325  NEVER = 285,
326  SKIP = 286,
327  IF = 287,
328  FI = 288,
329  DO = 289,
330  OD = 290,
331  ARROW = 291,
332  GOTO = 292,
333  FALSE = 293,
334  ATOMIC = 294,
335  ASSERT = 295,
336  FORMULA = 296,
337  ENDAUT = 297,
338  ENDDSTAR = 298,
339  LBTT = 299,
340  INT_S = 300,
341  LBTT_EMPTY = 301,
342  ACC = 302,
343  STATE_NUM = 303,
344  DEST_NUM = 304
345  };
346  };
347 
349  typedef token::yytokentype token_type;
350 
352  typedef int symbol_number_type;
353 
355  enum { empty_symbol = -2 };
356 
358  typedef unsigned char token_number_type;
359 
366  template <typename Base>
367  struct basic_symbol : Base
368  {
370  typedef Base super_type;
371 
373  basic_symbol ();
374 
376  basic_symbol (const basic_symbol& other);
377 
379  basic_symbol (typename Base::kind_type t,
380  const location_type& l);
381 
383  basic_symbol (typename Base::kind_type t,
384  const semantic_type& v,
385  const location_type& l);
386 
388  ~basic_symbol ();
389 
391  void clear ();
392 
394  bool empty () const;
395 
397  void move (basic_symbol& s);
398 
400  semantic_type value;
401 
403  location_type location;
404 
405  private:
407  basic_symbol& operator= (const basic_symbol& other);
408  };
409 
411  struct by_type
412  {
414  by_type ();
415 
417  by_type (const by_type& other);
418 
420  typedef token_type kind_type;
421 
423  by_type (kind_type t);
424 
426  void clear ();
427 
429  void move (by_type& that);
430 
433  symbol_number_type type_get () const;
434 
436  token_type token () const;
437 
441  int type;
442  };
443 
446 
447 
449  parser (result_& res_yyarg, spot::location initial_loc_yyarg);
450  virtual ~parser ();
451 
454  virtual int parse ();
455 
456 #if YYDEBUG
457  std::ostream& debug_stream () const YY_ATTRIBUTE_PURE;
460  void set_debug_stream (std::ostream &);
461 
463  typedef int debug_level_type;
465  debug_level_type debug_level () const YY_ATTRIBUTE_PURE;
467  void set_debug_level (debug_level_type l);
468 #endif
469 
473  virtual void error (const location_type& loc, const std::string& msg);
474 
476  void error (const syntax_error& err);
477 
478  private:
480  parser (const parser&);
481  parser& operator= (const parser&);
482 
484  typedef int state_type;
485 
489  virtual std::string yysyntax_error_ (state_type yystate,
490  const symbol_type& yyla) const;
491 
495  state_type yy_lr_goto_state_ (state_type yystate, int yysym);
496 
499  static bool yy_pact_value_is_default_ (int yyvalue);
500 
503  static bool yy_table_value_is_error_ (int yyvalue);
504 
505  static const short int yypact_ninf_;
506  static const signed char yytable_ninf_;
507 
509  static token_number_type yytranslate_ (int t);
510 
511  // Tables.
512  // YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
513  // STATE-NUM.
514  static const short int yypact_[];
515 
516  // YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
517  // Performed when YYTABLE does not specify something else to do. Zero
518  // means the default is an error.
519  static const unsigned char yydefact_[];
520 
521  // YYPGOTO[NTERM-NUM].
522  static const short int yypgoto_[];
523 
524  // YYDEFGOTO[NTERM-NUM].
525  static const short int yydefgoto_[];
526 
527  // YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
528  // positive, shift that token. If negative, reduce the rule whose
529  // number is the opposite. If YYTABLE_NINF, syntax error.
530  static const short int yytable_[];
531 
532  static const short int yycheck_[];
533 
534  // YYSTOS[STATE-NUM] -- The (internal number of the) accessing
535  // symbol of state STATE-NUM.
536  static const unsigned char yystos_[];
537 
538  // YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
539  static const unsigned char yyr1_[];
540 
541  // YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
542  static const unsigned char yyr2_[];
543 
544 
546  static std::string yytnamerr_ (const char *n);
547 
548 
550  static const char* const yytname_[];
551 #if YYDEBUG
552  // YYRLINE[YYN] -- Source line where rule number YYN was defined.
553  static const unsigned short int yyrline_[];
555  virtual void yy_reduce_print_ (int r);
557  virtual void yystack_print_ ();
558 
559  // Debugging.
560  int yydebug_;
561  std::ostream* yycdebug_;
562 
566  template <typename Base>
567  void yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const;
568 #endif
569 
574  template <typename Base>
575  void yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const;
576 
577  private:
579  struct by_state
580  {
582  by_state ();
583 
585  typedef state_type kind_type;
586 
588  by_state (kind_type s);
589 
591  by_state (const by_state& other);
592 
594  void clear ();
595 
597  void move (by_state& that);
598 
601  symbol_number_type type_get () const;
602 
604  enum { empty_state = -1 };
605 
608  state_type state;
609  };
610 
612  struct stack_symbol_type : basic_symbol<by_state>
613  {
615  typedef basic_symbol<by_state> super_type;
617  stack_symbol_type ();
619  stack_symbol_type (state_type s, symbol_type& sym);
621  stack_symbol_type& operator= (const stack_symbol_type& that);
622  };
623 
625  typedef stack<stack_symbol_type> stack_type;
626 
628  stack_type yystack_;
629 
635  void yypush_ (const char* m, stack_symbol_type& s);
636 
643  void yypush_ (const char* m, state_type s, symbol_type& sym);
644 
646  void yypop_ (unsigned int n = 1);
647 
649  enum
650  {
651  yyeof_ = 0,
652  yylast_ = 239,
653  yynnts_ = 81,
654  yyfinal_ = 24,
655  yyterror_ = 1,
656  yyerrcode_ = 256,
657  yyntokens_ = 65
658  };
659 
660 
661  // User arguments.
662  result_& res;
663  spot::location initial_loc;
664  };
665 
666 
667 
668 } // hoayy
669 #line 670 "parseaut.hh" // lalr1.cc:377
670 
671 
672 
673 
674 #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:265
semantic_type value
The semantic value.
Definition: parseaut.hh:400
void move(basic_symbol &s)
Destructive move, s is emptied into this.
Syntax errors thrown from user actions.
Definition: parseaut.hh:286
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:349
Definition: parseaut.hh:252
virtual int parse()
Definition: public.hh:92
Definition: parseaut.hh:113
void clear()
Record that this symbol is empty.
Tokens.
Definition: parseaut.hh:293
std::ostream & debug_stream() const
The current debugging stream.
Type access provider for token (enum) based symbols.
Definition: parseaut.hh:411
token_type kind_type
The symbol type as needed by the constructor.
Definition: parseaut.hh:420
Base super_type
Alias to Base.
Definition: parseaut.hh:370
symbol_number_type type_get() const
unsigned char token_number_type
Internal symbol number for tokens (subsumed by symbol_number_type).
Definition: parseaut.hh:358
A class implementing Kleene's three-valued logic.
Definition: trival.hh:33
~basic_symbol()
Destroy the symbol.
int type
Definition: parseaut.hh:441
basic_symbol< by_type > symbol_type
"External" symbols: returned by the scanner.
Definition: parseaut.hh:445
basic_symbol()
Default constructor.
spot::location location_type
Symbol locations.
Definition: parseaut.hh:283
Definition: parseaut.hh:66
A Bison parser.
Definition: parseaut.hh:260
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:367
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:403
bool empty() const
Whether empty.
int symbol_number_type
Symbol type: an internal symbol number.
Definition: parseaut.hh:352
Definition: acc.hh:34
int debug_level_type
Type for debugging levels.
Definition: parseaut.hh:463

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Thu Feb 18 2016 13:37:05 for spot by doxygen 1.8.9.1