ECMA262 (Javascript) interpreter

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

ECMA262 (Javascript) interpreter

Fabian Bergmark
I have been implementing an ECMA-262 (Javascript) interpreter over the
last few weeks. I have been following
http://www.ecma-international.org/ecma-262/5.1 and tried to keep my
implementation as close to the specification as possible.

The code can be found here https://github.com/fabianbergmark/ECMA-262

So far I have implemented the core language, but has yet to write all
the specification functions (Array.splice, String.substring etc.).
Before I do this and release it on hackage, I would appreciate
feedback on my implementation.

The issues I see at the time are:

* The parser is slow for deeply nested code
* Strict mode is not implemented
* Interpret.hs is ~ 6k lines
* SubType.hs uses IncoherentInstances, and a better implementation
would be nice. At the moment it works but for one case.

To test the code, install the cabal package and run ecma262 on a .js
file. One host object, console.log is provided and prints to stdout.

Fabian Bergmark
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: ECMA262 (Javascript) interpreter

Andrey Chudnov
1) Does it pass test-262?
2) I see you have implemented your own parser and AST? Have you looked
at the other packages implementing/trying to implement that?

On 12/07/2014 12:48 AM, Fabian Bergmark wrote:

> I have been implementing an ECMA-262 (Javascript) interpreter over the
> last few weeks. I have been following
> http://www.ecma-international.org/ecma-262/5.1 and tried to keep my
> implementation as close to the specification as possible.
>
> The code can be found here https://github.com/fabianbergmark/ECMA-262
>
> So far I have implemented the core language, but has yet to write all
> the specification functions (Array.splice, String.substring etc.).
> Before I do this and release it on hackage, I would appreciate
> feedback on my implementation.
>
> The issues I see at the time are:
>
> * The parser is slow for deeply nested code
> * Strict mode is not implemented
> * Interpret.hs is ~ 6k lines
> * SubType.hs uses IncoherentInstances, and a better implementation
> would be nice. At the moment it works but for one case.
>
> To test the code, install the cabal package and run ecma262 on a .js
> file. One host object, console.log is provided and prints to stdout.
>
> Fabian Bergmark
> _______________________________________________
> Haskell-Cafe mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: ECMA262 (Javascript) interpreter

Fabian Bergmark
I based my work on HJS, but realized that it deviated to much from the
specification for me to patch it with the features I want.

Im aware of the test-262 test suit and have used it to do some casual
testing. Before I release my package to hackage I will make sure it
passes

2014-12-07 16:23 GMT+10:00 Andrey Chudnov <[hidden email]>:

> 1) Does it pass test-262?
> 2) I see you have implemented your own parser and AST? Have you looked at
> the other packages implementing/trying to implement that?
>
>
> On 12/07/2014 12:48 AM, Fabian Bergmark wrote:
>>
>> I have been implementing an ECMA-262 (Javascript) interpreter over the
>> last few weeks. I have been following
>> http://www.ecma-international.org/ecma-262/5.1 and tried to keep my
>> implementation as close to the specification as possible.
>>
>> The code can be found here https://github.com/fabianbergmark/ECMA-262
>>
>> So far I have implemented the core language, but has yet to write all
>> the specification functions (Array.splice, String.substring etc.).
>> Before I do this and release it on hackage, I would appreciate
>> feedback on my implementation.
>>
>> The issues I see at the time are:
>>
>> * The parser is slow for deeply nested code
>> * Strict mode is not implemented
>> * Interpret.hs is ~ 6k lines
>> * SubType.hs uses IncoherentInstances, and a better implementation
>> would be nice. At the moment it works but for one case.
>>
>> To test the code, install the cabal package and run ecma262 on a .js
>> file. One host object, console.log is provided and prints to stdout.
>>
>> Fabian Bergmark
>> _______________________________________________
>> Haskell-Cafe mailing list
>> [hidden email]
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: ECMA262 (Javascript) interpreter

Tobias Dammers
In reply to this post by Fabian Bergmark
I'm kind of fiddling with solving the same (almost) problem, but since
you seem to have done most of the heavy lifting already, I'd like to
know whether your implementation could fit my needs.

