g2o
Loading...
Searching...
No Matches
Namespaces | Macros
bison_parser.cpp File Reference
#include <stdio.h>
#include <string>
#include <vector>
#include "commands.h"
#include "bison_parser.h"
#include "driver.h"
#include "scanner.h"
#include "slam_context.h"
Include dependency graph for bison_parser.cpp:

Go to the source code of this file.

Namespaces

namespace  SlamParser
 

Macros

#define yylex   SlamParserlex
 
#define yylex   driver.lexer->lex
 
#define YY_(msgid)   msgid
 
#define YY_EXCEPTIONS   1
 
#define YYRHSLOC(Rhs, K)   ((Rhs)[K].location)
 
#define YYLLOC_DEFAULT(Current, Rhs, N)
 
#define YYCDEBUG    if (false) std::cerr
 
#define YY_SYMBOL_PRINT(Title, Symbol)   YY_USE(Symbol)
 
#define YY_REDUCE_PRINT(Rule)   static_cast<void>(0)
 
#define YY_STACK_PRINT()   static_cast<void>(0)
 
#define yyerrok   (yyerrstatus_ = 0)
 
#define yyclearin   (yyla.clear())
 
#define YYACCEPT   goto yyacceptlab
 
#define YYABORT   goto yyabortlab
 
#define YYERROR   goto yyerrorlab
 
#define YYRECOVERING()   (!!yyerrstatus_)
 
#define YYCASE_(N, S)
 

Macro Definition Documentation

◆ YY_

#define YY_ (   msgid)    msgid

Definition at line 78 of file bison_parser.cpp.

◆ YY_EXCEPTIONS

#define YY_EXCEPTIONS   1

Definition at line 87 of file bison_parser.cpp.

◆ YY_REDUCE_PRINT

#define YY_REDUCE_PRINT (   Rule)    static_cast<void>(0)

Definition at line 139 of file bison_parser.cpp.

◆ YY_STACK_PRINT

#define YY_STACK_PRINT ( )    static_cast<void>(0)

Definition at line 140 of file bison_parser.cpp.

◆ YY_SYMBOL_PRINT

#define YY_SYMBOL_PRINT (   Title,
  Symbol 
)    YY_USE(Symbol)

Definition at line 138 of file bison_parser.cpp.

◆ YYABORT

#define YYABORT   goto yyabortlab

Definition at line 148 of file bison_parser.cpp.

◆ YYACCEPT

#define YYACCEPT   goto yyacceptlab

Definition at line 147 of file bison_parser.cpp.

◆ YYCASE_

#define YYCASE_ (   N,
 
)
Value:
case N: \
yyformat = S; \
break

◆ YYCDEBUG

#define YYCDEBUG    if (false) std::cerr

Definition at line 136 of file bison_parser.cpp.

