jococo / sallied-forth

A forth-a-like interpreter written in JavaScript for the browser.
MIT License
10 stars 1 forks source link

salliedforth.js

Build Status

A non-legal version of Forth.

See http://jococo.github.io/sallied-forth/ for some explanation and to try the live, in-browser REPL.

Will explore whether to eventually work directly with Asm.js is both possible and desirable.

I rose at the dawn, and without asking or bestowing a blessing, sallied forth into the high road to the city which passed near the house. I left nothing behind, the loss of which I regretted. I had purchased most of my own books with the product of my own separate industry, and their number being, of course, small, I had, by incessant application, gotten the whole of them by rote. They had ceased, therefore, to be of any further use. I left them, without reluctance, to the fate for which I knew them to be reserved, that of affording food and habitation to mice.

Arthur Mervyn

By non-legal I mean it doesn't strictly follow any Forth standard. The intention more is to create a simple and pragmatic Forth-a-like language implementation in JavaScript. There is no real use-case yet for this, other than as a workpad for exploring features and implementations of the Forth language. As there is no adherence to any Forth standard, I am free to bring in any features from other languages.

As mentioned, this was intended to utilize Asm.js for mega speed, but I am considering other paths..

Quick start

Either clone this git repository with:

git checkout https://github.com/jococo/sallied-forth.git

or clone it with the github application.

You will find a full, minified version of salliedforth.min.js in the directory build/js/

A simple web server

In the root folder, froma terminal, run the command:

npm install

And, when this has finished, type

npm start

To launch the local-web-server app from NPM. Then visit

http://localhost:8000/

in a web browser. This will initially show you a listing of the files and folders in the root of your project. Click on the 'examples' folder and you will be taken to the local web pages that demonstrate some example code. Also you can access a web based repl and run the Jasmine unit tests for the project (They only take a few seconds to run.)

Opening a REPL

Type the repl command into terminal or command line as so:

./repl

This allows you to interactively enter forth words and see the results immediately.

Please note: the repl command use rlwrap available from:

https://github.com/hanslub42/rlwrap

to give more modern console usage such as history and keyboard navigation. Enter ctrl+c to exit the repl.

At this time I haven't produced a Windows version of the repl. This shouldn't be difficult and will be created when I am next near a Windows pc. For now, you should be able to run:

node repl.js

although I haven't tested this for Windows compatibility yet.

Design decisions

Using dynamic features of the implementation language

Testing

Tests are included and run from the main index.html page at present. This project uses the excellent Jasmine library.

Most features have been developed with accompanying tests and they will be enhanced as the project evolves.

Possible Enhancements

TODO

DONE

License

The MIT License (MIT)

Copyright (c) 2013 Joc O'Connor

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.