Actually parses LR(0) grammers and sentences\! Only two problems is very inefficint gotoTable() and actionTable(), and it REJECTS the sentence after completing the Goal->Sentence(*) production. However, need to go to bed now. Does practially work though\! Yay\!
This commit is contained in:
@@ -13,7 +13,9 @@
|
||||
class ParseAction {
|
||||
public:
|
||||
enum ActionType { INVALID, REDUCE, SHIFT, ACCEPT, REJECT };
|
||||
ParseAction(ActionType action, ParseRule* reduceRule = NULL, int shiftState = 0);
|
||||
ParseAction(ActionType action);
|
||||
ParseAction(ActionType action, ParseRule* reduceRule);
|
||||
ParseAction(ActionType action, int shiftState);
|
||||
~ParseAction();
|
||||
std::string toString();
|
||||
static std::string actionToString(ActionType action);
|
||||
|
||||
@@ -33,6 +33,7 @@ class ParseRule {
|
||||
int getIndex();
|
||||
|
||||
bool advancePointer();
|
||||
bool isAtEnd();
|
||||
|
||||
std::string toString();
|
||||
std::string toDOT();
|
||||
|
||||
@@ -40,6 +40,8 @@ class Parser {
|
||||
|
||||
std::vector< State* > stateSets;
|
||||
|
||||
//std::vector< std::vector<ParseAction*> >
|
||||
|
||||
std::stack<int> stateStack;
|
||||
std::stack<Symbol*> symbolStack;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user