Changed Parser to be a virtual base class, inherited by LALRParser
This commit is contained in:
39
include/LALRParser.h
Normal file
39
include/LALRParser.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef LALRPARSER_H
|
||||
#define LALRPARSER_H
|
||||
|
||||
#include "Parser.h"
|
||||
/*
|
||||
#include "util.h"
|
||||
#include "ParseRule.h"
|
||||
#include "ParseAction.h"
|
||||
#include "Symbol.h"
|
||||
#include "State.h"
|
||||
#include "StringReader.h"
|
||||
#include "Lexer.h"
|
||||
#include "NodeTree.h"
|
||||
#include "Table.h"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
*/
|
||||
class LALRParser: public Parser {
|
||||
public:
|
||||
LALRParser();
|
||||
~LALRParser();
|
||||
|
||||
//using Parser::loadGrammer;
|
||||
|
||||
//Defaults in parser are mostly LALR, so we only need to
|
||||
//implement the actual parsing function
|
||||
NodeTree<Symbol*>* parseInput(std::string inputString);
|
||||
|
||||
private:
|
||||
//Nothing
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -23,24 +23,24 @@ class Parser {
|
||||
Parser();
|
||||
~Parser();
|
||||
|
||||
void loadGrammer(std::string grammerInputString);
|
||||
std::vector<Symbol*>* firstSet(Symbol* token);
|
||||
std::vector<Symbol*>* firstSet(Symbol* token, std::vector<Symbol*> &avoidList);
|
||||
std::vector<Symbol*>* incrementiveFollowSet(ParseRule* rule);
|
||||
void createStateSet();
|
||||
void closure(State* state);
|
||||
void addStates(std::vector< State* >* stateSets, State* state);
|
||||
int stateNum(State* state);
|
||||
std::string stateSetToString();
|
||||
|
||||
NodeTree<Symbol*>* parseInput(std::string inputString);
|
||||
|
||||
std::string grammerToString();
|
||||
std::string grammerToDOT();
|
||||
virtual void loadGrammer(std::string grammerInputString);
|
||||
virtual void createStateSet();
|
||||
virtual std::string stateSetToString();
|
||||
virtual NodeTree<Symbol*>* parseInput(std::string inputString) = 0;
|
||||
virtual std::string grammerToString();
|
||||
virtual std::string grammerToDOT();
|
||||
|
||||
std::string tableToString();
|
||||
|
||||
private:
|
||||
protected:
|
||||
std::vector<Symbol*>* firstSet(Symbol* token);
|
||||
std::vector<Symbol*>* firstSet(Symbol* token, std::vector<Symbol*> &avoidList);
|
||||
std::vector<Symbol*>* incrementiveFollowSet(ParseRule* rule);
|
||||
virtual void closure(State* state);
|
||||
virtual void addStates(std::vector< State* >* stateSets, State* state);
|
||||
int stateNum(State* state);
|
||||
|
||||
|
||||
StringReader reader;
|
||||
Lexer lexer;
|
||||
std::map<std::string, Symbol*> symbols;
|
||||
|
||||
Reference in New Issue
Block a user