Git Product home page Git Product logo

compiler-lex-yacc's Introduction

Compiler with Lex and Yacc

License

Description

This project is an implementation of an original programming language designed using YACC. The language incorporates various features such as type declarations, control statements, arithmetic and boolean expressions, and function calls. It also includes semantic analysis, symbol tables, and evaluation functionality. The project aims to provide a comprehensive and efficient programming language for various applications.

Features

  • Type declarations for predefined types (int, float, char, string, bool), arrays, and user-defined data types
  • Variable and constant definitions
  • Control statements (if, for, while, etc.) and assignment statements
  • Arithmetic and boolean expressions with support for different operators
  • Function calls with parameters
  • Predefined functions Eval(arg) and TypeOf(arg)
  • Program structure with sections for global variables, functions, and user-defined data types

Symbol Tables

The project includes symbol tables to store information about variables and functions. The tables can be printed to symbol_table.txt and symbol_table_functions.txt for variables and functions, respectively. These files provide insights into the defined symbols and their corresponding details.

Semantic Analysis

Semantic analysis is implemented to ensure correct usage of variables and functions within the language. It checks for variable and function declarations, duplicate variable declarations, consistent operand types in expressions, and proper function call parameters. Detailed error messages are generated to aid in identifying and fixing any semantic errors in the code.

Eval and TypeOf

The project provides the Eval and TypeOf functions. Eval evaluates arithmetic expressions and returns their actual values. TypeOf determines the type of an expression. Both functions enhance the functionality and utility of the programming language.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

compiler-lex-yacc's People

Contributors

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