Parser Table Generator

Sanjana Arvind
3 min readMay 4, 2021

--

Design a program that will generate the predictive parsing table for a given grammar G.

ABSTRACT

This project we have developed generates a parser table along with the first and follow sets when a grammar is given as an input text file. A syntax analyzer or parser essentially takes the input in the form of token streams from the lexical analyser and then analyses the source code against the production rules to detect any error in the code

SOFTWARE AND HARDWARE REQUIREMENTS

HARDWARE REQUIREMENTS
• Intel Dual Core, i3 or above
• 2GB of RAM
• 10GB of Disk Space

SOFTWARE REQUIREMENTS
• Windows 7+ / Ubuntu 16.04+
• Python
• Tabulate Python Package

INTRODUCTION

A compiler is a computer program that translates computer code written in one programming language (the source language) into another language (the target language). The name “compiler” is primarily used for programs that translate source code from a high-level programming language to a lower-level language (e.g., assembly language, object code, or machine code) to create an executable program.

The compilation is a sequential process, where each phase takes input from its previous stage, has its own representation of the source program, and feeds its output to the next phase of the compiler.

There are two types of parsers: Top-Down and Bottom-Up

In Top-Down parsers(LL1), the parser starts constructing the parse tree from the given start symbol and then tries to transform the start symbol to the input.

In Bottom-Up Parsers, the parsing starts with the input symbols and we try to construct the parse tree upward all the way up to the start symbol.

FLOW CHART

OUTPUT SCREENSHOT

  1. Grammar does not have left recursion or left factoring
Example 1

2.Removed left factoring from grammar

Example 2

CONCLUSION

This project implements the LL1 parsing technique. And shows the parsing table generated for the user-generated grammar along with the first and follow sets for each of the terminal symbols. The parse table is made easy to read and understand.

For future work, we intend to implement a method to remove the left recursion and left factoring before finding the first and follow sets so that the user does not have to manually find the grammar with no left factoring and recursion.

Link for the code: https://github.com/sahana2004/CDSS/tree/main

Team members :

Aishwarya Patil -(ENG18CS0203)

Prathyusha M -(ENG18CS0214)

Sahana M -(ENG18CS0240)

Sanjana A G -(ENG18CS0244)

SPECIAL THANKS

We owe our deep gratitude to our mentor Dr Anbunathan R, Founder and CEO, DigiTran solutions, Bangalore, Adjunct Professor, who helped us in this project by giving us more understanding of the topic of compiler design.

--

--

Sanjana Arvind
Sanjana Arvind

No responses yet