Code Monkey home page Code Monkey logo

lambdac's Introduction

Lambdac

The purpose of this application is to provide user interfaces for interpreting source code written in untyped lambda calculus. It contains an interpreter that evaluates lambda expressions using the call-by-value evaluation strategy.

This application, named Lambdac, is written in Java. It currently can run as either a textual user interface or a graphical user interface, both of which can run files and text. The implementation is based on the book Types and Programming Languages (TaPL).

How to Build

To build, first clone this repository and then, inside it, run

mvn package

How to Run

To start the application after the build, run

java -cp target/project-lambdac-0.1-SNAPSHOT.jar ch.usi.pf2.Main

The following command line arguments are also supported, which can be appended to the above command:

  • --gui opens the graphical user interface instead of the default textual user interface
  • --help shows more information about the supported command line arguments
  • <filePath> interprets the content of a file and prints the result
  • -c <text> interprets the given text and prints the result

User Instructions

The lambda expressions that are written in this application must follow the following grammar:

TERM        ::= ATOM
              | ABSTRACTION
              | APPLICATION
ATOM        ::= IDENTIFIER
              | "(" TERM ")"
ABSTRACTION ::= "\" IDENTIFIER "." TERM
APPLICATION ::= ATOM ATOM
              | APPLICATION ATOM
IDENTIFIER  ::= [a-zA-Z_][a-zA-Z_0-9]*

This means that an application is left associative (i.e. x y z is the same as (x y) z) and an abstraction extends as far to the right as possible (i.e. \x.x x is the same as \x.(x x) but not (\x.x) x).

Examples

Examples of lambda expressions that follow the above grammar are shown below:

(\x.x x) (\y.y)
(\b.\c.b c (\t.\f.f)) (\t.\f.t) (\t.\f.f)              # and true false
(\l.\m.\n.l m n) (\t.\f.f) (\x.x) (\y.y)               # ifthenelse false (\x.x) (\y.y)
(\n.\s.\z.s (n s z)) (\s.\z.s z)                       # succ 1
(\m.\n.\s.\z.m s (n s z)) (\s.\z.s z) (\s.\z.s (s z))  # plus 1 2

Features to Add

Patterns

  • Allow undo and redo operations using the command pattern.
  • Use the MVC architecture pattern.

Evaluation

  • Allow evaluation using different strategies (applicative order, normal order, call-by-value, and call-by-name).
  • Allow step-by-step evaluation.

User Experience

  • Add a REPL to the GUI.
  • Add more details to parse exceptions, such as start and end positions.

Environment

  • Allow variables to be added to the environment with let.
  • Add default environment variables, such as the ones in section 5.2 in TaPL.
  • Determine if an evaluated expression is behaviorally equivalent to environment variables.

Other

  • See last paragraph of section 7.1 in TaPL.
  • See second to last paragraph of section 7.2 in TaPL.

lambdac's People

Contributors

alensugimoto avatar artmorgan0 avatar igormoreno 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.