152 {
153#line 166 "bison_parser.cpp"
154
156Parser::Parser(class Driver& driver_yyarg)
157#if SLAMPARSERDEBUG
158 : yydebug_(false),
159 yycdebug_(&std::cerr),
160#else
161 :
162#endif
163 driver(driver_yyarg) {
164}
165
166Parser::~Parser() {}
167
168Parser::syntax_error::~syntax_error() YY_NOEXCEPT YY_NOTHROW {}
169
170/*---------.
171| symbol. |
172`---------*/
173
174// basic_symbol.
175template <typename Base>
176Parser::basic_symbol<Base>::basic_symbol(const basic_symbol& that)
177 : Base(that), value(that.value), location(that.location) {}
178
180template <typename Base>
181Parser::basic_symbol<Base>::basic_symbol(typename Base::kind_type t,
182 YY_MOVE_REF(location_type) l)
183 : Base(t), value(), location(l) {}
184
185template <typename Base>
186Parser::basic_symbol<Base>::basic_symbol(typename Base::kind_type t,
187 YY_RVREF(value_type) v,
188 YY_RVREF(location_type) l)
189 : Base(t), value(YY_MOVE(v)), location(YY_MOVE(l)) {}
190
191template <typename Base>
192Parser::symbol_kind_type Parser::basic_symbol<Base>::type_get() const
194 return this->kind();
195}
196
197template <typename Base>
198bool Parser::basic_symbol<Base>::empty() const YY_NOEXCEPT {
199 return this->kind() == symbol_kind::S_YYEMPTY;
200}
201
202template <typename Base>
203void Parser::basic_symbol<Base>::move(basic_symbol& s) {
204 super_type::move(s);
205 value = YY_MOVE(s.value);
206 location = YY_MOVE(s.location);
207}
208
209// by_kind.
210Parser::by_kind::by_kind() YY_NOEXCEPT : kind_(symbol_kind::S_YYEMPTY) {}
211
212#if 201103L <= YY_CPLUSPLUS
213Parser::by_kind::by_kind(by_kind&& that) YY_NOEXCEPT : kind_(that.kind_) {
214 that.clear();
215}
216#endif
217
218Parser::by_kind::by_kind(const by_kind& that) YY_NOEXCEPT : kind_(that.kind_) {}
219
220Parser::by_kind::by_kind(token_kind_type t) YY_NOEXCEPT
221 : kind_(yytranslate_(t)) {}
222
223void Parser::by_kind::clear() YY_NOEXCEPT { kind_ = symbol_kind::S_YYEMPTY; }
224
225void Parser::by_kind::move(by_kind& that) {
226 kind_ = that.kind_;
227 that.clear();
228}
229
230Parser::symbol_kind_type Parser::by_kind::kind() const YY_NOEXCEPT {
231 return kind_;
232}
233
234Parser::symbol_kind_type Parser::by_kind::type_get() const YY_NOEXCEPT {
235 return this->kind();
236}
237
238// by_state.
239Parser::by_state::by_state() YY_NOEXCEPT : state(empty_state) {}
240
241Parser::by_state::by_state(const by_state& that) YY_NOEXCEPT
242 : state(that.state) {}
243
244void Parser::by_state::clear() YY_NOEXCEPT { state = empty_state; }
245
246void Parser::by_state::move(by_state& that) {
247 state = that.state;
248 that.clear();
249}
250
251Parser::by_state::by_state(state_type s) YY_NOEXCEPT : state(s) {}
252
253Parser::symbol_kind_type Parser::by_state::kind() const YY_NOEXCEPT {
254 if (state == empty_state)
255 return symbol_kind::S_YYEMPTY;
256 else
257 return YY_CAST(symbol_kind_type, yystos_[+state]);
258}
259
260Parser::stack_symbol_type::stack_symbol_type() {}
261
262Parser::stack_symbol_type::stack_symbol_type(YY_RVREF(stack_symbol_type) that)
263 : super_type(YY_MOVE(that.state), YY_MOVE(that.value),
264 YY_MOVE(that.location)) {
265#if 201103L <= YY_CPLUSPLUS
266 // that is emptied.
267 that.state = empty_state;
268#endif
269}
270
271Parser::stack_symbol_type::stack_symbol_type(state_type s,
272 YY_MOVE_REF(symbol_type) that)
273 : super_type(s, YY_MOVE(that.value), YY_MOVE(that.location)) {
274 // that is emptied.
275 that.kind_ = symbol_kind::S_YYEMPTY;
276}
277
278#if YY_CPLUSPLUS < 201103L
279Parser::stack_symbol_type& Parser::stack_symbol_type::operator=(
280 const stack_symbol_type& that) {
281 state = that.state;
282 value = that.value;
283 location = that.location;
284 return *this;
285}
286
287Parser::stack_symbol_type& Parser::stack_symbol_type::operator=(
288 stack_symbol_type& that) {
289 state = that.state;
290 value = that.value;
291 location = that.location;
292 // that is emptied.
293 that.state = empty_state;
294 return *this;
295}
296#endif
297
298template <typename Base>
299void Parser::yy_destroy_(const char* yymsg, basic_symbol<Base>& yysym) const {
300 if (yymsg) YY_SYMBOL_PRINT(yymsg, yysym);
301
302 // User destructor.
303 switch (yysym.kind()) {
304 case symbol_kind::S_STRING: // "string"
305#line 79 "parser.yy"
306 {
307 delete (yysym.value.stringVal);
308 }
309#line 378 "bison_parser.cpp"
310 break;
311
312 case symbol_kind::S_add_se2: // add_se2
313#line 80 "parser.yy"
314 {
315 delete (yysym.value.commandNode);
316 }
317#line 384 "bison_parser.cpp"
318 break;
319
320 case symbol_kind::S_add_se3: // add_se3
321#line 80 "parser.yy"
322 {
323 delete (yysym.value.commandNode);
324 }
325#line 390 "bison_parser.cpp"
326 break;
327
328 case symbol_kind::S_fix_node: // fix_node
329#line 80 "parser.yy"
330 {
331 delete (yysym.value.commandNode);
332 }
333#line 396 "bison_parser.cpp"
334 break;
335
336 case symbol_kind::S_solve_state: // solve_state
337#line 80 "parser.yy"
338 {
339 delete (yysym.value.commandNode);
340 }
341#line 402 "bison_parser.cpp"
342 break;
343
344 case symbol_kind::S_query_state: // query_state
345#line 80 "parser.yy"
346 {
347 delete (yysym.value.commandNode);
348 }
349#line 408 "bison_parser.cpp"
350 break;
351
352 case symbol_kind::S_command: // command
353#line 80 "parser.yy"
354 {
355 delete (yysym.value.commandNode);
356 }
357#line 414 "bison_parser.cpp"
358 break;
359
360 default:
361 break;
362 }
363}
364
365#if SLAMPARSERDEBUG
366template <typename Base>
367void Parser::yy_print_(std::ostream& yyo,
368 const basic_symbol<Base>& yysym) const {
369 std::ostream& yyoutput = yyo;
370 YY_USE(yyoutput);
371 if (yysym.empty())
372 yyo << "empty symbol";
373 else {
374 symbol_kind_type yykind = yysym.kind();
375 yyo << (yykind < YYNTOKENS ? "token" : "nterm") << ' ' << yysym.name()
376 << " (" << yysym.location << ": ";
377 YY_USE(yykind);
378 yyo << ')';
379 }
380}
381#endif
382
383void Parser::yypush_(const char* m, YY_MOVE_REF(stack_symbol_type) sym) {
384 if (m) YY_SYMBOL_PRINT(m, sym);
385 yystack_.push(YY_MOVE(sym));
386}
387
388void Parser::yypush_(const char* m, state_type s,
389 YY_MOVE_REF(symbol_type) sym) {
390#if 201103L <= YY_CPLUSPLUS
391 yypush_(m, stack_symbol_type(s, std::move(sym)));
392#else
393 stack_symbol_type ss(s, sym);
394 yypush_(m, ss);
395#endif
396}
397
398void Parser::yypop_(int n) YY_NOEXCEPT { yystack_.pop(n); }
399
400#if SLAMPARSERDEBUG
401std::ostream& Parser::debug_stream() const { return *yycdebug_; }
402
403void Parser::set_debug_stream(std::ostream& o) { yycdebug_ = &o; }
404
405Parser::debug_level_type Parser::debug_level() const { return yydebug_; }
406
407void Parser::set_debug_level(debug_level_type l) { yydebug_ = l; }
408#endif // SLAMPARSERDEBUG
409
410Parser::state_type Parser::yy_lr_goto_state_(state_type yystate, int yysym) {
411 int yyr = yypgoto_[yysym - YYNTOKENS] + yystate;
412 if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
413 return yytable_[yyr];
414 else
415 return yydefgoto_[yysym - YYNTOKENS];
416}
417
418bool Parser::yy_pact_value_is_default_(int yyvalue) YY_NOEXCEPT {
419 return yyvalue == yypact_ninf_;
420}
421
422bool Parser::yy_table_value_is_error_(int yyvalue) YY_NOEXCEPT {
423 return yyvalue == yytable_ninf_;
424}
425
426int Parser::operator()() { return parse(); }
427
428int Parser::parse() {
429 int yyn;
431 int yylen = 0;
432
433 // Error handling.
434 int yyerrstatus_ = 0;
435
437 symbol_type yyla;
438
440 stack_symbol_type yyerror_range[3];
441
443 int yyresult;
444
445#if YY_EXCEPTIONS
446 try
447#endif // YY_EXCEPTIONS
448 {
449 YYCDEBUG << "Starting parse\n";
450
451 // User initialization code.
452#line 38 "parser.yy"
453 {
454 // initialize the initial location object
455 yyla.location.begin.filename = yyla.location.end.filename =
456 &driver.streamname;
457 }
458
459#line 557 "bison_parser.cpp"
460
461 /* Initialize the stack. The initial state will be set in
462 yynewstate, since the latter expects the semantical and the
463 location values to have been already stored, initialize these
464 stacks with a primary value. */
465 yystack_.clear();
466 yypush_(YY_NULLPTR, 0, YY_MOVE(yyla));
467
468 /*-----------------------------------------------.
469 | yynewstate -- push a new symbol on the stack. |
470 `-----------------------------------------------*/
471 yynewstate:
472 YYCDEBUG << "Entering state " << int(yystack_[0].state) << '\n';
474
475 // Accept?
476 if (yystack_[0].state == yyfinal_) YYACCEPT;
477
478 goto yybackup;
479
480 /*-----------.
481 | yybackup. |
482 `-----------*/
483 yybackup:
484 // Try to take a decision without lookahead.
485 yyn = yypact_[+yystack_[0].state];
486 if (yy_pact_value_is_default_(yyn)) goto yydefault;
487
488 // Read a lookahead token.
489 if (yyla.empty()) {
490 YYCDEBUG << "Reading a token\n";
491#if YY_EXCEPTIONS
492 try
493#endif // YY_EXCEPTIONS
494 {
495 yyla.kind_ = yytranslate_(yylex(&yyla.value, &yyla.location));
496 }
497#if YY_EXCEPTIONS
498 catch (const syntax_error& yyexc) {
499 YYCDEBUG << "Caught exception: " << yyexc.what() << '\n';
500 error(yyexc);
501 goto yyerrlab1;
502 }
503#endif // YY_EXCEPTIONS
504 }
505 YY_SYMBOL_PRINT("Next token is", yyla);
506
507 if (yyla.kind() == symbol_kind::S_YYerror) {
508 // The scanner already issued an error message, process directly
509 // to error recovery. But do not keep the error token as
510 // lookahead, it is too special and may lead us to an endless
511 // loop in error recovery. */
512 yyla.kind_ = symbol_kind::S_YYUNDEF;
513 goto yyerrlab1;
514 }
515
516 /* If the proper action on seeing token YYLA.TYPE is to reduce or
517 to detect an error, take that action. */
518 yyn += yyla.kind();
519 if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.kind()) {
520 goto yydefault;
521 }
522
523 // Reduce or error.
524 yyn = yytable_[yyn];
525 if (yyn <= 0) {
526 if (yy_table_value_is_error_(yyn)) goto yyerrlab;
527 yyn = -yyn;
528 goto yyreduce;
529 }
530
531 // Count tokens shifted since error; after three, turn off error status.
532 if (yyerrstatus_) --yyerrstatus_;
533
534 // Shift the lookahead token.
535 yypush_("Shifting", state_type(yyn), YY_MOVE(yyla));
536 goto yynewstate;
537
538 /*-----------------------------------------------------------.
539 | yydefault -- do the default action for the current state. |
540 `-----------------------------------------------------------*/
541 yydefault:
542 yyn = yydefact_[+yystack_[0].state];
543 if (yyn == 0) goto yyerrlab;
544 goto yyreduce;
545
546 /*-----------------------------.
547 | yyreduce -- do a reduction. |
548 `-----------------------------*/
549 yyreduce:
550 yylen = yyr2_[yyn];
551 {
552 stack_symbol_type yylhs;
553 yylhs.state = yy_lr_goto_state_(yystack_[yylen].state, yyr1_[yyn]);
554 /* If YYLEN is nonzero, implement the default value of the
555 action: '$$ = $1'. Otherwise, use the top of the stack.
556
557 Otherwise, the following line sets YYLHS.VALUE to garbage.
558 This behavior is undocumented and Bison users should not rely
559 upon it. */
560 if (yylen)
561 yylhs.value = yystack_[yylen - 1].value;
562 else
563 yylhs.value = yystack_[0].value;
564
565 // Default location.
566 {
567 stack_type::slice range(yystack_, yylen);
568 YYLLOC_DEFAULT(yylhs.location, range, yylen);
569 yyerror_range[1].location = yylhs.location;
570 }
571
572 // Perform the reduction.
573 YY_REDUCE_PRINT(yyn);
574#if YY_EXCEPTIONS
575 try
576#endif // YY_EXCEPTIONS
577 {
578 switch (yyn) {
579 case 2: // int_list: "integer"
580#line 104 "parser.yy"
581 {
582 (yylhs.value.intList) = new std::vector<int>;
583 (yylhs.value.intList)->push_back((yystack_[0].value.integerVal));
584 }
585#line 698 "bison_parser.cpp"
586 break;
587
588 case 3: // int_list: int_list "integer"
589#line 109 "parser.yy"
590 {
591 (yystack_[1].value.intList)
592 ->push_back((yystack_[0].value.integerVal));
593 (yylhs.value.intList) = (yystack_[1].value.intList);
594 }
595#line 707 "bison_parser.cpp"
596 break;
597
598 case 4: // NUMBER: "integer"
599#line 115 "parser.yy"
600 {
601 (yylhs.value.doubleVal) = (yystack_[0].value.integerVal);
602 }
603#line 715 "bison_parser.cpp"
604 break;
605
606 case 5: // NUMBER: "double"
607#line 119 "parser.yy"
608 {
609 (yylhs.value.doubleVal) = (yystack_[0].value.doubleVal);
610 }
611#line 723 "bison_parser.cpp"
612 break;
613
614 case 6: // add_se2: "ADD" "Vertex SE2" "integer"
615#line 124 "parser.yy"
616 {
617 (yylhs.value.commandNode) =
618 new AddNode(*(yystack_[1].value.stringVal),
619 (yystack_[0].value.integerVal), 3);
620 delete (yystack_[1].value.stringVal);
621 }
622#line 732 "bison_parser.cpp"
623 break;
624
625 case 7: // add_se2: "ADD" "Vertex SE2" "integer" NUMBER NUMBER NUMBER
626#line 129 "parser.yy"
627 {
628 std::vector<double> values;
629 values.push_back((yystack_[2].value.doubleVal));
630 values.push_back((yystack_[1].value.doubleVal));
631 values.push_back((yystack_[0].value.doubleVal));
632 (yylhs.value.commandNode) =
633 new AddNode(*(yystack_[4].value.stringVal),
634 (yystack_[3].value.integerVal), 3, values);
635 delete (yystack_[4].value.stringVal);
636 }
637#line 745 "bison_parser.cpp"
638 break;
639
640 case 8: // add_se2: "ADD" "Edge SE2" "integer" "integer" "integer"
641 // NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
642 // NUMBER
643#line 138 "parser.yy"
644 {
645 std::vector<double> values;
646 values.push_back((yystack_[8].value.doubleVal));
647 values.push_back((yystack_[7].value.doubleVal));
648 values.push_back((yystack_[6].value.doubleVal));
649 std::vector<double> information;
650 information.push_back((yystack_[5].value.doubleVal));
651 information.push_back((yystack_[4].value.doubleVal));
652 information.push_back((yystack_[3].value.doubleVal));
653 information.push_back((yystack_[2].value.doubleVal));
654 information.push_back((yystack_[1].value.doubleVal));
655 information.push_back((yystack_[0].value.doubleVal));
656 (yylhs.value.commandNode) = new AddEdge(
657 *(yystack_[12].value.stringVal),
658 (yystack_[11].value.integerVal), values.size(),
659 (yystack_[10].value.integerVal), (yystack_[9].value.integerVal),
660 values, information);
661 delete (yystack_[12].value.stringVal);
662 }
663#line 765 "bison_parser.cpp"
664 break;
665
666 case 9: // add_se3: "ADD" "Vertex SE3" "integer"
667#line 155 "parser.yy"
668 {
669 (yylhs.value.commandNode) =
670 new AddNode(*(yystack_[1].value.stringVal),
671 (yystack_[0].value.integerVal), 6);
672 delete (yystack_[1].value.stringVal);
673 }
674#line 774 "bison_parser.cpp"
675 break;
676
677 case 10: // add_se3: "ADD" "Vertex SE3" "integer" NUMBER NUMBER
678 // NUMBER NUMBER NUMBER NUMBER
679#line 160 "parser.yy"
680 {
681 (yylhs.value.commandNode) =
682 new AddNode(*(yystack_[7].value.stringVal),
683 (yystack_[6].value.integerVal), 6);
684 delete (yystack_[7].value.stringVal);
685 }
686#line 783 "bison_parser.cpp"
687 break;
688
689 case 11: // add_se3: "ADD" "Edge SE3" "integer" "integer" "integer"
690 // NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
691 // NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
692 // NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER
693 // NUMBER NUMBER NUMBER
694#line 165 "parser.yy"
695 {
696 std::vector<double> values;
697 values.push_back((yystack_[26].value.doubleVal));
698 values.push_back((yystack_[25].value.doubleVal));
699 values.push_back((yystack_[24].value.doubleVal));
700 values.push_back((yystack_[23].value.doubleVal));
701 values.push_back((yystack_[22].value.doubleVal));
702 values.push_back((yystack_[21].value.doubleVal));
703 std::vector<double> information;
704 information.push_back((yystack_[20].value.doubleVal));
705 information.push_back((yystack_[19].value.doubleVal));
706 information.push_back((yystack_[18].value.doubleVal));
707 information.push_back((yystack_[17].value.doubleVal));
708 information.push_back((yystack_[16].value.doubleVal));
709 information.push_back((yystack_[15].value.doubleVal));
710 information.push_back((yystack_[14].value.doubleVal));
711 information.push_back((yystack_[13].value.doubleVal));
712 information.push_back((yystack_[12].value.doubleVal));
713 information.push_back((yystack_[11].value.doubleVal));
714 information.push_back((yystack_[10].value.doubleVal));
715 information.push_back((yystack_[9].value.doubleVal));
716 information.push_back((yystack_[8].value.doubleVal));
717 information.push_back((yystack_[7].value.doubleVal));
718 information.push_back((yystack_[6].value.doubleVal));
719 information.push_back((yystack_[5].value.doubleVal));
720 information.push_back((yystack_[4].value.doubleVal));
721 information.push_back((yystack_[3].value.doubleVal));
722 information.push_back((yystack_[2].value.doubleVal));
723 information.push_back((yystack_[1].value.doubleVal));
724 information.push_back((yystack_[0].value.doubleVal));
725 (yylhs.value.commandNode) = new AddEdge(
726 *(yystack_[30].value.stringVal),
727 (yystack_[29].value.integerVal), values.size(),
728 (yystack_[28].value.integerVal),
729 (yystack_[27].value.integerVal), values, information);
730 delete (yystack_[30].value.stringVal);
731 }
732#line 821 "bison_parser.cpp"
733 break;
734
735 case 12: // fix_node: "Fix" "integer"
736#line 200 "parser.yy"
737 {
738 std::vector<int> values;
739 values.push_back((yystack_[0].value.integerVal));
740 (yylhs.value.commandNode) = new FixNode("FIX", values);
741 }
742#line 831 "bison_parser.cpp"
743 break;
744
745 case 13: // solve_state: "Solve State"
746#line 207 "parser.yy"
747 {
748 (yylhs.value.commandNode) = new SolveSate("SOLVE_STATE");
749 }
750#line 839 "bison_parser.cpp"
751 break;
752
753 case 14: // query_state: "Query State"
754#line 212 "parser.yy"
755 {
756 (yylhs.value.commandNode) = new QueryState("QUERY_STATE");
757 }
758#line 847 "bison_parser.cpp"
759 break;
760
761 case 15: // query_state: "Query State" int_list
762#line 216 "parser.yy"
763 {
764 (yylhs.value.commandNode) =
765 new QueryState("QUERY_STATE", *(yystack_[0].value.intList));
766 delete (yystack_[0].value.intList);
767 }
768#line 856 "bison_parser.cpp"
769 break;
770
771 case 16: // command: add_se2
772#line 222 "parser.yy"
773 {
774 (yylhs.value.commandNode) = (yystack_[0].value.commandNode);
775 }
776#line 864 "bison_parser.cpp"
777 break;
778
779 case 17: // command: add_se3
780#line 226 "parser.yy"
781 {
782 (yylhs.value.commandNode) = (yystack_[0].value.commandNode);
783 }
784#line 872 "bison_parser.cpp"
785 break;
786
787 case 18: // command: fix_node
788#line 230 "parser.yy"
789 {
790 (yylhs.value.commandNode) = (yystack_[0].value.commandNode);
791 }
792#line 880 "bison_parser.cpp"
793 break;
794
795 case 19: // command: solve_state
796#line 234 "parser.yy"
797 {
798 (yylhs.value.commandNode) = (yystack_[0].value.commandNode);
799 }
800#line 888 "bison_parser.cpp"
801 break;
802
803 case 20: // command: query_state
804#line 238 "parser.yy"
805 {
806 (yylhs.value.commandNode) = (yystack_[0].value.commandNode);
807 }
808#line 896 "bison_parser.cpp"
809 break;
810
811 case 23: // start: start command ';'
812#line 245 "parser.yy"
813 {
814 driver.slamContext.process((yystack_[1].value.commandNode));
815 delete (yystack_[1].value.commandNode);
816 }
817#line 905 "bison_parser.cpp"
818 break;
819
820#line 909 "bison_parser.cpp"
821
822 default:
823 break;
824 }
825 }
826#if YY_EXCEPTIONS
827 catch (const syntax_error& yyexc) {
828 YYCDEBUG << "Caught exception: " << yyexc.what() << '\n';
829 error(yyexc);
830 YYERROR;
831 }
832#endif // YY_EXCEPTIONS
833 YY_SYMBOL_PRINT("-> $$ =", yylhs);
834 yypop_(yylen);
835 yylen = 0;
836
837 // Shift the result of the reduction.
838 yypush_(YY_NULLPTR, YY_MOVE(yylhs));
839 }
840 goto yynewstate;
841
842 /*--------------------------------------.
843 | yyerrlab -- here on detecting error. |
844 `--------------------------------------*/
845 yyerrlab:
846 // If not already recovering from an error, report this error.
847 if (!yyerrstatus_) {
848 context yyctx(*this, yyla);
849 std::string msg = yysyntax_error_(yyctx);
850 error(yyla.location, YY_MOVE(msg));
851 }
852
853 yyerror_range[1].location = yyla.location;
854 if (yyerrstatus_ == 3) {
855 /* If just tried and failed to reuse lookahead token after an
856 error, discard it. */
857
858 // Return failure if at end of input.
859 if (yyla.kind() == symbol_kind::S_YYEOF)
860 YYABORT;
861 else if (!yyla.empty()) {
862 yy_destroy_("Error: discarding", yyla);
863 yyla.clear();
864 }
865 }
866
867 // Else will try to reuse lookahead token after shifting the error token.
868 goto yyerrlab1;
869
870 /*---------------------------------------------------.
871 | yyerrorlab -- error raised explicitly by YYERROR. |
872 `---------------------------------------------------*/
873 yyerrorlab:
874 /* Pacify compilers when the user code never invokes YYERROR and
875 the label yyerrorlab therefore never appears in user code. */
876 if (false) YYERROR;
877
878 /* Do not reclaim the symbols of the rule whose action triggered
879 this YYERROR. */
880 yypop_(yylen);
881 yylen = 0;
883 goto yyerrlab1;
884
885 /*-------------------------------------------------------------.
886 | yyerrlab1 -- common code for both syntax error and YYERROR. |
887 `-------------------------------------------------------------*/
888 yyerrlab1:
889 yyerrstatus_ = 3; // Each real token shifted decrements this.
890 // Pop stack until we find a state that shifts the error token.
891 for (;;) {
892 yyn = yypact_[+yystack_[0].state];
893 if (!yy_pact_value_is_default_(yyn)) {
894 yyn += symbol_kind::S_YYerror;
895 if (0 <= yyn && yyn <= yylast_ &&
896 yycheck_[yyn] == symbol_kind::S_YYerror) {
897 yyn = yytable_[yyn];
898 if (0 < yyn) break;
899 }
900 }
901
902 // Pop the current state because it cannot handle the error token.
903 if (yystack_.size() == 1) YYABORT;
904
905 yyerror_range[1].location = yystack_[0].location;
906 yy_destroy_("Error: popping", yystack_[0]);
907 yypop_();
909 }
910 {
911 stack_symbol_type error_token;
912
913 yyerror_range[2].location = yyla.location;
914 YYLLOC_DEFAULT(error_token.location, yyerror_range, 2);
915
916 // Shift the error token.
917 error_token.state = state_type(yyn);
918 yypush_("Shifting", YY_MOVE(error_token));
919 }
920 goto yynewstate;
921
922 /*-------------------------------------.
923 | yyacceptlab -- YYACCEPT comes here. |
924 `-------------------------------------*/
925 yyacceptlab:
926 yyresult = 0;
927 goto yyreturn;
928
929 /*-----------------------------------.
930 | yyabortlab -- YYABORT comes here. |
931 `-----------------------------------*/
932 yyabortlab:
933 yyresult = 1;
934 goto yyreturn;
935
936 /*-----------------------------------------------------.
937 | yyreturn -- parsing is finished, return the result. |
938 `-----------------------------------------------------*/
939 yyreturn:
940 if (!yyla.empty()) yy_destroy_("Cleanup: discarding lookahead", yyla);
941
942 /* Do not reclaim the symbols of the rule whose action triggered
943 this YYABORT or YYACCEPT. */
944 yypop_(yylen);
946 while (1 < yystack_.size()) {
947 yy_destroy_("Cleanup: popping", yystack_[0]);
948 yypop_();
949 }
950
951 return yyresult;
952 }
953#if YY_EXCEPTIONS
954 catch (...) {
955 YYCDEBUG << "Exception caught: cleaning lookahead and stack\n";
956 // Do not try to display the values of the reclaimed symbols,
957 // as their printers might throw an exception.
958 if (!yyla.empty()) yy_destroy_(YY_NULLPTR, yyla);
959
960 while (1 < yystack_.size()) {
961 yy_destroy_(YY_NULLPTR, yystack_[0]);
962 yypop_();
963 }
964 throw;
965 }
966#endif // YY_EXCEPTIONS
967}
968
969void Parser::error(const syntax_error& yyexc) {
970 error(yyexc.location, yyexc.what());
971}
972
973/* Return YYSTR after stripping away unnecessary quotes and
974 backslashes, so that it's suitable for yyerror. The heuristic is
975 that double-quoting is unnecessary unless the string contains an
976 apostrophe, a comma, or backslash (other than backslash-backslash).
977 YYSTR is taken from yytname. */
978std::string Parser::yytnamerr_(const char* yystr) {
979 if (*yystr == '"') {
980 std::string yyr;
981 char const* yyp = yystr;
982
983 for (;;) switch (*++yyp) {
984 case '\'':
985 case ',':
986 goto do_not_strip_quotes;
987
988 case '\\':
989 if (*++yyp != '\\')
990 goto do_not_strip_quotes;
991 else
992 goto append;
993
994 append:
995 default:
996 yyr += *yyp;
997 break;
998
999 case '"':
1000 return yyr;
1001 }
1002 do_not_strip_quotes:;
1003 }
1004
1005 return yystr;
1006}
1007
1008std::string Parser::symbol_name(symbol_kind_type yysymbol) {
1009 return yytnamerr_(yytname_[yysymbol]);
1010}
1011
1012// Parser::context.
1013Parser::context::context(const Parser& yyparser, const symbol_type& yyla)
1014 : yyparser_(yyparser), yyla_(yyla) {}
1015
1016int Parser::context::expected_tokens(symbol_kind_type yyarg[],
1017 int yyargn) const {
1018 // Actual number of expected tokens
1019 int yycount = 0;
1020
1021 const int yyn = yypact_[+yyparser_.yystack_[0].state];
1022 if (!yy_pact_value_is_default_(yyn)) {
1023 /* Start YYX at -YYN if negative to avoid negative indexes in
1024 YYCHECK. In other words, skip the first -YYN actions for
1025 this state because they are default actions. */
1026 const int yyxbegin = yyn < 0 ? -yyn : 0;
1027 // Stay within bounds of both yycheck and yytname.
1028 const int yychecklim = yylast_ - yyn + 1;
1029 const int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1030 for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
1031 if (yycheck_[yyx + yyn] == yyx && yyx != symbol_kind::S_YYerror &&
1032 !yy_table_value_is_error_(yytable_[yyx + yyn])) {
1033 if (!yyarg)
1034 ++yycount;
1035 else if (yycount == yyargn)
1036 return 0;
1037 else
1038 yyarg[yycount++] = YY_CAST(symbol_kind_type, yyx);
1039 }
1040 }
1041
1042 if (yyarg && yycount == 0 && 0 < yyargn) yyarg[0] = symbol_kind::S_YYEMPTY;
1043 return yycount;
1044}
1045
1046int Parser::yy_syntax_error_arguments_(const context& yyctx,
1047 symbol_kind_type yyarg[],
1048 int yyargn) const {
1049 /* There are many possibilities here to consider:
1050 - If this state is a consistent state with a default action, then
1051 the only way this function was invoked is if the default action
1052 is an error action. In that case, don't check for expected
1053 tokens because there are none.
1054 - The only way there can be no lookahead present (in yyla) is
1055 if this state is a consistent state with a default action.
1056 Thus, detecting the absence of a lookahead is sufficient to
1057 determine that there is no unexpected or expected token to
1058 report. In that case, just report a simple "syntax error".
1059 - Don't assume there isn't a lookahead just because this state is
1060 a consistent state with a default action. There might have
1061 been a previous inconsistent state, consistent state with a
1062 non-default action, or user semantic action that manipulated
1063 yyla. (However, yyla is currently not documented for users.)
1064 - Of course, the expected token list depends on states to have
1065 correct lookahead information, and it depends on the parser not
1066 to perform extra reductions after fetching a lookahead from the
1067 scanner and before detecting a syntax error. Thus, state merging
1068 (from LALR or IELR) and default reductions corrupt the expected
1069 token list. However, the list is correct for canonical LR with
1070 one exception: it will still contain any token that will not be
1071 accepted due to an error action in a later state.
1072 */
1073
1074 if (!yyctx.lookahead().empty()) {
1075 if (yyarg) yyarg[0] = yyctx.token();
1076 int yyn = yyctx.expected_tokens(yyarg ? yyarg + 1 : yyarg, yyargn - 1);
1077 return yyn + 1;
1078 }
1079 return 0;
1080}
1081
1082// Generate an error message.
1083std::string Parser::yysyntax_error_(const context& yyctx) const {
1084 // Its maximum.
1085 enum { YYARGS_MAX = 5 };
1086 // Arguments of yyformat.
1087 symbol_kind_type yyarg[YYARGS_MAX];
1088 int yycount = yy_syntax_error_arguments_(yyctx, yyarg, YYARGS_MAX);
1089
1090 char const* yyformat = YY_NULLPTR;
1091 switch (yycount) {
1092#define YYCASE_(N, S) \
1093 case N: \
1094 yyformat = S; \
1095 break
1096 default: // Avoid compiler warnings.
1097 YYCASE_(0, YY_("syntax error"));
1098 YYCASE_(1, YY_("syntax error, unexpected %s"));
1099 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1100 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1101 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1102 YYCASE_(
1103 5,
1104 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1105#undef YYCASE_
1106 }
1107
1108 std::string yyres;
1109 // Argument number.
1110 std::ptrdiff_t yyi = 0;
1111 for (char const* yyp = yyformat; *yyp; ++yyp)
1112 if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount) {
1113 yyres += symbol_name(yyarg[yyi++]);
1114 ++yyp;
1115 } else
1116 yyres += *yyp;
1117 return yyres;
1118}
1119
1120const signed char Parser::yypact_ninf_ = -24;
1121
1122const signed char Parser::yytable_ninf_ = -1;
1123
1124const signed char Parser::yypact_[] = {
1125 -24, 54, -24, -24, -7, 1, -24, 10, -24, -24, -24, -24, -24, 9, 31, 51,
1126 52, 55, -24, -24, 56, -24, 4, 4, 58, 59, -24, -24, -24, 4, 4, 60,
1127 61, 4, 4, 4, 4, -24, 4, 4, 4, 4, 4, 4, 4, 4, 4, -24,
1128 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, -24, 4, 4, 4, 4, 4,
1129 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, -24};
1130
1131const signed char Parser::yydefact_[] = {
1132 21, 0, 1, 22, 0, 0, 13, 14, 16, 17, 18, 19, 20, 0, 0, 0, 0, 0, 12, 2,
1133 15, 23, 6, 9, 0, 0, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0,
1134 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0,
1135 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11};
1136
1137const signed char Parser::yypgoto_[] = {-24, -24, -23, -24, -24,
1138 -24, -24, -24, -24, -24};
1139
1140const signed char Parser::yydefgoto_[] = {0, 20, 29, 8, 9, 10, 11, 12, 13, 1};
1141
1142const signed char Parser::yytable_[] = {
1143 30, 14, 15, 16, 17, 18, 33, 34, 27, 28, 37, 38, 39, 40, 19, 41, 42, 43,
1144 44, 45, 46, 47, 48, 49, 21, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 22,
1145 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
1146 2, 23, 24, 3, 0, 25, 26, 4, 31, 32, 35, 36, 5, 6, 7};
1147
1148const signed char Parser::yycheck_[] = {
1149 23, 8, 9, 10, 11, 4, 29, 30, 4, 5, 33, 34, 35, 36, 4, 38, 39, 40,
1150 41, 42, 43, 44, 45, 46, 15, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 4,
1151 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
1152 0, 4, 4, 3, -1, 4, 4, 7, 4, 4, 4, 4, 12, 13, 14};
1153
1154const signed char Parser::yystos_[] = {
1155 0, 25, 0, 3, 7, 12, 13, 14, 19, 20, 21, 22, 23, 24, 8, 9,
1156 10, 11, 4, 4, 17, 15, 4, 4, 4, 4, 4, 4, 5, 18, 18, 4,
1157 4, 18, 18, 4, 4, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
1158 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
1159 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18};
1160
1161const signed char Parser::yyr1_[] = {0, 16, 17, 17, 18, 18, 19, 19,
1162 19, 20, 20, 20, 21, 22, 23, 23,
1163 24, 24, 24, 24, 24, 25, 25, 25};
1164
1165const signed char Parser::yyr2_[] = {0, 2, 1, 2, 1, 1, 3, 6, 14, 3, 9, 32,
1166 2, 1, 1, 2, 1, 1, 1, 1, 1, 0, 2, 3};
1167
1168#if SLAMPARSERDEBUG || 1
1169// YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
1170// First, the terminals, then, starting at \a YYNTOKENS, nonterminals.
1171const char* const Parser::yytname_[] = {"\"end of file\"",
1172 "error",
1173 "\"invalid token\"",
1174 "\"end of line\"",
1175 "\"integer\"",
1176 "\"double\"",
1177 "\"string\"",
1178 "\"ADD\"",
1179 "\"Vertex SE2\"",
1180 "\"Vertex SE3\"",
1181 "\"Edge SE2\"",
1182 "\"Edge SE3\"",
1183 "\"Fix\"",
1184 "\"Solve State\"",
1185 "\"Query State\"",
1186 "';'",
1187 "$accept",
1188 "int_list",
1189 "NUMBER",
1190 "add_se2",
1191 "add_se3",
1192 "fix_node",
1193 "solve_state",
1194 "query_state",
1195 "command",
1196 "start",
1197 YY_NULLPTR};
1198#endif
1199
1200#if SLAMPARSERDEBUG
1201const unsigned char Parser::yyrline_[] = {
1202 0, 103, 103, 108, 114, 118, 123, 128, 137, 154, 159, 164,
1203 199, 206, 211, 215, 221, 225, 229, 233, 237, 242, 243, 244};
1204
1205void Parser::yy_stack_print_() const {
1206 *yycdebug_ << "Stack now";
1207 for (stack_type::const_iterator i = yystack_.begin(), i_end = yystack_.end();
1208 i != i_end; ++i)
1209 *yycdebug_ << ' ' << int(i->state);
1210 *yycdebug_ << '\n';
1211}
1212
1213void Parser::yy_reduce_print_(int yyrule) const {
1214 int yylno = yyrline_[yyrule];
1215 int yynrhs = yyr2_[yyrule];
1216 // Print the symbols being reduced, and their result.
1217 *yycdebug_ << "Reducing stack by rule " << yyrule - 1 << " (line " << yylno
1218 << "):\n";
1219 // The symbols being reduced.
1220 for (int yyi = 0; yyi < yynrhs; yyi++)
1221 YY_SYMBOL_PRINT(" $" << yyi + 1 << " =", yystack_[(yynrhs) - (yyi + 1)]);
1222}
1223#endif // SLAMPARSERDEBUG
1224
1225Parser::symbol_kind_type Parser::yytranslate_(int t) YY_NOEXCEPT {
1226 // YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to
1227 // TOKEN-NUM as returned by yylex.
1228 static const signed char translate_table[] = {
1229 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1230 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1231 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 15, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1232 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1233 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1234 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1235 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1236 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1237 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1238 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1239 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1240 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14};
1241 // Last valid token kind.
1242 const int code_max = 269;
1243
1244 if (t <= 0)
1245 return symbol_kind::S_YYEOF;
1246 else if (t <= code_max)
1247 return static_cast<symbol_kind_type>(translate_table[t]);
1248 else
1249 return symbol_kind::S_YYUNDEF;
1250}
1251
1252} // namespace SlamParser
1253#line 1458 "bison_parser.cpp"
1254
1255#line 252 "parser.yy"
1256/*** Additional Code ***/
1257
1258void SlamParser::Parser::error(const Parser::location_type& l,
1259 const std::string& m) {
1260 driver.error(l, m);
1261}
#define YYCDEBUG
#define YYABORT
#define YYLLOC_DEFAULT(Current, Rhs, N)
#define YY_REDUCE_PRINT(Rule)
#define YY_SYMBOL_PRINT(Title, Symbol)
#define yylex
#define YYCASE_(N, S)
#define YY_STACK_PRINT()
#define YY_(msgid)
#define YYACCEPT
#define YYERROR
#define YY_RVREF(Type)
#define YY_CAST(Type, Val)
#define YY_MOVE_REF(Type)
#define YY_NOEXCEPT
#define YY_MOVE
#define YY_NOTHROW
#define YY_USE(E)
void error(const class location &l, const std::string &m)
Definition driver.cpp:68
virtual void error(const location_type &loc, const std::string &msg)
class Driver & driver
#define YY_NULLPTR
Definition location.hh:52

