Beginning of transition rules
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@ namespace Parser {
|
|||||||
class Action
|
class Action
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~Action();
|
virtual ~Action() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class Ignore : public Action {};
|
class Ignore : public Action {};
|
||||||
|
|||||||
@@ -1 +1,37 @@
|
|||||||
#include "parserstate.hpp"
|
#include "parserstate.hpp"
|
||||||
|
|
||||||
|
using namespace Parser;
|
||||||
|
|
||||||
|
Transition State::anywhere_rule( wchar_t ch )
|
||||||
|
{
|
||||||
|
if ( (ch == 0x18) || (ch == 0x1A)
|
||||||
|
|| ((0x80 <= ch) && (ch <= 0x8F))
|
||||||
|
|| ((0x91 <= ch) && (ch <= 0x97))
|
||||||
|
|| (ch == 0x99) || (ch == 0x9A) ) {
|
||||||
|
return Transition( Execute(), new Ground() );
|
||||||
|
} else if ( ch == 0x9C ) {
|
||||||
|
return Transition( Ignore(), new Ground() );
|
||||||
|
} else if ( ch == 0x1B ) {
|
||||||
|
return Transition( Ignore(), new Escape() );
|
||||||
|
} else if ( (ch == 0x98) || (ch == 0x9E) || (ch == 0x9F) ) {
|
||||||
|
return Transition( Ignore(), new SOS_PM_APC_String() );
|
||||||
|
} else if ( ch == 0x90 ) {
|
||||||
|
return Transition( Ignore(), new DCS_Entry() );
|
||||||
|
} else if ( ch == 0x9D ) {
|
||||||
|
return Transition( Ignore(), new OSC_String() );
|
||||||
|
} else if ( ch == 0x9B ) {
|
||||||
|
return Transition( Ignore(), new CSI_Entry() );
|
||||||
|
}
|
||||||
|
|
||||||
|
return Transition( Ignore(), NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
Transition State::input( wchar_t ch )
|
||||||
|
{
|
||||||
|
Transition any = anywhere_rule( ch );
|
||||||
|
if ( any.next_state ) {
|
||||||
|
return any;
|
||||||
|
} else {
|
||||||
|
return this->input_state_rule( ch );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+9
-9
@@ -6,23 +6,23 @@
|
|||||||
namespace Parser {
|
namespace Parser {
|
||||||
class State
|
class State
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
virtual Transition input_state_rule( wchar_t ch ) { ch = ch; return Transition( Ignore(), NULL ); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual Action enter( void ) { return Ignore(); };
|
virtual Action enter( void ) { return Ignore(); };
|
||||||
virtual Action leave( void ) { return Ignore(); };
|
virtual Action leave( void ) { return Ignore(); };
|
||||||
|
|
||||||
virtual Transition input( wchar_t ch __attribute__ ((unused)) ) {
|
Transition input( wchar_t ch );
|
||||||
return IgnoreTransition();
|
Transition anywhere_rule( wchar_t ch );
|
||||||
}
|
|
||||||
|
|
||||||
static Transition anywhere( wchar_t ch );
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~State();
|
virtual ~State() {};
|
||||||
};
|
};
|
||||||
|
|
||||||
class Ground : public State {};
|
class Ground : public State {};
|
||||||
class Esc : public State {};
|
class Escape : public State {};
|
||||||
class Esc_Intermediate : public State {};
|
class Escape_Intermediate : public State {};
|
||||||
|
|
||||||
class CSI_Entry : public State {};
|
class CSI_Entry : public State {};
|
||||||
class CSI_Param : public State {};
|
class CSI_Param : public State {};
|
||||||
@@ -35,7 +35,7 @@ namespace Parser {
|
|||||||
class DCS_Passthrough : public State {};
|
class DCS_Passthrough : public State {};
|
||||||
class DCS_Ignore : public State {};
|
class DCS_Ignore : public State {};
|
||||||
|
|
||||||
class OCS_String : public State {};
|
class OSC_String : public State {};
|
||||||
class SOS_PM_APC_String : public State {};
|
class SOS_PM_APC_String : public State {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-13
@@ -5,29 +5,24 @@
|
|||||||
|
|
||||||
#include "parseraction.hpp"
|
#include "parseraction.hpp"
|
||||||
|
|
||||||
|
namespace Parser {
|
||||||
class State;
|
class State;
|
||||||
|
|
||||||
namespace Parser {
|
|
||||||
class Transition
|
class Transition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Action action;
|
Action action;
|
||||||
State *next_state;
|
State *next_state;
|
||||||
|
|
||||||
Transition();
|
Transition( const Transition &x )
|
||||||
Transition( const Transition & );
|
: action( x.action ),
|
||||||
|
next_state( x.next_state ) {}
|
||||||
bool operator=( const Transition & );
|
bool operator=( const Transition & );
|
||||||
virtual ~Transition();
|
virtual ~Transition() {}
|
||||||
};
|
|
||||||
|
|
||||||
class IgnoreTransition : public Transition
|
Transition( Action s_action, State *s_next_state )
|
||||||
{
|
: action( s_action ), next_state( s_next_state )
|
||||||
public:
|
{}
|
||||||
IgnoreTransition()
|
|
||||||
{
|
|
||||||
action = Ignore();
|
|
||||||
next_state = NULL;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user