cdtable.h 3.4 KB

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