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 {
2015-03-23 14:35:28 -04:00
private :
int pointerIndex ;
Symbol leftHandle ;
std : : vector < Symbol > lookahead ;
std : : vector < Symbol > rightSide ;
2013-05-20 19:34:15 -04:00
public :
ParseRule ( ) ;
2015-03-23 14:35: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 ( ) ;
2014-06-30 01:57:50 -07:00
const bool equalsExceptLookahead ( const ParseRule & other ) const ;
bool const operator = = ( const ParseRule & other ) const ;
bool const operator ! = ( const ParseRule & other ) const ;
bool const operator < ( const ParseRule & other ) const ; //Used for ordering so we can put ParseRule's in sets, and also so that ParseActions will have an ordering
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
2015-03-23 14:35:28 -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
2014-06-30 01:57:50 -07:00
std : : string toString ( bool printLookahead = true ) ;
2013-05-20 22:59:57 -04:00
std : : string toDOT ( ) ;
2013-05-20 19:34:15 -04:00
} ;
2014-06-30 01:57:50 -07:00
# endif