2013-05-20 19:34:15 -04:00
|
|
|
#ifndef PARSERULE_H
|
|
|
|
|
#define PARSERULE_H
|
|
|
|
|
|
|
|
|
|
#ifndef NULL
|
2014-03-06 13:13:40 -05:00
|
|
|
#define NULL ((void*)0)
|
2013-05-20 19:34:15 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "Symbol.h"
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
|
|
class ParseRule {
|
|
|
|
|
public:
|
|
|
|
|
ParseRule();
|
2013-10-02 03:15:20 -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-10-02 03:15:20 -04:00
|
|
|
void setLeftHandle(Symbol leftHandle);
|
|
|
|
|
void appendToRight(Symbol appendee);
|
2013-05-20 19:34:15 -04:00
|
|
|
|
2013-10-02 03:15:20 -04:00
|
|
|
Symbol getLeftSide();
|
|
|
|
|
void setRightSide(std::vector<Symbol> rightSide);
|
|
|
|
|
std::vector<Symbol> getRightSide();
|
|
|
|
|
Symbol getAtNextIndex();
|
|
|
|
|
Symbol getAtIndex();
|
2013-05-26 22:12:47 -04:00
|
|
|
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-10-02 03:15:20 -04:00
|
|
|
void setLookahead(std::vector<Symbol>* lookahead);
|
|
|
|
|
void addLookahead(std::vector<Symbol>* lookahead);
|
|
|
|
|
std::vector<Symbol>* getLookahead();
|
2013-06-26 14:27:28 -04:00
|
|
|
|
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;
|
2013-10-02 03:15:20 -04:00
|
|
|
Symbol leftHandle;
|
|
|
|
|
std::vector<Symbol>* lookahead;
|
|
|
|
|
std::vector<Symbol> rightSide;
|
2013-05-20 19:34:15 -04:00
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|