2013-05-20 19:34:15 -04:00
|
|
|
#ifndef PARSERULE_H
|
|
|
|
|
#define PARSERULE_H
|
|
|
|
|
|
|
|
|
|
#ifndef NULL
|
|
|
|
|
#define NULL 0
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "Symbol.h"
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
|
|
class ParseRule {
|
|
|
|
|
public:
|
|
|
|
|
ParseRule();
|
2013-06-26 14:27:28 -04:00
|
|
|
ParseRule(Symbol* leftHandle, int pointerIndex, std::vector<Symbol*> &rightSide, std::vector<Symbol*>* lookahead);
|
2013-05-20 19:34:15 -04:00
|
|
|
~ParseRule();
|
2013-06-26 14:27:28 -04:00
|
|
|
const bool equalsExceptLookahead(const ParseRule &other);
|
2013-05-24 00:00:41 -04:00
|
|
|
bool const operator==(const ParseRule &other);
|
2013-05-26 22:12:47 -04:00
|
|
|
bool const operator!=(const ParseRule &other);
|
2013-05-24 00:00:41 -04:00
|
|
|
|
2013-05-20 23:26:15 -04:00
|
|
|
ParseRule* clone();
|
|
|
|
|
|
2013-05-20 19:34:15 -04:00
|
|
|
void setLeftHandle(Symbol* leftHandle);
|
|
|
|
|
void appendToRight(Symbol* appendee);
|
|
|
|
|
|
2013-05-23 01:35:54 -04:00
|
|
|
Symbol* getLeftSide();
|
2013-08-12 00:02:50 -04:00
|
|
|
void setRightSide(std::vector<Symbol*> rightSide);
|
2013-05-23 01:35:54 -04:00
|
|
|
std::vector<Symbol*> getRightSide();
|
2013-05-26 22:12:47 -04:00
|
|
|
Symbol* getAtNextIndex();
|
|
|
|
|
Symbol* getAtIndex();
|
|
|
|
|
int getRightSize();
|
2013-05-24 00:00:41 -04:00
|
|
|
int getIndex();
|
2013-05-23 01:35:54 -04:00
|
|
|
|
2013-05-20 23:26:15 -04:00
|
|
|
bool advancePointer();
|
2013-05-29 20:43:35 -04:00
|
|
|
bool isAtEnd();
|
2013-05-20 23:26:15 -04:00
|
|
|
|
2013-06-26 14:27:28 -04:00
|
|
|
void setLookahead(std::vector<Symbol*>* lookahead);
|
2013-08-06 01:49:45 -04:00
|
|
|
void addLookahead(std::vector<Symbol*>* lookahead);
|
2013-06-26 14:27:28 -04:00
|
|
|
std::vector<Symbol*>* getLookahead();
|
|
|
|
|
|
2013-05-20 19:34:15 -04:00
|
|
|
std::string toString();
|
2013-05-20 22:59:57 -04:00
|
|
|
std::string toDOT();
|
2013-05-20 19:34:15 -04:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int pointerIndex;
|
|
|
|
|
Symbol* leftHandle;
|
2013-06-26 14:27:28 -04:00
|
|
|
std::vector<Symbol*>* lookahead;
|
2013-05-20 19:34:15 -04:00
|
|
|
std::vector<Symbol*> rightSide;
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|