Code Monkey home page Code Monkey logo

bmm_lexer_parser's Introduction

Bmm_Lexer_Parser

Summary

This project aims to build a compiler for a simple programming language called B--. It utilizes Flex and Bison to create a lexical analyzer and syntax analyzer capable of recognizing B-- source code. The compiler provides helpful error messages for identifying syntax errors in B-- sample code.

File Structure

.
├── README.md
├── bmm_parser.y
├── bmm_scanner.l
├── correct_sample.bmm
├── incorrect_sample.bmm

Prerequisites

Download

Assumptions

  • \n is not considered as a space but as a character
  • all other assumptions are intuitive

How to run ?

  • Enter following commands into terminal
    lex BMM_Scanner.l
    yacc -d BMM_Parser.y
    cc lex.yy.c y.tab.c -o Compiler    
    ./.Compiler<CorrectSample.bmm
    ./.Compiler<IncorrectSample.bmm
    

BMM_Scanner.l

  • Tokenized all the variable names, keywords, special characters and numbers.
  • It will print all the tokens in the terminal in the the orser scanned.

BMM_Parser.y

  • This program contains the BNF grammar rules for the compiler.
  • If there is any error in syntax it will stop parsing after prompting error message "Syntax Error".
  • If there is no syntax error all the scanning and parsing will be printed in terminal and Success message will be prompted in the end.

CorrectSample.bmm

  • Contains correct code free from any kind of syntax errors.

IncorrectSample.bmm

  • Contains syntax error in line 180 (contains PRIN instead of PRINT)

Authors

  • Prashant Singh (@prashant531)
  • Aditya Patil (@Nerditya)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.