Specifically, my use case is that I want to use JavaScript as a
scripting language for a host application written in Haskell; this could
be a game, or a CMS/blogging platform, or anything else that needs
scripting; one of the must-have requirements is to parametrize the
interpreter over arbitrary monads, such that it can be sandboxed into
whatever monad stack you need to script over.

On Sun, Dec 07, 2014 at 03:48:47PM +1000, Fabian Bergmark wrote:

> I have been implementing an ECMA-262 (Javascript) interpreter over the
> last few weeks. I have been following
> http://www.ecma-international.org/ecma-262/5.1 and tried to keep my
> implementation as close to the specification as possible.
>
> The code can be found here https://github.com/fabianbergmark/ECMA-262
>
> So far I have implemented the core language, but has yet to write all
> the specification functions (Array.splice, String.substring etc.).
> Before I do this and release it on hackage, I would appreciate
> feedback on my implementation.
>
> The issues I see at the time are:
>
> * The parser is slow for deeply nested code
> * Strict mode is not implemented
> * Interpret.hs is ~ 6k lines
> * SubType.hs uses IncoherentInstances, and a better implementation
> would be nice. At the moment it works but for one case.
>
> To test the code, install the cabal package and run ecma262 on a .js
> file. One host object, console.log is provided and prints to stdout.
>
> Fabian Bergmark
> _______________________________________________
> Haskell-Cafe mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-cafe

--
Tobias Dammers - [hidden email] - 070-3457628 - www.twokings.nl
Maandag t/m donderdag van 9.00 tot 17.30
Voor dringende vragen, mail naar [hidden email]
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: ECMA262 (Javascript) interpreter

Fabian Bergmark
Yes I wrote my interpreter to support just this. In my use case the
host objects execute Haskell code in a monad YQLM (StateT YQL IO) and
this works fine.

2014-12-08 22:59 GMT+10:00 Tobias Dammers <[hidden email]>:

> I'm kind of fiddling with solving the same (almost) problem, but since
> you seem to have done most of the heavy lifting already, I'd like to
> know whether your implementation could fit my needs.
>
> Specifically, my use case is that I want to use JavaScript as a
> scripting language for a host application written in Haskell; this could
> be a game, or a CMS/blogging platform, or anything else that needs
> scripting; one of the must-have requirements is to parametrize the
> interpreter over arbitrary monads, such that it can be sandboxed into
> whatever monad stack you need to script over.
>
> On Sun, Dec 07, 2014 at 03:48:47PM +1000, Fabian Bergmark wrote:
>> I have been implementing an ECMA-262 (Javascript) interpreter over the
>> last few weeks. I have been following
>> http://www.ecma-international.org/ecma-262/5.1 and tried to keep my
>> implementation as close to the specification as possible.
>>
>> The code can be found here https://github.com/fabianbergmark/ECMA-262
>>
>> So far I have implemented the core language, but has yet to write all
>> the specification functions (Array.splice, String.substring etc.).
>> Before I do this and release it on hackage, I would appreciate
>> feedback on my implementation.
>>
>> The issues I see at the time are:
>>
>> * The parser is slow for deeply nested code
>> * Strict mode is not implemented
>> * Interpret.hs is ~ 6k lines
>> * SubType.hs uses IncoherentInstances, and a better implementation
>> would be nice. At the moment it works but for one case.
>>
>> To test the code, install the cabal package and run ecma262 on a .js
>> file. One host object, console.log is provided and prints to stdout.
>>
>> Fabian Bergmark
>> _______________________________________________
>> Haskell-Cafe mailing list
>> [hidden email]
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
> --
> Tobias Dammers - [hidden email] - 070-3457628 - www.twokings.nl
> Maandag t/m donderdag van 9.00 tot 17.30
> Voor dringende vragen, mail naar [hidden email]
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: ECMA262 (Javascript) interpreter

Wojtek Narczyński
In reply to this post by Fabian Bergmark
On 07.12.2014 06:48, Fabian Bergmark wrote:
> I have been implementing an ECMA-262 (Javascript) interpreter over the
> last few weeks. I have been following
> http://www.ecma-international.org/ecma-262/5.1 and tried to keep my
> implementation as close to the specification as possible.
>
Have you seen http://www.jscert.org/? It is JavaScript formal
specification (JSCert) and interpreter (JSRef), written in Coq, with
certain properties proven. If your goal is correctness, then it might be
of interest to you.