◆ yyclearin

#define yyclearin   (yyla.clear())

Definition at line 145 of file bison_parser.cpp.

◆ yyerrok

#define yyerrok   (yyerrstatus_ = 0)

Definition at line 144 of file bison_parser.cpp.

◆ YYERROR

#define YYERROR   goto yyerrorlab

Definition at line 149 of file bison_parser.cpp.

◆ yylex [1/2]

#define yylex   SlamParserlex

Definition at line 38 of file bison_parser.cpp.

◆ yylex [2/2]

#define yylex   driver.lexer->lex

Definition at line 38 of file bison_parser.cpp.

◆ YYLLOC_DEFAULT

#define YYLLOC_DEFAULT (   Current,
  Rhs,
 
)
Value:
do \
if (N) { \
(Current).begin = YYRHSLOC(Rhs, 1).begin; \
(Current).end = YYRHSLOC(Rhs, N).end; \
} else { \
(Current).begin = (Current).end = YYRHSLOC(Rhs, 0).end; \
} \
while (false)
#define YYRHSLOC(Rhs, K)

Definition at line 97 of file bison_parser.cpp.

99 { \
100 (Current).begin = YYRHSLOC(Rhs, 1).begin; \
101 (Current).end = YYRHSLOC(Rhs, N).end; \
102 } else { \
103 (Current).begin = (Current).end = YYRHSLOC(Rhs, 0).end; \
104 } \
105 while (false)

◆ YYRECOVERING

#define YYRECOVERING ( )    (!!yyerrstatus_)

Definition at line 150 of file bison_parser.cpp.

◆ YYRHSLOC

#define YYRHSLOC (   Rhs,
 
)    ((Rhs)[K].location)

Definition at line 91 of file bison_parser.cpp.