rbxgoto.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright 2007 Victor Hugo Borja <vic@rubyforge.org>
  3. * 2006-2007 Adrian Thurston <thurston@complang.org>
  4. */
  5. /* This file is part of Ragel.
  6. *
  7. * Ragel 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 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * Ragel 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 Ragel; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #ifndef _RBX_GOTOCODEGEN_H
  22. #define _RBX_GOTOCODEGEN_H
  23. #include <iostream>
  24. #include <string>
  25. #include "rubycodegen.h"
  26. using std::string;
  27. class RbxGotoCodeGen : public RubyCodeGen
  28. {
  29. public:
  30. RbxGotoCodeGen( ostream &out ) : RubyCodeGen(out) {}
  31. virtual ~RbxGotoCodeGen() {}
  32. std::ostream &TO_STATE_ACTION_SWITCH();
  33. std::ostream &FROM_STATE_ACTION_SWITCH();
  34. std::ostream &EOF_ACTION_SWITCH();
  35. std::ostream &ACTION_SWITCH();
  36. std::ostream &STATE_GOTOS();
  37. std::ostream &TRANSITIONS();
  38. std::ostream &EXEC_FUNCS();
  39. std::ostream &FINISH_CASES();
  40. void GOTO( ostream &ret, int gotoDest, bool inFinish );
  41. void CALL( ostream &ret, int callDest, int targState, bool inFinish );
  42. void NEXT( ostream &ret, int nextDest, bool inFinish );
  43. void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish );
  44. void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish );
  45. void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish );
  46. void CURS( ostream &ret, bool inFinish );
  47. void TARGS( ostream &ret, bool inFinish, int targState );
  48. void RET( ostream &ret, bool inFinish );
  49. void BREAK( ostream &ret, int targState );
  50. int TO_STATE_ACTION( RedStateAp *state );
  51. int FROM_STATE_ACTION( RedStateAp *state );
  52. int EOF_ACTION( RedStateAp *state );
  53. void COND_TRANSLATE( GenStateCond *stateCond, int level );
  54. void emitCondBSearch( RedStateAp *state, int level, int low, int high );
  55. void STATE_CONDS( RedStateAp *state, bool genDefault );
  56. virtual std::ostream &TRANS_GOTO( RedTransAp *trans, int level );
  57. void emitSingleSwitch( RedStateAp *state );
  58. void emitRangeBSearch( RedStateAp *state, int level, int low, int high );
  59. /* Called from STATE_GOTOS just before writing the gotos */
  60. virtual void GOTO_HEADER( RedStateAp *state );
  61. virtual void STATE_GOTO_ERROR();
  62. virtual void writeData();
  63. virtual void writeEOF();
  64. virtual void writeExec();
  65. std::ostream &TO_STATE_ACTIONS();
  66. std::ostream &FROM_STATE_ACTIONS();
  67. std::ostream &EOF_ACTIONS();
  68. private:
  69. ostream &rbxGoto(ostream &out, string label);
  70. ostream &rbxLabel(ostream &out, string label);
  71. };
  72. /*
  73. * Local Variables:
  74. * mode: c++
  75. * indent-tabs-mode: 1
  76. * c-file-style: "bsd"
  77. * End:
  78. */
  79. #endif