/LL1-parser

💻 Python Implementation of a simple LL(1) parser

Primary LanguagePythonMIT LicenseMIT

LL(1) parser

It is a top down parser that handles certain class of grammars called LL(1) grammar.

Run locally

Clone the repo locally and follow the steps in the terminal to install the requirements.

For Linux

python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt

For Windows

python -m venv venv
source venv\Scripts\activate.bat
pip install -r requirements.txt

To run the parser, run the following:

flask run

Then navigate to http://localhost:5000 in your web browser.

Grammar

The given grammar:
image

Steps

The following steps are required to parse the input string with respect to the grammar:

1. Remove left recursion (if present) from the grammar

image

2. Left factor the grammar (if required)

image

3. Find First and Follow from the given grammar

image

4. Generate Parse Table using the First/Follow sets and the grammar

image

5. Parse the given input string using parse table

image