• Stars
    star
    503
  • Rank 87,705 (Top 2 %)
  • Language
    C++
  • License
    MIT License
  • Created over 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Automatically exported from code.google.com/p/tiny-js

tiny-js

(originally on Google Code)

This project aims to be an extremely simple (~2000 line) JavaScript interpreter, meant for inclusion in applications that require a simple, familiar script language that can be included with no dependencies other than normal C++ libraries. It currently consists of two source files: one containing the interpreter, another containing built-in functions such as String.substring.

TinyJS is not designed to be fast or full-featured. However it is great for scripting simple behaviour, or loading & saving settings.

I make absolutely no guarantees that this is compliant to JavaScript/EcmaScript standard. In fact I am sure it isn't. However I welcome suggestions for changes that will bring it closer to compliance without overly complicating the code, or useful test cases to add to the test suite.

Currently TinyJS supports:

  • Variables, Arrays, Structures
  • JSON parsing and output
  • Functions
  • Calling C/C++ code from JavaScript
  • Objects with Inheritance (not fully implemented)

Please see CodeExamples for examples of code that works...

For a list of known issues, please see the comments at the top of the TinyJS.cpp file, as well as the GitHub issues

There is also the 42tiny-js branch - this is maintained by Armin and provides a more full-featured JavaScript implementation than GitHub master.

TinyJS is released under an MIT licence.

Internal Structure

TinyJS uses a Recursive Descent Parser, so there is no 'Parser Generator' required. It does not compile to an intermediate code, and instead executes directly from source code. This makes it quite fast for code that is executed infrequently, and slow for loops.

Variables, Arrays and Objects are stored in a simple linked list tree structure (42tiny-js uses a C++ Map). This is simple, but relatively slow for large structures or arrays.

JavaScript for Microcontrollers

If you're after JavaScript for Microcontrollers, take a look at the Espruino JavaScript Interpreter - it is a complete re-write of TinyJS targeted at processors with extremely low RAM (8kb or more). It is currently available for a range of STM32 ARM Microcontrollers, including two boards that have it pre-installed.

More Repositories

1

ThinGallery

A single-file web gallery. Uses EXIF thumbnails to quickly display thumbnails for a directory with no server-side code
HTML
97
star
2

svgtoeagle

Online SVG to Eagle CAD converter
JavaScript
85
star
3

HeartRate

An online heart-rate monitor using getUserMedia
HTML
64
star
4

EspruinoCompiler

Node.js-based JavaScript->C++ compiler
JavaScript
25
star
5

tinycc

Property hacked up version of the Tiny C Compiler with basic ARM Thumb output
C
25
star
6

workshop-nodeconfeu2019

Bangle.js Workshop for NodeConf EU 2019
20
star
7

EspruinoSerialTerminal

A Simple Web-Based Serial Terminal for writing Espruino code
JavaScript
12
star
8

MakeTomatoes

Tomato Waterer Web Bluetooth interface (and JS code)
JavaScript
11
star
9

SingleFileSlideshow

A single-file slideshow that runs in a web browser and can be used on a Web Server without server-side scripting
10
star
10

PainRun

3D 'Death-run' style WebGL game
JavaScript
9
star
11

MQTToBLE

This repo contains a set of tools that you can use to set up a simple, scalable, MQTT over BLE implementation
JavaScript
6
star
12

workshop-thingy52

Web Bluetooth Workshop for Espruino and Nordic Thingy:52
Shell
5
star
13

RadioReceiver

Using a 433Mhz receiver, audio jack, and a webpage to gather data from wireless sensors
JavaScript
5
star
14

videomaker.js

A streaming MPEG4 encoder in JavaScript
JavaScript
4
star
15

heatshrink-js

An Emscripten port of the [heatshrink compression library](https://github.com/atomicobject/heatshrink) to JS
C
4
star
16

workshop-nodeconfeu2018

Bluetooth Workshop for Nodeconf EU 2018
JavaScript
1
star
17

WebThrust

browser-based multiplayer+physics version of Thrust
JavaScript
1
star
18

RenderHack

Render conf hack evening sample code
JavaScript
1
star
19

DfuFlasher

Tool for automatically flashing Nordic DFU devices
JavaScript
1
star
20

gfwilliams.github.io

JavaScript
1
star
21

EspruinoHRMTestHarness

Bangle.js Heart rate monitor test harness
C
1
star