Skip to content

probro27/Faux-Racket-Interpreter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Faux Racket Interpreter in Haskell

Overview

This is a simple interpreter for a subset of the Racket programming language. It supports basic arithmetic operations, variable binding, function definition, and function application.

Features

  • Arithmetic Operations: Addition, subtraction, multiplication, and division of numbers.
  • Variable Binding: Ability to bind variables to values using the With construct.
  • Function Definition: Define functions using the Fun construct.
  • Function Application: Apply functions to arguments using the App construct.
  • Error Handling: Detects division by zero errors and reports them appropriately.

Installation

Before building the project, make sure you have Cabal and GHC (Glasgow Haskell Compiler) installed on your system.

  • Cabal: Cabal is a system for building and packaging Haskell libraries and programs. You can download and install Cabal from here.

  • GHC: GHC is the standard Haskell compiler. You can download and install GHC from here.

Building the Project

To build the project, navigate to the project directory in your terminal and run the following command:

cabal build

This will compile the project and generate the executable file in the dist-newstyle directory.

Running the Code

To run the code, you can use the following command:

cabal run

Usage

To use the interpreter for different ASTs, you can define your Racket expressions as Abstract Syntax Trees (ASTs) and then use the provided run and runDebug functions to interpret them.

Example

import RacketInterpreter

main :: IO ()
main = do
    let ast = BinOp Add (Number 5) (Number 3)
    let result = run ast
    putStrLn $ "Result: " ++ show result

About

A Faux-Racket-Interpreter in Haskell.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published