goipgoto.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 _GOIPGOTO_H
  23. #define _GOIPGOTO_H
  24. #include <iostream>
  25. #include "gogoto.h"
  26. /* Forwards. */
  27. struct CodeGenData;
  28. class GoIpGotoCodeGen
  29. : public GoGotoCodeGen
  30. {
  31. public:
  32. GoIpGotoCodeGen( ostream &out )
  33. : GoGotoCodeGen(out) {}
  34. std::ostream &EXIT_STATES();
  35. std::ostream &TRANS_GOTO( RedTransAp *trans, int level );
  36. int TRANS_NR( RedTransAp *trans );
  37. std::ostream &FINISH_CASES( int level );
  38. std::ostream &AGAIN_CASES( int level );
  39. std::ostream &STATE_GOTOS_SWITCH( int level );
  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 RET( ostream &ret, bool inFinish );
  47. void CURS( ostream &ret, bool inFinish );
  48. void TARGS( ostream &ret, bool inFinish, int targState );
  49. void BREAK( ostream &ret, int targState, bool csForced );
  50. virtual void writeData();
  51. virtual void writeExec();
  52. protected:
  53. bool useAgainLabel();
  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, int level );
  58. void STATE_GOTO_ERROR( int level );
  59. /* Set up labelNeeded flag for each state. */
  60. void setLabelsNeeded( GenInlineList *inlineList );
  61. void setLabelsNeeded();
  62. };
  63. #endif