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