Coder Social home page Coder Social logo

mini-c's Introduction

Mini-C

CS F363 Compiler Construction Assignment-2

Problem Statement Specifications:

Consider a programming language, (Mini-C) with the following features:

  1. Type : int, float, char
  2. Basic statements: expression statement, assignment statements, and compound statements, declaration statement.
  3. Control and looping statements: if statement, for statement, while statement, and switch statement. (note that nesting of these statements is also possible.)
  4. System functions: printf and scanf statements.
  5. Other: Variables, arrays (1-D and 2-D only), and function
    The syntax for the above is same as in C language.
    The structure of the input program is also same as a C program ignoring headers and macros.

Tasks:

  1. Lexical Analysis: Tokenizes the input program into tokens (identifiers, operators, numbers, etc). Further reports if invalid scanf or printf statements are present in the program.
    A valid printf statement has one of the following structure:
  • printf(“text”) where text is a non-empty string of symbols in the language alphabet.
  • printf(“text”, list_of_variables) where text is a non-empty string of symbols in the language alphabet and list_of_variables is a nonempty sequence of variables separated by a comma (,).
    Further, the number of variables in list_of_variables is must be the same as the number of %d, %c, and %f terms in text.
  1. Syntax Analysis: Checking whether the input program is syntactically correct or not.
  2. Semantic Analysis:
  • Printing an Abstract Syntax Tree for the program.
  • Verifying Semantic errors like type checking, undeclared variables, multiple declarations of variables, functional arguments, etc.
  1. Code Generation: Intermediate Code generation ( Three Address Code )
  2. Simulation: Simulate the program

How to run:

  1. Compile files for all stages by running ./compile.sh in main directory.
  2. Run the corresponding executables for each phase with the input file
    for example: ./semantic_analyzer.out < input.txt or ./intermediate.out < input.txt

mini-c's People

Contributors

p00f avatar ashwin-1709 avatar arkighosh avatar mokshpapneja avatar sriramb2002 avatar

Watchers

 avatar  avatar  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.