cdflat.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Copyright 2004-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 _CDFLAT_H
  23. #define _CDFLAT_H
  24. #include <iostream>
  25. #include "cdcodegen.h"
  26. /* Forwards. */
  27. struct CodeGenData;
  28. struct NameInst;
  29. struct RedTransAp;
  30. struct RedStateAp;
  31. /*
  32. * FlatCodeGen
  33. */
  34. class FlatCodeGen : virtual public FsmCodeGen
  35. {
  36. public:
  37. FlatCodeGen( ostream &out ) : FsmCodeGen(out) {}
  38. virtual ~FlatCodeGen() { }
  39. protected:
  40. std::ostream &TO_STATE_ACTION_SWITCH();
  41. std::ostream &FROM_STATE_ACTION_SWITCH();
  42. std::ostream &EOF_ACTION_SWITCH();
  43. std::ostream &ACTION_SWITCH();
  44. std::ostream &KEYS();
  45. std::ostream &INDICIES();
  46. std::ostream &FLAT_INDEX_OFFSET();
  47. std::ostream &KEY_SPANS();
  48. std::ostream &TO_STATE_ACTIONS();
  49. std::ostream &FROM_STATE_ACTIONS();
  50. std::ostream &EOF_ACTIONS();
  51. std::ostream &EOF_TRANS();
  52. std::ostream &TRANS_TARGS();
  53. std::ostream &TRANS_ACTIONS();
  54. void LOCATE_TRANS();
  55. std::ostream &COND_INDEX_OFFSET();
  56. void COND_TRANSLATE();
  57. std::ostream &CONDS();
  58. std::ostream &COND_KEYS();
  59. std::ostream &COND_KEY_SPANS();
  60. void GOTO( ostream &ret, int gotoDest, bool inFinish );
  61. void CALL( ostream &ret, int callDest, int targState, bool inFinish );
  62. void NEXT( ostream &ret, int nextDest, bool inFinish );
  63. void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish );
  64. void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish );
  65. void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish );
  66. void CURS( ostream &ret, bool inFinish );
  67. void TARGS( ostream &ret, bool inFinish, int targState );
  68. void RET( ostream &ret, bool inFinish );
  69. void BREAK( ostream &ret, int targState, bool csForced );
  70. virtual std::ostream &TO_STATE_ACTION( RedStateAp *state );
  71. virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state );
  72. virtual std::ostream &EOF_ACTION( RedStateAp *state );
  73. virtual std::ostream &TRANS_ACTION( RedTransAp *trans );
  74. virtual void writeData();
  75. virtual void writeExec();
  76. };
  77. /*
  78. * CFlatCodeGen
  79. */
  80. struct CFlatCodeGen
  81. : public FlatCodeGen, public CCodeGen
  82. {
  83. CFlatCodeGen( ostream &out ) :
  84. FsmCodeGen(out), FlatCodeGen(out), CCodeGen(out) {}
  85. };
  86. /*
  87. * DFlatCodeGen
  88. */
  89. struct DFlatCodeGen
  90. : public FlatCodeGen, public DCodeGen
  91. {
  92. DFlatCodeGen( ostream &out ) :
  93. FsmCodeGen(out), FlatCodeGen(out), DCodeGen(out) {}
  94. };
  95. /*
  96. * D2FlatCodeGen
  97. */
  98. struct D2FlatCodeGen
  99. : public FlatCodeGen, public D2CodeGen
  100. {
  101. D2FlatCodeGen( ostream &out ) :
  102. FsmCodeGen(out), FlatCodeGen(out), D2CodeGen(out) {}
  103. };
  104. #endif