rubytable.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Copyright 2007 Victor Hugo Borja <vic@rubyforge.org>
  3. * 2006-2007 Adrian Thurston <thurston@complang.org>
  4. */
  5. /* This file is part of Ragel.
  6. *
  7. * Ragel is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * Ragel is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with Ragel; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #ifndef _RUBY_TABCODEGEN_H
  22. #define _RUBY_TABCODEGEN_H
  23. #include <iostream>
  24. #include <string>
  25. #include <stdio.h>
  26. #include "common.h"
  27. #include "gendata.h"
  28. #include "rubycodegen.h"
  29. using std::string;
  30. using std::ostream;
  31. /*
  32. * RubyCodeGen
  33. */
  34. class RubyTabCodeGen : public RubyCodeGen
  35. {
  36. public:
  37. RubyTabCodeGen( ostream &out ) :
  38. RubyCodeGen(out) {}
  39. virtual ~RubyTabCodeGen() {}
  40. public:
  41. void BREAK( ostream &ret, int targState );
  42. void GOTO( ostream &ret, int gotoDest, bool inFinish );
  43. void GOTO_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish );
  44. void CALL( ostream &ret, int callDest, int targState, bool inFinish );
  45. void CALL_EXPR( ostream &ret, GenInlineItem *ilItem, int targState, bool inFinish );
  46. void RET( ostream &ret, bool inFinish );
  47. void COND_TRANSLATE();
  48. void LOCATE_TRANS();
  49. virtual void writeExec();
  50. virtual void writeData();
  51. protected:
  52. virtual std::ostream &TO_STATE_ACTION_SWITCH();
  53. virtual std::ostream &FROM_STATE_ACTION_SWITCH();
  54. virtual std::ostream &EOF_ACTION_SWITCH();
  55. virtual std::ostream &ACTION_SWITCH();
  56. std::ostream &COND_KEYS();
  57. std::ostream &COND_SPACES();
  58. std::ostream &KEYS();
  59. std::ostream &INDICIES();
  60. std::ostream &COND_OFFSETS();
  61. std::ostream &KEY_OFFSETS();
  62. std::ostream &INDEX_OFFSETS();
  63. std::ostream &COND_LENS();
  64. std::ostream &SINGLE_LENS();
  65. std::ostream &RANGE_LENS();
  66. std::ostream &TO_STATE_ACTIONS();
  67. std::ostream &FROM_STATE_ACTIONS();
  68. std::ostream &EOF_ACTIONS();
  69. std::ostream &EOF_TRANS();
  70. std::ostream &TRANS_TARGS();
  71. std::ostream &TRANS_ACTIONS();
  72. std::ostream &TRANS_TARGS_WI();
  73. std::ostream &TRANS_ACTIONS_WI();
  74. void NEXT( ostream &ret, int nextDest, bool inFinish );
  75. void NEXT_EXPR( ostream &ret, GenInlineItem *ilItem, bool inFinish );
  76. virtual int TO_STATE_ACTION( RedStateAp *state );
  77. virtual int FROM_STATE_ACTION( RedStateAp *state );
  78. virtual int EOF_ACTION( RedStateAp *state );
  79. private:
  80. string array_type;
  81. string array_name;
  82. public:
  83. void EXEC( ostream &ret, GenInlineItem *item, int targState, int inFinish );
  84. void EXECTE( ostream &ret, GenInlineItem *item, int targState, int inFinish );
  85. void LM_SWITCH( ostream &ret, GenInlineItem *item, int targState, int inFinish );
  86. void SET_ACT( ostream &ret, GenInlineItem *item );
  87. void INIT_TOKSTART( ostream &ret, GenInlineItem *item );
  88. void INIT_ACT( ostream &ret, GenInlineItem *item );
  89. void SET_TOKSTART( ostream &ret, GenInlineItem *item );
  90. void SET_TOKEND( ostream &ret, GenInlineItem *item );
  91. void GET_TOKEND( ostream &ret, GenInlineItem *item );
  92. void SUB_ACTION( ostream &ret, GenInlineItem *item,
  93. int targState, bool inFinish );
  94. };
  95. #endif
  96. /*
  97. * Local Variables:
  98. * mode: c++
  99. * indent-tabs-mode: 1
  100. * c-file-style: "bsd"
  101. * End:
  102. */