Giter Club home page Giter Club logo

forsp-js's Introduction

forsp-js

Forsp interpreter in Typescript. Initial version is a direct port from the original written in C.

Immediate goal

To be able to solve Project Euler problems comfortably with Forsp. This requires extending the interpreter implementation and adding a standard library with at least the following features:

  • data structures and their associated methods:
    • string
    • list
    • dictionary
  • module import
  • Complete math operations
  • random number generator
  • functions for sort, filter, map, group, transpose

In keeping with the minimalist principle of Forsp, these features would mostly be implemented in Forsp as a standard library, extending the interpreter only where absolutely necessary.

Usage

As an interpreter

Make sure npm and node is installed on your system. To build

npm run build

To execute code directly in the commandline

node ./dist/index.js --raw "( 3 4 + 7 eq print )"

To execute a Forsp script file

node ./dist/index.js ./data/tutorial.fp

You can also use the web app interpreter at https://alicecengal.github.io/forsp-web/

As a library

The core library is in src/forsp. The module exposes the following members:

function setup(adapter: IO, inputProgram: string): State. adapter is an object that contains the IO functions for the interpreter to use. inputProgram must be a valid Forsp program. It returns an object that holds the state of the Forsp program execution. The State object is not part of the public interface, so I can't guarantee that its structure will stay the same as this project evolves.

async function run(st: State). Takes the object returned by setup and begins execution of the program

type IO. Interface for an adapter object that holds the IO functions used by the interpreter.

forsp-js's People

Contributors

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