spot 2.2.2

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List

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 "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;
99 spot::automaton_parser_options opts;
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:372
182
183
184 # include <vector>
185 # include <iostream>
186 # include <stdexcept>
187 # include <string>
188 # include "stack.hh"
189
190
191
192 #ifndef YY_ATTRIBUTE
193 # if (defined __GNUC__ \
194 && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
195 || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
196 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
197 # else
198 # define YY_ATTRIBUTE(Spec) /* empty */
199 # endif
200 #endif
201
202 #ifndef YY_ATTRIBUTE_PURE
203 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
204 #endif
205
206 #ifndef YY_ATTRIBUTE_UNUSED
207 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
208 #endif
209
210 #if !defined _Noreturn \
211 && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
212 # if defined _MSC_VER && 1200 <= _MSC_VER
213 # define _Noreturn __declspec (noreturn)
214 # else
215 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
216 # endif
217 #endif
218
219 /* Suppress unused-variable warnings by "using" E. */
220 #if ! defined lint || defined __GNUC__
221 # define YYUSE(E) ((void) (E))
222 #else
223 # define YYUSE(E) /* empty */
224 #endif
225
226 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
227 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
228 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
229 _Pragma ("GCC diagnostic push") \
230 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
231 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
232 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
233 _Pragma ("GCC diagnostic pop")
234 #else
235 # define YY_INITIAL_VALUE(Value) Value
236 #endif
237 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
238 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
239 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
240 #endif
241 #ifndef YY_INITIAL_VALUE
242 # define YY_INITIAL_VALUE(Value) /* Nothing. */
243 #endif
244
245 /* Debug traces. */
246 #ifndef YYDEBUG
247 # define YYDEBUG 1
248 #endif
249
250
251 namespace hoayy {
252 #line 253 "parseaut.hh" // lalr1.cc:372
253
254
255
256
257
259 class parser
260 {
261 public:
262 #ifndef YYSTYPE
263 union semantic_type
265 {
266 #line 175 "parseaut.yy" // lalr1.cc:372
267
268 std::string* str;
269 unsigned int num;
270 int b;
271 spot::acc_cond::mark_t mark;
272 pair* p;
273 std::list<pair>* list;
274 spot::acc_cond::acc_code* code;
275
276 #line 277 "parseaut.hh" // lalr1.cc:372
277 };
278 #else
279 typedef YYSTYPE semantic_type;
280 #endif
281 typedef spot::location location_type;
283
285 struct syntax_error : std::runtime_error
286 {
287 syntax_error (const location_type& l, const std::string& m);
288 location_type location;
289 };
290
292 struct token
293 {
294 enum yytokentype
295 {
296 ENDOFFILE = 0,
297 HOA = 258,
298 STATES = 259,
299 START = 260,
300 AP = 261,
301 ALIAS = 262,
302 ACCEPTANCE = 263,
303 ACCNAME = 264,
304 TOOL = 265,
305 NAME = 266,
306 PROPERTIES = 267,
307 BODY = 268,
308 END = 269,
309 STATE = 270,
310 SPOT_HIGHLIGHT_EDGES = 271,
311 SPOT_HIGHLIGHT_STATES = 272,
312 IDENTIFIER = 273,
313 HEADERNAME = 274,
314 ANAME = 275,
315 STRING = 276,
316 INT = 277,
317 DRA = 278,
318 DSA = 279,
319 V2 = 280,
320 EXPLICIT = 281,
321 ACCPAIRS = 282,
322 ACCSIG = 283,
323 ENDOFHEADER = 284,
324 NEVER = 285,
325 SKIP = 286,
326 IF = 287,
327 FI = 288,
328 DO = 289,
329 OD = 290,
330 ARROW = 291,
331 GOTO = 292,
332 FALSE = 293,
333 ATOMIC = 294,
334 ASSERT = 295,
335 FORMULA = 296,
336 ENDAUT = 297,
337 ENDDSTAR = 298,
338 LBTT = 299,
339 INT_S = 300,
340 LBTT_EMPTY = 301,
341 ACC = 302,
342 STATE_NUM = 303,
343 DEST_NUM = 304
344 };
345 };
346
348 typedef token::yytokentype token_type;
349
351 typedef int symbol_number_type;
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
383 ~basic_symbol ();
384
386 void move (basic_symbol& s);
387
389 semantic_type value;
390
392 location_type location;
393
394 private:
396 basic_symbol& operator= (const basic_symbol& other);
397 };
398
400 struct by_type
401 {
403 by_type ();
404
406 by_type (const by_type& other);
407
409 typedef token_type kind_type;
410
412 by_type (kind_type t);
413
415 void move (by_type& that);
416
419 symbol_number_type type_get () const;
420
422 token_type token () const;
423
424 enum { empty = 0 };
425
428 token_number_type type;
429 };
430
432 typedef basic_symbol<by_type> symbol_type;
433
434
436 parser (result_& res_yyarg, spot::location initial_loc_yyarg);
437 virtual ~parser ();
438
441 virtual int parse ();
442
443 #if YYDEBUG
444 std::ostream& debug_stream () const YY_ATTRIBUTE_PURE;
447 void set_debug_stream (std::ostream &);
448
450 typedef int debug_level_type;
452 debug_level_type debug_level () const YY_ATTRIBUTE_PURE;
454 void set_debug_level (debug_level_type l);
455 #endif
456
460 virtual void error (const location_type& loc, const std::string& msg);
461
463 void error (const syntax_error& err);
464
465 private:
467 parser (const parser&);
468 parser& operator= (const parser&);
469
471 typedef int state_type;
472
476 virtual std::string yysyntax_error_ (state_type yystate,
477 symbol_number_type yytoken) const;
478
482 state_type yy_lr_goto_state_ (state_type yystate, int yysym);
483
486 static bool yy_pact_value_is_default_ (int yyvalue);
487
490 static bool yy_table_value_is_error_ (int yyvalue);
491
492 static const short int yypact_ninf_;
493 static const signed char yytable_ninf_;
494
496 static token_number_type yytranslate_ (int t);
497
498 // Tables.
499 // YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
500 // STATE-NUM.
501 static const short int yypact_[];
502
503 // YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
504 // Performed when YYTABLE does not specify something else to do. Zero
505 // means the default is an error.
506 static const unsigned char yydefact_[];
507
508 // YYPGOTO[NTERM-NUM].
509 static const short int yypgoto_[];
510
511 // YYDEFGOTO[NTERM-NUM].
512 static const short int yydefgoto_[];
513
514 // YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
515 // positive, shift that token. If negative, reduce the rule whose
516 // number is the opposite. If YYTABLE_NINF, syntax error.
517 static const short int yytable_[];
518
519 static const short int yycheck_[];
520
521 // YYSTOS[STATE-NUM] -- The (internal number of the) accessing
522 // symbol of state STATE-NUM.
523 static const unsigned char yystos_[];
524
525 // YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
526 static const unsigned char yyr1_[];
527
528 // YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
529 static const unsigned char yyr2_[];
530
531
533 static std::string yytnamerr_ (const char *n);
534
535
537 static const char* const yytname_[];
538 #if YYDEBUG
539 // YYRLINE[YYN] -- Source line where rule number YYN was defined.
540 static const unsigned short int yyrline_[];
542 virtual void yy_reduce_print_ (int r);
544 virtual void yystack_print_ ();
545
546 // Debugging.
547 int yydebug_;
548 std::ostream* yycdebug_;
549
553 template <typename Base>
554 void yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const;
555 #endif
556
561 template <typename Base>
562 void yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const;
563
564 private:
566 struct by_state
567 {
569 by_state ();
570
572 typedef state_type kind_type;
573
575 by_state (kind_type s);
576
578 by_state (const by_state& other);
579
581 void move (by_state& that);
582
585 symbol_number_type type_get () const;
586
587 enum { empty = 0 };
588
590 state_type state;
591 };
592
594 struct stack_symbol_type : basic_symbol<by_state>
595 {
597 typedef basic_symbol<by_state> super_type;
599 stack_symbol_type ();
601 stack_symbol_type (state_type s, symbol_type& sym);
603 stack_symbol_type& operator= (const stack_symbol_type& that);
604 };
605
607 typedef stack<stack_symbol_type> stack_type;
608
610 stack_type yystack_;
611
617 void yypush_ (const char* m, stack_symbol_type& s);
618
625 void yypush_ (const char* m, state_type s, symbol_type& sym);
626
628 void yypop_ (unsigned int n = 1);
629
630 // Constants.
631 enum
632 {
633 yyeof_ = 0,
634 yylast_ = 239,
635 yynnts_ = 81,
636 yyempty_ = -2,
637 yyfinal_ = 24,
638 yyterror_ = 1,
639 yyerrcode_ = 256,
640 yyntokens_ = 65
641 };
642
643
644 // User arguments.
645 result_& res;
646 spot::location initial_loc;
647 };
648
649
650
651 } // hoayy
652 #line 653 "parseaut.hh" // lalr1.cc:372
653
654
655
656
657 #endif // !YY_HOAYY_PARSEAUT_HH_INCLUDED
hoayy::parser::by_type::type
token_number_type type
Definition: parseaut.hh:428
hoayy::parser::by_type::move
void move(by_type &that)
Steal the symbol type from that.
hoayy::parser::debug_level
debug_level_type debug_level() const
The current debugging level.
hoayy_support::result_
Definition: parseaut.hh:89
spot::environment
An environment that describes atomic propositions.
Definition: environment.hh:32
hoayy::parser::semantic_type
Symbol semantic values.
Definition: parseaut.hh:264
hoayy::parser::basic_symbol::value
semantic_type value
The semantic value.
Definition: parseaut.hh:389
hoayy::parser::basic_symbol::move
void move(basic_symbol &s)
Destructive move, s is emptied into this.
hoayy::parser::syntax_error
Syntax errors thrown from user actions.
Definition: parseaut.hh:285
hoayy::parser::set_debug_level
void set_debug_level(debug_level_type l)
Set the current debugging level.
std
Definition: formula.hh:1671
hoayy_support::result_::state_info
Definition: parseaut.hh:91
hoayy::parser::error
virtual void error(const location_type &loc, const std::string &msg)
hoayy::parser::by_type::token
token_type token() const
The token.
hoayy::parser::token_type
token::yytokentype token_type
(External) token type, as returned by yylex.
Definition: parseaut.hh:348
hoayy
Definition: parseaut.hh:251
hoayy::parser::parse
virtual int parse()
spot::automaton_parser_options
Definition: public.hh:92
hoayy_support::result_::prop_info
Definition: parseaut.hh:113
hoayy::parser::token
Tokens.
Definition: parseaut.hh:292
hoayy::parser::debug_stream
std::ostream & debug_stream() const
The current debugging stream.
hoayy::parser::by_type
Type access provider for token (enum) based symbols.
Definition: parseaut.hh:400
hoayy::parser::by_type::kind_type
token_type kind_type
The symbol type as needed by the constructor.
Definition: parseaut.hh:409
hoayy::parser::basic_symbol::super_type
Base super_type
Alias to Base.
Definition: parseaut.hh:366
hoayy::parser::by_type::type_get
symbol_number_type type_get() const
hoayy::parser::token_number_type
unsigned char token_number_type
Internal symbol number for tokens (subsumed by symbol_number_type).
Definition: parseaut.hh:354
spot::trival
A class implementing Kleene's three-valued logic.
Definition: trival.hh:33
hoayy::parser::symbol_type
basic_symbol< by_type > symbol_type
"External" symbols: returned by the scanner.
Definition: parseaut.hh:432
hoayy::parser::basic_symbol::basic_symbol
basic_symbol()
Default constructor.
hoayy::parser::location_type
spot::location location_type
Symbol locations.
Definition: parseaut.hh:282
hoayy_support
Definition: parseaut.hh:66
hoayy::parser
A Bison parser.
Definition: parseaut.hh:259
hoayy::parser::parser
parser(result_ &res_yyarg, spot::location initial_loc_yyarg)
Build a parser object.
hoayy::parser::basic_symbol
Definition: parseaut.hh:363
hoayy::parser::set_debug_stream
void set_debug_stream(std::ostream &)
Set the current debugging stream.
hoayy::parser::by_type::by_type
by_type()
Default constructor.
spot::acc_cond::acc_code
Definition: acc.hh:300
hoayy::parser::basic_symbol::location
location_type location
The location.
Definition: parseaut.hh:392
hoayy::parser::symbol_number_type
int symbol_number_type
Internal symbol number.
Definition: parseaut.hh:351
spot::acc_cond::mark_t
Definition: acc.hh:34
hoayy::parser::debug_level_type
int debug_level_type
Type for debugging levels.
Definition: parseaut.hh:450

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.