--
Wojtek
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: ECMA262 (Javascript) interpreter

Tobias Dammers
In reply to this post by Fabian Bergmark
Hi again;

I took a short look, and I think this looks like a promising candidate.
The things I'd miss the most at this point would be: one, splitting the
project up into a library and a CLI interpreter, so that it can be
embedded into a Haskell host application without further ado; two,
putting it on hackage (minor concern right now, but if at any time I
choose to publish my project, I don't want to depend on anything that's
not readily available through cabal); and three, a tiny bit more
documentation, or even just a few usage examples.

I'd be willing to help out with either if you're interested.

Cheers,

Tobias

On Sun, Dec 07, 2014 at 03:48:47PM +1000, Fabian Bergmark wrote:

> I have been implementing an ECMA-262 (Javascript) interpreter over the
> last few weeks. I have been following
> http://www.ecma-international.org/ecma-262/5.1 and tried to keep my
> implementation as close to the specification as possible.
>
> The code can be found here https://github.com/fabianbergmark/ECMA-262
>
> So far I have implemented the core language, but has yet to write all
> the specification functions (Array.splice, String.substring etc.).
> Before I do this and release it on hackage, I would appreciate
> feedback on my implementation.
>
> The issues I see at the time are:
>
> * The parser is slow for deeply nested code
> * Strict mode is not implemented
> * Interpret.hs is ~ 6k lines
> * SubType.hs uses IncoherentInstances, and a better implementation
> would be nice. At the moment it works but for one case.
>
> To test the code, install the cabal package and run ecma262 on a .js
> file. One host object, console.log is provided and prints to stdout.
>
> Fabian Bergmark
> _______________________________________________
> Haskell-Cafe mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: ECMA262 (Javascript) interpreter

Fabian Bergmark
The package is available on hackage. I think its a good idea to split the cli into a separate package, ecma262-cli. I will update the documentation in the next version.

If anyone would like to help me implement all the spec functions we could release a version 1 soon.

lördag 3 januari 2015 skrev Tobias Dammers <[hidden email]>:
Hi again;

I took a short look, and I think this looks like a promising candidate.
The things I'd miss the most at this point would be: one, splitting the
project up into a library and a CLI interpreter, so that it can be
embedded into a Haskell host application without further ado; two,
putting it on hackage (minor concern right now, but if at any time I
choose to publish my project, I don't want to depend on anything that's
not readily available through cabal); and three, a tiny bit more
documentation, or even just a few usage examples.

I'd be willing to help out with either if you're interested.

Cheers,

Tobias

On Sun, Dec 07, 2014 at 03:48:47PM +1000, Fabian Bergmark wrote:
> I have been implementing an ECMA-262 (Javascript) interpreter over the
> last few weeks. I have been following
> http://www.ecma-international.org/ecma-262/5.1 and tried to keep my
> implementation as close to the specification as possible.
>
> The code can be found here https://github.com/fabianbergmark/ECMA-262
>
> So far I have implemented the core language, but has yet to write all
> the specification functions (Array.splice, String.substring etc.).
> Before I do this and release it on hackage, I would appreciate
> feedback on my implementation.
>
> The issues I see at the time are:
>
> * The parser is slow for deeply nested code
> * Strict mode is not implemented
> * Interpret.hs is ~ 6k lines
> * SubType.hs uses IncoherentInstances, and a better implementation
> would be nice. At the moment it works but for one case.
>
> To test the code, install the cabal package and run ecma262 on a .js
> file. One host object, console.log is provided and prints to stdout.
>
> Fabian Bergmark
> _______________________________________________
> Haskell-Cafe mailing list
> <a href="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;Haskell-Cafe@haskell.org&#39;)">Haskell-Cafe@...
> http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________
Haskell-Cafe mailing list
<a href="javascript:;" onclick="_e(event, &#39;cvml&#39;, &#39;Haskell-Cafe@haskell.org&#39;)">Haskell-Cafe@...
http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe