as2js: Main Page

as2js  0.1.14
AlexScript to JavaScript
as2js Documentation

The idea of creating the as2js project was born from the time I worked on my ActionScript compiler for my sswf project, a library to create Flash animations.

While working with ActionScript, I learned that it would be "easy" to write a JavaScript compiler that would support classes and other advance declarations that JavaScript does not support.

Today, I am bringing this to life by working on the as2js project:

AlexScript to JavaScript.

So... how does it work? I have better documentation online on how to use the compiler itself (the as2js command line tool.) Here I mainly document the as2js library. This library can directly be used by your project instead of the as2js command line tool. Hence, allowing you do everything in memory!

At time of writing, I do not have a complete compiler so I cannot give a full example on how to use the library, but the as2js command line tool will show you how it gets done. Also, the numerous tests can be reviewed to see how things work and make use of some of that code in your own project.

The following should be close to what you'd want to do:

class message_callback : public as2js::MessageCallback
{
virtual void output(as2js::message_level_t message_level, as2js::err_code_t error_code, as2js::Position const& pos, std::string const& message)
{
... output message ...
}
} message_handler;
if(in.open("script.js"))
{
opt->set_option(as2js::Options::OPTION_STRICT, 1);
as2js::Node::pointer_t root(p->parse());
{
c->set_options(opt);
if(c->compile(root) == 0)
{
... assemble (not implemented yet) ...
}
}
}

The result is JavaScript code that any browser is capable of running, assuming your own code does not use features not available in a browser, of course...

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.

Syndicate content

Snap! Websites
An Open Source CMS System in C++

Contact Us Directly