csgoto.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 _GOTOCODEGEN_H
  23. #define _GOTOCODEGEN_H
  24. #include <iostream>
  25. #include "cscodegen.h"
  26. /* Forwards. */
  27. struct CodeGenData;
  28. struct NameInst;
  29. struct RedTransAp;
  30. struct RedStateAp;
  31. struct GenStateCond;
  32. /*
  33. * Goto driven fsm.
  34. */
  35. class CSharpGotoCodeGen : virtual public CSharpFsmCodeGen, public CSharpCodeGen
  36. {
  37. public:
  38. CSharpGotoCodeGen( ostream &out ) : CSharpFsmCodeGen(out), CSharpCodeGen(out) {}
  39. std::ostream &TO_STATE_ACTION_SWITCH();
  40. std::ostream &FROM_STATE_ACTION_SWITCH();
  41. std::ostream &EOF_ACTION_SWITCH();
  42. std::ostream &ACTION_SWITCH();
  43. std::ostream &STATE_GOTOS();
  44. std::ostream &TRANSITIONS();
  45. std::ostream &EXEC_FUNCS();
  46. std::ostream &FINISH_CASES();
  47. void GOTO( ostream &ret, int gotoDest, bool inFinish );
  48. void CALL( ostream &ret, int callDest, int targState, bool inFinish );
  49. void NEXT( ostream &ret, int nextDest, bool inFinish );
  50. void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish );
  51. void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish );
  52. void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish );
  53. void CURS( ostream &ret, bool inFinish );
  54. void TARGS( ostream &ret, bool inFinish, int targState );
  55. void RET( ostream &ret, bool inFinish );
  56. void BREAK( ostream &ret, int targState );
  57. virtual unsigned int TO_STATE_ACTION( RedStateAp *state );
  58. virtual unsigned int FROM_STATE_ACTION( RedStateAp *state );
  59. virtual unsigned int EOF_ACTION( RedStateAp *state );
  60. std::ostream &TO_STATE_ACTIONS();
  61. std::ostream &FROM_STATE_ACTIONS();
  62. std::ostream &EOF_ACTIONS();
  63. void COND_TRANSLATE( GenStateCond *stateCond, int level );
  64. void emitCondBSearch( RedStateAp *state, int level, int low, int high );
  65. void STATE_CONDS( RedStateAp *state, bool genDefault );
  66. virtual std::ostream &TRANS_GOTO( RedTransAp *trans, int level );
  67. void emitSingleSwitch( RedStateAp *state );
  68. void emitRangeBSearch( RedStateAp *state, int level, int low, int high );
  69. /* Called from STATE_GOTOS just before writing the gotos */
  70. virtual void GOTO_HEADER( RedStateAp *state );
  71. virtual void STATE_GOTO_ERROR();
  72. virtual void writeData();
  73. virtual void writeExec();
  74. };
  75. #endif