Giter Site home page Giter Site logo

eva_type_checker's Introduction

Abstract

This document outlines a concise type-checker for Eva, supporting a range of type-checking capabilities:

  • Mathematical Binary Operations: Handles addition, subtraction, multiplication, and division, including logical combinations thereof.
  • Comparison Operators: Supports greater than (>), less than (<), greater than or equal to (>=), less than or equal to (<=), and equals (==).
  • Variable Definition and Update: Manages variable declarations and updates within the scope.
  • Branching: Incorporates if conditions for flow control.
  • Lambda Functions: Allows anonymous function definitions.
  • Function Declarations and Calls: Supports defining and invoking functions.
  • Generic Function: Facilitates generic programming by allowing functions to operate on various types.

IDE Setup

  • PyCharm: Version 2022.3.2
  • Python: Version 3.11
  • Relevant Third-party Libraries:
    • sexpdata
    • pyInstaller

Project Structure

  • parser/: Converts raw Eva language into list form, e.g., (+ 1 3) -> ['+', 1, 3].
  • tests/: Contains test cases.
  • type_env.py: Defines the type-checking environment, preserving variables within the current and parent blocks.
  • EvaTC.py: Houses the main logic of the type checker.
  • Type.py: Defines the types utilized in Eva.
  • main.py: Acts as the entry point of the interpreter.

Running the Project

To generate an executable for the project, execute the following command in the terminal from the directory containing main.py:

pyinstaller --onefile --name eva-tc main.py

This command creates an executable named eva-tc in the dist/ directory. Usage examples include:

eva-tc -e "(+ 1 4)"
# Output: No Error!

eva-tc -e "(+ 1 '4')"
# Output: RuntimeError: Expected Type.number for "3" in expression, but got Type.string.

Code Examples

Additional code examples are available in the tests/ directory.

eva_type_checker's People

Contributors

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