Replace Action with Action* so can be polymorphic
This commit is contained in:
+13
-5
@@ -1,19 +1,27 @@
|
||||
#include "parser.hpp"
|
||||
|
||||
std::vector<Parser::Action> Parser::Parser::input( wchar_t ch )
|
||||
std::vector<Parser::Action *> Parser::Parser::input( wchar_t ch )
|
||||
{
|
||||
std::vector<Action> ret;
|
||||
std::vector<Action *> ret;
|
||||
|
||||
Transition tx = state->input( ch );
|
||||
|
||||
if ( tx.next_state != NULL ) {
|
||||
ret.push_back( state->exit() );
|
||||
Action *exitact = state->exit();
|
||||
if ( exitact ) {
|
||||
ret.push_back( exitact );
|
||||
}
|
||||
}
|
||||
|
||||
ret.push_back( tx.action );
|
||||
if ( tx.action ) {
|
||||
ret.push_back( tx.action );
|
||||
}
|
||||
|
||||
if ( tx.next_state != NULL ) {
|
||||
ret.push_back( tx.next_state->enter() );
|
||||
Action *enteract = tx.next_state->enter();
|
||||
if ( enteract ) {
|
||||
ret.push_back( enteract );
|
||||
}
|
||||
state = tx.next_state;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user