Action names
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include "parser.hpp"
|
#include "parser.hpp"
|
||||||
|
|
||||||
@@ -12,5 +13,7 @@ int main( void )
|
|||||||
b = parser.input( 'y' );
|
b = parser.input( 'y' );
|
||||||
c = parser.input( 'z' );
|
c = parser.input( 'z' );
|
||||||
|
|
||||||
|
std::cout << a[0].name;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+51
-15
@@ -1,27 +1,63 @@
|
|||||||
#ifndef PARSERACTION_HPP
|
#ifndef PARSERACTION_HPP
|
||||||
#define PARSERACTION_HPP
|
#define PARSERACTION_HPP
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Parser {
|
namespace Parser {
|
||||||
class Action
|
class Action
|
||||||
{
|
{
|
||||||
public:
|
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 Ignore : public Action {
|
||||||
class Print : public Action {};
|
public: Ignore() { name = "Ignore"; }
|
||||||
class Execute : public Action {};
|
};
|
||||||
class Clear : public Action {};
|
class Print : public Action {
|
||||||
class Collect : public Action {};
|
public: Print() { name = "Print"; }
|
||||||
class Param : public Action {};
|
};
|
||||||
class Esc_Dispatch : public Action {};
|
class Execute : public Action {
|
||||||
class CSI_Dispatch : public Action {};
|
public: Execute() { name = "Execute"; }
|
||||||
class Hook : public Action {};
|
};
|
||||||
class Put : public Action {};
|
class Clear : public Action {
|
||||||
class Unhook : public Action {};
|
public: Clear() { name = "Clear"; }
|
||||||
class OSC_Start : public Action {};
|
};
|
||||||
class OSC_Put : public Action {};
|
class Collect : public Action {
|
||||||
class OSC_End : 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
|
#endif
|
||||||
|
|||||||
+7
-2
@@ -34,11 +34,16 @@ Transition State::input( wchar_t ch )
|
|||||||
return any;
|
return any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Transition ret;
|
||||||
|
|
||||||
if ( ch >= 0xA0 ) {
|
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 )
|
static bool C0_prime( wchar_t ch )
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@ namespace Parser {
|
|||||||
virtual ~State() {};
|
virtual ~State() {};
|
||||||
|
|
||||||
State( const State & );
|
State( const State & );
|
||||||
bool operator=( const State & );
|
State & operator=( const State & );
|
||||||
};
|
};
|
||||||
|
|
||||||
class Ground : public State {
|
class Ground : public State {
|
||||||
|
|||||||
@@ -17,10 +17,16 @@ namespace Parser {
|
|||||||
Transition( const Transition &x )
|
Transition( const Transition &x )
|
||||||
: action( x.action ),
|
: action( x.action ),
|
||||||
next_state( x.next_state ) {}
|
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() {}
|
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 )
|
: action( s_action ), next_state( s_next_state )
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user