1 // A Bison parser, made by GNU Bison 3.7.2.
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 
38 
39 
40 
41 #include "parser.hpp"
42 
43 
44 // Unqualified %code blocks.
45 
46     #include "pio_assembler.h"
47   #ifdef _MSC_VER
48   #pragma warning(disable : 4244) // possible loss of data (valid warning, but there is a software check / missing cast)
49   #endif
50 
51 
52 
53 #ifndef YY_
54 # if defined YYENABLE_NLS && YYENABLE_NLS
55 #  if ENABLE_NLS
56 #   include <libintl.h> // FIXME: INFRINGES ON USER NAME SPACE.
57 #   define YY_(msgid) dgettext ("bison-runtime", msgid)
58 #  endif
59 # endif
60 # ifndef YY_
61 #  define YY_(msgid) msgid
62 # endif
63 #endif
64 
65 
66 // Whether we are compiled with exception support.
67 #ifndef YY_EXCEPTIONS
68 # if defined __GNUC__ && !defined __EXCEPTIONS
69 #  define YY_EXCEPTIONS 0
70 # else
71 #  define YY_EXCEPTIONS 1
72 # endif
73 #endif
74 
75 #define YYRHSLOC(Rhs, K) ((Rhs)[K].location)
76 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
77    If N is 0, then set CURRENT to the empty location which ends
78    the previous symbol: RHS[0] (always defined).  */
79 
80 # ifndef YYLLOC_DEFAULT
81 #  define YYLLOC_DEFAULT(Current, Rhs, N)                               \
82     do                                                                  \
83       if (N)                                                            \
84         {                                                               \
85           (Current).begin  = YYRHSLOC (Rhs, 1).begin;                   \
86           (Current).end    = YYRHSLOC (Rhs, N).end;                     \
87         }                                                               \
88       else                                                              \
89         {                                                               \
90           (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end;      \
91         }                                                               \
92     while (false)
93 # endif
94 
95 
96 // Enable debugging if requested.
97 #if YYDEBUG
98 
99 // A pseudo ostream that takes yydebug_ into account.
100 # define YYCDEBUG if (yydebug_) (*yycdebug_)
101 
102 # define YY_SYMBOL_PRINT(Title, Symbol)         \
103   do {                                          \
104     if (yydebug_)                               \
105     {                                           \
106       *yycdebug_ << Title << ' ';               \
107       yy_print_ (*yycdebug_, Symbol);           \
108       *yycdebug_ << '\n';                       \
109     }                                           \
110   } while (false)
111 
112 # define YY_REDUCE_PRINT(Rule)          \
113   do {                                  \
114     if (yydebug_)                       \
115       yy_reduce_print_ (Rule);          \
116   } while (false)
117 
118 # define YY_STACK_PRINT()               \
119   do {                                  \
120     if (yydebug_)                       \
121       yy_stack_print_ ();                \
122   } while (false)
123 
124 #else // !YYDEBUG
125 
126 # define YYCDEBUG if (false) std::cerr
127 # define YY_SYMBOL_PRINT(Title, Symbol)  YYUSE (Symbol)
128 # define YY_REDUCE_PRINT(Rule)           static_cast<void> (0)
129 # define YY_STACK_PRINT()                static_cast<void> (0)
130 
131 #endif // !YYDEBUG
132 
133 #define yyerrok         (yyerrstatus_ = 0)
134 #define yyclearin       (yyla.clear ())
135 
136 #define YYACCEPT        goto yyacceptlab
137 #define YYABORT         goto yyabortlab
138 #define YYERROR         goto yyerrorlab
139 #define YYRECOVERING()  (!!yyerrstatus_)
140 
141 namespace yy {
142 
143   /// Build a parser object.
parser(pio_assembler & pioasm_yyarg)144   parser::parser (pio_assembler& pioasm_yyarg)
145 #if YYDEBUG
146     : yydebug_ (false),
147       yycdebug_ (&std::cerr),
148 #else
149     :
150 #endif
151       yy_lac_established_ (false),
152       pioasm (pioasm_yyarg)
153   {}
154 
~parser()155   parser::~parser ()
156   {}
157 
~syntax_error()158   parser::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW
159   {}
160 
161   /*---------------.
162   | symbol kinds.  |
163   `---------------*/
164 
165 
166 
167   // by_state.
by_state()168   parser::by_state::by_state () YY_NOEXCEPT
169     : state (empty_state)
170   {}
171 
by_state(const by_state & that)172   parser::by_state::by_state (const by_state& that) YY_NOEXCEPT
173     : state (that.state)
174   {}
175 
176   void
clear()177   parser::by_state::clear () YY_NOEXCEPT
178   {
179     state = empty_state;
180   }
181 
182   void
move(by_state & that)183   parser::by_state::move (by_state& that)
184   {
185     state = that.state;
186     that.clear ();
187   }
188 
by_state(state_type s)189   parser::by_state::by_state (state_type s) YY_NOEXCEPT
190     : state (s)
191   {}
192 
193   parser::symbol_kind_type
kind() const194   parser::by_state::kind () const YY_NOEXCEPT
195   {
196     if (state == empty_state)
197       return symbol_kind::S_YYEMPTY;
198     else
199       return YY_CAST (symbol_kind_type, yystos_[+state]);
200   }
201 
stack_symbol_type()202   parser::stack_symbol_type::stack_symbol_type ()
203   {}
204 
stack_symbol_type(YY_RVREF (stack_symbol_type)that)205   parser::stack_symbol_type::stack_symbol_type (YY_RVREF (stack_symbol_type) that)
206     : super_type (YY_MOVE (that.state), YY_MOVE (that.location))
207   {
208     switch (that.kind ())
209     {
210       case symbol_kind::S_direction: // direction
211       case symbol_kind::S_autop: // autop
212       case symbol_kind::S_if_full: // if_full
213       case symbol_kind::S_if_empty: // if_empty
214       case symbol_kind::S_blocking: // blocking
215         value.YY_MOVE_OR_COPY< bool > (YY_MOVE (that.value));
216         break;
217 
218       case symbol_kind::S_condition: // condition
219         value.YY_MOVE_OR_COPY< enum condition > (YY_MOVE (that.value));
220         break;
221 
222       case symbol_kind::S_fifo_config: // fifo_config
223         value.YY_MOVE_OR_COPY< enum fifo_config > (YY_MOVE (that.value));
224         break;
225 
226       case symbol_kind::S_in_source: // in_source
227       case symbol_kind::S_out_target: // out_target
228       case symbol_kind::S_set_target: // set_target
229         value.YY_MOVE_OR_COPY< enum in_out_set > (YY_MOVE (that.value));
230         break;
231 
232       case symbol_kind::S_irq_modifiers: // irq_modifiers
233         value.YY_MOVE_OR_COPY< enum irq > (YY_MOVE (that.value));
234         break;
235 
236       case symbol_kind::S_mov_op: // mov_op
237         value.YY_MOVE_OR_COPY< enum mov_op > (YY_MOVE (that.value));
238         break;
239 
240       case symbol_kind::S_mov_target: // mov_target
241       case symbol_kind::S_mov_source: // mov_source
242         value.YY_MOVE_OR_COPY< extended_mov > (YY_MOVE (that.value));
243         break;
244 
245       case symbol_kind::S_FLOAT: // "float"
246         value.YY_MOVE_OR_COPY< float > (YY_MOVE (that.value));
247         break;
248 
249       case symbol_kind::S_INT: // "integer"
250         value.YY_MOVE_OR_COPY< int > (YY_MOVE (that.value));
251         break;
252 
253       case symbol_kind::S_instruction: // instruction
254       case symbol_kind::S_base_instruction: // base_instruction
255         value.YY_MOVE_OR_COPY< std::shared_ptr<instruction> > (YY_MOVE (that.value));
256         break;
257 
258       case symbol_kind::S_value: // value
259       case symbol_kind::S_expression: // expression
260       case symbol_kind::S_delay: // delay
261       case symbol_kind::S_sideset: // sideset
262       case symbol_kind::S_threshold: // threshold
263         value.YY_MOVE_OR_COPY< std::shared_ptr<resolvable> > (YY_MOVE (that.value));
264         break;
265 
266       case symbol_kind::S_label_decl: // label_decl
267       case symbol_kind::S_symbol_def: // symbol_def
268         value.YY_MOVE_OR_COPY< std::shared_ptr<symbol> > (YY_MOVE (that.value));
269         break;
270 
271       case symbol_kind::S_wait_source: // wait_source
272         value.YY_MOVE_OR_COPY< std::shared_ptr<wait_source> > (YY_MOVE (that.value));
273         break;
274 
275       case symbol_kind::S_ID: // "identifier"
276       case symbol_kind::S_STRING: // "string"
277       case symbol_kind::S_NON_WS: // "text"
278       case symbol_kind::S_CODE_BLOCK_START: // "code block"
279       case symbol_kind::S_CODE_BLOCK_CONTENTS: // "%}"
280       case symbol_kind::S_UNKNOWN_DIRECTIVE: // UNKNOWN_DIRECTIVE
281         value.YY_MOVE_OR_COPY< std::string > (YY_MOVE (that.value));
282         break;
283 
284       case symbol_kind::S_pio_version: // pio_version
285         value.YY_MOVE_OR_COPY< uint > (YY_MOVE (that.value));
286         break;
287 
288       default:
289         break;
290     }
291 
292 #if 201103L <= YY_CPLUSPLUS
293     // that is emptied.
294     that.state = empty_state;
295 #endif
296   }
297 
stack_symbol_type(state_type s,YY_MOVE_REF (symbol_type)that)298   parser::stack_symbol_type::stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) that)
299     : super_type (s, YY_MOVE (that.location))
300   {
301     switch (that.kind ())
302     {
303       case symbol_kind::S_direction: // direction
304       case symbol_kind::S_autop: // autop
305       case symbol_kind::S_if_full: // if_full
306       case symbol_kind::S_if_empty: // if_empty
307       case symbol_kind::S_blocking: // blocking
308         value.move< bool > (YY_MOVE (that.value));
309         break;
310 
311       case symbol_kind::S_condition: // condition
312         value.move< enum condition > (YY_MOVE (that.value));
313         break;
314 
315       case symbol_kind::S_fifo_config: // fifo_config
316         value.move< enum fifo_config > (YY_MOVE (that.value));
317         break;
318 
319       case symbol_kind::S_in_source: // in_source
320       case symbol_kind::S_out_target: // out_target
321       case symbol_kind::S_set_target: // set_target
322         value.move< enum in_out_set > (YY_MOVE (that.value));
323         break;
324 
325       case symbol_kind::S_irq_modifiers: // irq_modifiers
326         value.move< enum irq > (YY_MOVE (that.value));
327         break;
328 
329       case symbol_kind::S_mov_op: // mov_op
330         value.move< enum mov_op > (YY_MOVE (that.value));
331         break;
332 
333       case symbol_kind::S_mov_target: // mov_target
334       case symbol_kind::S_mov_source: // mov_source
335         value.move< extended_mov > (YY_MOVE (that.value));
336         break;
337 
338       case symbol_kind::S_FLOAT: // "float"
339         value.move< float > (YY_MOVE (that.value));
340         break;
341 
342       case symbol_kind::S_INT: // "integer"
343         value.move< int > (YY_MOVE (that.value));
344         break;
345 
346       case symbol_kind::S_instruction: // instruction
347       case symbol_kind::S_base_instruction: // base_instruction
348         value.move< std::shared_ptr<instruction> > (YY_MOVE (that.value));
349         break;
350 
351       case symbol_kind::S_value: // value
352       case symbol_kind::S_expression: // expression
353       case symbol_kind::S_delay: // delay
354       case symbol_kind::S_sideset: // sideset
355       case symbol_kind::S_threshold: // threshold
356         value.move< std::shared_ptr<resolvable> > (YY_MOVE (that.value));
357         break;
358 
359       case symbol_kind::S_label_decl: // label_decl
360       case symbol_kind::S_symbol_def: // symbol_def
361         value.move< std::shared_ptr<symbol> > (YY_MOVE (that.value));
362         break;
363 
364       case symbol_kind::S_wait_source: // wait_source
365         value.move< std::shared_ptr<wait_source> > (YY_MOVE (that.value));
366         break;
367 
368       case symbol_kind::S_ID: // "identifier"
369       case symbol_kind::S_STRING: // "string"
370       case symbol_kind::S_NON_WS: // "text"
371       case symbol_kind::S_CODE_BLOCK_START: // "code block"
372       case symbol_kind::S_CODE_BLOCK_CONTENTS: // "%}"
373       case symbol_kind::S_UNKNOWN_DIRECTIVE: // UNKNOWN_DIRECTIVE
374         value.move< std::string > (YY_MOVE (that.value));
375         break;
376 
377       case symbol_kind::S_pio_version: // pio_version
378         value.move< uint > (YY_MOVE (that.value));
379         break;
380 
381       default:
382         break;
383     }
384 
385     // that is emptied.
386     that.kind_ = symbol_kind::S_YYEMPTY;
387   }
388 
389 #if YY_CPLUSPLUS < 201103L
390   parser::stack_symbol_type&
operator =(const stack_symbol_type & that)391   parser::stack_symbol_type::operator= (const stack_symbol_type& that)
392   {
393     state = that.state;
394     switch (that.kind ())
395     {
396       case symbol_kind::S_direction: // direction
397       case symbol_kind::S_autop: // autop
398       case symbol_kind::S_if_full: // if_full
399       case symbol_kind::S_if_empty: // if_empty
400       case symbol_kind::S_blocking: // blocking
401         value.copy< bool > (that.value);
402         break;
403 
404       case symbol_kind::S_condition: // condition
405         value.copy< enum condition > (that.value);
406         break;
407 
408       case symbol_kind::S_fifo_config: // fifo_config
409         value.copy< enum fifo_config > (that.value);
410         break;
411 
412       case symbol_kind::S_in_source: // in_source
413       case symbol_kind::S_out_target: // out_target
414       case symbol_kind::S_set_target: // set_target
415         value.copy< enum in_out_set > (that.value);
416         break;
417 
418       case symbol_kind::S_irq_modifiers: // irq_modifiers
419         value.copy< enum irq > (that.value);
420         break;
421 
422       case symbol_kind::S_mov_op: // mov_op
423         value.copy< enum mov_op > (that.value);
424         break;
425 
426       case symbol_kind::S_mov_target: // mov_target
427       case symbol_kind::S_mov_source: // mov_source
428         value.copy< extended_mov > (that.value);
429         break;
430 
431       case symbol_kind::S_FLOAT: // "float"
432         value.copy< float > (that.value);
433         break;
434 
435       case symbol_kind::S_INT: // "integer"
436         value.copy< int > (that.value);
437         break;
438 
439       case symbol_kind::S_instruction: // instruction
440       case symbol_kind::S_base_instruction: // base_instruction
441         value.copy< std::shared_ptr<instruction> > (that.value);
442         break;
443 
444       case symbol_kind::S_value: // value
445       case symbol_kind::S_expression: // expression
446       case symbol_kind::S_delay: // delay
447       case symbol_kind::S_sideset: // sideset
448       case symbol_kind::S_threshold: // threshold
449         value.copy< std::shared_ptr<resolvable> > (that.value);
450         break;
451 
452       case symbol_kind::S_label_decl: // label_decl
453       case symbol_kind::S_symbol_def: // symbol_def
454         value.copy< std::shared_ptr<symbol> > (that.value);
455         break;
456 
457       case symbol_kind::S_wait_source: // wait_source
458         value.copy< std::shared_ptr<wait_source> > (that.value);
459         break;
460 
461       case symbol_kind::S_ID: // "identifier"
462       case symbol_kind::S_STRING: // "string"
463       case symbol_kind::S_NON_WS: // "text"
464       case symbol_kind::S_CODE_BLOCK_START: // "code block"
465       case symbol_kind::S_CODE_BLOCK_CONTENTS: // "%}"
466       case symbol_kind::S_UNKNOWN_DIRECTIVE: // UNKNOWN_DIRECTIVE
467         value.copy< std::string > (that.value);
468         break;
469 
470       case symbol_kind::S_pio_version: // pio_version
471         value.copy< uint > (that.value);
472         break;
473 
474       default:
475         break;
476     }
477 
478     location = that.location;
479     return *this;
480   }
481 
482   parser::stack_symbol_type&
operator =(stack_symbol_type & that)483   parser::stack_symbol_type::operator= (stack_symbol_type& that)
484   {
485     state = that.state;
486     switch (that.kind ())
487     {
488       case symbol_kind::S_direction: // direction
489       case symbol_kind::S_autop: // autop
490       case symbol_kind::S_if_full: // if_full
491       case symbol_kind::S_if_empty: // if_empty
492       case symbol_kind::S_blocking: // blocking
493         value.move< bool > (that.value);
494         break;
495 
496       case symbol_kind::S_condition: // condition
497         value.move< enum condition > (that.value);
498         break;
499 
500       case symbol_kind::S_fifo_config: // fifo_config
501         value.move< enum fifo_config > (that.value);
502         break;
503 
504       case symbol_kind::S_in_source: // in_source
505       case symbol_kind::S_out_target: // out_target
506       case symbol_kind::S_set_target: // set_target
507         value.move< enum in_out_set > (that.value);
508         break;
509 
510       case symbol_kind::S_irq_modifiers: // irq_modifiers
511         value.move< enum irq > (that.value);
512         break;
513 
514       case symbol_kind::S_mov_op: // mov_op
515         value.move< enum mov_op > (that.value);
516         break;
517 
518       case symbol_kind::S_mov_target: // mov_target
519       case symbol_kind::S_mov_source: // mov_source
520         value.move< extended_mov > (that.value);
521         break;
522 
523       case symbol_kind::S_FLOAT: // "float"
524         value.move< float > (that.value);
525         break;
526 
527       case symbol_kind::S_INT: // "integer"
528         value.move< int > (that.value);
529         break;
530 
531       case symbol_kind::S_instruction: // instruction
532       case symbol_kind::S_base_instruction: // base_instruction
533         value.move< std::shared_ptr<instruction> > (that.value);
534         break;
535 
536       case symbol_kind::S_value: // value
537       case symbol_kind::S_expression: // expression
538       case symbol_kind::S_delay: // delay
539       case symbol_kind::S_sideset: // sideset
540       case symbol_kind::S_threshold: // threshold
541         value.move< std::shared_ptr<resolvable> > (that.value);
542         break;
543 
544       case symbol_kind::S_label_decl: // label_decl
545       case symbol_kind::S_symbol_def: // symbol_def
546         value.move< std::shared_ptr<symbol> > (that.value);
547         break;
548 
549       case symbol_kind::S_wait_source: // wait_source
550         value.move< std::shared_ptr<wait_source> > (that.value);
551         break;
552 
553       case symbol_kind::S_ID: // "identifier"
554       case symbol_kind::S_STRING: // "string"
555       case symbol_kind::S_NON_WS: // "text"
556       case symbol_kind::S_CODE_BLOCK_START: // "code block"
557       case symbol_kind::S_CODE_BLOCK_CONTENTS: // "%}"
558       case symbol_kind::S_UNKNOWN_DIRECTIVE: // UNKNOWN_DIRECTIVE
559         value.move< std::string > (that.value);
560         break;
561 
562       case symbol_kind::S_pio_version: // pio_version
563         value.move< uint > (that.value);
564         break;
565 
566       default:
567         break;
568     }
569 
570     location = that.location;
571     // that is emptied.
572     that.state = empty_state;
573     return *this;
574   }
575 #endif
576 
577   template <typename Base>
578   void
yy_destroy_(const char * yymsg,basic_symbol<Base> & yysym) const579   parser::yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const
580   {
581     if (yymsg)
582       YY_SYMBOL_PRINT (yymsg, yysym);
583   }
584 
585 #if YYDEBUG
586   template <typename Base>
587   void
yy_print_(std::ostream & yyo,const basic_symbol<Base> & yysym) const588   parser::yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const
589   {
590     std::ostream& yyoutput = yyo;
591     YYUSE (yyoutput);
592     if (yysym.empty ())
593       yyo << "empty symbol";
594     else
595       {
596         symbol_kind_type yykind = yysym.kind ();
597         yyo << (yykind < YYNTOKENS ? "token" : "nterm")
598             << ' ' << yysym.name () << " ("
599             << yysym.location << ": ";
600         switch (yykind)
601     {
602       case symbol_kind::S_ID: // "identifier"
603                  { yyo << "..."; }
604         break;
605 
606       case symbol_kind::S_STRING: // "string"
607                  { yyo << "..."; }
608         break;
609 
610       case symbol_kind::S_NON_WS: // "text"
611                  { yyo << "..."; }
612         break;
613 
614       case symbol_kind::S_CODE_BLOCK_START: // "code block"
615                  { yyo << "..."; }
616         break;
617 
618       case symbol_kind::S_CODE_BLOCK_CONTENTS: // "%}"
619                  { yyo << "..."; }
620         break;
621 
622       case symbol_kind::S_UNKNOWN_DIRECTIVE: // UNKNOWN_DIRECTIVE
623                  { yyo << "..."; }
624         break;
625 
626       case symbol_kind::S_INT: // "integer"
627                  { yyo << "..."; }
628         break;
629 
630       case symbol_kind::S_FLOAT: // "float"
631                  { yyo << "..."; }
632         break;
633 
634       case symbol_kind::S_label_decl: // label_decl
635                  { yyo << "..."; }
636         break;
637 
638       case symbol_kind::S_value: // value
639                  { yyo << "..."; }
640         break;
641 
642       case symbol_kind::S_expression: // expression
643                  { yyo << "..."; }
644         break;
645 
646       case symbol_kind::S_pio_version: // pio_version
647                  { yyo << "..."; }
648         break;
649 
650       case symbol_kind::S_instruction: // instruction
651                  { yyo << "..."; }
652         break;
653 
654       case symbol_kind::S_base_instruction: // base_instruction
655                  { yyo << "..."; }
656         break;
657 
658       case symbol_kind::S_delay: // delay
659                  { yyo << "..."; }
660         break;
661 
662       case symbol_kind::S_sideset: // sideset
663                  { yyo << "..."; }
664         break;
665 
666       case symbol_kind::S_condition: // condition
667                  { yyo << "..."; }
668         break;
669 
670       case symbol_kind::S_wait_source: // wait_source
671                  { yyo << "..."; }
672         break;
673 
674       case symbol_kind::S_fifo_config: // fifo_config
675                  { yyo << "..."; }
676         break;
677 
678       case symbol_kind::S_in_source: // in_source
679                  { yyo << "..."; }
680         break;
681 
682       case symbol_kind::S_out_target: // out_target
683                  { yyo << "..."; }
684         break;
685 
686       case symbol_kind::S_mov_target: // mov_target
687                  { yyo << "..."; }
688         break;
689 
690       case symbol_kind::S_mov_source: // mov_source
691                  { yyo << "..."; }
692         break;
693 
694       case symbol_kind::S_mov_op: // mov_op
695                  { yyo << "..."; }
696         break;
697 
698       case symbol_kind::S_set_target: // set_target
699                  { yyo << "..."; }
700         break;
701 
702       case symbol_kind::S_direction: // direction
703                  { yyo << "..."; }
704         break;
705 
706       case symbol_kind::S_autop: // autop
707                  { yyo << "..."; }
708         break;
709 
710       case symbol_kind::S_threshold: // threshold
711                  { yyo << "..."; }
712         break;
713 
714       case symbol_kind::S_if_full: // if_full
715                  { yyo << "..."; }
716         break;
717 
718       case symbol_kind::S_if_empty: // if_empty
719                  { yyo << "..."; }
720         break;
721 
722       case symbol_kind::S_blocking: // blocking
723                  { yyo << "..."; }
724         break;
725 
726       case symbol_kind::S_irq_modifiers: // irq_modifiers
727                  { yyo << "..."; }
728         break;
729 
730       case symbol_kind::S_symbol_def: // symbol_def
731                  { yyo << "..."; }
732         break;
733 
734       default:
735         break;
736     }
737         yyo << ')';
738       }
739   }
740 #endif
741 
742   void
yypush_(const char * m,YY_MOVE_REF (stack_symbol_type)sym)743   parser::yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym)
744   {
745     if (m)
746       YY_SYMBOL_PRINT (m, sym);
747     yystack_.push (YY_MOVE (sym));
748   }
749 
750   void
yypush_(const char * m,state_type s,YY_MOVE_REF (symbol_type)sym)751   parser::yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym)
752   {
753 #if 201103L <= YY_CPLUSPLUS
754     yypush_ (m, stack_symbol_type (s, std::move (sym)));
755 #else
756     stack_symbol_type ss (s, sym);
757     yypush_ (m, ss);
758 #endif
759   }
760 
761   void
yypop_(int n)762   parser::yypop_ (int n)
763   {
764     yystack_.pop (n);
765   }
766 
767 #if YYDEBUG
768   std::ostream&
debug_stream() const769   parser::debug_stream () const
770   {
771     return *yycdebug_;
772   }
773 
774   void
set_debug_stream(std::ostream & o)775   parser::set_debug_stream (std::ostream& o)
776   {
777     yycdebug_ = &o;
778   }
779 
780 
781   parser::debug_level_type
debug_level() const782   parser::debug_level () const
783   {
784     return yydebug_;
785   }
786 
787   void
set_debug_level(debug_level_type l)788   parser::set_debug_level (debug_level_type l)
789   {
790     yydebug_ = l;
791   }
792 #endif // YYDEBUG
793 
794   parser::state_type
yy_lr_goto_state_(state_type yystate,int yysym)795   parser::yy_lr_goto_state_ (state_type yystate, int yysym)
796   {
797     int yyr = yypgoto_[yysym - YYNTOKENS] + yystate;
798     if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
799       return yytable_[yyr];
800     else
801       return yydefgoto_[yysym - YYNTOKENS];
802   }
803 
804   bool
yy_pact_value_is_default_(int yyvalue)805   parser::yy_pact_value_is_default_ (int yyvalue)
806   {
807     return yyvalue == yypact_ninf_;
808   }
809 
810   bool
yy_table_value_is_error_(int yyvalue)811   parser::yy_table_value_is_error_ (int yyvalue)
812   {
813     return yyvalue == yytable_ninf_;
814   }
815 
816   int
operator ()()817   parser::operator() ()
818   {
819     return parse ();
820   }
821 
822   int
parse()823   parser::parse ()
824   {
825     int yyn;
826     /// Length of the RHS of the rule being reduced.
827     int yylen = 0;
828 
829     // Error handling.
830     int yynerrs_ = 0;
831     int yyerrstatus_ = 0;
832 
833     /// The lookahead symbol.
834     symbol_type yyla;
835 
836     /// The locations where the error started and ended.
837     stack_symbol_type yyerror_range[3];
838 
839     /// The return value of parse ().
840     int yyresult;
841 
842     /// Discard the LAC context in case there still is one left from a
843     /// previous invocation.
844     yy_lac_discard_ ("init");
845 
846 #if YY_EXCEPTIONS
847     try
848 #endif // YY_EXCEPTIONS
849       {
850     YYCDEBUG << "Starting parse\n";
851 
852 
853     /* Initialize the stack.  The initial state will be set in
854        yynewstate, since the latter expects the semantical and the
855        location values to have been already stored, initialize these
856        stacks with a primary value.  */
857     yystack_.clear ();
858     yypush_ (YY_NULLPTR, 0, YY_MOVE (yyla));
859 
860   /*-----------------------------------------------.
861   | yynewstate -- push a new symbol on the stack.  |
862   `-----------------------------------------------*/
863   yynewstate:
864     YYCDEBUG << "Entering state " << int (yystack_[0].state) << '\n';
865     YY_STACK_PRINT ();
866 
867     // Accept?
868     if (yystack_[0].state == yyfinal_)
869       YYACCEPT;
870 
871     goto yybackup;
872 
873 
874   /*-----------.
875   | yybackup.  |
876   `-----------*/
877   yybackup:
878     // Try to take a decision without lookahead.
879     yyn = yypact_[+yystack_[0].state];
880     if (yy_pact_value_is_default_ (yyn))
881       goto yydefault;
882 
883     // Read a lookahead token.
884     if (yyla.empty ())
885       {
886         YYCDEBUG << "Reading a token\n";
887 #if YY_EXCEPTIONS
888         try
889 #endif // YY_EXCEPTIONS
890           {
891             symbol_type yylookahead (yylex (pioasm));
892             yyla.move (yylookahead);
893           }
894 #if YY_EXCEPTIONS
895         catch (const syntax_error& yyexc)
896           {
897             YYCDEBUG << "Caught exception: " << yyexc.what() << '\n';
898             error (yyexc);
899             goto yyerrlab1;
900           }
901 #endif // YY_EXCEPTIONS
902       }
903     YY_SYMBOL_PRINT ("Next token is", yyla);
904 
905     if (yyla.kind () == symbol_kind::S_YYerror)
906     {
907       // The scanner already issued an error message, process directly
908       // to error recovery.  But do not keep the error token as
909       // lookahead, it is too special and may lead us to an endless
910       // loop in error recovery. */
911       yyla.kind_ = symbol_kind::S_YYUNDEF;
912       goto yyerrlab1;
913     }
914 
915     /* If the proper action on seeing token YYLA.TYPE is to reduce or
916        to detect an error, take that action.  */
917     yyn += yyla.kind ();
918     if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.kind ())
919       {
920         if (!yy_lac_establish_ (yyla.kind ()))
921            goto yyerrlab;
922         goto yydefault;
923       }
924 
925     // Reduce or error.
926     yyn = yytable_[yyn];
927     if (yyn <= 0)
928       {
929         if (yy_table_value_is_error_ (yyn))
930           goto yyerrlab;
931         if (!yy_lac_establish_ (yyla.kind ()))
932            goto yyerrlab;
933 
934         yyn = -yyn;
935         goto yyreduce;
936       }
937 
938     // Count tokens shifted since error; after three, turn off error status.
939     if (yyerrstatus_)
940       --yyerrstatus_;
941 
942     // Shift the lookahead token.
943     yypush_ ("Shifting", state_type (yyn), YY_MOVE (yyla));
944     yy_lac_discard_ ("shift");
945     goto yynewstate;
946 
947 
948   /*-----------------------------------------------------------.
949   | yydefault -- do the default action for the current state.  |
950   `-----------------------------------------------------------*/
951   yydefault:
952     yyn = yydefact_[+yystack_[0].state];
953     if (yyn == 0)
954       goto yyerrlab;
955     goto yyreduce;
956 
957 
958   /*-----------------------------.
959   | yyreduce -- do a reduction.  |
960   `-----------------------------*/
961   yyreduce:
962     yylen = yyr2_[yyn];
963     {
964       stack_symbol_type yylhs;
965       yylhs.state = yy_lr_goto_state_ (yystack_[yylen].state, yyr1_[yyn]);
966       /* Variants are always initialized to an empty instance of the
967          correct type. The default '$$ = $1' action is NOT applied
968          when using variants.  */
969       switch (yyr1_[yyn])
970     {
971       case symbol_kind::S_direction: // direction
972       case symbol_kind::S_autop: // autop
973       case symbol_kind::S_if_full: // if_full
974       case symbol_kind::S_if_empty: // if_empty
975       case symbol_kind::S_blocking: // blocking
976         yylhs.value.emplace< bool > ();
977         break;
978 
979       case symbol_kind::S_condition: // condition
980         yylhs.value.emplace< enum condition > ();
981         break;
982 
983       case symbol_kind::S_fifo_config: // fifo_config
984         yylhs.value.emplace< enum fifo_config > ();
985         break;
986 
987       case symbol_kind::S_in_source: // in_source
988       case symbol_kind::S_out_target: // out_target
989       case symbol_kind::S_set_target: // set_target
990         yylhs.value.emplace< enum in_out_set > ();
991         break;
992 
993       case symbol_kind::S_irq_modifiers: // irq_modifiers
994         yylhs.value.emplace< enum irq > ();
995         break;
996 
997       case symbol_kind::S_mov_op: // mov_op
998         yylhs.value.emplace< enum mov_op > ();
999         break;
1000 
1001       case symbol_kind::S_mov_target: // mov_target
1002       case symbol_kind::S_mov_source: // mov_source
1003         yylhs.value.emplace< extended_mov > ();
1004         break;
1005 
1006       case symbol_kind::S_FLOAT: // "float"
1007         yylhs.value.emplace< float > ();
1008         break;
1009 
1010       case symbol_kind::S_INT: // "integer"
1011         yylhs.value.emplace< int > ();
1012         break;
1013 
1014       case symbol_kind::S_instruction: // instruction
1015       case symbol_kind::S_base_instruction: // base_instruction
1016         yylhs.value.emplace< std::shared_ptr<instruction> > ();
1017         break;
1018 
1019       case symbol_kind::S_value: // value
1020       case symbol_kind::S_expression: // expression
1021       case symbol_kind::S_delay: // delay
1022       case symbol_kind::S_sideset: // sideset
1023       case symbol_kind::S_threshold: // threshold
1024         yylhs.value.emplace< std::shared_ptr<resolvable> > ();
1025         break;
1026 
1027       case symbol_kind::S_label_decl: // label_decl
1028       case symbol_kind::S_symbol_def: // symbol_def
1029         yylhs.value.emplace< std::shared_ptr<symbol> > ();
1030         break;
1031 
1032       case symbol_kind::S_wait_source: // wait_source
1033         yylhs.value.emplace< std::shared_ptr<wait_source> > ();
1034         break;
1035 
1036       case symbol_kind::S_ID: // "identifier"
1037       case symbol_kind::S_STRING: // "string"
1038       case symbol_kind::S_NON_WS: // "text"
1039       case symbol_kind::S_CODE_BLOCK_START: // "code block"
1040       case symbol_kind::S_CODE_BLOCK_CONTENTS: // "%}"
1041       case symbol_kind::S_UNKNOWN_DIRECTIVE: // UNKNOWN_DIRECTIVE
1042         yylhs.value.emplace< std::string > ();
1043         break;
1044 
1045       case symbol_kind::S_pio_version: // pio_version
1046         yylhs.value.emplace< uint > ();
1047         break;
1048 
1049       default:
1050         break;
1051     }
1052 
1053 
1054       // Default location.
1055       {
1056         stack_type::slice range (yystack_, yylen);
1057         YYLLOC_DEFAULT (yylhs.location, range, yylen);
1058         yyerror_range[1].location = yylhs.location;
1059       }
1060 
1061       // Perform the reduction.
1062       YY_REDUCE_PRINT (yyn);
1063 #if YY_EXCEPTIONS
1064       try
1065 #endif // YY_EXCEPTIONS
1066         {
1067           switch (yyn)
1068             {
1069   case 2: // file: lines "end of file"
1070               { if (pioasm.error_count || pioasm.write_output()) YYABORT; }
1071     break;
1072 
1073   case 5: // line: ".program" "identifier"
1074                                                 { if (!pioasm.add_program(yylhs.location, yystack_[0].value.as < std::string > ())) { std::stringstream msg; msg << "program " << yystack_[0].value.as < std::string > () << " already exists"; error(yylhs.location, msg.str()); abort(); } }
1075     break;
1076 
1077   case 7: // line: instruction
1078                                                 { pioasm.get_current_program(yystack_[0].location, "instruction").add_instruction(yystack_[0].value.as < std::shared_ptr<instruction> > ()); }
1079     break;
1080 
1081   case 8: // line: label_decl instruction
1082                                                 { auto &p = pioasm.get_current_program(yystack_[0].location, "instruction"); p.add_label(yystack_[1].value.as < std::shared_ptr<symbol> > ()); p.add_instruction(yystack_[0].value.as < std::shared_ptr<instruction> > ()); }
1083     break;
1084 
1085   case 9: // line: label_decl
1086                                                 { pioasm.get_current_program(yystack_[0].location, "label").add_label(yystack_[0].value.as < std::shared_ptr<symbol> > ()); }
1087     break;
1088 
1089   case 12: // line: error
1090                                                 { if (pioasm.error_count > 6) { std::cerr << "\ntoo many errors; aborting.\n"; YYABORT; } }
1091     break;
1092 
1093   case 13: // code_block: "code block" "%}"
1094                                                 { std::string of = yystack_[1].value.as < std::string > (); if (of.empty()) of = output_format::default_name; pioasm.get_current_program(yylhs.location, "code block", false, false).add_code_block( code_block(yylhs.location, of, yystack_[0].value.as < std::string > ())); }
1095     break;
1096 
1097   case 14: // label_decl: symbol_def ":"
1098                             { yystack_[1].value.as < std::shared_ptr<symbol> > ()->is_label = true; yylhs.value.as < std::shared_ptr<symbol> > () = yystack_[1].value.as < std::shared_ptr<symbol> > (); }
1099     break;
1100 
1101   case 15: // directive: ".define" symbol_def expression
1102                                       { yystack_[1].value.as < std::shared_ptr<symbol> > ()->is_label = false; yystack_[1].value.as < std::shared_ptr<symbol> > ()->value = yystack_[0].value.as < std::shared_ptr<resolvable> > (); pioasm.get_current_program(yystack_[2].location, ".define", false, false).add_symbol(yystack_[1].value.as < std::shared_ptr<symbol> > ()); }
1103     break;
1104 
1105   case 16: // directive: ".origin" value
1106                                       { pioasm.get_current_program(yystack_[1].location, ".origin", true).set_origin(yylhs.location, yystack_[0].value.as < std::shared_ptr<resolvable> > ()); }
1107     break;
1108 
1109   case 17: // directive: ".pio_version" pio_version
1110                                       { pioasm.get_current_program(yystack_[1].location, ".pio_version", true, false).set_pio_version(yylhs.location, yystack_[0].value.as < uint > ()); }
1111     break;
1112 
1113   case 18: // directive: ".side_set" value "opt" "pindirs"
1114                                       { pioasm.get_current_program(yystack_[3].location, ".side_set", true).set_sideset(yylhs.location, yystack_[2].value.as < std::shared_ptr<resolvable> > (), true, true); }
1115     break;
1116 
1117   case 19: // directive: ".side_set" value "opt"
1118                                       { pioasm.get_current_program(yystack_[2].location, ".side_set", true).set_sideset(yylhs.location, yystack_[1].value.as < std::shared_ptr<resolvable> > (), true, false); }
1119     break;
1120 
1121   case 20: // directive: ".side_set" value "pindirs"
1122                                       { pioasm.get_current_program(yystack_[2].location, ".side_set", true).set_sideset(yylhs.location, yystack_[1].value.as < std::shared_ptr<resolvable> > (), false, true); }
1123     break;
1124 
1125   case 21: // directive: ".side_set" value
1126                                       { pioasm.get_current_program(yystack_[1].location, ".side_set", true).set_sideset(yylhs.location, yystack_[0].value.as < std::shared_ptr<resolvable> > (), false, false); }
1127     break;
1128 
1129   case 22: // directive: ".in" value direction autop threshold
1130                                            { pioasm.get_current_program(yystack_[4].location, ".in", true).set_in(yylhs.location, yystack_[3].value.as < std::shared_ptr<resolvable> > (), yystack_[2].value.as < bool > (), yystack_[1].value.as < bool > (), yystack_[0].value.as < std::shared_ptr<resolvable> > ()); }
1131     break;
1132 
1133   case 23: // directive: ".out" value direction autop threshold
1134                                             { pioasm.get_current_program(yystack_[4].location, ".out", true).set_out(yylhs.location, yystack_[3].value.as < std::shared_ptr<resolvable> > (), yystack_[2].value.as < bool > (), yystack_[1].value.as < bool > (), yystack_[0].value.as < std::shared_ptr<resolvable> > ()); }
1135     break;
1136 
1137   case 24: // directive: ".set" value
1138                                       { pioasm.get_current_program(yystack_[1].location, ".set", true).set_set_count(yylhs.location, yystack_[0].value.as < std::shared_ptr<resolvable> > ()); }
1139     break;
1140 
1141   case 25: // directive: ".wrap_target"
1142                                       { pioasm.get_current_program(yystack_[0].location, ".wrap_target").set_wrap_target(yylhs.location); }
1143     break;
1144 
1145   case 26: // directive: ".wrap"
1146                                       { pioasm.get_current_program(yystack_[0].location, ".wrap").set_wrap(yylhs.location); }
1147     break;
1148 
1149   case 27: // directive: ".word" value
1150                                       { pioasm.get_current_program(yystack_[1].location, "instruction").add_instruction(std::shared_ptr<instruction>(new instr_word(yylhs.location, yystack_[0].value.as < std::shared_ptr<resolvable> > ()))); }
1151     break;
1152 
1153   case 28: // directive: ".lang_opt" "text" "text" "=" "integer"
1154                                        { pioasm.get_current_program(yystack_[4].location, ".lang_opt").add_lang_opt(yystack_[3].value.as < std::string > (), yystack_[2].value.as < std::string > (), std::to_string(yystack_[0].value.as < int > ())); }
1155     break;
1156 
1157   case 29: // directive: ".lang_opt" "text" "text" "=" "string"
1158                                          { pioasm.get_current_program(yystack_[4].location, ".lang_opt").add_lang_opt(yystack_[3].value.as < std::string > (), yystack_[2].value.as < std::string > (), yystack_[0].value.as < std::string > ()); }
1159     break;
1160 
1161   case 30: // directive: ".lang_opt" "text" "text" "=" "text"
1162                                          { pioasm.get_current_program(yystack_[4].location, ".lang_opt").add_lang_opt(yystack_[3].value.as < std::string > (), yystack_[2].value.as < std::string > (), yystack_[0].value.as < std::string > ()); }
1163     break;
1164 
1165   case 31: // directive: ".lang_opt" error
1166                                       { error(yylhs.location, "expected format is .lang_opt language option_name = option_value"); }
1167     break;
1168 
1169   case 32: // directive: ".clock_div" "integer"
1170                                       { pioasm.get_current_program(yystack_[1].location, ".clock_div").set_clock_div(yylhs.location, yystack_[0].value.as < int > ()); }
1171     break;
1172 
1173   case 33: // directive: ".clock_div" "float"
1174                                       { pioasm.get_current_program(yystack_[1].location, ".clock_div").set_clock_div(yylhs.location, yystack_[0].value.as < float > ()); }
1175     break;
1176 
1177   case 34: // directive: ".fifo" fifo_config
1178                                       { pioasm.get_current_program(yystack_[1].location, ".fifo", true).set_fifo_config(yylhs.location, yystack_[0].value.as < enum fifo_config > ()); }
1179     break;
1180 
1181   case 35: // directive: ".mov_status" "txfifo" "<" value
1182                                       { pioasm.get_current_program(yystack_[3].location, ".mov_status", true).set_mov_status(mov_status_type::tx_lessthan, yystack_[0].value.as < std::shared_ptr<resolvable> > ()); }
1183     break;
1184 
1185   case 36: // directive: ".mov_status" "rxfifo" "<" value
1186                                       { pioasm.get_current_program(yystack_[3].location, ".mov_status", true).set_mov_status(mov_status_type::rx_lessthan, yystack_[0].value.as < std::shared_ptr<resolvable> > ()); }
1187     break;
1188 
1189   case 37: // directive: ".mov_status" "irq" "next" "set" value
1190                                            { pioasm.get_current_program(yystack_[4].location, ".mov_status", true).set_mov_status(mov_status_type::irq_set, yystack_[0].value.as < std::shared_ptr<resolvable> > (), 2); }
1191     break;
1192 
1193   case 38: // directive: ".mov_status" "irq" "prev" "set" value
1194                                            { pioasm.get_current_program(yystack_[4].location, ".mov_status", true).set_mov_status(mov_status_type::irq_set, yystack_[0].value.as < std::shared_ptr<resolvable> > (), 1); }
1195     break;
1196 
1197   case 39: // directive: ".mov_status" "irq" "set" value
1198                                       { pioasm.get_current_program(yystack_[3].location, ".mov_status", true).set_mov_status(mov_status_type::irq_set, yystack_[0].value.as < std::shared_ptr<resolvable> > ()); }
1199     break;
1200 
1201   case 40: // directive: ".mov_status"
1202                                       { error(yystack_[1].location, "expected 'txfifo < N', 'rxfifo < N' or 'irq set N'"); }
1203     break;
1204 
1205   case 41: // directive: UNKNOWN_DIRECTIVE
1206                                       { std::stringstream msg; msg << "unknown directive " << yystack_[0].value.as < std::string > (); throw syntax_error(yylhs.location, msg.str()); }
1207     break;
1208 
1209   case 42: // value: "integer"
1210            { yylhs.value.as < std::shared_ptr<resolvable> > () = resolvable_int(yylhs.location, yystack_[0].value.as < int > ()); }
1211     break;
1212 
1213   case 43: // value: "identifier"
1214           { yylhs.value.as < std::shared_ptr<resolvable> > () = std::shared_ptr<resolvable>(new name_ref(yylhs.location, yystack_[0].value.as < std::string > ())); }
1215     break;
1216 
1217   case 44: // value: "(" expression ")"
1218                                 { yylhs.value.as < std::shared_ptr<resolvable> > () = yystack_[1].value.as < std::shared_ptr<resolvable> > (); }
1219     break;
1220 
1221   case 45: // expression: value
1222      { yylhs.value.as < std::shared_ptr<resolvable> > () = yystack_[0].value.as < std::shared_ptr<resolvable> > (); }
1223     break;
1224 
1225   case 46: // expression: expression "+" expression
1226                                   { yylhs.value.as < std::shared_ptr<resolvable> > () = std::shared_ptr<binary_operation>(new binary_operation(yylhs.location, binary_operation::add, yystack_[2].value.as < std::shared_ptr<resolvable> > (), yystack_[0].value.as < std::shared_ptr<resolvable> > ())); }
1227     break;
1228 
1229   case 47: // expression: expression "-" expression
1230                                    { yylhs.value.as < std::shared_ptr<resolvable> > () = std::shared_ptr<binary_operation>(new binary_operation(yylhs.location, binary_operation::subtract, yystack_[2].value.as < std::shared_ptr<resolvable> > (), yystack_[0].value.as < std::shared_ptr<resolvable> > ())); }
1231     break;
1232 
1233   case 48: // expression: expression "*" expression
1234                                       { yylhs.value.as < std::shared_ptr<resolvable> > () = std::shared_ptr<binary_operation>(new binary_operation(yylhs.location, binary_operation::multiply, yystack_[2].value.as < std::shared_ptr<resolvable> > (), yystack_[0].value.as < std::shared_ptr<resolvable> > ()));  }
1235     break;
1236 
1237   case 49: // expression: expression "/" expression
1238                                     { yylhs.value.as < std::shared_ptr<resolvable> > () = std::shared_ptr<binary_operation>(new binary_operation(yylhs.location, binary_operation::divide, yystack_[2].value.as < std::shared_ptr<resolvable> > (), yystack_[0].value.as < std::shared_ptr<resolvable> > ())); }
1239     break;
1240 
1241   case 50: // expression: expression "|" expression
1242                                 { yylhs.value.as < std::shared_ptr<resolvable> > () = std::shared_ptr<binary_operation>(new binary_operation(yylhs.location, binary_operation::or_, yystack_[2].value.as < std::shared_ptr<resolvable> > (), yystack_[0].value.as < std::shared_ptr<resolvable> > ())); }
1243     break;
1244 
1245   case 51: // expression: expression "&" expression
1246                                  { yylhs.value.as < std::shared_ptr<resolvable> > () = std::shared_ptr<binary_operation>(new binary_operation(yylhs.location, binary_operation::and_, yystack_[2].value.as < std::shared_ptr<resolvable> > (), yystack_[0].value.as < std::shared_ptr<resolvable> > ())); }
1247     break;
1248 
1249   case 52: // expression: expression "^" expression
1250                                  { yylhs.value.as < std::shared_ptr<resolvable> > () = std::shared_ptr<binary_operation>(new binary_operation(yylhs.location, binary_operation::xor_, yystack_[2].value.as < std::shared_ptr<resolvable> > (), yystack_[0].value.as < std::shared_ptr<resolvable> > ())); }
1251     break;
1252 
1253   case 53: // expression: expression "<<" expression
1254                                  { yylhs.value.as < std::shared_ptr<resolvable> > () = std::shared_ptr<binary_operation>(new binary_operation(yylhs.location, binary_operation::shl_, yystack_[2].value.as < std::shared_ptr<resolvable> > (), yystack_[0].value.as < std::shared_ptr<resolvable> > ())); }
1255     break;
1256 
1257   case 54: // expression: expression ">>" expression
1258                                  { yylhs.value.as < std::shared_ptr<resolvable> > () = std::shared_ptr<binary_operation>(new binary_operation(yylhs.location, binary_operation::shr_, yystack_[2].value.as < std::shared_ptr<resolvable> > (), yystack_[0].value.as < std::shared_ptr<resolvable> > ())); }
1259     break;
1260 
1261   case 55: // expression: "-" expression
1262                         { yylhs.value.as < std::shared_ptr<resolvable> > () = std::shared_ptr<unary_operation>(new unary_operation(yylhs.location, unary_operation::negate, yystack_[0].value.as < std::shared_ptr<resolvable> > ())); }
1263     break;
1264 
1265   case 56: // expression: "::" expression
1266                           { yylhs.value.as < std::shared_ptr<resolvable> > () = std::shared_ptr<unary_operation>(new unary_operation(yylhs.location, unary_operation::reverse, yystack_[0].value.as < std::shared_ptr<resolvable> > ())); }
1267     break;
1268 
1269   case 57: // pio_version: "integer"
1270                  { yylhs.value.as < uint > () = yystack_[0].value.as < int > (); }
1271     break;
1272 
1273   case 58: // pio_version: "rp2040"
1274               { yylhs.value.as < uint > () = 0; }
1275     break;
1276 
1277   case 59: // pio_version: "rp2350"
1278               { yylhs.value.as < uint > () = 1; }
1279     break;
1280 
1281   case 60: // instruction: base_instruction sideset delay
1282                                    { yylhs.value.as < std::shared_ptr<instruction> > () = yystack_[2].value.as < std::shared_ptr<instruction> > (); yylhs.value.as < std::shared_ptr<instruction> > ()->sideset = yystack_[1].value.as < std::shared_ptr<resolvable> > (); yylhs.value.as < std::shared_ptr<instruction> > ()->delay = yystack_[0].value.as < std::shared_ptr<resolvable> > (); }
1283     break;
1284 
1285   case 61: // instruction: base_instruction delay sideset
1286                                    { yylhs.value.as < std::shared_ptr<instruction> > () = yystack_[2].value.as < std::shared_ptr<instruction> > (); yylhs.value.as < std::shared_ptr<instruction> > ()->delay = yystack_[1].value.as < std::shared_ptr<resolvable> > (); yylhs.value.as < std::shared_ptr<instruction> > ()->sideset = yystack_[0].value.as < std::shared_ptr<resolvable> > (); }
1287     break;
1288 
1289   case 62: // instruction: base_instruction sideset
1290                              { yylhs.value.as < std::shared_ptr<instruction> > () = yystack_[1].value.as < std::shared_ptr<instruction> > (); yylhs.value.as < std::shared_ptr<instruction> > ()->sideset = yystack_[0].value.as < std::shared_ptr<resolvable> > (); yylhs.value.as < std::shared_ptr<instruction> > ()->delay = resolvable_int(yylhs.location, 0); }
1291     break;
1292 
1293   case 63: // instruction: base_instruction delay
1294                            { yylhs.value.as < std::shared_ptr<instruction> > () = yystack_[1].value.as < std::shared_ptr<instruction> > (); yylhs.value.as < std::shared_ptr<instruction> > ()->delay = yystack_[0].value.as < std::shared_ptr<resolvable> > (); }
1295     break;
1296 
1297   case 64: // instruction: base_instruction
1298                      { yylhs.value.as < std::shared_ptr<instruction> > () = yystack_[0].value.as < std::shared_ptr<instruction> > (); yylhs.value.as < std::shared_ptr<instruction> > ()->delay = resolvable_int(yylhs.location, 0); }
1299     break;
1300 
1301   case 65: // base_instruction: "nop"
1302                                                           { yylhs.value.as < std::shared_ptr<instruction> > () = std::shared_ptr<instruction>(new instr_nop(yylhs.location)); }
1303     break;
1304 
1305   case 66: // base_instruction: "jmp" condition comma expression
1306                                                           { yylhs.value.as < std::shared_ptr<instruction> > () = std::shared_ptr<instruction>(new instr_jmp(yylhs.location, yystack_[2].value.as < enum condition > (), yystack_[0].value.as < std::shared_ptr<resolvable> > ())); }
1307     break;
1308 
1309   case 67: // base_instruction: "wait" value wait_source
1310                                                           { yylhs.value.as < std::shared_ptr<instruction> > () = std::shared_ptr<instruction>(new instr_wait(yylhs.location, yystack_[1].value.as < std::shared_ptr<resolvable> > (), yystack_[0].value.as < std::shared_ptr<wait_source> > ())); }
1311     break;
1312 
1313   case 68: // base_instruction: "wait" wait_source
1314                                                           { yylhs.value.as < std::shared_ptr<instruction> > () = std::shared_ptr<instruction>(new instr_wait(yylhs.location, resolvable_int(yylhs.location, 1),  yystack_[0].value.as < std::shared_ptr<wait_source> > ())); }
1315     break;
1316 
1317   case 69: // base_instruction: "in" in_source comma value
1318                                                           { yylhs.value.as < std::shared_ptr<instruction> > () = std::shared_ptr<instruction>(new instr_in(yylhs.location, yystack_[2].value.as < enum in_out_set > (), yystack_[0].value.as < std::shared_ptr<resolvable> > ())); }
1319     break;
1320 
1321   case 70: // base_instruction: "out" out_target comma value
1322                                                           { yylhs.value.as < std::shared_ptr<instruction> > () = std::shared_ptr<instruction>(new instr_out(yylhs.location, yystack_[2].value.as < enum in_out_set > (), yystack_[0].value.as < std::shared_ptr<resolvable> > ())); }
1323     break;
1324 
1325   case 71: // base_instruction: "push" if_full blocking
1326                                                           { yylhs.value.as < std::shared_ptr<instruction> > () = std::shared_ptr<instruction>(new instr_push(yylhs.location, yystack_[1].value.as < bool > (), yystack_[0].value.as < bool > ())); }
1327     break;
1328 
1329   case 72: // base_instruction: "pull" if_empty blocking
1330                                                           { yylhs.value.as < std::shared_ptr<instruction> > () = std::shared_ptr<instruction>(new instr_pull(yylhs.location, yystack_[1].value.as < bool > (), yystack_[0].value.as < bool > ())); }
1331     break;
1332 
1333   case 73: // base_instruction: "mov" mov_target comma mov_op mov_source
1334                                                           { yylhs.value.as < std::shared_ptr<instruction> > () = std::shared_ptr<instruction>(new instr_mov(yylhs.location, yystack_[3].value.as < extended_mov > (), yystack_[0].value.as < extended_mov > (), yystack_[1].value.as < enum mov_op > ())); }
1335     break;
1336 
1337   case 74: // base_instruction: "irq" irq_modifiers value "rel"
1338                                                           { yylhs.value.as < std::shared_ptr<instruction> > () = std::shared_ptr<instruction>(new instr_irq(yylhs.location, yystack_[2].value.as < enum irq > (), yystack_[1].value.as < std::shared_ptr<resolvable> > (), 2)); }
1339     break;
1340 
1341   case 75: // base_instruction: "irq" "prev" irq_modifiers value
1342                                                           { pioasm.check_version(1, yylhs.location, "irq prev"); yylhs.value.as < std::shared_ptr<instruction> > () = std::shared_ptr<instruction>(new instr_irq(yylhs.location, yystack_[1].value.as < enum irq > (), yystack_[0].value.as < std::shared_ptr<resolvable> > (), 1)); }
1343     break;
1344 
1345   case 76: // base_instruction: "irq" "next" irq_modifiers value
1346                                                           { pioasm.check_version(1, yylhs.location, "irq next"); yylhs.value.as < std::shared_ptr<instruction> > () = std::shared_ptr<instruction>(new instr_irq(yylhs.location, yystack_[1].value.as < enum irq > (), yystack_[0].value.as < std::shared_ptr<resolvable> > (), 3)); }
1347     break;
1348 
1349   case 77: // base_instruction: "irq" "prev" irq_modifiers value "rel"
1350                                                           { pioasm.check_version(1, yylhs.location, "irq prev"); error(yystack_[0].location, "'rel' is not supported for 'irq prev'"); }
1351     break;
1352 
1353   case 78: // base_instruction: "irq" "next" irq_modifiers value "rel"
1354                                                           { pioasm.check_version(1, yylhs.location, "irq next"); error(yystack_[0].location, "'rel' is not supported for 'irq next'"); }
1355     break;
1356 
1357   case 79: // base_instruction: "irq" irq_modifiers value
1358                                                           { yylhs.value.as < std::shared_ptr<instruction> > () = std::shared_ptr<instruction>(new instr_irq(yylhs.location, yystack_[1].value.as < enum irq > (), yystack_[0].value.as < std::shared_ptr<resolvable> > ())); }
1359     break;
1360 
1361   case 80: // base_instruction: "set" set_target comma value
1362                                                           { yylhs.value.as < std::shared_ptr<instruction> > () = std::shared_ptr<instruction>(new instr_set(yylhs.location, yystack_[2].value.as < enum in_out_set > (), yystack_[0].value.as < std::shared_ptr<resolvable> > ())); }
1363     break;
1364 
1365   case 81: // delay: "[" expression "]"
1366                                  { yylhs.value.as < std::shared_ptr<resolvable> > () = yystack_[1].value.as < std::shared_ptr<resolvable> > (); }
1367     break;
1368 
1369   case 82: // sideset: "side" value
1370                { yylhs.value.as < std::shared_ptr<resolvable> > () = yystack_[0].value.as < std::shared_ptr<resolvable> > (); }
1371     break;
1372 
1373   case 83: // condition: "!" "x"
1374                             { yylhs.value.as < enum condition > () = condition::xz; }
1375     break;
1376 
1377   case 84: // condition: "x" "--"
1378                             { yylhs.value.as < enum condition > () = condition::xnz__; }
1379     break;
1380 
1381   case 85: // condition: "!" "y"
1382                             { yylhs.value.as < enum condition > () = condition::yz; }
1383     break;
1384 
1385   case 86: // condition: "y" "--"
1386                             { yylhs.value.as < enum condition > () = condition::ynz__; }
1387     break;
1388 
1389   case 87: // condition: "x" "!=" "y"
1390                             { yylhs.value.as < enum condition > () = condition::xney; }
1391     break;
1392 
1393   case 88: // condition: "pin"
1394                             { yylhs.value.as < enum condition > () = condition::pin; }
1395     break;
1396 
1397   case 89: // condition: "!" "osre"
1398                             { yylhs.value.as < enum condition > () = condition::osrez; }
1399     break;
1400 
1401   case 90: // condition: %empty
1402                             { yylhs.value.as < enum condition > () = condition::al; }
1403     break;
1404 
1405   case 91: // wait_source: "irq" comma value "rel"
1406                             { yylhs.value.as < std::shared_ptr<wait_source> > () = std::shared_ptr<wait_source>(new wait_source(wait_source::irq, yystack_[1].value.as < std::shared_ptr<resolvable> > (), 2)); }
1407     break;
1408 
1409   case 92: // wait_source: "irq" "prev" comma value
1410                             { pioasm.check_version(1, yylhs.location, "irq prev"); yylhs.value.as < std::shared_ptr<wait_source> > () = std::shared_ptr<wait_source>(new wait_source(wait_source::irq, yystack_[0].value.as < std::shared_ptr<resolvable> > (), 1)); }
1411     break;
1412 
1413   case 93: // wait_source: "irq" "next" comma value
1414                             { pioasm.check_version(1, yylhs.location, "irq next"); yylhs.value.as < std::shared_ptr<wait_source> > () = std::shared_ptr<wait_source>(new wait_source(wait_source::irq, yystack_[0].value.as < std::shared_ptr<resolvable> > (), 3)); }
1415     break;
1416 
1417   case 94: // wait_source: "irq" "prev" comma value "rel"
1418                              { pioasm.check_version(1, yylhs.location, "irq prev"); error(yystack_[0].location, "'rel' is not supported for 'irq prev'"); }
1419     break;
1420 
1421   case 95: // wait_source: "irq" "next" comma value "rel"
1422                              { pioasm.check_version(1, yylhs.location, "irq next"); error(yystack_[0].location, "'rel' is not supported for 'irq next'"); }
1423     break;
1424 
1425   case 96: // wait_source: "irq" comma value
1426                             { yylhs.value.as < std::shared_ptr<wait_source> > () = std::shared_ptr<wait_source>(new wait_source(wait_source::irq, yystack_[0].value.as < std::shared_ptr<resolvable> > (), 0)); }
1427     break;
1428 
1429   case 97: // wait_source: "gpio" comma value
1430                             { yylhs.value.as < std::shared_ptr<wait_source> > () = std::shared_ptr<wait_source>(new wait_source(wait_source::gpio, yystack_[0].value.as < std::shared_ptr<resolvable> > ())); }
1431     break;
1432 
1433   case 98: // wait_source: "pin" comma value
1434                             { yylhs.value.as < std::shared_ptr<wait_source> > () = std::shared_ptr<wait_source>(new wait_source(wait_source::pin, yystack_[0].value.as < std::shared_ptr<resolvable> > ())); }
1435     break;
1436 
1437   case 99: // wait_source: "jmppin"
1438                             { pioasm.check_version(1, yylhs.location, "wait jmppin"); yylhs.value.as < std::shared_ptr<wait_source> > () = std::shared_ptr<wait_source>(new wait_source(wait_source::jmppin, std::make_shared<int_value>(yylhs.location, 0))); }
1439     break;
1440 
1441   case 100: // wait_source: "jmppin" "+" value
1442                             { pioasm.check_version(1, yylhs.location, "wait jmppin"); yylhs.value.as < std::shared_ptr<wait_source> > () = std::shared_ptr<wait_source>(new wait_source(wait_source::jmppin, yystack_[0].value.as < std::shared_ptr<resolvable> > ())); }
1443     break;
1444 
1445   case 101: // wait_source: %empty
1446                             { error(yystack_[0].location, pioasm.version_string(1, "expected irq, gpio, pin or jmp_pin", "expected irq, gpio or pin")); }
1447     break;
1448 
1449   case 102: // fifo_config: "txrx"
1450                   { yylhs.value.as < enum fifo_config > () = fifo_config::txrx; }
1451     break;
1452 
1453   case 103: // fifo_config: "tx"
1454                 { yylhs.value.as < enum fifo_config > () = fifo_config::tx; }
1455     break;
1456 
1457   case 104: // fifo_config: "rx"
1458                 { yylhs.value.as < enum fifo_config > () = fifo_config::rx; }
1459     break;
1460 
1461   case 105: // fifo_config: "txput"
1462                 { pioasm.check_version(1, yylhs.location, "txput"); yylhs.value.as < enum fifo_config > () = fifo_config::txput; }
1463     break;
1464 
1465   case 106: // fifo_config: "txget"
1466                 { pioasm.check_version(1, yylhs.location, "rxput"); yylhs.value.as < enum fifo_config > () = fifo_config::txget; }
1467     break;
1468 
1469   case 107: // fifo_config: "putget"
1470                 { pioasm.check_version(1, yylhs.location, "putget"); yylhs.value.as < enum fifo_config > () = fifo_config::putget; }
1471     break;
1472 
1473   case 108: // fifo_config: %empty
1474                 { error(yystack_[0].location, pioasm.version_string(1, "expected txrx, tx, rx, txput, rxget or putget", "expected txrx, tx or rx")); }
1475     break;
1476 
1477   case 111: // in_source: "pins"
1478                 { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_set_pins; }
1479     break;
1480 
1481   case 112: // in_source: "x"
1482                 { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_set_x; }
1483     break;
1484 
1485   case 113: // in_source: "y"
1486                 { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_set_y; }
1487     break;
1488 
1489   case 114: // in_source: "null"
1490                 { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_null; }
1491     break;
1492 
1493   case 115: // in_source: "isr"
1494                 { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_isr; }
1495     break;
1496 
1497   case 116: // in_source: "osr"
1498                 { yylhs.value.as < enum in_out_set > () = in_out_set::in_osr; }
1499     break;
1500 
1501   case 117: // in_source: "status"
1502                 { yylhs.value.as < enum in_out_set > () = in_out_set::in_status; }
1503     break;
1504 
1505   case 118: // out_target: "pins"
1506                  { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_set_pins; }
1507     break;
1508 
1509   case 119: // out_target: "x"
1510                  { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_set_x; }
1511     break;
1512 
1513   case 120: // out_target: "y"
1514                  { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_set_y; }
1515     break;
1516 
1517   case 121: // out_target: "null"
1518                  { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_null; }
1519     break;
1520 
1521   case 122: // out_target: "pindirs"
1522                  { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_set_pindirs; }
1523     break;
1524 
1525   case 123: // out_target: "isr"
1526                  { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_isr; }
1527     break;
1528 
1529   case 124: // out_target: "pc"
1530                  { yylhs.value.as < enum in_out_set > () = in_out_set::out_set_pc; }
1531     break;
1532 
1533   case 125: // out_target: "exec"
1534                  { yylhs.value.as < enum in_out_set > () = in_out_set::out_exec; }
1535     break;
1536 
1537   case 126: // mov_target: "pins"
1538                  { yylhs.value.as < extended_mov > () = mov::pins; }
1539     break;
1540 
1541   case 127: // mov_target: "x"
1542                  { yylhs.value.as < extended_mov > () = mov::x; }
1543     break;
1544 
1545   case 128: // mov_target: "y"
1546                  { yylhs.value.as < extended_mov > () = mov::y; }
1547     break;
1548 
1549   case 129: // mov_target: "exec"
1550                  { yylhs.value.as < extended_mov > () = mov::exec; }
1551     break;
1552 
1553   case 130: // mov_target: "pc"
1554                  { yylhs.value.as < extended_mov > () = mov::pc; }
1555     break;
1556 
1557   case 131: // mov_target: "isr"
1558                  { yylhs.value.as < extended_mov > () = mov::isr; }
1559     break;
1560 
1561   case 132: // mov_target: "osr"
1562                  { yylhs.value.as < extended_mov > () = mov::osr; }
1563     break;
1564 
1565   case 133: // mov_target: "pindirs"
1566                  { pioasm.check_version(1, yylhs.location, "mov pindirs"); yylhs.value.as < extended_mov > () = mov::pindirs; }
1567     break;
1568 
1569   case 134: // mov_target: "rxfifo" "[" "y" "]"
1570                                  { pioasm.check_version(1, yylhs.location, "mov rxfifo[], "); yylhs.value.as < extended_mov > () = mov::fifo_y; }
1571     break;
1572 
1573   case 135: // mov_target: "rxfifo" "[" value "]"
1574                                      { pioasm.check_version(1, yylhs.location, "mov rxfifo[], "); yylhs.value.as < extended_mov > () = extended_mov(yystack_[1].value.as < std::shared_ptr<resolvable> > ()); }
1575     break;
1576 
1577   case 136: // mov_source: "pins"
1578                  { yylhs.value.as < extended_mov > () = mov::pins; }
1579     break;
1580 
1581   case 137: // mov_source: "x"
1582                  { yylhs.value.as < extended_mov > () = mov::x; }
1583     break;
1584 
1585   case 138: // mov_source: "y"
1586                  { yylhs.value.as < extended_mov > () = mov::y; }
1587     break;
1588 
1589   case 139: // mov_source: "null"
1590                  { yylhs.value.as < extended_mov > () = mov::null; }
1591     break;
1592 
1593   case 140: // mov_source: "status"
1594                  { yylhs.value.as < extended_mov > () = mov::status; }
1595     break;
1596 
1597   case 141: // mov_source: "isr"
1598                  { yylhs.value.as < extended_mov > () = mov::isr; }
1599     break;
1600 
1601   case 142: // mov_source: "osr"
1602                  { yylhs.value.as < extended_mov > () = mov::osr; }
1603     break;
1604 
1605   case 143: // mov_source: "rxfifo" "[" "y" "]"
1606                                  { pioasm.check_version(1, yylhs.location, "mov rxfifo[], "); yylhs.value.as < extended_mov > () = mov::fifo_y; }
1607     break;
1608 
1609   case 144: // mov_source: "rxfifo" "[" value "]"
1610                                      { pioasm.check_version(1, yylhs.location, "mov rxfifo[], "); yylhs.value.as < extended_mov > () = extended_mov(yystack_[1].value.as < std::shared_ptr<resolvable> > ()); }
1611     break;
1612 
1613   case 145: // mov_op: "!"
1614                 { yylhs.value.as < enum mov_op > () = mov_op::invert; }
1615     break;
1616 
1617   case 146: // mov_op: "::"
1618                 { yylhs.value.as < enum mov_op > () = mov_op::bit_reverse; }
1619     break;
1620 
1621   case 147: // mov_op: %empty
1622                 { yylhs.value.as < enum mov_op > () = mov_op::none; }
1623     break;
1624 
1625   case 148: // set_target: "pins"
1626                 { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_set_pins; }
1627     break;
1628 
1629   case 149: // set_target: "x"
1630                 { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_set_x; }
1631     break;
1632 
1633   case 150: // set_target: "y"
1634                 { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_set_y; }
1635     break;
1636 
1637   case 151: // set_target: "pindirs"
1638                 { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_set_pindirs; }
1639     break;
1640 
1641   case 152: // direction: "left"
1642          { yylhs.value.as < bool > () = false; }
1643     break;
1644 
1645   case 153: // direction: "right"
1646           { yylhs.value.as < bool > () = true; }
1647     break;
1648 
1649   case 154: // direction: %empty
1650            { yylhs.value.as < bool > () = true; }
1651     break;
1652 
1653   case 155: // autop: "auto"
1654          { yylhs.value.as < bool > () = true; }
1655     break;
1656 
1657   case 156: // autop: "manual"
1658            { yylhs.value.as < bool > () = false; }
1659     break;
1660 
1661   case 157: // autop: %empty
1662            { yylhs.value.as < bool > () = false; }
1663     break;
1664 
1665   case 158: // threshold: value
1666                  { yylhs.value.as < std::shared_ptr<resolvable> > () = yystack_[0].value.as < std::shared_ptr<resolvable> > (); }
1667     break;
1668 
1669   case 159: // threshold: %empty
1670            { yylhs.value.as < std::shared_ptr<resolvable> > () = resolvable_int(yylhs.location, 32); }
1671     break;
1672 
1673   case 160: // if_full: "iffull"
1674            { yylhs.value.as < bool > () = true; }
1675     break;
1676 
1677   case 161: // if_full: %empty
1678            { yylhs.value.as < bool > () = false; }
1679     break;
1680 
1681   case 162: // if_empty: "ifempty"
1682             { yylhs.value.as < bool > () = true; }
1683     break;
1684 
1685   case 163: // if_empty: %empty
1686             { yylhs.value.as < bool > () = false; }
1687     break;
1688 
1689   case 164: // blocking: "block"
1690             { yylhs.value.as < bool > () = true; }
1691     break;
1692 
1693   case 165: // blocking: "noblock"
1694             { yylhs.value.as < bool > () = false; }
1695     break;
1696 
1697   case 166: // blocking: %empty
1698             { yylhs.value.as < bool > () = true; }
1699     break;
1700 
1701   case 167: // irq_modifiers: "clear"
1702                    { yylhs.value.as < enum irq > () = irq::clear; }
1703     break;
1704 
1705   case 168: // irq_modifiers: "wait"
1706                    { yylhs.value.as < enum irq > () = irq::set_wait; }
1707     break;
1708 
1709   case 169: // irq_modifiers: "nowait"
1710                    { yylhs.value.as < enum irq > () = irq::set; }
1711     break;
1712 
1713   case 170: // irq_modifiers: "set"
1714                    { yylhs.value.as < enum irq > () = irq::set; }
1715     break;
1716 
1717   case 171: // irq_modifiers: %empty
1718                    { yylhs.value.as < enum irq > () = irq::set; }
1719     break;
1720 
1721   case 172: // symbol_def: "identifier"
1722                     { yylhs.value.as < std::shared_ptr<symbol> > () = std::shared_ptr<symbol>(new symbol(yylhs.location, yystack_[0].value.as < std::string > ())); }
1723     break;
1724 
1725   case 173: // symbol_def: "public" "identifier"
1726                     { yylhs.value.as < std::shared_ptr<symbol> > () = std::shared_ptr<symbol>(new symbol(yylhs.location, yystack_[0].value.as < std::string > (), true)); }
1727     break;
1728 
1729   case 174: // symbol_def: "*" "identifier"
1730                     { yylhs.value.as < std::shared_ptr<symbol> > () = std::shared_ptr<symbol>(new symbol(yylhs.location, yystack_[0].value.as < std::string > (), true)); }
1731     break;
1732 
1733 
1734 
1735             default:
1736               break;
1737             }
1738         }
1739 #if YY_EXCEPTIONS
1740       catch (const syntax_error& yyexc)
1741         {
1742           YYCDEBUG << "Caught exception: " << yyexc.what() << '\n';
1743           error (yyexc);
1744           YYERROR;
1745         }
1746 #endif // YY_EXCEPTIONS
1747       YY_SYMBOL_PRINT ("-> $$ =", yylhs);
1748       yypop_ (yylen);
1749       yylen = 0;
1750 
1751       // Shift the result of the reduction.
1752       yypush_ (YY_NULLPTR, YY_MOVE (yylhs));
1753     }
1754     goto yynewstate;
1755 
1756 
1757   /*--------------------------------------.
1758   | yyerrlab -- here on detecting error.  |
1759   `--------------------------------------*/
1760   yyerrlab:
1761     // If not already recovering from an error, report this error.
1762     if (!yyerrstatus_)
1763       {
1764         ++yynerrs_;
1765         context yyctx (*this, yyla);
1766         std::string msg = yysyntax_error_ (yyctx);
1767         error (yyla.location, YY_MOVE (msg));
1768       }
1769 
1770 
1771     yyerror_range[1].location = yyla.location;
1772     if (yyerrstatus_ == 3)
1773       {
1774         /* If just tried and failed to reuse lookahead token after an
1775            error, discard it.  */
1776 
1777         // Return failure if at end of input.
1778         if (yyla.kind () == symbol_kind::S_YYEOF)
1779           YYABORT;
1780         else if (!yyla.empty ())
1781           {
1782             yy_destroy_ ("Error: discarding", yyla);
1783             yyla.clear ();
1784           }
1785       }
1786 
1787     // Else will try to reuse lookahead token after shifting the error token.
1788     goto yyerrlab1;
1789 
1790 
1791   /*---------------------------------------------------.
1792   | yyerrorlab -- error raised explicitly by YYERROR.  |
1793   `---------------------------------------------------*/
1794   yyerrorlab:
1795     /* Pacify compilers when the user code never invokes YYERROR and
1796        the label yyerrorlab therefore never appears in user code.  */
1797     if (false)
1798       YYERROR;
1799 
1800     /* Do not reclaim the symbols of the rule whose action triggered
1801        this YYERROR.  */
1802     yypop_ (yylen);
1803     yylen = 0;
1804     YY_STACK_PRINT ();
1805     goto yyerrlab1;
1806 
1807 
1808   /*-------------------------------------------------------------.
1809   | yyerrlab1 -- common code for both syntax error and YYERROR.  |
1810   `-------------------------------------------------------------*/
1811   yyerrlab1:
1812     yyerrstatus_ = 3;   // Each real token shifted decrements this.
1813     // Pop stack until we find a state that shifts the error token.
1814     for (;;)
1815       {
1816         yyn = yypact_[+yystack_[0].state];
1817         if (!yy_pact_value_is_default_ (yyn))
1818           {
1819             yyn += symbol_kind::S_YYerror;
1820             if (0 <= yyn && yyn <= yylast_
1821                 && yycheck_[yyn] == symbol_kind::S_YYerror)
1822               {
1823                 yyn = yytable_[yyn];
1824                 if (0 < yyn)
1825                   break;
1826               }
1827           }
1828 
1829         // Pop the current state because it cannot handle the error token.
1830         if (yystack_.size () == 1)
1831           YYABORT;
1832 
1833         yyerror_range[1].location = yystack_[0].location;
1834         yy_destroy_ ("Error: popping", yystack_[0]);
1835         yypop_ ();
1836         YY_STACK_PRINT ();
1837       }
1838     {
1839       stack_symbol_type error_token;
1840 
1841       yyerror_range[2].location = yyla.location;
1842       YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);
1843 
1844       // Shift the error token.
1845       yy_lac_discard_ ("error recovery");
1846       error_token.state = state_type (yyn);
1847       yypush_ ("Shifting", YY_MOVE (error_token));
1848     }
1849     goto yynewstate;
1850 
1851 
1852   /*-------------------------------------.
1853   | yyacceptlab -- YYACCEPT comes here.  |
1854   `-------------------------------------*/
1855   yyacceptlab:
1856     yyresult = 0;
1857     goto yyreturn;
1858 
1859 
1860   /*-----------------------------------.
1861   | yyabortlab -- YYABORT comes here.  |
1862   `-----------------------------------*/
1863   yyabortlab:
1864     yyresult = 1;
1865     goto yyreturn;
1866 
1867 
1868   /*-----------------------------------------------------.
1869   | yyreturn -- parsing is finished, return the result.  |
1870   `-----------------------------------------------------*/
1871   yyreturn:
1872     if (!yyla.empty ())
1873       yy_destroy_ ("Cleanup: discarding lookahead", yyla);
1874 
1875     /* Do not reclaim the symbols of the rule whose action triggered
1876        this YYABORT or YYACCEPT.  */
1877     yypop_ (yylen);
1878     YY_STACK_PRINT ();
1879     while (1 < yystack_.size ())
1880       {
1881         yy_destroy_ ("Cleanup: popping", yystack_[0]);
1882         yypop_ ();
1883       }
1884 
1885     return yyresult;
1886   }
1887 #if YY_EXCEPTIONS
1888     catch (...)
1889       {
1890         YYCDEBUG << "Exception caught: cleaning lookahead and stack\n";
1891         // Do not try to display the values of the reclaimed symbols,
1892         // as their printers might throw an exception.
1893         if (!yyla.empty ())
1894           yy_destroy_ (YY_NULLPTR, yyla);
1895 
1896         while (1 < yystack_.size ())
1897           {
1898             yy_destroy_ (YY_NULLPTR, yystack_[0]);
1899             yypop_ ();
1900           }
1901         throw;
1902       }
1903 #endif // YY_EXCEPTIONS
1904   }
1905 
1906   void
error(const syntax_error & yyexc)1907   parser::error (const syntax_error& yyexc)
1908   {
1909     error (yyexc.location, yyexc.what ());
1910   }
1911 
1912   /* Return YYSTR after stripping away unnecessary quotes and
1913      backslashes, so that it's suitable for yyerror.  The heuristic is
1914      that double-quoting is unnecessary unless the string contains an
1915      apostrophe, a comma, or backslash (other than backslash-backslash).
1916      YYSTR is taken from yytname.  */
1917   std::string
yytnamerr_(const char * yystr)1918   parser::yytnamerr_ (const char *yystr)
1919   {
1920     if (*yystr == '"')
1921       {
1922         std::string yyr;
1923         char const *yyp = yystr;
1924 
1925         for (;;)
1926           switch (*++yyp)
1927             {
1928             case '\'':
1929             case ',':
1930               goto do_not_strip_quotes;
1931 
1932             case '\\':
1933               if (*++yyp != '\\')
1934                 goto do_not_strip_quotes;
1935               else
1936                 goto append;
1937 
1938             append:
1939             default:
1940               yyr += *yyp;
1941               break;
1942 
1943             case '"':
1944               return yyr;
1945             }
1946       do_not_strip_quotes: ;
1947       }
1948 
1949     return yystr;
1950   }
1951 
1952   std::string
symbol_name(symbol_kind_type yysymbol)1953   parser::symbol_name (symbol_kind_type yysymbol)
1954   {
1955     return yytnamerr_ (yytname_[yysymbol]);
1956   }
1957 
1958 
1959 
1960   // parser::context.
context(const parser & yyparser,const symbol_type & yyla)1961   parser::context::context (const parser& yyparser, const symbol_type& yyla)
1962     : yyparser_ (yyparser)
1963     , yyla_ (yyla)
1964   {}
1965 
1966   int
expected_tokens(symbol_kind_type yyarg[],int yyargn) const1967   parser::context::expected_tokens (symbol_kind_type yyarg[], int yyargn) const
1968   {
1969     // Actual number of expected tokens
1970     int yycount = 0;
1971 
1972 #if YYDEBUG
1973     // Execute LAC once. We don't care if it is successful, we
1974     // only do it for the sake of debugging output.
1975     if (!yyparser_.yy_lac_established_)
1976       yyparser_.yy_lac_check_ (yyla_.kind ());
1977 #endif
1978 
1979     for (int yyx = 0; yyx < YYNTOKENS; ++yyx)
1980       {
1981         symbol_kind_type yysym = YY_CAST (symbol_kind_type, yyx);
1982         if (yysym != symbol_kind::S_YYerror
1983             && yysym != symbol_kind::S_YYUNDEF
1984             && yyparser_.yy_lac_check_ (yysym))
1985           {
1986             if (!yyarg)
1987               ++yycount;
1988             else if (yycount == yyargn)
1989               return 0;
1990             else
1991               yyarg[yycount++] = yysym;
1992           }
1993       }
1994     if (yyarg && yycount == 0 && 0 < yyargn)
1995       yyarg[0] = symbol_kind::S_YYEMPTY;
1996     return yycount;
1997   }
1998 
1999 
2000   bool
yy_lac_check_(symbol_kind_type yytoken) const2001   parser::yy_lac_check_ (symbol_kind_type yytoken) const
2002   {
2003     // Logically, the yylac_stack's lifetime is confined to this function.
2004     // Clear it, to get rid of potential left-overs from previous call.
2005     yylac_stack_.clear ();
2006     // Reduce until we encounter a shift and thereby accept the token.
2007 #if YYDEBUG
2008     YYCDEBUG << "LAC: checking lookahead " << symbol_name (yytoken) << ':';
2009 #endif
2010     std::ptrdiff_t lac_top = 0;
2011     while (true)
2012       {
2013         state_type top_state = (yylac_stack_.empty ()
2014                                 ? yystack_[lac_top].state
2015                                 : yylac_stack_.back ());
2016         int yyrule = yypact_[+top_state];
2017         if (yy_pact_value_is_default_ (yyrule)
2018             || (yyrule += yytoken) < 0 || yylast_ < yyrule
2019             || yycheck_[yyrule] != yytoken)
2020           {
2021             // Use the default action.
2022             yyrule = yydefact_[+top_state];
2023             if (yyrule == 0)
2024               {
2025                 YYCDEBUG << " Err\n";
2026                 return false;
2027               }
2028           }
2029         else
2030           {
2031             // Use the action from yytable.
2032             yyrule = yytable_[yyrule];
2033             if (yy_table_value_is_error_ (yyrule))
2034               {
2035                 YYCDEBUG << " Err\n";
2036                 return false;
2037               }
2038             if (0 < yyrule)
2039               {
2040                 YYCDEBUG << " S" << yyrule << '\n';
2041                 return true;
2042               }
2043             yyrule = -yyrule;
2044           }
2045         // By now we know we have to simulate a reduce.
2046         YYCDEBUG << " R" << yyrule - 1;
2047         // Pop the corresponding number of values from the stack.
2048         {
2049           std::ptrdiff_t yylen = yyr2_[yyrule];
2050           // First pop from the LAC stack as many tokens as possible.
2051           std::ptrdiff_t lac_size = std::ptrdiff_t (yylac_stack_.size ());
2052           if (yylen < lac_size)
2053             {
2054               yylac_stack_.resize (std::size_t (lac_size - yylen));
2055               yylen = 0;
2056             }
2057           else if (lac_size)
2058             {
2059               yylac_stack_.clear ();
2060               yylen -= lac_size;
2061             }
2062           // Only afterwards look at the main stack.
2063           // We simulate popping elements by incrementing lac_top.
2064           lac_top += yylen;
2065         }
2066         // Keep top_state in sync with the updated stack.
2067         top_state = (yylac_stack_.empty ()
2068                      ? yystack_[lac_top].state
2069                      : yylac_stack_.back ());
2070         // Push the resulting state of the reduction.
2071         state_type state = yy_lr_goto_state_ (top_state, yyr1_[yyrule]);
2072         YYCDEBUG << " G" << int (state);
2073         yylac_stack_.push_back (state);
2074       }
2075   }
2076 
2077   // Establish the initial context if no initial context currently exists.
2078   bool
yy_lac_establish_(symbol_kind_type yytoken)2079   parser::yy_lac_establish_ (symbol_kind_type yytoken)
2080   {
2081     /* Establish the initial context for the current lookahead if no initial
2082        context is currently established.
2083 
2084        We define a context as a snapshot of the parser stacks.  We define
2085        the initial context for a lookahead as the context in which the
2086        parser initially examines that lookahead in order to select a
2087        syntactic action.  Thus, if the lookahead eventually proves
2088        syntactically unacceptable (possibly in a later context reached via a
2089        series of reductions), the initial context can be used to determine
2090        the exact set of tokens that would be syntactically acceptable in the
2091        lookahead's place.  Moreover, it is the context after which any
2092        further semantic actions would be erroneous because they would be
2093        determined by a syntactically unacceptable token.
2094 
2095        yy_lac_establish_ should be invoked when a reduction is about to be
2096        performed in an inconsistent state (which, for the purposes of LAC,
2097        includes consistent states that don't know they're consistent because
2098        their default reductions have been disabled).
2099 
2100        For parse.lac=full, the implementation of yy_lac_establish_ is as
2101        follows.  If no initial context is currently established for the
2102        current lookahead, then check if that lookahead can eventually be
2103        shifted if syntactic actions continue from the current context.  */
2104     if (!yy_lac_established_)
2105       {
2106 #if YYDEBUG
2107         YYCDEBUG << "LAC: initial context established for "
2108                  << symbol_name (yytoken) << '\n';
2109 #endif
2110         yy_lac_established_ = true;
2111         return yy_lac_check_ (yytoken);
2112       }
2113     return true;
2114   }
2115 
2116   // Discard any previous initial lookahead context.
2117   void
yy_lac_discard_(const char * evt)2118   parser::yy_lac_discard_ (const char* evt)
2119   {
2120    /* Discard any previous initial lookahead context because of Event,
2121       which may be a lookahead change or an invalidation of the currently
2122       established initial context for the current lookahead.
2123 
2124       The most common example of a lookahead change is a shift.  An example
2125       of both cases is syntax error recovery.  That is, a syntax error
2126       occurs when the lookahead is syntactically erroneous for the
2127       currently established initial context, so error recovery manipulates
2128       the parser stacks to try to find a new initial context in which the
2129       current lookahead is syntactically acceptable.  If it fails to find
2130       such a context, it discards the lookahead.  */
2131     if (yy_lac_established_)
2132       {
2133         YYCDEBUG << "LAC: initial context discarded due to "
2134                  << evt << '\n';
2135         yy_lac_established_ = false;
2136       }
2137   }
2138 
2139   int
yy_syntax_error_arguments_(const context & yyctx,symbol_kind_type yyarg[],int yyargn) const2140   parser::yy_syntax_error_arguments_ (const context& yyctx,
2141                                                  symbol_kind_type yyarg[], int yyargn) const
2142   {
2143     /* There are many possibilities here to consider:
2144        - If this state is a consistent state with a default action, then
2145          the only way this function was invoked is if the default action
2146          is an error action.  In that case, don't check for expected
2147          tokens because there are none.
2148        - The only way there can be no lookahead present (in yyla) is
2149          if this state is a consistent state with a default action.
2150          Thus, detecting the absence of a lookahead is sufficient to
2151          determine that there is no unexpected or expected token to
2152          report.  In that case, just report a simple "syntax error".
2153        - Don't assume there isn't a lookahead just because this state is
2154          a consistent state with a default action.  There might have
2155          been a previous inconsistent state, consistent state with a
2156          non-default action, or user semantic action that manipulated
2157          yyla.  (However, yyla is currently not documented for users.)
2158          In the first two cases, it might appear that the current syntax
2159          error should have been detected in the previous state when
2160          yy_lac_check was invoked.  However, at that time, there might
2161          have been a different syntax error that discarded a different
2162          initial context during error recovery, leaving behind the
2163          current lookahead.
2164     */
2165 
2166     if (!yyctx.lookahead ().empty ())
2167       {
2168         if (yyarg)
2169           yyarg[0] = yyctx.token ();
2170         int yyn = yyctx.expected_tokens (yyarg ? yyarg + 1 : yyarg, yyargn - 1);
2171         return yyn + 1;
2172       }
2173     return 0;
2174   }
2175 
2176   // Generate an error message.
2177   std::string
yysyntax_error_(const context & yyctx) const2178   parser::yysyntax_error_ (const context& yyctx) const
2179   {
2180     // Its maximum.
2181     enum { YYARGS_MAX = 5 };
2182     // Arguments of yyformat.
2183     symbol_kind_type yyarg[YYARGS_MAX];
2184     int yycount = yy_syntax_error_arguments_ (yyctx, yyarg, YYARGS_MAX);
2185 
2186     char const* yyformat = YY_NULLPTR;
2187     switch (yycount)
2188       {
2189 #define YYCASE_(N, S)                         \
2190         case N:                               \
2191           yyformat = S;                       \
2192         break
2193       default: // Avoid compiler warnings.
2194         YYCASE_ (0, YY_("syntax error"));
2195         YYCASE_ (1, YY_("syntax error, unexpected %s"));
2196         YYCASE_ (2, YY_("syntax error, unexpected %s, expecting %s"));
2197         YYCASE_ (3, YY_("syntax error, unexpected %s, expecting %s or %s"));
2198         YYCASE_ (4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
2199         YYCASE_ (5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
2200 #undef YYCASE_
2201       }
2202 
2203     std::string yyres;
2204     // Argument number.
2205     std::ptrdiff_t yyi = 0;
2206     for (char const* yyp = yyformat; *yyp; ++yyp)
2207       if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
2208         {
2209           yyres += symbol_name (yyarg[yyi++]);
2210           ++yyp;
2211         }
2212       else
2213         yyres += *yyp;
2214     return yyres;
2215   }
2216 
2217 
2218   const signed char parser::yypact_ninf_ = -76;
2219 
2220   const signed char parser::yytable_ninf_ = -12;
2221 
2222   const short
2223   parser::yypact_[] =
2224   {
2225        4,   -76,   -75,   -68,   -76,   -76,    -6,    15,    15,    15,
2226       10,   -10,    27,   203,    35,    15,    15,    15,     6,     8,
2227      141,   163,   -34,    -1,   117,    67,    60,   -76,   -33,   -76,
2228      -32,   -76,    65,    23,   -76,   -76,   206,   -76,   -76,    12,
2229       72,   -76,   -76,    70,    70,   -76,   -76,    -4,   -76,   -76,
2230      -76,    -9,   -76,   -76,   -76,   -76,   -76,   -76,   -76,   -76,
2231      -76,   -76,   -76,   -76,   -76,   -30,    63,    76,   -76,    42,
2232       42,    22,   -76,   119,    74,    87,     9,    87,    87,    96,
2233      129,   -76,   -76,   -76,   -76,   -76,   -76,   -76,   -76,    87,
2234      -76,   -76,   -76,   -76,   -76,   -76,   -76,   -76,    87,   -76,
2235      157,   -76,   157,   -76,   -76,   -76,   -76,   -76,   -76,   -76,
2236      -76,   112,    87,   -76,   -76,    69,    69,   -76,   -76,    15,
2237      -76,   -76,   -76,   -76,    87,   -76,   -76,   -76,   -76,     4,
2238      -76,    70,    15,    90,   137,   -76,    70,    70,   -76,   257,
2239      227,   -76,   107,   145,    15,   123,   126,    15,    15,   -76,
2240      -76,   147,   147,   -76,   -76,   -76,   -76,   110,   -76,   -76,
2241       70,    87,    87,    15,    15,    15,    15,   -76,    15,    15,
2242      -76,   -76,   -76,   -76,    11,   268,    15,    15,   116,    15,
2243      -76,   248,   -76,   -76,   -76,   210,   257,    70,    70,    70,
2244       70,    70,    70,    70,    70,    70,   -76,   -76,   -21,   -76,
2245       15,    15,   -76,   -76,   -76,   -76,    15,    15,   -76,   257,
2246       15,    15,   124,   -76,   -76,   -76,   -76,   -76,   187,   201,
2247      -76,   -76,   135,   149,   153,   -76,   -76,   -76,   210,   210,
2248      120,   120,   -76,   -76,   -76,   266,   266,   -76,   -76,   -76,
2249      -76,   -76,   -76,   -76,   -76,   228,   229,   -76,   -76,   -76,
2250      -76,   -76,   -76,   -76,   -76,   -76,   -76,   287,   -76,   -76,
2251      -76,   -76,   -76,    13,   288,   289,   -76,   -76
2252   };
2253 
2254   const unsigned char
2255   parser::yydefact_[] =
2256   {
2257        0,    12,     0,     0,    25,    26,     0,     0,     0,     0,
2258        0,     0,     0,   108,    40,     0,     0,     0,    90,   101,
2259        0,     0,   161,   163,     0,   171,     0,    65,     0,   172,
2260        0,    41,     0,     0,     3,    10,     9,     6,     7,    64,
2261        0,   174,     5,     0,     0,    43,    42,    21,    27,    16,
2262       31,     0,    58,    59,    57,    17,    32,    33,   102,   103,
2263      104,   105,   106,   107,    34,     0,     0,     0,    24,   154,
2264      154,     0,    88,     0,     0,   110,   110,   110,   110,    99,
2265      101,    68,   111,   114,   112,   113,   115,   116,   117,   110,
2266      118,   121,   122,   119,   120,   125,   124,   123,   110,   160,
2267      166,   162,   166,   126,   133,   127,   128,   129,   130,   131,
2268      132,     0,   110,   168,   170,   171,   171,   169,   167,     0,
2269      148,   151,   149,   150,   110,   173,    13,     1,     2,     0,
2270        8,     0,     0,    63,    62,    14,     0,     0,    45,    15,
2271        0,    20,    19,     0,     0,     0,     0,     0,     0,   152,
2272      153,   157,   157,    89,    83,    85,    84,     0,    86,   109,
2273        0,   110,   110,     0,     0,     0,     0,    67,     0,     0,
2274      164,   165,    71,    72,     0,   147,     0,     0,    79,     0,
2275        4,     0,    82,    61,    60,    55,    56,     0,     0,     0,
2276        0,     0,     0,     0,     0,     0,    44,    18,     0,    39,
2277        0,     0,    36,    35,   155,   156,   159,   159,    87,    66,
2278        0,     0,    96,    98,    97,   100,    69,    70,     0,     0,
2279      145,   146,     0,    75,    76,    74,    80,    81,    46,    47,
2280       48,    49,    50,    51,    52,    53,    54,    29,    30,    28,
2281       38,    37,   158,    23,    22,    92,    93,    91,   134,   135,
2282      136,   139,   137,   138,   141,   142,   140,     0,    73,    77,
2283       78,    94,    95,     0,     0,     0,   143,   144
2284   };
2285 
2286   const short
2287   parser::yypgoto_[] =
2288   {
2289      -76,   -76,   -76,   167,   -76,   -76,   -76,    -7,   -41,   -76,
2290      263,   -76,   166,   168,   -76,   222,   -76,    66,   -76,   -76,
2291      -76,   -76,   -76,   -76,   233,   152,    98,   -76,   -76,   204,
2292      176,   301
2293   };
2294 
2295   const short
2296   parser::yydefgoto_[] =
2297   {
2298       -1,    32,    33,    34,    35,    36,    37,   138,   139,    55,
2299       38,    39,   133,   134,    75,    81,    64,   160,    89,    98,
2300      112,   258,   222,   124,   151,   206,   243,   100,   102,   172,
2301      119,    40
2302   };
2303 
2304   const short
2305   parser::yytable_[] =
2306   {
2307       47,    48,    49,   140,   -11,     1,     2,   -11,    68,    69,
2308       70,    50,    80,   159,    44,    41,     2,    44,   144,    44,
2309      131,    44,    42,   128,   145,   146,   129,    71,    99,     3,
2310        4,     5,     6,     7,     8,     9,    10,    11,    12,    13,
2311       14,    15,    16,    17,    18,    19,    20,    21,    22,    23,
2312       24,    25,    26,    27,   141,    76,    72,   125,    77,    78,
2313      101,    79,   126,   161,   162,   127,    52,    53,   142,    28,
2314      237,   238,    73,    74,   153,   239,    44,   135,   218,    28,
2315      264,   136,    65,   143,    29,   132,    54,   147,   154,   155,
2316      181,   159,   137,   158,    29,   185,   186,    30,    45,    31,
2317      148,    45,    51,    45,    46,    45,   166,    46,   113,    46,
2318      113,    46,   178,    66,    67,   114,   120,   114,   121,   209,
2319      174,   115,   116,    56,    57,   182,   122,   123,   149,   150,
2320      117,   118,   117,   118,   191,   192,   193,   199,   156,   157,
2321      202,   203,   163,   164,   165,   131,   228,   229,   230,   231,
2322      232,   233,   234,   235,   236,   168,   212,   213,   214,   215,
2323       45,   216,   217,   132,   169,   197,    46,   219,   198,   223,
2324      224,   200,   226,   103,   201,   104,    76,   208,   175,    77,
2325       78,   225,    79,   105,   106,   107,   108,   109,   110,   247,
2326      179,   250,   251,   240,   241,   111,   248,    82,    83,   242,
2327      242,   252,   253,   245,   246,   254,   255,    84,    85,   256,
2328      249,    86,    87,   257,   259,    88,   170,   171,   260,    90,
2329       91,    92,   189,   190,   191,   192,   193,   210,   211,    93,
2330       94,    95,    96,    97,   196,   204,   205,   187,   188,   189,
2331      190,   191,   192,   193,   194,   195,    18,    19,    20,    21,
2332       22,    23,    24,    25,    26,    27,   265,   227,   187,   188,
2333      189,   190,   191,   192,   193,   194,   195,   187,   188,   189,
2334      190,   191,   192,   193,   194,   195,   187,   188,   189,   190,
2335      191,   192,   193,    58,    59,    60,    61,    62,    63,   220,
2336      221,   176,   177,   261,   262,   263,   180,   266,   267,   130,
2337      184,   183,   167,   152,   207,   244,   173,    43
2338   };
2339 
2340   const short
2341   parser::yycheck_[] =
2342   {
2343        7,     8,     9,    44,     0,     1,    12,     3,    15,    16,
2344       17,     1,    19,     4,     6,    90,    12,     6,    48,     6,
2345        8,     6,    90,     0,    54,    55,     3,    21,    62,    25,
2346       26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
2347       36,    37,    38,    39,    40,    41,    42,    43,    44,    45,
2348       46,    47,    48,    49,    58,    47,    50,    90,    50,    51,
2349       61,    53,    94,    54,    55,     0,    76,    77,    72,    75,
2350       91,    92,    66,    67,    52,    96,     6,     5,    67,    75,
2351       67,    11,    47,    92,    90,    73,    96,    24,    66,    67,
2352      131,     4,    22,    19,    90,   136,   137,    93,    90,    95,
2353       24,    90,    92,    90,    96,    90,    10,    96,    41,    96,
2354       41,    96,   119,    78,    79,    48,    56,    48,    58,   160,
2355        8,    54,    55,    96,    97,   132,    66,    67,    86,    87,
2356       63,    64,    63,    64,    14,    15,    16,   144,    19,    20,
2357      147,   148,    76,    77,    78,     8,   187,   188,   189,   190,
2358      191,   192,   193,   194,   195,    89,   163,   164,   165,   166,
2359       90,   168,   169,    73,    98,    58,    96,   174,    23,   176,
2360      177,    48,   179,    56,    48,    58,    47,    67,   112,    50,
2361       51,    65,    53,    66,    67,    68,    69,    70,    71,    65,
2362      124,    56,    57,   200,   201,    78,     9,    56,    57,   206,
2363      207,    66,    67,   210,   211,    70,    71,    66,    67,    74,
2364        9,    70,    71,    78,    65,    74,    59,    60,    65,    56,
2365       57,    58,    12,    13,    14,    15,    16,   161,   162,    66,
2366       67,    68,    69,    70,     7,    88,    89,    10,    11,    12,
2367       13,    14,    15,    16,    17,    18,    40,    41,    42,    43,
2368       44,    45,    46,    47,    48,    49,   263,     9,    10,    11,
2369       12,    13,    14,    15,    16,    17,    18,    10,    11,    12,
2370       13,    14,    15,    16,    17,    18,    10,    11,    12,    13,
2371       14,    15,    16,    80,    81,    82,    83,    84,    85,    21,
2372       22,   115,   116,    65,    65,     8,   129,     9,     9,    36,
2373      134,   133,    80,    70,   152,   207,   102,     6
2374   };
2375 
2376   const unsigned char
2377   parser::yystos_[] =
2378   {
2379        0,     1,    12,    25,    26,    27,    28,    29,    30,    31,
2380       32,    33,    34,    35,    36,    37,    38,    39,    40,    41,
2381       42,    43,    44,    45,    46,    47,    48,    49,    75,    90,
2382       93,    95,    99,   100,   101,   102,   103,   104,   108,   109,
2383      129,    90,    90,   129,     6,    90,    96,   105,   105,   105,
2384        1,    92,    76,    77,    96,   107,    96,    97,    80,    81,
2385       82,    83,    84,    85,   114,    47,    78,    79,   105,   105,
2386      105,    21,    50,    66,    67,   112,    47,    50,    51,    53,
2387      105,   113,    56,    57,    66,    67,    70,    71,    74,   116,
2388       56,    57,    58,    66,    67,    68,    69,    70,   117,    62,
2389      125,    61,   126,    56,    58,    66,    67,    68,    69,    70,
2390       71,    78,   118,    41,    48,    54,    55,    63,    64,   128,
2391       56,    58,    66,    67,   121,    90,    94,     0,     0,     3,
2392      108,     8,    73,   110,   111,     5,    11,    22,   105,   106,
2393      106,    58,    72,    92,    48,    54,    55,    24,    24,    86,
2394       87,   122,   122,    52,    66,    67,    19,    20,    19,     4,
2395      115,    54,    55,   115,   115,   115,    10,   113,   115,   115,
2396       59,    60,   127,   127,     8,   115,   128,   128,   105,   115,
2397      101,   106,   105,   111,   110,   106,   106,    10,    11,    12,
2398       13,    14,    15,    16,    17,    18,     7,    58,    23,   105,
2399       48,    48,   105,   105,    88,    89,   123,   123,    67,   106,
2400      115,   115,   105,   105,   105,   105,   105,   105,    67,   105,
2401       21,    22,   120,   105,   105,    65,   105,     9,   106,   106,
2402      106,   106,   106,   106,   106,   106,   106,    91,    92,    96,
2403      105,   105,   105,   124,   124,   105,   105,    65,     9,     9,
2404       56,    57,    66,    67,    70,    71,    74,    78,   119,    65,
2405       65,    65,    65,     8,    67,   105,     9,     9
2406   };
2407 
2408   const unsigned char
2409   parser::yyr1_[] =
2410   {
2411        0,    98,    99,   100,   100,   101,   101,   101,   101,   101,
2412      101,   101,   101,   102,   103,   104,   104,   104,   104,   104,
2413      104,   104,   104,   104,   104,   104,   104,   104,   104,   104,
2414      104,   104,   104,   104,   104,   104,   104,   104,   104,   104,
2415      104,   104,   105,   105,   105,   106,   106,   106,   106,   106,
2416      106,   106,   106,   106,   106,   106,   106,   107,   107,   107,
2417      108,   108,   108,   108,   108,   109,   109,   109,   109,   109,
2418      109,   109,   109,   109,   109,   109,   109,   109,   109,   109,
2419      109,   110,   111,   112,   112,   112,   112,   112,   112,   112,
2420      112,   113,   113,   113,   113,   113,   113,   113,   113,   113,
2421      113,   113,   114,   114,   114,   114,   114,   114,   114,   115,
2422      115,   116,   116,   116,   116,   116,   116,   116,   117,   117,
2423      117,   117,   117,   117,   117,   117,   118,   118,   118,   118,
2424      118,   118,   118,   118,   118,   118,   119,   119,   119,   119,
2425      119,   119,   119,   119,   119,   120,   120,   120,   121,   121,
2426      121,   121,   122,   122,   122,   123,   123,   123,   124,   124,
2427      125,   125,   126,   126,   127,   127,   127,   128,   128,   128,
2428      128,   128,   129,   129,   129
2429   };
2430 
2431   const signed char
2432   parser::yyr2_[] =
2433   {
2434        0,     2,     2,     1,     3,     2,     1,     1,     2,     1,
2435        1,     0,     1,     2,     2,     3,     2,     2,     4,     3,
2436        3,     2,     5,     5,     2,     1,     1,     2,     5,     5,
2437        5,     2,     2,     2,     2,     4,     4,     5,     5,     4,
2438        1,     1,     1,     1,     3,     1,     3,     3,     3,     3,
2439        3,     3,     3,     3,     3,     2,     2,     1,     1,     1,
2440        3,     3,     2,     2,     1,     1,     4,     3,     2,     4,
2441        4,     3,     3,     5,     4,     4,     4,     5,     5,     3,
2442        4,     3,     2,     2,     2,     2,     2,     3,     1,     2,
2443        0,     4,     4,     4,     5,     5,     3,     3,     3,     1,
2444        3,     0,     1,     1,     1,     1,     1,     1,     0,     1,
2445        0,     1,     1,     1,     1,     1,     1,     1,     1,     1,
2446        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
2447        1,     1,     1,     1,     4,     4,     1,     1,     1,     1,
2448        1,     1,     1,     4,     4,     1,     1,     0,     1,     1,
2449        1,     1,     1,     1,     0,     1,     1,     0,     1,     0,
2450        1,     0,     1,     0,     1,     1,     0,     1,     1,     1,
2451        1,     0,     1,     2,     2
2452   };
2453 
2454 
2455 #if YYDEBUG || 1
2456   // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
2457   // First, the terminals, then, starting at \a YYNTOKENS, nonterminals.
2458   const char*
2459   const parser::yytname_[] =
2460   {
2461   "\"end of file\"", "error", "\"invalid token\"", "\"end of line\"",
2462   "\",\"", "\":\"", "\"(\"", "\")\"", "\"[\"", "\"]\"", "\"+\"", "\"-\"",
2463   "\"*\"", "\"/\"", "\"|\"", "\"&\"", "\"^\"", "\"<<\"", "\">>\"",
2464   "\"--\"", "\"!=\"", "\"!\"", "\"::\"", "\"=\"", "\"<\"", "\".program\"",
2465   "\".wrap_target\"", "\".wrap\"", "\".define\"", "\".side_set\"",
2466   "\".word\"", "\".origin\"", "\".lang_opt\"", "\".pio_version\"",
2467   "\".clock_div\"", "\".fifo\"", "\".mov_status\"", "\".set\"", "\".out\"",
2468   "\".in\"", "\"jmp\"", "\"wait\"", "\"in\"", "\"out\"", "\"push\"",
2469   "\"pull\"", "\"mov\"", "\"irq\"", "\"set\"", "\"nop\"", "\"pin\"",
2470   "\"gpio\"", "\"osre\"", "\"jmppin\"", "\"prev\"", "\"next\"", "\"pins\"",
2471   "\"null\"", "\"pindirs\"", "\"block\"", "\"noblock\"", "\"ifempty\"",
2472   "\"iffull\"", "\"nowait\"", "\"clear\"", "\"rel\"", "\"x\"", "\"y\"",
2473   "\"exec\"", "\"pc\"", "\"isr\"", "\"osr\"", "\"opt\"", "\"side\"",
2474   "\"status\"", "\"public\"", "\"rp2040\"", "\"rp2350\"", "\"rxfifo\"",
2475   "\"txfifo\"", "\"txrx\"", "\"tx\"", "\"rx\"", "\"txput\"", "\"txget\"",
2476   "\"putget\"", "\"left\"", "\"right\"", "\"auto\"", "\"manual\"",
2477   "\"identifier\"", "\"string\"", "\"text\"", "\"code block\"", "\"%}\"",
2478   "UNKNOWN_DIRECTIVE", "\"integer\"", "\"float\"", "$accept", "file",
2479   "lines", "line", "code_block", "label_decl", "directive", "value",
2480   "expression", "pio_version", "instruction", "base_instruction", "delay",
2481   "sideset", "condition", "wait_source", "fifo_config", "comma",
2482   "in_source", "out_target", "mov_target", "mov_source", "mov_op",
2483   "set_target", "direction", "autop", "threshold", "if_full", "if_empty",
2484   "blocking", "irq_modifiers", "symbol_def", YY_NULLPTR
2485   };
2486 #endif
2487 
2488 
2489 #if YYDEBUG
2490   const short
2491   parser::yyrline_[] =
2492   {
2493        0,   169,   169,   173,   174,   177,   178,   179,   180,   181,
2494      182,   183,   184,   188,   192,   195,   196,   197,   198,   199,
2495      200,   201,   202,   203,   204,   205,   206,   207,   208,   209,
2496      210,   211,   212,   213,   214,   215,   216,   217,   218,   219,
2497      220,   221,   226,   227,   228,   232,   233,   234,   235,   236,
2498      237,   238,   239,   240,   241,   242,   243,   246,   247,   248,
2499      252,   253,   254,   255,   256,   260,   261,   262,   263,   264,
2500      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
2501      275,   280,   284,   288,   289,   290,   291,   292,   293,   294,
2502      295,   299,   300,   301,   302,   303,   304,   305,   306,   307,
2503      308,   309,   312,   313,   314,   315,   316,   317,   318,   321,
2504      321,   324,   325,   326,   327,   328,   329,   330,   333,   334,
2505      335,   336,   337,   338,   339,   340,   343,   344,   345,   346,
2506      347,   348,   349,   350,   351,   352,   355,   356,   357,   358,
2507      359,   360,   361,   362,   363,   367,   368,   369,   373,   374,
2508      375,   376,   380,   381,   382,   386,   387,   388,   391,   392,
2509      396,   397,   401,   402,   406,   407,   408,   412,   413,   414,
2510      415,   416,   420,   421,   422
2511   };
2512 
2513   void
yy_stack_print_() const2514   parser::yy_stack_print_ () const
2515   {
2516     *yycdebug_ << "Stack now";
2517     for (stack_type::const_iterator
2518            i = yystack_.begin (),
2519            i_end = yystack_.end ();
2520          i != i_end; ++i)
2521       *yycdebug_ << ' ' << int (i->state);
2522     *yycdebug_ << '\n';
2523   }
2524 
2525   void
yy_reduce_print_(int yyrule) const2526   parser::yy_reduce_print_ (int yyrule) const
2527   {
2528     int yylno = yyrline_[yyrule];
2529     int yynrhs = yyr2_[yyrule];
2530     // Print the symbols being reduced, and their result.
2531     *yycdebug_ << "Reducing stack by rule " << yyrule - 1
2532                << " (line " << yylno << "):\n";
2533     // The symbols being reduced.
2534     for (int yyi = 0; yyi < yynrhs; yyi++)
2535       YY_SYMBOL_PRINT ("   $" << yyi + 1 << " =",
2536                        yystack_[(yynrhs) - (yyi + 1)]);
2537   }
2538 #endif // YYDEBUG
2539 
2540 
2541 } // yy
2542 
2543 
error(const location_type & l,const std::string & m)2544 void yy::parser::error(const location_type& l, const std::string& m)
2545 {
2546    if (l.begin.filename) {
2547       std::cerr << l << ": " << m << '\n';
2548       pioasm.error_count++;
2549       if (l.begin.line == l.end.line && *l.begin.filename == *l.end.filename) {
2550         std::ifstream file(l.begin.filename->c_str());
2551         std::string line;
2552         for(int i = 0; i < l.begin.line; ++i) {
2553              std::getline(file, line);
2554         }
2555         fprintf(stderr, "%5d | %s\n", l.begin.line, line.c_str());
2556         fprintf(stderr, "%5s | %*s", "", l.begin.column, "^");
2557         for (int i = l.begin.column; i < l.end.column - 1; i++) {
2558               putc ('~', stderr);
2559         }
2560         putc ('\n', stderr);
2561       }
2562   } else {
2563       std::cerr << m << '\n';
2564   }
2565 }
2566