mlflat.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 _MLFLAT_H
  23. #define _MLFLAT_H
  24. #include <iostream>
  25. #include "mlcodegen.h"
  26. /* Forwards. */
  27. //struct CodeGenData;
  28. //struct NameInst;
  29. //struct RedTransAp;
  30. //struct RedStateAp;
  31. /*
  32. * OCamlFlatCodeGen
  33. */
  34. class OCamlFlatCodeGen : public OCamlCodeGen
  35. {
  36. public:
  37. OCamlFlatCodeGen( ostream &out ) : OCamlCodeGen(out) {}
  38. virtual ~OCamlFlatCodeGen() { }
  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 );
  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. void initVarTypes();
  77. string slenType, transType, indsType, condsType;
  78. };
  79. #endif