Action names

This commit is contained in:
Keith Winstein
2011-01-10 00:24:25 -05:00
parent d8ac8c15c2
commit 2ce73ca1d5
5 changed files with 70 additions and 20 deletions
+3
View File
@@ -1,4 +1,5 @@
#include <vector>
#include <iostream>
#include "parser.hpp"
@@ -12,5 +13,7 @@ int main( void )
b = parser.input( 'y' );
c = parser.input( 'z' );
std::cout << a[0].name;
return 0;
}
+51 -15
View File
@@ -1,27 +1,63 @@
#ifndef PARSERACTION_HPP
#define PARSERACTION_HPP
#include <string>
namespace Parser {
class Action
{
public:
virtual ~Action() {}
bool char_present;
wchar_t ch;
std::string name;
Action() : char_present( false ), ch( -1 ), name( "" ) {}
virtual ~Action() {};
};
class Ignore : public Action {};
class Print : public Action {};
class Execute : public Action {};
class Clear : public Action {};
class Collect : public Action {};
class Param : public Action {};
class Esc_Dispatch : public Action {};
class CSI_Dispatch : public Action {};
class Hook : public Action {};
class Put : public Action {};
class Unhook : public Action {};
class OSC_Start : public Action {};
class OSC_Put : public Action {};
class OSC_End : public Action {};
class Ignore : public Action {
public: Ignore() { name = "Ignore"; }
};
class Print : public Action {
public: Print() { name = "Print"; }
};
class Execute : public Action {
public: Execute() { name = "Execute"; }
};
class Clear : public Action {
public: Clear() { name = "Clear"; }
};
class Collect : public Action {
public: Collect() { name = "Collect"; }
};
class Param : public Action {
public: Param() { name = "Param"; }
};
class Esc_Dispatch : public Action {
public: Esc_Dispatch() { name = "Esc_Dispatch"; }
};
class CSI_Dispatch : public Action {
public: CSI_Dispatch() { name = "CSI_Dispatch"; }
};
class Hook : public Action {
public: Hook() { name = "Hook"; }
};
class Put : public Action {
public: Put() { name = "Put"; }
};
class Unhook : public Action {
public: Unhook() { name = "Unhook"; }
};
class OSC_Start : public Action {
public: OSC_Start() { name = "OSC_Start"; }
};
class OSC_Put : public Action {
public: OSC_Put() { name = "OSC_Put"; }
};
class OSC_End : public Action {
public: OSC_End() { name = "OSC_End"; }
};
}
#endif
+7 -2
View File
@@ -34,11 +34,16 @@ Transition State::input( wchar_t ch )
return any;
}
Transition ret;
if ( ch >= 0xA0 ) {
return this->input_state_rule( 0x41 );
ret = this->input_state_rule( 0x41 );
} else {
ret = this->input_state_rule( ch );
}
return this->input_state_rule( ch );
ret.action.ch = ch;
return ret;
}
static bool C0_prime( wchar_t ch )
+1 -1
View File
@@ -25,7 +25,7 @@ namespace Parser {
virtual ~State() {};
State( const State & );
bool operator=( const State & );
State & operator=( const State & );
};
class Ground : public State {
+8 -2
View File
@@ -17,10 +17,16 @@ namespace Parser {
Transition( const Transition &x )
: action( x.action ),
next_state( x.next_state ) {}
bool operator=( const Transition & );
Transition & operator=( const Transition &t )
{
action = t.action;
next_state = t.next_state;
return *this;
}
virtual ~Transition() {}
Transition( Action s_action, State *s_next_state )
Transition( Action s_action=Ignore(), State *s_next_state=NULL )
: action( s_action ), next_state( s_next_state )
{}
};