Added main loop of parser.

This commit is contained in:
Nathan Braswell
2013-05-23 01:35:54 -04:00
parent 14fc410e00
commit e4f83cbb67
9 changed files with 142 additions and 2 deletions

37
src/ParseAction.cpp Normal file
View File

@@ -0,0 +1,37 @@
#include "ParseAction.h"
ParseAction::ParseAction(ActionType action, ParseRule* reduceRule, int shiftState) {
this->action = action;
this->reduceRule = reduceRule;
this->shiftState = shiftState;
}
ParseAction::~ParseAction() {
}
std::string ParseAction::actionToString(ActionType action) {
switch (action) {
case REDUCE:
return "reduce";
break;
case SHIFT:
return "shift";
break;
case ACCEPT:
return "accept";
break;
case REJECT:
return "reject";
break;
}
}
std::string ParseAction::toString() {
std::string outputString = actionToString(action);
if (reduceRule)
outputString += " " + reduceRule->toString();
if (shiftState)
outputString += " " + shiftState;
return(outputString);
}