GithubHelp home page GithubHelp logo

aliasar1 / compiler-construction-project Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 86 KB

This is my compiler construction project which is implemented for only lexical and syntax analyzer phase in Java.

Java 100.00%
compiler compiler-construction java lexeme lexical-analyzer project syntax-analysis

compiler-construction-project's Introduction

Compiler Construction Project

Objective

This is my compiler construction project which is implemented for only lexical and syntax analyzer phase. For syntax analyzer the provided rules are: E -> E + T , E -> T , T -> T * F , T -> F , F -> ( E ) , F -> id

The code is written in java. Along with that for GUI Java Swing is used.

Requirements

Recognize following tokens for the lexemes in the input source program: – Keywords: int, char, string, if, else, do, while. – Identifiers (ID): letter followed by zero or more letters or digits. – String Literal: (SL): anything that is surrounded by double quotes, for example “Hello” – Integer value (IV): example: 155 (unsigned only) – Relational Operators (ROP): <, <=, ==, <>, >= and > – Arithmetic Operators (AOP): +, -, *, / – Other Operators (OOP): assignment: =, parenthesis: (, ), braces: {, }, line terminator: ;

• Upon recognizing a token, lexical analyzer should output the lexeme, the token name and the attribute value based on the above table. • Store tokens in symbol table based on the above table. • Should properly handle the comments enclosed in /* and */ or following // . • Should properly handle the white spaces (blanks, tabs or newlines). • Also output all the data stored in the symbol table. • If the input to your compiler contains something other than the lexemes mentioned in the table above, then it should generate and display the error with: – The line number – The unrecognized lexeme in the source code and – A meaningful error message • For Syntax Analysis, if the input contains a legal expression involving operators + and * and parenthesis ( and ), your compiler should accept it and output “Compiled Successfully” message, otherwise give out error message with correct line number and a meaningful error message: Use the CFG and the Parsing Table given below for Syntax Analysis of the input.

image

Here are the screen shots of GUI:

image

Lexical Analyzer Working:

image image

Incase of Lexical Error:

image image

Syntax Analyzer:

image

Incase of Syntax Error:

image image

compiler-construction-project's People

Contributors

aliasar1 avatar sarimeffendi avatar

Stargazers

 avatar

Watchers

 avatar

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.