parser.cpp 80 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208
  1. // A Bison parser, made by GNU Bison 3.7.2.
  2. // Skeleton implementation for Bison LALR(1) parsers in C++
  3. // Copyright (C) 2002-2015, 2018-2020 Free Software Foundation, Inc.
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. // You should have received a copy of the GNU General Public License
  13. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. // As a special exception, you may create a larger work that contains
  15. // part or all of the Bison parser skeleton and distribute that work
  16. // under terms of your choice, so long as that work isn't itself a
  17. // parser generator using the skeleton or a modified version thereof
  18. // as a parser skeleton. Alternatively, if you modify or redistribute
  19. // the parser skeleton itself, you may (at your option) remove this
  20. // special exception, which will cause the skeleton and the resulting
  21. // Bison output files to be licensed under the GNU General Public
  22. // License without this special exception.
  23. // This special exception was added by the Free Software Foundation in
  24. // version 2.2 of Bison.
  25. // DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
  26. // especially those whose name start with YY_ or yy_. They are
  27. // private implementation details that can be changed or removed.
  28. #include "parser.hpp"
  29. // Unqualified %code blocks.
  30. #include "pio_assembler.h"
  31. #ifdef _MSC_VER
  32. #pragma warning(disable : 4244) // possible loss of data (valid warning, but there is a software check / missing cast)
  33. #endif
  34. #ifndef YY_
  35. # if defined YYENABLE_NLS && YYENABLE_NLS
  36. # if ENABLE_NLS
  37. # include <libintl.h> // FIXME: INFRINGES ON USER NAME SPACE.
  38. # define YY_(msgid) dgettext ("bison-runtime", msgid)
  39. # endif
  40. # endif
  41. # ifndef YY_
  42. # define YY_(msgid) msgid
  43. # endif
  44. #endif
  45. // Whether we are compiled with exception support.
  46. #ifndef YY_EXCEPTIONS
  47. # if defined __GNUC__ && !defined __EXCEPTIONS
  48. # define YY_EXCEPTIONS 0
  49. # else
  50. # define YY_EXCEPTIONS 1
  51. # endif
  52. #endif
  53. #define YYRHSLOC(Rhs, K) ((Rhs)[K].location)
  54. /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
  55. If N is 0, then set CURRENT to the empty location which ends
  56. the previous symbol: RHS[0] (always defined). */
  57. # ifndef YYLLOC_DEFAULT
  58. # define YYLLOC_DEFAULT(Current, Rhs, N) \
  59. do \
  60. if (N) \
  61. { \
  62. (Current).begin = YYRHSLOC (Rhs, 1).begin; \
  63. (Current).end = YYRHSLOC (Rhs, N).end; \
  64. } \
  65. else \
  66. { \
  67. (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
  68. } \
  69. while (false)
  70. # endif
  71. // Enable debugging if requested.
  72. #if YYDEBUG
  73. // A pseudo ostream that takes yydebug_ into account.
  74. # define YYCDEBUG if (yydebug_) (*yycdebug_)
  75. # define YY_SYMBOL_PRINT(Title, Symbol) \
  76. do { \
  77. if (yydebug_) \
  78. { \
  79. *yycdebug_ << Title << ' '; \
  80. yy_print_ (*yycdebug_, Symbol); \
  81. *yycdebug_ << '\n'; \
  82. } \
  83. } while (false)
  84. # define YY_REDUCE_PRINT(Rule) \
  85. do { \
  86. if (yydebug_) \
  87. yy_reduce_print_ (Rule); \
  88. } while (false)
  89. # define YY_STACK_PRINT() \
  90. do { \
  91. if (yydebug_) \
  92. yy_stack_print_ (); \
  93. } while (false)
  94. #else // !YYDEBUG
  95. # define YYCDEBUG if (false) std::cerr
  96. # define YY_SYMBOL_PRINT(Title, Symbol) YYUSE (Symbol)
  97. # define YY_REDUCE_PRINT(Rule) static_cast<void> (0)
  98. # define YY_STACK_PRINT() static_cast<void> (0)
  99. #endif // !YYDEBUG
  100. #define yyerrok (yyerrstatus_ = 0)
  101. #define yyclearin (yyla.clear ())
  102. #define YYACCEPT goto yyacceptlab
  103. #define YYABORT goto yyabortlab
  104. #define YYERROR goto yyerrorlab
  105. #define YYRECOVERING() (!!yyerrstatus_)
  106. namespace yy {
  107. /// Build a parser object.
  108. parser::parser (pio_assembler& pioasm_yyarg)
  109. #if YYDEBUG
  110. : yydebug_ (false),
  111. yycdebug_ (&std::cerr),
  112. #else
  113. :
  114. #endif
  115. yy_lac_established_ (false),
  116. pioasm (pioasm_yyarg)
  117. {}
  118. parser::~parser ()
  119. {}
  120. parser::syntax_error::~syntax_error () YY_NOEXCEPT YY_NOTHROW
  121. {}
  122. /*---------------.
  123. | symbol kinds. |
  124. `---------------*/
  125. // by_state.
  126. parser::by_state::by_state () YY_NOEXCEPT
  127. : state (empty_state)
  128. {}
  129. parser::by_state::by_state (const by_state& that) YY_NOEXCEPT
  130. : state (that.state)
  131. {}
  132. void
  133. parser::by_state::clear () YY_NOEXCEPT
  134. {
  135. state = empty_state;
  136. }
  137. void
  138. parser::by_state::move (by_state& that)
  139. {
  140. state = that.state;
  141. that.clear ();
  142. }
  143. parser::by_state::by_state (state_type s) YY_NOEXCEPT
  144. : state (s)
  145. {}
  146. parser::symbol_kind_type
  147. parser::by_state::kind () const YY_NOEXCEPT
  148. {
  149. if (state == empty_state)
  150. return symbol_kind::S_YYEMPTY;
  151. else
  152. return YY_CAST (symbol_kind_type, yystos_[+state]);
  153. }
  154. parser::stack_symbol_type::stack_symbol_type ()
  155. {}
  156. parser::stack_symbol_type::stack_symbol_type (YY_RVREF (stack_symbol_type) that)
  157. : super_type (YY_MOVE (that.state), YY_MOVE (that.location))
  158. {
  159. switch (that.kind ())
  160. {
  161. case symbol_kind::S_if_full: // if_full
  162. case symbol_kind::S_if_empty: // if_empty
  163. case symbol_kind::S_blocking: // blocking
  164. value.YY_MOVE_OR_COPY< bool > (YY_MOVE (that.value));
  165. break;
  166. case symbol_kind::S_condition: // condition
  167. value.YY_MOVE_OR_COPY< enum condition > (YY_MOVE (that.value));
  168. break;
  169. case symbol_kind::S_in_source: // in_source
  170. case symbol_kind::S_out_target: // out_target
  171. case symbol_kind::S_set_target: // set_target
  172. value.YY_MOVE_OR_COPY< enum in_out_set > (YY_MOVE (that.value));
  173. break;
  174. case symbol_kind::S_irq_modifiers: // irq_modifiers
  175. value.YY_MOVE_OR_COPY< enum irq > (YY_MOVE (that.value));
  176. break;
  177. case symbol_kind::S_mov_target: // mov_target
  178. case symbol_kind::S_mov_source: // mov_source
  179. value.YY_MOVE_OR_COPY< enum mov > (YY_MOVE (that.value));
  180. break;
  181. case symbol_kind::S_mov_op: // mov_op
  182. value.YY_MOVE_OR_COPY< enum mov_op > (YY_MOVE (that.value));
  183. break;
  184. case symbol_kind::S_INT: // "integer"
  185. value.YY_MOVE_OR_COPY< int > (YY_MOVE (that.value));
  186. break;
  187. case symbol_kind::S_instruction: // instruction
  188. case symbol_kind::S_base_instruction: // base_instruction
  189. value.YY_MOVE_OR_COPY< std::shared_ptr<instruction> > (YY_MOVE (that.value));
  190. break;
  191. case symbol_kind::S_value: // value
  192. case symbol_kind::S_expression: // expression
  193. case symbol_kind::S_delay: // delay
  194. case symbol_kind::S_sideset: // sideset
  195. value.YY_MOVE_OR_COPY< std::shared_ptr<resolvable> > (YY_MOVE (that.value));
  196. break;
  197. case symbol_kind::S_label_decl: // label_decl
  198. case symbol_kind::S_symbol_def: // symbol_def
  199. value.YY_MOVE_OR_COPY< std::shared_ptr<symbol> > (YY_MOVE (that.value));
  200. break;
  201. case symbol_kind::S_wait_source: // wait_source
  202. value.YY_MOVE_OR_COPY< std::shared_ptr<wait_source> > (YY_MOVE (that.value));
  203. break;
  204. case symbol_kind::S_ID: // "identifier"
  205. case symbol_kind::S_STRING: // "string"
  206. case symbol_kind::S_NON_WS: // "text"
  207. case symbol_kind::S_CODE_BLOCK_START: // "code block"
  208. case symbol_kind::S_CODE_BLOCK_CONTENTS: // "%}"
  209. case symbol_kind::S_UNKNOWN_DIRECTIVE: // UNKNOWN_DIRECTIVE
  210. value.YY_MOVE_OR_COPY< std::string > (YY_MOVE (that.value));
  211. break;
  212. default:
  213. break;
  214. }
  215. #if 201103L <= YY_CPLUSPLUS
  216. // that is emptied.
  217. that.state = empty_state;
  218. #endif
  219. }
  220. parser::stack_symbol_type::stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) that)
  221. : super_type (s, YY_MOVE (that.location))
  222. {
  223. switch (that.kind ())
  224. {
  225. case symbol_kind::S_if_full: // if_full
  226. case symbol_kind::S_if_empty: // if_empty
  227. case symbol_kind::S_blocking: // blocking
  228. value.move< bool > (YY_MOVE (that.value));
  229. break;
  230. case symbol_kind::S_condition: // condition
  231. value.move< enum condition > (YY_MOVE (that.value));
  232. break;
  233. case symbol_kind::S_in_source: // in_source
  234. case symbol_kind::S_out_target: // out_target
  235. case symbol_kind::S_set_target: // set_target
  236. value.move< enum in_out_set > (YY_MOVE (that.value));
  237. break;
  238. case symbol_kind::S_irq_modifiers: // irq_modifiers
  239. value.move< enum irq > (YY_MOVE (that.value));
  240. break;
  241. case symbol_kind::S_mov_target: // mov_target
  242. case symbol_kind::S_mov_source: // mov_source
  243. value.move< enum mov > (YY_MOVE (that.value));
  244. break;
  245. case symbol_kind::S_mov_op: // mov_op
  246. value.move< enum mov_op > (YY_MOVE (that.value));
  247. break;
  248. case symbol_kind::S_INT: // "integer"
  249. value.move< int > (YY_MOVE (that.value));
  250. break;
  251. case symbol_kind::S_instruction: // instruction
  252. case symbol_kind::S_base_instruction: // base_instruction
  253. value.move< std::shared_ptr<instruction> > (YY_MOVE (that.value));
  254. break;
  255. case symbol_kind::S_value: // value
  256. case symbol_kind::S_expression: // expression
  257. case symbol_kind::S_delay: // delay
  258. case symbol_kind::S_sideset: // sideset
  259. value.move< std::shared_ptr<resolvable> > (YY_MOVE (that.value));
  260. break;
  261. case symbol_kind::S_label_decl: // label_decl
  262. case symbol_kind::S_symbol_def: // symbol_def
  263. value.move< std::shared_ptr<symbol> > (YY_MOVE (that.value));
  264. break;
  265. case symbol_kind::S_wait_source: // wait_source
  266. value.move< std::shared_ptr<wait_source> > (YY_MOVE (that.value));
  267. break;
  268. case symbol_kind::S_ID: // "identifier"
  269. case symbol_kind::S_STRING: // "string"
  270. case symbol_kind::S_NON_WS: // "text"
  271. case symbol_kind::S_CODE_BLOCK_START: // "code block"
  272. case symbol_kind::S_CODE_BLOCK_CONTENTS: // "%}"
  273. case symbol_kind::S_UNKNOWN_DIRECTIVE: // UNKNOWN_DIRECTIVE
  274. value.move< std::string > (YY_MOVE (that.value));
  275. break;
  276. default:
  277. break;
  278. }
  279. // that is emptied.
  280. that.kind_ = symbol_kind::S_YYEMPTY;
  281. }
  282. #if YY_CPLUSPLUS < 201103L
  283. parser::stack_symbol_type&
  284. parser::stack_symbol_type::operator= (const stack_symbol_type& that)
  285. {
  286. state = that.state;
  287. switch (that.kind ())
  288. {
  289. case symbol_kind::S_if_full: // if_full
  290. case symbol_kind::S_if_empty: // if_empty
  291. case symbol_kind::S_blocking: // blocking
  292. value.copy< bool > (that.value);
  293. break;
  294. case symbol_kind::S_condition: // condition
  295. value.copy< enum condition > (that.value);
  296. break;
  297. case symbol_kind::S_in_source: // in_source
  298. case symbol_kind::S_out_target: // out_target
  299. case symbol_kind::S_set_target: // set_target
  300. value.copy< enum in_out_set > (that.value);
  301. break;
  302. case symbol_kind::S_irq_modifiers: // irq_modifiers
  303. value.copy< enum irq > (that.value);
  304. break;
  305. case symbol_kind::S_mov_target: // mov_target
  306. case symbol_kind::S_mov_source: // mov_source
  307. value.copy< enum mov > (that.value);
  308. break;
  309. case symbol_kind::S_mov_op: // mov_op
  310. value.copy< enum mov_op > (that.value);
  311. break;
  312. case symbol_kind::S_INT: // "integer"
  313. value.copy< int > (that.value);
  314. break;
  315. case symbol_kind::S_instruction: // instruction
  316. case symbol_kind::S_base_instruction: // base_instruction
  317. value.copy< std::shared_ptr<instruction> > (that.value);
  318. break;
  319. case symbol_kind::S_value: // value
  320. case symbol_kind::S_expression: // expression
  321. case symbol_kind::S_delay: // delay
  322. case symbol_kind::S_sideset: // sideset
  323. value.copy< std::shared_ptr<resolvable> > (that.value);
  324. break;
  325. case symbol_kind::S_label_decl: // label_decl
  326. case symbol_kind::S_symbol_def: // symbol_def
  327. value.copy< std::shared_ptr<symbol> > (that.value);
  328. break;
  329. case symbol_kind::S_wait_source: // wait_source
  330. value.copy< std::shared_ptr<wait_source> > (that.value);
  331. break;
  332. case symbol_kind::S_ID: // "identifier"
  333. case symbol_kind::S_STRING: // "string"
  334. case symbol_kind::S_NON_WS: // "text"
  335. case symbol_kind::S_CODE_BLOCK_START: // "code block"
  336. case symbol_kind::S_CODE_BLOCK_CONTENTS: // "%}"
  337. case symbol_kind::S_UNKNOWN_DIRECTIVE: // UNKNOWN_DIRECTIVE
  338. value.copy< std::string > (that.value);
  339. break;
  340. default:
  341. break;
  342. }
  343. location = that.location;
  344. return *this;
  345. }
  346. parser::stack_symbol_type&
  347. parser::stack_symbol_type::operator= (stack_symbol_type& that)
  348. {
  349. state = that.state;
  350. switch (that.kind ())
  351. {
  352. case symbol_kind::S_if_full: // if_full
  353. case symbol_kind::S_if_empty: // if_empty
  354. case symbol_kind::S_blocking: // blocking
  355. value.move< bool > (that.value);
  356. break;
  357. case symbol_kind::S_condition: // condition
  358. value.move< enum condition > (that.value);
  359. break;
  360. case symbol_kind::S_in_source: // in_source
  361. case symbol_kind::S_out_target: // out_target
  362. case symbol_kind::S_set_target: // set_target
  363. value.move< enum in_out_set > (that.value);
  364. break;
  365. case symbol_kind::S_irq_modifiers: // irq_modifiers
  366. value.move< enum irq > (that.value);
  367. break;
  368. case symbol_kind::S_mov_target: // mov_target
  369. case symbol_kind::S_mov_source: // mov_source
  370. value.move< enum mov > (that.value);
  371. break;
  372. case symbol_kind::S_mov_op: // mov_op
  373. value.move< enum mov_op > (that.value);
  374. break;
  375. case symbol_kind::S_INT: // "integer"
  376. value.move< int > (that.value);
  377. break;
  378. case symbol_kind::S_instruction: // instruction
  379. case symbol_kind::S_base_instruction: // base_instruction
  380. value.move< std::shared_ptr<instruction> > (that.value);
  381. break;
  382. case symbol_kind::S_value: // value
  383. case symbol_kind::S_expression: // expression
  384. case symbol_kind::S_delay: // delay
  385. case symbol_kind::S_sideset: // sideset
  386. value.move< std::shared_ptr<resolvable> > (that.value);
  387. break;
  388. case symbol_kind::S_label_decl: // label_decl
  389. case symbol_kind::S_symbol_def: // symbol_def
  390. value.move< std::shared_ptr<symbol> > (that.value);
  391. break;
  392. case symbol_kind::S_wait_source: // wait_source
  393. value.move< std::shared_ptr<wait_source> > (that.value);
  394. break;
  395. case symbol_kind::S_ID: // "identifier"
  396. case symbol_kind::S_STRING: // "string"
  397. case symbol_kind::S_NON_WS: // "text"
  398. case symbol_kind::S_CODE_BLOCK_START: // "code block"
  399. case symbol_kind::S_CODE_BLOCK_CONTENTS: // "%}"
  400. case symbol_kind::S_UNKNOWN_DIRECTIVE: // UNKNOWN_DIRECTIVE
  401. value.move< std::string > (that.value);
  402. break;
  403. default:
  404. break;
  405. }
  406. location = that.location;
  407. // that is emptied.
  408. that.state = empty_state;
  409. return *this;
  410. }
  411. #endif
  412. template <typename Base>
  413. void
  414. parser::yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const
  415. {
  416. if (yymsg)
  417. YY_SYMBOL_PRINT (yymsg, yysym);
  418. }
  419. #if YYDEBUG
  420. template <typename Base>
  421. void
  422. parser::yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const
  423. {
  424. std::ostream& yyoutput = yyo;
  425. YYUSE (yyoutput);
  426. if (yysym.empty ())
  427. yyo << "empty symbol";
  428. else
  429. {
  430. symbol_kind_type yykind = yysym.kind ();
  431. yyo << (yykind < YYNTOKENS ? "token" : "nterm")
  432. << ' ' << yysym.name () << " ("
  433. << yysym.location << ": ";
  434. switch (yykind)
  435. {
  436. case symbol_kind::S_ID: // "identifier"
  437. { yyo << "..."; }
  438. break;
  439. case symbol_kind::S_STRING: // "string"
  440. { yyo << "..."; }
  441. break;
  442. case symbol_kind::S_NON_WS: // "text"
  443. { yyo << "..."; }
  444. break;
  445. case symbol_kind::S_CODE_BLOCK_START: // "code block"
  446. { yyo << "..."; }
  447. break;
  448. case symbol_kind::S_CODE_BLOCK_CONTENTS: // "%}"
  449. { yyo << "..."; }
  450. break;
  451. case symbol_kind::S_UNKNOWN_DIRECTIVE: // UNKNOWN_DIRECTIVE
  452. { yyo << "..."; }
  453. break;
  454. case symbol_kind::S_INT: // "integer"
  455. { yyo << "..."; }
  456. break;
  457. case symbol_kind::S_label_decl: // label_decl
  458. { yyo << "..."; }
  459. break;
  460. case symbol_kind::S_value: // value
  461. { yyo << "..."; }
  462. break;
  463. case symbol_kind::S_expression: // expression
  464. { yyo << "..."; }
  465. break;
  466. case symbol_kind::S_instruction: // instruction
  467. { yyo << "..."; }
  468. break;
  469. case symbol_kind::S_base_instruction: // base_instruction
  470. { yyo << "..."; }
  471. break;
  472. case symbol_kind::S_delay: // delay
  473. { yyo << "..."; }
  474. break;
  475. case symbol_kind::S_sideset: // sideset
  476. { yyo << "..."; }
  477. break;
  478. case symbol_kind::S_condition: // condition
  479. { yyo << "..."; }
  480. break;
  481. case symbol_kind::S_wait_source: // wait_source
  482. { yyo << "..."; }
  483. break;
  484. case symbol_kind::S_in_source: // in_source
  485. { yyo << "..."; }
  486. break;
  487. case symbol_kind::S_out_target: // out_target
  488. { yyo << "..."; }
  489. break;
  490. case symbol_kind::S_mov_target: // mov_target
  491. { yyo << "..."; }
  492. break;
  493. case symbol_kind::S_mov_source: // mov_source
  494. { yyo << "..."; }
  495. break;
  496. case symbol_kind::S_mov_op: // mov_op
  497. { yyo << "..."; }
  498. break;
  499. case symbol_kind::S_set_target: // set_target
  500. { yyo << "..."; }
  501. break;
  502. case symbol_kind::S_if_full: // if_full
  503. { yyo << "..."; }
  504. break;
  505. case symbol_kind::S_if_empty: // if_empty
  506. { yyo << "..."; }
  507. break;
  508. case symbol_kind::S_blocking: // blocking
  509. { yyo << "..."; }
  510. break;
  511. case symbol_kind::S_irq_modifiers: // irq_modifiers
  512. { yyo << "..."; }
  513. break;
  514. case symbol_kind::S_symbol_def: // symbol_def
  515. { yyo << "..."; }
  516. break;
  517. default:
  518. break;
  519. }
  520. yyo << ')';
  521. }
  522. }
  523. #endif
  524. void
  525. parser::yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym)
  526. {
  527. if (m)
  528. YY_SYMBOL_PRINT (m, sym);
  529. yystack_.push (YY_MOVE (sym));
  530. }
  531. void
  532. parser::yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym)
  533. {
  534. #if 201103L <= YY_CPLUSPLUS
  535. yypush_ (m, stack_symbol_type (s, std::move (sym)));
  536. #else
  537. stack_symbol_type ss (s, sym);
  538. yypush_ (m, ss);
  539. #endif
  540. }
  541. void
  542. parser::yypop_ (int n)
  543. {
  544. yystack_.pop (n);
  545. }
  546. #if YYDEBUG
  547. std::ostream&
  548. parser::debug_stream () const
  549. {
  550. return *yycdebug_;
  551. }
  552. void
  553. parser::set_debug_stream (std::ostream& o)
  554. {
  555. yycdebug_ = &o;
  556. }
  557. parser::debug_level_type
  558. parser::debug_level () const
  559. {
  560. return yydebug_;
  561. }
  562. void
  563. parser::set_debug_level (debug_level_type l)
  564. {
  565. yydebug_ = l;
  566. }
  567. #endif // YYDEBUG
  568. parser::state_type
  569. parser::yy_lr_goto_state_ (state_type yystate, int yysym)
  570. {
  571. int yyr = yypgoto_[yysym - YYNTOKENS] + yystate;
  572. if (0 <= yyr && yyr <= yylast_ && yycheck_[yyr] == yystate)
  573. return yytable_[yyr];
  574. else
  575. return yydefgoto_[yysym - YYNTOKENS];
  576. }
  577. bool
  578. parser::yy_pact_value_is_default_ (int yyvalue)
  579. {
  580. return yyvalue == yypact_ninf_;
  581. }
  582. bool
  583. parser::yy_table_value_is_error_ (int yyvalue)
  584. {
  585. return yyvalue == yytable_ninf_;
  586. }
  587. int
  588. parser::operator() ()
  589. {
  590. return parse ();
  591. }
  592. int
  593. parser::parse ()
  594. {
  595. int yyn;
  596. /// Length of the RHS of the rule being reduced.
  597. int yylen = 0;
  598. // Error handling.
  599. int yynerrs_ = 0;
  600. int yyerrstatus_ = 0;
  601. /// The lookahead symbol.
  602. symbol_type yyla;
  603. /// The locations where the error started and ended.
  604. stack_symbol_type yyerror_range[3];
  605. /// The return value of parse ().
  606. int yyresult;
  607. /// Discard the LAC context in case there still is one left from a
  608. /// previous invocation.
  609. yy_lac_discard_ ("init");
  610. #if YY_EXCEPTIONS
  611. try
  612. #endif // YY_EXCEPTIONS
  613. {
  614. YYCDEBUG << "Starting parse\n";
  615. /* Initialize the stack. The initial state will be set in
  616. yynewstate, since the latter expects the semantical and the
  617. location values to have been already stored, initialize these
  618. stacks with a primary value. */
  619. yystack_.clear ();
  620. yypush_ (YY_NULLPTR, 0, YY_MOVE (yyla));
  621. /*-----------------------------------------------.
  622. | yynewstate -- push a new symbol on the stack. |
  623. `-----------------------------------------------*/
  624. yynewstate:
  625. YYCDEBUG << "Entering state " << int (yystack_[0].state) << '\n';
  626. YY_STACK_PRINT ();
  627. // Accept?
  628. if (yystack_[0].state == yyfinal_)
  629. YYACCEPT;
  630. goto yybackup;
  631. /*-----------.
  632. | yybackup. |
  633. `-----------*/
  634. yybackup:
  635. // Try to take a decision without lookahead.
  636. yyn = yypact_[+yystack_[0].state];
  637. if (yy_pact_value_is_default_ (yyn))
  638. goto yydefault;
  639. // Read a lookahead token.
  640. if (yyla.empty ())
  641. {
  642. YYCDEBUG << "Reading a token\n";
  643. #if YY_EXCEPTIONS
  644. try
  645. #endif // YY_EXCEPTIONS
  646. {
  647. symbol_type yylookahead (yylex (pioasm));
  648. yyla.move (yylookahead);
  649. }
  650. #if YY_EXCEPTIONS
  651. catch (const syntax_error& yyexc)
  652. {
  653. YYCDEBUG << "Caught exception: " << yyexc.what() << '\n';
  654. error (yyexc);
  655. goto yyerrlab1;
  656. }
  657. #endif // YY_EXCEPTIONS
  658. }
  659. YY_SYMBOL_PRINT ("Next token is", yyla);
  660. if (yyla.kind () == symbol_kind::S_YYerror)
  661. {
  662. // The scanner already issued an error message, process directly
  663. // to error recovery. But do not keep the error token as
  664. // lookahead, it is too special and may lead us to an endless
  665. // loop in error recovery. */
  666. yyla.kind_ = symbol_kind::S_YYUNDEF;
  667. goto yyerrlab1;
  668. }
  669. /* If the proper action on seeing token YYLA.TYPE is to reduce or
  670. to detect an error, take that action. */
  671. yyn += yyla.kind ();
  672. if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.kind ())
  673. {
  674. if (!yy_lac_establish_ (yyla.kind ()))
  675. goto yyerrlab;
  676. goto yydefault;
  677. }
  678. // Reduce or error.
  679. yyn = yytable_[yyn];
  680. if (yyn <= 0)
  681. {
  682. if (yy_table_value_is_error_ (yyn))
  683. goto yyerrlab;
  684. if (!yy_lac_establish_ (yyla.kind ()))
  685. goto yyerrlab;
  686. yyn = -yyn;
  687. goto yyreduce;
  688. }
  689. // Count tokens shifted since error; after three, turn off error status.
  690. if (yyerrstatus_)
  691. --yyerrstatus_;
  692. // Shift the lookahead token.
  693. yypush_ ("Shifting", state_type (yyn), YY_MOVE (yyla));
  694. yy_lac_discard_ ("shift");
  695. goto yynewstate;
  696. /*-----------------------------------------------------------.
  697. | yydefault -- do the default action for the current state. |
  698. `-----------------------------------------------------------*/
  699. yydefault:
  700. yyn = yydefact_[+yystack_[0].state];
  701. if (yyn == 0)
  702. goto yyerrlab;
  703. goto yyreduce;
  704. /*-----------------------------.
  705. | yyreduce -- do a reduction. |
  706. `-----------------------------*/
  707. yyreduce:
  708. yylen = yyr2_[yyn];
  709. {
  710. stack_symbol_type yylhs;
  711. yylhs.state = yy_lr_goto_state_ (yystack_[yylen].state, yyr1_[yyn]);
  712. /* Variants are always initialized to an empty instance of the
  713. correct type. The default '$$ = $1' action is NOT applied
  714. when using variants. */
  715. switch (yyr1_[yyn])
  716. {
  717. case symbol_kind::S_if_full: // if_full
  718. case symbol_kind::S_if_empty: // if_empty
  719. case symbol_kind::S_blocking: // blocking
  720. yylhs.value.emplace< bool > ();
  721. break;
  722. case symbol_kind::S_condition: // condition
  723. yylhs.value.emplace< enum condition > ();
  724. break;
  725. case symbol_kind::S_in_source: // in_source
  726. case symbol_kind::S_out_target: // out_target
  727. case symbol_kind::S_set_target: // set_target
  728. yylhs.value.emplace< enum in_out_set > ();
  729. break;
  730. case symbol_kind::S_irq_modifiers: // irq_modifiers
  731. yylhs.value.emplace< enum irq > ();
  732. break;
  733. case symbol_kind::S_mov_target: // mov_target
  734. case symbol_kind::S_mov_source: // mov_source
  735. yylhs.value.emplace< enum mov > ();
  736. break;
  737. case symbol_kind::S_mov_op: // mov_op
  738. yylhs.value.emplace< enum mov_op > ();
  739. break;
  740. case symbol_kind::S_INT: // "integer"
  741. yylhs.value.emplace< int > ();
  742. break;
  743. case symbol_kind::S_instruction: // instruction
  744. case symbol_kind::S_base_instruction: // base_instruction
  745. yylhs.value.emplace< std::shared_ptr<instruction> > ();
  746. break;
  747. case symbol_kind::S_value: // value
  748. case symbol_kind::S_expression: // expression
  749. case symbol_kind::S_delay: // delay
  750. case symbol_kind::S_sideset: // sideset
  751. yylhs.value.emplace< std::shared_ptr<resolvable> > ();
  752. break;
  753. case symbol_kind::S_label_decl: // label_decl
  754. case symbol_kind::S_symbol_def: // symbol_def
  755. yylhs.value.emplace< std::shared_ptr<symbol> > ();
  756. break;
  757. case symbol_kind::S_wait_source: // wait_source
  758. yylhs.value.emplace< std::shared_ptr<wait_source> > ();
  759. break;
  760. case symbol_kind::S_ID: // "identifier"
  761. case symbol_kind::S_STRING: // "string"
  762. case symbol_kind::S_NON_WS: // "text"
  763. case symbol_kind::S_CODE_BLOCK_START: // "code block"
  764. case symbol_kind::S_CODE_BLOCK_CONTENTS: // "%}"
  765. case symbol_kind::S_UNKNOWN_DIRECTIVE: // UNKNOWN_DIRECTIVE
  766. yylhs.value.emplace< std::string > ();
  767. break;
  768. default:
  769. break;
  770. }
  771. // Default location.
  772. {
  773. stack_type::slice range (yystack_, yylen);
  774. YYLLOC_DEFAULT (yylhs.location, range, yylen);
  775. yyerror_range[1].location = yylhs.location;
  776. }
  777. // Perform the reduction.
  778. YY_REDUCE_PRINT (yyn);
  779. #if YY_EXCEPTIONS
  780. try
  781. #endif // YY_EXCEPTIONS
  782. {
  783. switch (yyn)
  784. {
  785. case 2: // file: lines "end of file"
  786. { if (pioasm.error_count || pioasm.write_output()) YYABORT; }
  787. break;
  788. case 5: // line: ".program" "identifier"
  789. { 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(); } }
  790. break;
  791. case 7: // line: instruction
  792. { pioasm.get_current_program(yystack_[0].location, "instruction").add_instruction(yystack_[0].value.as < std::shared_ptr<instruction> > ()); }
  793. break;
  794. case 8: // line: label_decl instruction
  795. { 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> > ()); }
  796. break;
  797. case 9: // line: label_decl
  798. { pioasm.get_current_program(yystack_[0].location, "label").add_label(yystack_[0].value.as < std::shared_ptr<symbol> > ()); }
  799. break;
  800. case 12: // line: error
  801. { if (pioasm.error_count > 6) { std::cerr << "\ntoo many errors; aborting.\n"; YYABORT; } }
  802. break;
  803. case 13: // code_block: "code block" "%}"
  804. { 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 > ())); }
  805. break;
  806. case 14: // label_decl: symbol_def ":"
  807. { 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> > (); }
  808. break;
  809. case 15: // directive: ".define" symbol_def expression
  810. { 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> > ()); }
  811. break;
  812. case 16: // directive: ".origin" value
  813. { pioasm.get_current_program(yystack_[1].location, ".origin", true).set_origin(yylhs.location, yystack_[0].value.as < std::shared_ptr<resolvable> > ()); }
  814. break;
  815. case 17: // directive: ".side_set" value "opt" "pindirs"
  816. { pioasm.get_current_program(yystack_[3].location, ".side_set", true).set_sideset(yylhs.location, yystack_[2].value.as < std::shared_ptr<resolvable> > (), true, true); }
  817. break;
  818. case 18: // directive: ".side_set" value "opt"
  819. { pioasm.get_current_program(yystack_[2].location, ".side_set", true).set_sideset(yylhs.location, yystack_[1].value.as < std::shared_ptr<resolvable> > (), true, false); }
  820. break;
  821. case 19: // directive: ".side_set" value "pindirs"
  822. { pioasm.get_current_program(yystack_[2].location, ".side_set", true).set_sideset(yylhs.location, yystack_[1].value.as < std::shared_ptr<resolvable> > (), false, true); }
  823. break;
  824. case 20: // directive: ".side_set" value
  825. { pioasm.get_current_program(yystack_[1].location, ".side_set", true).set_sideset(yylhs.location, yystack_[0].value.as < std::shared_ptr<resolvable> > (), false, false); }
  826. break;
  827. case 21: // directive: ".wrap_target"
  828. { pioasm.get_current_program(yystack_[0].location, ".wrap_target").set_wrap_target(yylhs.location); }
  829. break;
  830. case 22: // directive: ".wrap"
  831. { pioasm.get_current_program(yystack_[0].location, ".wrap").set_wrap(yylhs.location); }
  832. break;
  833. case 23: // directive: ".word" value
  834. { 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> > ()))); }
  835. break;
  836. case 24: // directive: ".lang_opt" "text" "text" "=" "integer"
  837. { 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 > ())); }
  838. break;
  839. case 25: // directive: ".lang_opt" "text" "text" "=" "string"
  840. { 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 > ()); }
  841. break;
  842. case 26: // directive: ".lang_opt" "text" "text" "=" "text"
  843. { 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 > ()); }
  844. break;
  845. case 27: // directive: ".lang_opt" error
  846. { error(yylhs.location, "expected format is .lang_opt language option_name = option_value"); }
  847. break;
  848. case 28: // directive: UNKNOWN_DIRECTIVE
  849. { std::stringstream msg; msg << "unknown directive " << yystack_[0].value.as < std::string > (); throw syntax_error(yylhs.location, msg.str()); }
  850. break;
  851. case 29: // value: "integer"
  852. { yylhs.value.as < std::shared_ptr<resolvable> > () = resolvable_int(yylhs.location, yystack_[0].value.as < int > ()); }
  853. break;
  854. case 30: // value: "identifier"
  855. { yylhs.value.as < std::shared_ptr<resolvable> > () = std::shared_ptr<resolvable>(new name_ref(yylhs.location, yystack_[0].value.as < std::string > ())); }
  856. break;
  857. case 31: // value: "(" expression ")"
  858. { yylhs.value.as < std::shared_ptr<resolvable> > () = yystack_[1].value.as < std::shared_ptr<resolvable> > (); }
  859. break;
  860. case 32: // expression: value
  861. { yylhs.value.as < std::shared_ptr<resolvable> > () = yystack_[0].value.as < std::shared_ptr<resolvable> > (); }
  862. break;
  863. case 33: // expression: expression "+" expression
  864. { 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> > ())); }
  865. break;
  866. case 34: // expression: expression "-" expression
  867. { 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> > ())); }
  868. break;
  869. case 35: // expression: expression "*" expression
  870. { 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> > ())); }
  871. break;
  872. case 36: // expression: expression "/" expression
  873. { 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> > ())); }
  874. break;
  875. case 37: // expression: expression "|" expression
  876. { 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> > ())); }
  877. break;
  878. case 38: // expression: expression "&" expression
  879. { 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> > ())); }
  880. break;
  881. case 39: // expression: expression "^" expression
  882. { 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> > ())); }
  883. break;
  884. case 40: // expression: "-" expression
  885. { 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> > ())); }
  886. break;
  887. case 41: // expression: "::" expression
  888. { 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> > ())); }
  889. break;
  890. case 42: // instruction: base_instruction sideset delay
  891. { 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> > (); }
  892. break;
  893. case 43: // instruction: base_instruction delay sideset
  894. { 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> > (); }
  895. break;
  896. case 44: // instruction: base_instruction sideset
  897. { 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); }
  898. break;
  899. case 45: // instruction: base_instruction delay
  900. { 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> > (); }
  901. break;
  902. case 46: // instruction: base_instruction
  903. { 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); }
  904. break;
  905. case 47: // base_instruction: "nop"
  906. { yylhs.value.as < std::shared_ptr<instruction> > () = std::shared_ptr<instruction>(new instr_nop(yylhs.location)); }
  907. break;
  908. case 48: // base_instruction: "jmp" condition comma expression
  909. { 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> > ())); }
  910. break;
  911. case 49: // base_instruction: "wait" value wait_source
  912. { 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> > ())); }
  913. break;
  914. case 50: // base_instruction: "wait" value "," value
  915. { std::stringstream msg; location l; l.begin = yystack_[2].location.end; l.end = yystack_[1].location.end; msg << "expected irq, gpio or pin after the polarity value and before the \",\""; throw yy::parser::syntax_error(l, msg.str()); }
  916. break;
  917. case 51: // base_instruction: "wait" wait_source
  918. { 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> > ())); }
  919. break;
  920. case 52: // base_instruction: "in" in_source comma value
  921. { 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> > ())); }
  922. break;
  923. case 53: // base_instruction: "out" out_target comma value
  924. { 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> > ())); }
  925. break;
  926. case 54: // base_instruction: "push" if_full blocking
  927. { 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 > ())); }
  928. break;
  929. case 55: // base_instruction: "pull" if_empty blocking
  930. { 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 > ())); }
  931. break;
  932. case 56: // base_instruction: "mov" mov_target comma mov_op mov_source
  933. { yylhs.value.as < std::shared_ptr<instruction> > () = std::shared_ptr<instruction>(new instr_mov(yylhs.location, yystack_[3].value.as < enum mov > (), yystack_[0].value.as < enum mov > (), yystack_[1].value.as < enum mov_op > ())); }
  934. break;
  935. case 57: // base_instruction: "irq" irq_modifiers value "rel"
  936. { 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> > (), true)); }
  937. break;
  938. case 58: // base_instruction: "irq" irq_modifiers value
  939. { 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> > ())); }
  940. break;
  941. case 59: // base_instruction: "set" set_target comma value
  942. { 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> > ())); }
  943. break;
  944. case 60: // delay: "[" expression "]"
  945. { yylhs.value.as < std::shared_ptr<resolvable> > () = yystack_[1].value.as < std::shared_ptr<resolvable> > (); }
  946. break;
  947. case 61: // sideset: "side" value
  948. { yylhs.value.as < std::shared_ptr<resolvable> > () = yystack_[0].value.as < std::shared_ptr<resolvable> > (); }
  949. break;
  950. case 62: // condition: "!" "x"
  951. { yylhs.value.as < enum condition > () = condition::xz; }
  952. break;
  953. case 63: // condition: "x" "--"
  954. { yylhs.value.as < enum condition > () = condition::xnz__; }
  955. break;
  956. case 64: // condition: "!" "y"
  957. { yylhs.value.as < enum condition > () = condition::yz; }
  958. break;
  959. case 65: // condition: "y" "--"
  960. { yylhs.value.as < enum condition > () = condition::ynz__; }
  961. break;
  962. case 66: // condition: "x" "!=" "y"
  963. { yylhs.value.as < enum condition > () = condition::xney; }
  964. break;
  965. case 67: // condition: "pin"
  966. { yylhs.value.as < enum condition > () = condition::pin; }
  967. break;
  968. case 68: // condition: "!" "osre"
  969. { yylhs.value.as < enum condition > () = condition::osrez; }
  970. break;
  971. case 69: // condition: %empty
  972. { yylhs.value.as < enum condition > () = condition::al; }
  973. break;
  974. case 70: // wait_source: "irq" comma value "rel"
  975. { 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> > (), true)); }
  976. break;
  977. case 71: // wait_source: "irq" comma value
  978. { 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> > (), false)); }
  979. break;
  980. case 72: // wait_source: "gpio" comma value
  981. { 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> > ())); }
  982. break;
  983. case 73: // wait_source: "pin" comma value
  984. { 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> > ())); }
  985. break;
  986. case 76: // in_source: "pins"
  987. { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_set_pins; }
  988. break;
  989. case 77: // in_source: "x"
  990. { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_set_x; }
  991. break;
  992. case 78: // in_source: "y"
  993. { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_set_y; }
  994. break;
  995. case 79: // in_source: "null"
  996. { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_null; }
  997. break;
  998. case 80: // in_source: "isr"
  999. { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_isr; }
  1000. break;
  1001. case 81: // in_source: "osr"
  1002. { yylhs.value.as < enum in_out_set > () = in_out_set::in_osr; }
  1003. break;
  1004. case 82: // in_source: "status"
  1005. { yylhs.value.as < enum in_out_set > () = in_out_set::in_status; }
  1006. break;
  1007. case 83: // out_target: "pins"
  1008. { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_set_pins; }
  1009. break;
  1010. case 84: // out_target: "x"
  1011. { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_set_x; }
  1012. break;
  1013. case 85: // out_target: "y"
  1014. { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_set_y; }
  1015. break;
  1016. case 86: // out_target: "null"
  1017. { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_null; }
  1018. break;
  1019. case 87: // out_target: "pindirs"
  1020. { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_set_pindirs; }
  1021. break;
  1022. case 88: // out_target: "isr"
  1023. { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_isr; }
  1024. break;
  1025. case 89: // out_target: "pc"
  1026. { yylhs.value.as < enum in_out_set > () = in_out_set::out_set_pc; }
  1027. break;
  1028. case 90: // out_target: "exec"
  1029. { yylhs.value.as < enum in_out_set > () = in_out_set::out_exec; }
  1030. break;
  1031. case 91: // mov_target: "pins"
  1032. { yylhs.value.as < enum mov > () = mov::pins; }
  1033. break;
  1034. case 92: // mov_target: "x"
  1035. { yylhs.value.as < enum mov > () = mov::x; }
  1036. break;
  1037. case 93: // mov_target: "y"
  1038. { yylhs.value.as < enum mov > () = mov::y; }
  1039. break;
  1040. case 94: // mov_target: "exec"
  1041. { yylhs.value.as < enum mov > () = mov::exec; }
  1042. break;
  1043. case 95: // mov_target: "pc"
  1044. { yylhs.value.as < enum mov > () = mov::pc; }
  1045. break;
  1046. case 96: // mov_target: "isr"
  1047. { yylhs.value.as < enum mov > () = mov::isr; }
  1048. break;
  1049. case 97: // mov_target: "osr"
  1050. { yylhs.value.as < enum mov > () = mov::osr; }
  1051. break;
  1052. case 98: // mov_source: "pins"
  1053. { yylhs.value.as < enum mov > () = mov::pins; }
  1054. break;
  1055. case 99: // mov_source: "x"
  1056. { yylhs.value.as < enum mov > () = mov::x; }
  1057. break;
  1058. case 100: // mov_source: "y"
  1059. { yylhs.value.as < enum mov > () = mov::y; }
  1060. break;
  1061. case 101: // mov_source: "null"
  1062. { yylhs.value.as < enum mov > () = mov::null; }
  1063. break;
  1064. case 102: // mov_source: "status"
  1065. { yylhs.value.as < enum mov > () = mov::status; }
  1066. break;
  1067. case 103: // mov_source: "isr"
  1068. { yylhs.value.as < enum mov > () = mov::isr; }
  1069. break;
  1070. case 104: // mov_source: "osr"
  1071. { yylhs.value.as < enum mov > () = mov::osr; }
  1072. break;
  1073. case 105: // mov_op: "!"
  1074. { yylhs.value.as < enum mov_op > () = mov_op::invert; }
  1075. break;
  1076. case 106: // mov_op: "::"
  1077. { yylhs.value.as < enum mov_op > () = mov_op::bit_reverse; }
  1078. break;
  1079. case 107: // mov_op: %empty
  1080. { yylhs.value.as < enum mov_op > () = mov_op::none; }
  1081. break;
  1082. case 108: // set_target: "pins"
  1083. { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_set_pins; }
  1084. break;
  1085. case 109: // set_target: "x"
  1086. { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_set_x; }
  1087. break;
  1088. case 110: // set_target: "y"
  1089. { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_set_y; }
  1090. break;
  1091. case 111: // set_target: "pindirs"
  1092. { yylhs.value.as < enum in_out_set > () = in_out_set::in_out_set_pindirs; }
  1093. break;
  1094. case 112: // if_full: "iffull"
  1095. { yylhs.value.as < bool > () = true; }
  1096. break;
  1097. case 113: // if_full: %empty
  1098. { yylhs.value.as < bool > () = false; }
  1099. break;
  1100. case 114: // if_empty: "ifempty"
  1101. { yylhs.value.as < bool > () = true; }
  1102. break;
  1103. case 115: // if_empty: %empty
  1104. { yylhs.value.as < bool > () = false; }
  1105. break;
  1106. case 116: // blocking: "block"
  1107. { yylhs.value.as < bool > () = true; }
  1108. break;
  1109. case 117: // blocking: "noblock"
  1110. { yylhs.value.as < bool > () = false; }
  1111. break;
  1112. case 118: // blocking: %empty
  1113. { yylhs.value.as < bool > () = true; }
  1114. break;
  1115. case 119: // irq_modifiers: "clear"
  1116. { yylhs.value.as < enum irq > () = irq::clear; }
  1117. break;
  1118. case 120: // irq_modifiers: "wait"
  1119. { yylhs.value.as < enum irq > () = irq::set_wait; }
  1120. break;
  1121. case 121: // irq_modifiers: "nowait"
  1122. { yylhs.value.as < enum irq > () = irq::set; }
  1123. break;
  1124. case 122: // irq_modifiers: "set"
  1125. { yylhs.value.as < enum irq > () = irq::set; }
  1126. break;
  1127. case 123: // irq_modifiers: %empty
  1128. { yylhs.value.as < enum irq > () = irq::set; }
  1129. break;
  1130. case 124: // symbol_def: "identifier"
  1131. { yylhs.value.as < std::shared_ptr<symbol> > () = std::shared_ptr<symbol>(new symbol(yylhs.location, yystack_[0].value.as < std::string > ())); }
  1132. break;
  1133. case 125: // symbol_def: "public" "identifier"
  1134. { yylhs.value.as < std::shared_ptr<symbol> > () = std::shared_ptr<symbol>(new symbol(yylhs.location, yystack_[0].value.as < std::string > (), true)); }
  1135. break;
  1136. case 126: // symbol_def: "*" "identifier"
  1137. { yylhs.value.as < std::shared_ptr<symbol> > () = std::shared_ptr<symbol>(new symbol(yylhs.location, yystack_[0].value.as < std::string > (), true)); }
  1138. break;
  1139. default:
  1140. break;
  1141. }
  1142. }
  1143. #if YY_EXCEPTIONS
  1144. catch (const syntax_error& yyexc)
  1145. {
  1146. YYCDEBUG << "Caught exception: " << yyexc.what() << '\n';
  1147. error (yyexc);
  1148. YYERROR;
  1149. }
  1150. #endif // YY_EXCEPTIONS
  1151. YY_SYMBOL_PRINT ("-> $$ =", yylhs);
  1152. yypop_ (yylen);
  1153. yylen = 0;
  1154. // Shift the result of the reduction.
  1155. yypush_ (YY_NULLPTR, YY_MOVE (yylhs));
  1156. }
  1157. goto yynewstate;
  1158. /*--------------------------------------.
  1159. | yyerrlab -- here on detecting error. |
  1160. `--------------------------------------*/
  1161. yyerrlab:
  1162. // If not already recovering from an error, report this error.
  1163. if (!yyerrstatus_)
  1164. {
  1165. ++yynerrs_;
  1166. context yyctx (*this, yyla);
  1167. std::string msg = yysyntax_error_ (yyctx);
  1168. error (yyla.location, YY_MOVE (msg));
  1169. }
  1170. yyerror_range[1].location = yyla.location;
  1171. if (yyerrstatus_ == 3)
  1172. {
  1173. /* If just tried and failed to reuse lookahead token after an
  1174. error, discard it. */
  1175. // Return failure if at end of input.
  1176. if (yyla.kind () == symbol_kind::S_YYEOF)
  1177. YYABORT;
  1178. else if (!yyla.empty ())
  1179. {
  1180. yy_destroy_ ("Error: discarding", yyla);
  1181. yyla.clear ();
  1182. }
  1183. }
  1184. // Else will try to reuse lookahead token after shifting the error token.
  1185. goto yyerrlab1;
  1186. /*---------------------------------------------------.
  1187. | yyerrorlab -- error raised explicitly by YYERROR. |
  1188. `---------------------------------------------------*/
  1189. yyerrorlab:
  1190. /* Pacify compilers when the user code never invokes YYERROR and
  1191. the label yyerrorlab therefore never appears in user code. */
  1192. if (false)
  1193. YYERROR;
  1194. /* Do not reclaim the symbols of the rule whose action triggered
  1195. this YYERROR. */
  1196. yypop_ (yylen);
  1197. yylen = 0;
  1198. YY_STACK_PRINT ();
  1199. goto yyerrlab1;
  1200. /*-------------------------------------------------------------.
  1201. | yyerrlab1 -- common code for both syntax error and YYERROR. |
  1202. `-------------------------------------------------------------*/
  1203. yyerrlab1:
  1204. yyerrstatus_ = 3; // Each real token shifted decrements this.
  1205. // Pop stack until we find a state that shifts the error token.
  1206. for (;;)
  1207. {
  1208. yyn = yypact_[+yystack_[0].state];
  1209. if (!yy_pact_value_is_default_ (yyn))
  1210. {
  1211. yyn += symbol_kind::S_YYerror;
  1212. if (0 <= yyn && yyn <= yylast_
  1213. && yycheck_[yyn] == symbol_kind::S_YYerror)
  1214. {
  1215. yyn = yytable_[yyn];
  1216. if (0 < yyn)
  1217. break;
  1218. }
  1219. }
  1220. // Pop the current state because it cannot handle the error token.
  1221. if (yystack_.size () == 1)
  1222. YYABORT;
  1223. yyerror_range[1].location = yystack_[0].location;
  1224. yy_destroy_ ("Error: popping", yystack_[0]);
  1225. yypop_ ();
  1226. YY_STACK_PRINT ();
  1227. }
  1228. {
  1229. stack_symbol_type error_token;
  1230. yyerror_range[2].location = yyla.location;
  1231. YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);
  1232. // Shift the error token.
  1233. yy_lac_discard_ ("error recovery");
  1234. error_token.state = state_type (yyn);
  1235. yypush_ ("Shifting", YY_MOVE (error_token));
  1236. }
  1237. goto yynewstate;
  1238. /*-------------------------------------.
  1239. | yyacceptlab -- YYACCEPT comes here. |
  1240. `-------------------------------------*/
  1241. yyacceptlab:
  1242. yyresult = 0;
  1243. goto yyreturn;
  1244. /*-----------------------------------.
  1245. | yyabortlab -- YYABORT comes here. |
  1246. `-----------------------------------*/
  1247. yyabortlab:
  1248. yyresult = 1;
  1249. goto yyreturn;
  1250. /*-----------------------------------------------------.
  1251. | yyreturn -- parsing is finished, return the result. |
  1252. `-----------------------------------------------------*/
  1253. yyreturn:
  1254. if (!yyla.empty ())
  1255. yy_destroy_ ("Cleanup: discarding lookahead", yyla);
  1256. /* Do not reclaim the symbols of the rule whose action triggered
  1257. this YYABORT or YYACCEPT. */
  1258. yypop_ (yylen);
  1259. YY_STACK_PRINT ();
  1260. while (1 < yystack_.size ())
  1261. {
  1262. yy_destroy_ ("Cleanup: popping", yystack_[0]);
  1263. yypop_ ();
  1264. }
  1265. return yyresult;
  1266. }
  1267. #if YY_EXCEPTIONS
  1268. catch (...)
  1269. {
  1270. YYCDEBUG << "Exception caught: cleaning lookahead and stack\n";
  1271. // Do not try to display the values of the reclaimed symbols,
  1272. // as their printers might throw an exception.
  1273. if (!yyla.empty ())
  1274. yy_destroy_ (YY_NULLPTR, yyla);
  1275. while (1 < yystack_.size ())
  1276. {
  1277. yy_destroy_ (YY_NULLPTR, yystack_[0]);
  1278. yypop_ ();
  1279. }
  1280. throw;
  1281. }
  1282. #endif // YY_EXCEPTIONS
  1283. }
  1284. void
  1285. parser::error (const syntax_error& yyexc)
  1286. {
  1287. error (yyexc.location, yyexc.what ());
  1288. }
  1289. /* Return YYSTR after stripping away unnecessary quotes and
  1290. backslashes, so that it's suitable for yyerror. The heuristic is
  1291. that double-quoting is unnecessary unless the string contains an
  1292. apostrophe, a comma, or backslash (other than backslash-backslash).
  1293. YYSTR is taken from yytname. */
  1294. std::string
  1295. parser::yytnamerr_ (const char *yystr)
  1296. {
  1297. if (*yystr == '"')
  1298. {
  1299. std::string yyr;
  1300. char const *yyp = yystr;
  1301. for (;;)
  1302. switch (*++yyp)
  1303. {
  1304. case '\'':
  1305. case ',':
  1306. goto do_not_strip_quotes;
  1307. case '\\':
  1308. if (*++yyp != '\\')
  1309. goto do_not_strip_quotes;
  1310. else
  1311. goto append;
  1312. append:
  1313. default:
  1314. yyr += *yyp;
  1315. break;
  1316. case '"':
  1317. return yyr;
  1318. }
  1319. do_not_strip_quotes: ;
  1320. }
  1321. return yystr;
  1322. }
  1323. std::string
  1324. parser::symbol_name (symbol_kind_type yysymbol)
  1325. {
  1326. return yytnamerr_ (yytname_[yysymbol]);
  1327. }
  1328. // parser::context.
  1329. parser::context::context (const parser& yyparser, const symbol_type& yyla)
  1330. : yyparser_ (yyparser)
  1331. , yyla_ (yyla)
  1332. {}
  1333. int
  1334. parser::context::expected_tokens (symbol_kind_type yyarg[], int yyargn) const
  1335. {
  1336. // Actual number of expected tokens
  1337. int yycount = 0;
  1338. #if YYDEBUG
  1339. // Execute LAC once. We don't care if it is successful, we
  1340. // only do it for the sake of debugging output.
  1341. if (!yyparser_.yy_lac_established_)
  1342. yyparser_.yy_lac_check_ (yyla_.kind ());
  1343. #endif
  1344. for (int yyx = 0; yyx < YYNTOKENS; ++yyx)
  1345. {
  1346. symbol_kind_type yysym = YY_CAST (symbol_kind_type, yyx);
  1347. if (yysym != symbol_kind::S_YYerror
  1348. && yysym != symbol_kind::S_YYUNDEF
  1349. && yyparser_.yy_lac_check_ (yysym))
  1350. {
  1351. if (!yyarg)
  1352. ++yycount;
  1353. else if (yycount == yyargn)
  1354. return 0;
  1355. else
  1356. yyarg[yycount++] = yysym;
  1357. }
  1358. }
  1359. if (yyarg && yycount == 0 && 0 < yyargn)
  1360. yyarg[0] = symbol_kind::S_YYEMPTY;
  1361. return yycount;
  1362. }
  1363. bool
  1364. parser::yy_lac_check_ (symbol_kind_type yytoken) const
  1365. {
  1366. // Logically, the yylac_stack's lifetime is confined to this function.
  1367. // Clear it, to get rid of potential left-overs from previous call.
  1368. yylac_stack_.clear ();
  1369. // Reduce until we encounter a shift and thereby accept the token.
  1370. #if YYDEBUG
  1371. YYCDEBUG << "LAC: checking lookahead " << symbol_name (yytoken) << ':';
  1372. #endif
  1373. std::ptrdiff_t lac_top = 0;
  1374. while (true)
  1375. {
  1376. state_type top_state = (yylac_stack_.empty ()
  1377. ? yystack_[lac_top].state
  1378. : yylac_stack_.back ());
  1379. int yyrule = yypact_[+top_state];
  1380. if (yy_pact_value_is_default_ (yyrule)
  1381. || (yyrule += yytoken) < 0 || yylast_ < yyrule
  1382. || yycheck_[yyrule] != yytoken)
  1383. {
  1384. // Use the default action.
  1385. yyrule = yydefact_[+top_state];
  1386. if (yyrule == 0)
  1387. {
  1388. YYCDEBUG << " Err\n";
  1389. return false;
  1390. }
  1391. }
  1392. else
  1393. {
  1394. // Use the action from yytable.
  1395. yyrule = yytable_[yyrule];
  1396. if (yy_table_value_is_error_ (yyrule))
  1397. {
  1398. YYCDEBUG << " Err\n";
  1399. return false;
  1400. }
  1401. if (0 < yyrule)
  1402. {
  1403. YYCDEBUG << " S" << yyrule << '\n';
  1404. return true;
  1405. }
  1406. yyrule = -yyrule;
  1407. }
  1408. // By now we know we have to simulate a reduce.
  1409. YYCDEBUG << " R" << yyrule - 1;
  1410. // Pop the corresponding number of values from the stack.
  1411. {
  1412. std::ptrdiff_t yylen = yyr2_[yyrule];
  1413. // First pop from the LAC stack as many tokens as possible.
  1414. std::ptrdiff_t lac_size = std::ptrdiff_t (yylac_stack_.size ());
  1415. if (yylen < lac_size)
  1416. {
  1417. yylac_stack_.resize (std::size_t (lac_size - yylen));
  1418. yylen = 0;
  1419. }
  1420. else if (lac_size)
  1421. {
  1422. yylac_stack_.clear ();
  1423. yylen -= lac_size;
  1424. }
  1425. // Only afterwards look at the main stack.
  1426. // We simulate popping elements by incrementing lac_top.
  1427. lac_top += yylen;
  1428. }
  1429. // Keep top_state in sync with the updated stack.
  1430. top_state = (yylac_stack_.empty ()
  1431. ? yystack_[lac_top].state
  1432. : yylac_stack_.back ());
  1433. // Push the resulting state of the reduction.
  1434. state_type state = yy_lr_goto_state_ (top_state, yyr1_[yyrule]);
  1435. YYCDEBUG << " G" << int (state);
  1436. yylac_stack_.push_back (state);
  1437. }
  1438. }
  1439. // Establish the initial context if no initial context currently exists.
  1440. bool
  1441. parser::yy_lac_establish_ (symbol_kind_type yytoken)
  1442. {
  1443. /* Establish the initial context for the current lookahead if no initial
  1444. context is currently established.
  1445. We define a context as a snapshot of the parser stacks. We define
  1446. the initial context for a lookahead as the context in which the
  1447. parser initially examines that lookahead in order to select a
  1448. syntactic action. Thus, if the lookahead eventually proves
  1449. syntactically unacceptable (possibly in a later context reached via a
  1450. series of reductions), the initial context can be used to determine
  1451. the exact set of tokens that would be syntactically acceptable in the
  1452. lookahead's place. Moreover, it is the context after which any
  1453. further semantic actions would be erroneous because they would be
  1454. determined by a syntactically unacceptable token.
  1455. yy_lac_establish_ should be invoked when a reduction is about to be
  1456. performed in an inconsistent state (which, for the purposes of LAC,
  1457. includes consistent states that don't know they're consistent because
  1458. their default reductions have been disabled).
  1459. For parse.lac=full, the implementation of yy_lac_establish_ is as
  1460. follows. If no initial context is currently established for the
  1461. current lookahead, then check if that lookahead can eventually be
  1462. shifted if syntactic actions continue from the current context. */
  1463. if (!yy_lac_established_)
  1464. {
  1465. #if YYDEBUG
  1466. YYCDEBUG << "LAC: initial context established for "
  1467. << symbol_name (yytoken) << '\n';
  1468. #endif
  1469. yy_lac_established_ = true;
  1470. return yy_lac_check_ (yytoken);
  1471. }
  1472. return true;
  1473. }
  1474. // Discard any previous initial lookahead context.
  1475. void
  1476. parser::yy_lac_discard_ (const char* evt)
  1477. {
  1478. /* Discard any previous initial lookahead context because of Event,
  1479. which may be a lookahead change or an invalidation of the currently
  1480. established initial context for the current lookahead.
  1481. The most common example of a lookahead change is a shift. An example
  1482. of both cases is syntax error recovery. That is, a syntax error
  1483. occurs when the lookahead is syntactically erroneous for the
  1484. currently established initial context, so error recovery manipulates
  1485. the parser stacks to try to find a new initial context in which the
  1486. current lookahead is syntactically acceptable. If it fails to find
  1487. such a context, it discards the lookahead. */
  1488. if (yy_lac_established_)
  1489. {
  1490. YYCDEBUG << "LAC: initial context discarded due to "
  1491. << evt << '\n';
  1492. yy_lac_established_ = false;
  1493. }
  1494. }
  1495. int
  1496. parser::yy_syntax_error_arguments_ (const context& yyctx,
  1497. symbol_kind_type yyarg[], int yyargn) const
  1498. {
  1499. /* There are many possibilities here to consider:
  1500. - If this state is a consistent state with a default action, then
  1501. the only way this function was invoked is if the default action
  1502. is an error action. In that case, don't check for expected
  1503. tokens because there are none.
  1504. - The only way there can be no lookahead present (in yyla) is
  1505. if this state is a consistent state with a default action.
  1506. Thus, detecting the absence of a lookahead is sufficient to
  1507. determine that there is no unexpected or expected token to
  1508. report. In that case, just report a simple "syntax error".
  1509. - Don't assume there isn't a lookahead just because this state is
  1510. a consistent state with a default action. There might have
  1511. been a previous inconsistent state, consistent state with a
  1512. non-default action, or user semantic action that manipulated
  1513. yyla. (However, yyla is currently not documented for users.)
  1514. In the first two cases, it might appear that the current syntax
  1515. error should have been detected in the previous state when
  1516. yy_lac_check was invoked. However, at that time, there might
  1517. have been a different syntax error that discarded a different
  1518. initial context during error recovery, leaving behind the
  1519. current lookahead.
  1520. */
  1521. if (!yyctx.lookahead ().empty ())
  1522. {
  1523. if (yyarg)
  1524. yyarg[0] = yyctx.token ();
  1525. int yyn = yyctx.expected_tokens (yyarg ? yyarg + 1 : yyarg, yyargn - 1);
  1526. return yyn + 1;
  1527. }
  1528. return 0;
  1529. }
  1530. // Generate an error message.
  1531. std::string
  1532. parser::yysyntax_error_ (const context& yyctx) const
  1533. {
  1534. // Its maximum.
  1535. enum { YYARGS_MAX = 5 };
  1536. // Arguments of yyformat.
  1537. symbol_kind_type yyarg[YYARGS_MAX];
  1538. int yycount = yy_syntax_error_arguments_ (yyctx, yyarg, YYARGS_MAX);
  1539. char const* yyformat = YY_NULLPTR;
  1540. switch (yycount)
  1541. {
  1542. #define YYCASE_(N, S) \
  1543. case N: \
  1544. yyformat = S; \
  1545. break
  1546. default: // Avoid compiler warnings.
  1547. YYCASE_ (0, YY_("syntax error"));
  1548. YYCASE_ (1, YY_("syntax error, unexpected %s"));
  1549. YYCASE_ (2, YY_("syntax error, unexpected %s, expecting %s"));
  1550. YYCASE_ (3, YY_("syntax error, unexpected %s, expecting %s or %s"));
  1551. YYCASE_ (4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
  1552. YYCASE_ (5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
  1553. #undef YYCASE_
  1554. }
  1555. std::string yyres;
  1556. // Argument number.
  1557. std::ptrdiff_t yyi = 0;
  1558. for (char const* yyp = yyformat; *yyp; ++yyp)
  1559. if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
  1560. {
  1561. yyres += symbol_name (yyarg[yyi++]);
  1562. ++yyp;
  1563. }
  1564. else
  1565. yyres += *yyp;
  1566. return yyres;
  1567. }
  1568. const signed char parser::yypact_ninf_ = -52;
  1569. const signed char parser::yytable_ninf_ = -12;
  1570. const short
  1571. parser::yypact_[] =
  1572. {
  1573. 3, -52, -41, -39, -52, -52, -3, 5, 5, 5,
  1574. 7, 44, 10, 0, 101, 18, 30, 94, 51, 50,
  1575. -52, 20, -52, 13, -52, 88, 17, -52, -52, 129,
  1576. -52, -52, 2, 85, -52, -52, 1, 1, -52, -52,
  1577. 40, -52, -52, -52, 42, 58, -52, 28, 96, 120,
  1578. 120, 120, 120, 15, -52, -52, -52, -52, -52, -52,
  1579. -52, -52, 120, -52, -52, -52, -52, -52, -52, -52,
  1580. -52, 120, -52, 63, -52, 63, -52, -52, -52, -52,
  1581. -52, -52, -52, 120, -52, -52, -52, -52, 5, -52,
  1582. -52, -52, -52, 120, -52, -52, -52, -52, 3, -52,
  1583. 1, 5, 45, 130, -52, 1, 1, -52, 177, 162,
  1584. -52, 97, 132, -52, -52, -52, -52, 87, -52, -52,
  1585. 1, 5, 5, 5, 5, -52, 5, 5, -52, -52,
  1586. -52, -52, 29, 118, 5, -52, 170, -52, -52, -52,
  1587. 107, 177, 1, 1, 1, 1, 1, 1, 1, -52,
  1588. -52, -51, -52, 177, 119, -52, -52, -52, -52, -52,
  1589. -52, -52, 82, -52, -52, -52, 107, 107, 184, 184,
  1590. -52, -52, -52, -52, -52, -52, -52, -52, -52, -52,
  1591. -52, -52, -52, -52, -52
  1592. };
  1593. const signed char
  1594. parser::yydefact_[] =
  1595. {
  1596. 0, 12, 0, 0, 21, 22, 0, 0, 0, 0,
  1597. 0, 69, 0, 0, 0, 113, 115, 0, 123, 0,
  1598. 47, 0, 124, 0, 28, 0, 0, 3, 10, 9,
  1599. 6, 7, 46, 0, 126, 5, 0, 0, 30, 29,
  1600. 20, 23, 16, 27, 0, 0, 67, 0, 0, 75,
  1601. 75, 75, 75, 0, 51, 76, 79, 77, 78, 80,
  1602. 81, 82, 75, 83, 86, 87, 84, 85, 90, 89,
  1603. 88, 75, 112, 118, 114, 118, 91, 92, 93, 94,
  1604. 95, 96, 97, 75, 120, 122, 121, 119, 0, 108,
  1605. 111, 109, 110, 75, 125, 13, 1, 2, 0, 8,
  1606. 0, 0, 45, 44, 14, 0, 0, 32, 15, 0,
  1607. 19, 18, 0, 68, 62, 64, 63, 0, 65, 74,
  1608. 0, 0, 0, 0, 0, 49, 0, 0, 116, 117,
  1609. 54, 55, 107, 58, 0, 4, 0, 61, 43, 42,
  1610. 40, 41, 0, 0, 0, 0, 0, 0, 0, 31,
  1611. 17, 0, 66, 48, 71, 73, 72, 50, 52, 53,
  1612. 105, 106, 0, 57, 59, 60, 33, 34, 35, 36,
  1613. 37, 38, 39, 25, 26, 24, 70, 98, 101, 99,
  1614. 100, 103, 104, 102, 56
  1615. };
  1616. const short
  1617. parser::yypgoto_[] =
  1618. {
  1619. -52, -52, -52, 98, -52, -52, -52, -7, -14, 168,
  1620. -52, 99, 102, -52, 148, 25, -52, -52, -52, -52,
  1621. -52, -52, -52, -52, 128, -52, 199
  1622. };
  1623. const short
  1624. parser::yydefgoto_[] =
  1625. {
  1626. -1, 25, 26, 27, 28, 29, 30, 107, 108, 31,
  1627. 32, 102, 103, 49, 54, 120, 62, 71, 83, 184,
  1628. 162, 93, 73, 75, 130, 88, 33
  1629. };
  1630. const short
  1631. parser::yytable_[] =
  1632. {
  1633. 40, 41, 42, -11, 1, 53, -11, 37, 43, 2,
  1634. 100, 37, 105, 173, 174, 2, 37, 97, 175, 124,
  1635. 98, 106, 34, 109, 35, 3, 4, 5, 6, 7,
  1636. 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
  1637. 18, 19, 20, 55, 56, 116, 117, 50, 160, 161,
  1638. 51, 52, 50, 57, 58, 51, 52, 59, 60, 21,
  1639. 22, 61, 101, 45, 38, 21, 22, 72, 38, 23,
  1640. 39, 24, 44, 38, 39, 121, 122, 123, 74, 39,
  1641. 95, 133, 84, 94, 46, 110, 136, 126, 96, 85,
  1642. 104, 140, 141, 89, 137, 90, 127, 47, 48, 111,
  1643. 113, 86, 87, 91, 92, 101, 153, 112, 132, 128,
  1644. 129, 114, 115, 118, 154, 155, 156, 157, 134, 158,
  1645. 159, 146, 147, 148, 119, 177, 178, 164, 166, 167,
  1646. 168, 169, 170, 171, 172, 179, 180, 76, 100, 181,
  1647. 182, 152, 150, 183, 63, 64, 65, 77, 78, 79,
  1648. 80, 81, 82, 151, 66, 67, 68, 69, 70, 11,
  1649. 12, 13, 14, 15, 16, 17, 18, 19, 20, 149,
  1650. 163, 176, 142, 143, 144, 145, 146, 147, 148, 165,
  1651. 142, 143, 144, 145, 146, 147, 148, 142, 143, 144,
  1652. 145, 146, 147, 148, 142, 143, 135, 99, 146, 147,
  1653. 148, 125, 139, 131, 138, 36
  1654. };
  1655. const unsigned char
  1656. parser::yycheck_[] =
  1657. {
  1658. 7, 8, 9, 0, 1, 12, 3, 6, 1, 12,
  1659. 8, 6, 11, 64, 65, 12, 6, 0, 69, 4,
  1660. 3, 20, 63, 37, 63, 22, 23, 24, 25, 26,
  1661. 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
  1662. 37, 38, 39, 43, 44, 17, 18, 37, 19, 20,
  1663. 40, 41, 37, 53, 54, 40, 41, 57, 58, 62,
  1664. 63, 61, 60, 19, 63, 62, 63, 49, 63, 66,
  1665. 69, 68, 65, 63, 69, 50, 51, 52, 48, 69,
  1666. 67, 88, 31, 63, 40, 45, 100, 62, 0, 38,
  1667. 5, 105, 106, 43, 101, 45, 71, 53, 54, 59,
  1668. 42, 50, 51, 53, 54, 60, 120, 65, 83, 46,
  1669. 47, 53, 54, 17, 121, 122, 123, 124, 93, 126,
  1670. 127, 14, 15, 16, 4, 43, 44, 134, 142, 143,
  1671. 144, 145, 146, 147, 148, 53, 54, 43, 8, 57,
  1672. 58, 54, 45, 61, 43, 44, 45, 53, 54, 55,
  1673. 56, 57, 58, 21, 53, 54, 55, 56, 57, 30,
  1674. 31, 32, 33, 34, 35, 36, 37, 38, 39, 7,
  1675. 52, 52, 10, 11, 12, 13, 14, 15, 16, 9,
  1676. 10, 11, 12, 13, 14, 15, 16, 10, 11, 12,
  1677. 13, 14, 15, 16, 10, 11, 98, 29, 14, 15,
  1678. 16, 53, 103, 75, 102, 6
  1679. };
  1680. const signed char
  1681. parser::yystos_[] =
  1682. {
  1683. 0, 1, 12, 22, 23, 24, 25, 26, 27, 28,
  1684. 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
  1685. 39, 62, 63, 66, 68, 71, 72, 73, 74, 75,
  1686. 76, 79, 80, 96, 63, 63, 96, 6, 63, 69,
  1687. 77, 77, 77, 1, 65, 19, 40, 53, 54, 83,
  1688. 37, 40, 41, 77, 84, 43, 44, 53, 54, 57,
  1689. 58, 61, 86, 43, 44, 45, 53, 54, 55, 56,
  1690. 57, 87, 49, 92, 48, 93, 43, 53, 54, 55,
  1691. 56, 57, 58, 88, 31, 38, 50, 51, 95, 43,
  1692. 45, 53, 54, 91, 63, 67, 0, 0, 3, 79,
  1693. 8, 60, 81, 82, 5, 11, 20, 77, 78, 78,
  1694. 45, 59, 65, 42, 53, 54, 17, 18, 17, 4,
  1695. 85, 85, 85, 85, 4, 84, 85, 85, 46, 47,
  1696. 94, 94, 85, 77, 85, 73, 78, 77, 82, 81,
  1697. 78, 78, 10, 11, 12, 13, 14, 15, 16, 7,
  1698. 45, 21, 54, 78, 77, 77, 77, 77, 77, 77,
  1699. 19, 20, 90, 52, 77, 9, 78, 78, 78, 78,
  1700. 78, 78, 78, 64, 65, 69, 52, 43, 44, 53,
  1701. 54, 57, 58, 61, 89
  1702. };
  1703. const signed char
  1704. parser::yyr1_[] =
  1705. {
  1706. 0, 70, 71, 72, 72, 73, 73, 73, 73, 73,
  1707. 73, 73, 73, 74, 75, 76, 76, 76, 76, 76,
  1708. 76, 76, 76, 76, 76, 76, 76, 76, 76, 77,
  1709. 77, 77, 78, 78, 78, 78, 78, 78, 78, 78,
  1710. 78, 78, 79, 79, 79, 79, 79, 80, 80, 80,
  1711. 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
  1712. 81, 82, 83, 83, 83, 83, 83, 83, 83, 83,
  1713. 84, 84, 84, 84, 85, 85, 86, 86, 86, 86,
  1714. 86, 86, 86, 87, 87, 87, 87, 87, 87, 87,
  1715. 87, 88, 88, 88, 88, 88, 88, 88, 89, 89,
  1716. 89, 89, 89, 89, 89, 90, 90, 90, 91, 91,
  1717. 91, 91, 92, 92, 93, 93, 94, 94, 94, 95,
  1718. 95, 95, 95, 95, 96, 96, 96
  1719. };
  1720. const signed char
  1721. parser::yyr2_[] =
  1722. {
  1723. 0, 2, 2, 1, 3, 2, 1, 1, 2, 1,
  1724. 1, 0, 1, 2, 2, 3, 2, 4, 3, 3,
  1725. 2, 1, 1, 2, 5, 5, 5, 2, 1, 1,
  1726. 1, 3, 1, 3, 3, 3, 3, 3, 3, 3,
  1727. 2, 2, 3, 3, 2, 2, 1, 1, 4, 3,
  1728. 4, 2, 4, 4, 3, 3, 5, 4, 3, 4,
  1729. 3, 2, 2, 2, 2, 2, 3, 1, 2, 0,
  1730. 4, 3, 3, 3, 1, 0, 1, 1, 1, 1,
  1731. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1732. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  1733. 1, 1, 1, 1, 1, 1, 1, 0, 1, 1,
  1734. 1, 1, 1, 0, 1, 0, 1, 1, 0, 1,
  1735. 1, 1, 1, 0, 1, 2, 2
  1736. };
  1737. #if YYDEBUG || 1
  1738. // YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
  1739. // First, the terminals, then, starting at \a YYNTOKENS, nonterminals.
  1740. const char*
  1741. const parser::yytname_[] =
  1742. {
  1743. "\"end of file\"", "error", "\"invalid token\"", "\"end of line\"",
  1744. "\",\"", "\":\"", "\"(\"", "\")\"", "\"[\"", "\"]\"", "\"+\"", "\"-\"",
  1745. "\"*\"", "\"/\"", "\"|\"", "\"&\"", "\"^\"", "\"--\"", "\"!=\"", "\"!\"",
  1746. "\"::\"", "\"=\"", "\".program\"", "\".wrap_target\"", "\".wrap\"",
  1747. "\".define\"", "\".side_set\"", "\".word\"", "\".origin\"",
  1748. "\".lang_opt\"", "\"jmp\"", "\"wait\"", "\"in\"", "\"out\"", "\"push\"",
  1749. "\"pull\"", "\"mov\"", "\"irq\"", "\"set\"", "\"nop\"", "\"pin\"",
  1750. "\"gpio\"", "\"osre\"", "\"pins\"", "\"null\"", "\"pindirs\"",
  1751. "\"block\"", "\"noblock\"", "\"ifempty\"", "\"iffull\"", "\"nowait\"",
  1752. "\"clear\"", "\"rel\"", "\"x\"", "\"y\"", "\"exec\"", "\"pc\"",
  1753. "\"isr\"", "\"osr\"", "\"opt\"", "\"side\"", "\"status\"", "\"public\"",
  1754. "\"identifier\"", "\"string\"", "\"text\"", "\"code block\"", "\"%}\"",
  1755. "UNKNOWN_DIRECTIVE", "\"integer\"", "$accept", "file", "lines", "line",
  1756. "code_block", "label_decl", "directive", "value", "expression",
  1757. "instruction", "base_instruction", "delay", "sideset", "condition",
  1758. "wait_source", "comma", "in_source", "out_target", "mov_target",
  1759. "mov_source", "mov_op", "set_target", "if_full", "if_empty", "blocking",
  1760. "irq_modifiers", "symbol_def", YY_NULLPTR
  1761. };
  1762. #endif
  1763. #if YYDEBUG
  1764. const short
  1765. parser::yyrline_[] =
  1766. {
  1767. 0, 136, 136, 140, 141, 144, 145, 146, 147, 148,
  1768. 149, 150, 151, 155, 159, 162, 163, 164, 165, 166,
  1769. 167, 168, 169, 170, 171, 172, 173, 174, 175, 180,
  1770. 181, 182, 186, 187, 188, 189, 190, 191, 192, 193,
  1771. 194, 195, 199, 200, 201, 202, 203, 207, 208, 209,
  1772. 210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
  1773. 224, 228, 232, 233, 234, 235, 236, 237, 238, 239,
  1774. 243, 244, 245, 246, 248, 248, 251, 252, 253, 254,
  1775. 255, 256, 257, 260, 261, 262, 263, 264, 265, 266,
  1776. 267, 270, 271, 272, 273, 274, 275, 276, 279, 280,
  1777. 281, 282, 283, 284, 285, 289, 290, 291, 295, 296,
  1778. 297, 298, 302, 303, 307, 308, 312, 313, 314, 318,
  1779. 319, 320, 321, 322, 326, 327, 328
  1780. };
  1781. void
  1782. parser::yy_stack_print_ () const
  1783. {
  1784. *yycdebug_ << "Stack now";
  1785. for (stack_type::const_iterator
  1786. i = yystack_.begin (),
  1787. i_end = yystack_.end ();
  1788. i != i_end; ++i)
  1789. *yycdebug_ << ' ' << int (i->state);
  1790. *yycdebug_ << '\n';
  1791. }
  1792. void
  1793. parser::yy_reduce_print_ (int yyrule) const
  1794. {
  1795. int yylno = yyrline_[yyrule];
  1796. int yynrhs = yyr2_[yyrule];
  1797. // Print the symbols being reduced, and their result.
  1798. *yycdebug_ << "Reducing stack by rule " << yyrule - 1
  1799. << " (line " << yylno << "):\n";
  1800. // The symbols being reduced.
  1801. for (int yyi = 0; yyi < yynrhs; yyi++)
  1802. YY_SYMBOL_PRINT (" $" << yyi + 1 << " =",
  1803. yystack_[(yynrhs) - (yyi + 1)]);
  1804. }
  1805. #endif // YYDEBUG
  1806. } // yy
  1807. void yy::parser::error(const location_type& l, const std::string& m)
  1808. {
  1809. if (l.begin.filename) {
  1810. std::cerr << l << ": " << m << '\n';
  1811. pioasm.error_count++;
  1812. if (l.begin.line == l.end.line && *l.begin.filename == *l.end.filename) {
  1813. std::ifstream file(l.begin.filename->c_str());
  1814. std::string line;
  1815. for(int i = 0; i < l.begin.line; ++i) {
  1816. std::getline(file, line);
  1817. }
  1818. fprintf(stderr, "%5d | %s\n", l.begin.line, line.c_str());
  1819. fprintf(stderr, "%5s | %*s", "", l.begin.column, "^");
  1820. for (int i = l.begin.column; i < l.end.column - 1; i++) {
  1821. putc ('~', stderr);
  1822. }
  1823. putc ('\n', stderr);
  1824. }
  1825. } else {
  1826. std::cerr << m << '\n';
  1827. }
  1828. }