Coder Social home page Coder Social logo

poulcheria / c-like--language-compiler--flex-bison Goto Github PK

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

This project is a C-like language compiler implemented using Flex (lexical analyzer) and Bison (parser generator) as part of a university project at the Computer Engineering and Informatics Department (CEID) .

Yacc 4.71% Lex 1.53% C 93.75%

c-like--language-compiler--flex-bison's Introduction

C-Like Language Compiler

This project is a C-like language compiler implemented using Flex (lexical analyzer) and Bison (parser generator) as part of a university project at the Computer Engineering and Informatics Department (CEID).

Features

  • Lexer: The Flex file (flex.l) contains the rules for tokenizing the input source code.
  • Parser: The Bison file (bison.y) defines the grammar and rules for parsing the tokens generated by the lexer.
  • Input Files: The input files (input.txt, input2.txt, input3.txt) contain correct grammar of the C-like language.
  • Wrong Input File : The wronginput.txt file containt incorrect grammar of the C-like language.

Language Constructs

The C-like language supported by the compiler includes the following constructs:

  • Variables: Declare and use variables of integer and character types.
  • Control Flow: Support for if-else statements, while and for loops, and switch-case statements.
  • Functions: Define and call functions.
  • Print Statement: Print statements using the print keyword.
  • Comments: Support for single-line and multi-line comments.
  • Data Types: Integer (int) and character (char) data types.
  • Arrays: Declaration and usage of arrays.

How to Run

To compile and run the C-like language compiler, follow these steps:

  1. Install Flex and Bison: Ensure you have Flex and Bison installed on your system.
  2. Compilation: Open a terminal, navigate to the project directory, and run the following commands:
flex lexer.l
bison -d parser.y
gcc lex.yy.c parser.tab.c -o compiler

c-like--language-compiler--flex-bison's People

Contributors

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