Replace Action with Action* so can be polymorphic

This commit is contained in:
Keith Winstein
2011-01-13 00:44:07 -05:00
parent 82ac626320
commit 59f000cdce
7 changed files with 123 additions and 107 deletions
+13 -5
View File
@@ -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;
}