Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ECMAScript-262 implementation in C?

Possible duplicate: Tiny javascript implementation?

I have searched around for a C implementation of Javascript, but I couldn't find one. I need this for an ultra-portable application that will run on platforms without a C++ compiler.

Here are my requirements:

  • ANSI C (C89 compatible if possible)
  • Minimal dependencies
  • Embeddable (not stand-alone)
  • Open Source (GPL v2 compatible)

I don't care about speed, but correctness is an issue. I would prefer for it to support ECMAScript-262 v5, but v3 is good enough for now.

Does something like this exist? If not, are there any implementations that would be relatively simple to port?

DMDScript is the simplest that I've found, so I may end up porting that. Apparently there is no reference implementation, so this may be the best way to go.

Note:

I also found tiny-js, which is meant to be small and simple, but it doesn't seem to be standards compliant. It is actively developed it seems...

like image 500
beatgammit Avatar asked Jan 28 '13 18:01

beatgammit


2 Answers

Spidermonkey 1.8.0 RC1 and the previous releases are in C. You can use that.

They introduced C++ in their latest release as of 11 Feb 2013 in 1.8.5 release

like image 73
rahulg Avatar answered Sep 22 '22 01:09

rahulg


The SpiderMonkey wiki claims it is C/C++, however, from looking at the source package, it seems to be pure C actually.

The official download link is http://ftp.mozilla.org/pub/mozilla.org/js/js-1.8.0-rc1.tar.gz

If that doesn't turn out to be pure C, try the older versions. Their FTP (http://ftp.mozilla.org/pub/mozilla.org/js/) currently hosts spidermonkey 1.8.5 down to 1.4, and Rhino 1.7 down to 1.4.

The documentation for Spidermonkey API seems good as well.

like image 30
John Dvorak Avatar answered Sep 21 '22 01:09

John Dvorak