Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
89 lines (63 sloc) 2.96 KB
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
PSOL is a cleaner syntax for JSOL. A PSOL program can be parsed into JSOL
using Examples of PSOL can be found in the examples/psol
directory, or in test_data/psol.
Check out for an online JSOL/PSOL playground.
This is the very first version, so there are many improvements to be made.
- 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).
- '{"a": 5}' -> assignment
- '"add": {...}' -> function definition
- '["add", "a", "b", "a"]' -> function call
- '{"lit": "hello"}' -> string literal
- '["import", {"lit": "file"}]' -> import a module
- '{"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
- '{"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
The examples/jsol directory has some example programs.
Run examples by typing ' 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
- file_reader.jsol - prompts the user for a filename and then prints the
file to the screen. Uses the 'file' module.
- - ./ (in main directory) illustrates passing a JSOL
program between applications
- - ./ 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 ' examples/psol/<name_of_example>'
Run tests using ''
- Better error handling/messages.
- More examples.
- Documentation.
- Porting into other languages (probably starting with JavaScript).
Created by Clark DuVall
You can’t perform that action at this time.