Giter VIP home page Giter VIP logo

jsol's Introduction

JSOL: JavaScript Object Language

JSOL is an interpreted language represented by JSON. Since any JSOL program
is completely written in JSON, its data structures and functions can be
represented (and edited) in any language that has a JSON parser and JSOL
interpreter. This allows for easy passing of complete programs between
applications.

PSOL is a cleaner syntax for JSOL. A PSOL program can be parsed into JSOL
using parser.py. Examples of PSOL can be found in the examples/psol
directory, or in test_data/psol.

Check out http://jsol.org for an online JSOL/PSOL playground.

This is the very first version, so there are many improvements to be made.


Features

 - Closures
 - First class functions
 - String, list, number, dictionary, null, and function types
 - Fully representable in JSON.
 - Easily extendable with modules (see examples/file_reader.jsol).


Syntax

   Basic
    - '{"a": 5}'                     -> assignment
    - '"add": {...}'                 -> function definition
    - '["add", "a", "b", "a"]'       -> function call
    - '{"lit": "hello"}'             -> string literal
    - '["import", {"lit": "file"}]'  -> import a module

   Lists
    - '{"lit": [1, 2, 3]}'           -> list literal
    - '["l", 0]'                     -> get first element in list
    - '["l", 0, 5]'                  -> set first element in list to be 5
    - '["del", "l", 0]'              -> delete and return first element in list
    - '["ins", "l", 0, 5]'           -> insert 5 into the beginning of the list

   Dictionaries
    - '{"lit": {"a": 5, "b": 2}}'    -> dictionary literal
    - '["d", {"lit": "a"}]'          -> get the value with the key "a"
    - '["d", {"lit": "a"}, 5]'       -> set "a" to be 5 in the dictionary

   If block
    - '["if",                        |
          <cond>, [...],             |
          <cond>, [...],             |
          ...                        |
          [...]                      |
       ]'                            -> if/else


Examples

The examples/jsol directory has some example programs.
Run examples by typing 'jsol.py examples/jsol/<name_of_example>'

   - fib.jsol - outputs the Fibonacci sequence using a closure
   - recursive.jsol - an example of a recursive function
   - quick_sort.jsol - an example of sorting a list by passing in a compare
     function
   - file_reader.jsol - prompts the user for a filename and then prints the
     file to the screen. Uses the 'file' module.
   - passer.py - ./passer.py (in main directory) illustrates passing a JSOL
     program between applications
   - editor.py - ./editor.py shows how a JSOL program can be edited on the fly

Most of these examples also have a PSOL version in examples/psol.
Run these by typing 'parser.py examples/psol/<name_of_example>'


Testing

Run tests using 'run_tests.sh'


Future

 - Better error handling/messages.
 - More examples.
 - Documentation.
 - Porting into other languages (probably starting with JavaScript).

Created by Clark DuVall http://clarkduvall.com

jsol's People

Contributors

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