cdipgoto.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Copyright 2001-2006 Adrian Thurston <thurston@complang.org>
  3. * 2004 Erich Ocean <eric.ocean@ampede.com>
  4. * 2005 Alan West <alan@alanz.com>
  5. */
  6. /* This file is part of Ragel.
  7. *
  8. * Ragel is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * Ragel is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with Ragel; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #ifndef _CDIPGOTO_H
  23. #define _CDIPGOTO_H
  24. #include <iostream>
  25. #include "cdgoto.h"
  26. /* Forwards. */
  27. struct CodeGenData;
  28. /*
  29. * class FGotoCodeGen
  30. */
  31. class IpGotoCodeGen : public GotoCodeGen
  32. {
  33. public:
  34. IpGotoCodeGen( ostream &out ) : FsmCodeGen(out), GotoCodeGen(out) {}
  35. std::ostream &EXIT_STATES();
  36. std::ostream &TRANS_GOTO( RedTransAp *trans, int level );
  37. std::ostream &FINISH_CASES();
  38. std::ostream &AGAIN_CASES();
  39. void GOTO( ostream &ret, int gotoDest, bool inFinish );
  40. void CALL( ostream &ret, int callDest, int targState, bool inFinish );
  41. void NEXT( ostream &ret, int nextDest, bool inFinish );
  42. void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish );
  43. void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish );
  44. void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish );
  45. void RET( ostream &ret, bool inFinish );
  46. void CURS( ostream &ret, bool inFinish );
  47. void TARGS( ostream &ret, bool inFinish, int targState );
  48. void BREAK( ostream &ret, int targState, bool csForced );
  49. virtual void writeData();
  50. virtual void writeExec();
  51. protected:
  52. bool useAgainLabel();
  53. void EOF_CHECK( ostream &ret, int gotoDest );
  54. /* Called from GotoCodeGen::STATE_GOTOS just before writing the gotos for
  55. * each state. */
  56. bool IN_TRANS_ACTIONS( RedStateAp *state );
  57. void GOTO_HEADER( RedStateAp *state );
  58. void STATE_GOTO_ERROR();
  59. /* Set up labelNeeded flag for each state. */
  60. void setLabelsNeeded( GenInlineList *inlineList );
  61. void setLabelsNeeded();
  62. };
  63. /*
  64. * class CIpGotoCodeGen
  65. */
  66. struct CIpGotoCodeGen
  67. : public IpGotoCodeGen, public CCodeGen
  68. {
  69. CIpGotoCodeGen( ostream &out ) :
  70. FsmCodeGen(out), IpGotoCodeGen(out), CCodeGen(out) {}
  71. };
  72. /*
  73. * class DIpGotoCodeGen
  74. */
  75. struct DIpGotoCodeGen
  76. : public IpGotoCodeGen, public DCodeGen
  77. {
  78. DIpGotoCodeGen( ostream &out ) :
  79. FsmCodeGen(out), IpGotoCodeGen(out), DCodeGen(out) {}
  80. };
  81. /*
  82. * class D2IpGotoCodeGen
  83. */
  84. struct D2IpGotoCodeGen
  85. : public IpGotoCodeGen, public D2CodeGen
  86. {
  87. D2IpGotoCodeGen( ostream &out ) :
  88. FsmCodeGen(out), IpGotoCodeGen(out), D2CodeGen(out) {}
  89. };
  90. #endif