Main flow of the program is in main.cc
inside the src folder
- Get Grammar from file
- Pass Grammar to Parser for building
- Errors like ShiftReduceException or ReduceReduceException may be raised
- Input is given to the Parser to check if it satisfies the grammar
- Output is given according to whether the given string is accepted or not
- Run
make
in the root directory to build the project, object files go inside the build directory - Generates a final binary in the root directory
shadow-parser
make clean
removes all build files and cleans up the project
The Grammar file will be of the format
S->aBc
where S is the left hand side of the production and aBc is the right hand side of the production Capital letters are considered to be Variables and small letters are considered to be terminals
ProdType : pair<char, string>
Grammar : vector<ProdType>
ParseRowType : vector<string>
ParseTableType: vector<ParseRowType>
- parseFile takes in a filename and builds the grammar
- parseSymbols extracts the terminals and variables from the grammar
- getGrammar returns the grammar built
- Abstract class for all the parsers to build on
- Takes Grammar, terminals and variables as input
- builds a parse table as a variable in the class
- Length of ParseRow is same as the number of Alphabets
- The int in ParseCell gives the next state
- The char in ParseCell can be:
- s : shift
- r : reduce
- a : accept
- e : error ( default )
- The index of the ParseRow in a ParseTable signifies the state when the row is considered
- All source files go inside the src folder
- All header files go inside the include folder
- All parser files go inside the parser folder inside the corresponding folder
- All C++ files use the extension .cc and all headers use the extension .h
main.cc
file inside the src folder handles the general flow of the program
Wanna be part of the team? Feel free to contact and chip in.