Make each state a singleton instead of constructing anew each time

This commit is contained in:
Keith Winstein
2011-01-09 04:16:07 -05:00
parent f2ceffc5d9
commit 2f70137df0
4 changed files with 106 additions and 40 deletions
+9
View File
@@ -4,10 +4,13 @@
#include "parsertransition.hpp"
namespace Parser {
class StateFamily;
class State
{
protected:
virtual Transition input_state_rule( wchar_t ch ) = 0;
StateFamily *family;
private:
virtual Action enter( void ) { return Ignore(); };
@@ -17,7 +20,13 @@ namespace Parser {
Transition anywhere_rule( wchar_t ch );
public:
void setfamily( StateFamily *s_family ) { family = s_family; }
State() : family( NULL ) {};
virtual ~State() {};
State( const State & );
bool operator=( const State & );
};
class Ground : public State {